mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-13 16:08:50 +01:00
[d3d11] Use new resource view binding methods
This commit is contained in:
parent
317850e16f
commit
28ecf8268d
@ -3323,16 +3323,34 @@ namespace dxvk {
|
|||||||
void D3D11CommonContext<ContextType>::BindShaderResource(
|
void D3D11CommonContext<ContextType>::BindShaderResource(
|
||||||
UINT Slot,
|
UINT Slot,
|
||||||
D3D11ShaderResourceView* pResource) {
|
D3D11ShaderResourceView* pResource) {
|
||||||
EmitCs([
|
if (pResource) {
|
||||||
cSlotId = Slot,
|
if (pResource->GetViewInfo().Dimension != D3D11_RESOURCE_DIMENSION_BUFFER) {
|
||||||
cImageView = pResource != nullptr ? pResource->GetImageView() : nullptr,
|
EmitCs([
|
||||||
cBufferView = pResource != nullptr ? pResource->GetBufferView() : nullptr
|
cSlotId = Slot,
|
||||||
] (DxvkContext* ctx) mutable {
|
cView = pResource->GetImageView()
|
||||||
VkShaderStageFlagBits stage = GetShaderStage(ShaderStage);
|
] (DxvkContext* ctx) mutable {
|
||||||
ctx->bindResourceView(stage, cSlotId,
|
VkShaderStageFlagBits stage = GetShaderStage(ShaderStage);
|
||||||
Forwarder::move(cImageView),
|
ctx->bindResourceImageView(stage, cSlotId,
|
||||||
Forwarder::move(cBufferView));
|
Forwarder::move(cView));
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
EmitCs([
|
||||||
|
cSlotId = Slot,
|
||||||
|
cView = pResource->GetBufferView()
|
||||||
|
] (DxvkContext* ctx) mutable {
|
||||||
|
VkShaderStageFlagBits stage = GetShaderStage(ShaderStage);
|
||||||
|
ctx->bindResourceBufferView(stage, cSlotId,
|
||||||
|
Forwarder::move(cView));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
EmitCs([
|
||||||
|
cSlotId = Slot
|
||||||
|
] (DxvkContext* ctx) {
|
||||||
|
VkShaderStageFlagBits stage = GetShaderStage(ShaderStage);
|
||||||
|
ctx->bindResourceImageView(stage, cSlotId, nullptr);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3343,32 +3361,60 @@ namespace dxvk {
|
|||||||
D3D11UnorderedAccessView* pUav,
|
D3D11UnorderedAccessView* pUav,
|
||||||
UINT CtrSlot,
|
UINT CtrSlot,
|
||||||
UINT Counter) {
|
UINT Counter) {
|
||||||
EmitCs([
|
if (pUav) {
|
||||||
cUavSlotId = UavSlot,
|
if (pUav->GetViewInfo().Dimension == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
||||||
cCtrSlotId = CtrSlot,
|
EmitCs([
|
||||||
cImageView = pUav != nullptr ? pUav->GetImageView() : nullptr,
|
cUavSlotId = UavSlot,
|
||||||
cBufferView = pUav != nullptr ? pUav->GetBufferView() : nullptr,
|
cCtrSlotId = CtrSlot,
|
||||||
cCounterSlice = pUav != nullptr ? pUav->GetCounterSlice() : DxvkBufferSlice(),
|
cBufferView = pUav->GetBufferView(),
|
||||||
cCounterValue = Counter
|
cCounterSlice = pUav->GetCounterSlice(),
|
||||||
] (DxvkContext* ctx) mutable {
|
cCounterValue = Counter
|
||||||
VkShaderStageFlags stages = ShaderStage == DxbcProgramType::PixelShader
|
] (DxvkContext* ctx) mutable {
|
||||||
? VK_SHADER_STAGE_ALL_GRAPHICS
|
VkShaderStageFlags stages = ShaderStage == DxbcProgramType::ComputeShader
|
||||||
: VK_SHADER_STAGE_COMPUTE_BIT;
|
? VK_SHADER_STAGE_COMPUTE_BIT
|
||||||
|
: VK_SHADER_STAGE_ALL_GRAPHICS;
|
||||||
|
|
||||||
if (cCounterSlice.defined() && cCounterValue != ~0u) {
|
if (cCounterSlice.defined() && cCounterValue != ~0u) {
|
||||||
ctx->updateBuffer(
|
ctx->updateBuffer(
|
||||||
cCounterSlice.buffer(),
|
cCounterSlice.buffer(),
|
||||||
cCounterSlice.offset(),
|
cCounterSlice.offset(),
|
||||||
sizeof(uint32_t),
|
sizeof(uint32_t),
|
||||||
&cCounterValue);
|
&cCounterValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->bindResourceBufferView(stages, cUavSlotId,
|
||||||
|
Forwarder::move(cBufferView));
|
||||||
|
ctx->bindResourceBuffer(stages, cCtrSlotId,
|
||||||
|
Forwarder::move(cCounterSlice));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
EmitCs([
|
||||||
|
cUavSlotId = UavSlot,
|
||||||
|
cCtrSlotId = CtrSlot,
|
||||||
|
cImageView = pUav->GetImageView()
|
||||||
|
] (DxvkContext* ctx) mutable {
|
||||||
|
VkShaderStageFlags stages = ShaderStage == DxbcProgramType::ComputeShader
|
||||||
|
? VK_SHADER_STAGE_COMPUTE_BIT
|
||||||
|
: VK_SHADER_STAGE_ALL_GRAPHICS;
|
||||||
|
|
||||||
|
ctx->bindResourceImageView(stages, cUavSlotId,
|
||||||
|
Forwarder::move(cImageView));
|
||||||
|
ctx->bindResourceBuffer(stages, cCtrSlotId, DxvkBufferSlice());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
EmitCs([
|
||||||
|
cUavSlotId = UavSlot,
|
||||||
|
cCtrSlotId = CtrSlot
|
||||||
|
] (DxvkContext* ctx) {
|
||||||
|
VkShaderStageFlags stages = ShaderStage == DxbcProgramType::ComputeShader
|
||||||
|
? VK_SHADER_STAGE_COMPUTE_BIT
|
||||||
|
: VK_SHADER_STAGE_ALL_GRAPHICS;
|
||||||
|
|
||||||
ctx->bindResourceView(stages, cUavSlotId,
|
ctx->bindResourceImageView(stages, cUavSlotId, nullptr);
|
||||||
Forwarder::move(cImageView),
|
ctx->bindResourceBuffer(stages, cCtrSlotId, DxvkBufferSlice());
|
||||||
Forwarder::move(cBufferView));
|
});
|
||||||
ctx->bindResourceBuffer(stages, cCtrSlotId,
|
}
|
||||||
Forwarder::move(cCounterSlice));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3883,7 +3929,7 @@ namespace dxvk {
|
|||||||
auto srvSlotId = computeSrvBinding(programType, 0);
|
auto srvSlotId = computeSrvBinding(programType, 0);
|
||||||
|
|
||||||
for (uint32_t j = 0; j < cUsedBindings.stages[i].srvCount; j++)
|
for (uint32_t j = 0; j < cUsedBindings.stages[i].srvCount; j++)
|
||||||
ctx->bindResourceView(stage, srvSlotId + j, nullptr, nullptr);
|
ctx->bindResourceImageView(stage, srvSlotId + j, nullptr);
|
||||||
|
|
||||||
// Unbind texture samplers
|
// Unbind texture samplers
|
||||||
auto samplerSlotId = computeSamplerBinding(programType, 0);
|
auto samplerSlotId = computeSamplerBinding(programType, 0);
|
||||||
@ -3902,7 +3948,7 @@ namespace dxvk {
|
|||||||
auto ctrSlotId = computeUavCounterBinding(programType, 0);
|
auto ctrSlotId = computeUavCounterBinding(programType, 0);
|
||||||
|
|
||||||
for (uint32_t j = 0; j < cUsedBindings.stages[i].uavCount; j++) {
|
for (uint32_t j = 0; j < cUsedBindings.stages[i].uavCount; j++) {
|
||||||
ctx->bindResourceView(stages, uavSlotId, nullptr, nullptr);
|
ctx->bindResourceImageView(stages, uavSlotId, nullptr);
|
||||||
ctx->bindResourceBuffer(stages, ctrSlotId, DxvkBufferSlice());
|
ctx->bindResourceBuffer(stages, ctrSlotId, DxvkBufferSlice());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1298,14 +1298,14 @@ namespace dxvk {
|
|||||||
ctx->bindResourceSampler(VK_SHADER_STAGE_FRAGMENT_BIT, 1, Rc<DxvkSampler>(m_sampler));
|
ctx->bindResourceSampler(VK_SHADER_STAGE_FRAGMENT_BIT, 1, Rc<DxvkSampler>(m_sampler));
|
||||||
|
|
||||||
for (uint32_t i = 0; i < cViews.size(); i++)
|
for (uint32_t i = 0; i < cViews.size(); i++)
|
||||||
ctx->bindResourceView(VK_SHADER_STAGE_FRAGMENT_BIT, 2 + i, Rc<DxvkImageView>(cViews[i]), nullptr);
|
ctx->bindResourceImageView(VK_SHADER_STAGE_FRAGMENT_BIT, 2 + i, Rc<DxvkImageView>(cViews[i]));
|
||||||
|
|
||||||
ctx->draw(3, 1, 0, 0);
|
ctx->draw(3, 1, 0, 0);
|
||||||
|
|
||||||
ctx->bindResourceSampler(VK_SHADER_STAGE_FRAGMENT_BIT, 1, nullptr);
|
ctx->bindResourceSampler(VK_SHADER_STAGE_FRAGMENT_BIT, 1, nullptr);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < cViews.size(); i++)
|
for (uint32_t i = 0; i < cViews.size(); i++)
|
||||||
ctx->bindResourceView(VK_SHADER_STAGE_FRAGMENT_BIT, 2 + i, nullptr, nullptr);
|
ctx->bindResourceImageView(VK_SHADER_STAGE_FRAGMENT_BIT, 2 + i, nullptr);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user