2024-10-09 20:00:56 -06:00
|
|
|
#version 450
|
|
|
|
#extension GL_EXT_buffer_reference : require
|
|
|
|
|
2024-10-18 16:15:00 -06:00
|
|
|
struct String {
|
|
|
|
vec2 pos;
|
|
|
|
vec4 color;
|
|
|
|
float size;
|
|
|
|
uint code;
|
|
|
|
};
|
|
|
|
|
|
|
|
layout(std430, buffer_reference) readonly buffer StringList {
|
|
|
|
String s[];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Glyph {
|
|
|
|
vec2 pos;
|
|
|
|
vec4 color;
|
|
|
|
float size;
|
|
|
|
uint code;
|
|
|
|
};
|
|
|
|
|
|
|
|
layout(std430, buffer_reference) readonly buffer GlyphList {
|
|
|
|
Glyph g[];
|
|
|
|
};
|
|
|
|
|
2024-10-17 17:31:13 -06:00
|
|
|
struct Rect {
|
2024-10-18 16:15:00 -06:00
|
|
|
vec2 pos;
|
2024-10-17 17:31:13 -06:00
|
|
|
vec2 size;
|
|
|
|
vec4 color;
|
|
|
|
};
|
|
|
|
|
|
|
|
layout(std430, buffer_reference) readonly buffer RectList {
|
|
|
|
Rect r[];
|
|
|
|
};
|
|
|
|
|
2024-10-18 16:15:00 -06:00
|
|
|
layout(std430, buffer_reference) readonly buffer CodeList {
|
|
|
|
uint c[];
|
2024-10-18 14:26:41 -06:00
|
|
|
};
|
|
|
|
|
2024-10-18 16:15:00 -06:00
|
|
|
struct DrawCommand {
|
|
|
|
uint vertex_count;
|
|
|
|
uint instance_count;
|
|
|
|
uint fist_vertex;
|
|
|
|
uint first_instance;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DispatchCommand {
|
|
|
|
uint x;
|
|
|
|
uint y;
|
|
|
|
uint z;
|
|
|
|
};
|
|
|
|
|
|
|
|
layout(std430, buffer_reference) buffer UILayer {
|
|
|
|
StringList strings;
|
|
|
|
CodeList codes;
|
|
|
|
|
2024-10-17 17:31:13 -06:00
|
|
|
RectList rects;
|
2024-10-18 16:15:00 -06:00
|
|
|
GlyphList glyphs;
|
|
|
|
|
|
|
|
DrawCommand draw_glyphs;
|
|
|
|
DrawCommand draw_rects;
|
|
|
|
|
|
|
|
DispatchCommand dispatch_strings;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Symbol {
|
|
|
|
int top;
|
|
|
|
uint left;
|
|
|
|
uint width;
|
|
|
|
uint height;
|
|
|
|
uint advance;
|
|
|
|
};
|
|
|
|
|
|
|
|
layout(std430, buffer_reference) buffer SymbolList {
|
|
|
|
Symbol s[];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct Font {
|
|
|
|
uint num_symbols;
|
|
|
|
uint width;
|
|
|
|
uint height;
|
|
|
|
SymbolList symbols;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
layout(std430, buffer_reference) buffer FontList {
|
|
|
|
Font f[];
|
|
|
|
};
|
|
|
|
|
|
|
|
layout(std430, buffer_reference) buffer UIContext {
|
|
|
|
mat4 screen;
|
|
|
|
FontList fonts;
|
|
|
|
};
|
|
|
|
|
|
|
|
layout(std430, push_constant) uniform PushConstant {
|
|
|
|
UIContext context;
|
|
|
|
UILayer layer;
|
2024-10-17 17:31:13 -06:00
|
|
|
} pc;
|
2024-10-09 20:00:56 -06:00
|
|
|
|
|
|
|
layout(location = 0) out vec4 fragColor;
|
|
|
|
|
2024-10-17 15:56:35 -06:00
|
|
|
const vec2 square[6] = {
|
|
|
|
vec2(0.0, 0.0),
|
|
|
|
vec2(1.0, 0.0),
|
|
|
|
vec2(0.0, 1.0),
|
|
|
|
vec2(1.0, 0.0),
|
|
|
|
vec2(1.0, 1.0),
|
|
|
|
vec2(0.0, 1.0),
|
|
|
|
};
|
|
|
|
|
2024-10-09 20:00:56 -06:00
|
|
|
void main() {
|
2024-10-18 16:15:00 -06:00
|
|
|
Rect rect = pc.layer.rects.r[gl_InstanceIndex];
|
|
|
|
gl_Position = pc.context.screen * vec4(square[gl_VertexIndex] * rect.size + rect.pos, 0.0, 1.0);
|
2024-10-17 17:31:13 -06:00
|
|
|
fragColor = rect.color;
|
2024-10-09 20:00:56 -06:00
|
|
|
}
|
|
|
|
|