MCPcopy Create free account
hub / github.com/TheRealMJP/DeferredTexturing / RenderClusters

Method RenderClusters

BindlessDeferred/BindlessDeferred.cpp:1268–1418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1266}
1267
1268void BindlessDeferred::RenderClusters()
1269{
1270 ID3D12GraphicsCommandList* cmdList = DX12::CmdList;
1271
1272 PIXMarker marker(cmdList, "Cluster Update");
1273 ProfileBlock profileBlock(cmdList, "Cluster Update");
1274
1275 decalClusterBuffer.MakeWritable(cmdList);
1276 spotLightClusterBuffer.MakeWritable(cmdList);
1277
1278 if(AppSettings::RenderDecals)
1279 {
1280 // Clear decal clusters
1281 D3D12_CPU_DESCRIPTOR_HANDLE cpuDescriptors[1] = { decalClusterBuffer.UAV() };
1282 DescriptorHandle gpuHandle = DX12::MakeDescriptorTable(ArraySize_(cpuDescriptors), cpuDescriptors);
1283
1284 uint32 values[4] = { };
1285 cmdList->ClearUnorderedAccessViewUint(gpuHandle.GPUHandle, cpuDescriptors[0], decalClusterBuffer.InternalBuffer.Resource, values, 0, nullptr);
1286 }
1287
1288 if(AppSettings::RenderLights)
1289 {
1290 // Clear spot light clusters
1291 D3D12_CPU_DESCRIPTOR_HANDLE cpuDescriptors[1] = { spotLightClusterBuffer.UAV() };
1292 DescriptorHandle gpuHandle = DX12::MakeDescriptorTable(ArraySize_(cpuDescriptors), cpuDescriptors);
1293
1294 uint32 values[4] = { };
1295 cmdList->ClearUnorderedAccessViewUint(gpuHandle.GPUHandle, cpuDescriptors[0], spotLightClusterBuffer.InternalBuffer.Resource, values, 0, nullptr);
1296 }
1297
1298 clusterConstants.Data.ViewProjection = camera.ViewProjectionMatrix();
1299 clusterConstants.Data.InvProjection = Float4x4::Invert(camera.ProjectionMatrix());
1300 clusterConstants.Data.NearClip = camera.NearClip();
1301 clusterConstants.Data.FarClip = camera.FarClip();
1302 clusterConstants.Data.InvClipRange = 1.0f / (camera.FarClip() - camera.NearClip());
1303 clusterConstants.Data.NumXTiles = uint32(AppSettings::NumXTiles);
1304 clusterConstants.Data.NumYTiles = uint32(AppSettings::NumYTiles);
1305 clusterConstants.Data.NumXYTiles = uint32(AppSettings::NumXTiles * AppSettings::NumYTiles);
1306 clusterConstants.Data.InstanceOffset = 0;
1307 clusterConstants.Data.NumLights = Min<uint32>(uint32(spotLights.Size()), AppSettings::MaxLightClamp);
1308 clusterConstants.Data.NumDecals = uint32(Min(numDecals, AppSettings::MaxDecals));
1309
1310 D3D12_CPU_DESCRIPTOR_HANDLE rtvHandles[1] = { clusterMSAATarget.RTV.CPUHandle };
1311 ClusterRasterizationModes rastMode = AppSettings::ClusterRasterizationMode;
1312 if(rastMode == ClusterRasterizationModes::MSAA4x || rastMode == ClusterRasterizationModes::MSAA8x)
1313 cmdList->OMSetRenderTargets(1, rtvHandles, false, nullptr);
1314 else
1315 cmdList->OMSetRenderTargets(0, nullptr, false, nullptr);
1316
1317 DX12::SetViewport(cmdList, AppSettings::NumXTiles, AppSettings::NumYTiles);
1318 cmdList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
1319
1320 cmdList->SetGraphicsRootSignature(clusterRS);
1321
1322 if(AppSettings::RenderDecals)
1323 {
1324 // Update decal clusters
1325 decalClusterBuffer.UAVBarrier(cmdList);

Callers

nothing calls this directly

Calls 14

MakeDescriptorTableFunction · 0.85
MinFunction · 0.85
SetViewportFunction · 0.85
BindCBufferGfxFunction · 0.85
BindShaderResourcesFunction · 0.85
MakeWritableMethod · 0.80
UAVMethod · 0.80
UAVBarrierMethod · 0.80
UploadMethod · 0.80
SetAsGfxRootParameterMethod · 0.80
MakeReadableMethod · 0.80
SizeMethod · 0.45

Tested by

no test coverage detected