1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-11 10:24:10 +01:00

[d3d11] Use EmitCs for shader and resource binding methods

This commit is contained in:
Philip Rebohle 2018-01-20 18:54:37 +01:00
parent 7fad731096
commit cbbfefbbb7
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99

View File

@ -880,8 +880,10 @@ namespace dxvk {
if (m_state.vs.shader != shader) { if (m_state.vs.shader != shader) {
m_state.vs.shader = shader; m_state.vs.shader = shader;
m_context->bindShader(VK_SHADER_STAGE_VERTEX_BIT, EmitCs([cShader = shader != nullptr ? shader->GetShader() : nullptr]
shader != nullptr ? shader->GetShader() : nullptr); (DxvkContext* ctx) {
ctx->bindShader(VK_SHADER_STAGE_VERTEX_BIT, cShader);
});
} }
} }
@ -1141,8 +1143,10 @@ namespace dxvk {
if (m_state.gs.shader != shader) { if (m_state.gs.shader != shader) {
m_state.gs.shader = shader; m_state.gs.shader = shader;
m_context->bindShader(VK_SHADER_STAGE_GEOMETRY_BIT, EmitCs([cShader = shader != nullptr ? shader->GetShader() : nullptr]
shader != nullptr ? shader->GetShader() : nullptr); (DxvkContext* ctx) {
ctx->bindShader(VK_SHADER_STAGE_GEOMETRY_BIT, cShader);
});
} }
} }
@ -1234,8 +1238,10 @@ namespace dxvk {
if (m_state.ps.shader != shader) { if (m_state.ps.shader != shader) {
m_state.ps.shader = shader; m_state.ps.shader = shader;
m_context->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT, EmitCs([cShader = shader != nullptr ? shader->GetShader() : nullptr]
shader != nullptr ? shader->GetShader() : nullptr); (DxvkContext* ctx) {
ctx->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT, cShader);
});
} }
} }
@ -1327,8 +1333,10 @@ namespace dxvk {
if (m_state.cs.shader != shader) { if (m_state.cs.shader != shader) {
m_state.cs.shader = shader; m_state.cs.shader = shader;
m_context->bindShader(VK_SHADER_STAGE_COMPUTE_BIT, EmitCs([cShader = shader != nullptr ? shader->GetShader() : nullptr]
shader != nullptr ? shader->GetShader() : nullptr); (DxvkContext* ctx) {
ctx->bindShader(VK_SHADER_STAGE_COMPUTE_BIT, cShader);
});
} }
} }
@ -1744,13 +1752,14 @@ namespace dxvk {
if (Bindings[StartSlot + i] != newBuffer) { if (Bindings[StartSlot + i] != newBuffer) {
Bindings[StartSlot + i] = newBuffer; Bindings[StartSlot + i] = newBuffer;
if (newBuffer != nullptr) { EmitCs([
m_context->bindResourceBuffer( cSlotId = slotId + i,
slotId + i, newBuffer->GetBufferSlice(0)); cSlice = newBuffer != nullptr
} else { ? newBuffer->GetBufferSlice()
m_context->bindResourceBuffer( : DxvkBufferSlice()
slotId + i, DxvkBufferSlice()); ] (DxvkContext* ctx) {
} ctx->bindResourceBuffer(cSlotId, cSlice);
});
} }
} }
} }
@ -1772,13 +1781,14 @@ namespace dxvk {
if (Bindings[StartSlot + i] != sampler) { if (Bindings[StartSlot + i] != sampler) {
Bindings[StartSlot + i] = sampler; Bindings[StartSlot + i] = sampler;
if (sampler != nullptr) { EmitCs([
m_context->bindResourceSampler( cSlotId = slotId + i,
slotId + i, sampler->GetDXVKSampler()); cSampler = sampler != nullptr
} else { ? sampler->GetDXVKSampler()
m_context->bindResourceSampler( : m_defaultSampler
slotId + i, m_defaultSampler); ] (DxvkContext* ctx) {
} ctx->bindResourceSampler(cSlotId, cSampler);
});
} }
} }
} }
@ -1803,17 +1813,23 @@ namespace dxvk {
if (resView != nullptr) { if (resView != nullptr) {
// Figure out what we have to bind based on the resource type // Figure out what we have to bind based on the resource type
if (resView->GetResourceType() == D3D11_RESOURCE_DIMENSION_BUFFER) { if (resView->GetResourceType() == D3D11_RESOURCE_DIMENSION_BUFFER) {
m_context->bindResourceTexelBuffer( EmitCs([cSlotId = slotId + i, cView = resView->GetBufferView()]
slotId + i, resView->GetBufferView()); (DxvkContext* ctx) {
ctx->bindResourceTexelBuffer(cSlotId, cView);
});
} else { } else {
m_context->bindResourceImage( EmitCs([cSlotId = slotId + i, cView = resView->GetImageView()]
slotId + i, resView->GetImageView()); (DxvkContext* ctx) {
ctx->bindResourceImage(cSlotId, cView);
});
} }
} else { } else {
// When unbinding a resource, it doesn't really matter if // When unbinding a resource, it doesn't really matter if
// the resource type is correct, so we'll just bind a null // the resource type is correct, so we'll just bind a null
// image to the given resource slot // image to the given resource slot
m_context->bindResourceImage(slotId + i, nullptr); EmitCs([cSlotId = slotId + i] (DxvkContext* ctx) {
ctx->bindResourceImage(cSlotId, nullptr);
});
} }
} }
} }
@ -1843,20 +1859,30 @@ namespace dxvk {
if (uav != nullptr) { if (uav != nullptr) {
// Figure out what we have to bind based on the resource type // Figure out what we have to bind based on the resource type
if (uav->GetResourceType() == D3D11_RESOURCE_DIMENSION_BUFFER) { if (uav->GetResourceType() == D3D11_RESOURCE_DIMENSION_BUFFER) {
m_context->bindResourceTexelBuffer( EmitCs([
uavSlotId + i, uav->GetBufferView()); cUavSlotId = uavSlotId + i,
m_context->bindResourceBuffer( cCtrSlotId = ctrSlotId + i,
ctrSlotId + i, uav->GetCounterSlice()); cUavBuffer = uav->GetBufferView(),
cCtrBuffer = uav->GetCounterSlice()
] (DxvkContext* ctx) {
ctx->bindResourceTexelBuffer(cUavSlotId, cUavBuffer);
ctx->bindResourceBuffer (cCtrSlotId, cCtrBuffer);
});
} else { } else {
m_context->bindResourceImage( EmitCs([cUavSlotId = uavSlotId + i, cUavImage = uav->GetImageView()]
uavSlotId + i, uav->GetImageView()); (DxvkContext* ctx) {
ctx->bindResourceImage(cUavSlotId, cUavImage);
});
} }
} else { } else {
// When unbinding a resource, it doesn't really matter if // When unbinding a resource, it doesn't really matter if
// the resource type is correct, so we'll just bind a null // the resource type is correct, so we'll just bind a null
// image to the given resource slot // image to the given resource slot
m_context->bindResourceTexelBuffer(uavSlotId + i, nullptr); EmitCs([cUavSlotId = uavSlotId + i, cCtrSlotId = ctrSlotId + i]
m_context->bindResourceBuffer (ctrSlotId + i, DxvkBufferSlice()); (DxvkContext* ctx) {
ctx->bindResourceTexelBuffer(cUavSlotId, nullptr);
ctx->bindResourceBuffer (cCtrSlotId, DxvkBufferSlice());
});
} }
} }
} }
@ -1876,11 +1902,13 @@ namespace dxvk {
if (counterSlice.defined() if (counterSlice.defined()
&& counterValue.atomicCtr != 0xFFFFFFFFu) { && counterValue.atomicCtr != 0xFFFFFFFFu) {
m_context->updateBuffer( EmitCs([counterSlice, counterValue] (DxvkContext* ctx) {
ctx->updateBuffer(
counterSlice.buffer(), counterSlice.buffer(),
counterSlice.offset(), counterSlice.offset(),
counterSlice.length(), counterSlice.length(),
&counterValue); &counterValue);
});
} }
} }
} }