Write constant buffers if changed or layout changed

This commit is contained in:
Robert Beckebans 2022-11-20 15:42:48 +01:00
parent c48346c551
commit 632ad33f80
5 changed files with 13 additions and 15 deletions

View file

@ -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();

View file

@ -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 };
}

View file

@ -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() );

View file

@ -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;

View file

@ -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()
{