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

[d3d11] Request high-priority shader compiles as necessary

This can reduce stutter in case shaders are needed immediately while
background threads are still busy compiling a different set of shaders.
This commit is contained in:
Philip Rebohle 2022-08-11 01:56:17 +02:00
parent c3a53127d7
commit d3ab905621
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 34 additions and 20 deletions

View File

@ -3110,26 +3110,38 @@ namespace dxvk {
template<DxbcProgramType ShaderStage>
void D3D11CommonContext<ContextType>::BindShader(
const D3D11CommonShader* pShaderModule) {
// Bind the shader and the ICB at once
EmitCs([
cSlice = pShaderModule != nullptr
&& pShaderModule->GetIcb() != nullptr
? DxvkBufferSlice(pShaderModule->GetIcb())
: DxvkBufferSlice(),
cShader = pShaderModule != nullptr
? pShaderModule->GetShader()
: nullptr
] (DxvkContext* ctx) mutable {
constexpr VkShaderStageFlagBits stage = GetShaderStage(ShaderStage);
if (pShaderModule) {
auto buffer = pShaderModule->GetIcb();
auto shader = pShaderModule->GetShader();
uint32_t slotId = computeConstantBufferBinding(ShaderStage,
D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT);
if (unlikely(shader->needsLibraryCompile()))
m_device->requestCompileShader(shader);
ctx->bindShader<stage>(
Forwarder::move(cShader));
ctx->bindResourceBuffer(stage, slotId,
Forwarder::move(cSlice));
});
EmitCs([
cBuffer = std::move(buffer),
cShader = std::move(shader)
] (DxvkContext* ctx) mutable {
constexpr VkShaderStageFlagBits stage = GetShaderStage(ShaderStage);
uint32_t slotId = computeConstantBufferBinding(ShaderStage,
D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT);
ctx->bindShader<stage>(
Forwarder::move(cShader));
ctx->bindResourceBuffer(stage, slotId,
Forwarder::move(cBuffer));
});
} else {
EmitCs([] (DxvkContext* ctx) {
constexpr VkShaderStageFlagBits stage = GetShaderStage(ShaderStage);
uint32_t slotId = computeConstantBufferBinding(ShaderStage,
D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT);
ctx->bindShader<stage>(nullptr);
ctx->bindResourceBuffer(stage, slotId, DxvkBufferSlice());
});
}
}

View File

@ -43,8 +43,10 @@ namespace dxvk {
return m_shader;
}
Rc<DxvkBuffer> GetIcb() const {
return m_buffer;
DxvkBufferSlice GetIcb() const {
return m_buffer != nullptr
? DxvkBufferSlice(m_buffer)
: DxvkBufferSlice();
}
std::string GetName() const {