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

[dxvk] Add depth-stencil unpacking shaders

This commit is contained in:
Philip Rebohle 2019-03-26 12:01:28 +01:00
parent 90c7878a53
commit 7124c3f449
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 117 additions and 0 deletions

View File

@ -30,6 +30,10 @@ dxvk_shaders = files([
'shaders/dxvk_pack_d24s8.comp',
'shaders/dxvk_pack_d32s8.comp',
'shaders/dxvk_unpack_d24s8_as_d32s8.comp',
'shaders/dxvk_unpack_d24s8.comp',
'shaders/dxvk_unpack_d32s8.comp',
'hud/shaders/hud_line.frag',
'hud/shaders/hud_text.frag',
'hud/shaders/hud_vert.vert',

View File

@ -0,0 +1,36 @@
#version 450
layout(
local_size_x = 64,
local_size_y = 1,
local_size_z = 1) in;
layout(binding = 0, r32ui) writeonly uniform uimageBuffer u_depth;
layout(binding = 1, r8ui) writeonly uniform uimageBuffer u_stencil;
layout(binding = 2)
readonly buffer s_buffer_t {
uint data[];
} s_buffer;
layout(push_constant)
uniform u_info_t {
uvec2 dst_extent;
uvec2 src_extent;
} u_info;
void main() {
if (all(lessThan(gl_GlobalInvocationID.xy, u_info.dst_extent))) {
uint src_index = gl_GlobalInvocationID.x
+ gl_GlobalInvocationID.y * u_info.src_extent.x
+ gl_GlobalInvocationID.z * u_info.src_extent.y;
uint dst_index = gl_GlobalInvocationID.x
+ gl_GlobalInvocationID.y * u_info.dst_extent.x
+ gl_GlobalInvocationID.z * u_info.dst_extent.y;
uint src_data = s_buffer.data[src_index];
imageStore(u_depth, int(dst_index), uvec4(src_data & 0xFFFFFF));
imageStore(u_stencil, int(dst_index), uvec4(src_data >> 24));
}
}

View File

@ -0,0 +1,36 @@
#version 450
layout(
local_size_x = 64,
local_size_y = 1,
local_size_z = 1) in;
layout(binding = 0, r32f) writeonly uniform imageBuffer u_depth;
layout(binding = 1, r8ui) writeonly uniform uimageBuffer u_stencil;
layout(binding = 2)
readonly buffer s_buffer_t {
uint data[];
} s_buffer;
layout(push_constant)
uniform u_info_t {
uvec2 dst_extent;
uvec2 src_extent;
} u_info;
void main() {
if (all(lessThan(gl_GlobalInvocationID.xy, u_info.dst_extent))) {
uint src_index = gl_GlobalInvocationID.x
+ gl_GlobalInvocationID.y * u_info.src_extent.x
+ gl_GlobalInvocationID.z * u_info.src_extent.y;
uint dst_index = gl_GlobalInvocationID.x
+ gl_GlobalInvocationID.y * u_info.dst_extent.x
+ gl_GlobalInvocationID.z * u_info.dst_extent.y;
uint src_data = s_buffer.data[src_index];
imageStore(u_depth, int(dst_index), vec4(float(src_data & 0xFFFFFF) / float(0xFFFFFF)));
imageStore(u_stencil, int(dst_index), uvec4(src_data >> 24));
}
}

View File

@ -0,0 +1,41 @@
#version 450
layout(
local_size_x = 64,
local_size_y = 1,
local_size_z = 1) in;
struct d32s8_t {
float d32;
uint s8;
};
layout(binding = 0, r32f) writeonly uniform imageBuffer u_depth;
layout(binding = 1, r8ui) writeonly uniform uimageBuffer u_stencil;
layout(binding = 2)
readonly buffer s_buffer_t {
d32s8_t data[];
} s_buffer;
layout(push_constant)
uniform u_info_t {
uvec2 dst_extent;
uvec2 src_extent;
} u_info;
void main() {
if (all(lessThan(gl_GlobalInvocationID.xy, u_info.dst_extent))) {
uint src_index = gl_GlobalInvocationID.x
+ gl_GlobalInvocationID.y * u_info.src_extent.x
+ gl_GlobalInvocationID.z * u_info.src_extent.y;
uint dst_index = gl_GlobalInvocationID.x
+ gl_GlobalInvocationID.y * u_info.dst_extent.x
+ gl_GlobalInvocationID.z * u_info.dst_extent.y;
d32s8_t src_data = s_buffer.data[src_index];
imageStore(u_depth, int(dst_index), vec4(src_data.d32));
imageStore(u_stencil, int(dst_index), uvec4(src_data.s8));
}
}