Adding vertex input description, readding slang
This commit is contained in:
+4
-1
@@ -3,4 +3,7 @@
|
||||
url = https://github.com/d-bahr/CRCpp.git
|
||||
[submodule "external/vcpkg"]
|
||||
path = external/vcpkg
|
||||
url = https://github.com/Microsoft/vcpkg.git
|
||||
url = https://github.com/Microsoft/vcpkg.git
|
||||
[submodule "external/slang"]
|
||||
path = external/slang
|
||||
url = https://github.com/shader-slang/slang.git
|
||||
|
||||
+1
Submodule external/slang added at ec0224edc3
@@ -4,11 +4,10 @@ import MaterialParameter;
|
||||
import Scene;
|
||||
|
||||
[shader("vertex")]
|
||||
FragmentParameter vertexMain(
|
||||
uint vertexId: SV_VertexID,
|
||||
uint instanceId: SV_InstanceID,
|
||||
FragmentParameter vertexMain(
|
||||
VertexInput input
|
||||
){
|
||||
InstanceData inst = pScene.instances[instanceId];
|
||||
VertexAttributes attr = pVertexData.getAttributes(vertexId);
|
||||
InstanceData inst = pScene.instances[input.instanceId];
|
||||
VertexAttributes attr = pVertexData.getAttributes(input.vertexId);
|
||||
return attr.getParameter(inst.transformMatrix);
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
import MaterialParameter;
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
uint vertexId;
|
||||
uint instanceId: SV_InstanceID;
|
||||
}
|
||||
|
||||
interface IVertexData
|
||||
{
|
||||
VertexAttributes getAttributes(uint index);
|
||||
|
||||
@@ -338,7 +338,7 @@ void MeshLoader::import(MeshImportArgs args, PMeshAsset meshAsset)
|
||||
aiProcess_GenUVCoords |
|
||||
aiProcess_FindDegenerates));
|
||||
const aiScene *scene = importer.ApplyPostProcessing(aiProcess_CalcTangentSpace | aiProcess_ImproveCacheLocality);
|
||||
|
||||
|
||||
Array<PMaterialInstanceAsset> globalMaterials(scene->mNumMaterials);
|
||||
loadTextures(scene, args.filePath.parent_path(), args.importPath);
|
||||
loadMaterials(scene, args.filePath.stem().string(), args.filePath.parent_path(), args.importPath, globalMaterials);
|
||||
|
||||
@@ -65,9 +65,6 @@ int main()
|
||||
AssetImporter::importMesh(MeshImportArgs{
|
||||
.filePath= sourcePath / "old_resources/models/cube.fbx",
|
||||
});
|
||||
AssetImporter::importMesh(MeshImportArgs{
|
||||
.filePath = sourcePath / "old_resources/models/sponza/sponza.gltf",
|
||||
});
|
||||
//AssetImporter::importMesh(MeshImportArgs{
|
||||
// .filePath= sourcePath / "old_resources/models/flameThrower.fbx",
|
||||
// });
|
||||
|
||||
@@ -82,6 +82,8 @@ public:
|
||||
virtual ODescriptorLayout createDescriptorLayout(const std::string& name = "") = 0;
|
||||
virtual OPipelineLayout createPipelineLayout(PPipelineLayout baseLayout = nullptr) = 0;
|
||||
|
||||
virtual OVertexInput createVertexInput(VertexInputStateCreateInfo createInfo) = 0;
|
||||
|
||||
virtual void resolveTexture(Gfx::PTexture source, Gfx::PTexture destination) = 0;
|
||||
|
||||
bool supportMeshShading() const { return meshShadingEnabled; }
|
||||
|
||||
@@ -118,7 +118,24 @@ struct ShaderCreateInfo
|
||||
Array<Pair<const char*, const char*>> typeParameter;
|
||||
Map<const char*, const char*> defines;
|
||||
};
|
||||
|
||||
struct VertexInputBinding
|
||||
{
|
||||
uint32 binding;
|
||||
uint32 stride;
|
||||
Gfx::SeVertexInputRate inputRate;
|
||||
};
|
||||
struct VertexInputAttribute
|
||||
{
|
||||
uint32 location;
|
||||
uint32 binding;
|
||||
Gfx::SeFormat format;
|
||||
uint32 offset;
|
||||
};
|
||||
struct VertexInputStateCreateInfo
|
||||
{
|
||||
Array<VertexInputBinding> bindings;
|
||||
Array<VertexInputAttribute> attributes;
|
||||
};
|
||||
namespace Gfx
|
||||
{
|
||||
struct SePushConstantRange
|
||||
@@ -180,6 +197,7 @@ struct ColorBlendState
|
||||
StaticArray<float, 4> blendConstants;
|
||||
};
|
||||
|
||||
DECLARE_REF(VertexInput)
|
||||
DECLARE_REF(VertexShader)
|
||||
DECLARE_REF(TaskShader)
|
||||
DECLARE_REF(MeshShader)
|
||||
@@ -190,6 +208,7 @@ DECLARE_REF(PipelineLayout)
|
||||
struct LegacyPipelineCreateInfo
|
||||
{
|
||||
SePrimitiveTopology topology;
|
||||
PVertexInput vertexInput;
|
||||
PVertexShader vertexShader;
|
||||
PFragmentShader fragmentShader;
|
||||
PRenderPass renderPass;
|
||||
|
||||
@@ -3,6 +3,15 @@
|
||||
using namespace Seele;
|
||||
using namespace Seele::Gfx;
|
||||
|
||||
VertexInput::VertexInput(VertexInputStateCreateInfo createInfo)
|
||||
: createInfo(createInfo)
|
||||
{
|
||||
}
|
||||
|
||||
VertexInput::~VertexInput()
|
||||
{
|
||||
}
|
||||
|
||||
GraphicsPipeline::GraphicsPipeline(OPipelineLayout layout)
|
||||
: layout(std::move(layout))
|
||||
{
|
||||
|
||||
@@ -6,6 +6,15 @@ namespace Seele
|
||||
{
|
||||
namespace Gfx
|
||||
{
|
||||
class VertexInput
|
||||
{
|
||||
public:
|
||||
VertexInput(VertexInputStateCreateInfo createInfo);
|
||||
virtual ~VertexInput();
|
||||
const VertexInputStateCreateInfo& getInfo() const { return createInfo; }
|
||||
private:
|
||||
VertexInputStateCreateInfo createInfo;
|
||||
};
|
||||
class GraphicsPipeline
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -249,6 +249,11 @@ Gfx::OPipelineLayout Graphics::createPipelineLayout(Gfx::PPipelineLayout baseLay
|
||||
return new PipelineLayout(this, baseLayout);
|
||||
}
|
||||
|
||||
Gfx::OVertexInput Graphics::createVertexInput(VertexInputStateCreateInfo createInfo)
|
||||
{
|
||||
return new VertexInput(createInfo);
|
||||
}
|
||||
|
||||
void Graphics::resolveTexture(Gfx::PTexture source, Gfx::PTexture destination)
|
||||
{
|
||||
PTextureBase sourceTex = source.cast<TextureBase>();
|
||||
|
||||
@@ -66,6 +66,8 @@ public:
|
||||
virtual Gfx::ODescriptorLayout createDescriptorLayout(const std::string& name = "") override;
|
||||
virtual Gfx::OPipelineLayout createPipelineLayout(Gfx::PPipelineLayout baseLayout = nullptr) override;
|
||||
|
||||
virtual Gfx::OVertexInput createVertexInput(VertexInputStateCreateInfo createInfo) override;
|
||||
|
||||
virtual void resolveTexture(Gfx::PTexture source, Gfx::PTexture destination) override;
|
||||
|
||||
void vkCmdDrawMeshTasksEXT(VkCommandBuffer handle, uint32 groupX, uint32 groupY, uint32 groupZ);
|
||||
|
||||
@@ -5,6 +5,15 @@
|
||||
using namespace Seele;
|
||||
using namespace Seele::Vulkan;
|
||||
|
||||
VertexInput::VertexInput(VertexInputStateCreateInfo createInfo)
|
||||
: Gfx::VertexInput(createInfo)
|
||||
{
|
||||
}
|
||||
|
||||
VertexInput::~VertexInput()
|
||||
{
|
||||
}
|
||||
|
||||
GraphicsPipeline::GraphicsPipeline(PGraphics graphics, VkPipeline handle, Gfx::OPipelineLayout pipelineLayout)
|
||||
: Gfx::GraphicsPipeline(std::move(pipelineLayout))
|
||||
, graphics(graphics)
|
||||
|
||||
@@ -6,6 +6,13 @@ namespace Seele
|
||||
{
|
||||
namespace Vulkan
|
||||
{
|
||||
class VertexInput : public Gfx::VertexInput
|
||||
{
|
||||
public:
|
||||
VertexInput(VertexInputStateCreateInfo createInfo);
|
||||
virtual ~VertexInput();
|
||||
private:
|
||||
};
|
||||
DECLARE_REF(PipelineLayout)
|
||||
DECLARE_REF(Graphics)
|
||||
class GraphicsPipeline : public Gfx::GraphicsPipeline
|
||||
|
||||
@@ -52,10 +52,36 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gf
|
||||
{
|
||||
PPipelineLayout layout = Gfx::PPipelineLayout(gfxInfo.pipelineLayout).cast<PipelineLayout>();
|
||||
uint32 hash = layout->getHash();
|
||||
const VertexInputStateCreateInfo& vertexInputDesc = gfxInfo.vertexInput->getInfo();
|
||||
Array<VkVertexInputBindingDescription> bindings(vertexInputDesc.bindings.size());
|
||||
Array<VkVertexInputAttributeDescription> attributes(vertexInputDesc.attributes.size());
|
||||
for (size_t i = 0; i < bindings.size(); i++)
|
||||
{
|
||||
bindings[i] = {
|
||||
.binding = vertexInputDesc.bindings[i].binding,
|
||||
.stride = vertexInputDesc.bindings[i].stride,
|
||||
.inputRate = VkVertexInputRate(vertexInputDesc.bindings[i].inputRate),
|
||||
};
|
||||
}
|
||||
for (size_t i = 0; i < attributes.size(); i++)
|
||||
{
|
||||
attributes[i] = {
|
||||
.location = vertexInputDesc.attributes[i].location,
|
||||
.binding = vertexInputDesc.attributes[i].binding,
|
||||
.format = cast(vertexInputDesc.attributes[i].format),
|
||||
.offset = vertexInputDesc.attributes[i].offset,
|
||||
};
|
||||
}
|
||||
hash = CRC::Calculate(bindings.data(), sizeof(VkVertexInputBindingDescription) * bindings.size(), CRC::CRC_32(), hash);
|
||||
hash = CRC::Calculate(attributes.data(), sizeof(VkVertexInputAttributeDescription) * attributes.size(), CRC::CRC_32(), hash);
|
||||
VkPipelineVertexInputStateCreateInfo vertexInput = {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
.flags = 0,
|
||||
.vertexBindingDescriptionCount = (uint32)bindings.size(),
|
||||
.pVertexBindingDescriptions = bindings.data(),
|
||||
.vertexAttributeDescriptionCount = (uint32)attributes.size(),
|
||||
.pVertexAttributeDescriptions = attributes.data(),
|
||||
};
|
||||
uint32 stageCount = 0;
|
||||
|
||||
|
||||
@@ -63,7 +63,6 @@ void Shader::create(const ShaderCreateInfo& createInfo)
|
||||
|
||||
Slang::ComPtr<slang::ISession> session;
|
||||
CHECK_RESULT(globalSession->createSession(sessionDesc, session.writeRef()));
|
||||
|
||||
Slang::ComPtr<slang::IBlob> diagnostics;
|
||||
Array<slang::IComponentType*> modules;
|
||||
Slang::ComPtr<slang::IEntryPoint> entrypoint;
|
||||
|
||||
Reference in New Issue
Block a user