MCPcopy Create free account
hub / github.com/DiligentGraphics/DiligentFX / Render

Method Render

Components/src/CoordinateGridRenderer.cpp:60–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60void CoordinateGridRenderer::Render(const RenderAttributes& RenderAttribs)
61{
62 DEV_CHECK_ERR(RenderAttribs.pDevice != nullptr, "RenderAttribs.pDevice must not be null");
63 DEV_CHECK_ERR(RenderAttribs.pDeviceContext != nullptr, "RenderAttribs.pDeviceContext must not be null");
64 DEV_CHECK_ERR(RenderAttribs.pColorRTV != nullptr, "RenderAttribs.pColorRTV must not be null");
65 DEV_CHECK_ERR(RenderAttribs.pDepthSRV != nullptr, "RenderAttribs.pDepthSRV must not be null");
66
67 m_Resources.Insert(RESOURCE_IDENTIFIER_INPUT_COLOR, RenderAttribs.pColorRTV->GetTexture());
68 m_Resources.Insert(RESOURCE_IDENTIFIER_INPUT_DEPTH, RenderAttribs.pDepthSRV->GetTexture());
69
70 ScopedDebugGroup DebugGroupGlobal{RenderAttribs.pDeviceContext, "CoordinateGridRenderer"};
71
72 if (RenderAttribs.pCameraAttribsCB == nullptr)
73 {
74 DEV_CHECK_ERR(RenderAttribs.pCamera != nullptr, "RenderAttribs.pCurrCamera must not be null");
75
76 if (!m_Resources[RESOURCE_IDENTIFIER_CAMERA_CONSTANT_BUFFER])
77 {
78 RefCntAutoPtr<IBuffer> pBuffer;
79 CreateUniformBuffer(RenderAttribs.pDevice, sizeof(HLSL::CameraAttribs), "CoordinateGridRenderer::CameraAttibsConstantBuffer", &pBuffer);
80 m_Resources.Insert(RESOURCE_IDENTIFIER_CAMERA_CONSTANT_BUFFER, pBuffer);
81 }
82
83 MapHelper<HLSL::CameraAttribs> CameraAttibs{RenderAttribs.pDeviceContext, m_Resources[RESOURCE_IDENTIFIER_CAMERA_CONSTANT_BUFFER], MAP_WRITE, MAP_FLAG_DISCARD};
84 *CameraAttibs = *RenderAttribs.pCamera;
85 }
86 else
87 {
88 m_Resources.Insert(RESOURCE_IDENTIFIER_CAMERA_CONSTANT_BUFFER, RenderAttribs.pCameraAttribsCB);
89 }
90
91 if (memcmp(RenderAttribs.pAttribs, m_pRenderAttribs.get(), sizeof(HLSL::CoordinateGridAttribs)) != 0)
92 {
93 memcpy(m_pRenderAttribs.get(), RenderAttribs.pAttribs, sizeof(HLSL::CoordinateGridAttribs));
94 RenderAttribs.pDeviceContext->UpdateBuffer(m_Resources[RESOURCE_IDENTIFIER_SETTINGS_CONSTANT_BUFFER].AsBuffer(), 0, sizeof(HLSL::CoordinateGridAttribs), RenderAttribs.pAttribs, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
95 }
96
97 RenderGridAxes(RenderAttribs);
98
99 // Release references to input resources
100 for (Uint32 ResourceIdx = 0; ResourceIdx <= RESOURCE_IDENTIFIER_INPUT_LAST; ++ResourceIdx)
101 m_Resources[ResourceIdx].Release();
102}
103
104bool CoordinateGridRenderer::UpdateUI(HLSL::CoordinateGridAttribs& Attribs, CoordinateGridRenderer::FEATURE_FLAGS& FeatureFlags)
105{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected