25 #define IMG_WIDTH (qvk.extent_screen_images.width)
26 #define IMG_HEIGHT (qvk.extent_screen_images.height)
27 #define IMG_WIDTH_MGPU (qvk.extent_screen_images.width / qvk.device_count)
29 #define IMG_WIDTH_GRAD ((qvk.extent_screen_images.width + GRAD_DWN - 1) / GRAD_DWN)
30 #define IMG_HEIGHT_GRAD ((qvk.extent_screen_images.height + GRAD_DWN - 1) / GRAD_DWN)
31 #define IMG_WIDTH_GRAD_MGPU ((qvk.extent_screen_images.width + GRAD_DWN - 1) / GRAD_DWN / qvk.device_count)
35 IMG_DO(PT_VISBUF, 0, R32G32B32A32_SFLOAT, rgba32f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
36 IMG_DO(PT_ALBEDO, 1, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
37 IMG_DO(PT_METALLIC, 2, R8G8_UNORM, rg8, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
38 IMG_DO(PT_MOTION, 3, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH, IMG_HEIGHT ) \
39 IMG_DO(PT_TRANSPARENT, 4, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
40 IMG_DO(PT_TEX_GRADIENTS, 5, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
41 IMG_DO(ASVGF_HIST_COLOR_HF, 6, R32_UINT, r32ui, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
42 IMG_DO(ASVGF_ATROUS_PING_LF_SH, 7, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_GRAD_MGPU, IMG_HEIGHT_GRAD) \
43 IMG_DO(ASVGF_ATROUS_PONG_LF_SH, 8, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_GRAD_MGPU, IMG_HEIGHT_GRAD) \
44 IMG_DO(ASVGF_ATROUS_PING_LF_COCG, 9, R16G16_SFLOAT, rg16f, IMG_WIDTH_GRAD_MGPU, IMG_HEIGHT_GRAD) \
45 IMG_DO(ASVGF_ATROUS_PONG_LF_COCG, 10, R16G16_SFLOAT, rg16f, IMG_WIDTH_GRAD_MGPU, IMG_HEIGHT_GRAD) \
46 IMG_DO(ASVGF_ATROUS_PING_HF, 11, R32_UINT, r32ui, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
47 IMG_DO(ASVGF_ATROUS_PONG_HF, 12, R32_UINT, r32ui, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
48 IMG_DO(ASVGF_ATROUS_PING_SPEC, 13, R32_UINT, r32ui, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
49 IMG_DO(ASVGF_ATROUS_PONG_SPEC, 14, R32_UINT, r32ui, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
50 IMG_DO(ASVGF_ATROUS_PING_MOMENTS, 15, R16G16_SFLOAT, rg16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
51 IMG_DO(ASVGF_ATROUS_PONG_MOMENTS, 16, R16G16_SFLOAT, rg16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
52 IMG_DO(ASVGF_COLOR, 17, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH, IMG_HEIGHT ) \
53 IMG_DO(ASVGF_TEX_GRADIENTS_FWD, 18, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_GRAD_MGPU, IMG_HEIGHT_GRAD) \
54 IMG_DO(ASVGF_POS_WS_FWD, 19, R32G32B32A32_SFLOAT, rgba32f, IMG_WIDTH_GRAD_MGPU, IMG_HEIGHT_GRAD) \
55 IMG_DO(ASVGF_VISBUF_FWD, 20, R32G32B32A32_SFLOAT, rgba32f, IMG_WIDTH_GRAD_MGPU, IMG_HEIGHT_GRAD) \
56 IMG_DO(ASVGF_GRAD_LF_PING, 21, R16G16_SFLOAT, rg16f, IMG_WIDTH_GRAD_MGPU, IMG_HEIGHT_GRAD) \
57 IMG_DO(ASVGF_GRAD_LF_PONG, 22, R16G16_SFLOAT, rg16f, IMG_WIDTH_GRAD_MGPU, IMG_HEIGHT_GRAD) \
58 IMG_DO(ASVGF_GRAD_HF_SPEC_PING, 23, R16G16_SFLOAT, rg16f, IMG_WIDTH_GRAD_MGPU, IMG_HEIGHT_GRAD) \
59 IMG_DO(ASVGF_GRAD_HF_SPEC_PONG, 24, R16G16_SFLOAT, rg16f, IMG_WIDTH_GRAD_MGPU, IMG_HEIGHT_GRAD) \
60 IMG_DO(PT_SHADING_POSITION, 25, R32G32B32A32_SFLOAT, rgba32f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
61 IMG_DO(FLAT_COLOR, 26, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH, IMG_HEIGHT ) \
62 IMG_DO(FLAT_MOTION, 27, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH, IMG_HEIGHT ) \
63 IMG_DO(PT_GODRAYS_THROUGHPUT_DIST,28, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
64 IMG_DO(BLOOM_DOWNSCALE_MIP_1, 29, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH / 2, IMG_HEIGHT / 2 ) \
65 IMG_DO(BLOOM_HBLUR, 30, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH / 4, IMG_HEIGHT / 4 ) \
66 IMG_DO(BLOOM_VBLUR, 31, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH / 4, IMG_HEIGHT / 4 ) \
67 IMG_DO(TAA_OUTPUT, 32, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH, IMG_HEIGHT ) \
68 IMG_DO(PT_VIEW_DIRECTION, 33, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
69 IMG_DO(PT_VIEW_DIRECTION2, 34, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
70 IMG_DO(PT_THROUGHPUT, 35, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
71 IMG_DO(PT_BOUNCE_THROUGHPUT, 36, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
72 IMG_DO(HQ_COLOR_INTERLEAVED, 37, R32G32B32A32_SFLOAT, rgba32f, IMG_WIDTH, IMG_HEIGHT ) \
73 IMG_DO(PT_COLOR_LF_SH, 38, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
74 IMG_DO(PT_COLOR_LF_COCG, 39, R16G16_SFLOAT, rg16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
75 IMG_DO(PT_COLOR_HF, 40, R32_UINT, r32ui, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
76 IMG_DO(PT_COLOR_SPEC, 41, R32_UINT, r32ui, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
77 IMG_DO(PT_GEO_NORMAL, 42, R32_UINT, r32ui, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
78 IMG_DO(PT_GEO_NORMAL2, 43, R32_UINT, r32ui, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
79 IMG_DO(PT_CLUSTER, 44, R16_UINT, r16ui, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
81 #define LIST_IMAGES_A_B \
82 IMG_DO(PT_VIEW_DEPTH_A, 45, R32_SFLOAT, r32f, IMG_WIDTH, IMG_HEIGHT ) \
83 IMG_DO(PT_VIEW_DEPTH_B, 46, R32_SFLOAT, r32f, IMG_WIDTH, IMG_HEIGHT ) \
84 IMG_DO(PT_NORMAL_A, 47, R32_UINT, r32ui, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
85 IMG_DO(PT_NORMAL_B, 48, R32_UINT, r32ui, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
86 IMG_DO(ASVGF_FILTERED_SPEC_A, 49, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
87 IMG_DO(ASVGF_FILTERED_SPEC_B, 50, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
88 IMG_DO(ASVGF_HIST_MOMENTS_HF_A, 51, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
89 IMG_DO(ASVGF_HIST_MOMENTS_HF_B, 52, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
90 IMG_DO(ASVGF_TAA_A, 53, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH, IMG_HEIGHT ) \
91 IMG_DO(ASVGF_TAA_B, 54, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH, IMG_HEIGHT ) \
92 IMG_DO(ASVGF_RNG_SEED_A, 55, R32_UINT, r32ui, IMG_WIDTH, IMG_HEIGHT ) \
93 IMG_DO(ASVGF_RNG_SEED_B, 56, R32_UINT, r32ui, IMG_WIDTH, IMG_HEIGHT ) \
94 IMG_DO(ASVGF_HIST_COLOR_LF_SH_A, 57, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
95 IMG_DO(ASVGF_HIST_COLOR_LF_SH_B, 58, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
96 IMG_DO(ASVGF_HIST_COLOR_LF_COCG_A,59, R16G16_SFLOAT, rg16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
97 IMG_DO(ASVGF_HIST_COLOR_LF_COCG_B,60, R16G16_SFLOAT, rg16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
98 IMG_DO(ASVGF_GRAD_SMPL_POS_A, 61, R32_UINT, r32ui, IMG_WIDTH_GRAD_MGPU, IMG_HEIGHT_GRAD) \
99 IMG_DO(ASVGF_GRAD_SMPL_POS_B, 62, R32_UINT, r32ui, IMG_WIDTH_GRAD_MGPU, IMG_HEIGHT_GRAD) \
101 #define LIST_IMAGES_B_A \
102 IMG_DO(PT_VIEW_DEPTH_B, 45, R32_SFLOAT, r32f, IMG_WIDTH, IMG_HEIGHT ) \
103 IMG_DO(PT_VIEW_DEPTH_A, 46, R32_SFLOAT, r32f, IMG_WIDTH, IMG_HEIGHT ) \
104 IMG_DO(PT_NORMAL_B, 47, R32_UINT, r32ui, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
105 IMG_DO(PT_NORMAL_A, 48, R32_UINT, r32ui, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
106 IMG_DO(ASVGF_FILTERED_SPEC_B, 49, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
107 IMG_DO(ASVGF_FILTERED_SPEC_A, 50, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
108 IMG_DO(ASVGF_HIST_MOMENTS_HF_B, 51, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
109 IMG_DO(ASVGF_HIST_MOMENTS_HF_A, 52, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
110 IMG_DO(ASVGF_TAA_B, 53, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH, IMG_HEIGHT ) \
111 IMG_DO(ASVGF_TAA_A, 54, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH, IMG_HEIGHT ) \
112 IMG_DO(ASVGF_RNG_SEED_B, 55, R32_UINT, r32ui, IMG_WIDTH, IMG_HEIGHT ) \
113 IMG_DO(ASVGF_RNG_SEED_A, 56, R32_UINT, r32ui, IMG_WIDTH, IMG_HEIGHT ) \
114 IMG_DO(ASVGF_HIST_COLOR_LF_SH_B, 57, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
115 IMG_DO(ASVGF_HIST_COLOR_LF_SH_A, 58, R16G16B16A16_SFLOAT, rgba16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
116 IMG_DO(ASVGF_HIST_COLOR_LF_COCG_B,59, R16G16_SFLOAT, rg16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
117 IMG_DO(ASVGF_HIST_COLOR_LF_COCG_A,60, R16G16_SFLOAT, rg16f, IMG_WIDTH_MGPU, IMG_HEIGHT ) \
118 IMG_DO(ASVGF_GRAD_SMPL_POS_B, 61, R32_UINT, r32ui, IMG_WIDTH_GRAD_MGPU, IMG_HEIGHT_GRAD) \
119 IMG_DO(ASVGF_GRAD_SMPL_POS_A, 62, R32_UINT, r32ui, IMG_WIDTH_GRAD_MGPU, IMG_HEIGHT_GRAD) \
121 #define NUM_IMAGES 63
125 #define GLOBAL_TEXTURES_TEX_ARR_BINDING_IDX 0
126 #define BINDING_OFFSET_IMAGES (1 + GLOBAL_TEXTURES_TEX_ARR_BINDING_IDX)
127 #define BINDING_OFFSET_TEXTURES (BINDING_OFFSET_IMAGES + NUM_IMAGES)
128 #define BINDING_OFFSET_BLUE_NOISE (BINDING_OFFSET_TEXTURES + NUM_IMAGES)
129 #define BINDING_OFFSET_ENVMAP (BINDING_OFFSET_BLUE_NOISE + 1)
130 #define BINDING_OFFSET_PHYSICAL_SKY (BINDING_OFFSET_ENVMAP + 1)
131 #define BINDING_OFFSET_PHYSICAL_SKY_IMG (BINDING_OFFSET_PHYSICAL_SKY + 1)
132 #define BINDING_OFFSET_SKY_TRANSMITTANCE (BINDING_OFFSET_PHYSICAL_SKY_IMG + 1)
133 #define BINDING_OFFSET_SKY_SCATTERING (BINDING_OFFSET_SKY_TRANSMITTANCE + 1)
134 #define BINDING_OFFSET_SKY_IRRADIANCE (BINDING_OFFSET_SKY_SCATTERING + 1)
135 #define BINDING_OFFSET_SKY_CLOUDS (BINDING_OFFSET_SKY_IRRADIANCE + 1)
136 #define BINDING_OFFSET_TERRAIN_ALBEDO (BINDING_OFFSET_SKY_CLOUDS + 1)
137 #define BINDING_OFFSET_TERRAIN_NORMALS (BINDING_OFFSET_TERRAIN_ALBEDO + 1)
138 #define BINDING_OFFSET_TERRAIN_DEPTH (BINDING_OFFSET_TERRAIN_NORMALS + 1)
139 #define BINDING_OFFSET_TERRAIN_SHADOWMAP (BINDING_OFFSET_TERRAIN_DEPTH + 1)
147 #if MAX_RIMAGES != NUM_GLOBAL_TEXTUES
148 #error need to fix the constant here as well
153 #define IMG_DO(_name, ...) \
163 #elif defined(GLOBAL_TEXTURES_DESC_SET_IDX)
172 ) uniform sampler2D global_texture_descriptors[];
174 #define SAMPLER_r16ui usampler2D
175 #define SAMPLER_r32ui usampler2D
176 #define SAMPLER_rg32ui usampler2D
177 #define SAMPLER_r32i isampler2D
178 #define SAMPLER_r32f sampler2D
179 #define SAMPLER_rg32f sampler2D
180 #define SAMPLER_rg16f sampler2D
181 #define SAMPLER_rgba32f sampler2D
182 #define SAMPLER_rgba16f sampler2D
183 #define SAMPLER_rgba8 sampler2D
184 #define SAMPLER_r8 sampler2D
185 #define SAMPLER_rg8 sampler2D
187 #define IMAGE_r16ui uimage2D
188 #define IMAGE_r32ui uimage2D
189 #define IMAGE_rg32ui uimage2D
190 #define IMAGE_r32i iimage2D
191 #define IMAGE_r32f image2D
192 #define IMAGE_rg32f image2D
193 #define IMAGE_rg16f image2D
194 #define IMAGE_rgba32f image2D
195 #define IMAGE_rgba16f image2D
196 #define IMAGE_rgba8 image2D
197 #define IMAGE_r8 image2D
198 #define IMAGE_rg8 image2D
201 #define IMG_DO(_name, _binding, _vkformat, _glslformat, _w, _h) \
202 layout(set = GLOBAL_TEXTURES_DESC_SET_IDX, binding = BINDING_OFFSET_IMAGES + _binding, _glslformat) \
203 uniform IMAGE_##_glslformat IMG_##_name;
209 #define IMG_DO(_name, _binding, _vkformat, _glslformat, _w, _h) \
210 layout(set = GLOBAL_TEXTURES_DESC_SET_IDX, binding = BINDING_OFFSET_TEXTURES + _binding) \
211 uniform SAMPLER_##_glslformat TEX_##_name;
219 ) uniform sampler2DArray TEX_BLUE_NOISE;
224 ) uniform samplerCube TEX_ENVMAP;
229 ) uniform samplerCube TEX_PHYSICAL_SKY;
235 ) uniform imageCube IMG_PHYSICAL_SKY;
242 ) uniform sampler2D TEX_SKY_TRANSMITTANCE;
247 ) uniform sampler3D TEX_SKY_SCATTERING;
252 ) uniform sampler2D TEX_SKY_IRRADIANCE;
257 ) uniform sampler3D TEX_SKY_CLOUDS;
262 ) uniform samplerCube IMG_TERRAIN_ALBEDO;
267 ) uniform samplerCube IMG_TERRAIN_NORMALS;
272 ) uniform samplerCube IMG_TERRAIN_DEPTH;
277 ) uniform sampler2D TEX_TERRAIN_SHADOWMAP;
281 global_texture(
uint idx, vec2 tex_coord)
284 return vec4(1, 0, 1, 0);
285 return texture(global_texture_descriptors[nonuniformEXT(idx)], tex_coord);
289 global_textureLod(
uint idx, vec2 tex_coord,
float lod)
292 return vec4(1, 1, 0, 0);
293 return textureLod(global_texture_descriptors[nonuniformEXT(idx)], tex_coord, lod);
297 global_textureGrad(
uint idx, vec2 tex_coord, vec2 d_x, vec2 d_y)
300 return vec4(1, 1, 0, 0);
301 return textureGrad(global_texture_descriptors[nonuniformEXT(idx)], tex_coord, d_x, d_y);
309 return textureSize(global_texture_descriptors[nonuniformEXT(idx)],
level);