@@ -64,6 +64,31 @@ MaybeError ValidateStorageTextureViewDimension(wgpu::TextureViewDimension dimens
6464 UNREACHABLE ();
6565}
6666
67+ MaybeError ValidateReadWriteStorageTextureAccess (
68+ DeviceBase* device,
69+ const StorageTextureBindingLayout& storageTextureBindingLayout) {
70+ switch (storageTextureBindingLayout.access ) {
71+ case wgpu::StorageTextureAccess::ReadOnly:
72+ case wgpu::StorageTextureAccess::ReadWrite:
73+ if (!device->APIHasFeature (
74+ wgpu::FeatureName::ChromiumExperimentalReadWriteStorageTexture)) {
75+ return DAWN_VALIDATION_ERROR (
76+ " storage texture access %s cannot be used without feature "
77+ " %s" ,
78+ storageTextureBindingLayout.access ,
79+ wgpu::FeatureName::ChromiumExperimentalReadWriteStorageTexture);
80+ }
81+ break ;
82+
83+ case wgpu::StorageTextureAccess::WriteOnly:
84+ break ;
85+ default :
86+ UNREACHABLE ();
87+ }
88+
89+ return {};
90+ }
91+
6792MaybeError ValidateBindGroupLayoutEntry (DeviceBase* device,
6893 const BindGroupLayoutEntry& entry,
6994 bool allowInternalBinding) {
@@ -143,11 +168,20 @@ MaybeError ValidateBindGroupLayoutEntry(DeviceBase* device,
143168 DAWN_TRY (ValidateStorageTextureViewDimension (storageTexture.viewDimension ));
144169 }
145170
146- if (storageTexture.access == wgpu::StorageTextureAccess::WriteOnly) {
147- DAWN_INVALID_IF (entry.visibility & wgpu::ShaderStage::Vertex,
148- " Write-only storage texture binding is used with a visibility (%s) "
149- " that contains %s." ,
150- entry.visibility , wgpu::ShaderStage::Vertex);
171+ DAWN_TRY (ValidateReadWriteStorageTextureAccess (device, storageTexture));
172+
173+ switch (storageTexture.access ) {
174+ case wgpu::StorageTextureAccess::ReadOnly:
175+ break ;
176+ case wgpu::StorageTextureAccess::ReadWrite:
177+ case wgpu::StorageTextureAccess::WriteOnly:
178+ DAWN_INVALID_IF (entry.visibility & wgpu::ShaderStage::Vertex,
179+ " Storage texture binding with %s is used with a visibility (%s) "
180+ " that contains %s." ,
181+ storageTexture.access , entry.visibility , wgpu::ShaderStage::Vertex);
182+ break ;
183+ default :
184+ UNREACHABLE ();
151185 }
152186 }
153187
0 commit comments