@@ -46,6 +46,14 @@ const MAX_BUFFER_SIZE_U32: u32 = MAX_BUFFER_SIZE as u32;
46
46
47
47
// Mesa has issues with height/depth that don't fit in a 16 bits signed integers.
48
48
const MAX_TEXTURE_EXTENT : u32 = std:: i16:: MAX as u32 ;
49
+ // We have to restrict the number of bindings for any given resource type so that
50
+ // the sum of these limits multiplied by the number of shader stages fits
51
+ // maxBindingsPerBindGroup (1000). This restriction is arbitrary and is likely to
52
+ // change eventually. See github.com/gpuweb/gpuweb/pull/4484
53
+ // For now it's impractical for users to have very large numbers of bindings so this
54
+ // limit should not be too restrictive until we add support for a bindless API.
55
+ // Then we may have to ignore the spec or get it changed.
56
+ const MAX_BINDINGS_PER_RESOURCE_TYPE : u32 = 64 ;
49
57
50
58
fn restrict_limits ( limits : wgt:: Limits ) -> wgt:: Limits {
51
59
wgt:: Limits {
@@ -55,12 +63,19 @@ fn restrict_limits(limits: wgt::Limits) -> wgt::Limits {
55
63
max_texture_dimension_3d : limits. max_texture_dimension_3d . min ( MAX_TEXTURE_EXTENT ) ,
56
64
max_sampled_textures_per_shader_stage : limits
57
65
. max_sampled_textures_per_shader_stage
58
- . min ( 256 ) ,
59
- max_samplers_per_shader_stage : limits. max_samplers_per_shader_stage . min ( 256 ) ,
66
+ . min ( MAX_BINDINGS_PER_RESOURCE_TYPE ) ,
67
+ max_samplers_per_shader_stage : limits
68
+ . max_samplers_per_shader_stage
69
+ . min ( MAX_BINDINGS_PER_RESOURCE_TYPE ) ,
60
70
max_storage_textures_per_shader_stage : limits
61
71
. max_storage_textures_per_shader_stage
62
- . min ( 256 ) ,
63
- max_uniform_buffers_per_shader_stage : limits. max_uniform_buffers_per_shader_stage . min ( 256 ) ,
72
+ . min ( MAX_BINDINGS_PER_RESOURCE_TYPE ) ,
73
+ max_uniform_buffers_per_shader_stage : limits
74
+ . max_uniform_buffers_per_shader_stage
75
+ . min ( MAX_BINDINGS_PER_RESOURCE_TYPE ) ,
76
+ max_storage_buffers_per_shader_stage : limits
77
+ . max_storage_buffers_per_shader_stage
78
+ . min ( MAX_BINDINGS_PER_RESOURCE_TYPE ) ,
64
79
max_uniform_buffer_binding_size : limits
65
80
. max_uniform_buffer_binding_size
66
81
. min ( MAX_BUFFER_SIZE_U32 ) ,
0 commit comments