Skip to content

Commit 1f91a80

Browse files
committed
[WebGPU] Set texture views completely for render passes
1 parent 24637ad commit 1f91a80

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

backends/gpu/webgpu/sources/commandlist.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,26 @@ static WGPUStoreOp convert_store_op(kore_gpu_store_op op) {
3737
return WGPUStoreOp_Store;
3838
}
3939

40+
static WGPUTextureViewDimension convert_dimension(kore_gpu_texture_view_dimension dimension) {
41+
switch (dimension) {
42+
case KORE_GPU_TEXTURE_VIEW_DIMENSION_1D:
43+
return WGPUTextureViewDimension_1D;
44+
case KORE_GPU_TEXTURE_VIEW_DIMENSION_2D:
45+
return WGPUTextureViewDimension_2D;
46+
case KORE_GPU_TEXTURE_VIEW_DIMENSION_2DARRAY:
47+
return WGPUTextureViewDimension_2DArray;
48+
case KORE_GPU_TEXTURE_VIEW_DIMENSION_CUBE:
49+
return WGPUTextureViewDimension_Cube;
50+
case KORE_GPU_TEXTURE_VIEW_DIMENSION_CUBEARRAY:
51+
return WGPUTextureViewDimension_CubeArray;
52+
case KORE_GPU_TEXTURE_VIEW_DIMENSION_3D:
53+
return WGPUTextureViewDimension_3D;
54+
}
55+
56+
assert(false);
57+
return WGPUTextureViewDimension_2D;
58+
}
59+
4060
void kore_webgpu_command_list_destroy(kore_gpu_command_list *list) {}
4161

4262
void kore_webgpu_command_list_begin_render_pass(kore_gpu_command_list *list, const kore_gpu_render_pass_parameters *parameters) {
@@ -50,10 +70,12 @@ void kore_webgpu_command_list_begin_render_pass(kore_gpu_command_list *list, con
5070

5171
for (uint32_t attachment_index = 0; attachment_index < parameters->color_attachments_count; ++attachment_index) {
5272
WGPUTextureViewDescriptor texture_view_descriptor = {
53-
.format = kore_webgpu_convert_texture_format(parameters->color_attachments[attachment_index].texture.texture->webgpu.format),
54-
.dimension = WGPUTextureViewDimension_2D,
55-
.arrayLayerCount = 1,
56-
.mipLevelCount = 1,
73+
.format = kore_webgpu_convert_texture_format(parameters->color_attachments[attachment_index].texture.texture->webgpu.format),
74+
.dimension = convert_dimension(parameters->color_attachments[attachment_index].texture.dimension),
75+
.baseMipLevel = parameters->color_attachments[attachment_index].texture.base_mip_level,
76+
.mipLevelCount = parameters->color_attachments[attachment_index].texture.mip_level_count,
77+
.baseArrayLayer = parameters->color_attachments[attachment_index].texture.base_array_layer,
78+
.arrayLayerCount = parameters->color_attachments[attachment_index].texture.array_layer_count,
5779
};
5880
texture_views[attachment_index] =
5981
wgpuTextureCreateView(parameters->color_attachments[attachment_index].texture.texture->webgpu.texture, &texture_view_descriptor);

0 commit comments

Comments
 (0)