MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / raster_redraw

Function raster_redraw

samples/cgpu/cgpu-basic/hot-triangle/triangle.c:154–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154void raster_redraw()
155{
156 // sync & reset
157 cgpu_wait_fences(&present_fence, 1);
158 CGPUAcquireNextDescriptor acquire_desc = {
159 .fence = present_fence
160 };
161 backbuffer_index = cgpu_acquire_next_image(swapchain, &acquire_desc);
162 const CGPUTextureId back_buffer = swapchain->back_buffers[backbuffer_index];
163 const CGPUTextureViewId back_buffer_view = views[backbuffer_index];
164 cgpu_reset_command_pool(pool);
165 // record
166 cgpu_cmd_begin(cmd);
167 CGPUColorAttachment screen_attachment = {
168 .view = back_buffer_view,
169 .load_action = CGPU_LOAD_ACTION_CLEAR,
170 .store_action = CGPU_STORE_ACTION_STORE,
171 .clear_color = fastclear_0000
172 };
173 CGPURenderPassDescriptor rp_desc = {
174 .render_target_count = 1,
175 .sample_count = CGPU_SAMPLE_COUNT_1,
176 .color_attachments = &screen_attachment,
177 .depth_stencil = CGPU_NULLPTR
178 };
179 CGPUTextureBarrier draw_barrier = {
180 .texture = back_buffer,
181 .src_state = CGPU_RESOURCE_STATE_UNDEFINED,
182 .dst_state = CGPU_RESOURCE_STATE_RENDER_TARGET
183 };
184 CGPUResourceBarrierDescriptor barrier_desc0 = { .texture_barriers = &draw_barrier, .texture_barriers_count = 1 };
185 cgpu_cmd_resource_barrier(cmd, &barrier_desc0);
186 CGPURenderPassEncoderId rp_encoder = cgpu_cmd_begin_render_pass(cmd, &rp_desc);
187 // get hot-reloadable wasm
188 SWAModuleId wa_module = get_available_wasm(wa_watcher);
189 if (wa_module != NULL)
190 {
191 SWAValue params[5];
192 params[0].I = (int64_t)cmd;
193 params[0].type = SWA_VAL_I64;
194 params[1].I = (int64_t)pipeline;
195 params[1].type = SWA_VAL_I64;
196 params[2].I = (int64_t)rp_encoder;
197 params[3].i = back_buffer->info->width;
198 params[3].type = SWA_VAL_I32;
199 params[4].i = back_buffer->info->height;
200 params[4].type = SWA_VAL_I32;
201 SWAExecDescriptor exec_desc = {
202 5, params,
203 0, NULL
204 };
205 const char* res = swa_exec(wa_module, "raster_cmd_record", &exec_desc);
206 if (res) printf("[fatal]: %s", res);
207 }
208 else
209 {
210 raster_cmd_record(cmd, pipeline,
211 rp_encoder,

Callers 1

raster_programFunction · 0.70

Calls 14

cgpu_wait_fencesFunction · 0.85
cgpu_acquire_next_imageFunction · 0.85
cgpu_reset_command_poolFunction · 0.85
cgpu_cmd_beginFunction · 0.85
get_available_wasmFunction · 0.85
swa_execFunction · 0.85
raster_cmd_recordFunction · 0.85
cgpu_cmd_end_render_passFunction · 0.85
cgpu_cmd_endFunction · 0.85
cgpu_submit_queueFunction · 0.85

Tested by

no test coverage detected