File tree Expand file tree Collapse file tree 8 files changed +30
-20
lines changed Expand file tree Collapse file tree 8 files changed +30
-20
lines changed Original file line number Diff line number Diff line change @@ -625,6 +625,8 @@ pub enum ColorAttachmentError {
625
625
mip_level : u32 ,
626
626
depth_or_array_layer : u32 ,
627
627
} ,
628
+ #[ error( "Color attachment's usage cannot contain {0:?} if StoreOp is {1:?}" ) ]
629
+ InvalidUsageForStoreOp ( TextureUsages , StoreOp ) ,
628
630
}
629
631
630
632
impl WebGpuError for ColorAttachmentError {
@@ -1585,6 +1587,17 @@ impl Global {
1585
1587
let view = texture_views. get ( * view_id) . get ( ) ?;
1586
1588
view. same_device ( device) ?;
1587
1589
1590
+ if view. desc . usage . contains ( TextureUsages :: TRANSIENT )
1591
+ && * store_op != StoreOp :: Discard
1592
+ {
1593
+ return Err ( RenderPassErrorInner :: ColorAttachment (
1594
+ ColorAttachmentError :: InvalidUsageForStoreOp (
1595
+ TextureUsages :: TRANSIENT ,
1596
+ * store_op,
1597
+ ) ,
1598
+ ) ) ;
1599
+ }
1600
+
1588
1601
let resolve_target = if let Some ( resolve_target_id) = resolve_target {
1589
1602
let rt_arc = texture_views. get ( * resolve_target_id) . get ( ) ?;
1590
1603
rt_arc. same_device ( device) ?;
Original file line number Diff line number Diff line change @@ -1262,6 +1262,17 @@ impl Device {
1262
1262
}
1263
1263
}
1264
1264
1265
+ if desc. usage . contains ( wgt:: TextureUsages :: TRANSIENT ) {
1266
+ let extra_usage =
1267
+ desc. usage - wgt:: TextureUsages :: TRANSIENT - wgt:: TextureUsages :: RENDER_ATTACHMENT ;
1268
+ if !extra_usage. is_empty ( ) {
1269
+ return Err ( CreateTextureError :: IncompatibleUsage (
1270
+ wgt:: TextureUsages :: TRANSIENT ,
1271
+ extra_usage,
1272
+ ) ) ;
1273
+ }
1274
+ }
1275
+
1265
1276
let format_features = self
1266
1277
. describe_format_features ( desc. format )
1267
1278
. map_err ( |error| CreateTextureError :: MissingFeatures ( desc. format , error) ) ?;
@@ -4464,10 +4475,6 @@ impl Device {
4464
4475
{
4465
4476
format_features. flags . set ( tfsc:: FILTERABLE , false ) ;
4466
4477
}
4467
- format_features. allowed_usages . set (
4468
- wgt:: TextureUsages :: TRANSIENT ,
4469
- self . features . contains ( wgt:: Features :: TRANSIENT_ATTACHMENTS ) ,
4470
- ) ;
4471
4478
format_features
4472
4479
}
4473
4480
Original file line number Diff line number Diff line change @@ -706,6 +706,7 @@ impl Adapter {
706
706
wgt:: TextureUsages :: STORAGE_ATOMIC ,
707
707
caps. contains ( Tfc :: STORAGE_ATOMIC ) ,
708
708
) ;
709
+ allowed_usages |= wgt:: TextureUsages :: TRANSIENT ;
709
710
710
711
let mut flags = wgt:: TextureFormatFeatureFlags :: empty ( ) ;
711
712
flags. set (
Original file line number Diff line number Diff line change @@ -1509,6 +1509,8 @@ pub enum CreateTextureError {
1509
1509
CreateTextureView ( #[ from] CreateTextureViewError ) ,
1510
1510
#[ error( "Invalid usage flags {0:?}" ) ]
1511
1511
InvalidUsage ( wgt:: TextureUsages ) ,
1512
+ #[ error( "Texture usage {0:?} is not compatible with texture usage {1:?}" ) ]
1513
+ IncompatibleUsage ( wgt:: TextureUsages , wgt:: TextureUsages ) ,
1512
1514
#[ error( transparent) ]
1513
1515
InvalidDimension ( #[ from] TextureDimensionError ) ,
1514
1516
#[ error( "Depth texture ({1:?}) can't be created as {0:?}" ) ]
@@ -1564,6 +1566,7 @@ impl WebGpuError for CreateTextureError {
1564
1566
Self :: MissingDownlevelFlags ( e) => e,
1565
1567
1566
1568
Self :: InvalidUsage ( _)
1569
+ | Self :: IncompatibleUsage ( _, _)
1567
1570
| Self :: InvalidDepthDimension ( _, _)
1568
1571
| Self :: InvalidCompressedDimension ( _, _)
1569
1572
| Self :: InvalidMipLevelCount { .. }
Original file line number Diff line number Diff line change @@ -1002,8 +1002,6 @@ impl super::PrivateCapabilities {
1002
1002
features. insert ( F :: SUBGROUP | F :: SUBGROUP_BARRIER ) ;
1003
1003
}
1004
1004
1005
- features. set ( F :: TRANSIENT_ATTACHMENTS , self . supports_memoryless_storage ) ;
1006
-
1007
1005
features
1008
1006
}
1009
1007
Original file line number Diff line number Diff line change @@ -560,8 +560,7 @@ impl PhysicalDeviceFeatures {
560
560
| F :: PIPELINE_CACHE
561
561
| F :: SHADER_EARLY_DEPTH_TEST
562
562
| F :: TEXTURE_ATOMIC
563
- | F :: EXPERIMENTAL_PASSTHROUGH_SHADERS
564
- | F :: TRANSIENT_ATTACHMENTS ;
563
+ | F :: EXPERIMENTAL_PASSTHROUGH_SHADERS ;
565
564
566
565
let mut dl_flags = Df :: COMPUTE_SHADERS
567
566
| Df :: BASE_VERTEX
Original file line number Diff line number Diff line change @@ -1231,17 +1231,6 @@ bitflags_array! {
1231
1231
///
1232
1232
/// [`Device::create_shader_module_passthrough`]: https://docs.rs/wgpu/latest/wgpu/struct.Device.html#method.create_shader_module_passthrough
1233
1233
const EXPERIMENTAL_PASSTHROUGH_SHADERS = 1 << 52 ;
1234
-
1235
- /// Allows transient attachments to be created with [`TextureUsages::TRANSIENT`]
1236
- ///
1237
- /// Supported platforms
1238
- /// - Vulkan
1239
- /// - Metal
1240
- ///
1241
- /// This is a native only feature
1242
- ///
1243
- /// [`TextureUsages::TRANSIENT`]: super::TextureUsages::TRANSIENT
1244
- const TRANSIENT_ATTACHMENTS = 1 << 53 ;
1245
1234
}
1246
1235
1247
1236
/// Features that are not guaranteed to be supported.
Original file line number Diff line number Diff line change @@ -5610,7 +5610,7 @@ bitflags::bitflags! {
5610
5610
//
5611
5611
/// Allows a texture to be used with image atomics. Requires [`Features::TEXTURE_ATOMIC`].
5612
5612
const STORAGE_ATOMIC = 1 << 16 ;
5613
- /// Allows a texture to be transient. Requires [`Features::TRANSIENT_ATTACHMENTS`] .
5613
+ /// Allows a texture to be transient. No-op on platforms other than Vulkan and Metal .
5614
5614
const TRANSIENT = 1 << 17 ;
5615
5615
}
5616
5616
}
You can’t perform that action at this time.
0 commit comments