Skip to content

Commit c467a30

Browse files
jimblandyteoxoy
authored andcommitted
[naga] Delete Constant::override and Override.
1 parent 7c0df7c commit c467a30

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 {
@@ -752,9 +746,6 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
752746
spirv::Decoration::RowMajor => {
753747
dec.matrix_major = Some(Majority::Row);
754748
}
755-
spirv::Decoration::SpecId => {
756-
dec.specialization = Some(self.next()?);
757-
}
758749
other => {
759750
log::warn!("Unknown decoration {:?}", other);
760751
for _ in base_words + 1..inst.wc {
@@ -4918,7 +4909,6 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
49184909
LookupConstant {
49194910
handle: module.constants.append(
49204911
crate::Constant {
4921-
r#override: decor.specialization(),
49224912
name: decor.name,
49234913
ty,
49244914
init,
@@ -4969,7 +4959,6 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
49694959
LookupConstant {
49704960
handle: module.constants.append(
49714961
crate::Constant {
4972-
r#override: decor.specialization(),
49734962
name: decor.name,
49744963
ty,
49754964
init,
@@ -5004,7 +4993,6 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
50044993
.append(crate::Expression::ZeroValue(ty), span);
50054994
let handle = module.constants.append(
50064995
crate::Constant {
5007-
r#override: decor.specialization(),
50084996
name: decor.name,
50094997
ty,
50104998
init,
@@ -5043,7 +5031,6 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
50435031
LookupConstant {
50445032
handle: module.constants.append(
50455033
crate::Constant {
5046-
r#override: decor.specialization(),
50475034
name: decor.name,
50485035
ty,
50495036
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
*/
@@ -890,17 +888,6 @@ pub enum Literal {
890888
AbstractFloat(f64),
891889
}
892890

893-
#[derive(Debug, PartialEq)]
894-
#[cfg_attr(feature = "clone", derive(Clone))]
895-
#[cfg_attr(feature = "serialize", derive(Serialize))]
896-
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
897-
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
898-
pub enum Override {
899-
None,
900-
ByName,
901-
ByNameOrId(u32),
902-
}
903-
904891
/// Constant value.
905892
#[derive(Debug, PartialEq)]
906893
#[cfg_attr(feature = "clone", derive(Clone))]
@@ -909,20 +896,17 @@ pub enum Override {
909896
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
910897
pub struct Constant {
911898
pub name: Option<String>,
912-
pub r#override: Override,
913899
pub ty: Handle<Type>,
914900

915901
/// The value of the constant.
916902
///
917903
/// This [`Handle`] refers to [`Module::const_expressions`], not
918904
/// any [`Function::expressions`] arena.
919905
///
920-
/// If [`override`] is [`None`], then this must be a Naga
906+
/// If `override` is `None`, then this must be a Naga
921907
/// [constant expression]. Otherwise, this may be a Naga
922908
/// [override expression] or [constant expression].
923909
///
924-
/// [`override`]: Constant::override
925-
/// [`None`]: Override::None
926910
/// [constant expression]: index.html#constant-expressions
927911
/// [override expression]: index.html#override-expressions
928912
pub init: Handle<Expression>,

naga/src/proc/constant_evaluator.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,7 +1916,6 @@ mod tests {
19161916
let h = constants.append(
19171917
Constant {
19181918
name: None,
1919-
r#override: crate::Override::None,
19201919
ty: scalar_ty,
19211920
init: const_expressions
19221921
.append(Expression::Literal(Literal::I32(4)), Default::default()),
@@ -1927,7 +1926,6 @@ mod tests {
19271926
let h1 = constants.append(
19281927
Constant {
19291928
name: None,
1930-
r#override: crate::Override::None,
19311929
ty: scalar_ty,
19321930
init: const_expressions
19331931
.append(Expression::Literal(Literal::I32(8)), Default::default()),
@@ -1938,7 +1936,6 @@ mod tests {
19381936
let vec_h = constants.append(
19391937
Constant {
19401938
name: None,
1941-
r#override: crate::Override::None,
19421939
ty: vec_ty,
19431940
init: const_expressions.append(
19441941
Expression::Compose {
@@ -2037,7 +2034,6 @@ mod tests {
20372034
let h = constants.append(
20382035
Constant {
20392036
name: None,
2040-
r#override: crate::Override::None,
20412037
ty: scalar_ty,
20422038
init: const_expressions
20432039
.append(Expression::Literal(Literal::I32(4)), Default::default()),
@@ -2124,7 +2120,6 @@ mod tests {
21242120
let vec1 = constants.append(
21252121
Constant {
21262122
name: None,
2127-
r#override: crate::Override::None,
21282123
ty: vec_ty,
21292124
init: const_expressions.append(
21302125
Expression::Compose {
@@ -2140,7 +2135,6 @@ mod tests {
21402135
let vec2 = constants.append(
21412136
Constant {
21422137
name: None,
2143-
r#override: crate::Override::None,
21442138
ty: vec_ty,
21452139
init: const_expressions.append(
21462140
Expression::Compose {
@@ -2156,7 +2150,6 @@ mod tests {
21562150
let h = constants.append(
21572151
Constant {
21582152
name: None,
2159-
r#override: crate::Override::None,
21602153
ty: matrix_ty,
21612154
init: const_expressions.append(
21622155
Expression::Compose {
@@ -2252,7 +2245,6 @@ mod tests {
22522245
let h = constants.append(
22532246
Constant {
22542247
name: None,
2255-
r#override: crate::Override::None,
22562248
ty: i32_ty,
22572249
init: const_expressions
22582250
.append(Expression::Literal(Literal::I32(4)), Default::default()),
@@ -2332,7 +2324,6 @@ mod tests {
23322324
let h = constants.append(
23332325
Constant {
23342326
name: None,
2335-
r#override: crate::Override::None,
23362327
ty: i32_ty,
23372328
init: const_expressions
23382329
.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
@@ -538,13 +538,9 @@ impl crate::Expression {
538538
///
539539
/// [`Access`]: crate::Expression::Access
540540
/// [`ResolveContext`]: crate::proc::ResolveContext
541-
pub fn is_dynamic_index(&self, module: &crate::Module) -> bool {
541+
pub const fn is_dynamic_index(&self) -> bool {
542542
match *self {
543-
Self::Literal(_) | Self::ZeroValue(_) => false,
544-
Self::Constant(handle) => {
545-
let constant = &module.constants[handle];
546-
!matches!(constant.r#override, crate::Override::None)
547-
}
543+
Self::Literal(_) | Self::ZeroValue(_) | Self::Constant(_) => false,
548544
_ => true,
549545
}
550546
}

naga/src/valid/expression.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,7 @@ impl super::Validator {
250250
return Err(ExpressionError::InvalidIndexType(index));
251251
}
252252
}
253-
if dynamic_indexing_restricted
254-
&& function.expressions[index].is_dynamic_index(module)
255-
{
253+
if dynamic_indexing_restricted && function.expressions[index].is_dynamic_index() {
256254
return Err(ExpressionError::IndexMustBeConstant(base));
257255
}
258256

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)