7
7
8
8
use core:: array;
9
9
10
+ use crate :: core_3d:: {
11
+ graph:: { Core3d , Node3d } ,
12
+ prepare_core_3d_depth_textures,
13
+ } ;
10
14
use bevy_app:: { App , Plugin } ;
11
15
use bevy_asset:: { load_internal_asset, weak_handle, Handle } ;
12
16
use bevy_derive:: { Deref , DerefMut } ;
@@ -21,6 +25,7 @@ use bevy_ecs::{
21
25
world:: { FromWorld , World } ,
22
26
} ;
23
27
use bevy_math:: { uvec2, UVec2 , Vec4Swizzles as _} ;
28
+ use bevy_render:: batching:: gpu_preprocessing:: GpuPreprocessingSupport ;
24
29
use bevy_render:: {
25
30
experimental:: occlusion_culling:: {
26
31
OcclusionCulling , OcclusionCullingSubview , OcclusionCullingSubviewEntities ,
@@ -30,23 +35,19 @@ use bevy_render::{
30
35
binding_types:: { sampler, texture_2d, texture_2d_multisampled, texture_storage_2d} ,
31
36
BindGroup , BindGroupEntries , BindGroupLayout , BindGroupLayoutEntries ,
32
37
CachedComputePipelineId , ComputePassDescriptor , ComputePipeline , ComputePipelineDescriptor ,
33
- DownlevelFlags , Extent3d , IntoBinding , PipelineCache , PushConstantRange , Sampler ,
34
- SamplerBindingType , SamplerDescriptor , Shader , ShaderStages , SpecializedComputePipeline ,
38
+ Extent3d , IntoBinding , PipelineCache , PushConstantRange , Sampler , SamplerBindingType ,
39
+ SamplerDescriptor , Shader , ShaderStages , SpecializedComputePipeline ,
35
40
SpecializedComputePipelines , StorageTextureAccess , TextureAspect , TextureDescriptor ,
36
41
TextureDimension , TextureFormat , TextureSampleType , TextureUsages , TextureView ,
37
42
TextureViewDescriptor , TextureViewDimension ,
38
43
} ,
39
- renderer:: { RenderAdapter , RenderContext , RenderDevice } ,
44
+ renderer:: { RenderContext , RenderDevice } ,
40
45
texture:: TextureCache ,
41
46
view:: { ExtractedView , NoIndirectDrawing , ViewDepthTexture } ,
42
47
Render , RenderApp , RenderSet ,
43
48
} ;
44
49
use bitflags:: bitflags;
45
-
46
- use crate :: core_3d:: {
47
- graph:: { Core3d , Node3d } ,
48
- prepare_core_3d_depth_textures,
49
- } ;
50
+ use tracing:: debug;
50
51
51
52
/// Identifies the `downsample_depth.wgsl` shader.
52
53
pub const DOWNSAMPLE_DEPTH_SHADER_HANDLE : Handle < Shader > =
@@ -325,26 +326,14 @@ pub struct DownsampleDepthPipelines {
325
326
sampler : Sampler ,
326
327
}
327
328
328
- fn supports_compute_shaders ( device : & RenderDevice , adapter : & RenderAdapter ) -> bool {
329
- adapter
330
- . get_downlevel_capabilities ( )
331
- . flags
332
- . contains ( DownlevelFlags :: COMPUTE_SHADERS )
333
- // Even if the adapter supports compute, we might be simulating a lack of
334
- // compute via device limits (see `WgpuSettingsPriority::WebGL2` and
335
- // `wgpu::Limits::downlevel_webgl2_defaults()`). This will have set all the
336
- // `max_compute_*` limits to zero, so we arbitrarily pick one as a canary.
337
- && ( device. limits ( ) . max_compute_workgroup_storage_size != 0 )
338
- }
339
-
340
329
/// Creates the [`DownsampleDepthPipelines`] if downsampling is supported on the
341
330
/// current platform.
342
331
fn create_downsample_depth_pipelines (
343
332
mut commands : Commands ,
344
333
render_device : Res < RenderDevice > ,
345
- render_adapter : Res < RenderAdapter > ,
346
334
pipeline_cache : Res < PipelineCache > ,
347
335
mut specialized_compute_pipelines : ResMut < SpecializedComputePipelines < DownsampleDepthPipeline > > ,
336
+ gpu_preprocessing_support : Res < GpuPreprocessingSupport > ,
348
337
mut has_run : Local < bool > ,
349
338
) {
350
339
// Only run once.
@@ -356,9 +345,8 @@ fn create_downsample_depth_pipelines(
356
345
}
357
346
* has_run = true ;
358
347
359
- // If we don't have compute shaders, we can't invoke the downsample depth
360
- // compute shader.
361
- if !supports_compute_shaders ( & render_device, & render_adapter) {
348
+ if !gpu_preprocessing_support. is_culling_supported ( ) {
349
+ debug ! ( "Downsample depth is not supported on this platform." ) ;
362
350
return ;
363
351
}
364
352
0 commit comments