@@ -326,12 +326,16 @@ bitflags::bitflags! {
326
326
const MAPPABLE_PRIMARY_BUFFERS = 1 << 16 ;
327
327
/// Allows the user to create uniform arrays of textures in shaders:
328
328
///
329
- /// eg. `uniform texture2D textures[10]`.
329
+ /// ex.
330
+ /// `var textures: binding_array<texture_2d<f32>, 10>` (WGSL)\
331
+ /// `uniform texture2D textures[10]` (GLSL)
330
332
///
331
333
/// If [`Features::STORAGE_RESOURCE_BINDING_ARRAY`] is supported as well as this, the user
332
334
/// may also create uniform arrays of storage textures.
333
335
///
334
- /// eg. `uniform image2D textures[10]`.
336
+ /// ex.
337
+ /// `var textures: array<texture_storage_2d<f32, write>, 10>` (WGSL)\
338
+ /// `uniform image2D textures[10]` (GLSL)
335
339
///
336
340
/// This capability allows them to exist and to be indexed by dynamically uniform
337
341
/// values.
@@ -345,15 +349,19 @@ bitflags::bitflags! {
345
349
const TEXTURE_BINDING_ARRAY = 1 << 17 ;
346
350
/// Allows the user to create arrays of buffers in shaders:
347
351
///
348
- /// eg. `uniform myBuffer { .... } buffer_array[10]`.
352
+ /// ex.
353
+ /// `var<uniform> buffer_array: array<MyBuffer, 10>` (WGSL)\
354
+ /// `uniform myBuffer { ... } buffer_array[10]` (GLSL)
349
355
///
350
356
/// This capability allows them to exist and to be indexed by dynamically uniform
351
357
/// values.
352
358
///
353
359
/// If [`Features::STORAGE_RESOURCE_BINDING_ARRAY`] is supported as well as this, the user
354
360
/// may also create arrays of storage buffers.
355
361
///
356
- /// eg. `buffer myBuffer { ... } buffer_array[10]`
362
+ /// ex.
363
+ /// `var<storage> buffer_array: array<MyBuffer, 10>` (WGSL)\
364
+ /// `buffer myBuffer { ... } buffer_array[10]` (GLSL)
357
365
///
358
366
/// Supported platforms:
359
367
/// - DX12
@@ -376,21 +384,21 @@ bitflags::bitflags! {
376
384
const STORAGE_RESOURCE_BINDING_ARRAY = 1 << 19 ;
377
385
/// Allows shaders to index sampled texture and storage buffer resource arrays with dynamically non-uniform values:
378
386
///
379
- /// eg . `texture_array[vertex_data]`
387
+ /// ex . `texture_array[vertex_data]`
380
388
///
381
389
/// In order to use this capability, the corresponding GLSL extension must be enabled like so:
382
390
///
383
391
/// `#extension GL_EXT_nonuniform_qualifier : require`
384
392
///
385
393
/// and then used either as `nonuniformEXT` qualifier in variable declaration:
386
394
///
387
- /// eg . `layout(location = 0) nonuniformEXT flat in int vertex_data;`
395
+ /// ex . `layout(location = 0) nonuniformEXT flat in int vertex_data;`
388
396
///
389
397
/// or as `nonuniformEXT` constructor:
390
398
///
391
- /// eg . `texture_array[nonuniformEXT(vertex_data)]`
399
+ /// ex . `texture_array[nonuniformEXT(vertex_data)]`
392
400
///
393
- /// HLSL does not need any extension.
401
+ /// WGSL and HLSL do not need any extension.
394
402
///
395
403
/// Supported platforms:
396
404
/// - DX12
@@ -401,21 +409,21 @@ bitflags::bitflags! {
401
409
const SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING = 1 << 20 ;
402
410
/// Allows shaders to index uniform buffer and storage texture resource arrays with dynamically non-uniform values:
403
411
///
404
- /// eg . `texture_array[vertex_data]`
412
+ /// ex . `texture_array[vertex_data]`
405
413
///
406
414
/// In order to use this capability, the corresponding GLSL extension must be enabled like so:
407
415
///
408
416
/// `#extension GL_EXT_nonuniform_qualifier : require`
409
417
///
410
418
/// and then used either as `nonuniformEXT` qualifier in variable declaration:
411
419
///
412
- /// eg . `layout(location = 0) nonuniformEXT flat in int vertex_data;`
420
+ /// ex . `layout(location = 0) nonuniformEXT flat in int vertex_data;`
413
421
///
414
422
/// or as `nonuniformEXT` constructor:
415
423
///
416
- /// eg . `texture_array[nonuniformEXT(vertex_data)]`
424
+ /// ex . `texture_array[nonuniformEXT(vertex_data)]`
417
425
///
418
- /// HLSL does not need any extension.
426
+ /// WGSL and HLSL do not need any extension.
419
427
///
420
428
/// Supported platforms:
421
429
/// - DX12
@@ -1206,22 +1214,22 @@ bitflags_serde_shim::impl_serde_for_bitflags!(ShaderStages);
1206
1214
#[ cfg_attr( feature = "trace" , derive( Serialize ) ) ]
1207
1215
#[ cfg_attr( feature = "replay" , derive( Deserialize ) ) ]
1208
1216
pub enum TextureViewDimension {
1209
- /// A one dimensional texture. `texture1D ` in glsl shaders .
1217
+ /// A one dimensional texture. `texture_1d ` in WGSL and `texture1D` in GLSL .
1210
1218
#[ cfg_attr( feature = "serde" , serde( rename = "1d" ) ) ]
1211
1219
D1 ,
1212
- /// A two dimensional texture. `texture2D ` in glsl shaders .
1220
+ /// A two dimensional texture. `texture_2d ` in WGSL and `texture2D` in GLSL .
1213
1221
#[ cfg_attr( feature = "serde" , serde( rename = "2d" ) ) ]
1214
1222
D2 ,
1215
- /// A two dimensional array texture. `texture2DArray ` in glsl shaders .
1223
+ /// A two dimensional array texture. `texture_2d_array ` in WGSL and `texture2DArray` in GLSL .
1216
1224
#[ cfg_attr( feature = "serde" , serde( rename = "2d-array" ) ) ]
1217
1225
D2Array ,
1218
- /// A cubemap texture. `textureCube ` in glsl shaders .
1226
+ /// A cubemap texture. `texture_cube ` in WGSL and `textureCube` in GLSL .
1219
1227
#[ cfg_attr( feature = "serde" , serde( rename = "cube" ) ) ]
1220
1228
Cube ,
1221
- /// A cubemap array texture. `textureCubeArray ` in glsl shaders .
1229
+ /// A cubemap array texture. `texture_cube_array ` in WGSL and `textureCubeArray` in GLSL .
1222
1230
#[ cfg_attr( feature = "serde" , serde( rename = "cube-array" ) ) ]
1223
1231
CubeArray ,
1224
- /// A three dimensional texture. `texture3D ` in glsl shaders .
1232
+ /// A three dimensional texture. `texture_3d ` in WGSL and `texture3D` in GLSL .
1225
1233
#[ cfg_attr( feature = "serde" , serde( rename = "3d" ) ) ]
1226
1234
D3 ,
1227
1235
}
@@ -2195,15 +2203,15 @@ impl TextureFormat {
2195
2203
Self :: Rgb10a2Unorm => ( native, float, linear, msaa_resolve, ( 1 , 1 ) , 4 , attachment, 4 ) ,
2196
2204
Self :: Rg11b10Float => ( native, float, linear, msaa, ( 1 , 1 ) , 4 , basic, 3 ) ,
2197
2205
2198
- // Packed 32 bit textures
2206
+ // Packed 32 bit textures
2199
2207
Self :: Rg32Uint => ( native, uint, linear, noaa, ( 1 , 1 ) , 8 , all_flags, 2 ) ,
2200
2208
Self :: Rg32Sint => ( native, sint, linear, noaa, ( 1 , 1 ) , 8 , all_flags, 2 ) ,
2201
2209
Self :: Rg32Float => ( native, nearest, linear, noaa, ( 1 , 1 ) , 8 , all_flags, 2 ) ,
2202
2210
Self :: Rgba16Uint => ( native, uint, linear, msaa, ( 1 , 1 ) , 8 , all_flags, 4 ) ,
2203
2211
Self :: Rgba16Sint => ( native, sint, linear, msaa, ( 1 , 1 ) , 8 , all_flags, 4 ) ,
2204
2212
Self :: Rgba16Float => ( native, float, linear, msaa_resolve, ( 1 , 1 ) , 8 , all_flags, 4 ) ,
2205
2213
2206
- // Packed 32 bit textures
2214
+ // Packed 32 bit textures
2207
2215
Self :: Rgba32Uint => ( native, uint, linear, noaa, ( 1 , 1 ) , 16 , all_flags, 4 ) ,
2208
2216
Self :: Rgba32Sint => ( native, sint, linear, noaa, ( 1 , 1 ) , 16 , all_flags, 4 ) ,
2209
2217
Self :: Rgba32Float => ( native, nearest, linear, noaa, ( 1 , 1 ) , 16 , all_flags, 4 ) ,
@@ -2215,7 +2223,7 @@ impl TextureFormat {
2215
2223
Self :: Depth24PlusStencil8 => ( native, depth, linear, msaa, ( 1 , 1 ) , 4 , attachment, 2 ) ,
2216
2224
Self :: Depth24UnormStencil8 => ( d24_s8, depth, linear, msaa, ( 1 , 1 ) , 4 , attachment, 2 ) ,
2217
2225
2218
- // Packed uncompressed
2226
+ // Packed uncompressed
2219
2227
Self :: Rgb9e5Ufloat => ( native, float, linear, noaa, ( 1 , 1 ) , 4 , basic, 3 ) ,
2220
2228
2221
2229
// Optional normalized 16-bit-per-channel formats
@@ -3710,6 +3718,16 @@ pub struct ImageDataLayout {
3710
3718
pub enum BufferBindingType {
3711
3719
/// A buffer for uniform values.
3712
3720
///
3721
+ /// Example WGSL syntax:
3722
+ /// ```rust,ignore
3723
+ /// struct Globals {
3724
+ /// a_uniform: vec2<f32>,
3725
+ /// another_uniform: vec2<f32>,
3726
+ /// }
3727
+ /// @group(0) @binding(0)
3728
+ /// var<uniform> globals: Globals;
3729
+ /// ```
3730
+ ///
3713
3731
/// Example GLSL syntax:
3714
3732
/// ```cpp,ignore
3715
3733
/// layout(std140, binding = 0)
@@ -3721,6 +3739,12 @@ pub enum BufferBindingType {
3721
3739
Uniform ,
3722
3740
/// A storage buffer.
3723
3741
///
3742
+ /// Example WGSL syntax:
3743
+ /// ```rust,ignore
3744
+ /// @group(0) @binding(0)
3745
+ /// var<storage, read_write> my_element: array<vec4<f32>>;
3746
+ /// ```
3747
+ ///
3724
3748
/// Example GLSL syntax:
3725
3749
/// ```cpp,ignore
3726
3750
/// layout (set=0, binding=0) buffer myStorageBuffer {
@@ -3729,7 +3753,15 @@ pub enum BufferBindingType {
3729
3753
/// ```
3730
3754
Storage {
3731
3755
/// If `true`, the buffer can only be read in the shader,
3732
- /// and it must be annotated with `readonly`.
3756
+ /// and it:
3757
+ /// - may or may not be annotated with `read` (WGSL).
3758
+ /// - must be annotated with `readonly` (GLSL).
3759
+ ///
3760
+ /// Example WGSL syntax:
3761
+ /// ```rust,ignore
3762
+ /// @group(0) @binding(0)
3763
+ /// var<storage, read> my_element: array<vec4<f32>>;
3764
+ /// ```
3733
3765
///
3734
3766
/// Example GLSL syntax:
3735
3767
/// ```cpp,ignore
@@ -3757,6 +3789,12 @@ impl Default for BufferBindingType {
3757
3789
pub enum TextureSampleType {
3758
3790
/// Sampling returns floats.
3759
3791
///
3792
+ /// Example WGSL syntax:
3793
+ /// ```rust,ignore
3794
+ /// @group(0) @binding(0)
3795
+ /// var t: texure_2d<f32>;
3796
+ /// ```
3797
+ ///
3760
3798
/// Example GLSL syntax:
3761
3799
/// ```cpp,ignore
3762
3800
/// layout(binding = 0)
@@ -3769,6 +3807,12 @@ pub enum TextureSampleType {
3769
3807
} ,
3770
3808
/// Sampling does the depth reference comparison.
3771
3809
///
3810
+ /// Example WGSL syntax:
3811
+ /// ```rust,ignore
3812
+ /// @group(0) @binding(0)
3813
+ /// var t: texture_depth_2d;
3814
+ /// ```
3815
+ ///
3772
3816
/// Example GLSL syntax:
3773
3817
/// ```cpp,ignore
3774
3818
/// layout(binding = 0)
@@ -3777,6 +3821,12 @@ pub enum TextureSampleType {
3777
3821
Depth ,
3778
3822
/// Sampling returns signed integers.
3779
3823
///
3824
+ /// Example WGSL syntax:
3825
+ /// ```rust,ignore
3826
+ /// @group(0) @binding(0)
3827
+ /// var t: texture_2d<i32>;
3828
+ /// ```
3829
+ ///
3780
3830
/// Example GLSL syntax:
3781
3831
/// ```cpp,ignore
3782
3832
/// layout(binding = 0)
@@ -3785,6 +3835,12 @@ pub enum TextureSampleType {
3785
3835
Sint ,
3786
3836
/// Sampling returns unsigned integers.
3787
3837
///
3838
+ /// Example WGSL syntax:
3839
+ /// ```rust,ignore
3840
+ /// @group(0) @binding(0)
3841
+ /// var t: texture_2d<u32>;
3842
+ /// ```
3843
+ ///
3788
3844
/// Example GLSL syntax:
3789
3845
/// ```cpp,ignore
3790
3846
/// layout(binding = 0)
@@ -3810,23 +3866,49 @@ impl Default for TextureSampleType {
3810
3866
#[ cfg_attr( feature = "replay" , derive( Deserialize ) ) ]
3811
3867
#[ cfg_attr( feature = "serde" , serde( rename_all = "kebab-case" ) ) ]
3812
3868
pub enum StorageTextureAccess {
3813
- /// The texture can only be written in the shader and it must be annotated with `writeonly`.
3869
+ /// The texture can only be written in the shader and it:
3870
+ /// - may or may not be annotated with `write` (WGSL).
3871
+ /// - must be annotated with `writeonly` (GLSL).
3872
+ ///
3873
+ /// Example WGSL syntax:
3874
+ /// ```rust,ignore
3875
+ /// @group(0) @binding(0)
3876
+ /// var my_storage_image: texture_storage_2d<f32, write>;
3877
+ /// ```
3814
3878
///
3815
3879
/// Example GLSL syntax:
3816
3880
/// ```cpp,ignore
3817
3881
/// layout(set=0, binding=0, r32f) writeonly uniform image2D myStorageImage;
3818
3882
/// ```
3819
3883
WriteOnly ,
3820
- /// The texture can only be read in the shader and it must be annotated with `readonly`.
3821
- /// [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] must be enabled to use this access mode,
3884
+ /// The texture can only be read in the shader and it must be annotated with `read` (WGSL) or
3885
+ /// `readonly` (GLSL).
3886
+ ///
3887
+ /// [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] must be enabled to use this access
3888
+ /// mode. This is a native-only extension.
3889
+ ///
3890
+ /// Example WGSL syntax:
3891
+ /// ```rust,ignore
3892
+ /// @group(0) @binding(0)
3893
+ /// var my_storage_image: texture_storage_2d<f32, read>;
3894
+ /// ```
3822
3895
///
3823
3896
/// Example GLSL syntax:
3824
3897
/// ```cpp,ignore
3825
3898
/// layout(set=0, binding=0, r32f) readonly uniform image2D myStorageImage;
3826
3899
/// ```
3827
3900
ReadOnly ,
3828
- /// The texture can be both read and written in the shader.
3829
- /// [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] must be enabled to use this access mode.
3901
+ /// The texture can be both read and written in the shader and must be annotated with
3902
+ /// `read_write` in WGSL.
3903
+ ///
3904
+ /// [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] must be enabled to use this access
3905
+ /// mode. This is a nonstandard, native-only extension.
3906
+ ///
3907
+ /// Example WGSL syntax:
3908
+ /// ```rust,ignore
3909
+ /// @group(0) @binding(0)
3910
+ /// var my_storage_image: texture_storage_2d<f32, read_write>;
3911
+ /// ```
3830
3912
///
3831
3913
/// Example GLSL syntax:
3832
3914
/// ```cpp,ignore
@@ -3891,6 +3973,12 @@ pub enum BindingType {
3891
3973
} ,
3892
3974
/// A sampler that can be used to sample a texture.
3893
3975
///
3976
+ /// Example WGSL syntax:
3977
+ /// ```rust,ignore
3978
+ /// @group(0) @binding(0)
3979
+ /// var s: sampler;
3980
+ /// ```
3981
+ ///
3894
3982
/// Example GLSL syntax:
3895
3983
/// ```cpp,ignore
3896
3984
/// layout(binding = 0)
@@ -3902,6 +3990,12 @@ pub enum BindingType {
3902
3990
Sampler ( SamplerBindingType ) ,
3903
3991
/// A texture binding.
3904
3992
///
3993
+ /// Example WGSL syntax:
3994
+ /// ```rust,ignore
3995
+ /// @group(0) @binding(0)
3996
+ /// var t: texture_2d<f32>;
3997
+ /// ```
3998
+ ///
3905
3999
/// Example GLSL syntax:
3906
4000
/// ```cpp,ignore
3907
4001
/// layout(binding = 0)
@@ -3922,9 +4016,15 @@ pub enum BindingType {
3922
4016
} ,
3923
4017
/// A storage texture.
3924
4018
///
4019
+ /// Example WGSL syntax:
4020
+ /// ```rust,ignore
4021
+ /// @group(0) @binding(0)
4022
+ /// var my_storage_image: texture_storage_2d<f32, write>;
4023
+ /// ```
4024
+ ///
3925
4025
/// Example GLSL syntax:
3926
4026
/// ```cpp,ignore
3927
- /// layout(set=0, binding=0, r32f) uniform image2D myStorageImage;
4027
+ /// layout(set=0, binding=0, r32f) writeonly uniform image2D myStorageImage;
3928
4028
/// ```
3929
4029
/// Note that the texture format must be specified in the shader as well.
3930
4030
/// A list of valid formats can be found in the specification here: <https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.60.html#layout-qualifiers>
0 commit comments