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