Fixed struct alignment to align vec3s to 16 bytes

main
noah metz 2024-10-18 10:02:39 -06:00
parent b67a2a924c
commit 22d3b62b12
4 changed files with 12 additions and 10 deletions

@ -20,7 +20,8 @@ typedef struct GraphicsPipelineStruct {
} GraphicsPipeline;
typedef struct ColoredRectStruct {
vec4 pos;
vec3 pos;
uint32_t padding0;
vec2 size;
vec4 color;
} ColoredRect;
@ -30,7 +31,8 @@ typedef struct UIUniformStruct {
} UIUniform;
typedef struct StringStruct {
vec4 pos;
vec3 pos;
uint32_t padding0;
vec4 color;
float size;
uint32_t offset;
@ -52,7 +54,8 @@ typedef struct StringPointersStruct {
} StringPointers;
typedef struct CharacterStruct {
vec4 pos;
vec3 pos;
uint32_t padding0;
vec4 color;
float size;
uint32_t code;

@ -6,7 +6,7 @@ layout(set = 0, binding = 0) uniform UIUniform {
} ubo;
struct Rect {
vec4 pos;
vec3 pos;
vec2 size;
vec4 color;
};

@ -10,14 +10,14 @@ struct Symbol {
};
struct Character {
vec4 pos;
vec3 pos;
vec4 color;
float size;
uint code;
};
struct String {
vec4 pos;
vec3 pos;
vec4 color;
float size;
uint offset;
@ -75,11 +75,10 @@ void main() {
float x = 0;
for(uint i = 0; i < string.len; i++) {
Symbol symbol = font.symbol_list.symbols[push.pointers.codes.codes[string.offset + i]];
push.pointers.characters.characters[buffer_pos + i].pos = vec4(string.pos.xyz + vec3(x, 0, 0), 0);
push.pointers.characters.characters[buffer_pos + i].pos = string.pos + vec3(x, 0, 0);
x += string.size*symbol.advance/font.width;
push.pointers.characters.characters[buffer_pos + i].size = string.size;
push.pointers.characters.characters[buffer_pos + i].color = string.color;
push.pointers.characters.characters[buffer_pos + i].code = push.pointers.codes.codes[string.offset + i];
}
// Write the characters to push.pointers.characters.characters[buffer_pos:buffer_pos+string.len)
}

@ -10,7 +10,7 @@ struct Symbol {
};
struct Character {
vec4 pos;
vec3 pos;
vec4 color;
float size;
uint code;
@ -68,7 +68,7 @@ void main() {
fragUV = vec2(fragU, fragV);
fragColor = character.color;
gl_Position = ubo.screen * vec4(vec3(x, y, 0.0) + character.pos.xyz, 1.0);
gl_Position = ubo.screen * vec4(vec3(x, y, 0.0) + character.pos, 1.0);
code = character.code;
}