mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-01 16:24:12 +01:00
[dxvk] Add compute shaders for depth-stencil packing
This commit is contained in:
parent
0dbac29729
commit
863f2d07fd
@ -24,6 +24,9 @@ dxvk_shaders = files([
|
||||
'shaders/dxvk_mipgen_frag_1d.frag',
|
||||
'shaders/dxvk_mipgen_frag_2d.frag',
|
||||
'shaders/dxvk_mipgen_frag_3d.frag',
|
||||
|
||||
'shaders/dxvk_pack_d24s8.comp',
|
||||
'shaders/dxvk_pack_d32s8.comp',
|
||||
|
||||
'shaders/dxvk_resolve_vert.vert',
|
||||
'shaders/dxvk_resolve_geom.geom',
|
||||
|
42
src/dxvk/shaders/dxvk_pack_d24s8.comp
Normal file
42
src/dxvk/shaders/dxvk_pack_d24s8.comp
Normal file
@ -0,0 +1,42 @@
|
||||
#version 450
|
||||
|
||||
#extension GL_EXT_samplerless_texture_functions : enable
|
||||
|
||||
layout(
|
||||
local_size_x = 8,
|
||||
local_size_y = 8,
|
||||
local_size_z = 1) in;
|
||||
|
||||
layout(binding = 0, std430)
|
||||
writeonly buffer s_buffer_t {
|
||||
uint data[];
|
||||
} s_buffer;
|
||||
|
||||
layout(binding = 1) uniform texture2DArray u_depth;
|
||||
layout(binding = 2) uniform utexture2DArray u_stencil;
|
||||
|
||||
layout(push_constant)
|
||||
uniform u_info_t {
|
||||
uvec2 src_offset;
|
||||
uvec2 src_extent;
|
||||
} u_info;
|
||||
|
||||
void main() {
|
||||
if (all(lessThan(gl_GlobalInvocationID.xy, u_info.src_extent))) {
|
||||
uvec3 src_offset = uvec3(
|
||||
gl_GlobalInvocationID.xy + u_info.src_offset,
|
||||
gl_GlobalInvocationID.z);
|
||||
|
||||
uvec2 dst_pitch = uvec2(u_info.src_extent.x,
|
||||
u_info.src_extent.x * u_info.src_extent.y);
|
||||
|
||||
uint dst_offset = gl_GlobalInvocationID.x
|
||||
+ gl_GlobalInvocationID.y * dst_pitch.x
|
||||
+ gl_GlobalInvocationID.z * dst_pitch.y;
|
||||
|
||||
float depth = texelFetch(u_depth, ivec3(src_offset), 0).r;
|
||||
uint stencil = texelFetch(u_stencil, ivec3(src_offset), 0).r;
|
||||
|
||||
s_buffer.data[dst_offset] = uint(mix(0.0f, float((1 << 24) - 1), depth)) | (stencil << 24);
|
||||
}
|
||||
}
|
45
src/dxvk/shaders/dxvk_pack_d32s8.comp
Normal file
45
src/dxvk/shaders/dxvk_pack_d32s8.comp
Normal file
@ -0,0 +1,45 @@
|
||||
#version 450
|
||||
|
||||
#extension GL_EXT_samplerless_texture_functions : enable
|
||||
|
||||
layout(
|
||||
local_size_x = 8,
|
||||
local_size_y = 8,
|
||||
local_size_z = 1) in;
|
||||
|
||||
struct d32s8_t {
|
||||
float d32;
|
||||
uint s8;
|
||||
};
|
||||
|
||||
layout(binding = 0, std430)
|
||||
writeonly buffer s_buffer_t {
|
||||
d32s8_t data[];
|
||||
} s_buffer;
|
||||
|
||||
layout(binding = 1) uniform texture2DArray u_depth;
|
||||
layout(binding = 2) uniform utexture2DArray u_stencil;
|
||||
|
||||
layout(push_constant)
|
||||
uniform u_info_t {
|
||||
uvec2 src_offset;
|
||||
uvec2 src_extent;
|
||||
} u_info;
|
||||
|
||||
void main() {
|
||||
if (all(lessThan(gl_GlobalInvocationID.xy, u_info.src_extent))) {
|
||||
uvec3 src_offset = uvec3(
|
||||
gl_GlobalInvocationID.xy + u_info.src_offset,
|
||||
gl_GlobalInvocationID.z);
|
||||
|
||||
uvec2 dst_pitch = uvec2(u_info.src_extent.x,
|
||||
u_info.src_extent.x * u_info.src_extent.y);
|
||||
|
||||
uint dst_offset = gl_GlobalInvocationID.x
|
||||
+ gl_GlobalInvocationID.y * dst_pitch.x
|
||||
+ gl_GlobalInvocationID.z * dst_pitch.y;
|
||||
|
||||
s_buffer.data[dst_offset].d32 = texelFetch(u_depth, ivec3(src_offset), 0).r;
|
||||
s_buffer.data[dst_offset].s8 = texelFetch(u_stencil, ivec3(src_offset), 0).r;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user