diff --git a/neo/renderer/ImmediateMode.cpp b/neo/renderer/ImmediateMode.cpp index 651ca155..98fc8b2a 100644 --- a/neo/renderer/ImmediateMode.cpp +++ b/neo/renderer/ImmediateMode.cpp @@ -138,7 +138,7 @@ void fhImmediateMode::End() vertexBuffer.Update( drawVerts, drawVertsUsed * sizeof( idDrawVert ), 0, false, commandList ); indexBuffer.Update( lineIndices, drawVertsUsed * sizeof( triIndex_t ), 0, false, commandList ); - renderProgManager.CommitConstantBuffer( commandList ); + renderProgManager.CommitConstantBuffer( commandList, true ); int bindingLayoutType = renderProgManager.BindingLayoutType(); diff --git a/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp b/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp index a2c2017a..1b19436a 100644 --- a/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp +++ b/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp @@ -469,12 +469,15 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf ) } #endif - if( renderProgManager.CommitConstantBuffer( commandList ) ) + if( renderProgManager.CommitConstantBuffer( commandList, bindingLayoutType != prevBindingLayoutType ) ) { - // Reset the graphics state if the constant buffer is written to since - // the render pass is ended for vulkan. setGraphicsState will - // reinstate the render pass. - changeState = true; + if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) + { + // Reset the graphics state if the constant buffer is written to since + // the render pass is ended for vulkan. setGraphicsState will + // reinstate the render pass. + changeState = true; + } } // @@ -1421,15 +1424,10 @@ void idRenderBackend::GetCurrentBindingLayout( int type ) } else { - desc[0].bindings[0].resourceHandle = paramCb; - desc[0].bindings[0].range = range; auto& bindings = desc[0].bindings; bindings[0].resourceHandle = paramCb; bindings[0].range = range; - bindings[0].resourceHandle = paramCb; - bindings[0].range = range; - bindings[1].resourceHandle = currentJointBuffer; bindings[1].range = nvrhi::BufferRange{ currentJointOffset, sizeof( idVec4 )* numBoneMatrices }; } diff --git a/neo/renderer/NVRHI/RenderProgs_NVRHI.cpp b/neo/renderer/NVRHI/RenderProgs_NVRHI.cpp index 964630f4..831e5677 100644 --- a/neo/renderer/NVRHI/RenderProgs_NVRHI.cpp +++ b/neo/renderer/NVRHI/RenderProgs_NVRHI.cpp @@ -307,11 +307,11 @@ void idRenderProgManager::ZeroUniforms() } // Only updates the constant buffer if it was updated at all -bool idRenderProgManager::CommitConstantBuffer( nvrhi::ICommandList* commandList ) +bool idRenderProgManager::CommitConstantBuffer( nvrhi::ICommandList* commandList, bool bindingLayoutTypeChanged ) { // RB: It would be better to NUM_BINDING_LAYOUTS uniformsChanged entrys but we don't know the current binding layout type when we set the uniforms. // The vkDoom3 backend even didn't bother with this and always fired the uniforms for each draw call. - //if( uniformsChanged ) + if( uniformsChanged || bindingLayoutTypeChanged ) { commandList->writeBuffer( constantBuffer[BindingLayoutType()], uniforms.Ptr(), uniforms.Allocated() ); diff --git a/neo/renderer/RenderPass.cpp b/neo/renderer/RenderPass.cpp index 25330e88..f7c3c294 100644 --- a/neo/renderer/RenderPass.cpp +++ b/neo/renderer/RenderPass.cpp @@ -289,7 +289,7 @@ void BasicTriangle::Render( nvrhi::IFramebuffer* framebuffer ) renderProgManager.SetRenderParm( renderParm_t::RENDERPARM_PROJMATRIX_W, &projMat[12] ); } - renderProgManager.CommitConstantBuffer( commandList ); + renderProgManager.CommitConstantBuffer( commandList, true ); idVertexBuffer* vertexBuffer; uint vertOffset = 0; diff --git a/neo/renderer/RenderProgs.h b/neo/renderer/RenderProgs.h index 67f768be..bd8f68de 100644 --- a/neo/renderer/RenderProgs.h +++ b/neo/renderer/RenderProgs.h @@ -1017,7 +1017,7 @@ public: int UniformSize(); #if defined( USE_NVRHI ) - bool CommitConstantBuffer( nvrhi::ICommandList* commandList ); + bool CommitConstantBuffer( nvrhi::ICommandList* commandList, bool bindingLayoutTypeChanged ); ID_INLINE nvrhi::IBuffer* ConstantBuffer() {