From: Mikko Rasa Date: Wed, 16 Mar 2022 11:27:47 +0000 (+0200) Subject: Annotate uniforms with descriptor set layout qualifiers X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=a741acd5c501c03de5181656498d2bcbe0df9157;p=libs%2Fgl.git Annotate uniforms with descriptor set layout qualifiers Higher numbered sets are used for data which is expected to change more often. --- diff --git a/builtin_data/_ambientocclusion.glsl b/builtin_data/_ambientocclusion.glsl index ecdaed7a..0fca6bb2 100644 --- a/builtin_data/_ambientocclusion.glsl +++ b/builtin_data/_ambientocclusion.glsl @@ -1,6 +1,6 @@ const int max_samples = 128; -uniform CameraTransform +layout(set=0) uniform CameraTransform { mat4 eye_world_matrix; mat4 world_eye_matrix; @@ -8,11 +8,11 @@ uniform CameraTransform mat4 eye_clip_matrix; }; -uniform sampler2D source; -uniform sampler2D depth; -uniform sampler2D occlusion; -uniform sampler2D rotate; -uniform AmbientOcclusionParams +layout(set=2) uniform sampler2D source; +layout(set=2) uniform sampler2D depth; +layout(set=2) uniform sampler2D occlusion; +layout(set=2) uniform sampler2D rotate; +layout(set=2) uniform AmbientOcclusionParams { float darkness; vec3 sample_points[max_samples]; diff --git a/builtin_data/_bloom.glsl b/builtin_data/_bloom.glsl index f261cc1d..21da9235 100644 --- a/builtin_data/_bloom.glsl +++ b/builtin_data/_bloom.glsl @@ -1,12 +1,12 @@ -uniform sampler2D source; -uniform sampler2D blurred; -uniform BloomParams +layout(set=2) uniform sampler2D source; +layout(set=2) uniform sampler2D blurred; +layout(set=2) uniform BloomParams { float factors[19]; int size; float strength; }; -uniform BloomPerPassParams +layout(set=2) uniform BloomPerPassParams { uniform vec2 delta; }; diff --git a/builtin_data/_colorcurve.glsl b/builtin_data/_colorcurve.glsl index 9b6ae362..afa6ee32 100644 --- a/builtin_data/_colorcurve.glsl +++ b/builtin_data/_colorcurve.glsl @@ -1,13 +1,13 @@ import flat_effect; -uniform ToneMapping +layout(set=2) uniform ToneMapping { float exposure; vec3 brightness_response; }; -uniform sampler2D source; -uniform sampler1D curve; +layout(set=2) uniform sampler2D source; +layout(set=2) uniform sampler1D curve; #pragma MSP stage(fragment) layout(location=0) out vec4 frag_color; diff --git a/builtin_data/_pbr_prefilter.glsl b/builtin_data/_pbr_prefilter.glsl index 50fde165..2d3b8f59 100644 --- a/builtin_data/_pbr_prefilter.glsl +++ b/builtin_data/_pbr_prefilter.glsl @@ -4,7 +4,7 @@ layout(push_constant) uniform PrecalcParams float roughness; }; -uniform samplerCube environment_map; +layout(set=0) uniform samplerCube environment_map; vec2 hammersley(int i, int count) { diff --git a/builtin_data/_sky.glsl b/builtin_data/_sky.glsl index 1dbda579..4ece8e57 100644 --- a/builtin_data/_sky.glsl +++ b/builtin_data/_sky.glsl @@ -6,7 +6,7 @@ struct AtmosphericEvents vec3 ozone_absorb; }; -uniform Atmosphere +layout(set=2) uniform Atmosphere { AtmosphericEvents events; float rayleigh_density_decay; @@ -19,7 +19,7 @@ uniform Atmosphere int n_steps; }; -uniform View +layout(set=2) uniform View { float view_height; vec4 light_color; @@ -34,7 +34,7 @@ struct OpticalPathInfo const float mie_asymmetry = 0.8; -uniform sampler2D transmittance_lookup; +layout(set=2) uniform sampler2D transmittance_lookup; vec3 rayleigh_density(vec3 base, float height) { diff --git a/builtin_data/_sky_backdrop.glsl b/builtin_data/_sky_backdrop.glsl index fa8f1be5..8e90d91c 100644 --- a/builtin_data/_sky_backdrop.glsl +++ b/builtin_data/_sky_backdrop.glsl @@ -1,7 +1,7 @@ import msp_interface; import _sky; -uniform sampler2D distant; +layout(set=2) uniform sampler2D distant; #pragma MSP stage(vertex) void main() diff --git a/shaderlib/common.glsl b/shaderlib/common.glsl index 557d4d76..44ef150a 100644 --- a/shaderlib/common.glsl +++ b/shaderlib/common.glsl @@ -1,14 +1,14 @@ import msp_interface; import shadow; -uniform EnvMap +layout(set=0) uniform EnvMap { mat3 env_world_matrix; }; -uniform sampler2D normal_map; -uniform samplerCube environment_map; -uniform samplerCube irradiance_map; +layout(set=1) uniform sampler2D normal_map; +layout(set=0) uniform samplerCube environment_map; +layout(set=0) uniform samplerCube irradiance_map; layout(constant_id=auto) const bool use_normal_map = false; diff --git a/shaderlib/cooktorrance.glsl b/shaderlib/cooktorrance.glsl index ad1a459d..fe6179b7 100644 --- a/shaderlib/cooktorrance.glsl +++ b/shaderlib/cooktorrance.glsl @@ -10,18 +10,18 @@ struct PbrMaterialParameters float roughness; }; -uniform PbrMaterial +layout(set=1) uniform PbrMaterial { PbrMaterialParameters pbr_material; float alpha_cutoff; }; -uniform sampler2D base_color_map; -uniform sampler2D metalness_map; -uniform sampler2D roughness_map; -uniform sampler2D occlusion_map; -uniform sampler2D emission_map; -uniform sampler2D fresnel_lookup; +layout(set=1) uniform sampler2D base_color_map; +layout(set=1) uniform sampler2D metalness_map; +layout(set=1) uniform sampler2D roughness_map; +layout(set=1) uniform sampler2D occlusion_map; +layout(set=1) uniform sampler2D emission_map; +layout(set=1) uniform sampler2D fresnel_lookup; layout(constant_id=auto) const bool use_base_color_map = false; layout(constant_id=auto) const bool use_metalness_map = false; diff --git a/shaderlib/msp_interface.glsl b/shaderlib/msp_interface.glsl index 3ad27c43..5ecb4f82 100644 --- a/shaderlib/msp_interface.glsl +++ b/shaderlib/msp_interface.glsl @@ -11,7 +11,7 @@ layout(push_constant) uniform ObjectTransform mat4 world_obj_matrix; mat3 world_obj_normal_matrix; }; -uniform CameraTransform +layout(set=0) uniform CameraTransform { mat4 eye_world_matrix; mat4 world_eye_matrix; @@ -20,7 +20,7 @@ uniform CameraTransform }; const int max_lights = 6; -uniform Lighting +layout(set=0) uniform Lighting { LightSourceParameters light_sources[max_lights]; vec4 ambient_color; diff --git a/shaderlib/occluder.glsl b/shaderlib/occluder.glsl index abd29a0a..6d6cd560 100644 --- a/shaderlib/occluder.glsl +++ b/shaderlib/occluder.glsl @@ -1,11 +1,11 @@ import msp_interface; -uniform AlphaCutoff +layout(set=1) uniform AlphaCutoff { float alpha_cutoff; }; -uniform sampler2D alpha_map; +layout(set=1) uniform sampler2D alpha_map; layout(constant_id=auto) const bool use_alpha_cutoff = false; diff --git a/shaderlib/phong.glsl b/shaderlib/phong.glsl index 23489711..28e9e500 100644 --- a/shaderlib/phong.glsl +++ b/shaderlib/phong.glsl @@ -11,17 +11,17 @@ struct BasicMaterialParameters float reflectivity; }; -uniform BasicMaterial +layout(set=1) uniform BasicMaterial { BasicMaterialParameters basic_material; float alpha_cutoff; }; -uniform sampler2D diffuse_map; -uniform sampler2D specular_map; -uniform sampler2D shininess_map; -uniform sampler2D emission_map; -uniform sampler2D reflectivity_map; +layout(set=1) uniform sampler2D diffuse_map; +layout(set=1) uniform sampler2D specular_map; +layout(set=1) uniform sampler2D shininess_map; +layout(set=1) uniform sampler2D emission_map; +layout(set=1) uniform sampler2D reflectivity_map; layout(constant_id=auto) const bool use_diffuse_map = false; layout(constant_id=auto) const bool use_specular = false; diff --git a/shaderlib/shadow.glsl b/shaderlib/shadow.glsl index 2e8a05b0..049ec188 100644 --- a/shaderlib/shadow.glsl +++ b/shaderlib/shadow.glsl @@ -9,13 +9,13 @@ struct ShadowParameters vec2 bias; }; -uniform ShadowMap +layout(set=0) uniform ShadowMap { ShadowParameters shadows[max_lights]; mat4 shd_world_matrix[max_lights*4]; }; -uniform sampler2DShadow shadow_map; +layout(set=0) uniform sampler2DShadow shadow_map; layout(constant_id=auto) const bool use_shadow_map = false; diff --git a/shaderlib/unlit.glsl b/shaderlib/unlit.glsl index f4920a79..29cfd3f2 100644 --- a/shaderlib/unlit.glsl +++ b/shaderlib/unlit.glsl @@ -6,13 +6,13 @@ struct UnlitMaterialParameters vec4 color; }; -uniform UnlitMaterial +layout(set=1) uniform UnlitMaterial { UnlitMaterialParameters unlit_material; float alpha_cutoff; }; -uniform sampler2D color_tex; +layout(set=1) uniform sampler2D color_tex; layout(constant_id=auto) const bool use_texture = false; layout(constant_id=auto) const bool use_vertex_color = false;