diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index c9110bc7a..a6edc4a31 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -3125,7 +3125,7 @@ namespace dxvk { uint32_t slotId = computeConstantBufferBinding(ShaderStage, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT); - ctx->bindShader(stage, + ctx->bindShader( Forwarder::move(cShader)); ctx->bindResourceBuffer(stage, slotId, Forwarder::move(cSlice)); @@ -3911,6 +3911,14 @@ namespace dxvk { for (uint32_t i = 0; i < cUsedBindings.soCount; i++) ctx->bindXfbBuffer(i, DxvkBufferSlice(), DxvkBufferSlice()); + // Unbind all shaders + ctx->bindShader(nullptr); + ctx->bindShader(nullptr); + ctx->bindShader(nullptr); + ctx->bindShader(nullptr); + ctx->bindShader(nullptr); + ctx->bindShader(nullptr); + // Unbind per-shader stage resources for (uint32_t i = 0; i < 6; i++) { auto programType = DxbcProgramType(i); @@ -3918,8 +3926,6 @@ namespace dxvk { // Unbind constant buffers, including the shader's ICB auto cbSlotId = computeConstantBufferBinding(programType, 0); - - ctx->bindShader(stage, nullptr); ctx->bindResourceBuffer(stage, cbSlotId + D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, DxvkBufferSlice()); for (uint32_t j = 0; j < cUsedBindings.stages[i].cbvCount; j++) diff --git a/src/d3d11/d3d11_video.cpp b/src/d3d11/d3d11_video.cpp index 4cc3f08c0..72346bc85 100644 --- a/src/d3d11/d3d11_video.cpp +++ b/src/d3d11/d3d11_video.cpp @@ -1199,8 +1199,8 @@ namespace dxvk { rt.color[0].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; ctx->bindRenderTargets(std::move(rt), 0u); - ctx->bindShader(VK_SHADER_STAGE_VERTEX_BIT, Rc(m_vs)); - ctx->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT, Rc(m_fs)); + ctx->bindShader(Rc(m_vs)); + ctx->bindShader(Rc(m_fs)); ctx->bindResourceBuffer(VK_SHADER_STAGE_FRAGMENT_BIT, 0, DxvkBufferSlice(m_ubo)); DxvkInputAssemblyState iaState; @@ -1314,8 +1314,8 @@ namespace dxvk { m_ctx->EmitCs([this] (DxvkContext* ctx) { ctx->bindRenderTargets(DxvkRenderTargets(), 0u); - ctx->bindShader(VK_SHADER_STAGE_VERTEX_BIT, nullptr); - ctx->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT, nullptr); + ctx->bindShader(nullptr); + ctx->bindShader(nullptr); ctx->bindResourceBuffer(VK_SHADER_STAGE_FRAGMENT_BIT, 0, DxvkBufferSlice()); }); diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 95cade416..56f1206ba 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -2668,15 +2668,15 @@ namespace dxvk { // Unbind the pixel shader, we aren't drawing // to avoid val errors / UB. - ctx->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT, nullptr); + ctx->bindShader(nullptr); - ctx->bindShader(VK_SHADER_STAGE_GEOMETRY_BIT, std::move(shader)); + ctx->bindShader(std::move(shader)); ctx->bindResourceBuffer(VK_SHADER_STAGE_GEOMETRY_BIT, getSWVPBufferSlot(), std::move(cBufferSlice)); ctx->draw( drawInfo.vertexCount, drawInfo.instanceCount, cStartIndex, 0); ctx->bindResourceBuffer(VK_SHADER_STAGE_GEOMETRY_BIT, getSWVPBufferSlot(), DxvkBufferSlice()); - ctx->bindShader(VK_SHADER_STAGE_GEOMETRY_BIT, nullptr); + ctx->bindShader(nullptr); }); // We unbound the pixel shader before, @@ -6131,7 +6131,7 @@ namespace dxvk { cShader = pShaderModule->GetShader(Permutation) ] (DxvkContext* ctx) mutable { constexpr VkShaderStageFlagBits stage = GetShaderStage(ShaderStage); - ctx->bindShader(stage, std::move(cShader)); + ctx->bindShader(std::move(cShader)); }); } @@ -6504,7 +6504,7 @@ namespace dxvk { &cShaders = m_ffModules ](DxvkContext* ctx) { auto shader = cShaders.GetShaderModule(this, cKey); - ctx->bindShader(VK_SHADER_STAGE_VERTEX_BIT, shader.GetShader()); + ctx->bindShader(shader.GetShader()); }); } @@ -6679,7 +6679,7 @@ namespace dxvk { &cShaders = m_ffModules ](DxvkContext* ctx) { auto shader = cShaders.GetShaderModule(this, cKey); - ctx->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT, shader.GetShader()); + ctx->bindShader(shader.GetShader()); }); } diff --git a/src/d3d9/d3d9_format_helpers.cpp b/src/d3d9/d3d9_format_helpers.cpp index d8cd3233d..de73fdbe7 100644 --- a/src/d3d9/d3d9_format_helpers.cpp +++ b/src/d3d9/d3d9_format_helpers.cpp @@ -96,7 +96,7 @@ namespace dxvk { m_context->setSpecConstant(VK_PIPELINE_BIND_POINT_COMPUTE, 0, specConstantValue); m_context->bindResourceImageView(VK_SHADER_STAGE_COMPUTE_BIT, BindingIds::Image, std::move(tmpImageView)); m_context->bindResourceBufferView(VK_SHADER_STAGE_COMPUTE_BIT, BindingIds::Buffer, std::move(tmpBufferView)); - m_context->bindShader(VK_SHADER_STAGE_COMPUTE_BIT, Rc(m_shaders[videoFormat.FormatType])); + m_context->bindShader(Rc(m_shaders[videoFormat.FormatType])); m_context->pushConstants(0, sizeof(VkExtent2D), &imageExtent); m_context->dispatch( (imageExtent.width / 8) + (imageExtent.width % 8), diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 4da4bb14a..6a55ef739 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -261,10 +261,10 @@ namespace dxvk { * \param [in] stage Target shader stage * \param [in] shader The shader to bind */ + template void bindShader( - VkShaderStageFlagBits stage, Rc&& shader) { - switch (stage) { + switch (Stage) { case VK_SHADER_STAGE_VERTEX_BIT: m_state.gp.shaders.vs = std::move(shader); break; @@ -293,7 +293,7 @@ namespace dxvk { return; } - if (stage == VK_SHADER_STAGE_COMPUTE_BIT) { + if (Stage == VK_SHADER_STAGE_COMPUTE_BIT) { m_flags.set( DxvkContextFlag::CpDirtyPipelineState); } else { diff --git a/src/dxvk/dxvk_swapchain_blitter.cpp b/src/dxvk/dxvk_swapchain_blitter.cpp index eca02445d..591cce3ad 100644 --- a/src/dxvk/dxvk_swapchain_blitter.cpp +++ b/src/dxvk/dxvk_swapchain_blitter.cpp @@ -197,8 +197,8 @@ namespace dxvk { ctx->bindResourceImageView(VK_SHADER_STAGE_FRAGMENT_BIT, BindingIds::Image, Rc(srcView)); ctx->bindResourceImageView(VK_SHADER_STAGE_FRAGMENT_BIT, BindingIds::Gamma, Rc(m_gammaView)); - ctx->bindShader(VK_SHADER_STAGE_VERTEX_BIT, Rc(m_vs)); - ctx->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT, Rc(fs)); + ctx->bindShader(Rc(m_vs)); + ctx->bindShader(Rc(fs)); PresenterArgs args; args.srcOffset = srcRect.offset; diff --git a/src/dxvk/hud/dxvk_hud_renderer.cpp b/src/dxvk/hud/dxvk_hud_renderer.cpp index 5d47d7c79..b638c7d73 100644 --- a/src/dxvk/hud/dxvk_hud_renderer.cpp +++ b/src/dxvk/hud/dxvk_hud_renderer.cpp @@ -104,8 +104,8 @@ namespace dxvk::hud { if (m_mode != Mode::RenderText) { m_mode = Mode::RenderText; - m_context->bindShader(VK_SHADER_STAGE_VERTEX_BIT, Rc(m_textShaders.vert)); - m_context->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT, Rc(m_textShaders.frag)); + m_context->bindShader(Rc(m_textShaders.vert)); + m_context->bindShader(Rc(m_textShaders.frag)); m_context->bindResourceBuffer(VK_SHADER_STAGE_VERTEX_BIT, 0, DxvkBufferSlice(m_fontBuffer)); m_context->bindResourceBufferView(VK_SHADER_STAGE_VERTEX_BIT, 1, Rc(m_dataView)); @@ -126,8 +126,8 @@ namespace dxvk::hud { if (m_mode != Mode::RenderGraph) { m_mode = Mode::RenderGraph; - m_context->bindShader(VK_SHADER_STAGE_VERTEX_BIT, Rc(m_graphShaders.vert)); - m_context->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT, Rc(m_graphShaders.frag)); + m_context->bindShader(Rc(m_graphShaders.vert)); + m_context->bindShader(Rc(m_graphShaders.frag)); m_context->bindResourceBuffer(VK_SHADER_STAGE_FRAGMENT_BIT, 0, DxvkBufferSlice(m_dataBuffer));