Reintroducing type parameters for vertex data
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
import Common;
|
import Common;
|
||||||
import MaterialParameter;
|
import MaterialParameter;
|
||||||
import Scene;
|
import Scene;
|
||||||
|
import LightEnv;
|
||||||
|
|
||||||
//interface IMaterial
|
interface IMaterial
|
||||||
//{
|
{
|
||||||
// associatedtype BRDF: IBRDF;
|
associatedtype BRDF: IBRDF;
|
||||||
// static BRDF prepare(MaterialParameter input);
|
BRDF prepare(MaterialParameter input);
|
||||||
//};
|
};
|
||||||
struct MaterialResources
|
struct MaterialResources
|
||||||
{
|
{
|
||||||
Texture2D textureArray[512];
|
Texture2D textureArray[512];
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Common;
|
|||||||
import VertexData;
|
import VertexData;
|
||||||
import MaterialParameter;
|
import MaterialParameter;
|
||||||
|
|
||||||
struct StaticMeshVertexData
|
struct StaticMeshVertexData : IVertexData
|
||||||
{
|
{
|
||||||
float uint16ToFloat(uint16_t value)
|
float uint16ToFloat(uint16_t value)
|
||||||
{
|
{
|
||||||
@@ -34,5 +34,3 @@ struct StaticMeshVertexData
|
|||||||
StructuredBuffer<uint16_t> color;
|
StructuredBuffer<uint16_t> color;
|
||||||
StructuredBuffer<uint16_t> texCoords[MAX_TEXCOORDS];
|
StructuredBuffer<uint16_t> texCoords[MAX_TEXCOORDS];
|
||||||
};
|
};
|
||||||
layout(set=1)
|
|
||||||
ParameterBlock<StaticMeshVertexData> pVertexData;
|
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ struct VertexInput
|
|||||||
uint instanceId: SV_InstanceID;
|
uint instanceId: SV_InstanceID;
|
||||||
}
|
}
|
||||||
|
|
||||||
//interface IVertexData
|
interface IVertexData
|
||||||
//{
|
{
|
||||||
// VertexAttributes getAttributes(uint index);
|
VertexAttributes getAttributes(uint index);
|
||||||
//};
|
};
|
||||||
|
layout(set = 1)
|
||||||
|
ParameterBlock<IVertexData> pVertexData;
|
||||||
@@ -3,7 +3,7 @@ import MaterialParameter;
|
|||||||
import LightEnv;
|
import LightEnv;
|
||||||
import Scene;
|
import Scene;
|
||||||
import RayTracingData;
|
import RayTracingData;
|
||||||
import StaticMeshVertexData;
|
import VertexData;
|
||||||
import Material;
|
import Material;
|
||||||
import MATERIAL_FILE_NAME;
|
import MATERIAL_FILE_NAME;
|
||||||
|
|
||||||
|
|||||||
@@ -133,7 +133,16 @@ void EnvironmentLoader::import(EnvironmentImportArgs args, PEnvironmentMapAsset
|
|||||||
Gfx::SE_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
Gfx::SE_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||||
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE)},
|
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{
|
URect{
|
||||||
.size = {SOURCE_RESOLUTION, SOURCE_RESOLUTION},
|
.size = {SOURCE_RESOLUTION, SOURCE_RESOLUTION},
|
||||||
.offset = {0, 0},
|
.offset = {0, 0},
|
||||||
|
|||||||
@@ -214,6 +214,7 @@ void RayTracingPass::publishOutputs() {
|
|||||||
.name = "RayGenMiss",
|
.name = "RayGenMiss",
|
||||||
.modules = {"RayGen", "AnyHit", "Miss"},
|
.modules = {"RayGen", "AnyHit", "Miss"},
|
||||||
.entryPoints = {{"raygen", "RayGen"}, {"anyhit", "AnyHit"}, {"miss", "Miss"}},
|
.entryPoints = {{"raygen", "RayGen"}, {"anyhit", "AnyHit"}, {"miss", "Miss"}},
|
||||||
|
.typeParameter = {{"IVertexData", "StaticMeshVertexData"}},
|
||||||
.defines = {{"RAY_TRACING", "1"}},
|
.defines = {{"RAY_TRACING", "1"}},
|
||||||
.rootSignature = pipelineLayout,
|
.rootSignature = pipelineLayout,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ void ShaderCompiler::createShaders(ShaderPermutation permutation, Gfx::OPipeline
|
|||||||
{
|
{
|
||||||
createInfo.dumpIntermediate = true;
|
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.modules.add(permutation.vertexDataName);
|
||||||
//createInfo.dumpIntermediate = true;
|
//createInfo.dumpIntermediate = true;
|
||||||
|
|
||||||
|
|||||||
@@ -344,6 +344,8 @@ void RenderCommand::drawIndexed(uint32 indexCount, uint32 instanceCount, int32 f
|
|||||||
}
|
}
|
||||||
void RenderCommand::drawMesh(uint32 groupX, uint32 groupY, uint32 groupZ) {
|
void RenderCommand::drawMesh(uint32 groupX, uint32 groupY, uint32 groupZ) {
|
||||||
assert(threadId == std::this_thread::get_id());
|
assert(threadId == std::this_thread::get_id());
|
||||||
|
if (groupX * groupY * groupZ == 0) // any dimension is 0
|
||||||
|
return;
|
||||||
vkCmdDrawMeshTasksEXT(handle, groupX, groupY, groupZ);
|
vkCmdDrawMeshTasksEXT(handle, groupX, groupY, groupZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,12 +147,12 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
|
|||||||
// workaround
|
// workaround
|
||||||
if (info.name == "RayGenMiss")
|
if (info.name == "RayGenMiss")
|
||||||
{
|
{
|
||||||
layout->addMapping("pVertexData", 1);
|
|
||||||
layout->addMapping("pScene", 2);
|
layout->addMapping("pScene", 2);
|
||||||
layout->addMapping("pLightEnv", 3);
|
layout->addMapping("pLightEnv", 3);
|
||||||
layout->addMapping("pResources", 4);
|
layout->addMapping("pResources", 4);
|
||||||
layout->addMapping("pRayTracingParams", 5);
|
layout->addMapping("pRayTracingParams", 5);
|
||||||
}
|
}
|
||||||
|
layout->addMapping("pVertexData", 1);
|
||||||
// layout->addMapping("pWaterMaterial", 1);
|
// layout->addMapping("pWaterMaterial", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -159,9 +159,9 @@ void Material::load(ArchiveBuffer& buffer) {
|
|||||||
void Material::compile() {
|
void Material::compile() {
|
||||||
std::ofstream codeStream("./shaders/generated/" + materialName + ".slang");
|
std::ofstream codeStream("./shaders/generated/" + materialName + ".slang");
|
||||||
codeStream << "import MaterialParameter;\n";
|
codeStream << "import MaterialParameter;\n";
|
||||||
codeStream << "import LightEnv;\n";
|
|
||||||
codeStream << "import Material;\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 << "\ttypedef " << brdf.profile << " BRDF;\n";
|
||||||
codeStream << "\tstatic " << brdf.profile << " prepare(MaterialParameter input) {\n";
|
codeStream << "\tstatic " << brdf.profile << " prepare(MaterialParameter input) {\n";
|
||||||
codeStream << "\t\t" << brdf.profile << " result;\n";
|
codeStream << "\t\t" << brdf.profile << " result;\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user