@@ -335,11 +335,10 @@ RenderingDeviceDriver::TextureID RenderingDeviceDriverWebGpu::texture_create(con
335
335
},
336
336
};
337
337
338
- // HACK: You cannot have a Depth24PlusStencil8 or Depth32FloatStencil8 texture view.
338
+ // HACK: You cannot have a Depth24PlusStencil8 or Depth32FloatStencil8 texture view be bound .
339
339
if (view_format == WGPUTextureFormat_Depth24PlusStencil8) {
340
340
view_format = WGPUTextureFormat_Depth24Plus;
341
341
aspect = WGPUTextureAspect_DepthOnly;
342
-
343
342
} else if (view_format == WGPUTextureFormat_Depth32FloatStencil8) {
344
343
view_format = WGPUTextureFormat_Depth32Float;
345
344
aspect = WGPUTextureAspect_DepthOnly;
@@ -1397,6 +1396,7 @@ RenderingDeviceDriver::ShaderID RenderingDeviceDriverWebGpu::shader_create_from_
1397
1396
.end = binary_data.push_constant_size ,
1398
1397
};
1399
1398
}
1399
+ shader_info->push_constant_stage_flags = binary_data.push_constant_stages ;
1400
1400
1401
1401
WGPUPipelineLayoutExtras wgpu_pipeline_extras = (WGPUPipelineLayoutExtras){
1402
1402
.chain = (WGPUChainedStruct){
@@ -1794,18 +1794,18 @@ void RenderingDeviceDriverWebGpu::command_bind_push_constants(CommandBufferID p_
1794
1794
data.resize (byte_size);
1795
1795
memcpy (data.ptrw (), p_data.ptr (), byte_size);
1796
1796
1797
- if (shader_info->stage_flags & WGPUShaderStage_Compute) {
1797
+ if (shader_info->push_constant_stage_flags & WGPUShaderStage_Compute) {
1798
1798
command_buffer_info->active_compute_pass_info .commands .push_back ((ComputePassEncoderCommand){
1799
1799
.type = ComputePassEncoderCommand::CommandType::SET_PUSH_CONSTANTS,
1800
1800
.set_push_constants = (ComputePassEncoderCommand::SetPushConstants){
1801
1801
.offset = p_first_index },
1802
1802
.push_constant_data = data,
1803
1803
});
1804
- } else if (shader_info->stage_flags & WGPUShaderStage_Vertex || shader_info->stage_flags & WGPUShaderStage_Fragment) {
1804
+ } else if (shader_info->push_constant_stage_flags & WGPUShaderStage_Vertex || shader_info->push_constant_stage_flags & WGPUShaderStage_Fragment) {
1805
1805
command_buffer_info->active_render_pass_info .commands .push_back ((RenderPassEncoderCommand){
1806
1806
.type = RenderPassEncoderCommand::CommandType::SET_PUSH_CONSTANTS,
1807
1807
.set_push_constants = (RenderPassEncoderCommand::SetPushConstants){
1808
- .stages = shader_info->stage_flags ,
1808
+ .stages = shader_info->push_constant_stage_flags ,
1809
1809
.offset = p_first_index },
1810
1810
.push_constant_data = data });
1811
1811
}
@@ -1887,7 +1887,7 @@ void RenderingDeviceDriverWebGpu::command_begin_render_pass(CommandBufferID p_cm
1887
1887
for (uint32_t i = 0 ; i < render_pass_info->attachments .size (); i++) {
1888
1888
RenderPassAttachmentInfo attachment = render_pass_info->attachments [i];
1889
1889
1890
- if (attachment.is_depth_stencil ) {
1890
+ if (attachment.is_depth_stencil || attachment. is_depth_stencil_read_only ) {
1891
1891
TextureID attachment_texture_id = framebuffer_info->attachments [i];
1892
1892
TextureInfo *attachment_texture = (TextureInfo *)attachment_texture_id.id ;
1893
1893
maybe_depth_stencil_attachment.first = (WGPURenderPassDepthStencilAttachment){
@@ -2491,9 +2491,22 @@ RenderingDeviceDriver::PipelineID RenderingDeviceDriverWebGpu::render_pipeline_c
2491
2491
pipeline_descriptor.primitive = primitive_state;
2492
2492
2493
2493
// pipeline_descriptor.depth_stencil
2494
- // HACK: This behavior isn't accurate?
2495
- if (p_depth_stencil_state.enable_depth_write ) {
2496
- WGPUDepthStencilState depth_stencil_state = (WGPUDepthStencilState){
2494
+ WGPUDepthStencilState depth_stencil_state;
2495
+
2496
+ // HACK: Whether a depth stencil state should be attached isn't always reported, so let's walk the render pass'
2497
+ // attachments to double check.
2498
+ bool use_depth = p_depth_stencil_state.enable_depth_write || p_depth_stencil_state.enable_depth_test || p_depth_stencil_state.enable_depth_range || p_depth_stencil_state.enable_stencil ;
2499
+
2500
+ for (uint32_t i = 0 ; i < render_pass_info->attachments .size (); i++) {
2501
+ const RenderPassAttachmentInfo &attachment = render_pass_info->attachments [i];
2502
+ if (attachment.is_depth_stencil || attachment.is_depth_stencil_read_only ) {
2503
+ use_depth = true ;
2504
+ break ;
2505
+ }
2506
+ }
2507
+
2508
+ if (use_depth) {
2509
+ depth_stencil_state = (WGPUDepthStencilState){
2497
2510
// TODO: We do not have info on depth target format.
2498
2511
.format = WGPUTextureFormat_Depth32Float,
2499
2512
.depthWriteEnabled = p_depth_stencil_state.enable_depth_write ? WGPUOptionalBool_True : WGPUOptionalBool_False,
@@ -2781,7 +2794,10 @@ String RenderingDeviceDriverWebGpu::get_api_version() const {
2781
2794
return " v24.0.0 (wgpu)" ;
2782
2795
}
2783
2796
2784
- String RenderingDeviceDriverWebGpu::get_pipeline_cache_uuid () const {}
2797
+ String RenderingDeviceDriverWebGpu::get_pipeline_cache_uuid () const {
2798
+ // TODO: impl
2799
+ return " webgpu" ;
2800
+ }
2785
2801
2786
2802
const RenderingDeviceDriver::Capabilities &RenderingDeviceDriverWebGpu::get_capabilities () const {
2787
2803
return capabilties;
0 commit comments