Allow buffer ranges for constant buffers

This commit is contained in:
Stephen Pridham 2022-11-18 08:02:53 -05:00 committed by Robert Beckebans
parent c1c0334bf2
commit 47312f8997
2 changed files with 12 additions and 4 deletions

View file

@ -107,6 +107,11 @@ public:
return ( size & MAPPED_FLAG ) != 0;
}
void SetDebugName(idStr str)
{
debugName = str;
}
protected:
void SetMapped() const
{
@ -140,6 +145,7 @@ protected:
nvrhi::InputLayoutHandle inputLayout;
nvrhi::BufferHandle bufferHandle;
void* buffer;
idStr debugName;
#else
// GL
GLintptr bufferHandle;

View file

@ -484,6 +484,7 @@ idUniformBuffer::idUniformBuffer()
offsetInOtherBuffer = OWNS_BUFFER_FLAG;
bufferHandle.Reset();
SetUnmapped();
SetDebugName("Uniform Buffer");
}
/*
@ -509,22 +510,23 @@ 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::ShaderResource;
bufferDesc.initialState = nvrhi::ResourceStates::ConstantBuffer;
bufferDesc.keepInitialState = true;
bufferDesc.canHaveTypedViews = true;
bufferDesc.canHaveRawViews = true;
bufferDesc.byteSize = numBytes;
bufferDesc.structStride = sizeof( idVec4 );
bufferDesc.isConstantBuffer = true;
if( usage == BU_DYNAMIC )
{
bufferDesc.debugName = "Mapped JointBuffer";
bufferDesc.debugName = debugName.c_str();
bufferDesc.initialState = nvrhi::ResourceStates::CopyDest;
bufferDesc.cpuAccess = nvrhi::CpuAccessMode::Write;
}
else
{
bufferDesc.debugName = "Static JointBuffer";
bufferDesc.debugName = debugName.c_str();
bufferDesc.keepInitialState = true;
}
@ -631,7 +633,7 @@ void* idUniformBuffer::MapBuffer( bufferMapType_t mapType )
accessMode = nvrhi::CpuAccessMode::Read;
}
buffer = deviceManager->GetDevice()->mapBuffer( bufferHandle, accessMode );
buffer = deviceManager->GetDevice()->mapBuffer(bufferHandle, accessMode, { (uint64)GetOffset(), (uint64)GetSize() });
SetMapped();