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

Method RenderPicking

BindlessDeferred/BindlessDeferred.cpp:1970–1999  ·  view source on GitHub ↗

Runs a simple compute shader that reads depth + tangent from for a particular pixel, and copies the results to a readback buffer that's used to generate the "cursor" decal

Source from the content-addressed store, hash-verified

1968// Runs a simple compute shader that reads depth + tangent from for a particular pixel, and copies
1969// the results to a readback buffer that's used to generate the "cursor" decal
1970void BindlessDeferred::RenderPicking()
1971{
1972 if(currMouseState.IsOverWindow == false || AppSettings::EnableDecalPicker == false)
1973 return;
1974
1975 ID3D12GraphicsCommandList* cmdList = DX12::CmdList;
1976
1977 PIXMarker pixMarker(cmdList, "Picking");
1978
1979 cmdList->SetPipelineState(AppSettings::MSAAMode != MSAAModes::MSAANone ? pickingPSOs[1] : pickingPSOs[0]);
1980 cmdList->SetComputeRootSignature(pickingRS);
1981
1982 pickingConstants.Data.InverseViewProjection = Float4x4::Invert(camera.ViewProjectionMatrix());
1983 pickingConstants.Data.PixelPos = Uint2(currMouseState.X, currMouseState.Y);
1984 pickingConstants.Data.RTSize.x = float(mainTarget.Width());
1985 pickingConstants.Data.RTSize.y = float(mainTarget.Height());
1986 pickingConstants.Upload();
1987 pickingConstants.SetAsComputeRootParameter(cmdList, 0);
1988
1989 pickingBuffer.MakeWritable(cmdList);
1990
1991 D3D12_CPU_DESCRIPTOR_HANDLE descriptors[3] = { tangentFrameTarget.SRV(), depthBuffer.SRV(), pickingBuffer.UAV() };
1992 DX12::BindShaderResources(cmdList, 1, ArraySize_(descriptors), descriptors, CmdListMode::Compute);
1993
1994 cmdList->Dispatch(1, 1, 1);
1995
1996 pickingBuffer.MakeReadable(cmdList);
1997
1998 cmdList->CopyResource(pickingReadbackBuffers[DX12::CurrFrameIdx].Resource, pickingBuffer.InternalBuffer.Resource);
1999}
2000
2001// Renders the 2D "overhead" visualizer that shows per-cluster light/decal counts
2002void BindlessDeferred::RenderClusterVisualizer()

Callers

nothing calls this directly

Calls 10

Uint2Class · 0.85
BindShaderResourcesFunction · 0.85
UploadMethod · 0.80
MakeWritableMethod · 0.80
UAVMethod · 0.80
MakeReadableMethod · 0.80
WidthMethod · 0.45
HeightMethod · 0.45
SRVMethod · 0.45

Tested by

no test coverage detected