Bit of shader refactoring
This commit is contained in:
@@ -15,7 +15,7 @@ layout(set=5)
|
||||
ParameterBlock<LightCullingData> pLightCullingData;
|
||||
|
||||
[shader("pixel")]
|
||||
float4 fragmentMain(in FragmentParameter params : PARAMETER) : SV_Target
|
||||
float4 fragmentMain(in FragmentParameter params) : SV_Target
|
||||
{
|
||||
MaterialParameter materialParams = params.getMaterialParameter();
|
||||
LightingParameter lightingParams = params.getLightingParameter();
|
||||
|
||||
@@ -3,21 +3,12 @@ import VertexData;
|
||||
import MaterialParameter;
|
||||
import Scene;
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
FragmentParameter parameter : PARAMETER;
|
||||
float4 clipPos: SV_Position;
|
||||
}
|
||||
|
||||
[shader("vertex")]
|
||||
VertexShaderOutput vertexMain(
|
||||
FragmentParameter vertexMain(
|
||||
uint vertexId: SV_VertexID,
|
||||
uint instanceId: SV_InstanceID,
|
||||
){
|
||||
InstanceData inst = pScene.instances[instanceId];
|
||||
VertexAttributes attr = pVertexData.getAttributes(vertexId, inst.transformMatrix);
|
||||
VertexShaderOutput output;
|
||||
output.parameter = attr.getParameter(inst.transformMatrix);
|
||||
output.clipPos = output.parameter.position_CS;
|
||||
return output;
|
||||
return attr.getParameter(inst.transformMatrix);
|
||||
}
|
||||
@@ -76,8 +76,7 @@ struct PrimitiveAttributes
|
||||
|
||||
struct MeshOutput
|
||||
{
|
||||
FragmentParameter parameter : PARAMETER;
|
||||
float4 position_CS : SV_Position;
|
||||
FragmentParameter parameter;
|
||||
};
|
||||
|
||||
[numthreads(MESH_GROUP_SIZE, 1, 1)]
|
||||
@@ -94,10 +93,9 @@ void meshMain(
|
||||
MeshData md = pScene.meshData[meshPayload.instanceId[groupID]];
|
||||
MeshletDescription m = pScene.meshletInfos[meshPayload.meshletId[groupID]];
|
||||
const uint vertexLoops = (MAX_VERTICES + MESH_GROUP_SIZE - 1) / MESH_GROUP_SIZE;
|
||||
for(uint loop = 0; loop < vertexLoops; ++loop)
|
||||
for(uint i = threadID; i < MAX_VERTICES; i += MESH_GROUP_SIZE)
|
||||
{
|
||||
uint v = threadID + loop * MESH_GROUP_SIZE;
|
||||
v = min(v, m.vertexCount - 1);
|
||||
uint v = min(i, m.vertexCount - 1);
|
||||
InterlockedMax(gs_numVertices, v + 1);
|
||||
{
|
||||
int vertexIndex = pScene.vertexIndices[m.vertexOffset + v];
|
||||
@@ -106,10 +104,9 @@ void meshMain(
|
||||
}
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
const uint primitiveLoops = (MAX_PRIMITIVES + MESH_GROUP_SIZE - 1) / MESH_GROUP_SIZE;
|
||||
for(uint loop = 0; loop < primitiveLoops; ++loop)
|
||||
for(uint i = threadID; i < MAX_PRIMITIVES; i += MESH_GROUP_SIZE)
|
||||
{
|
||||
uint p = threadID + loop * MESH_GROUP_SIZE;
|
||||
p = min(p, m.primitiveCount - 1);
|
||||
uint p = min(i, m.primitiveCount - 1);
|
||||
InterlockedMax(gs_numPrimitives, p + 1);
|
||||
{
|
||||
uint32_t local_idx0 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 0];
|
||||
@@ -128,14 +125,12 @@ void meshMain(
|
||||
v = min(v, m.vertexCount - 1);
|
||||
FragmentParameter parameter = gs_vertices[v].getParameter(inst.transformMatrix);
|
||||
vertices[v].parameter = parameter;
|
||||
vertices[v].position_CS = parameter.position_CS;
|
||||
if(vertexLoops >= 1)
|
||||
{
|
||||
uint v = threadID + MESH_GROUP_SIZE;
|
||||
v = min(v, m.vertexCount - 1);
|
||||
FragmentParameter parameter = gs_vertices[v].getParameter(inst.transformMatrix);
|
||||
vertices[v].parameter = parameter;
|
||||
vertices[v].position_CS = parameter.position_CS;
|
||||
}
|
||||
|
||||
uint p = threadID;
|
||||
|
||||
@@ -2,10 +2,10 @@ import Common;
|
||||
|
||||
struct MaterialParameter
|
||||
{
|
||||
float3 position_TS : POSITION0;
|
||||
float3 position_WS : POSITION1;
|
||||
float2 texCoords : TEXCOORDS0;
|
||||
float3 vertexColor : COLOR0;
|
||||
float3 position_TS;
|
||||
float3 position_WS;
|
||||
float2 texCoords;
|
||||
float3 vertexColor;
|
||||
};
|
||||
|
||||
// data used by light environment
|
||||
|
||||
@@ -11,9 +11,11 @@ struct MeshletDescription
|
||||
|
||||
struct MeshData
|
||||
{
|
||||
uint numMeshlets;
|
||||
uint meshletOffset;
|
||||
uint indicesOffset;
|
||||
uint numMeshlets;
|
||||
uint meshletOffset;
|
||||
uint firstIndex;
|
||||
uint numIndices;
|
||||
uint indicesOffset;
|
||||
};
|
||||
|
||||
static const uint MAX_VERTICES = 64;
|
||||
|
||||
@@ -468,10 +468,7 @@ CommandPool::CommandPool(PGraphics graphics, PQueue queue)
|
||||
|
||||
CommandPool::~CommandPool()
|
||||
{
|
||||
for (auto& command : allocatedBuffers)
|
||||
{
|
||||
command->waitForCommand();
|
||||
}
|
||||
vkDeviceWaitIdle(graphics->getDevice());
|
||||
allocatedRenderCommands.clear();
|
||||
allocatedComputeCommands.clear();
|
||||
allocatedBuffers.clear();
|
||||
|
||||
Reference in New Issue
Block a user