This repository was archived by the owner on Jan 29, 2025. It is now read-only.
File tree 3 files changed +10
-18
lines changed
3 files changed +10
-18
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ pub enum GlobalVariableError {
33
33
) ,
34
34
#[ error( "Initializer doesn't match the variable type" ) ]
35
35
InitializerType ,
36
+ #[ error( "Storage address space doesn't support write-only access" ) ]
37
+ StorageAddressSpaceWriteOnlyNotSupported ,
36
38
}
37
39
38
40
#[ derive( Clone , Debug , thiserror:: Error ) ]
@@ -416,7 +418,7 @@ impl super::Validator {
416
418
crate :: AddressSpace :: Function => {
417
419
return Err ( GlobalVariableError :: InvalidUsage ( var. space ) )
418
420
}
419
- crate :: AddressSpace :: Storage { .. } => {
421
+ crate :: AddressSpace :: Storage { access } => {
420
422
if let Err ( ( ty_handle, disalignment) ) = type_info. storage_layout {
421
423
if self . flags . contains ( super :: ValidationFlags :: STRUCT_LAYOUTS ) {
422
424
return Err ( GlobalVariableError :: Alignment (
@@ -426,6 +428,9 @@ impl super::Validator {
426
428
) ) ;
427
429
}
428
430
}
431
+ if access == crate :: StorageAccess :: STORE {
432
+ return Err ( GlobalVariableError :: StorageAddressSpaceWriteOnlyNotSupported ) ;
433
+ }
429
434
( TypeFlags :: DATA | TypeFlags :: HOST_SHAREABLE , true )
430
435
}
431
436
crate :: AddressSpace :: Uniform => {
Original file line number Diff line number Diff line change @@ -4,10 +4,6 @@ layout(set = 0, binding = 0) buffer testBufferBlock {
4
4
uint [] data;
5
5
} testBuffer;
6
6
7
- layout (set = 0 , binding = 1 ) writeonly buffer testBufferWriteOnlyBlock {
8
- uint [] data;
9
- } testBufferWriteOnly;
10
-
11
7
layout (set = 0 , binding = 2 ) readonly buffer testBufferReadOnlyBlock {
12
8
uint [] data;
13
9
} testBufferReadOnly;
@@ -16,7 +12,5 @@ void main() {
16
12
uint a = testBuffer.data[0 ];
17
13
testBuffer.data[1 ] = 2 ;
18
14
19
- testBufferWriteOnly.data[1 ] = 2 ;
20
-
21
15
uint b = testBufferReadOnly.data[0 ];
22
16
}
Original file line number Diff line number Diff line change @@ -2,31 +2,24 @@ struct testBufferBlock {
2
2
data : array <u32 >,
3
3
}
4
4
5
- struct testBufferWriteOnlyBlock {
6
- data : array <u32 >,
7
- }
8
-
9
5
struct testBufferReadOnlyBlock {
10
6
data : array <u32 >,
11
7
}
12
8
13
9
@group (0 ) @binding (0 )
14
10
var <storage , read_write > testBuffer: testBufferBlock;
15
- @group (0 ) @binding (1 )
16
- var <storage , read_write > testBufferWriteOnly: testBufferWriteOnlyBlock;
17
11
@group (0 ) @binding (2 )
18
12
var <storage > testBufferReadOnly: testBufferReadOnlyBlock;
19
13
20
14
fn main_1 () {
21
15
var a : u32 ;
22
16
var b : u32 ;
23
17
24
- let _e12 = testBuffer. data[0 ];
25
- a = _e12 ;
18
+ let _e9 = testBuffer. data[0 ];
19
+ a = _e9 ;
26
20
testBuffer. data[1 ] = u32 (2 );
27
- testBufferWriteOnly. data[1 ] = u32 (2 );
28
- let _e27 = testBufferReadOnly. data[0 ];
29
- b = _e27 ;
21
+ let _e19 = testBufferReadOnly. data[0 ];
22
+ b = _e19 ;
30
23
return ;
31
24
}
32
25
You can’t perform that action at this time.
0 commit comments