Skip to content

Commit 5146b3f

Browse files
fix(namer): normalize ":<>," characters to a snake case separator
1 parent 9070215 commit 5146b3f

21 files changed

+96
-90
lines changed

naga/src/proc/namer.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ impl Namer {
119119
Cow::Borrowed(string)
120120
} else {
121121
let mut filtered = string.chars().fold(String::new(), |mut s, c| {
122+
let c = match c {
123+
// Make several common characters in C++-ish types become snake case
124+
// separators.
125+
':' | '<' | '>' | ',' => '_',
126+
c => c,
127+
};
122128
let had_underscore_at_end = s.ends_with('_');
123129
if had_underscore_at_end && c == '_' {
124130
return s;

naga/tests/out/glsl/wgsl-atomicCompareExchange.test_atomic_compare_exchange_i32.Compute.glsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ precision highp int;
55

66
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
77

8-
struct _atomic_compare_exchange_result_u003c_Sint_u002c_4_u003e {
8+
struct _atomic_compare_exchange_result_Sint_4_ {
99
int old_value;
1010
bool exchanged;
1111
};
12-
struct _atomic_compare_exchange_result_u003c_Uint_u002c_4_u003e {
12+
struct _atomic_compare_exchange_result_Uint_4_ {
1313
uint old_value;
1414
bool exchanged;
1515
};
@@ -50,7 +50,7 @@ void main() {
5050
int new = floatBitsToInt((intBitsToFloat(_e14) + 1.0));
5151
uint _e20 = i;
5252
int _e22 = old;
53-
_atomic_compare_exchange_result_u003c_Sint_u002c_4_u003e _e23; _e23.old_value = atomicCompSwap(_group_0_binding_0_cs[_e20], _e22, new);
53+
_atomic_compare_exchange_result_Sint_4_ _e23; _e23.old_value = atomicCompSwap(_group_0_binding_0_cs[_e20], _e22, new);
5454
_e23.exchanged = (_e23.old_value == _e22);
5555
old = _e23.old_value;
5656
exchanged = _e23.exchanged;

naga/tests/out/glsl/wgsl-atomicCompareExchange.test_atomic_compare_exchange_u32.Compute.glsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ precision highp int;
55

66
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
77

8-
struct _atomic_compare_exchange_result_u003c_Sint_u002c_4_u003e {
8+
struct _atomic_compare_exchange_result_Sint_4_ {
99
int old_value;
1010
bool exchanged;
1111
};
12-
struct _atomic_compare_exchange_result_u003c_Uint_u002c_4_u003e {
12+
struct _atomic_compare_exchange_result_Uint_4_ {
1313
uint old_value;
1414
bool exchanged;
1515
};
@@ -50,7 +50,7 @@ void main() {
5050
uint new = floatBitsToUint((uintBitsToFloat(_e14) + 1.0));
5151
uint _e20 = i_1;
5252
uint _e22 = old_1;
53-
_atomic_compare_exchange_result_u003c_Uint_u002c_4_u003e _e23; _e23.old_value = atomicCompSwap(_group_0_binding_1_cs[_e20], _e22, new);
53+
_atomic_compare_exchange_result_Uint_4_ _e23; _e23.old_value = atomicCompSwap(_group_0_binding_1_cs[_e20], _e22, new);
5454
_e23.exchanged = (_e23.old_value == _e22);
5555
old_1 = _e23.old_value;
5656
exchanged_1 = _e23.exchanged;

naga/tests/out/glsl/wgsl-atomicOps.cs_main.Compute.glsl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ struct Struct {
99
uint atomic_scalar;
1010
int atomic_arr[2];
1111
};
12-
struct _atomic_compare_exchange_result_u003c_Uint_u002c_4_u003e {
12+
struct _atomic_compare_exchange_result_Uint_4_ {
1313
uint old_value;
1414
bool exchanged;
1515
};
16-
struct _atomic_compare_exchange_result_u003c_Sint_u002c_4_u003e {
16+
struct _atomic_compare_exchange_result_Sint_4_ {
1717
int old_value;
1818
bool exchanged;
1919
};
@@ -135,21 +135,21 @@ void main() {
135135
int _e295 = atomicExchange(workgroup_atomic_arr[1], 1);
136136
uint _e299 = atomicExchange(workgroup_struct.atomic_scalar, 1u);
137137
int _e304 = atomicExchange(workgroup_struct.atomic_arr[1], 1);
138-
_atomic_compare_exchange_result_u003c_Uint_u002c_4_u003e _e308; _e308.old_value = atomicCompSwap(_group_0_binding_0_cs, 1u, 2u);
138+
_atomic_compare_exchange_result_Uint_4_ _e308; _e308.old_value = atomicCompSwap(_group_0_binding_0_cs, 1u, 2u);
139139
_e308.exchanged = (_e308.old_value == 1u);
140-
_atomic_compare_exchange_result_u003c_Sint_u002c_4_u003e _e313; _e313.old_value = atomicCompSwap(_group_0_binding_1_cs[1], 1, 2);
140+
_atomic_compare_exchange_result_Sint_4_ _e313; _e313.old_value = atomicCompSwap(_group_0_binding_1_cs[1], 1, 2);
141141
_e313.exchanged = (_e313.old_value == 1);
142-
_atomic_compare_exchange_result_u003c_Uint_u002c_4_u003e _e318; _e318.old_value = atomicCompSwap(_group_0_binding_2_cs.atomic_scalar, 1u, 2u);
142+
_atomic_compare_exchange_result_Uint_4_ _e318; _e318.old_value = atomicCompSwap(_group_0_binding_2_cs.atomic_scalar, 1u, 2u);
143143
_e318.exchanged = (_e318.old_value == 1u);
144-
_atomic_compare_exchange_result_u003c_Sint_u002c_4_u003e _e324; _e324.old_value = atomicCompSwap(_group_0_binding_2_cs.atomic_arr[1], 1, 2);
144+
_atomic_compare_exchange_result_Sint_4_ _e324; _e324.old_value = atomicCompSwap(_group_0_binding_2_cs.atomic_arr[1], 1, 2);
145145
_e324.exchanged = (_e324.old_value == 1);
146-
_atomic_compare_exchange_result_u003c_Uint_u002c_4_u003e _e328; _e328.old_value = atomicCompSwap(workgroup_atomic_scalar, 1u, 2u);
146+
_atomic_compare_exchange_result_Uint_4_ _e328; _e328.old_value = atomicCompSwap(workgroup_atomic_scalar, 1u, 2u);
147147
_e328.exchanged = (_e328.old_value == 1u);
148-
_atomic_compare_exchange_result_u003c_Sint_u002c_4_u003e _e333; _e333.old_value = atomicCompSwap(workgroup_atomic_arr[1], 1, 2);
148+
_atomic_compare_exchange_result_Sint_4_ _e333; _e333.old_value = atomicCompSwap(workgroup_atomic_arr[1], 1, 2);
149149
_e333.exchanged = (_e333.old_value == 1);
150-
_atomic_compare_exchange_result_u003c_Uint_u002c_4_u003e _e338; _e338.old_value = atomicCompSwap(workgroup_struct.atomic_scalar, 1u, 2u);
150+
_atomic_compare_exchange_result_Uint_4_ _e338; _e338.old_value = atomicCompSwap(workgroup_struct.atomic_scalar, 1u, 2u);
151151
_e338.exchanged = (_e338.old_value == 1u);
152-
_atomic_compare_exchange_result_u003c_Sint_u002c_4_u003e _e344; _e344.old_value = atomicCompSwap(workgroup_struct.atomic_arr[1], 1, 2);
152+
_atomic_compare_exchange_result_Sint_4_ _e344; _e344.old_value = atomicCompSwap(workgroup_struct.atomic_arr[1], 1, 2);
153153
_e344.exchanged = (_e344.old_value == 1);
154154
return;
155155
}

naga/tests/out/hlsl/spv-fetch_depth.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void function()
1919
}
2020

2121
[numthreads(32, 1, 1)]
22-
void cull_u003a_u003a_fetch_depth()
22+
void cull_fetch_depth()
2323
{
2424
function();
2525
}

naga/tests/out/hlsl/spv-fetch_depth.ron

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
],
66
compute:[
77
(
8-
entry_point:"cull_u003a_u003a_fetch_depth",
8+
entry_point:"cull_fetch_depth",
99
target_profile:"cs_5_1",
1010
),
1111
],

naga/tests/out/hlsl/wgsl-atomicCompareExchange-int64.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ struct NagaConstants {
55
};
66
ConstantBuffer<NagaConstants> _NagaConstants: register(b0, space1);
77

8-
struct _atomic_compare_exchange_result_u003c_Sint_u002c_8_u003e {
8+
struct _atomic_compare_exchange_result_Sint_8_ {
99
int64_t old_value;
1010
bool exchanged;
1111
int _end_pad_0;
1212
};
1313

14-
struct _atomic_compare_exchange_result_u003c_Uint_u002c_8_u003e {
14+
struct _atomic_compare_exchange_result_Uint_8_ {
1515
uint64_t old_value;
1616
bool exchanged;
1717
int _end_pad_0;
@@ -63,7 +63,7 @@ void test_atomic_compare_exchange_i64_()
6363
int64_t new_ = (_e14 + 10L);
6464
uint _e19 = i;
6565
int64_t _e21 = old;
66-
_atomic_compare_exchange_result_u003c_Sint_u002c_8_u003e _e22; arr_i64_.InterlockedCompareExchange64(_e19*8, _e21, new_, _e22.old_value);
66+
_atomic_compare_exchange_result_Sint_8_ _e22; arr_i64_.InterlockedCompareExchange64(_e19*8, _e21, new_, _e22.old_value);
6767
_e22.exchanged = (_e22.old_value == _e21);
6868
old = _e22.old_value;
6969
exchanged = _e22.exchanged;
@@ -115,7 +115,7 @@ void test_atomic_compare_exchange_u64_()
115115
uint64_t new_1 = (_e14 + 10uL);
116116
uint _e19 = i_1;
117117
uint64_t _e21 = old_1;
118-
_atomic_compare_exchange_result_u003c_Uint_u002c_8_u003e _e22; arr_u64_.InterlockedCompareExchange64(_e19*8, _e21, new_1, _e22.old_value);
118+
_atomic_compare_exchange_result_Uint_8_ _e22; arr_u64_.InterlockedCompareExchange64(_e19*8, _e21, new_1, _e22.old_value);
119119
_e22.exchanged = (_e22.old_value == _e21);
120120
old_1 = _e22.old_value;
121121
exchanged_1 = _e22.exchanged;

naga/tests/out/hlsl/wgsl-atomicCompareExchange.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
struct _atomic_compare_exchange_result_u003c_Sint_u002c_4_u003e {
1+
struct _atomic_compare_exchange_result_Sint_4_ {
22
int old_value;
33
bool exchanged;
44
};
55

6-
struct _atomic_compare_exchange_result_u003c_Uint_u002c_4_u003e {
6+
struct _atomic_compare_exchange_result_Uint_4_ {
77
uint old_value;
88
bool exchanged;
99
};
@@ -54,7 +54,7 @@ void test_atomic_compare_exchange_i32_()
5454
int new_ = asint((asfloat(_e14) + 1.0));
5555
uint _e20 = i;
5656
int _e22 = old;
57-
_atomic_compare_exchange_result_u003c_Sint_u002c_4_u003e _e23; arr_i32_.InterlockedCompareExchange(_e20*4, _e22, new_, _e23.old_value);
57+
_atomic_compare_exchange_result_Sint_4_ _e23; arr_i32_.InterlockedCompareExchange(_e20*4, _e22, new_, _e23.old_value);
5858
_e23.exchanged = (_e23.old_value == _e22);
5959
old = _e23.old_value;
6060
exchanged = _e23.exchanged;
@@ -106,7 +106,7 @@ void test_atomic_compare_exchange_u32_()
106106
uint new_1 = asuint((asfloat(_e14) + 1.0));
107107
uint _e20 = i_1;
108108
uint _e22 = old_1;
109-
_atomic_compare_exchange_result_u003c_Uint_u002c_4_u003e _e23; arr_u32_.InterlockedCompareExchange(_e20*4, _e22, new_1, _e23.old_value);
109+
_atomic_compare_exchange_result_Uint_4_ _e23; arr_u32_.InterlockedCompareExchange(_e20*4, _e22, new_1, _e23.old_value);
110110
_e23.exchanged = (_e23.old_value == _e22);
111111
old_1 = _e23.old_value;
112112
exchanged_1 = _e23.exchanged;

naga/tests/out/hlsl/wgsl-atomicOps-int64.hlsl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ struct Struct {
1010
int64_t atomic_arr[2];
1111
};
1212

13-
struct _atomic_compare_exchange_result_u003c_Uint_u002c_8_u003e {
13+
struct _atomic_compare_exchange_result_Uint_8_ {
1414
uint64_t old_value;
1515
bool exchanged;
1616
int _end_pad_0;
1717
};
1818

19-
struct _atomic_compare_exchange_result_u003c_Sint_u002c_8_u003e {
19+
struct _atomic_compare_exchange_result_Sint_8_ {
2020
int64_t old_value;
2121
bool exchanged;
2222
int _end_pad_0;
@@ -126,21 +126,21 @@ void cs_main(uint3 id : SV_GroupThreadID, uint3 __local_invocation_id : SV_Group
126126
int64_t _e279; InterlockedExchange(workgroup_atomic_arr[1], 1L, _e279);
127127
uint64_t _e283; InterlockedExchange(workgroup_struct.atomic_scalar, 1uL, _e283);
128128
int64_t _e288; InterlockedExchange(workgroup_struct.atomic_arr[1], 1L, _e288);
129-
_atomic_compare_exchange_result_u003c_Uint_u002c_8_u003e _e292; storage_atomic_scalar.InterlockedCompareExchange64(0, 1uL, 2uL, _e292.old_value);
129+
_atomic_compare_exchange_result_Uint_8_ _e292; storage_atomic_scalar.InterlockedCompareExchange64(0, 1uL, 2uL, _e292.old_value);
130130
_e292.exchanged = (_e292.old_value == 1uL);
131-
_atomic_compare_exchange_result_u003c_Sint_u002c_8_u003e _e297; storage_atomic_arr.InterlockedCompareExchange64(8, 1L, 2L, _e297.old_value);
131+
_atomic_compare_exchange_result_Sint_8_ _e297; storage_atomic_arr.InterlockedCompareExchange64(8, 1L, 2L, _e297.old_value);
132132
_e297.exchanged = (_e297.old_value == 1L);
133-
_atomic_compare_exchange_result_u003c_Uint_u002c_8_u003e _e302; storage_struct.InterlockedCompareExchange64(0, 1uL, 2uL, _e302.old_value);
133+
_atomic_compare_exchange_result_Uint_8_ _e302; storage_struct.InterlockedCompareExchange64(0, 1uL, 2uL, _e302.old_value);
134134
_e302.exchanged = (_e302.old_value == 1uL);
135-
_atomic_compare_exchange_result_u003c_Sint_u002c_8_u003e _e308; storage_struct.InterlockedCompareExchange64(8+8, 1L, 2L, _e308.old_value);
135+
_atomic_compare_exchange_result_Sint_8_ _e308; storage_struct.InterlockedCompareExchange64(8+8, 1L, 2L, _e308.old_value);
136136
_e308.exchanged = (_e308.old_value == 1L);
137-
_atomic_compare_exchange_result_u003c_Uint_u002c_8_u003e _e312; InterlockedCompareExchange(workgroup_atomic_scalar, 1uL, 2uL, _e312.old_value);
137+
_atomic_compare_exchange_result_Uint_8_ _e312; InterlockedCompareExchange(workgroup_atomic_scalar, 1uL, 2uL, _e312.old_value);
138138
_e312.exchanged = (_e312.old_value == 1uL);
139-
_atomic_compare_exchange_result_u003c_Sint_u002c_8_u003e _e317; InterlockedCompareExchange(workgroup_atomic_arr[1], 1L, 2L, _e317.old_value);
139+
_atomic_compare_exchange_result_Sint_8_ _e317; InterlockedCompareExchange(workgroup_atomic_arr[1], 1L, 2L, _e317.old_value);
140140
_e317.exchanged = (_e317.old_value == 1L);
141-
_atomic_compare_exchange_result_u003c_Uint_u002c_8_u003e _e322; InterlockedCompareExchange(workgroup_struct.atomic_scalar, 1uL, 2uL, _e322.old_value);
141+
_atomic_compare_exchange_result_Uint_8_ _e322; InterlockedCompareExchange(workgroup_struct.atomic_scalar, 1uL, 2uL, _e322.old_value);
142142
_e322.exchanged = (_e322.old_value == 1uL);
143-
_atomic_compare_exchange_result_u003c_Sint_u002c_8_u003e _e328; InterlockedCompareExchange(workgroup_struct.atomic_arr[1], 1L, 2L, _e328.old_value);
143+
_atomic_compare_exchange_result_Sint_8_ _e328; InterlockedCompareExchange(workgroup_struct.atomic_arr[1], 1L, 2L, _e328.old_value);
144144
_e328.exchanged = (_e328.old_value == 1L);
145145
return;
146146
}

naga/tests/out/hlsl/wgsl-atomicOps.hlsl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ struct Struct {
33
int atomic_arr[2];
44
};
55

6-
struct _atomic_compare_exchange_result_u003c_Uint_u002c_4_u003e {
6+
struct _atomic_compare_exchange_result_Uint_4_ {
77
uint old_value;
88
bool exchanged;
99
};
1010

11-
struct _atomic_compare_exchange_result_u003c_Sint_u002c_4_u003e {
11+
struct _atomic_compare_exchange_result_Sint_4_ {
1212
int old_value;
1313
bool exchanged;
1414
};
@@ -117,21 +117,21 @@ void cs_main(uint3 id : SV_GroupThreadID, uint3 __local_invocation_id : SV_Group
117117
int _e295; InterlockedExchange(workgroup_atomic_arr[1], int(1), _e295);
118118
uint _e299; InterlockedExchange(workgroup_struct.atomic_scalar, 1u, _e299);
119119
int _e304; InterlockedExchange(workgroup_struct.atomic_arr[1], int(1), _e304);
120-
_atomic_compare_exchange_result_u003c_Uint_u002c_4_u003e _e308; storage_atomic_scalar.InterlockedCompareExchange(0, 1u, 2u, _e308.old_value);
120+
_atomic_compare_exchange_result_Uint_4_ _e308; storage_atomic_scalar.InterlockedCompareExchange(0, 1u, 2u, _e308.old_value);
121121
_e308.exchanged = (_e308.old_value == 1u);
122-
_atomic_compare_exchange_result_u003c_Sint_u002c_4_u003e _e313; storage_atomic_arr.InterlockedCompareExchange(4, int(1), int(2), _e313.old_value);
122+
_atomic_compare_exchange_result_Sint_4_ _e313; storage_atomic_arr.InterlockedCompareExchange(4, int(1), int(2), _e313.old_value);
123123
_e313.exchanged = (_e313.old_value == int(1));
124-
_atomic_compare_exchange_result_u003c_Uint_u002c_4_u003e _e318; storage_struct.InterlockedCompareExchange(0, 1u, 2u, _e318.old_value);
124+
_atomic_compare_exchange_result_Uint_4_ _e318; storage_struct.InterlockedCompareExchange(0, 1u, 2u, _e318.old_value);
125125
_e318.exchanged = (_e318.old_value == 1u);
126-
_atomic_compare_exchange_result_u003c_Sint_u002c_4_u003e _e324; storage_struct.InterlockedCompareExchange(4+4, int(1), int(2), _e324.old_value);
126+
_atomic_compare_exchange_result_Sint_4_ _e324; storage_struct.InterlockedCompareExchange(4+4, int(1), int(2), _e324.old_value);
127127
_e324.exchanged = (_e324.old_value == int(1));
128-
_atomic_compare_exchange_result_u003c_Uint_u002c_4_u003e _e328; InterlockedCompareExchange(workgroup_atomic_scalar, 1u, 2u, _e328.old_value);
128+
_atomic_compare_exchange_result_Uint_4_ _e328; InterlockedCompareExchange(workgroup_atomic_scalar, 1u, 2u, _e328.old_value);
129129
_e328.exchanged = (_e328.old_value == 1u);
130-
_atomic_compare_exchange_result_u003c_Sint_u002c_4_u003e _e333; InterlockedCompareExchange(workgroup_atomic_arr[1], int(1), int(2), _e333.old_value);
130+
_atomic_compare_exchange_result_Sint_4_ _e333; InterlockedCompareExchange(workgroup_atomic_arr[1], int(1), int(2), _e333.old_value);
131131
_e333.exchanged = (_e333.old_value == int(1));
132-
_atomic_compare_exchange_result_u003c_Uint_u002c_4_u003e _e338; InterlockedCompareExchange(workgroup_struct.atomic_scalar, 1u, 2u, _e338.old_value);
132+
_atomic_compare_exchange_result_Uint_4_ _e338; InterlockedCompareExchange(workgroup_struct.atomic_scalar, 1u, 2u, _e338.old_value);
133133
_e338.exchanged = (_e338.old_value == 1u);
134-
_atomic_compare_exchange_result_u003c_Sint_u002c_4_u003e _e344; InterlockedCompareExchange(workgroup_struct.atomic_arr[1], int(1), int(2), _e344.old_value);
134+
_atomic_compare_exchange_result_Sint_4_ _e344; InterlockedCompareExchange(workgroup_struct.atomic_arr[1], int(1), int(2), _e344.old_value);
135135
_e344.exchanged = (_e344.old_value == int(1));
136136
return;
137137
}

0 commit comments

Comments
 (0)