MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Render

Method Render

Source/Engine/Renderer/HistogramPass.cpp:26–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24 });
25
26GPUBuffer* HistogramPass::Render(RenderContext& renderContext, GPUTexture* colorBuffer)
27{
28 auto device = GPUDevice::Instance;
29 auto context = device->GetMainContext();
30 if (checkIfSkipPass() || !_isSupported)
31 return nullptr;
32 PROFILE_GPU_CPU("Histogram");
33
34 // Setup constants
35 HistogramData data;
36 const uint32 colorBufferX = colorBuffer->Width();
37 const uint32 colorBufferY = colorBuffer->Height();
38 data.InputSizeX = colorBufferX;
39 data.InputSizeY = colorBufferY;
40 GetHistogramMad(data.HistogramMul, data.HistogramAdd);
41
42 // Update constants
43 const auto shader = _shader->GetShader();
44 const auto cb0 = shader->GetCB(0);
45 context->UpdateCB(cb0, &data);
46 context->BindCB(0, cb0);
47
48 // Clear the histogram buffer
49 context->BindUA(0, _histogramBuffer->View());
50 context->Dispatch(_csClearHistogram, (HISTOGRAM_SIZE + THREADGROUP_SIZE_X - 1) / THREADGROUP_SIZE_X, 1, 1);
51
52 // Generate the histogram
53 context->BindSR(0, colorBuffer);
54 context->BindUA(0, _histogramBuffer->View());
55 context->Dispatch(_csGenerateHistogram, (colorBufferX + THREADGROUP_SIZE_X - 1) / THREADGROUP_SIZE_X, (colorBufferY + THREADGROUP_SIZE_Y - 1) / THREADGROUP_SIZE_Y, 1);
56
57 // Cleanup
58 context->ResetUA();
59 context->ResetSR();
60
61 return _histogramBuffer;
62}
63
64void HistogramPass::GetHistogramMad(float& multiply, float& add)
65{

Callers

nothing calls this directly

Calls 10

GetMainContextMethod · 0.45
GetShaderMethod · 0.45
UpdateCBMethod · 0.45
BindCBMethod · 0.45
BindUAMethod · 0.45
ViewMethod · 0.45
DispatchMethod · 0.45
BindSRMethod · 0.45
ResetUAMethod · 0.45
ResetSRMethod · 0.45

Tested by

no test coverage detected