Skip to content

Commit

Permalink
offscreen-sapp: add render pass labels
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Feb 10, 2024
1 parent e87cf3b commit 90d3d18
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions sapp/offscreen-sapp.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,7 @@ static void init(void) {
}
};

// offscreen pass action: clear to grey
state.offscreen.pass.action = (sg_pass_action) {
.colors[0] = {
.load_action = SG_LOADACTION_CLEAR,
.clear_value = { 0.25f, 0.25f, 0.25f, 1.0f }
}
};

// create a render pass object with one color and one depth render attachment image
// setup a render pass struct with one color and one depth render attachment image
// NOTE: we need to explicitly set the sample count in the attachment image objects,
// because the offscreen pass uses a different sample count than the display render pass
// (the display render pass is multi-sampled, the offscreen pass is not)
Expand All @@ -74,11 +66,19 @@ static void init(void) {
img_desc.pixel_format = SG_PIXELFORMAT_DEPTH;
img_desc.label = "depth-image";
sg_image depth_img = sg_make_image(&img_desc);
state.offscreen.pass.attachments = sg_make_attachments(&(sg_attachments_desc){
.colors[0].image = color_img,
.depth_stencil.image = depth_img,
state.offscreen.pass = (sg_pass) {
.attachments = sg_make_attachments(&(sg_attachments_desc){
.colors[0].image = color_img,
.depth_stencil.image = depth_img,
}),
.action = {
.colors[0] = {
.load_action = SG_LOADACTION_CLEAR,
.clear_value = { 0.25f, 0.25f, 0.25f, 1.0f }
}
},
.label = "offscreen-pass"
});
};

// a donut shape which is rendered into the offscreen render target, and
// a sphere shape which is rendered into the default framebuffer
Expand Down Expand Up @@ -215,7 +215,11 @@ static void frame(void) {
vs_params = (vs_params_t) {
.mvp = compute_mvp(-state.rx * 0.25f, state.ry * 0.25f, (float)w/(float)h, 2.0f)
};
sg_begin_pass(&(sg_pass){ .action = state.display.pass_action, .swapchain = sglue_swapchain() });
sg_begin_pass(&(sg_pass){
.action = state.display.pass_action,
.swapchain = sglue_swapchain(),
.label = "swapchain-pass",
});
sg_apply_pipeline(state.display.pip);
sg_apply_bindings(&state.display.bind);
sg_apply_uniforms(SG_SHADERSTAGE_VS, SLOT_vs_params, &SG_RANGE(vs_params));
Expand Down

0 comments on commit 90d3d18

Please sign in to comment.