Skip to content

Commit 88c231b

Browse files
committed
[tint] Add read-only storage texture builtins
Most backends "just worked", except HLSL which uses a different register space for read-only textures. Bug: tint:2007 Change-Id: I7925b3bdf7389e3b429e0a570e988adde0443452 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/146961 Kokoro: Kokoro <[email protected]> Reviewed-by: Ben Clayton <[email protected]>
1 parent 6d338a7 commit 88c231b

File tree

3,575 files changed

+186168
-70
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,575 files changed

+186168
-70
lines changed

src/tint/lang/core/core.def

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,9 @@ match u32_texel_format
399399

400400
match write: access.write
401401
match read_write: access.read_write
402+
match readable
403+
: access.read
404+
| access.read_write
402405
match writable
403406
: access.write
404407
| access.read_write
@@ -758,10 +761,10 @@ match workgroup
758761
@must_use fn textureDimensions(texture: texture_depth_cube_array) -> vec2<u32>
759762
@must_use fn textureDimensions<L: iu32>(texture: texture_depth_cube_array, level: L) -> vec2<u32>
760763
@must_use fn textureDimensions(texture: texture_depth_multisampled_2d) -> vec2<u32>
761-
@must_use fn textureDimensions<F: texel_format, A: writable>(texture: texture_storage_1d<F, A>) -> u32
762-
@must_use fn textureDimensions<F: texel_format, A: writable>(texture: texture_storage_2d<F, A>) -> vec2<u32>
763-
@must_use fn textureDimensions<F: texel_format, A: writable>(texture: texture_storage_2d_array<F, A>) -> vec2<u32>
764-
@must_use fn textureDimensions<F: texel_format, A: writable>(texture: texture_storage_3d<F, A>) -> vec3<u32>
764+
@must_use fn textureDimensions<F: texel_format, A: access>(texture: texture_storage_1d<F, A>) -> u32
765+
@must_use fn textureDimensions<F: texel_format, A: access>(texture: texture_storage_2d<F, A>) -> vec2<u32>
766+
@must_use fn textureDimensions<F: texel_format, A: access>(texture: texture_storage_2d_array<F, A>) -> vec2<u32>
767+
@must_use fn textureDimensions<F: texel_format, A: access>(texture: texture_storage_3d<F, A>) -> vec3<u32>
765768
@must_use fn textureDimensions(texture: texture_external) -> vec2<u32>
766769
@must_use fn textureGather<T: fiu32, C: iu32>(@const component: C, texture: texture_2d<T>, sampler: sampler, coords: vec2<f32>) -> vec4<T>
767770
@must_use fn textureGather<T: fiu32, C: iu32>(@const component: C, texture: texture_2d<T>, sampler: sampler, coords: vec2<f32>, @const offset: vec2<i32>) -> vec4<T>
@@ -785,7 +788,7 @@ match workgroup
785788
@must_use fn textureNumLayers<T: fiu32>(texture: texture_cube_array<T>) -> u32
786789
@must_use fn textureNumLayers(texture: texture_depth_2d_array) -> u32
787790
@must_use fn textureNumLayers(texture: texture_depth_cube_array) -> u32
788-
@must_use fn textureNumLayers<F: texel_format, A: writable>(texture: texture_storage_2d_array<F, A>) -> u32
791+
@must_use fn textureNumLayers<F: texel_format, A: access>(texture: texture_storage_2d_array<F, A>) -> u32
789792
@must_use fn textureNumLevels<T: fiu32>(texture: texture_1d<T>) -> u32
790793
@must_use fn textureNumLevels<T: fiu32>(texture: texture_2d<T>) -> u32
791794
@must_use fn textureNumLevels<T: fiu32>(texture: texture_2d_array<T>) -> u32
@@ -878,18 +881,18 @@ fn textureStore<C: iu32>(texture: texture_storage_3d<u32_texel_format, writable>
878881
@must_use fn textureLoad<C: iu32, A: iu32, L: iu32>(texture: texture_depth_2d_array, coords: vec2<C>, array_index: A, level: L) -> f32
879882
@must_use fn textureLoad<C: iu32, S: iu32>(texture: texture_depth_multisampled_2d, coords: vec2<C>, sample_index: S) -> f32
880883
@must_use fn textureLoad<C: iu32>(texture: texture_external, coords: vec2<C>) -> vec4<f32>
881-
@must_use fn textureLoad<C: iu32>(texture: texture_storage_1d<f32_texel_format, read_write>, coords: C) -> vec4<f32>
882-
@must_use fn textureLoad<C: iu32>(texture: texture_storage_1d<i32_texel_format, read_write>, coords: C) -> vec4<i32>
883-
@must_use fn textureLoad<C: iu32>(texture: texture_storage_1d<u32_texel_format, read_write>, coords: C) -> vec4<u32>
884-
@must_use fn textureLoad<C: iu32>(texture: texture_storage_2d<f32_texel_format, read_write>, coords: vec2<C>) -> vec4<f32>
885-
@must_use fn textureLoad<C: iu32>(texture: texture_storage_2d<i32_texel_format, read_write>, coords: vec2<C>) -> vec4<i32>
886-
@must_use fn textureLoad<C: iu32>(texture: texture_storage_2d<u32_texel_format, read_write>, coords: vec2<C>) -> vec4<u32>
887-
@must_use fn textureLoad<C: iu32, A: iu32>(texture: texture_storage_2d_array<f32_texel_format, read_write>, coords: vec2<C>, array_index: A) -> vec4<f32>
888-
@must_use fn textureLoad<C: iu32, A: iu32>(texture: texture_storage_2d_array<i32_texel_format, read_write>, coords: vec2<C>, array_index: A) -> vec4<i32>
889-
@must_use fn textureLoad<C: iu32, A: iu32>(texture: texture_storage_2d_array<u32_texel_format, read_write>, coords: vec2<C>, array_index: A) -> vec4<u32>
890-
@must_use fn textureLoad<C: iu32>(texture: texture_storage_3d<f32_texel_format, read_write>, coords: vec3<C>) -> vec4<f32>
891-
@must_use fn textureLoad<C: iu32>(texture: texture_storage_3d<i32_texel_format, read_write>, coords: vec3<C>) -> vec4<i32>
892-
@must_use fn textureLoad<C: iu32>(texture: texture_storage_3d<u32_texel_format, read_write>, coords: vec3<C>) -> vec4<u32>
884+
@must_use fn textureLoad<C: iu32>(texture: texture_storage_1d<f32_texel_format, readable>, coords: C) -> vec4<f32>
885+
@must_use fn textureLoad<C: iu32>(texture: texture_storage_1d<i32_texel_format, readable>, coords: C) -> vec4<i32>
886+
@must_use fn textureLoad<C: iu32>(texture: texture_storage_1d<u32_texel_format, readable>, coords: C) -> vec4<u32>
887+
@must_use fn textureLoad<C: iu32>(texture: texture_storage_2d<f32_texel_format, readable>, coords: vec2<C>) -> vec4<f32>
888+
@must_use fn textureLoad<C: iu32>(texture: texture_storage_2d<i32_texel_format, readable>, coords: vec2<C>) -> vec4<i32>
889+
@must_use fn textureLoad<C: iu32>(texture: texture_storage_2d<u32_texel_format, readable>, coords: vec2<C>) -> vec4<u32>
890+
@must_use fn textureLoad<C: iu32, A: iu32>(texture: texture_storage_2d_array<f32_texel_format, readable>, coords: vec2<C>, array_index: A) -> vec4<f32>
891+
@must_use fn textureLoad<C: iu32, A: iu32>(texture: texture_storage_2d_array<i32_texel_format, readable>, coords: vec2<C>, array_index: A) -> vec4<i32>
892+
@must_use fn textureLoad<C: iu32, A: iu32>(texture: texture_storage_2d_array<u32_texel_format, readable>, coords: vec2<C>, array_index: A) -> vec4<u32>
893+
@must_use fn textureLoad<C: iu32>(texture: texture_storage_3d<f32_texel_format, readable>, coords: vec3<C>) -> vec4<f32>
894+
@must_use fn textureLoad<C: iu32>(texture: texture_storage_3d<i32_texel_format, readable>, coords: vec3<C>) -> vec4<i32>
895+
@must_use fn textureLoad<C: iu32>(texture: texture_storage_3d<u32_texel_format, readable>, coords: vec3<C>) -> vec4<u32>
893896

894897
@stage("fragment", "compute") fn atomicLoad<T: iu32, S: workgroup_or_storage>(ptr<S, atomic<T>, read_write>) -> T
895898
@stage("fragment", "compute") fn atomicStore<T: iu32, S: workgroup_or_storage>(ptr<S, atomic<T>, read_write>, T)

src/tint/lang/core/intrinsic/data/data.cc

Lines changed: 54 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,6 +1651,22 @@ constexpr NumberMatcher kReadWriteMatcher {
16511651
}
16521652
};
16531653

1654+
/// EnumMatcher for 'match readable'
1655+
constexpr NumberMatcher kReadableMatcher {
1656+
/* match */ [](MatchState&, Number number) -> Number {
1657+
switch (static_cast<Access>(number.Value())) {
1658+
case Access::kRead:
1659+
case Access::kReadWrite:
1660+
return number;
1661+
default:
1662+
return Number::invalid;
1663+
}
1664+
},
1665+
/* string */ [](MatchState*) -> std::string {
1666+
return "read or read_write";
1667+
}
1668+
};
1669+
16541670
/// EnumMatcher for 'match writable'
16551671
constexpr NumberMatcher kWritableMatcher {
16561672
/* match */ [](MatchState&, Number number) -> Number {
@@ -1815,11 +1831,12 @@ constexpr NumberMatcher kNumberMatchers[] = {
18151831
/* [5] */ kU32TexelFormatMatcher,
18161832
/* [6] */ kWriteMatcher,
18171833
/* [7] */ kReadWriteMatcher,
1818-
/* [8] */ kWritableMatcher,
1819-
/* [9] */ kFunctionPrivateWorkgroupMatcher,
1820-
/* [10] */ kWorkgroupOrStorageMatcher,
1821-
/* [11] */ kStorageMatcher,
1822-
/* [12] */ kWorkgroupMatcher,
1834+
/* [8] */ kReadableMatcher,
1835+
/* [9] */ kWritableMatcher,
1836+
/* [10] */ kFunctionPrivateWorkgroupMatcher,
1837+
/* [11] */ kWorkgroupOrStorageMatcher,
1838+
/* [12] */ kStorageMatcher,
1839+
/* [13] */ kWorkgroupMatcher,
18231840
};
18241841

18251842
constexpr TypeMatcherIndex kTypeMatcherIndices[] = {
@@ -2003,26 +2020,26 @@ static_assert(TypeMatcherIndex::CanIndex(kTypeMatcherIndices),
20032020
"TypeMatcherIndex is not large enough to index kTypeMatcherIndices");
20042021

20052022
constexpr NumberMatcherIndex kNumberMatcherIndices[] = {
2006-
/* [0] */ NumberMatcherIndex(11),
2023+
/* [0] */ NumberMatcherIndex(12),
20072024
/* [1] */ NumberMatcherIndex(0),
20082025
/* [2] */ NumberMatcherIndex(0),
20092026
/* [3] */ NumberMatcherIndex(1),
20102027
/* [4] */ NumberMatcherIndex(0),
20112028
/* [5] */ NumberMatcherIndex(7),
2012-
/* [6] */ NumberMatcherIndex(12),
2029+
/* [6] */ NumberMatcherIndex(13),
20132030
/* [7] */ NumberMatcherIndex(7),
20142031
/* [8] */ NumberMatcherIndex(3),
2015-
/* [9] */ NumberMatcherIndex(8),
2032+
/* [9] */ NumberMatcherIndex(9),
20162033
/* [10] */ NumberMatcherIndex(4),
2017-
/* [11] */ NumberMatcherIndex(8),
2034+
/* [11] */ NumberMatcherIndex(9),
20182035
/* [12] */ NumberMatcherIndex(5),
2019-
/* [13] */ NumberMatcherIndex(8),
2036+
/* [13] */ NumberMatcherIndex(9),
20202037
/* [14] */ NumberMatcherIndex(3),
2021-
/* [15] */ NumberMatcherIndex(7),
2038+
/* [15] */ NumberMatcherIndex(8),
20222039
/* [16] */ NumberMatcherIndex(4),
2023-
/* [17] */ NumberMatcherIndex(7),
2040+
/* [17] */ NumberMatcherIndex(8),
20242041
/* [18] */ NumberMatcherIndex(5),
2025-
/* [19] */ NumberMatcherIndex(7),
2042+
/* [19] */ NumberMatcherIndex(8),
20262043
/* [20] */ NumberMatcherIndex(1),
20272044
/* [21] */ NumberMatcherIndex(2),
20282045
/* [22] */ NumberMatcherIndex(0),
@@ -4722,17 +4739,12 @@ constexpr TemplateNumberInfo kTemplateNumbers[] = {
47224739
{
47234740
/* [7] */
47244741
/* name */ "A",
4725-
/* matcher_index */ NumberMatcherIndex(8),
4726-
},
4727-
{
4728-
/* [8] */
4729-
/* name */ "A",
47304742
/* matcher_index */ NumberMatcherIndex(/* invalid */),
47314743
},
47324744
{
4733-
/* [9] */
4745+
/* [8] */
47344746
/* name */ "S",
4735-
/* matcher_index */ NumberMatcherIndex(10),
4747+
/* matcher_index */ NumberMatcherIndex(11),
47364748
},
47374749
};
47384750

@@ -10474,7 +10486,7 @@ constexpr OverloadInfo kOverloads[] = {
1047410486
/* num_template_types */ 1,
1047510487
/* num_template_numbers */ 1,
1047610488
/* template_types */ TemplateTypeIndex(25),
10477-
/* template_numbers */ TemplateNumberIndex(8),
10489+
/* template_numbers */ TemplateNumberIndex(7),
1047810490
/* parameters */ ParameterIndex(366),
1047910491
/* return_type_matcher_indices */ TypeMatcherIndicesIndex(35),
1048010492
/* return_number_matcher_indices */ NumberMatcherIndicesIndex(/* invalid */),
@@ -10773,7 +10785,7 @@ constexpr OverloadInfo kOverloads[] = {
1077310785
/* num_template_types */ 1,
1077410786
/* num_template_numbers */ 1,
1077510787
/* template_types */ TemplateTypeIndex(26),
10776-
/* template_numbers */ TemplateNumberIndex(9),
10788+
/* template_numbers */ TemplateNumberIndex(8),
1077710789
/* parameters */ ParameterIndex(0),
1077810790
/* return_type_matcher_indices */ TypeMatcherIndicesIndex(2),
1077910791
/* return_number_matcher_indices */ NumberMatcherIndicesIndex(/* invalid */),
@@ -10786,7 +10798,7 @@ constexpr OverloadInfo kOverloads[] = {
1078610798
/* num_template_types */ 1,
1078710799
/* num_template_numbers */ 1,
1078810800
/* template_types */ TemplateTypeIndex(26),
10789-
/* template_numbers */ TemplateNumberIndex(9),
10801+
/* template_numbers */ TemplateNumberIndex(8),
1079010802
/* parameters */ ParameterIndex(0),
1079110803
/* return_type_matcher_indices */ TypeMatcherIndicesIndex(/* invalid */),
1079210804
/* return_number_matcher_indices */ NumberMatcherIndicesIndex(/* invalid */),
@@ -10799,7 +10811,7 @@ constexpr OverloadInfo kOverloads[] = {
1079910811
/* num_template_types */ 1,
1080010812
/* num_template_numbers */ 1,
1080110813
/* template_types */ TemplateTypeIndex(26),
10802-
/* template_numbers */ TemplateNumberIndex(9),
10814+
/* template_numbers */ TemplateNumberIndex(8),
1080310815
/* parameters */ ParameterIndex(0),
1080410816
/* return_type_matcher_indices */ TypeMatcherIndicesIndex(2),
1080510817
/* return_number_matcher_indices */ NumberMatcherIndicesIndex(/* invalid */),
@@ -10812,7 +10824,7 @@ constexpr OverloadInfo kOverloads[] = {
1081210824
/* num_template_types */ 1,
1081310825
/* num_template_numbers */ 1,
1081410826
/* template_types */ TemplateTypeIndex(26),
10815-
/* template_numbers */ TemplateNumberIndex(9),
10827+
/* template_numbers */ TemplateNumberIndex(8),
1081610828
/* parameters */ ParameterIndex(0),
1081710829
/* return_type_matcher_indices */ TypeMatcherIndicesIndex(80),
1081810830
/* return_number_matcher_indices */ NumberMatcherIndicesIndex(/* invalid */),
@@ -11506,10 +11518,10 @@ constexpr IntrinsicInfo kBuiltins[] = {
1150611518
/* fn textureDimensions(texture: texture_depth_cube_array) -> vec2<u32> */
1150711519
/* fn textureDimensions<L : iu32>(texture: texture_depth_cube_array, level: L) -> vec2<u32> */
1150811520
/* fn textureDimensions(texture: texture_depth_multisampled_2d) -> vec2<u32> */
11509-
/* fn textureDimensions<F : texel_format, A : writable>(texture: texture_storage_1d<F, A>) -> u32 */
11510-
/* fn textureDimensions<F : texel_format, A : writable>(texture: texture_storage_2d<F, A>) -> vec2<u32> */
11511-
/* fn textureDimensions<F : texel_format, A : writable>(texture: texture_storage_2d_array<F, A>) -> vec2<u32> */
11512-
/* fn textureDimensions<F : texel_format, A : writable>(texture: texture_storage_3d<F, A>) -> vec3<u32> */
11521+
/* fn textureDimensions<F : texel_format, A : access>(texture: texture_storage_1d<F, A>) -> u32 */
11522+
/* fn textureDimensions<F : texel_format, A : access>(texture: texture_storage_2d<F, A>) -> vec2<u32> */
11523+
/* fn textureDimensions<F : texel_format, A : access>(texture: texture_storage_2d_array<F, A>) -> vec2<u32> */
11524+
/* fn textureDimensions<F : texel_format, A : access>(texture: texture_storage_3d<F, A>) -> vec3<u32> */
1151311525
/* fn textureDimensions(texture: texture_external) -> vec2<u32> */
1151411526
/* num overloads */ 27,
1151511527
/* overloads */ OverloadIndex(0),
@@ -11548,7 +11560,7 @@ constexpr IntrinsicInfo kBuiltins[] = {
1154811560
/* fn textureNumLayers<T : fiu32>(texture: texture_cube_array<T>) -> u32 */
1154911561
/* fn textureNumLayers(texture: texture_depth_2d_array) -> u32 */
1155011562
/* fn textureNumLayers(texture: texture_depth_cube_array) -> u32 */
11551-
/* fn textureNumLayers<F : texel_format, A : writable>(texture: texture_storage_2d_array<F, A>) -> u32 */
11563+
/* fn textureNumLayers<F : texel_format, A : access>(texture: texture_storage_2d_array<F, A>) -> u32 */
1155211564
/* num overloads */ 5,
1155311565
/* overloads */ OverloadIndex(246),
1155411566
},
@@ -11696,18 +11708,18 @@ constexpr IntrinsicInfo kBuiltins[] = {
1169611708
/* fn textureLoad<C : iu32, A : iu32, L : iu32>(texture: texture_depth_2d_array, coords: vec2<C>, array_index: A, level: L) -> f32 */
1169711709
/* fn textureLoad<C : iu32, S : iu32>(texture: texture_depth_multisampled_2d, coords: vec2<C>, sample_index: S) -> f32 */
1169811710
/* fn textureLoad<C : iu32>(texture: texture_external, coords: vec2<C>) -> vec4<f32> */
11699-
/* fn textureLoad<C : iu32>(texture: texture_storage_1d<f32_texel_format, read_write>, coords: C) -> vec4<f32> */
11700-
/* fn textureLoad<C : iu32>(texture: texture_storage_1d<i32_texel_format, read_write>, coords: C) -> vec4<i32> */
11701-
/* fn textureLoad<C : iu32>(texture: texture_storage_1d<u32_texel_format, read_write>, coords: C) -> vec4<u32> */
11702-
/* fn textureLoad<C : iu32>(texture: texture_storage_2d<f32_texel_format, read_write>, coords: vec2<C>) -> vec4<f32> */
11703-
/* fn textureLoad<C : iu32>(texture: texture_storage_2d<i32_texel_format, read_write>, coords: vec2<C>) -> vec4<i32> */
11704-
/* fn textureLoad<C : iu32>(texture: texture_storage_2d<u32_texel_format, read_write>, coords: vec2<C>) -> vec4<u32> */
11705-
/* fn textureLoad<C : iu32, A : iu32>(texture: texture_storage_2d_array<f32_texel_format, read_write>, coords: vec2<C>, array_index: A) -> vec4<f32> */
11706-
/* fn textureLoad<C : iu32, A : iu32>(texture: texture_storage_2d_array<i32_texel_format, read_write>, coords: vec2<C>, array_index: A) -> vec4<i32> */
11707-
/* fn textureLoad<C : iu32, A : iu32>(texture: texture_storage_2d_array<u32_texel_format, read_write>, coords: vec2<C>, array_index: A) -> vec4<u32> */
11708-
/* fn textureLoad<C : iu32>(texture: texture_storage_3d<f32_texel_format, read_write>, coords: vec3<C>) -> vec4<f32> */
11709-
/* fn textureLoad<C : iu32>(texture: texture_storage_3d<i32_texel_format, read_write>, coords: vec3<C>) -> vec4<i32> */
11710-
/* fn textureLoad<C : iu32>(texture: texture_storage_3d<u32_texel_format, read_write>, coords: vec3<C>) -> vec4<u32> */
11711+
/* fn textureLoad<C : iu32>(texture: texture_storage_1d<f32_texel_format, readable>, coords: C) -> vec4<f32> */
11712+
/* fn textureLoad<C : iu32>(texture: texture_storage_1d<i32_texel_format, readable>, coords: C) -> vec4<i32> */
11713+
/* fn textureLoad<C : iu32>(texture: texture_storage_1d<u32_texel_format, readable>, coords: C) -> vec4<u32> */
11714+
/* fn textureLoad<C : iu32>(texture: texture_storage_2d<f32_texel_format, readable>, coords: vec2<C>) -> vec4<f32> */
11715+
/* fn textureLoad<C : iu32>(texture: texture_storage_2d<i32_texel_format, readable>, coords: vec2<C>) -> vec4<i32> */
11716+
/* fn textureLoad<C : iu32>(texture: texture_storage_2d<u32_texel_format, readable>, coords: vec2<C>) -> vec4<u32> */
11717+
/* fn textureLoad<C : iu32, A : iu32>(texture: texture_storage_2d_array<f32_texel_format, readable>, coords: vec2<C>, array_index: A) -> vec4<f32> */
11718+
/* fn textureLoad<C : iu32, A : iu32>(texture: texture_storage_2d_array<i32_texel_format, readable>, coords: vec2<C>, array_index: A) -> vec4<i32> */
11719+
/* fn textureLoad<C : iu32, A : iu32>(texture: texture_storage_2d_array<u32_texel_format, readable>, coords: vec2<C>, array_index: A) -> vec4<u32> */
11720+
/* fn textureLoad<C : iu32>(texture: texture_storage_3d<f32_texel_format, readable>, coords: vec3<C>) -> vec4<f32> */
11721+
/* fn textureLoad<C : iu32>(texture: texture_storage_3d<i32_texel_format, readable>, coords: vec3<C>) -> vec4<i32> */
11722+
/* fn textureLoad<C : iu32>(texture: texture_storage_3d<u32_texel_format, readable>, coords: vec3<C>) -> vec4<u32> */
1171111723
/* num overloads */ 21,
1171211724
/* overloads */ OverloadIndex(27),
1171311725
},

src/tint/lang/core/intrinsic/table_test.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,10 @@ TEST_F(IntrinsicTableTest, OverloadOrderByNumberOfParameters) {
601601
textureDimensions(texture: texture_depth_cube) -> vec2<u32>
602602
textureDimensions(texture: texture_depth_cube_array) -> vec2<u32>
603603
textureDimensions(texture: texture_depth_multisampled_2d) -> vec2<u32>
604-
textureDimensions(texture: texture_storage_1d<F, A>) -> u32 where: A is write or read_write
605-
textureDimensions(texture: texture_storage_2d<F, A>) -> vec2<u32> where: A is write or read_write
606-
textureDimensions(texture: texture_storage_2d_array<F, A>) -> vec2<u32> where: A is write or read_write
607-
textureDimensions(texture: texture_storage_3d<F, A>) -> vec3<u32> where: A is write or read_write
604+
textureDimensions(texture: texture_storage_1d<F, A>) -> u32
605+
textureDimensions(texture: texture_storage_2d<F, A>) -> vec2<u32>
606+
textureDimensions(texture: texture_storage_2d_array<F, A>) -> vec2<u32>
607+
textureDimensions(texture: texture_storage_3d<F, A>) -> vec3<u32>
608608
textureDimensions(texture: texture_external) -> vec2<u32>
609609
)");
610610
}
@@ -641,10 +641,10 @@ TEST_F(IntrinsicTableTest, OverloadOrderByMatchingParameter) {
641641
textureDimensions(texture: texture_depth_cube) -> vec2<u32>
642642
textureDimensions(texture: texture_depth_cube_array) -> vec2<u32>
643643
textureDimensions(texture: texture_depth_multisampled_2d) -> vec2<u32>
644-
textureDimensions(texture: texture_storage_1d<F, A>) -> u32 where: A is write or read_write
645-
textureDimensions(texture: texture_storage_2d<F, A>) -> vec2<u32> where: A is write or read_write
646-
textureDimensions(texture: texture_storage_2d_array<F, A>) -> vec2<u32> where: A is write or read_write
647-
textureDimensions(texture: texture_storage_3d<F, A>) -> vec3<u32> where: A is write or read_write
644+
textureDimensions(texture: texture_storage_1d<F, A>) -> u32
645+
textureDimensions(texture: texture_storage_2d<F, A>) -> vec2<u32>
646+
textureDimensions(texture: texture_storage_2d_array<F, A>) -> vec2<u32>
647+
textureDimensions(texture: texture_storage_3d<F, A>) -> vec3<u32>
648648
textureDimensions(texture: texture_external) -> vec2<u32>
649649
)");
650650
}

src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3318,7 +3318,8 @@ bool ASTPrinter::EmitHandleVariable(const ast::Var* var, const sem::Variable* se
33183318

33193319
if (unwrapped_type->Is<core::type::Texture>()) {
33203320
register_space = "t";
3321-
if (unwrapped_type->Is<core::type::StorageTexture>()) {
3321+
if (auto* st = unwrapped_type->As<core::type::StorageTexture>();
3322+
st && st->access() != core::Access::kRead) {
33223323
register_space = "u";
33233324
}
33243325
} else if (unwrapped_type->Is<core::type::Sampler>()) {

0 commit comments

Comments
 (0)