From 6867b0e9a63078cf1aba715bacba9dbaae8b72ad Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 7 Dec 2024 23:00:53 +0100 Subject: [PATCH] Validation layer is complaining about missing readonly specifier on buffers in GLSL --- .../shaders/lightmap/binding_lightmapper.glsl | 14 ++++++------ .../shaders/lightmap/binding_raytrace.glsl | 6 ++--- .../shaders/lightmap/binding_viewer.glsl | 16 +++++++------- .../static/shaders/scene/binding_fixed.glsl | 6 ++--- .../shaders/scene/binding_rsbuffers.glsl | 22 +++++++++---------- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/wadsrc/static/shaders/lightmap/binding_lightmapper.glsl b/wadsrc/static/shaders/lightmap/binding_lightmapper.glsl index a03e2ab49c..393a01b503 100644 --- a/wadsrc/static/shaders/lightmap/binding_lightmapper.glsl +++ b/wadsrc/static/shaders/lightmap/binding_lightmapper.glsl @@ -1,5 +1,5 @@ -layout(set = 0, binding = 0) uniform Uniforms +layout(set = 0, binding = 0) uniform readonly Uniforms { vec3 SunDir; float Padding1; @@ -42,11 +42,11 @@ struct LightInfo float Padding3; }; -layout(set = 0, binding = 1) buffer SurfaceIndexBuffer { uint surfaceIndices[]; }; -layout(set = 0, binding = 2) buffer SurfaceBuffer { SurfaceInfo surfaces[]; }; -layout(set = 0, binding = 3) buffer LightBuffer { LightInfo lights[]; }; -layout(set = 0, binding = 4) buffer LightIndexBuffer { int lightIndexes[]; }; -layout(set = 0, binding = 5) buffer PortalBuffer { PortalInfo portals[]; }; +layout(set = 0, binding = 1) buffer readonly SurfaceIndexBuffer { uint surfaceIndices[]; }; +layout(set = 0, binding = 2) buffer readonly SurfaceBuffer { SurfaceInfo surfaces[]; }; +layout(set = 0, binding = 3) buffer readonly LightBuffer { LightInfo lights[]; }; +layout(set = 0, binding = 4) buffer readonly LightIndexBuffer { int lightIndexes[]; }; +layout(set = 0, binding = 5) buffer readonly PortalBuffer { PortalInfo portals[]; }; struct LightmapRaytracePC { @@ -66,4 +66,4 @@ struct LightmapRaytracePC float TileHeight; }; -layout(std430, set = 0, binding = 6) buffer ConstantsBuffer { LightmapRaytracePC constants[]; }; +layout(std430, set = 0, binding = 6) buffer readonly ConstantsBuffer { LightmapRaytracePC constants[]; }; diff --git a/wadsrc/static/shaders/lightmap/binding_raytrace.glsl b/wadsrc/static/shaders/lightmap/binding_raytrace.glsl index 88c9eeefe6..3083d3623e 100644 --- a/wadsrc/static/shaders/lightmap/binding_raytrace.glsl +++ b/wadsrc/static/shaders/lightmap/binding_raytrace.glsl @@ -17,7 +17,7 @@ struct CollisionNode int padding3; }; -layout(std430, set = 1, binding = 0) buffer NodeBuffer +layout(std430, set = 1, binding = 0) buffer readonly NodeBuffer { int nodesRoot; int nodebufferPadding1; @@ -36,5 +36,5 @@ struct SurfaceVertex // Note: this must always match the FFlatVertex struct vec2 luv; }; -layout(std430, set = 1, binding = 1) buffer VertexBuffer { SurfaceVertex vertices[]; }; -layout(std430, set = 1, binding = 2) buffer ElementBuffer { int elements[]; }; +layout(std430, set = 1, binding = 1) buffer readonly VertexBuffer { SurfaceVertex vertices[]; }; +layout(std430, set = 1, binding = 2) buffer readonly ElementBuffer { int elements[]; }; diff --git a/wadsrc/static/shaders/lightmap/binding_viewer.glsl b/wadsrc/static/shaders/lightmap/binding_viewer.glsl index 8701703db0..5a5dbc1b75 100644 --- a/wadsrc/static/shaders/lightmap/binding_viewer.glsl +++ b/wadsrc/static/shaders/lightmap/binding_viewer.glsl @@ -34,11 +34,11 @@ struct LightInfo float Padding3; }; -layout(set = 0, binding = 0, std430) buffer SurfaceIndexBuffer { uint surfaceIndices[]; }; -layout(set = 0, binding = 1, std430) buffer SurfaceBuffer { SurfaceInfo surfaces[]; }; -layout(set = 0, binding = 2, std430) buffer LightBuffer { LightInfo lights[]; }; -layout(set = 0, binding = 3, std430) buffer LightIndexBuffer { int lightIndexes[]; }; -layout(set = 0, binding = 4, std430) buffer PortalBuffer { PortalInfo portals[]; }; +layout(set = 0, binding = 0, std430) buffer readonly SurfaceIndexBuffer { uint surfaceIndices[]; }; +layout(set = 0, binding = 1, std430) buffer readonly SurfaceBuffer { SurfaceInfo surfaces[]; }; +layout(set = 0, binding = 2, std430) buffer readonly LightBuffer { LightInfo lights[]; }; +layout(set = 0, binding = 3, std430) buffer readonly LightIndexBuffer { int lightIndexes[]; }; +layout(set = 0, binding = 4, std430) buffer readonly PortalBuffer { PortalInfo portals[]; }; #if defined(USE_RAYQUERY) @@ -58,7 +58,7 @@ struct CollisionNode int padding3; }; -layout(set = 0, binding = 5, std430) buffer NodeBuffer +layout(set = 0, binding = 5, std430) buffer readonly NodeBuffer { int nodesRoot; int nodebufferPadding1; @@ -77,8 +77,8 @@ struct SurfaceVertex // Note: this must always match the FFlatVertex struct vec2 luv; }; -layout(set = 0, binding = 6, std430) buffer VertexBuffer { SurfaceVertex vertices[]; }; -layout(set = 0, binding = 7, std430) buffer ElementBuffer { int elements[]; }; +layout(set = 0, binding = 6, std430) buffer readonly VertexBuffer { SurfaceVertex vertices[]; }; +layout(set = 0, binding = 7, std430) buffer readonly ElementBuffer { int elements[]; }; layout(set = 1, binding = 0) uniform sampler2D textures[]; diff --git a/wadsrc/static/shaders/scene/binding_fixed.glsl b/wadsrc/static/shaders/scene/binding_fixed.glsl index 902665a2c8..b5b39da698 100644 --- a/wadsrc/static/shaders/scene/binding_fixed.glsl +++ b/wadsrc/static/shaders/scene/binding_fixed.glsl @@ -20,7 +20,7 @@ struct CollisionNode int element_index; int padding3; }; -layout(std430, set = 0, binding = 5) buffer NodeBuffer +layout(std430, set = 0, binding = 5) buffer readonly NodeBuffer { int nodesRoot; int nodebufferPadding1; @@ -35,7 +35,7 @@ struct SurfaceVertex // Note: this must always match the FFlatVertex struct vec2 uv; vec2 luv; }; -layout(std430, set = 0, binding = 6) buffer VertexBuffer { SurfaceVertex vertices[]; }; -layout(std430, set = 0, binding = 7) buffer ElementBuffer { int elements[]; }; +layout(std430, set = 0, binding = 6) buffer readonly VertexBuffer { SurfaceVertex vertices[]; }; +layout(std430, set = 0, binding = 7) buffer readonly ElementBuffer { int elements[]; }; #endif #endif diff --git a/wadsrc/static/shaders/scene/binding_rsbuffers.glsl b/wadsrc/static/shaders/scene/binding_rsbuffers.glsl index 1ff0fc2908..47039f7248 100644 --- a/wadsrc/static/shaders/scene/binding_rsbuffers.glsl +++ b/wadsrc/static/shaders/scene/binding_rsbuffers.glsl @@ -1,6 +1,6 @@ // This must match the HWViewpointUniforms struct -layout(set = 1, binding = 0, std140) uniform ViewpointUBO +layout(set = 1, binding = 0, std140) uniform readonly ViewpointUBO { mat4 ProjectionMatrix; mat4 ViewMatrix; @@ -21,7 +21,7 @@ layout(set = 1, binding = 0, std140) uniform ViewpointUBO int uLightTilesWidth; // Levelmesh light tiles }; -layout(set = 1, binding = 1, std140) uniform MatricesUBO +layout(set = 1, binding = 1, std140) uniform readonly MatricesUBO { mat4 ModelMatrix; mat4 NormalModelMatrix; @@ -93,52 +93,52 @@ struct Fogball #ifdef USE_LEVELMESH -layout(set = 1, binding = 2, std430) buffer SurfaceUniformsSSO +layout(set = 1, binding = 2, std430) buffer readonly SurfaceUniformsSSO { SurfaceUniforms data[]; }; -layout(set = 1, binding = 3, std430) buffer SurfaceLightUniformsSSO +layout(set = 1, binding = 3, std430) buffer readonly SurfaceLightUniformsSSO { SurfaceLightUniforms lightdata[]; }; -layout(set = 1, binding = 4, std430) buffer LightBufferSSO +layout(set = 1, binding = 4, std430) buffer readonly LightBufferSSO { vec4 lights[]; }; -layout(set = 1, binding = 5, std140) uniform FogballBufferUBO +layout(set = 1, binding = 5, std140) uniform readonly FogballBufferUBO { Fogball fogballs[MAX_FOGBALL_DATA]; }; // bone matrix buffers -layout(set = 1, binding = 6, std430) buffer BoneBufferSSO +layout(set = 1, binding = 6, std430) buffer readonly BoneBufferSSO { mat4 bones[]; }; #else -layout(set = 1, binding = 2, std140) uniform SurfaceUniformsUBO +layout(set = 1, binding = 2, std140) uniform readonly SurfaceUniformsUBO { SurfaceUniforms data[MAX_SURFACE_UNIFORMS]; }; // light buffers -layout(set = 1, binding = 3, std140) uniform LightBufferUBO +layout(set = 1, binding = 3, std140) uniform readonly LightBufferUBO { vec4 lights[MAX_LIGHT_DATA]; }; -layout(set = 1, binding = 4, std140) uniform FogballBufferUBO +layout(set = 1, binding = 4, std140) uniform readonly FogballBufferUBO { Fogball fogballs[MAX_FOGBALL_DATA]; }; // bone matrix buffers -layout(set = 1, binding = 5, std430) buffer BoneBufferSSO +layout(set = 1, binding = 5, std430) buffer readonly BoneBufferSSO { mat4 bones[]; };