@@ -17,6 +17,7 @@ use bevy_render::{
17
17
} ;
18
18
use futures_lite:: future;
19
19
use renderer:: WgpuRenderResourceContext ;
20
+ use std:: borrow:: Cow ;
20
21
21
22
#[ derive( Clone , Copy ) ]
22
23
pub enum WgpuFeature {
@@ -41,54 +42,43 @@ pub enum WgpuFeature {
41
42
VertexAttribute64Bit ,
42
43
}
43
44
44
- impl From < WgpuFeature > for wgpu:: Features {
45
- fn from ( value : WgpuFeature ) -> Self {
46
- match value {
47
- WgpuFeature :: DepthClamping => wgpu:: Features :: DEPTH_CLAMPING ,
48
- WgpuFeature :: TextureCompressionBc => wgpu:: Features :: TEXTURE_COMPRESSION_BC ,
49
- WgpuFeature :: TimestampQuery => wgpu:: Features :: TIMESTAMP_QUERY ,
50
- WgpuFeature :: PipelineStatisticsQuery => wgpu:: Features :: PIPELINE_STATISTICS_QUERY ,
51
- WgpuFeature :: MappablePrimaryBuffers => wgpu:: Features :: MAPPABLE_PRIMARY_BUFFERS ,
52
- WgpuFeature :: SampledTextureBindingArray => {
53
- wgpu:: Features :: SAMPLED_TEXTURE_BINDING_ARRAY
54
- }
55
- WgpuFeature :: SampledTextureArrayDynamicIndexing => {
56
- wgpu:: Features :: SAMPLED_TEXTURE_ARRAY_DYNAMIC_INDEXING
57
- }
58
- WgpuFeature :: SampledTextureArrayNonUniformIndexing => {
59
- wgpu:: Features :: SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING
60
- }
61
- WgpuFeature :: UnsizedBindingArray => wgpu:: Features :: UNSIZED_BINDING_ARRAY ,
62
- WgpuFeature :: MultiDrawIndirect => wgpu:: Features :: MULTI_DRAW_INDIRECT ,
63
- WgpuFeature :: MultiDrawIndirectCount => wgpu:: Features :: MULTI_DRAW_INDIRECT_COUNT ,
64
- WgpuFeature :: PushConstants => wgpu:: Features :: PUSH_CONSTANTS ,
65
- WgpuFeature :: AddressModeClampToBorder => wgpu:: Features :: ADDRESS_MODE_CLAMP_TO_BORDER ,
66
- WgpuFeature :: NonFillPolygonMode => wgpu:: Features :: NON_FILL_POLYGON_MODE ,
67
- WgpuFeature :: TextureCompressionEtc2 => wgpu:: Features :: TEXTURE_COMPRESSION_ETC2 ,
68
- WgpuFeature :: TextureCompressionAstcLdr => wgpu:: Features :: TEXTURE_COMPRESSION_ASTC_LDR ,
69
- WgpuFeature :: TextureAdapterSpecificFormatFeatures => {
70
- wgpu:: Features :: TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES
71
- }
72
- WgpuFeature :: ShaderFloat64 => wgpu:: Features :: SHADER_FLOAT64 ,
73
- WgpuFeature :: VertexAttribute64Bit => wgpu:: Features :: VERTEX_ATTRIBUTE_64BIT ,
74
- }
75
- }
45
+ #[ derive( Default , Clone ) ]
46
+ pub struct WgpuFeatures {
47
+ pub features : Vec < WgpuFeature > ,
76
48
}
77
49
78
- impl From < WgpuFeatures > for wgpu:: Features {
79
- fn from ( features : WgpuFeatures ) -> Self {
80
- features
81
- . features
82
- . iter ( )
83
- . fold ( wgpu:: Features :: empty ( ) , |wgpu_features, feature| {
84
- wgpu_features | ( * feature) . into ( )
85
- } )
86
- }
50
+ #[ derive( Debug , Clone ) ]
51
+ pub struct WgpuLimits {
52
+ pub max_bind_groups : u32 ,
53
+ pub max_dynamic_uniform_buffers_per_pipeline_layout : u32 ,
54
+ pub max_dynamic_storage_buffers_per_pipeline_layout : u32 ,
55
+ pub max_sampled_textures_per_shader_stage : u32 ,
56
+ pub max_samplers_per_shader_stage : u32 ,
57
+ pub max_storage_buffers_per_shader_stage : u32 ,
58
+ pub max_storage_textures_per_shader_stage : u32 ,
59
+ pub max_uniform_buffers_per_shader_stage : u32 ,
60
+ pub max_uniform_buffer_binding_size : u32 ,
61
+ pub max_push_constant_size : u32 ,
87
62
}
88
63
89
- #[ derive( Default , Clone ) ]
90
- pub struct WgpuFeatures {
91
- pub features : Vec < WgpuFeature > ,
64
+ impl Default for WgpuLimits {
65
+ fn default ( ) -> Self {
66
+ let default = wgpu:: Limits :: default ( ) ;
67
+ WgpuLimits {
68
+ max_bind_groups : default. max_bind_groups ,
69
+ max_dynamic_uniform_buffers_per_pipeline_layout : default
70
+ . max_dynamic_uniform_buffers_per_pipeline_layout ,
71
+ max_dynamic_storage_buffers_per_pipeline_layout : default
72
+ . max_dynamic_storage_buffers_per_pipeline_layout ,
73
+ max_sampled_textures_per_shader_stage : default. max_sampled_textures_per_shader_stage ,
74
+ max_samplers_per_shader_stage : default. max_samplers_per_shader_stage ,
75
+ max_storage_buffers_per_shader_stage : default. max_storage_buffers_per_shader_stage ,
76
+ max_storage_textures_per_shader_stage : default. max_storage_textures_per_shader_stage ,
77
+ max_uniform_buffers_per_shader_stage : default. max_uniform_buffers_per_shader_stage ,
78
+ max_uniform_buffer_binding_size : default. max_uniform_buffer_binding_size ,
79
+ max_push_constant_size : default. max_push_constant_size ,
80
+ }
81
+ }
92
82
}
93
83
94
84
#[ derive( Default ) ]
@@ -120,9 +110,11 @@ pub fn get_wgpu_render_system(resources: &mut Resources) -> impl FnMut(&mut Worl
120
110
121
111
#[ derive( Default , Clone ) ]
122
112
pub struct WgpuOptions {
113
+ pub device_label : Option < Cow < ' static , str > > ,
123
114
pub backend : WgpuBackend ,
124
115
pub power_pref : WgpuPowerOptions ,
125
116
pub features : WgpuFeatures ,
117
+ pub limits : WgpuLimits ,
126
118
}
127
119
128
120
#[ derive( Clone ) ]
0 commit comments