20 #ifndef _GLOBAL_UBO_DESCRIPTOR_SET_LAYOUT_H_
21 #define _GLOBAL_UBO_DESCRIPTOR_SET_LAYOUT_H_
25 #define GLOBAL_UBO_BINDING_IDX 0
26 #define GLOBAL_INSTANCE_BUFFER_BINDING_IDX 1
29 #define UBO_CVAR_DO(name, default_value) GLOBAL_UBO_VAR_LIST_DO(float, name)
36 #define UBO_CVAR_LIST \
37 UBO_CVAR_DO(flt_antilag_hf, 1) \
38 UBO_CVAR_DO(flt_antilag_lf, 0.2) \
39 UBO_CVAR_DO(flt_antilag_spec, 2) \
40 UBO_CVAR_DO(flt_atrous_depth, 0.5) \
41 UBO_CVAR_DO(flt_atrous_deflicker_lf, 2) \
42 UBO_CVAR_DO(flt_atrous_hf, 4) \
43 UBO_CVAR_DO(flt_atrous_lf, 4) \
44 UBO_CVAR_DO(flt_atrous_spec, 3) \
45 UBO_CVAR_DO(flt_atrous_lum_hf, 16) \
46 UBO_CVAR_DO(flt_atrous_normal_hf, 64) \
47 UBO_CVAR_DO(flt_atrous_normal_lf, 8) \
48 UBO_CVAR_DO(flt_atrous_normal_spec, 1) \
49 UBO_CVAR_DO(flt_enable, 1) \
50 UBO_CVAR_DO(flt_fixed_albedo, 0) \
51 UBO_CVAR_DO(flt_grad_transparent, 0.3) \
52 UBO_CVAR_DO(flt_min_alpha_color_hf, 0.1) \
53 UBO_CVAR_DO(flt_min_alpha_color_lf, 0.01) \
54 UBO_CVAR_DO(flt_min_alpha_color_spec, 0.1) \
55 UBO_CVAR_DO(flt_min_alpha_moments_hf, 0.01) \
56 UBO_CVAR_DO(flt_scale_hf, 1) \
57 UBO_CVAR_DO(flt_scale_lf, 1) \
58 UBO_CVAR_DO(flt_scale_overlay, 1.0) \
59 UBO_CVAR_DO(flt_scale_spec, 1) \
60 UBO_CVAR_DO(flt_show_gradients, 0) \
61 UBO_CVAR_DO(flt_taa, 1) \
62 UBO_CVAR_DO(flt_taa_anti_sparkle, 0.25) \
63 UBO_CVAR_DO(flt_taa_variance, 0.7) \
64 UBO_CVAR_DO(flt_taa_history_weight, 0.95) \
65 UBO_CVAR_DO(flt_temporal_hf, 1) \
66 UBO_CVAR_DO(flt_temporal_lf, 1) \
67 UBO_CVAR_DO(flt_temporal_spec, 1) \
68 UBO_CVAR_DO(pt_aperture, 2.0) \
69 UBO_CVAR_DO(pt_aperture_angle, 0) \
70 UBO_CVAR_DO(pt_aperture_type, 0) \
71 UBO_CVAR_DO(pt_beam_softness, 1.0) \
72 UBO_CVAR_DO(pt_bump_scale, 1.0) \
73 UBO_CVAR_DO(pt_cameras, 1) \
74 UBO_CVAR_DO(pt_direct_polygon_lights, 1) \
75 UBO_CVAR_DO(pt_direct_roughness_threshold, 0.18) \
76 UBO_CVAR_DO(pt_direct_area_threshold, 0.2) \
77 UBO_CVAR_DO(pt_direct_sphere_lights, 1) \
78 UBO_CVAR_DO(pt_direct_sun_light, 1) \
79 UBO_CVAR_DO(pt_explosion_brightness, 4.0) \
80 UBO_CVAR_DO(pt_fake_roughness_threshold, 0.20) \
81 UBO_CVAR_DO(pt_focus, 200) \
82 UBO_CVAR_DO(pt_indirect_polygon_lights, 1) \
83 UBO_CVAR_DO(pt_indirect_sphere_lights, 1) \
84 UBO_CVAR_DO(pt_light_stats, 1) \
85 UBO_CVAR_DO(pt_max_log_sky_luminance, -3) \
86 UBO_CVAR_DO(pt_min_log_sky_luminance, -10) \
87 UBO_CVAR_DO(pt_metallic_override, -1) \
88 UBO_CVAR_DO(pt_ndf_trim, 0.9) \
89 UBO_CVAR_DO(pt_num_bounce_rays, 1) \
90 UBO_CVAR_DO(pt_particle_softness, 1.0) \
91 UBO_CVAR_DO(pt_reflect_refract, 2) \
92 UBO_CVAR_DO(pt_roughness_override, -1) \
93 UBO_CVAR_DO(pt_specular_anti_flicker, 2) \
94 UBO_CVAR_DO(pt_show_sky, 0) \
95 UBO_CVAR_DO(pt_sun_bounce_range, 2000) \
96 UBO_CVAR_DO(pt_sun_specular, 1.0) \
97 UBO_CVAR_DO(pt_texture_lod_bias, 0) \
98 UBO_CVAR_DO(pt_toksvig, 1) \
99 UBO_CVAR_DO(pt_thick_glass, 0) \
100 UBO_CVAR_DO(pt_water_density, 0.5) \
101 UBO_CVAR_DO(tm_debug, 0) \
102 UBO_CVAR_DO(tm_dyn_range_stops, 7.0) \
103 UBO_CVAR_DO(tm_enable, 1) \
104 UBO_CVAR_DO(tm_exposure_bias, -1.0) \
105 UBO_CVAR_DO(tm_exposure_speed_down, 1) \
106 UBO_CVAR_DO(tm_exposure_speed_up, 2) \
107 UBO_CVAR_DO(tm_high_percentile, 90) \
108 UBO_CVAR_DO(tm_knee_start, 0.6) \
109 UBO_CVAR_DO(tm_low_percentile, 70) \
110 UBO_CVAR_DO(tm_max_luminance, 1.0) \
111 UBO_CVAR_DO(tm_min_luminance, 0.0002) \
112 UBO_CVAR_DO(tm_noise_blend, 0.5) \
113 UBO_CVAR_DO(tm_noise_stops, -12) \
114 UBO_CVAR_DO(tm_reinhard, 0.5) \
115 UBO_CVAR_DO(tm_slope_blur_sigma, 12.0) \
116 UBO_CVAR_DO(tm_white_point, 10.0) \
119 #define GLOBAL_UBO_VAR_LIST \
120 GLOBAL_UBO_VAR_LIST_DO(int, current_frame_idx) \
121 GLOBAL_UBO_VAR_LIST_DO(int, width) \
122 GLOBAL_UBO_VAR_LIST_DO(int, height)\
123 GLOBAL_UBO_VAR_LIST_DO(int, current_gpu_slice_width) \
125 GLOBAL_UBO_VAR_LIST_DO(int, medium) \
126 GLOBAL_UBO_VAR_LIST_DO(float, time) \
127 GLOBAL_UBO_VAR_LIST_DO(int, first_person_model) \
128 GLOBAL_UBO_VAR_LIST_DO(int, environment_type) \
130 GLOBAL_UBO_VAR_LIST_DO(vec3, sun_direction) \
131 GLOBAL_UBO_VAR_LIST_DO(float, bloom_intensity) \
132 GLOBAL_UBO_VAR_LIST_DO(vec3, sun_tangent) \
133 GLOBAL_UBO_VAR_LIST_DO(float, sun_tan_half_angle) \
134 GLOBAL_UBO_VAR_LIST_DO(vec3, sun_bitangent) \
135 GLOBAL_UBO_VAR_LIST_DO(float, sun_bounce_scale) \
136 GLOBAL_UBO_VAR_LIST_DO(vec3, sun_color) \
137 GLOBAL_UBO_VAR_LIST_DO(float, sun_cos_half_angle) \
138 GLOBAL_UBO_VAR_LIST_DO(vec3, sun_direction_envmap) \
139 GLOBAL_UBO_VAR_LIST_DO(int, sun_visible) \
141 GLOBAL_UBO_VAR_LIST_DO(float, sky_transmittance) \
142 GLOBAL_UBO_VAR_LIST_DO(float, sky_phase_g) \
143 GLOBAL_UBO_VAR_LIST_DO(float, sky_amb_phase_g) \
144 GLOBAL_UBO_VAR_LIST_DO(float, sun_solid_angle) \
146 GLOBAL_UBO_VAR_LIST_DO(vec3, physical_sky_ground_radiance) \
147 GLOBAL_UBO_VAR_LIST_DO(int, physical_sky_flags) \
149 GLOBAL_UBO_VAR_LIST_DO(float, sky_scattering) \
150 GLOBAL_UBO_VAR_LIST_DO(float, temporal_blend_factor) \
151 GLOBAL_UBO_VAR_LIST_DO(int, planet_albedo_map) \
152 GLOBAL_UBO_VAR_LIST_DO(int, planet_normal_map) \
154 GLOBAL_UBO_VAR_LIST_DO(int, num_sphere_lights) \
155 GLOBAL_UBO_VAR_LIST_DO(int , num_static_lights) \
156 GLOBAL_UBO_VAR_LIST_DO(int, num_static_primitives) \
157 GLOBAL_UBO_VAR_LIST_DO(int, cluster_debug_index) \
159 GLOBAL_UBO_VAR_LIST_DO(int, water_normal_texture) \
160 GLOBAL_UBO_VAR_LIST_DO(float, pt_env_scale) \
161 GLOBAL_UBO_VAR_LIST_DO(float, cylindrical_hfov) \
162 GLOBAL_UBO_VAR_LIST_DO(float, cylindrical_hfov_prev) \
164 GLOBAL_UBO_VAR_LIST_DO(int, pt_swap_checkerboard) \
165 GLOBAL_UBO_VAR_LIST_DO(float, shadow_map_depth_scale) \
166 GLOBAL_UBO_VAR_LIST_DO(float, god_rays_intensity) \
167 GLOBAL_UBO_VAR_LIST_DO(float, god_rays_eccentricity) \
169 GLOBAL_UBO_VAR_LIST_DO(int, num_cameras) \
170 GLOBAL_UBO_VAR_LIST_DO(int, screen_image_width) \
171 GLOBAL_UBO_VAR_LIST_DO(int, screen_image_height) \
172 GLOBAL_UBO_VAR_LIST_DO(int, prev_gpu_slice_width) \
174 GLOBAL_UBO_VAR_LIST_DO(int, prev_width) \
175 GLOBAL_UBO_VAR_LIST_DO(int, prev_height)\
176 GLOBAL_UBO_VAR_LIST_DO(float, inv_width)\
177 GLOBAL_UBO_VAR_LIST_DO(float, inv_height)\
179 GLOBAL_UBO_VAR_LIST_DO(float, prev_adapted_luminance) \
180 GLOBAL_UBO_VAR_LIST_DO(float, padding1) \
181 GLOBAL_UBO_VAR_LIST_DO(float, padding2) \
182 GLOBAL_UBO_VAR_LIST_DO(float, padding3) \
184 GLOBAL_UBO_VAR_LIST_DO(vec4, world_center) \
185 GLOBAL_UBO_VAR_LIST_DO(vec4, world_size) \
186 GLOBAL_UBO_VAR_LIST_DO(vec4, world_half_size_inv) \
188 GLOBAL_UBO_VAR_LIST_DO(vec4, sphere_light_data[MAX_LIGHT_SOURCES * 2]) \
189 GLOBAL_UBO_VAR_LIST_DO(vec4, cam_pos) \
190 GLOBAL_UBO_VAR_LIST_DO(mat4, V) \
191 GLOBAL_UBO_VAR_LIST_DO(mat4, invV) \
192 GLOBAL_UBO_VAR_LIST_DO(mat4, V_prev) \
193 GLOBAL_UBO_VAR_LIST_DO(mat4, P) \
194 GLOBAL_UBO_VAR_LIST_DO(mat4, invP) \
195 GLOBAL_UBO_VAR_LIST_DO(mat4, P_prev) \
196 GLOBAL_UBO_VAR_LIST_DO(mat4, invP_prev) \
197 GLOBAL_UBO_VAR_LIST_DO(mat4, environment_rotation_matrix) \
198 GLOBAL_UBO_VAR_LIST_DO(mat4, shadow_map_VP) \
199 GLOBAL_UBO_VAR_LIST_DO(mat4, security_camera_data[MAX_CAMERAS]) \
201 UBO_CVAR_LIST // WARNING: Do not put any other members into global_ubo after this: the CVAR list is not vec4-aligned
203 #define INSTANCE_BUFFER_VAR_LIST \
204 INSTANCE_BUFFER_VAR_LIST_DO(int, model_indices [SHADER_MAX_ENTITIES + SHADER_MAX_BSP_ENTITIES]) \
205 INSTANCE_BUFFER_VAR_LIST_DO(uint, model_current_to_prev [SHADER_MAX_ENTITIES]) \
206 INSTANCE_BUFFER_VAR_LIST_DO(uint, model_prev_to_current [SHADER_MAX_ENTITIES]) \
207 INSTANCE_BUFFER_VAR_LIST_DO(uint, world_current_to_prev [SHADER_MAX_BSP_ENTITIES]) \
208 INSTANCE_BUFFER_VAR_LIST_DO(uint, world_prev_to_current [SHADER_MAX_BSP_ENTITIES]) \
209 INSTANCE_BUFFER_VAR_LIST_DO(uint, bsp_prim_offset [SHADER_MAX_BSP_ENTITIES]) \
210 INSTANCE_BUFFER_VAR_LIST_DO(uint, model_idx_offset [SHADER_MAX_ENTITIES]) \
211 INSTANCE_BUFFER_VAR_LIST_DO(uint, model_cluster_id [SHADER_MAX_ENTITIES]) \
212 INSTANCE_BUFFER_VAR_LIST_DO(uint, model_cluster_id_prev [SHADER_MAX_ENTITIES]) \
213 INSTANCE_BUFFER_VAR_LIST_DO(uint, bsp_cluster_id [SHADER_MAX_BSP_ENTITIES]) \
214 INSTANCE_BUFFER_VAR_LIST_DO(uint, bsp_cluster_id_prev [SHADER_MAX_BSP_ENTITIES]) \
215 INSTANCE_BUFFER_VAR_LIST_DO(ModelInstance, model_instances [SHADER_MAX_ENTITIES]) \
216 INSTANCE_BUFFER_VAR_LIST_DO(ModelInstance, model_instances_prev [SHADER_MAX_ENTITIES]) \
217 INSTANCE_BUFFER_VAR_LIST_DO(BspMeshInstance, bsp_mesh_instances [SHADER_MAX_BSP_ENTITIES]) \
218 INSTANCE_BUFFER_VAR_LIST_DO(BspMeshInstance, bsp_mesh_instances_prev [SHADER_MAX_BSP_ENTITIES]) \
220 INSTANCE_BUFFER_VAR_LIST_DO(uint, model_instance_buf_offset[SHADER_MAX_ENTITIES]) \
221 INSTANCE_BUFFER_VAR_LIST_DO(uint, model_instance_buf_size [SHADER_MAX_ENTITIES]) \
222 INSTANCE_BUFFER_VAR_LIST_DO(uint, bsp_instance_buf_offset [SHADER_MAX_BSP_ENTITIES]) \
223 INSTANCE_BUFFER_VAR_LIST_DO(uint, bsp_instance_buf_size [SHADER_MAX_BSP_ENTITIES]) \
227 #if SHADER_MAX_ENTITIES != MAX_ENTITIES
228 #error need to update constant here
238 float alpha;
float padding[3];
243 int frame;
float padding[3];
246 #define int_t int32_t
248 #define GLOBAL_UBO_VAR_LIST_DO(type, name) type##_t name;
250 #undef GLOBAL_UBO_VAR_LIST_DO
254 #define INSTANCE_BUFFER_VAR_LIST_DO(type, name) type name;
256 #undef INSTANCE_BUFFER_VAR_LIST_DO
264 uvec4 mat_offset_backlerp;
273 struct GlobalUniformBuffer {
274 #define GLOBAL_UBO_VAR_LIST_DO(type, name) type name;
276 #undef GLOBAL_UBO_VAR_LIST_DO
279 struct GlobalUniformInstanceBuffer {
280 #define INSTANCE_BUFFER_VAR_LIST_DO(type, name) type name;
282 #undef INSTANCE_BUFFER_VAR_LIST_DO
286 GlobalUniformBuffer global_ubo;
290 GlobalUniformInstanceBuffer instance_buffer;