-
Notifications
You must be signed in to change notification settings - Fork 24
/
cube_reflection.c
601 lines (527 loc) · 21.3 KB
/
cube_reflection.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
#include "example_base.h"
#include <string.h>
#include "../webgpu/imgui_overlay.h"
/* -------------------------------------------------------------------------- *
* WebGPU Example - Cube Reflection
*
* This example shows how to create a basic reflection pipeline.
*
* Ref:
* https://dawn.googlesource.com/dawn/+/refs/heads/main/examples/CubeReflection.cpp
* -------------------------------------------------------------------------- */
// Index buffer
static struct wgpu_buffer_t indices = {0};
// Cube vertex buffer
static struct wgpu_buffer_t cube_vertices = {0};
// Plane vertex buffer
static struct wgpu_buffer_t plane_vertices = {0};
static struct {
mat4 view;
mat4 proj;
} camera_data = {0};
// Other buffers
static wgpu_buffer_t camera_buffer = {0};
static wgpu_buffer_t transform_buffer[2] = {0};
// Bind groups stores the resources bound to the binding points in a shader
static WGPUBindGroup bind_group[2] = {0};
static WGPUBindGroupLayout bind_group_layout = NULL;
// The pipeline layout
static WGPUPipelineLayout pipeline_layout = NULL;
// Pipelines
static WGPURenderPipeline pipeline = NULL;
static WGPURenderPipeline plane_pipeline = NULL;
static WGPURenderPipeline reflection_pipeline = NULL;
// Render pass descriptor for frame buffer writes
static struct {
WGPURenderPassColorAttachment color_attachments[1];
WGPURenderPassDescriptor descriptor;
} render_pass = {0};
// Render state
static struct {
uint32_t a;
float b;
} render_state = {0};
// Other variables
static const char* example_title = "Cube Reflection";
static bool prepared = false;
static void prepare_buffers(wgpu_context_t* wgpu_context)
{
/* Index buffer */
{
static const uint32_t index_data[6 * 6] = {
0, 1, 2, 0, 2, 3, //
4, 5, 6, 4, 6, 7, //
8, 9, 10, 8, 10, 11, //
12, 13, 14, 12, 14, 15, //
16, 17, 18, 16, 18, 19, //
20, 21, 22, 20, 22, 23, //
};
indices = wgpu_create_buffer(
wgpu_context, &(wgpu_buffer_desc_t){
.label = "Cube indices buffer",
.usage = WGPUBufferUsage_CopyDst | WGPUBufferUsage_Index,
.size = sizeof(index_data),
.count = (uint32_t)ARRAY_SIZE(index_data),
.initial.data = index_data,
});
}
/* Cube vertices data */
{
static const float vertex_data[6 * 4 * 6] = {
-1.f, -1.f, 1.f, 1.f, 0.f, 0.f, 1.f, -1.f, 1.f, 1.f, 0.f, 0.f, //
1.f, 1.f, 1.f, 1.f, 0.f, 0.f, -1.f, 1.f, 1.f, 1.f, 0.f, 0.f, //
-1.f, -1.f, -1.f, 1.f, 1.f, 0.f, -1.f, 1.f, -1.f, 1.f, 1.f, 0.f, //
1.f, 1.f, -1.f, 1.f, 1.f, 0.f, 1.f, -1.f, -1.f, 1.f, 1.f, 0.f, //
-1.f, 1.f, -1.f, 1.f, 0.f, 1.f, -1.f, 1.f, 1.f, 1.f, 0.f, 1.f, //
1.f, 1.f, 1.f, 1.f, 0.f, 1.f, 1.f, 1.f, -1.f, 1.f, 0.f, 1.f, //
-1.f, -1.f, -1.f, 0.f, 1.f, 0.f, 1.f, -1.f, -1.f, 0.f, 1.f, 0.f, //
1.f, -1.f, 1.f, 0.f, 1.f, 0.f, -1.f, -1.f, 1.f, 0.f, 1.f, 0.f, //
1.f, -1.f, -1.f, 0.f, 1.f, 1.f, 1.f, 1.f, -1.f, 0.f, 1.f, 1.f, //
1.f, 1.f, 1.f, 0.f, 1.f, 1.f, 1.f, -1.f, 1.f, 0.f, 1.f, 1.f, //
-1.f, -1.f, -1.f, 1.f, 1.f, 1.f, -1.f, -1.f, 1.f, 1.f, 1.f, 1.f, //
-1.f, 1.f, 1.f, 1.f, 1.f, 1.f, -1.f, 1.f, -1.f, 1.f, 1.f, 1.f, //
};
cube_vertices = wgpu_create_buffer(
wgpu_context, &(wgpu_buffer_desc_t){
.label = "Cube vertices buffer",
.usage = WGPUBufferUsage_CopyDst | WGPUBufferUsage_Vertex,
.size = sizeof(vertex_data),
.count = (uint32_t)ARRAY_SIZE(vertex_data),
.initial.data = vertex_data,
});
}
/* Plane vertice data */
{
static const float plane_data[6 * 4] = {
-2.f, -1.f, -2.f, 0.5f, 0.5f, 0.5f, 2.f, -1.f, -2.f, 0.5f, 0.5f, 0.5f, //
2.f, -1.f, 2.f, 0.5f, 0.5f, 0.5f, -2.f, -1.f, 2.f, 0.5f, 0.5f, 0.5f, //
};
plane_vertices = wgpu_create_buffer(
wgpu_context, &(wgpu_buffer_desc_t){
.label = "Plane vertices buffer",
.usage = WGPUBufferUsage_CopyDst | WGPUBufferUsage_Vertex,
.size = sizeof(plane_data),
.count = (uint32_t)ARRAY_SIZE(plane_data),
.initial.data = plane_data,
});
}
}
static void prepare_uniform_buffers(wgpu_context_t* wgpu_context)
{
/* Camera data buffer */
{
camera_buffer
= wgpu_create_buffer(wgpu_context, &(wgpu_buffer_desc_t){
.label = "Camera data buffer",
.usage = WGPUBufferUsage_CopyDst
| WGPUBufferUsage_Uniform,
.size = sizeof(camera_data),
});
}
/* Camera projection matrix */
glm_perspective(glm_rad(45.0f), 1.f, 1.0f, 100.0f, camera_data.proj);
/* Transform buffers */
{
mat4 transform = GLM_MAT4_IDENTITY_INIT;
transform_buffer[0]
= wgpu_create_buffer(wgpu_context, &(wgpu_buffer_desc_t){
.label = "Transform buffer 0",
.usage = WGPUBufferUsage_CopyDst
| WGPUBufferUsage_Uniform,
.size = sizeof(mat4),
.initial.data = &transform,
});
glm_translate(transform, (vec3){0.f, -2.f, 0.f});
transform_buffer[1]
= wgpu_create_buffer(wgpu_context, &(wgpu_buffer_desc_t){
.label = "Transform buffer 1",
.usage = WGPUBufferUsage_CopyDst
| WGPUBufferUsage_Uniform,
.size = sizeof(mat4),
.initial.data = &transform,
});
}
}
static void setup_render_pass(wgpu_context_t* wgpu_context)
{
/* Color attachment */
render_pass.color_attachments[0] = (WGPURenderPassColorAttachment) {
.view = NULL, /* Attachment is acquired in render loop. */
.depthSlice = ~0,
.loadOp = WGPULoadOp_Clear,
.storeOp = WGPUStoreOp_Store,
.clearValue = (WGPUColor) {
.r = 0.1f,
.g = 0.2f,
.b = 0.3f,
.a = 1.0f,
},
};
/* Depth attachment */
wgpu_setup_deph_stencil(wgpu_context, NULL);
/* Render pass descriptor */
render_pass.descriptor = (WGPURenderPassDescriptor){
.label = "Render pass descriptor",
.colorAttachmentCount = 1,
.colorAttachments = render_pass.color_attachments,
.depthStencilAttachment = &wgpu_context->depth_stencil.att_desc,
};
}
static void setup_pipeline_layout(wgpu_context_t* wgpu_context)
{
/* Bind group layout */
WGPUBindGroupLayoutEntry bgl_entries[2] = {
[0] = (WGPUBindGroupLayoutEntry) {
// Binding 0: Uniform buffer (Vertex shader) => cameraData
.binding = 0,
.visibility = WGPUShaderStage_Vertex,
.buffer = (WGPUBufferBindingLayout) {
.type = WGPUBufferBindingType_Uniform,
.hasDynamicOffset = false,
.minBindingSize = sizeof(camera_data),
},
.sampler = {0},
},
[1] = (WGPUBindGroupLayoutEntry) {
// Binding 1: Uniform buffer (Vertex shader) => modelData
.binding = 1,
.visibility = WGPUShaderStage_Vertex,
.buffer = (WGPUBufferBindingLayout) {
.type = WGPUBufferBindingType_Uniform,
.hasDynamicOffset = false,
.minBindingSize = sizeof(mat4),
},
.sampler = {0},
},
};
WGPUBindGroupLayoutDescriptor bgl_desc = {
.label = "Bind group layout",
.entryCount = (uint32_t)ARRAY_SIZE(bgl_entries),
.entries = bgl_entries,
};
bind_group_layout
= wgpuDeviceCreateBindGroupLayout(wgpu_context->device, &bgl_desc);
ASSERT(bind_group_layout != NULL);
/* Pipeline layout */
WGPUPipelineLayoutDescriptor pipeline_layout_desc = {
.label = "Pipeline layout",
.bindGroupLayoutCount = 1,
.bindGroupLayouts = &bind_group_layout,
};
pipeline_layout = wgpuDeviceCreatePipelineLayout(wgpu_context->device,
&pipeline_layout_desc);
ASSERT(pipeline_layout != NULL);
}
static void setup_bind_groups(wgpu_context_t* wgpu_context)
{
/* Bind groups */
for (uint32_t i = 0; i < (uint32_t)ARRAY_SIZE(bind_group); ++i) {
WGPUBindGroupEntry bg_entries[2] = {
[0] = {
// Binding 0: Uniform buffer (Vertex shader) => cameraData
.binding = 0,
.buffer = camera_buffer.buffer,
.offset = 0,
.size = camera_buffer.size,
},
[1] = {
// Binding 1: Uniform buffer (Vertex shader) => modelData
.binding = 1,
.buffer = transform_buffer[i].buffer,
.offset = 0,
.size = transform_buffer[i].size,
},
};
WGPUBindGroupDescriptor bg_desc = {
.label = "Bind group",
.layout = bind_group_layout,
.entryCount = (uint32_t)ARRAY_SIZE(bg_entries),
.entries = bg_entries,
};
bind_group[i] = wgpuDeviceCreateBindGroup(wgpu_context->device, &bg_desc);
ASSERT(bind_group[i] != NULL);
}
}
// Create the graphics pipeline
static void prepare_pipelines(wgpu_context_t* wgpu_context)
{
/* Primitive state */
WGPUPrimitiveState primitive_state = {
.topology = WGPUPrimitiveTopology_TriangleList,
.frontFace = WGPUFrontFace_CCW,
.cullMode = WGPUCullMode_None,
};
/* Color target state */
WGPUBlendState blend_state = wgpu_create_blend_state(true);
WGPUColorTargetState color_target_state = (WGPUColorTargetState){
.format = wgpu_context->swap_chain.format,
.blend = &blend_state,
.writeMask = WGPUColorWriteMask_All,
};
/* Vertex buffer layout */
WGPU_VERTEX_BUFFER_LAYOUT(
cube_reflection, 6 * sizeof(float),
// Attribute location 0: Position
WGPU_VERTATTR_DESC(0, WGPUVertexFormat_Float32x3, 0),
// Attribute location 1: Color
WGPU_VERTATTR_DESC(1, WGPUVertexFormat_Float32x3, 3 * sizeof(float)));
/* Vertex state */
WGPUVertexState vertex_state = wgpu_create_vertex_state(
wgpu_context, &(wgpu_vertex_state_t){
.shader_desc = (wgpu_shader_desc_t){
/* Vertex shader SPIR-V */
.label = "Cube vertex shader SPIR-V",
.file = "shaders/cube_reflection/shader.vert.spv",
},
.buffer_count = 1,
.buffers = &cube_reflection_vertex_buffer_layout,
});
/* Fragment states */
WGPUFragmentState fragment_state = wgpu_create_fragment_state(
wgpu_context, &(wgpu_fragment_state_t){
.shader_desc = (wgpu_shader_desc_t){
/* Fragment shader SPIR-V */
.label = "Cube fragment shader SPIR-V",
.file = "shaders/cube_reflection/shader.frag.spv",
},
.target_count = 1,
.targets = &color_target_state,
});
WGPUFragmentState fragment_state_reflection = wgpu_create_fragment_state(
wgpu_context, &(wgpu_fragment_state_t){
.shader_desc = (wgpu_shader_desc_t){
/* Fragment shader SPIR-V */
.label = "Cube reflection fragment shader SPIR-V",
.file = "shaders/cube_reflection/reflection.frag.spv",
},
.target_count = 1,
.targets = &color_target_state,
});
/* Multisample state */
WGPUMultisampleState multisample_state
= wgpu_create_multisample_state_descriptor(
&(create_multisample_state_desc_t){
.sample_count = 1,
});
/* Cube rendering pipeline */
{
/* Depth stencil state */
WGPUDepthStencilState depth_stencil_state
= wgpu_create_depth_stencil_state(&(create_depth_stencil_state_desc_t){
.format = WGPUTextureFormat_Depth24PlusStencil8,
.depth_write_enabled = true,
});
depth_stencil_state.depthCompare = WGPUCompareFunction_Less;
/* Create rendering pipeline using the specified states */
pipeline = wgpuDeviceCreateRenderPipeline(
wgpu_context->device, &(WGPURenderPipelineDescriptor){
.label = "Cube render pipeline",
.layout = pipeline_layout,
.primitive = primitive_state,
.vertex = vertex_state,
.fragment = &fragment_state,
.depthStencil = &depth_stencil_state,
.multisample = multisample_state,
});
ASSERT(pipeline != NULL);
}
/* Plane rendering pipeline */
{
/* Depth stencil state */
WGPUDepthStencilState depth_stencil_state
= wgpu_create_depth_stencil_state(&(create_depth_stencil_state_desc_t){
.format = WGPUTextureFormat_Depth24PlusStencil8,
.depth_write_enabled = false,
});
depth_stencil_state.stencilFront.passOp = WGPUStencilOperation_Replace;
depth_stencil_state.stencilBack.passOp = WGPUStencilOperation_Replace;
depth_stencil_state.depthCompare = WGPUCompareFunction_Less;
/* Create rendering pipeline using the specified states */
plane_pipeline = wgpuDeviceCreateRenderPipeline(
wgpu_context->device, &(WGPURenderPipelineDescriptor){
.label = "Plane render pipeline",
.layout = pipeline_layout,
.primitive = primitive_state,
.vertex = vertex_state,
.fragment = &fragment_state,
.depthStencil = &depth_stencil_state,
.multisample = multisample_state,
});
ASSERT(plane_pipeline != NULL);
}
/* Cube reflection rendering pipeline */
{
/* Depth stencil state */
WGPUDepthStencilState depth_stencil_state
= wgpu_create_depth_stencil_state(&(create_depth_stencil_state_desc_t){
.format = WGPUTextureFormat_Depth24PlusStencil8,
.depth_write_enabled = true,
});
depth_stencil_state.stencilFront.compare = WGPUCompareFunction_Equal;
depth_stencil_state.stencilBack.compare = WGPUCompareFunction_Equal;
depth_stencil_state.stencilFront.passOp = WGPUStencilOperation_Replace;
depth_stencil_state.stencilBack.passOp = WGPUStencilOperation_Replace;
depth_stencil_state.depthCompare = WGPUCompareFunction_Less;
/* Create rendering pipeline using the specified states */
reflection_pipeline = wgpuDeviceCreateRenderPipeline(
wgpu_context->device, &(WGPURenderPipelineDescriptor){
.label = "Cube reflection render pipeline",
.layout = pipeline_layout,
.primitive = primitive_state,
.vertex = vertex_state,
.fragment = &fragment_state_reflection,
.depthStencil = &depth_stencil_state,
.multisample = multisample_state,
});
ASSERT(reflection_pipeline != NULL);
}
/* Partial cleanup */
WGPU_RELEASE_RESOURCE(ShaderModule, vertex_state.module);
WGPU_RELEASE_RESOURCE(ShaderModule, fragment_state.module);
WGPU_RELEASE_RESOURCE(ShaderModule, fragment_state_reflection.module);
}
static void update_camera_view(wgpu_context_t* wgpu_context)
{
/* Update render state */
render_state.a = (render_state.a + 1) % 256;
render_state.b += 0.002f;
if (render_state.b >= 1.0f) {
render_state.b = 0.0f;
}
/* Update camera view */
glm_lookat((vec3){8.0f * sin(glm_rad(render_state.b * 360.0f)), /* x (eye) */
2.0f, /* y (eye) */
8.0f * cos(glm_rad(render_state.b * 360.0f))}, /* z (eye) */
(vec3){0.0f, 0.0f, 0.0f}, /* center */
(vec3){0.0f, 1.0f, 0.0f}, /* up */
camera_data.view);
/* Update uniform buffer */
wgpu_queue_write_buffer(wgpu_context, camera_buffer.buffer, 0, &camera_data,
camera_buffer.size);
}
static int example_initialize(wgpu_example_context_t* context)
{
if (context) {
prepare_buffers(context->wgpu_context);
prepare_uniform_buffers(context->wgpu_context);
setup_pipeline_layout(context->wgpu_context);
setup_bind_groups(context->wgpu_context);
prepare_pipelines(context->wgpu_context);
setup_render_pass(context->wgpu_context);
prepared = true;
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}
static void example_on_update_ui_overlay(wgpu_example_context_t* context)
{
if (imgui_overlay_header("Settings")) {
imgui_overlay_checkBox(context->imgui_overlay, "Paused", &context->paused);
}
}
static WGPUCommandBuffer build_command_buffer(wgpu_context_t* wgpu_context)
{
render_pass.color_attachments[0].view = wgpu_context->swap_chain.frame_buffer;
wgpu_context->cmd_enc
= wgpuDeviceCreateCommandEncoder(wgpu_context->device, NULL);
{
WGPURenderPassEncoder rpass_enc = wgpuCommandEncoderBeginRenderPass(
wgpu_context->cmd_enc, &render_pass.descriptor);
/* Render cube */
{
wgpuRenderPassEncoderSetPipeline(rpass_enc, pipeline);
wgpuRenderPassEncoderSetBindGroup(rpass_enc, 0, bind_group[0], 0, 0);
wgpuRenderPassEncoderSetVertexBuffer(rpass_enc, 0, cube_vertices.buffer,
0, WGPU_WHOLE_SIZE);
wgpuRenderPassEncoderSetIndexBuffer(
rpass_enc, indices.buffer, WGPUIndexFormat_Uint32, 0, WGPU_WHOLE_SIZE);
wgpuRenderPassEncoderDrawIndexed(rpass_enc, 36, 1, 0, 0, 0);
}
/* Render plane */
{
wgpuRenderPassEncoderSetStencilReference(rpass_enc, 0x1);
wgpuRenderPassEncoderSetPipeline(rpass_enc, plane_pipeline);
wgpuRenderPassEncoderSetBindGroup(rpass_enc, 0, bind_group[0], 0, 0);
wgpuRenderPassEncoderSetVertexBuffer(rpass_enc, 0, plane_vertices.buffer,
0, WGPU_WHOLE_SIZE);
wgpuRenderPassEncoderDrawIndexed(rpass_enc, 6, 1, 0, 0, 0);
}
/* Render cube reflection */
{
wgpuRenderPassEncoderSetPipeline(rpass_enc, reflection_pipeline);
wgpuRenderPassEncoderSetBindGroup(rpass_enc, 0, bind_group[1], 0, 0);
wgpuRenderPassEncoderSetVertexBuffer(rpass_enc, 0, cube_vertices.buffer,
0, WGPU_WHOLE_SIZE);
wgpuRenderPassEncoderDrawIndexed(rpass_enc, 36, 1, 0, 0, 0);
}
wgpuRenderPassEncoderEnd(rpass_enc);
WGPU_RELEASE_RESOURCE(RenderPassEncoder, rpass_enc)
}
/* Draw ui overlay */
draw_ui(wgpu_context->context, example_on_update_ui_overlay);
/* Get command buffer */
WGPUCommandBuffer command_buffer
= wgpu_get_command_buffer(wgpu_context->cmd_enc);
ASSERT(command_buffer != NULL);
WGPU_RELEASE_RESOURCE(CommandEncoder, wgpu_context->cmd_enc)
return command_buffer;
}
static int example_draw(wgpu_example_context_t* context)
{
/* Prepare frame */
prepare_frame(context);
// Command buffer to be submitted to the queue */
wgpu_context_t* wgpu_context = context->wgpu_context;
wgpu_context->submit_info.command_buffer_count = 1;
wgpu_context->submit_info.command_buffers[0]
= build_command_buffer(context->wgpu_context);
/* Submit command buffers to queue */
submit_command_buffers(context);
/* Submit frame */
submit_frame(context);
return EXIT_SUCCESS;
}
static int example_render(wgpu_example_context_t* context)
{
if (!prepared) {
return EXIT_FAILURE;
}
const int draw_result = example_draw(context);
if (!context->paused) {
update_camera_view(context->wgpu_context);
}
return draw_result;
}
// Clean up used resources
static void example_destroy(wgpu_example_context_t* context)
{
UNUSED_VAR(context);
WGPU_RELEASE_RESOURCE(Buffer, indices.buffer)
WGPU_RELEASE_RESOURCE(Buffer, cube_vertices.buffer)
WGPU_RELEASE_RESOURCE(Buffer, plane_vertices.buffer)
WGPU_RELEASE_RESOURCE(Buffer, camera_buffer.buffer)
WGPU_RELEASE_RESOURCE(Buffer, transform_buffer[0].buffer)
WGPU_RELEASE_RESOURCE(Buffer, transform_buffer[1].buffer)
WGPU_RELEASE_RESOURCE(BindGroup, bind_group[0])
WGPU_RELEASE_RESOURCE(BindGroup, bind_group[1])
WGPU_RELEASE_RESOURCE(BindGroupLayout, bind_group_layout)
WGPU_RELEASE_RESOURCE(PipelineLayout, pipeline_layout)
WGPU_RELEASE_RESOURCE(RenderPipeline, pipeline)
WGPU_RELEASE_RESOURCE(RenderPipeline, plane_pipeline)
WGPU_RELEASE_RESOURCE(RenderPipeline, reflection_pipeline)
}
void example_cube_reflection(int argc, char* argv[])
{
// clang-format off
example_run(argc, argv, &(refexport_t){
.example_settings = (wgpu_example_settings_t){
.title = example_title,
.overlay = true,
.vsync = true,
},
.example_initialize_func = &example_initialize,
.example_render_func = &example_render,
.example_destroy_func = &example_destroy
});
// clang-format on
}