update vulkan library, fix bugs

This commit is contained in:
Matthew 2026-03-07 19:58:44 +11:00
parent e7124105aa
commit fc67f2512d
3 changed files with 61 additions and 58 deletions

@ -1 +1 @@
Subproject commit 38f7bcf3d6c48aaa4fb8e663cec45bd4d2767561
Subproject commit 0c5521153f63001273170b09b15a5eaabb289885

View File

@ -21,7 +21,7 @@ f32 g_delta = 0.0;
struct RenderCtx
{
PlatformWindow* window;
Descriptor[FS][FO] font_descs;
Descriptor[FS] font_descs;
Descriptor default_tex;
Descriptor sampler;
Pipeline pipeline;

View File

@ -26,7 +26,7 @@ import core.stdc.stdio : sprintf;
- Display string should be separate from key string
- If key is 0 then its transient and will be discarded next frame
- Events should be created then processed instead of directly from inputs
// Little mode ui thing in the corner thats colored and it slides the colour out (left to right) when mode is changed
- Little mode ui thing in the corner thats colored and it slides the colour out (left to right) when mode is changed
*********************************/
@ -190,7 +190,8 @@ struct FontSet
FontAtlas atlas;
u32 size;
u32 index;
bool[FRAME_OVERLAP] loaded;
bool texture_loaded;
bool[FO] descriptor_written;
alias atlas this;
}
@ -408,38 +409,46 @@ InitUI(Ctx* ctx)
alpha_op: BO.Add,
};
for(u64 i = 0; i < ctx.font_descs.length; i += 1)
for(u32 i = 0; i < ctx.font_descs.length; i += 1)
{
for(u32 j = 0; j < ctx.font_descs[i].length; j += 1)
{
CreateImageViewTex(&ctx.font_descs[i][j], ATLAS_DIMENSION, ATLAS_DIMENSION, DT.Image, 0, j);
ctx.font_sets[j].index = j;
}
}
CreateDescriptor(&ctx.font_descs[i], DescInfo(
type: DT.Image,
format: FMT.RGBA_UNORM,
usage: IU.Texture,
w: ATLAS_DIMENSION,
h: ATLAS_DIMENSION,
ch: 4,
binding: 0,
index: i,
));
FontSet* atlas = GetFontSet(14);
LoadFontSet();
ctx.font_sets[i].index = i;
}
CreateGraphicsPipeline(&ctx.pipeline, &ui_info);
ctx.sampler = CreateSampler(MipmapMode.Nearest, 1);
CreateDescriptor(&ctx.sampler, DescInfo(
type: DT.Sampler,
mipmap_mode: MipmapMode.Nearest,
binding: 1,
));
u8[512*512*4] white_tex = 255;
for(u64 i = 0; i < ctx.font_descs.length; i += 1)
{
for(u32 j = 1; j < ctx.font_descs[i].length; j += 1)
{
Transfer(&ctx.font_descs[i][j].view, white_tex, ATLAS_DIMENSION, ATLAS_DIMENSION);
}
Transfer!(true)(&ctx.font_descs[i], white_tex);
}
for(u64 i = 0; i < FRAME_OVERLAP; i += 1)
{
Write(ctx.desc_sets[i], ctx.font_descs[i]);
Write(ctx.desc_sets[i], ctx.font_descs);
Write(ctx.desc_sets[i], &ctx.sampler);
}
SetClearColors([0.0, 0.0, 0.0, 1.0], [0.0, 0.0, 0.0, 0.0]);
FontSet* atlas = GetFontSet(14);
LoadFontSet();
}
}
@ -502,17 +511,15 @@ GetFontSet(u32 size)
if(!fs)
{
u32 i = ctx.font_sets_used;
fs = &ctx.font_sets[i];
fs = &ctx.font_sets[ctx.font_sets_used++];
ctx.fonts_to_load = true;
assert(ctx.font);
fs.atlas = CreateAtlas(&ctx.arena, ctx.font, size, UVec2(ATLAS_DIMENSION));
fs.size = size;
fs.loaded = false;
ctx.fonts_to_load = true;
ctx.font_sets_used += 1;
fs.texture_loaded = false;
fs.descriptor_written = false;
}
return fs;
@ -527,14 +534,18 @@ LoadFontSet()
for(u64 i = 0; i < ctx.font_sets_used; i += 1)
{
FontSet* fs = ctx.font_sets.ptr + i;
if(!fs.loaded[fi])
if(!fs.texture_loaded)
{
Transfer(&ctx.font_descs[fi][i].view, fs.atlas.data, ATLAS_DIMENSION, ATLAS_DIMENSION);
fs.loaded[fi] = true;
}
Transfer!(true)(&ctx.font_descs[i], fs.atlas.data);
fs.texture_loaded = true;
}
Write(ctx.desc_sets[fi], ctx.font_descs[fi]);
if(!fs.descriptor_written[fi])
{
Write(ctx.desc_sets[fi], ctx.font_descs);
fs.descriptor_written[fi] = true;
}
}
ctx.fonts_to_load[fi] = false;
}
@ -1625,14 +1636,6 @@ BeginUI(Inputs* inputs)
PushConstants(ctx.pipeline, &ctx.pc);
Bind(ctx.pipeline, ctx.desc_sets[ctx.f_idx]);
}
else
{
Vec2 ext = GetExtent();
if(ext != ctx.res)
{
ctx.res = ext;
}
}
memset(ctx.buffers[ctx.f_idx].vtx.ptr, 0, Vertex.sizeof * ctx.buffers[ctx.f_idx].count);
ctx.buffers[ctx.f_idx].count = 0;