| 239 | } |
| 240 | |
| 241 | void ModelView::Render(nvrhi::ICommandList* commandList, nvrhi::IFramebuffer* framebuffer) |
| 242 | { |
| 243 | if (!m_descriptorsValid) |
| 244 | { |
| 245 | // Need to make sure nothing is being executed while we update the descriptor table. |
| 246 | // This is a rare event, so a WFI is fine. |
| 247 | m_device->waitForIdle(); |
| 248 | |
| 249 | // Write all descriptors, don't bother tracking individual ones - there's only a few. |
| 250 | for (const auto& bindingSetItem : m_descriptors) |
| 251 | { |
| 252 | if (bindingSetItem.type != nvrhi::ResourceType::None) |
| 253 | m_device->writeDescriptorTable(m_descriptorTable, bindingSetItem); |
| 254 | } |
| 255 | |
| 256 | m_descriptorsValid = true; |
| 257 | } |
| 258 | |
| 259 | // Draw the sky in the background |
| 260 | commandList->clearDepthStencilTexture(m_depthBuffer, nvrhi::AllSubresources, true, 1.f, true, 0); |
| 261 | render::SkyParameters skyParameters{}; |
| 262 | skyParameters.brightness = 0.5f; |
| 263 | m_skyPass->Render(commandList, m_view, *m_light, skyParameters); |
| 264 | m_commonPasses->BlitTexture(commandList, framebuffer, m_colorBuffer); |
| 265 | |
| 266 | // Fill the model rendering constants |
| 267 | ModelViewConstants constants{}; |
| 268 | m_view.FillPlanarViewConstants(constants.view); |
| 269 | m_light->FillLightConstants(constants.light); |
| 270 | constants.mipLevel = m_showMipLevel; |
| 271 | constants.skyColor = skyParameters.skyColor * skyParameters.brightness; |
| 272 | constants.groundColor = skyParameters.groundColor * skyParameters.brightness; |
| 273 | constants.decompressedTextureOffset = c_MaxTextures; |
| 274 | // Setup the split-screen variables, reuse that logic to display the decompressed texture only by setting splitPosition to -1. |
| 275 | constants.enableSplitScreen = m_displayMode == DisplayMode::SplitScreen || m_displayMode == DisplayMode::RightTexture; |
| 276 | constants.splitPosition = m_displayMode == DisplayMode::SplitScreen ? m_splitPosition : -1; |
| 277 | constants.convertFromSrgbMask = 0; |
| 278 | for (uint32_t i = 0; i < c_MaxTextures; ++i) |
| 279 | { |
| 280 | if (m_convertFromSRGB[i]) |
| 281 | constants.convertFromSrgbMask |= 1 << i; |
| 282 | } |
| 283 | |
| 284 | const int imageOffset = 0; |
| 285 | constants.albedoTexture = -1; |
| 286 | constants.alphaTexture = -1; |
| 287 | constants.emissiveTexture = -1; |
| 288 | constants.metalnessTexture = -1; |
| 289 | constants.normalTexture = -1; |
| 290 | constants.occlusionTexture = -1; |
| 291 | constants.roughnessTexture = -1; |
| 292 | |
| 293 | for (const auto& semantic : m_semanticBindings) |
| 294 | { |
| 295 | switch(semantic.label) |
| 296 | { |
| 297 | case SemanticLabel::Albedo: |
| 298 | constants.albedoTexture = semantic.imageIndex + imageOffset; |
nothing calls this directly
no outgoing calls
no test coverage detected