Skip to content

Commit

Permalink
update samples and shaders for sokol-gfx bindings cleanup update
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Oct 21, 2024
1 parent 2d0da34 commit a19f915
Show file tree
Hide file tree
Showing 29 changed files with 11,034 additions and 13,858 deletions.
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

0 comments on commit a19f915

Please sign in to comment.