diff options
Diffstat (limited to 'shaders')
| -rw-r--r-- | shaders/compute.comp | 2 | ||||
| -rw-r--r-- | shaders/tonemapping.comp | 2 | ||||
| -rw-r--r-- | shaders/ui.frag | 12 | ||||
| -rw-r--r-- | shaders/ui.vert | 18 |
4 files changed, 23 insertions, 11 deletions
diff --git a/shaders/compute.comp b/shaders/compute.comp index db5756c..0696f6d 100644 --- a/shaders/compute.comp +++ b/shaders/compute.comp @@ -94,7 +94,7 @@ layout(buffer_reference) readonly buffer nodes_array { bvh_node[] nodes; }; -layout(set = 0, binding = 0, rgba32f) uniform image2D images[]; +layout(set = 0, binding = 2, rgba32f) uniform image2D images[]; layout(push_constant) uniform buffers { scene_metadata scene; diff --git a/shaders/tonemapping.comp b/shaders/tonemapping.comp index 5613d55..94c7479 100644 --- a/shaders/tonemapping.comp +++ b/shaders/tonemapping.comp @@ -8,7 +8,7 @@ layout(buffer_reference) readonly buffer scene_metadata { uint downscale_factor;
};
-layout(set = 0, binding = 0, rgba32f) uniform image2D images[];
+layout(set = 0, binding = 2, rgba32f) uniform image2D images[];
layout(push_constant) uniform constants {
scene_metadata scene;
diff --git a/shaders/ui.frag b/shaders/ui.frag index 78833d1..c4e0150 100644 --- a/shaders/ui.frag +++ b/shaders/ui.frag @@ -1,3 +1,5 @@ +#extension GL_EXT_nonuniform_qualifier : require
+
layout(location = 0) out vec4 o_Color;
layout(location = 0) in struct {
@@ -5,8 +7,14 @@ layout(location = 0) in struct { vec4 color;
} In;
-layout(set = 0, binding = 2) uniform sampler2D atlas;
+layout(set = 0, binding = 0) uniform sampler samplers[];
+layout(set = 0, binding = 1) uniform texture2D textures[];
+
+layout(push_constant) uniform constants {
+ layout(offset = 56) uint texture_index;
+ uint sampler_index;
+} consts;
void main() {
- o_Color = In.color * texture(atlas, In.uv.xy);
+ o_Color = In.color * texture(sampler2D(textures[consts.texture_index], samplers[consts.sampler_index]), In.uv.xy);
}
diff --git a/shaders/ui.vert b/shaders/ui.vert index c935357..dd71ef6 100644 --- a/shaders/ui.vert +++ b/shaders/ui.vert @@ -1,17 +1,21 @@ -struct Vertex {
+#extension GL_EXT_buffer_reference : require
+
+struct vertex {
vec2 pos;
vec2 uv;
uint color;
+ uint[3] padding;
};
-layout(set = 0, binding = 0) uniform Vertices {
- Vertex vertices[158];
+layout(buffer_reference) readonly buffer vertices {
+ vertex vertices[];
};
-layout(set = 0, binding = 1) uniform UiTransforms {
+layout(push_constant) uniform constants {
+ layout(offset = 32) vertices vertex_buffer;
vec2 scale;
vec2 translate;
-};
+} consts;
out gl_PerVertex {
vec4 gl_Position;
@@ -24,10 +28,10 @@ layout(location = 0) out struct { void main() {
- Vertex v = vertices[gl_VertexIndex];
+ vertex v = consts.vertex_buffer.vertices[gl_VertexIndex];
Out.color = unpackUnorm4x8(v.color);
Out.uv = v.uv;
- gl_Position = vec4(v.pos * scale + translate, 0.0, 1.0);
+ gl_Position = vec4(v.pos * consts.scale + consts.translate, 0.0, 1.0);
}
|
