Going back to a single renderprog volatile constant buffer to avoid crashes

This commit is contained in:
Robert Beckebans 2023-12-28 16:16:15 +01:00
parent 13f9ee8cfb
commit 1e9bc96191
7 changed files with 18 additions and 13 deletions

View file

@ -729,9 +729,13 @@ bool idUniformBuffer::AllocBufferObject( const void* data, int allocSize, buffer
// This buffer is a shader resource as opposed to a constant buffer due to
// constant buffers not being able to be sub-ranged.
nvrhi::BufferDesc bufferDesc;
//bufferDesc.initialState = nvrhi::ResourceStates::ConstantBuffer; // SRS - shouldn't this be initialized to CopyDest?
bufferDesc.initialState = nvrhi::ResourceStates::CopyDest;
bufferDesc.canHaveTypedViews = true;
bufferDesc.canHaveRawViews = true;
bufferDesc.byteSize = numBytes;
bufferDesc.structStride = sizeof( idVec4 ); // SRS - this defines a structured storage buffer vs. a constant buffer
bufferDesc.initialState = nvrhi::ResourceStates::Common;
bufferDesc.structStride = sizeof( idVec4 );
bufferDesc.isConstantBuffer = true;
if( usage == BU_DYNAMIC )
{

View file

@ -316,7 +316,7 @@ bool idRenderProgManager::CommitConstantBuffer( nvrhi::ICommandList* commandList
// The vkDoom3 backend even didn't bother with this and always fired the uniforms for each draw call.
if( uniformsChanged || bindingLayoutTypeChanged )
{
commandList->writeBuffer( constantBuffer[BindingLayoutType()], uniforms.Ptr(), uniforms.Allocated() );
commandList->writeBuffer( constantBuffer /*[BindingLayoutType()]*/, uniforms.Ptr(), uniforms.Allocated() );
uniformsChanged = false;

View file

@ -254,8 +254,8 @@ void SsaoPass::Render(
quarterResExtent.maxY = ( quarterResExtent.maxY + 3 ) / 4;
// TODO required and remove this by fixing the shaders
// because they include #include <global_inc.hlsl>
renderProgManager.BindShader_TextureVertexColor();
renderProgManager.CommitConstantBuffer( commandList, true );
SsaoConstants ssaoConstants = {};

View file

@ -6238,7 +6238,7 @@ void idRenderBackend::CRTPostProcess()
DrawElementsWithCounters( &unitSquareSurface );
}
GL_SelectTexture( 0 );
//GL_SelectTexture( 0 );
//renderProgManager.Unbind();
// copy LDR result to DX12 / Vulkan swapchain image

View file

@ -88,10 +88,10 @@ void idRenderProgManager::Init( nvrhi::IDevice* device )
uniforms.SetNum( RENDERPARM_TOTAL, vec4_zero );
uniformsChanged = false;
for( int i = 0; i < NUM_BINDING_LAYOUTS; i++ )
//for( int i = 0; i < NUM_BINDING_LAYOUTS; i++ )
{
auto constantBufferDesc = nvrhi::utils::CreateVolatileConstantBufferDesc( uniforms.Allocated(), va( "RenderParams_%d", i ), 16384 );
constantBuffer[i] = device->createBuffer( constantBufferDesc );
auto constantBufferDesc = nvrhi::utils::CreateVolatileConstantBufferDesc( uniforms.Allocated(), va( "RenderParams_%d", 1 ), 16384 );
constantBuffer = device->createBuffer( constantBufferDesc );
}
// === Main draw vertex layout ===
@ -722,9 +722,9 @@ void idRenderProgManager::Shutdown()
}
// SRS - Unmap buffer memory using overloaded = operator
for( int i = 0; i < constantBuffer.Num(); i++ )
//for( int i = 0; i < constantBuffer.Num(); i++ )
{
constantBuffer[i] = nullptr;
constantBuffer = nullptr;
}
}

View file

@ -976,7 +976,7 @@ public:
ID_INLINE nvrhi::IBuffer* ConstantBuffer()
{
return constantBuffer[BindingLayoutType()];
return constantBuffer;//[BindingLayoutType()];
}
ID_INLINE idUniformBuffer& BindingParamUbo()
{
@ -1082,7 +1082,8 @@ private:
idStaticList< idStaticList<nvrhi::BindingLayoutHandle, nvrhi::c_MaxBindingLayouts>, NUM_BINDING_LAYOUTS > bindingLayouts;
idArray<nvrhi::BufferHandle, NUM_BINDING_LAYOUTS> constantBuffer;
//idArray<nvrhi::BufferHandle, NUM_BINDING_LAYOUTS> constantBuffer;
nvrhi::BufferHandle constantBuffer;
};
extern idRenderProgManager renderProgManager;

View file

@ -27,7 +27,7 @@ SOFTWARE.
===========================================================================
*/
#include "global_inc.hlsl"
#include <global_inc.hlsl>
// *INDENT-OFF*