1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-12 22:08:59 +01:00

[d3d11] Track highest bound constant buffer

This commit is contained in:
Philip Rebohle 2022-08-04 17:37:10 +02:00
parent 18c4ca8e92
commit 5dd2b20940
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 17 additions and 3 deletions

View File

@ -1,3 +1,5 @@
#include <algorithm>
#include "d3d11_context.h"
#include "d3d11_context_def.h"
#include "d3d11_context_imm.h"
@ -3781,7 +3783,9 @@ namespace dxvk {
D3D11MaxUsedBindings result;
for (uint32_t i = 0; i < result.stages.size(); i++) {
result.stages[i].cbvCount = D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT;
auto stage = DxbcProgramType(i);
result.stages[i].cbvCount = m_state.cbv[stage].maxCount;
result.stages[i].srvCount = D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT;
result.stages[i].uavCount = 0;
result.stages[i].samplerCount = D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT;
@ -4108,7 +4112,7 @@ namespace dxvk {
const auto& bindings = m_state.cbv[Stage];
uint32_t slotId = computeConstantBufferBinding(Stage, 0);
for (uint32_t i = 0; i < bindings.buffers.size(); i++) {
for (uint32_t i = 0; i < bindings.maxCount; i++) {
BindConstantBuffer<Stage>(slotId + i, bindings.buffers[i].buffer.ptr(),
bindings.buffers[i].constantOffset, bindings.buffers[i].constantBound);
}
@ -4182,6 +4186,9 @@ namespace dxvk {
BindConstantBuffer<ShaderStage>(slotId + i, newBuffer, 0, constantCount);
}
}
bindings.maxCount = std::clamp(StartSlot + NumBuffers,
bindings.maxCount, uint32_t(bindings.buffers.size()));
}
@ -4254,6 +4261,9 @@ namespace dxvk {
BindConstantBufferRange<ShaderStage>(slotId + i, constantOffset, constantBound);
}
}
bindings.maxCount = std::clamp(StartSlot + NumBuffers,
bindings.maxCount, uint32_t(bindings.buffers.size()));
}

View File

@ -60,9 +60,13 @@ namespace dxvk {
struct D3D11ShaderStageCbvBinding {
std::array<D3D11ConstantBufferBinding, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT> buffers = { };
uint32_t maxCount = 0;
void reset() {
for (uint32_t i = 0; i < buffers.size(); i++)
for (uint32_t i = 0; i < maxCount; i++)
buffers[i] = D3D11ConstantBufferBinding();
maxCount = 0;
}
};