Skip to content

Commit 4d060f8

Browse files
jimblandyteoxoy
authored andcommitted
[naga] Delete Constant::override and Override.
1 parent c2f530f commit 4d060f8

File tree

11 files changed

+7
-115
lines changed

11 files changed

+7
-115
lines changed

naga/src/front/glsl/parser_tests.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,6 @@ fn constants() {
557557
constants.next().unwrap().1,
558558
&Constant {
559559
name: Some("a".to_owned()),
560-
r#override: crate::Override::None,
561560
ty: ty_handle,
562561
init: init_handle
563562
}
@@ -567,7 +566,6 @@ fn constants() {
567566
constants.next().unwrap().1,
568567
&Constant {
569568
name: Some("b".to_owned()),
570-
r#override: crate::Override::None,
571569
ty: ty_handle,
572570
init: init_handle
573571
}

naga/src/front/glsl/variables.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,6 @@ impl Frontend {
472472

473473
let constant = Constant {
474474
name: name.clone(),
475-
r#override: crate::Override::None,
476475
ty,
477476
init,
478477
};

naga/src/front/spv/mod.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ struct Decoration {
196196
location: Option<spirv::Word>,
197197
desc_set: Option<spirv::Word>,
198198
desc_index: Option<spirv::Word>,
199-
specialization: Option<spirv::Word>,
200199
storage_buffer: bool,
201200
offset: Option<spirv::Word>,
202201
array_stride: Option<NonZeroU32>,
@@ -216,11 +215,6 @@ impl Decoration {
216215
}
217216
}
218217

219-
fn specialization(&self) -> crate::Override {
220-
self.specialization
221-
.map_or(crate::Override::None, crate::Override::ByNameOrId)
222-
}
223-
224218
const fn resource_binding(&self) -> Option<crate::ResourceBinding> {
225219
match *self {
226220
Decoration {
@@ -756,9 +750,6 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
756750
spirv::Decoration::RowMajor => {
757751
dec.matrix_major = Some(Majority::Row);
758752
}
759-
spirv::Decoration::SpecId => {
760-
dec.specialization = Some(self.next()?);
761-
}
762753
other => {
763754
log::warn!("Unknown decoration {:?}", other);
764755
for _ in base_words + 1..inst.wc {
@@ -4931,7 +4922,6 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
49314922
LookupConstant {
49324923
handle: module.constants.append(
49334924
crate::Constant {
4934-
r#override: decor.specialization(),
49354925
name: decor.name,
49364926
ty,
49374927
init,
@@ -4982,7 +4972,6 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
49824972
LookupConstant {
49834973
handle: module.constants.append(
49844974
crate::Constant {
4985-
r#override: decor.specialization(),
49864975
name: decor.name,
49874976
ty,
49884977
init,
@@ -5017,7 +5006,6 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
50175006
.append(crate::Expression::ZeroValue(ty), span);
50185007
let handle = module.constants.append(
50195008
crate::Constant {
5020-
r#override: decor.specialization(),
50215009
name: decor.name,
50225010
ty,
50235011
init,
@@ -5056,7 +5044,6 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
50565044
LookupConstant {
50575045
handle: module.constants.append(
50585046
crate::Constant {
5059-
r#override: decor.specialization(),
50605047
name: decor.name,
50615048
ty,
50625049
init,

naga/src/front/wgsl/lower/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,6 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
956956
let handle = ctx.module.constants.append(
957957
crate::Constant {
958958
name: Some(c.name.name.to_string()),
959-
r#override: crate::Override::None,
960959
ty,
961960
init,
962961
},

naga/src/lib.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ tree.
175175
A Naga *constant expression* is one of the following [`Expression`]
176176
variants, whose operands (if any) are also constant expressions:
177177
- [`Literal`]
178-
- [`Constant`], for [`Constant`s][const_type] whose [`override`] is [`None`]
178+
- [`Constant`], for [`Constant`s][const_type] whose `override` is `None`
179179
- [`ZeroValue`], for fixed-size types
180180
- [`Compose`]
181181
- [`Access`]
@@ -195,7 +195,7 @@ A constant expression can be evaluated at module translation time.
195195
196196
A Naga *override expression* is the same as a [constant expression],
197197
except that it is also allowed to refer to [`Constant`s][const_type]
198-
whose [`override`] is something other than [`None`].
198+
whose `override` is something other than `None`.
199199
200200
An override expression can be evaluated at pipeline creation time.
201201
@@ -239,8 +239,6 @@ An override expression can be evaluated at pipeline creation time.
239239
[`As`]: Expression::As
240240
241241
[const_type]: Constant
242-
[`override`]: Constant::override
243-
[`None`]: Override::None
244242
245243
[constant expression]: index.html#constant-expressions
246244
*/
@@ -892,17 +890,6 @@ pub enum Literal {
892890
AbstractFloat(f64),
893891
}
894892

895-
#[derive(Debug, PartialEq)]
896-
#[cfg_attr(feature = "clone", derive(Clone))]
897-
#[cfg_attr(feature = "serialize", derive(Serialize))]
898-
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
899-
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
900-
pub enum Override {
901-
None,
902-
ByName,
903-
ByNameOrId(u32),
904-
}
905-
906893
/// Constant value.
907894
#[derive(Debug, PartialEq)]
908895
#[cfg_attr(feature = "clone", derive(Clone))]
@@ -911,20 +898,17 @@ pub enum Override {
911898
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
912899
pub struct Constant {
913900
pub name: Option<String>,
914-
pub r#override: Override,
915901
pub ty: Handle<Type>,
916902

917903
/// The value of the constant.
918904
///
919905
/// This [`Handle`] refers to [`Module::const_expressions`], not
920906
/// any [`Function::expressions`] arena.
921907
///
922-
/// If [`override`] is [`None`], then this must be a Naga
908+
/// If `override` is `None`, then this must be a Naga
923909
/// [constant expression]. Otherwise, this may be a Naga
924910
/// [override expression] or [constant expression].
925911
///
926-
/// [`override`]: Constant::override
927-
/// [`None`]: Override::None
928912
/// [constant expression]: index.html#constant-expressions
929913
/// [override expression]: index.html#override-expressions
930914
pub init: Handle<Expression>,

naga/src/proc/constant_evaluator.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,6 @@ mod tests {
20592059
let h = constants.append(
20602060
Constant {
20612061
name: None,
2062-
r#override: crate::Override::None,
20632062
ty: scalar_ty,
20642063
init: const_expressions
20652064
.append(Expression::Literal(Literal::I32(4)), Default::default()),
@@ -2070,7 +2069,6 @@ mod tests {
20702069
let h1 = constants.append(
20712070
Constant {
20722071
name: None,
2073-
r#override: crate::Override::None,
20742072
ty: scalar_ty,
20752073
init: const_expressions
20762074
.append(Expression::Literal(Literal::I32(8)), Default::default()),
@@ -2081,7 +2079,6 @@ mod tests {
20812079
let vec_h = constants.append(
20822080
Constant {
20832081
name: None,
2084-
r#override: crate::Override::None,
20852082
ty: vec_ty,
20862083
init: const_expressions.append(
20872084
Expression::Compose {
@@ -2180,7 +2177,6 @@ mod tests {
21802177
let h = constants.append(
21812178
Constant {
21822179
name: None,
2183-
r#override: crate::Override::None,
21842180
ty: scalar_ty,
21852181
init: const_expressions
21862182
.append(Expression::Literal(Literal::I32(4)), Default::default()),
@@ -2267,7 +2263,6 @@ mod tests {
22672263
let vec1 = constants.append(
22682264
Constant {
22692265
name: None,
2270-
r#override: crate::Override::None,
22712266
ty: vec_ty,
22722267
init: const_expressions.append(
22732268
Expression::Compose {
@@ -2283,7 +2278,6 @@ mod tests {
22832278
let vec2 = constants.append(
22842279
Constant {
22852280
name: None,
2286-
r#override: crate::Override::None,
22872281
ty: vec_ty,
22882282
init: const_expressions.append(
22892283
Expression::Compose {
@@ -2299,7 +2293,6 @@ mod tests {
22992293
let h = constants.append(
23002294
Constant {
23012295
name: None,
2302-
r#override: crate::Override::None,
23032296
ty: matrix_ty,
23042297
init: const_expressions.append(
23052298
Expression::Compose {
@@ -2395,7 +2388,6 @@ mod tests {
23952388
let h = constants.append(
23962389
Constant {
23972390
name: None,
2398-
r#override: crate::Override::None,
23992391
ty: i32_ty,
24002392
init: const_expressions
24012393
.append(Expression::Literal(Literal::I32(4)), Default::default()),
@@ -2475,7 +2467,6 @@ mod tests {
24752467
let h = constants.append(
24762468
Constant {
24772469
name: None,
2478-
r#override: crate::Override::None,
24792470
ty: i32_ty,
24802471
init: const_expressions
24812472
.append(Expression::Literal(Literal::I32(4)), Default::default()),

naga/src/proc/mod.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -553,13 +553,9 @@ impl crate::Expression {
553553
///
554554
/// [`Access`]: crate::Expression::Access
555555
/// [`ResolveContext`]: crate::proc::ResolveContext
556-
pub fn is_dynamic_index(&self, module: &crate::Module) -> bool {
556+
pub const fn is_dynamic_index(&self) -> bool {
557557
match *self {
558-
Self::Literal(_) | Self::ZeroValue(_) => false,
559-
Self::Constant(handle) => {
560-
let constant = &module.constants[handle];
561-
!matches!(constant.r#override, crate::Override::None)
562-
}
558+
Self::Literal(_) | Self::ZeroValue(_) | Self::Constant(_) => false,
563559
_ => true,
564560
}
565561
}

naga/src/valid/expression.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,7 @@ impl super::Validator {
252252
return Err(ExpressionError::InvalidIndexType(index));
253253
}
254254
}
255-
if dynamic_indexing_restricted
256-
&& function.expressions[index].is_dynamic_index(module)
257-
{
255+
if dynamic_indexing_restricted && function.expressions[index].is_dynamic_index() {
258256
return Err(ExpressionError::IndexMustBeConstant(base));
259257
}
260258

naga/src/valid/handles.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,7 @@ impl super::Validator {
7676
|handle| Self::validate_expression_handle(handle, const_expressions);
7777

7878
for (_handle, constant) in constants.iter() {
79-
let &crate::Constant {
80-
name: _,
81-
r#override: _,
82-
ty,
83-
init,
84-
} = constant;
79+
let &crate::Constant { name: _, ty, init } = constant;
8580
validate_type(ty)?;
8681
validate_const_expr(init)?;
8782
}
@@ -679,7 +674,6 @@ fn constant_deps() {
679674
let self_referential_const = constants.append(
680675
Constant {
681676
name: None,
682-
r#override: crate::Override::None,
683677
ty: i32_handle,
684678
init: fun_expr,
685679
},

naga/tests/out/ir/shadow.compact.ron

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -159,115 +159,96 @@
159159
constants: [
160160
(
161161
name: None,
162-
override: None,
163162
ty: 1,
164163
init: 1,
165164
),
166165
(
167166
name: None,
168-
override: None,
169167
ty: 1,
170168
init: 2,
171169
),
172170
(
173171
name: None,
174-
override: None,
175172
ty: 1,
176173
init: 3,
177174
),
178175
(
179176
name: None,
180-
override: None,
181177
ty: 1,
182178
init: 4,
183179
),
184180
(
185181
name: None,
186-
override: None,
187182
ty: 1,
188183
init: 5,
189184
),
190185
(
191186
name: None,
192-
override: None,
193187
ty: 2,
194188
init: 9,
195189
),
196190
(
197191
name: None,
198-
override: None,
199192
ty: 3,
200193
init: 10,
201194
),
202195
(
203196
name: None,
204-
override: None,
205197
ty: 3,
206198
init: 11,
207199
),
208200
(
209201
name: None,
210-
override: None,
211202
ty: 3,
212203
init: 12,
213204
),
214205
(
215206
name: None,
216-
override: None,
217207
ty: 7,
218208
init: 13,
219209
),
220210
(
221211
name: None,
222-
override: None,
223212
ty: 7,
224213
init: 14,
225214
),
226215
(
227216
name: None,
228-
override: None,
229217
ty: 7,
230218
init: 15,
231219
),
232220
(
233221
name: None,
234-
override: None,
235222
ty: 7,
236223
init: 16,
237224
),
238225
(
239226
name: None,
240-
override: None,
241227
ty: 7,
242228
init: 17,
243229
),
244230
(
245231
name: None,
246-
override: None,
247232
ty: 7,
248233
init: 18,
249234
),
250235
(
251236
name: None,
252-
override: None,
253237
ty: 7,
254238
init: 19,
255239
),
256240
(
257241
name: None,
258-
override: None,
259242
ty: 7,
260243
init: 20,
261244
),
262245
(
263246
name: None,
264-
override: None,
265247
ty: 7,
266248
init: 21,
267249
),
268250
(
269251
name: None,
270-
override: None,
271252
ty: 7,
272253
init: 22,
273254
),

0 commit comments

Comments
 (0)