Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for sokol-gfx bindings cleanup. #31

Merged
merged 6 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
.hash = "122084d460283a7f621f64817c12a4689dacda8c8b02cf9c46747a3572c2166bee83",
},
.shdc = .{
.url = "git+https://github.com/floooh/sokol-tools-bin#0732ba3f61dcfd0d0988f4c351421d84ec8b67e4",
.hash = "1220169ae64fd1a357d9dbefc476d3b2f1c9f68ebf979fc56b5947bb0ddba9cceaae",
.url = "git+https://github.com/floooh/sokol-tools-bin#9d15a9b3f39624c32faebeaf6284e6d64209f988",
.hash = "12202522a9311ecc8ddcefd60b3943d1ca5a6717f5230a193ca63bf3d53c29c59bf7",
},
},
}
10 changes: 5 additions & 5 deletions src/examples/blend.d
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void init()
layout: {
buffers: [{stride: 28}],
attrs: [
shd.ATTR_VS_BG_POSITION: {format: sg.VertexFormat.Float2},
shd.ATTR_BG_POSITION: {format: sg.VertexFormat.Float2},
],
},
primitive_type: sg.PrimitiveType.Triangle_strip
Expand All @@ -72,8 +72,8 @@ void init()
shader: sg.makeShader(shd.quadShaderDesc(sg.queryBackend())),
layout: {
attrs: [
shd.ATTR_VS_QUAD_POSITION: {format: sg.VertexFormat.Float3},
shd.ATTR_VS_QUAD_COLOR0: {format: sg.VertexFormat.Float4},
shd.ATTR_QUAD_POSITION: {format: sg.VertexFormat.Float3},
shd.ATTR_QUAD_COLOR0: {format: sg.VertexFormat.Float4},
],
},
primitive_type: sg.PrimitiveType.Triangle_strip,
Expand Down Expand Up @@ -117,7 +117,7 @@ void frame()
size: state.bg_fs_params.sizeof,};
sg.applyPipeline(state.bg_pip);
sg.applyBindings(state.bind);
sg.applyUniforms(sg.ShaderStage.Fs, shd.SLOT_BG_FS_PARAMS, r);
sg.applyUniforms(shd.UB_BG_FS_PARAMS, r);
sg.draw(0, 4, 1);

// draw the blended quads
Expand All @@ -138,7 +138,7 @@ void frame()
};
sg.applyPipeline(state.pips[src][dst]);
sg.applyBindings(state.bind);
sg.applyUniforms(sg.ShaderStage.Vs, shd.SLOT_QUAD_VS_PARAMS, rg);
sg.applyUniforms(shd.UB_QUAD_VS_PARAMS, rg);
sg.draw(0, 4, 1);
r0 += 0.6;
}
Expand Down
6 changes: 3 additions & 3 deletions src/examples/cube.d
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ void init()
sg.PipelineDesc pld = {
layout: {
attrs: [
shd.ATTR_VS_POSITION: {format: sg.VertexFormat.Float3},
shd.ATTR_VS_COLOR0: {format: sg.VertexFormat.Float4},
shd.ATTR_CUBE_POSITION: {format: sg.VertexFormat.Float3},
shd.ATTR_CUBE_COLOR0: {format: sg.VertexFormat.Float4},
],
},
shader: sg.makeShader(shd.cubeShaderDesc(sg.queryBackend())),
Expand All @@ -123,7 +123,7 @@ void frame()
sg.applyPipeline(state.pip);
sg.applyBindings(state.bind);
sg.Range r = {ptr: &vsParams, size: vsParams.sizeof};
sg.applyUniforms(sg.ShaderStage.Vs, shd.SLOT_VS_PARAMS, r);
sg.applyUniforms(shd.UB_VS_PARAMS, r);
sg.draw(0, 36, 1);
sg.endPass();
sg.commit();
Expand Down
22 changes: 11 additions & 11 deletions src/examples/mrt.d
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ void init()
sg.PipelineDesc offscreen_pip_desc = {
layout: {
attrs: [
shd.ATTR_VS_OFFSCREEN_POS: {format: sg.VertexFormat.Float3},
shd.ATTR_VS_OFFSCREEN_BRIGHT0: {format: sg.VertexFormat.Float},
shd.ATTR_OFFSCREEN_POS: {format: sg.VertexFormat.Float3},
shd.ATTR_OFFSCREEN_BRIGHT0: {format: sg.VertexFormat.Float},
]
},
shader: sg.makeShader(shd.offscreenShaderDesc(sg.queryBackend())),
Expand Down Expand Up @@ -187,7 +187,7 @@ void init()
sg.PipelineDesc fsq_pip_desc = {
layout: {
attrs: [
shd.ATTR_VS_FSQ_POS: {format: sg.VertexFormat.Float2},
shd.ATTR_FSQ_POS: {format: sg.VertexFormat.Float2},
]
},
shader: sg.makeShader(shd.fsqShaderDesc(sg.queryBackend())),
Expand All @@ -209,15 +209,15 @@ void init()
state.fsq.bind.vertex_buffers[0] = quad_vbuf;
foreach (i; [0, 1, 2])
{
state.fsq.bind.fs.images[i] = state.offscreen.atts_desc.colors[i].image;
state.fsq.bind.images[i] = state.offscreen.atts_desc.colors[i].image;
}
state.fsq.bind.fs.samplers[0] = smp;
state.fsq.bind.samplers[shd.SMP_SMP] = smp;

// shader, pipeline and resource bindings to render debug visualization quads
sg.PipelineDesc dbg_pip_desc = {
layout: {
attrs: [
shd.ATTR_VS_DBG_POS: {format: sg.VertexFormat.Float2},
shd.ATTR_DBG_POS: {format: sg.VertexFormat.Float2},
]
},
shader: sg.makeShader(shd.dbgShaderDesc(sg.queryBackend())),
Expand All @@ -228,7 +228,7 @@ void init()
// resource bindings to render the debug visualization
// (the required images will be filled in during rendering)
state.dbg.bind.vertex_buffers[0] = quad_vbuf;
state.dbg.bind.fs.samplers[0] = smp;
state.dbg.bind.samplers[shd.SMP_SMP] = smp;
}

void frame()
Expand All @@ -253,7 +253,7 @@ void frame()
sg.applyPipeline(state.offscreen.pip);
sg.applyBindings(state.offscreen.bind);
sg.Range offs_rg = {ptr: &offscreen_params, offscreen_params.sizeof};
sg.applyUniforms(sg.ShaderStage.Vs, shd.SLOT_OFFSCREEN_PARAMS, offs_rg);
sg.applyUniforms(shd.UB_OFFSCREEN_PARAMS, offs_rg);
sg.draw(0, 36, 1);
sg.endPass();

Expand All @@ -266,13 +266,13 @@ void frame()
sg.applyPipeline(state.fsq.pip);
sg.applyBindings(state.fsq.bind);
sg.Range fsq_rg = {ptr: &fsq_params, size: fsq_params.sizeof};
sg.applyUniforms(sg.ShaderStage.Vs, shd.SLOT_FSQ_PARAMS, fsq_rg);
sg.applyUniforms(shd.UB_FSQ_PARAMS, fsq_rg);
sg.draw(0, 4, 1);
sg.applyPipeline(state.dbg.pip);
foreach (i; [0, 1, 2])
{
sg.applyViewport(i * 100, 0, 100, 100, false);
state.dbg.bind.fs.images[0] = state.offscreen.atts_desc.colors[i].image;
state.dbg.bind.images[shd.IMG_TEX] = state.offscreen.atts_desc.colors[i].image;
sg.applyBindings(state.dbg.bind);
sg.draw(0, 4, 1);
}
Expand Down Expand Up @@ -340,7 +340,7 @@ void createOffscreenAttachments(int width, int height)
// update the fullscreen-quad texture bindings
foreach (i; [0, 1, 2])
{
state.fsq.bind.fs.images[i] = state.offscreen.atts_desc.colors[i].image;
state.fsq.bind.images[i] = state.offscreen.atts_desc.colors[i].image;
}
}

Expand Down
Loading