Fixing slang compilation temporarily, renaming vertexfactory

This commit is contained in:
Dynamitos
2020-08-06 00:54:43 +02:00
parent ab4a3b5e23
commit f27859a02c
66 changed files with 1005 additions and 627 deletions
+2
View File
@@ -19,6 +19,8 @@ target_sources(SeeleEngine
SceneRenderPath.cpp
View.h
View.cpp
VertexShaderInput.h
VertexShaderInput.cpp
Window.cpp
Window.h
WindowManager.h
+1 -1
View File
@@ -2,7 +2,7 @@
#include "MinimalEngine.h"
#include "GraphicsResources.h"
#include "Containers/Array.h"
#include "RenderPass/VertexFactory.h"
#include "VertexShaderInput.h"
namespace Seele
{
+29
View File
@@ -8,6 +8,27 @@ static constexpr bool useAsyncCompute = true;
static constexpr bool waitIdleOnSubmit = true;
static constexpr uint32 numFramesBuffered = 3;
enum class MaterialShadingModel
{
Unlit,
DefaultLit,
Subsurface,
PreintegratedSkin,
ClearCoat,
SubsurfaceProfile,
TwoSidedFoliage,
Hair,
Cloth,
Eye,
Max
};
enum class RenderPassType : uint8
{
DepthPrepass,
BasePass
};
typedef uint32_t SeFlags;
typedef uint32_t SeBool32;
typedef uint64_t SeDeviceSize;
@@ -1853,5 +1874,13 @@ enum class QueueType
TRANSFER = 3,
DEDICATED_TRANSFER = 4
};
enum class VertexAttribute
{
POSITION,
TEXCOORD,
NORMAL,
TANGENT,
BITANGENT
};
} // namespace Gfx
} // namespace Seele
+2 -4
View File
@@ -95,12 +95,10 @@ struct IndexBufferCreateInfo
};
struct ShaderCreateInfo
{
std::string code;
//It's possible to input multiple source files for materials or vertexFactories
Array<std::string> shaderCode;
std::string entryPoint;
Array<const char*> typeParameter;
ShaderCreateInfo(const std::string& code)
: code(code)
{}
};
namespace Gfx
+51
View File
@@ -1,10 +1,61 @@
#include "GraphicsResources.h"
#include "Material/MaterialInstance.h"
#include "Material/Material.h"
#include "Graphics.h"
using namespace Seele;
using namespace Seele::Gfx;
std::string getShaderNameFromRenderPassType(Gfx::RenderPassType type)
{
switch (type)
{
case Gfx::RenderPassType::DepthPrepass:
return "DepthPrepass.slang";
case Gfx::RenderPassType::BasePass:
return "ForwardPlus.slang";
default:
return "";
}
}
ShaderMap::ShaderMap()
{
}
ShaderMap::~ShaderMap()
{
}
const ShaderCollection* ShaderMap::findShaders(PermutationId&& id) const
{
for(uint32 i = 0; i < shaders.size(); ++i)
{
if(shaders[i].id == id)
{
return &(shaders[i]);
}
}
return nullptr;
}
ShaderCollection& ShaderMap::createShaders(
PGraphics graphics,
RenderPassType renderPass,
PMaterial material,
PVertexShaderInput vertexInput,
bool bPositionOnly)
{
ShaderCollection& collection = shaders.add();
collection.vertexDeclaration = bPositionOnly ? vertexInput->getPositionDeclaration() : vertexInput->getDeclaration();
ShaderCreateInfo createInfo;
createInfo.entryPoint = "vertexMain";
createInfo.typeParameter = {material->getMaterialName().c_str(), vertexInput->getName().c_str()};
collection.vertexShader = graphics->createVertexShader(createInfo);
return collection;
}
void DescriptorLayout::addDescriptorBinding(uint32 bindingIndex, SeDescriptorType type, uint32 arrayCount)
{
if (descriptorBindings.size() <= bindingIndex)
+76 -3
View File
@@ -2,10 +2,9 @@
#include "GraphicsEnums.h"
#include "Containers/Array.h"
#include "Containers/List.h"
#include "Math/MemCRC.h"
#include "Material/MaterialInstance.h"
#include "GraphicsInitializer.h"
#include "MeshBatch.h"
#include <boost/crc.hpp>
#ifdef _DEBUG
#define ENABLE_VALIDATION
@@ -27,6 +26,10 @@ public:
};
DEFINE_REF(SamplerState);
class Shader
{};
DEFINE_REF(Shader);
class VertexShader
{
public:
@@ -66,6 +69,72 @@ public:
virtual ~FragmentShader() {}
};
DEFINE_REF(FragmentShader);
//Uniquely identifies a permutation of shaders
//using the type parameters used to generate it
struct ShaderPermutation
{
RenderPassType passType;
char vertexInputName[15];
char materialName[16];
//TODO: lightmapping etc
};
//Hashed ShaderPermutation for fast lookup
struct PermutationId
{
uint32 hash;
PermutationId()
{}
PermutationId(ShaderPermutation permutation)
{
boost::crc_32_type result;
result.process_bytes(&permutation, sizeof(ShaderPermutation));
hash = result.checksum();
}
friend inline bool operator==(const PermutationId& lhs, const PermutationId& rhs)
{
return lhs.hash == rhs.hash;
}
friend inline bool operator!=(const PermutationId& lhs, const PermutationId& rhs)
{
return lhs.hash != rhs.hash;
}
friend inline bool operator<(const PermutationId& lhs, const PermutationId& rhs)
{
return lhs.hash < rhs.hash;
}
friend inline bool operator>(const PermutationId& lhs, const PermutationId& rhs)
{
return lhs.hash > rhs.hash;
}
};
struct ShaderCollection
{
PermutationId id;
PVertexDeclaration vertexDeclaration;
PVertexShader vertexShader;
PControlShader controlShader;
PEvaluationShader evalutionShader;
PGeometryShader geometryShader;
PFragmentShader fragmentShader;
};
class ShaderMap
{
public:
ShaderMap();
~ShaderMap();
const ShaderCollection* findShaders(PermutationId&& id) const;
ShaderCollection& createShaders(
PGraphics graphics,
RenderPassType passName,
PMaterial material,
PVertexShaderInput vertexInput,
bool bPositionOnly);
private:
Array<ShaderCollection> shaders;
};
DEFINE_REF(ShaderMap);
class ComputeShader
{
public:
@@ -395,7 +464,11 @@ public:
virtual ~Viewport();
virtual void resize(uint32 newX, uint32 newY) = 0;
virtual void move(uint32 newOffsetX, uint32 newOffsetY) = 0;
inline PWindow getOwner() const {return owner;}
inline uint32 getSizeX() const {return sizeX;}
inline uint32 getSizeY() const {return sizeY;}
inline uint32 getOffsetX() const {return offsetX;}
inline uint32 getOffsetY() const {return offsetY;}
protected:
uint32 sizeX;
uint32 sizeY;
+1 -1
View File
@@ -10,4 +10,4 @@ Mesh::Mesh(MeshDescription description, Gfx::PIndexBuffer indexBuffer)
Mesh::~Mesh()
{
}
}
+25 -15
View File
@@ -1,20 +1,13 @@
#pragma once
#include "GraphicsResources.h"
#include "Material/MaterialAsset.h"
namespace Seele
{
#define MAX_TEX_CHANNELS 4
enum class VertexAttribute
{
POSITION,
TEXCOORD,
NORMAL,
TANGENT,
BITANGENT
};
#define MAX_TEX_CHANNELS 8
struct MeshDescription
{
Array<VertexAttribute> layout;
Array<Gfx::VertexAttribute> layout;
Gfx::PVertexDeclaration declaration;
uint32 getStride() const
{
@@ -27,19 +20,27 @@ struct MeshDescription
{
switch (a)
{
case VertexAttribute::POSITION:
case VertexAttribute::NORMAL:
case VertexAttribute::TANGENT:
case VertexAttribute::BITANGENT:
case Gfx::VertexAttribute::POSITION:
case Gfx::VertexAttribute::NORMAL:
case Gfx::VertexAttribute::TANGENT:
case Gfx::VertexAttribute::BITANGENT:
vertexSize += 3;
break;
case VertexAttribute::TEXCOORD:
case Gfx::VertexAttribute::TEXCOORD:
vertexSize += 2;
break;
}
}
return vertexSize;
}
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int version)
{
ar & layout;
//TODO declaration
}
};
DECLARE_REF(MaterialAsset);
class Mesh
@@ -51,6 +52,15 @@ public:
Gfx::PIndexBuffer indexBuffer;
MeshDescription description;
PMaterialAsset referencedMaterial;
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int version)
{
ar & description;
ar & referencedMaterial->getFullPath();
//TODO:
}
};
DEFINE_REF(Mesh);
} // namespace Seele
+4 -5
View File
@@ -2,11 +2,11 @@
namespace Seele
{
DECLARE_REF(Material);
DECLARE_REF(VertexShaderInput);
DECLARE_NAME_REF(Gfx, VertexBuffer);
DECLARE_NAME_REF(Gfx, IndexBuffer);
DECLARE_NAME_REF(Gfx, UniformBuffer);
DECLARE_REF(Material);
DECLARE_REF(VertexFactory);
struct MeshBatchElement
{
public:
@@ -52,7 +52,7 @@ struct MeshBatch
Gfx::SePrimitiveTopology topology;
PVertexFactory vertexFactory;
PVertexShaderInput vertexInput;
PMaterial material;
@@ -81,11 +81,10 @@ struct MeshBatch
, isBackfaceCullingDisabled(false)
, isCastingShadow(true)
, useWireframe(false)
, vertexFactory(nullptr)
, vertexInput(nullptr)
, material(nullptr)
, topology(Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST)
{
elements.add();
}
};
DECLARE_REF(PrimitiveComponent);
@@ -0,0 +1,91 @@
#include "BasePass.h"
#include "Graphics/Graphics.h"
#include "Graphics/Window.h"
using namespace Seele;
BasePassMeshProcessor::BasePassMeshProcessor(const PScene scene, Gfx::PGraphics graphics, uint8 translucentBasePass)
: MeshProcessor(scene, graphics)
, translucentBasePass(translucentBasePass)
{
}
BasePassMeshProcessor::~BasePassMeshProcessor()
{
}
void BasePassMeshProcessor::addMeshBatch(
const MeshBatch& batch,
const PPrimitiveComponent primitiveComponent,
const Gfx::PRenderPass renderPass,
int32 staticMeshId)
{
const PMaterialAsset material = batch.material;
const Gfx::MaterialShadingModel shadingModel = material->getShadingModel();
const PVertexShaderInput vertexInput = batch.vertexInput;
//TODO query tesselation
const Gfx::ShaderCollection* collection = material->getShaders(Gfx::RenderPassType::BasePass, vertexInput);
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand();
buildMeshDrawCommand(batch,
primitiveComponent,
renderPass,
renderCommand,
material,
collection->vertexShader,
collection->controlShader,
collection->evalutionShader,
collection->geometryShader,
collection->fragmentShader,
false);
renderCommands.add(renderCommand);
}
Array<Gfx::PRenderCommand> BasePassMeshProcessor::getRenderCommands()
{
return renderCommands;
}
void BasePassMeshProcessor::clearCommands()
{
renderCommands.clear();
}
BasePass::BasePass(const PScene scene, Gfx::PGraphics graphics, Gfx::PViewport viewport)
: processor(new BasePassMeshProcessor(scene, graphics, false))
, scene(scene)
, graphics(graphics)
{
Gfx::PRenderTargetAttachment colorAttachment = new Gfx::SwapchainAttachment(viewport->getOwner());
TextureCreateInfo depthBufferInfo;
depthBufferInfo.width = viewport->getSizeX();
depthBufferInfo.height = viewport->getSizeY();
depthBufferInfo.format = Gfx::SE_FORMAT_D32_SFLOAT;
depthBufferInfo.usage = Gfx::SE_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
depthBuffer = graphics->createTexture2D(depthBufferInfo);
Gfx::PRenderTargetAttachment depthAttachment =
new Gfx::RenderTargetAttachment(depthBuffer, Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
Gfx::PRenderTargetLayout layout = new Gfx::RenderTargetLayout(colorAttachment, depthAttachment);
renderPass = graphics->createRenderPass(layout);
}
BasePass::~BasePass()
{
}
void BasePass::render()
{
processor->clearCommands();
graphics->beginRenderPass(renderPass);
for (auto &&primitive : scene->getPrimitives())
{
for (auto &&meshBatch : primitive->staticMeshes)
{
processor->addMeshBatch(meshBatch, primitive, renderPass);
}
}
graphics->executeCommands(processor->getRenderCommands());
graphics->endRenderPass();
}
+27 -3
View File
@@ -1,15 +1,39 @@
#pragma once
#include "MinimalEngine.h"
#include "MeshProcessor.h"
namespace Seele
{
class BasePassMeshProcessor : public MeshProcessor
{
public:
BasePassMeshProcessor(const PScene scene, Gfx::PGraphics graphics, uint8 translucentBasePass);
virtual ~BasePassMeshProcessor();
virtual void addMeshBatch(
const MeshBatch& batch,
const PPrimitiveComponent primitiveComponent,
const Gfx::PRenderPass renderPass,
int32 staticMeshId = -1) override;
Array<Gfx::PRenderCommand> getRenderCommands();
void clearCommands();
private:
Array<Gfx::PRenderCommand> renderCommands;
uint8 translucentBasePass;
};
DEFINE_REF(BasePassMeshProcessor);
class BasePass
{
public:
BasePass();
BasePass(const PScene scene, Gfx::PGraphics graphics, Gfx::PViewport viewport);
~BasePass();
void render();
private:
Gfx::PRenderPass renderPass;
Gfx::PTexture2D depthBuffer;
const PScene scene;
UPBasePassMeshProcessor processor;
Gfx::PGraphics graphics;
};
DEFINE_REF(BasePass);
} // namespace Seele
@@ -5,6 +5,4 @@ target_sources(SeeleEngine
DepthPrepass.h
DepthPrepass.cpp
MeshProcessor.h
MeshProcessor.cpp
VertexFactory.h
VertexFactory.cpp)
MeshProcessor.cpp)
@@ -1,6 +1,6 @@
#include "MeshProcessor.h"
#include "Graphics/Graphics.h"
#include "VertexFactory.h"
#include "Graphics/VertexShaderInput.h"
using namespace Seele;
@@ -28,11 +28,11 @@ void MeshProcessor::buildMeshDrawCommand(
Gfx::PFragmentShader fragmentShader,
bool positionOnly)
{
const PVertexFactory vertexFactory = meshBatch.vertexFactory;
const PVertexShaderInput vertexInput = meshBatch.vertexInput;
GraphicsPipelineCreateInfo pipelineInitializer;
pipelineInitializer.topology = meshBatch.topology;
Gfx::PVertexDeclaration vertexDecl = positionOnly ? vertexFactory->getPositionDeclaration() : vertexFactory->getDeclaration();
Gfx::PVertexDeclaration vertexDecl = positionOnly ? vertexInput->getPositionDeclaration() : vertexInput->getDeclaration();
pipelineInitializer.vertexDeclaration = vertexDecl;
pipelineInitializer.vertexShader = vertexShader;
pipelineInitializer.controlShader = controlShader;
@@ -44,11 +44,11 @@ void MeshProcessor::buildMeshDrawCommand(
VertexInputStreamArray vertexStreams;
if(positionOnly)
{
vertexFactory->getPositionOnlyStream(vertexStreams);
vertexInput->getPositionOnlyStream(vertexStreams);
}
else
{
vertexFactory->getStreams(vertexStreams);
vertexInput->getStreams(vertexStreams);
}
drawCommand->bindVertexBuffer(vertexStreams);
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(pipelineInitializer);
@@ -11,12 +11,13 @@ class MeshProcessor
public:
MeshProcessor(const PScene scene, Gfx::PGraphics graphics);
virtual ~MeshProcessor();
private:
protected:
PScene scene;
Gfx::PGraphics graphics;
virtual void addMeshBatch(
const MeshBatch& meshBatch,
const PPrimitiveComponent primitiveComponent,
const PPrimitiveComponent primitiveComponent,
const Gfx::PRenderPass renderPass,
int32 staticMeshId = -1) = 0;
void buildMeshDrawCommand(
const MeshBatch& meshBatch,
@@ -1,65 +0,0 @@
#include "VertexFactory.h"
#include "Graphics/Mesh.h"
#include <memory>
using namespace Seele;
List<PVertexFactory> VertexFactory::registeredVertexFactories;
std::mutex VertexFactory::registeredVertexFactoryLock;
VertexFactory::VertexFactory()
{
std::scoped_lock lock(registeredVertexFactoryLock);
registeredVertexFactories.add(this);
}
VertexFactory::VertexFactory(MeshDescription description)
: declaration(description.declaration)
{
auto declStreams = declaration->getVertexStreams();
std::copy(declStreams.begin(), declStreams.end(), streams.begin());
uint32 positionStreamIndex = 0;
positionDeclaration = new Gfx::VertexDeclaration();
for (uint32 i = 0; i < declStreams.size(); i++)
{
if(description.layout[i] == VertexAttribute::POSITION)
{
positionStream[positionStreamIndex++] = declStreams[i];
positionDeclaration->addVertexStream(declStreams[i]);
}
}
std::scoped_lock lock(registeredVertexFactoryLock);
registeredVertexFactories.add(this);
}
VertexFactory::~VertexFactory()
{
registeredVertexFactories.remove(registeredVertexFactories.find(this));
}
void VertexFactory::getStreams(VertexInputStreamArray& outVertexStreams) const
{
for(uint32 i = 0; i < streams.size(); ++i)
{
const Gfx::VertexStream& stream = streams[i];
if(stream.vertexBuffer == nullptr)
{
outVertexStreams.add(VertexInputStream(i, 0, nullptr));
}
else
{
outVertexStreams.add(VertexInputStream(i, stream.offset, stream.vertexBuffer));
}
}
}
void VertexFactory::getPositionOnlyStream(VertexInputStreamArray& outVertexStreams) const
{
for (uint32 i = 0; i < positionStream.size(); ++i)
{
const Gfx::VertexStream& stream = positionStream[i];
outVertexStreams.add(VertexInputStream(i, stream.offset, stream.vertexBuffer));
}
}
+2 -1
View File
@@ -7,6 +7,7 @@ using namespace Seele;
SceneRenderPath::SceneRenderPath(Gfx::PGraphics graphics, Gfx::PViewport target)
: RenderPath(graphics, target)
, basePass(new BasePass(scene, graphics, target))
{
scene = new Scene();
PMeshAsset asset = AssetRegistry::findMesh("Unbenannt");
@@ -35,7 +36,7 @@ void SceneRenderPath::beginFrame()
void SceneRenderPath::render()
{
basePass->render();
}
void SceneRenderPath::endFrame()
+2
View File
@@ -1,5 +1,6 @@
#pragma once
#include "RenderPath.h"
#include "Graphics/RenderPass/BasePass.h"
namespace Seele
{
@@ -17,5 +18,6 @@ public:
protected:
PScene scene;
UPBasePass basePass;
};
} // namespace Seele
+2
View File
@@ -3,6 +3,8 @@
#include "Scene/Scene.h"
#include "Window.h"
using namespace Seele;
Seele::SceneView::SceneView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreateInfo &createInfo)
: View(graphics, owner, createInfo)
{
+69
View File
@@ -0,0 +1,69 @@
#include "VertexShaderInput.h"
#include "Graphics/Mesh.h"
#include <sstream>
#include <memory>
using namespace Seele;
List<PVertexShaderInput> VertexShaderInput::registeredInputs;
std::mutex VertexShaderInput::registeredInputsLock;
VertexShaderInput::VertexShaderInput(std::string name)
: name(name)
{
std::scoped_lock lock(registeredInputsLock);
registeredInputs.add(this);
}
VertexShaderInput::VertexShaderInput(MeshDescription description, std::string name)
: declaration(description.declaration)
, layout(description.layout)
, name(name)
{
auto declStreams = declaration->getVertexStreams();
std::copy(declStreams.begin(), declStreams.end(), streams.begin());
uint32 positionStreamIndex = 0;
positionDeclaration = new Gfx::VertexDeclaration();
for (uint32 i = 0; i < declStreams.size(); i++)
{
if(description.layout[i] == Gfx::VertexAttribute::POSITION)
{
positionStreams[positionStreamIndex++] = declStreams[i];
positionDeclaration->addVertexStream(declStreams[i]);
}
}
std::scoped_lock lock(registeredInputsLock);
registeredInputs.add(this);
}
VertexShaderInput::~VertexShaderInput()
{
registeredInputs.remove(registeredInputs.find(this));
}
void VertexShaderInput::getStreams(VertexInputStreamArray& outVertexStreams) const
{
for(uint32 i = 0; i < streams.size(); ++i)
{
const Gfx::VertexStream& stream = streams[i];
if(stream.vertexBuffer == nullptr)
{
outVertexStreams.add(VertexInputStream(i, 0, nullptr));
}
else
{
outVertexStreams.add(VertexInputStream(i, stream.offset, stream.vertexBuffer));
}
}
}
void VertexShaderInput::getPositionOnlyStream(VertexInputStreamArray& outVertexStreams) const
{
for (uint32 i = 0; i < positionStreams.size(); ++i)
{
const Gfx::VertexStream& stream = positionStreams[i];
outVertexStreams.add(VertexInputStream(i, stream.offset, stream.vertexBuffer));
}
}
@@ -1,6 +1,7 @@
#pragma once
#include "MinimalEngine.h"
#include "Graphics/GraphicsResources.h"
#include "GraphicsEnums.h"
#include "GraphicsResources.h"
namespace Seele
{
@@ -35,62 +36,32 @@ struct VertexInputStream
}
};
/*struct VertexStreamComponent
{
const Gfx::PVertexBuffer vertexBuffer = nullptr;
uint32 streamOffset = 0;
uint8 offset = 0;
uint8 stride;
Gfx::SeFormat type;
VertexStreamComponent()
{
}
VertexStreamComponent(const Gfx::PVertexBuffer vertexBuffer, uint32 offset, uint32 stride, Gfx::SeFormat type)
: vertexBuffer(vertexBuffer)
, streamOffset(0)
, offset(offset)
, stride(stride)
, type(type)
{
}
VertexStreamComponent(const Gfx::PVertexBuffer vertexBuffer, uint32 streamOffset, uint32 offset, uint32 stride, Gfx::SeFormat type)
: vertexBuffer(vertexBuffer)
, streamOffset(streamOffset)
, offset(offset)
, stride(stride)
, type(type)
{
}
};*/
typedef Array<VertexInputStream> VertexInputStreamArray;
struct MeshDescription;
DECLARE_REF(VertexFactory);
class VertexFactory
DECLARE_REF(VertexShaderInput);
class VertexShaderInput
{
public:
VertexFactory();
VertexFactory(MeshDescription description);
~VertexFactory();
VertexShaderInput(std::string name);
VertexShaderInput(MeshDescription description, std::string name);
~VertexShaderInput();
void getStreams(VertexInputStreamArray& outVertexStreams) const;
void getPositionOnlyStream(VertexInputStreamArray& outVertexStreams) const;
virtual bool supportsTesselation() { return false; }
Gfx::PVertexDeclaration getDeclaration() const {return declaration;}
Gfx::PVertexDeclaration getPositionDeclaration() const {return positionDeclaration;}
std::string getName() const { return name; }
std::string getCode() const { return code; }
private:
static List<PVertexFactory> registeredVertexFactories;
static std::mutex registeredVertexFactoryLock;
static List<PVertexShaderInput> registeredInputs;
static std::mutex registeredInputsLock;
Array<Gfx::VertexAttribute> layout;
StaticArray<Gfx::VertexStream, 16> streams;
StaticArray<Gfx::VertexStream, 16> positionStream;
StaticArray<Gfx::VertexStream, 16> positionStreams;
Gfx::PVertexDeclaration declaration;
Gfx::PVertexDeclaration positionDeclaration;
std::string name;
std::string code;
};
DEFINE_REF(VertexFactory);
DEFINE_REF(VertexShaderInput);
} // namespace Seele
@@ -1,7 +1,6 @@
#include "VulkanAllocator.h"
#include "VulkanGraphics.h"
#include "VulkanInitializer.h"
#include "Math/MemCRC.h"
using namespace Seele::Vulkan;
@@ -69,7 +69,9 @@ void PipelineLayout::create()
createInfo.pPushConstantRanges = vkPushConstants.data();
VK_CHECK(vkCreatePipelineLayout(graphics->getDevice(), &createInfo, nullptr, &layoutHandle));
layoutHash = memCrc32(&createInfo, sizeof(VkPipelineLayoutCreateInfo), 0);
boost::crc_32_type result;
result.process_bytes(&createInfo, sizeof(VkPipelineLayoutCreateInfo));
layoutHash = result.checksum();
}
void PipelineLayout::reset()
@@ -41,7 +41,9 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::PRende
1);
VK_CHECK(vkCreateFramebuffer(graphics->getDevice(), &createInfo, nullptr, &handle));
hash = memCrc32(&description, sizeof(FramebufferDescription));
boost::crc_32_type result;
result.process_bytes(&description, sizeof(FramebufferDescription));
hash = result.checksum();
}
Framebuffer::~Framebuffer()
@@ -1,6 +1,7 @@
#pragma once
#include "Graphics/GraphicsEnums.h"
#include <vulkan/vulkan.h>
#include <iostream>
#define VK_CHECK(f) \
{ \
@@ -124,5 +124,7 @@ uint32 RenderPass::getFramebufferHash()
PTexture2D tex = layout->depthAttachment->getTexture().cast<Texture2D>();
description.depthAttachment = tex->getView();
}
return memCrc32(&description, sizeof(FramebufferDescription));
boost::crc_32_type result;
result.process_bytes(&description, sizeof(FramebufferDescription));
return result.checksum();
}
+9 -6
View File
@@ -58,12 +58,15 @@ void Shader::create(const ShaderCreateInfo& createInfo)
int translationUnitIndex = spAddTranslationUnit(request, SLANG_SOURCE_LANGUAGE_SLANG, "");
spAddTranslationUnitSourceString(
request,
translationUnitIndex,
entryPointName.c_str(),
createInfo.code.c_str()
);
for(auto code : createInfo.shaderCode)
{
spAddTranslationUnitSourceString(
request,
translationUnitIndex,
entryPointName.c_str(),
code.data()
);
}
spAddSearchPath(request, "shaders/lib/");
spSetGlobalGenericArgs(request, createInfo.typeParameter.size(), createInfo.typeParameter.data());