Reintroducing type parameters for vertex data

This commit is contained in:
Dynamitos
2025-04-11 09:54:09 +02:00
parent dd07aa25fa
commit 5a54530a48
10 changed files with 31 additions and 18 deletions
+6 -5
View File
@@ -1,12 +1,13 @@
import Common;
import MaterialParameter;
import Scene;
import LightEnv;
//interface IMaterial
//{
// associatedtype BRDF: IBRDF;
// static BRDF prepare(MaterialParameter input);
//};
interface IMaterial
{
associatedtype BRDF: IBRDF;
BRDF prepare(MaterialParameter input);
};
struct MaterialResources
{
Texture2D textureArray[512];
+1 -3
View File
@@ -2,7 +2,7 @@ import Common;
import VertexData;
import MaterialParameter;
struct StaticMeshVertexData
struct StaticMeshVertexData : IVertexData
{
float uint16ToFloat(uint16_t value)
{
@@ -34,5 +34,3 @@ struct StaticMeshVertexData
StructuredBuffer<uint16_t> color;
StructuredBuffer<uint16_t> texCoords[MAX_TEXCOORDS];
};
layout(set=1)
ParameterBlock<StaticMeshVertexData> pVertexData;
+6 -4
View File
@@ -6,7 +6,9 @@ struct VertexInput
uint instanceId: SV_InstanceID;
}
//interface IVertexData
//{
// VertexAttributes getAttributes(uint index);
//};
interface IVertexData
{
VertexAttributes getAttributes(uint index);
};
layout(set = 1)
ParameterBlock<IVertexData> pVertexData;
+1 -1
View File
@@ -3,7 +3,7 @@ import MaterialParameter;
import LightEnv;
import Scene;
import RayTracingData;
import StaticMeshVertexData;
import VertexData;
import Material;
import MATERIAL_FILE_NAME;
+10 -1
View File
@@ -133,7 +133,16 @@ void EnvironmentLoader::import(EnvironmentImportArgs args, PEnvironmentMapAsset
Gfx::SE_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE)},
},
{},
{
Gfx::SubPassDependency{
.srcSubpass = 0,
.dstSubpass = ~0U,
.srcStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
.dstStage = Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
.srcAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
.dstAccess = Gfx::SE_ACCESS_SHADER_READ_BIT,
}
},
URect{
.size = {SOURCE_RESOLUTION, SOURCE_RESOLUTION},
.offset = {0, 0},
@@ -214,6 +214,7 @@ void RayTracingPass::publishOutputs() {
.name = "RayGenMiss",
.modules = {"RayGen", "AnyHit", "Miss"},
.entryPoints = {{"raygen", "RayGen"}, {"anyhit", "AnyHit"}, {"miss", "Miss"}},
.typeParameter = {{"IVertexData", "StaticMeshVertexData"}},
.defines = {{"RAY_TRACING", "1"}},
.rootSignature = pipelineLayout,
};
+1 -1
View File
@@ -123,7 +123,7 @@ void ShaderCompiler::createShaders(ShaderPermutation permutation, Gfx::OPipeline
{
createInfo.dumpIntermediate = true;
}
//createInfo.typeParameter.add({Pair<const char*, const char*>("IVertexData", permutation.vertexDataName)});
createInfo.typeParameter.add({Pair<const char*, const char*>("IVertexData", permutation.vertexDataName)});
createInfo.modules.add(permutation.vertexDataName);
//createInfo.dumpIntermediate = true;
+2
View File
@@ -344,6 +344,8 @@ void RenderCommand::drawIndexed(uint32 indexCount, uint32 instanceCount, int32 f
}
void RenderCommand::drawMesh(uint32 groupX, uint32 groupY, uint32 groupZ) {
assert(threadId == std::this_thread::get_id());
if (groupX * groupY * groupZ == 0) // any dimension is 0
return;
vkCmdDrawMeshTasksEXT(handle, groupX, groupY, groupZ);
}
+1 -1
View File
@@ -147,12 +147,12 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
// workaround
if (info.name == "RayGenMiss")
{
layout->addMapping("pVertexData", 1);
layout->addMapping("pScene", 2);
layout->addMapping("pLightEnv", 3);
layout->addMapping("pResources", 4);
layout->addMapping("pRayTracingParams", 5);
}
layout->addMapping("pVertexData", 1);
// layout->addMapping("pWaterMaterial", 1);
}
+2 -2
View File
@@ -159,9 +159,9 @@ void Material::load(ArchiveBuffer& buffer) {
void Material::compile() {
std::ofstream codeStream("./shaders/generated/" + materialName + ".slang");
codeStream << "import MaterialParameter;\n";
codeStream << "import LightEnv;\n";
codeStream << "import Material;\n";
codeStream << "struct Material{\n";
codeStream << "import LightEnv;\n";
codeStream << "struct Material : IMaterial{\n";
codeStream << "\ttypedef " << brdf.profile << " BRDF;\n";
codeStream << "\tstatic " << brdf.profile << " prepare(MaterialParameter input) {\n";
codeStream << "\t\t" << brdf.profile << " result;\n";