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

[dxvk] Get rid of separate depth shaders for shader-based copies

We can export both depth and color in a single shader instead.
This commit is contained in:
Philip Rebohle 2024-03-19 15:51:45 +01:00
parent a163082770
commit c5aeb0f87a
8 changed files with 14 additions and 70 deletions

View File

@ -9,9 +9,6 @@
#include <dxvk_copy_color_1d.h> #include <dxvk_copy_color_1d.h>
#include <dxvk_copy_color_2d.h> #include <dxvk_copy_color_2d.h>
#include <dxvk_copy_color_ms.h> #include <dxvk_copy_color_ms.h>
#include <dxvk_copy_depth_1d.h>
#include <dxvk_copy_depth_2d.h>
#include <dxvk_copy_depth_ms.h>
#include <dxvk_copy_depth_stencil_1d.h> #include <dxvk_copy_depth_stencil_1d.h>
#include <dxvk_copy_depth_stencil_2d.h> #include <dxvk_copy_depth_stencil_2d.h>
#include <dxvk_copy_depth_stencil_ms.h> #include <dxvk_copy_depth_stencil_ms.h>
@ -84,11 +81,7 @@ namespace dxvk {
m_color { m_color {
createShaderModule(dxvk_copy_color_1d), createShaderModule(dxvk_copy_color_1d),
createShaderModule(dxvk_copy_color_2d), createShaderModule(dxvk_copy_color_2d),
createShaderModule(dxvk_copy_color_ms) }, createShaderModule(dxvk_copy_color_ms) } {
m_depth {
createShaderModule(dxvk_copy_depth_1d),
createShaderModule(dxvk_copy_depth_2d),
createShaderModule(dxvk_copy_depth_ms) } {
if (device->features().vk12.shaderOutputLayer) { if (device->features().vk12.shaderOutputLayer) {
m_shaderVert = createShaderModule(dxvk_fullscreen_layer_vert); m_shaderVert = createShaderModule(dxvk_fullscreen_layer_vert);
} else { } else {
@ -119,9 +112,6 @@ namespace dxvk {
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_depthStencil.fragMs, nullptr); m_vkd->vkDestroyShaderModule(m_vkd->device(), m_depthStencil.fragMs, nullptr);
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_depthStencil.frag2D, nullptr); m_vkd->vkDestroyShaderModule(m_vkd->device(), m_depthStencil.frag2D, nullptr);
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_depthStencil.frag1D, nullptr); m_vkd->vkDestroyShaderModule(m_vkd->device(), m_depthStencil.frag1D, nullptr);
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_depth.fragMs, nullptr);
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_depth.frag2D, nullptr);
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_depth.frag1D, nullptr);
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_color.fragMs, nullptr); m_vkd->vkDestroyShaderModule(m_vkd->device(), m_color.fragMs, nullptr);
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_color.frag2D, nullptr); m_vkd->vkDestroyShaderModule(m_vkd->device(), m_color.frag2D, nullptr);
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_color.frag1D, nullptr); m_vkd->vkDestroyShaderModule(m_vkd->device(), m_color.frag1D, nullptr);
@ -313,7 +303,7 @@ namespace dxvk {
std::array<std::pair<const FragShaders*, VkImageAspectFlags>, 3> shaderSets = {{ std::array<std::pair<const FragShaders*, VkImageAspectFlags>, 3> shaderSets = {{
{ &m_color, VK_IMAGE_ASPECT_COLOR_BIT }, { &m_color, VK_IMAGE_ASPECT_COLOR_BIT },
{ &m_depth, VK_IMAGE_ASPECT_DEPTH_BIT }, { &m_color, VK_IMAGE_ASPECT_DEPTH_BIT },
{ &m_depthStencil, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT }, { &m_depthStencil, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT },
}}; }};

View File

@ -20,9 +20,6 @@ dxvk_shaders = files([
'shaders/dxvk_copy_color_1d.frag', 'shaders/dxvk_copy_color_1d.frag',
'shaders/dxvk_copy_color_2d.frag', 'shaders/dxvk_copy_color_2d.frag',
'shaders/dxvk_copy_color_ms.frag', 'shaders/dxvk_copy_color_ms.frag',
'shaders/dxvk_copy_depth_1d.frag',
'shaders/dxvk_copy_depth_2d.frag',
'shaders/dxvk_copy_depth_ms.frag',
'shaders/dxvk_copy_depth_stencil_1d.frag', 'shaders/dxvk_copy_depth_stencil_1d.frag',
'shaders/dxvk_copy_depth_stencil_2d.frag', 'shaders/dxvk_copy_depth_stencil_2d.frag',
'shaders/dxvk_copy_depth_stencil_ms.frag', 'shaders/dxvk_copy_depth_stencil_ms.frag',

View File

@ -13,6 +13,8 @@ uniform u_info_t {
} u_info; } u_info;
void main() { void main() {
o_color = texelFetch(s_image, vec4 color = texelFetch(s_image,
ivec2(gl_FragCoord.x + u_info.offset.x, gl_Layer), 0); ivec2(gl_FragCoord.x + u_info.offset.x, gl_Layer), 0);
o_color = color;
gl_FragDepth = color.r;
} }

View File

@ -13,6 +13,8 @@ uniform u_info_t {
} u_info; } u_info;
void main() { void main() {
o_color = texelFetch(s_image, vec4 color = texelFetch(s_image,
ivec3(gl_FragCoord.xy + u_info.offset, gl_Layer), 0); ivec3(gl_FragCoord.xy + u_info.offset, gl_Layer), 0);
o_color = color;
gl_FragDepth = color.r;
} }

View File

@ -13,7 +13,9 @@ uniform u_info_t {
} u_info; } u_info;
void main() { void main() {
o_color = texelFetch(s_image, vec4 color = texelFetch(s_image,
ivec3(gl_FragCoord.xy + u_info.offset, gl_Layer), ivec3(gl_FragCoord.xy + u_info.offset, gl_Layer),
gl_SampleID); gl_SampleID);
o_color = color;
gl_FragDepth = color.r;
} }

View File

@ -1,16 +0,0 @@
#version 450
#extension GL_EXT_samplerless_texture_functions : require
layout(set = 0, binding = 0)
uniform texture1DArray s_image;
layout(push_constant)
uniform u_info_t {
ivec2 offset;
} u_info;
void main() {
gl_FragDepth = texelFetch(s_image,
ivec2(gl_FragCoord.x + u_info.offset.x, gl_Layer), 0).r;
}

View File

@ -1,16 +0,0 @@
#version 450
#extension GL_EXT_samplerless_texture_functions : require
layout(set = 0, binding = 0)
uniform texture2DArray s_image;
layout(push_constant)
uniform u_info_t {
ivec2 offset;
} u_info;
void main() {
gl_FragDepth = texelFetch(s_image,
ivec3(gl_FragCoord.xy + u_info.offset, gl_Layer), 0).r;
}

View File

@ -1,17 +0,0 @@
#version 450
#extension GL_EXT_samplerless_texture_functions : require
layout(set = 0, binding = 0)
uniform texture2DMSArray s_image;
layout(push_constant)
uniform u_info_t {
ivec2 offset;
} u_info;
void main() {
gl_FragDepth = texelFetch(s_image,
ivec3(gl_FragCoord.xy + u_info.offset, gl_Layer),
gl_SampleID).r;
}