mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-02 10:24:12 +01:00
[d3d11] Further optimize constant buffer binding
Saves a few CPU cycles on the more common SetConstantBuffers method, compared to SetConstantBuffers1.
This commit is contained in:
parent
3141467c37
commit
a41bd8c4a0
@ -3286,14 +3286,24 @@ namespace dxvk {
|
|||||||
|
|
||||||
void D3D11DeviceContext::BindConstantBuffer(
|
void D3D11DeviceContext::BindConstantBuffer(
|
||||||
UINT Slot,
|
UINT Slot,
|
||||||
const D3D11ConstantBufferBinding* pBufferBinding) {
|
D3D11Buffer* pBuffer) {
|
||||||
EmitCs([
|
EmitCs([
|
||||||
cSlotId = Slot,
|
cSlotId = Slot,
|
||||||
cBufferSlice = pBufferBinding->constantBound
|
cBufferSlice = pBuffer ? pBuffer->GetBufferSlice() : DxvkBufferSlice()
|
||||||
? pBufferBinding->buffer->GetBufferSlice(
|
] (DxvkContext* ctx) {
|
||||||
pBufferBinding->constantOffset * 16,
|
ctx->bindResourceBuffer(cSlotId, cBufferSlice);
|
||||||
pBufferBinding->constantBound * 16)
|
});
|
||||||
: DxvkBufferSlice()
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void D3D11DeviceContext::BindConstantBuffer1(
|
||||||
|
UINT Slot,
|
||||||
|
D3D11Buffer* pBuffer,
|
||||||
|
UINT Offset,
|
||||||
|
UINT Length) {
|
||||||
|
EmitCs([
|
||||||
|
cSlotId = Slot,
|
||||||
|
cBufferSlice = Length ? pBuffer->GetBufferSlice(16 * Offset, 16 * Length) : DxvkBufferSlice()
|
||||||
] (DxvkContext* ctx) {
|
] (DxvkContext* ctx) {
|
||||||
ctx->bindResourceBuffer(cSlotId, cBufferSlice);
|
ctx->bindResourceBuffer(cSlotId, cBufferSlice);
|
||||||
});
|
});
|
||||||
@ -3399,9 +3409,10 @@ namespace dxvk {
|
|||||||
for (uint32_t i = 0; i < NumBuffers; i++) {
|
for (uint32_t i = 0; i < NumBuffers; i++) {
|
||||||
auto newBuffer = static_cast<D3D11Buffer*>(ppConstantBuffers[i]);
|
auto newBuffer = static_cast<D3D11Buffer*>(ppConstantBuffers[i]);
|
||||||
|
|
||||||
UINT constantBound = newBuffer
|
UINT constantBound = 0;
|
||||||
? newBuffer->Desc()->ByteWidth / 16
|
|
||||||
: 0;
|
if (likely(newBuffer != nullptr))
|
||||||
|
constantBound = newBuffer->Desc()->ByteWidth / 16;
|
||||||
|
|
||||||
if (Bindings[StartSlot + i].buffer != newBuffer
|
if (Bindings[StartSlot + i].buffer != newBuffer
|
||||||
|| Bindings[StartSlot + i].constantBound != constantBound) {
|
|| Bindings[StartSlot + i].constantBound != constantBound) {
|
||||||
@ -3410,7 +3421,7 @@ namespace dxvk {
|
|||||||
Bindings[StartSlot + i].constantCount = constantBound;
|
Bindings[StartSlot + i].constantCount = constantBound;
|
||||||
Bindings[StartSlot + i].constantBound = constantBound;
|
Bindings[StartSlot + i].constantBound = constantBound;
|
||||||
|
|
||||||
BindConstantBuffer(slotId + i, &Bindings[StartSlot + i]);
|
BindConstantBuffer(slotId + i, newBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3466,7 +3477,7 @@ namespace dxvk {
|
|||||||
Bindings[StartSlot + i].constantCount = constantCount;
|
Bindings[StartSlot + i].constantCount = constantCount;
|
||||||
Bindings[StartSlot + i].constantBound = constantBound;
|
Bindings[StartSlot + i].constantBound = constantBound;
|
||||||
|
|
||||||
BindConstantBuffer(slotId + i, &Bindings[StartSlot + i]);
|
BindConstantBuffer1(slotId + i, newBuffer, constantOffset, constantBound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3643,8 +3654,10 @@ namespace dxvk {
|
|||||||
D3D11ConstantBufferBindings& Bindings) {
|
D3D11ConstantBufferBindings& Bindings) {
|
||||||
uint32_t slotId = computeConstantBufferBinding(Stage, 0);
|
uint32_t slotId = computeConstantBufferBinding(Stage, 0);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < Bindings.size(); i++)
|
for (uint32_t i = 0; i < Bindings.size(); i++) {
|
||||||
BindConstantBuffer(slotId + i, &Bindings[i]);
|
BindConstantBuffer1(slotId + i, Bindings[i].buffer.ptr(),
|
||||||
|
Bindings[i].constantOffset, Bindings[i].constantBound);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -708,7 +708,13 @@ namespace dxvk {
|
|||||||
|
|
||||||
void BindConstantBuffer(
|
void BindConstantBuffer(
|
||||||
UINT Slot,
|
UINT Slot,
|
||||||
const D3D11ConstantBufferBinding* pBufferBinding);
|
D3D11Buffer* pBuffer);
|
||||||
|
|
||||||
|
void BindConstantBuffer1(
|
||||||
|
UINT Slot,
|
||||||
|
D3D11Buffer* pBuffer,
|
||||||
|
UINT Offset,
|
||||||
|
UINT Length);
|
||||||
|
|
||||||
void BindSampler(
|
void BindSampler(
|
||||||
UINT Slot,
|
UINT Slot,
|
||||||
|
Loading…
Reference in New Issue
Block a user