From 632b254714ad04fbc64cd0d3a7d1a3ea5246ddf0 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 3 Apr 2019 17:39:13 +0200 Subject: [PATCH] [d3d11] Use combined image sampler descriptors for the presenter --- src/d3d11/d3d11_swapchain.cpp | 16 +++++++--------- src/d3d11/d3d11_swapchain.h | 6 ++---- src/dxgi/shaders/dxgi_presenter_frag.frag | 15 ++++++--------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/d3d11/d3d11_swapchain.cpp b/src/d3d11/d3d11_swapchain.cpp index 300b8784f..55034c3ea 100644 --- a/src/d3d11/d3d11_swapchain.cpp +++ b/src/d3d11/d3d11_swapchain.cpp @@ -286,11 +286,11 @@ namespace dxvk { m_context->setInputAssemblyState(m_iaState); m_context->setInputLayout(0, nullptr, 0, nullptr); - m_context->bindResourceSampler(BindingIds::Sampler, fitSize ? m_samplerFitting : m_samplerScaling); - m_context->bindResourceSampler(BindingIds::GammaSmp, m_gammaSampler); + m_context->bindResourceSampler(BindingIds::Image, fitSize ? m_samplerFitting : m_samplerScaling); + m_context->bindResourceSampler(BindingIds::Gamma, m_gammaSampler); - m_context->bindResourceView(BindingIds::Texture, m_swapImageView, nullptr); - m_context->bindResourceView(BindingIds::GammaTex, m_gammaTextureView, nullptr); + m_context->bindResourceView(BindingIds::Image, m_swapImageView, nullptr); + m_context->bindResourceView(BindingIds::Gamma, m_gammaTextureView, nullptr); m_context->draw(4, 1, 0, 0); @@ -664,11 +664,9 @@ namespace dxvk { const SpirvCodeBuffer vsCode(dxgi_presenter_vert); const SpirvCodeBuffer fsCode(dxgi_presenter_frag); - const std::array fsResourceSlots = {{ - { BindingIds::Sampler, VK_DESCRIPTOR_TYPE_SAMPLER, VK_IMAGE_VIEW_TYPE_MAX_ENUM }, - { BindingIds::Texture, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_IMAGE_VIEW_TYPE_2D }, - { BindingIds::GammaSmp, VK_DESCRIPTOR_TYPE_SAMPLER, VK_IMAGE_VIEW_TYPE_MAX_ENUM }, - { BindingIds::GammaTex, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_IMAGE_VIEW_TYPE_1D }, + const std::array fsResourceSlots = {{ + { BindingIds::Image, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_IMAGE_VIEW_TYPE_2D }, + { BindingIds::Gamma, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_IMAGE_VIEW_TYPE_1D }, }}; m_vertShader = m_device->createShader( diff --git a/src/d3d11/d3d11_swapchain.h b/src/d3d11/d3d11_swapchain.h index 4099bb607..dcbc6e906 100644 --- a/src/d3d11/d3d11_swapchain.h +++ b/src/d3d11/d3d11_swapchain.h @@ -72,10 +72,8 @@ namespace dxvk { private: enum BindingIds : uint32_t { - Sampler = 0, - Texture = 1, - GammaSmp = 2, - GammaTex = 3, + Image = 0, + Gamma = 1, }; Com m_dxgiDevice; diff --git a/src/dxgi/shaders/dxgi_presenter_frag.frag b/src/dxgi/shaders/dxgi_presenter_frag.frag index 7ff685156..41c97cdb0 100644 --- a/src/dxgi/shaders/dxgi_presenter_frag.frag +++ b/src/dxgi/shaders/dxgi_presenter_frag.frag @@ -2,23 +2,20 @@ layout(constant_id = 3) const bool s_gamma_bound = false; -layout(binding = 0) uniform sampler s_sampler; -layout(binding = 1) uniform texture2D t_texture; - -layout(binding = 2) uniform sampler s_gamma; -layout(binding = 3) uniform texture1D t_gamma; +layout(binding = 0) uniform sampler2D s_image; +layout(binding = 1) uniform sampler1D s_gamma; layout(location = 0) in vec2 i_texcoord; layout(location = 0) out vec4 o_color; void main() { - o_color = texture(sampler2D(t_texture, s_sampler), i_texcoord); + o_color = texture(s_image, i_texcoord); if (s_gamma_bound) { o_color = vec4( - texture(sampler1D(t_gamma, s_gamma), o_color.r).r, - texture(sampler1D(t_gamma, s_gamma), o_color.g).g, - texture(sampler1D(t_gamma, s_gamma), o_color.b).b, + texture(s_gamma, o_color.r).r, + texture(s_gamma, o_color.g).g, + texture(s_gamma, o_color.b).b, o_color.a); } } \ No newline at end of file