@@ -178,13 +178,15 @@ FormatTable BuildFormatTable(const DeviceBase* device) {
178178 bool supportsResolveTarget, uint32_t byteSize, SampleTypeBit sampleTypes,
179179 uint8_t componentCount, uint8_t renderTargetPixelByteCost = 0 ,
180180 uint8_t renderTargetComponentAlignment = 0 ,
181+ bool supportsReadWriteStorageUsage = false ,
181182 wgpu::TextureFormat baseFormat = wgpu::TextureFormat::Undefined) {
182183 Format internalFormat;
183184 internalFormat.format = format;
184185 internalFormat.isRenderable = renderable;
185186 internalFormat.isCompressed = false ;
186187 internalFormat.unsupportedReason = unsupportedReason;
187188 internalFormat.supportsStorageUsage = supportsStorageUsage;
189+ internalFormat.supportsReadWriteStorageUsage = supportsReadWriteStorageUsage;
188190
189191 if (supportsMultisample) {
190192 ASSERT (renderable);
@@ -236,18 +238,20 @@ FormatTable BuildFormatTable(const DeviceBase* device) {
236238 AddFormat (internalFormat);
237239 };
238240
239- auto AddColorFormat =
240- [&AddConditionalColorFormat](
241- wgpu::TextureFormat format, bool renderable, bool supportsStorageUsage,
242- bool supportsMultisample, bool supportsResolveTarget, uint32_t byteSize,
243- SampleTypeBit sampleTypes, uint8_t componentCount,
244- uint8_t renderTargetPixelByteCost = 0 , uint8_t renderTargetComponentAlignment = 0 ,
245- wgpu::TextureFormat baseFormat = wgpu::TextureFormat::Undefined) {
246- AddConditionalColorFormat (format, std::monostate{}, renderable, supportsStorageUsage,
247- supportsMultisample, supportsResolveTarget, byteSize,
248- sampleTypes, componentCount, renderTargetPixelByteCost,
249- renderTargetComponentAlignment, baseFormat);
250- };
241+ auto AddColorFormat = [&AddConditionalColorFormat](
242+ wgpu::TextureFormat format, bool renderable,
243+ bool supportsStorageUsage, bool supportsMultisample,
244+ bool supportsResolveTarget, uint32_t byteSize,
245+ SampleTypeBit sampleTypes, uint8_t componentCount,
246+ uint8_t renderTargetPixelByteCost = 0 ,
247+ uint8_t renderTargetComponentAlignment = 0 ,
248+ bool supportsReadWriteStorageUsage = false ,
249+ wgpu::TextureFormat baseFormat = wgpu::TextureFormat::Undefined) {
250+ AddConditionalColorFormat (
251+ format, std::monostate{}, renderable, supportsStorageUsage, supportsMultisample,
252+ supportsResolveTarget, byteSize, sampleTypes, componentCount, renderTargetPixelByteCost,
253+ renderTargetComponentAlignment, supportsReadWriteStorageUsage, baseFormat);
254+ };
251255
252256 auto AddDepthFormat = [&AddFormat](wgpu::TextureFormat format, uint32_t byteSize,
253257 UnsupportedReason unsupportedReason) {
@@ -388,21 +392,22 @@ FormatTable BuildFormatTable(const DeviceBase* device) {
388392
389393 // 4 bytes color formats
390394 SampleTypeBit sampleTypeFor32BitFloatFormats = device->HasFeature (Feature::Float32Filterable) ? kAnyFloat : SampleTypeBit::UnfilterableFloat;
391- AddColorFormat (wgpu::TextureFormat::R32Uint, true , true , false , false , 4 , SampleTypeBit::Uint, 1 , 4 , 4 );
392- AddColorFormat (wgpu::TextureFormat::R32Sint, true , true , false , false , 4 , SampleTypeBit::Sint, 1 , 4 , 4 );
393- AddColorFormat (wgpu::TextureFormat::R32Float, true , true , true , false , 4 , sampleTypeFor32BitFloatFormats, 1 , 4 , 4 );
395+ bool SupportsReadWriteStorageUsage = device->HasFeature (Feature::ChromiumExperimentalReadWriteStorageTexture);
396+ AddColorFormat (wgpu::TextureFormat::R32Uint, true , true , false , false , 4 , SampleTypeBit::Uint, 1 , 4 , 4 , SupportsReadWriteStorageUsage);
397+ AddColorFormat (wgpu::TextureFormat::R32Sint, true , true , false , false , 4 , SampleTypeBit::Sint, 1 , 4 , 4 , SupportsReadWriteStorageUsage);
398+ AddColorFormat (wgpu::TextureFormat::R32Float, true , true , true , false , 4 , sampleTypeFor32BitFloatFormats, 1 , 4 , 4 , SupportsReadWriteStorageUsage);
394399 AddColorFormat (wgpu::TextureFormat::RG16Uint, true , false , true , false , 4 , SampleTypeBit::Uint, 2 , 4 , 2 );
395400 AddColorFormat (wgpu::TextureFormat::RG16Sint, true , false , true , false , 4 , SampleTypeBit::Sint, 2 , 4 , 2 );
396401 AddColorFormat (wgpu::TextureFormat::RG16Float, true , false , true , true , 4 , kAnyFloat , 2 , 4 , 2 );
397402 AddColorFormat (wgpu::TextureFormat::RGBA8Unorm, true , true , true , true , 4 , kAnyFloat , 4 , 8 , 1 );
398- AddColorFormat (wgpu::TextureFormat::RGBA8UnormSrgb, true , false , true , true , 4 , kAnyFloat , 4 , 8 , 1 , wgpu::TextureFormat::RGBA8Unorm);
403+ AddColorFormat (wgpu::TextureFormat::RGBA8UnormSrgb, true , false , true , true , 4 , kAnyFloat , 4 , 8 , 1 , false , wgpu::TextureFormat::RGBA8Unorm);
399404 AddColorFormat (wgpu::TextureFormat::RGBA8Snorm, false , true , false , false , 4 , kAnyFloat , 4 );
400405 AddColorFormat (wgpu::TextureFormat::RGBA8Uint, true , true , true , false , 4 , SampleTypeBit::Uint, 4 , 4 , 1 );
401406 AddColorFormat (wgpu::TextureFormat::RGBA8Sint, true , true , true , false , 4 , SampleTypeBit::Sint, 4 , 4 , 1 );
402407
403408 bool BGRA8UnormSupportsStorageUsage = device->HasFeature (Feature::BGRA8UnormStorage);
404409 AddColorFormat (wgpu::TextureFormat::BGRA8Unorm, true , BGRA8UnormSupportsStorageUsage, true , true , 4 , kAnyFloat , 4 , 8 , 1 );
405- AddConditionalColorFormat (wgpu::TextureFormat::BGRA8UnormSrgb, device->IsCompatibilityMode () ? UnsupportedReason (CompatibilityMode{}) : Format::supported, true , false , true , true , 4 , kAnyFloat , 4 , 8 , 1 , wgpu::TextureFormat::BGRA8Unorm);
410+ AddConditionalColorFormat (wgpu::TextureFormat::BGRA8UnormSrgb, device->IsCompatibilityMode () ? UnsupportedReason (CompatibilityMode{}) : Format::supported, true , false , true , true , 4 , kAnyFloat , 4 , 8 , 1 , false , wgpu::TextureFormat::BGRA8Unorm);
406411 AddColorFormat (wgpu::TextureFormat::RGB10A2Unorm, true , false , true , true , 4 , kAnyFloat , 4 , 8 , 4 );
407412
408413 bool isRG11B10UfloatRenderable = device->HasFeature (Feature::RG11B10UfloatRenderable);
0 commit comments