Fixing shader refactor
This commit is contained in:
@@ -28,13 +28,13 @@ void meshMain(
|
||||
InstanceData inst = pScene.instances[meshPayload.instanceId];
|
||||
MeshletDescription m = pScene.meshletInfos[meshPayload.meshletOffset + meshletNumber];
|
||||
MeshletCullingInfo cull = pScene.cullingInfos[meshletId];
|
||||
SetMeshOutputCounts(m.vertexCount, m.primitiveCount);
|
||||
SetMeshOutputCounts(m.vertexIndices.size, m.primitiveIndices.size);
|
||||
|
||||
for(uint i = threadID; i < MAX_PRIMITIVES; i += MESH_GROUP_SIZE)
|
||||
{
|
||||
uint p = min(i, m.primitiveCount - 1);
|
||||
uint p = min(i, m.primitiveIndices.size - 1);
|
||||
{
|
||||
uint baseIndex = m.primitiveOffset + (p * 3);
|
||||
uint baseIndex = m.primitiveIndices.offset + (p * 3);
|
||||
uint local_idx0 = pScene.primitiveIndices[baseIndex + 0];
|
||||
uint local_idx1 = pScene.primitiveIndices[baseIndex + 1];
|
||||
uint local_idx2 = pScene.primitiveIndices[baseIndex + 2];
|
||||
@@ -48,9 +48,9 @@ void meshMain(
|
||||
}
|
||||
for(uint i = threadID; i < MAX_VERTICES; i += MESH_GROUP_SIZE)
|
||||
{
|
||||
uint v = min(i, m.vertexCount - 1);
|
||||
uint v = min(i, m.vertexIndices.size - 1);
|
||||
{
|
||||
uint vertexIndex = pScene.vertexIndices[m.vertexOffset + v];
|
||||
uint vertexIndex = pScene.vertexIndices[m.vertexIndices.offset + v];
|
||||
VertexAttributes attr = pVertexData.getAttributes(m.indicesOffset + vertexIndex);
|
||||
vertices[v] = attr.getParameter(inst.transformMatrix, inst.inverseTransformMatrix);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ void taskMain(
|
||||
instance = pScene.instances[pOffsets.instanceOffset + groupID];
|
||||
mesh = pScene.meshData[pOffsets.instanceOffset + groupID];
|
||||
p.instanceId = pOffsets.instanceOffset + groupID;
|
||||
p.meshletOffset = mesh.meshletOffset;
|
||||
p.meshletOffset = mesh.meshletRange.offset;
|
||||
p.cullingOffset = pScene.cullingOffsets[p.instanceId];
|
||||
modelViewProjection = mul(pViewParams.viewProjectionMatrix, instance.transformMatrix);
|
||||
float3 origin = viewToModel(instance.inverseTransformMatrix, float4(0, 0, 0, 1)).xyz;
|
||||
@@ -113,7 +113,7 @@ void taskMain(
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (uint i = threadID; i < mesh.numMeshlets; i += TASK_GROUP_SIZE)
|
||||
for (uint i = threadID; i < mesh.meshletRange.size; i += TASK_GROUP_SIZE)
|
||||
{
|
||||
uint m = p.meshletOffset + i;
|
||||
uint cull = p.cullingOffset + i;
|
||||
|
||||
@@ -29,13 +29,13 @@ void meshMain(
|
||||
InstanceData inst = pScene.instances[meshPayload.instanceId];
|
||||
MeshletDescription m = pScene.meshletInfos[meshPayload.meshletOffset + meshletNumber];
|
||||
MeshletCullingInfo cull = pScene.cullingInfos[meshletId];
|
||||
SetMeshOutputCounts(m.vertexCount, m.primitiveCount);
|
||||
SetMeshOutputCounts(m.vertexIndices.size, m.primitiveIndices.size);
|
||||
|
||||
for(uint i = threadID; i < MAX_PRIMITIVES; i += MESH_GROUP_SIZE)
|
||||
{
|
||||
uint p = min(i, m.primitiveCount - 1);
|
||||
uint p = min(i, m.primitiveIndices.size - 1);
|
||||
{
|
||||
uint baseIndex = m.primitiveOffset + (p * 3);
|
||||
uint baseIndex = m.primitiveIndices.offset + (p * 3);
|
||||
uint local_idx0 = pScene.primitiveIndices[baseIndex + 0];
|
||||
uint local_idx1 = pScene.primitiveIndices[baseIndex + 1];
|
||||
uint local_idx2 = pScene.primitiveIndices[baseIndex + 2];
|
||||
@@ -50,9 +50,9 @@ void meshMain(
|
||||
}
|
||||
for(uint i = threadID; i < MAX_VERTICES; i += MESH_GROUP_SIZE)
|
||||
{
|
||||
uint v = min(i, m.vertexCount - 1);
|
||||
uint v = min(i, m.vertexIndices.size - 1);
|
||||
{
|
||||
uint vertexIndex = pScene.vertexIndices[m.vertexOffset + v];
|
||||
uint vertexIndex = pScene.vertexIndices[m.vertexIndices.offset + v];
|
||||
VertexAttributes attr = pVertexData.getAttributes(m.indicesOffset + vertexIndex);
|
||||
vertices[v] = attr.getParameter(inst.transformMatrix, inst.inverseTransformMatrix);
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@ void taskMain(
|
||||
head = 0;
|
||||
mesh = pScene.meshData[pOffsets.instanceOffset + groupID];
|
||||
p.instanceId = pOffsets.instanceOffset + groupID;
|
||||
p.meshletOffset = mesh.meshletOffset;
|
||||
p.meshletOffset = mesh.meshletRange.offset;
|
||||
p.cullingOffset = pScene.cullingOffsets[p.instanceId];
|
||||
}
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
for (uint i = threadID; i < mesh.numMeshlets; i += TASK_GROUP_SIZE)
|
||||
for (uint i = threadID; i < mesh.meshletRange.size; i += TASK_GROUP_SIZE)
|
||||
{
|
||||
uint m = p.meshletOffset + i;
|
||||
uint cull = p.cullingOffset + i;
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
import Bounding;
|
||||
|
||||
struct PoolRange
|
||||
{
|
||||
uint32_t offset;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
struct MeshletDescription
|
||||
{
|
||||
AABB bounding;
|
||||
uint32_t vertexCount;
|
||||
uint32_t primitiveCount;
|
||||
uint32_t vertexOffset;
|
||||
uint32_t primitiveOffset;
|
||||
// range into vertexIndices array
|
||||
PoolRange vertexIndices;
|
||||
// range into primitiveIndices array
|
||||
PoolRange primitiveIndices;
|
||||
float3 color;
|
||||
uint32_t indicesOffset;
|
||||
};
|
||||
@@ -14,10 +20,9 @@ struct MeshletDescription
|
||||
struct MeshData
|
||||
{
|
||||
AABB bounding;
|
||||
uint32_t numMeshlets;
|
||||
uint32_t meshletOffset;
|
||||
uint32_t firstIndex;
|
||||
uint32_t numIndices;
|
||||
PoolRange meshletRange;
|
||||
// offset into the global index buffer
|
||||
PoolRange indicesRange;
|
||||
};
|
||||
|
||||
static const uint32_t MAX_VERTICES = 256;
|
||||
|
||||
@@ -13,9 +13,9 @@ void anyhit(inout RayPayload hitValue, in BuiltInTriangleIntersectionAttributes
|
||||
MeshData m = pScene.meshData[InstanceID()];
|
||||
|
||||
// offset into the index buffer
|
||||
uint indexOffset = m.firstIndex;
|
||||
uint indexOffset = m.indicesRange.offset;
|
||||
// added to indices to reference correct part of global mesh pool
|
||||
uint vertexOffset = pScene.meshletInfos[m.meshletOffset].indicesOffset;
|
||||
uint vertexOffset = pScene.meshletInfos[m.meshletRange.offset].indicesOffset;
|
||||
|
||||
uint vertexIndex0 = vertexOffset + pRayTracingParams.indexBuffer[indexOffset + 3 * PrimitiveIndex() + 0];
|
||||
uint vertexIndex1 = vertexOffset + pRayTracingParams.indexBuffer[indexOffset + 3 * PrimitiveIndex() + 1];
|
||||
|
||||
@@ -90,9 +90,9 @@ void closestHit(inout RayPayload hitValue, in BuiltInTriangleIntersectionAttribu
|
||||
MeshData m = pScene.meshData[InstanceID()];
|
||||
|
||||
// offset into the index buffer
|
||||
uint indexOffset = m.firstIndex;
|
||||
uint indexOffset = m.indicesRange.offset;
|
||||
// added to indices to reference correct part of global mesh pool
|
||||
uint vertexOffset = pScene.meshletInfos[m.meshletOffset].indicesOffset;
|
||||
uint vertexOffset = pScene.meshletInfos[m.meshletRange.offset].indicesOffset;
|
||||
|
||||
uint vertexIndex0 = vertexOffset + pRayTracingParams.indexBuffer[indexOffset + 3 * PrimitiveIndex() + 0];
|
||||
uint vertexIndex1 = vertexOffset + pRayTracingParams.indexBuffer[indexOffset + 3 * PrimitiveIndex() + 1];
|
||||
|
||||
Reference in New Issue
Block a user