Skip to content

Commit

Permalink
fixes for sokol-gfx bindings cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Nov 8, 2024
1 parent 2c3dd08 commit edcb0fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
12 changes: 5 additions & 7 deletions src/gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ void gfx_init(const gfx_desc_t* desc) {
sg_pipeline_desc pip_desc_alpha = {
.layout = {
.attrs = {
[ATTR_vs_pos] = { .format = SG_VERTEXFORMAT_USHORT2N },
[ATTR_vs_uv] = { .format = SG_VERTEXFORMAT_USHORT2N }
[0] = { .format = SG_VERTEXFORMAT_USHORT2N },
[1] = { .format = SG_VERTEXFORMAT_USHORT2N }
},
},
.shader = sg_make_shader(shd_alpha_shader_desc(sg_query_backend())),
Expand Down Expand Up @@ -186,12 +186,10 @@ void gfx_draw(void) {
if (gfx.layer_visible[i] && (gfx.layers[i].vb.id != SG_INVALID_ID)) {
sg_apply_bindings(&(sg_bindings){
.vertex_buffers[0] = gfx.layers[i].vb,
.vs = {
.images[SLOT_palette_tex] = gfx.img,
.samplers[SLOT_palette_smp] = gfx.smp,
}
.images[IMG_palette_tex] = gfx.img,
.samplers[SMP_palette_smp] = gfx.smp,
});
sg_apply_uniforms(SG_SHADERSTAGE_VS, SLOT_vs_params, &SG_RANGE(vs_params));
sg_apply_uniforms(UB_vs_params, &SG_RANGE(vs_params));
sg_draw(0, gfx.layers[i].num_elms, 1);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/gfx.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@ctype vec2 float2_t

@vs vs
uniform vs_params {
layout(binding=0) uniform vs_params {
vec4 color0;
vec2 half_size;
vec2 offset;
Expand All @@ -15,10 +15,10 @@ uniform vs_params {

const float max_nodes = 8192.0;

uniform texture2D palette_tex;
uniform sampler palette_smp;
in vec2 pos;
in vec2 uv;
layout(binding=0) uniform texture2D palette_tex;
layout(binding=0) uniform sampler palette_smp;
layout(location=0) in vec2 pos;
layout(location=1) in vec2 uv;
out vec4 color;

void main() {
Expand Down

0 comments on commit edcb0fb

Please sign in to comment.