mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-29 02:03:35 +00:00
[wgsl-in] Use deterministic ordering for dependency ordering.
Use `FastIndexSet`, rather than `FastHashSet`, for tracking global declarations' dependencies, so that the order in which functions are inserted into the `Module` is not dependent on the hash function.
This commit is contained in:
parent
1b1ea37f15
commit
57bebbcd20
@ -1,5 +1,5 @@
|
||||
use crate::front::wgsl::parse::number::Number;
|
||||
use crate::{Arena, FastHashSet, Handle, Span};
|
||||
use crate::{Arena, FastIndexSet, Handle, Span};
|
||||
use std::hash::Hash;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
@ -73,7 +73,7 @@ pub struct GlobalDecl<'a> {
|
||||
|
||||
/// Names of all module-scope or predeclared objects this
|
||||
/// declaration uses.
|
||||
pub dependencies: FastHashSet<Dependency<'a>>,
|
||||
pub dependencies: FastIndexSet<Dependency<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -2,7 +2,7 @@ use crate::front::wgsl::error::{Error, ExpectedToken};
|
||||
use crate::front::wgsl::parse::lexer::{Lexer, Token};
|
||||
use crate::front::wgsl::parse::number::Number;
|
||||
use crate::front::SymbolTable;
|
||||
use crate::{Arena, FastHashSet, Handle, ShaderStage, Span};
|
||||
use crate::{Arena, FastIndexSet, Handle, ShaderStage, Span};
|
||||
|
||||
pub mod ast;
|
||||
pub mod conv;
|
||||
@ -51,7 +51,7 @@ struct ExpressionContext<'input, 'temp, 'out> {
|
||||
///
|
||||
/// [`GlobalDecl`]: ast::GlobalDecl
|
||||
/// [`dependencies`]: ast::GlobalDecl::dependencies
|
||||
unresolved: &'out mut FastHashSet<ast::Dependency<'input>>,
|
||||
unresolved: &'out mut FastIndexSet<ast::Dependency<'input>>,
|
||||
}
|
||||
|
||||
impl<'a> ExpressionContext<'a, '_, '_> {
|
||||
@ -2076,7 +2076,7 @@ impl Parser {
|
||||
&mut self,
|
||||
lexer: &mut Lexer<'a>,
|
||||
out: &mut ast::TranslationUnit<'a>,
|
||||
dependencies: &mut FastHashSet<ast::Dependency<'a>>,
|
||||
dependencies: &mut FastIndexSet<ast::Dependency<'a>>,
|
||||
) -> Result<ast::Function<'a>, Error<'a>> {
|
||||
self.push_rule_span(Rule::FunctionDecl, lexer);
|
||||
// read function name
|
||||
@ -2238,7 +2238,7 @@ impl Parser {
|
||||
(None, None) => {}
|
||||
}
|
||||
|
||||
let mut dependencies = FastHashSet::default();
|
||||
let mut dependencies = FastIndexSet::default();
|
||||
let mut ctx = ExpressionContext {
|
||||
expressions: &mut out.expressions,
|
||||
local_table: &mut SymbolTable::default(),
|
||||
|
@ -9,14 +9,14 @@ var Texture: texture_2d<f32>;
|
||||
@group(0) @binding(1)
|
||||
var Sampler: sampler;
|
||||
|
||||
fn returns() -> S {
|
||||
return S(Value);
|
||||
}
|
||||
|
||||
fn statement() {
|
||||
return;
|
||||
}
|
||||
|
||||
fn returns() -> S {
|
||||
return S(Value);
|
||||
}
|
||||
|
||||
fn call() {
|
||||
statement();
|
||||
let _e0 = returns();
|
||||
|
Loading…
Reference in New Issue
Block a user