summaryrefslogtreecommitdiffstats
path: root/src/libs/dxvk-native-1.9.2a/src/dxvk/shaders/dxvk_pack_d32s8.comp
blob: a0332f02cd7d9a3354a82c32dc9194511ae9e849 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#version 450

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  sampler2DArray u_depth;
layout(binding = 2) uniform usampler2DArray u_stencil;

layout(push_constant)
uniform u_info_t {
  uvec2 src_offset;
  uvec2 src_extent;
  uvec2 dst_offset;
  uvec2 dst_extent;
} u_info;

void main() {
  if (all(lessThan(gl_GlobalInvocationID.xy, u_info.src_extent))) {
    uvec3 src_coord = uvec3(
      gl_GlobalInvocationID.xy + u_info.src_offset,
      gl_GlobalInvocationID.z);

    uvec3 dst_coord = uvec3(
      gl_GlobalInvocationID.xy + u_info.dst_offset,
      gl_GlobalInvocationID.z);
    
    uint dst_index = dst_coord.x + u_info.dst_extent.x * (dst_coord.y + u_info.dst_extent.y * dst_coord.z);

    s_buffer.data[dst_index].d32 = texelFetch(u_depth,   ivec3(src_coord), 0).r;
    s_buffer.data[dst_index].s8  = texelFetch(u_stencil, ivec3(src_coord), 0).r;
  }
}