Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement override-expression evaluation #5249

Merged
merged 15 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions naga/src/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ impl<T> Handle<T> {
serde(transparent)
)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(test, derive(PartialEq))]
pub struct Range<T> {
inner: ops::Range<u32>,
#[cfg_attr(any(feature = "serialize", feature = "deserialize"), serde(skip))]
Expand All @@ -140,6 +141,7 @@ impl<T> Range<T> {

// NOTE: Keep this diagnostic in sync with that of [`BadHandle`].
#[derive(Clone, Debug, thiserror::Error)]
#[cfg_attr(test, derive(PartialEq))]
#[error("Handle range {range:?} of {kind} is either not present, or inaccessible yet")]
pub struct BadRangeError {
// This error is used for many `Handle` types, but there's no point in making this generic, so
Expand Down
2 changes: 1 addition & 1 deletion naga/src/back/glsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2395,7 +2395,7 @@ impl<'a, W: Write> Writer<'a, W> {
fn write_const_expr(&mut self, expr: Handle<crate::Expression>) -> BackendResult {
self.write_possibly_const_expr(
expr,
&self.module.const_expressions,
&self.module.global_expressions,
|expr| &self.info[expr],
|writer, expr| writer.write_const_expr(expr),
)
Expand Down
2 changes: 1 addition & 1 deletion naga/src/back/hlsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ pub enum Error {
#[error("{0}")]
Custom(String),
#[error(transparent)]
PipelineConstant(#[from] back::pipeline_constants::PipelineConstantError),
PipelineConstant(#[from] Box<back::pipeline_constants::PipelineConstantError>),
}

#[derive(Default)]
Expand Down
13 changes: 9 additions & 4 deletions naga/src/back/hlsl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,14 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
module_info: &valid::ModuleInfo,
pipeline_options: &PipelineOptions,
) -> Result<super::ReflectionInfo, Error> {
let module =
back::pipeline_constants::process_overrides(module, &pipeline_options.constants)?;
let (module, module_info) = back::pipeline_constants::process_overrides(
module,
module_info,
&pipeline_options.constants,
)
.map_err(Box::new)?;
let module = module.as_ref();
let module_info = module_info.as_ref();

self.reset(module);

Expand Down Expand Up @@ -254,7 +259,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {

self.write_special_functions(module)?;

self.write_wrapped_compose_functions(module, &module.const_expressions)?;
self.write_wrapped_compose_functions(module, &module.global_expressions)?;

// Write all named constants
let mut constants = module
Expand Down Expand Up @@ -2018,7 +2023,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
self.write_possibly_const_expression(
module,
expr,
&module.const_expressions,
&module.global_expressions,
|writer, expr| writer.write_const_expression(module, expr),
)
}
Expand Down
2 changes: 1 addition & 1 deletion naga/src/back/msl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub enum Error {
#[error("ray tracing is not supported prior to MSL 2.3")]
UnsupportedRayTracing,
#[error(transparent)]
PipelineConstant(#[from] crate::back::pipeline_constants::PipelineConstantError),
PipelineConstant(#[from] Box<crate::back::pipeline_constants::PipelineConstantError>),
}

#[derive(Clone, Debug, PartialEq, thiserror::Error)]
Expand Down
8 changes: 5 additions & 3 deletions naga/src/back/msl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ impl<W: Write> Writer<W> {
) -> BackendResult {
self.put_possibly_const_expression(
expr_handle,
&module.const_expressions,
&module.global_expressions,
module,
mod_info,
&(module, mod_info),
Expand Down Expand Up @@ -3119,9 +3119,11 @@ impl<W: Write> Writer<W> {
options: &Options,
pipeline_options: &PipelineOptions,
) -> Result<TranslationInfo, Error> {
let module =
back::pipeline_constants::process_overrides(module, &pipeline_options.constants)?;
let (module, info) =
back::pipeline_constants::process_overrides(module, info, &pipeline_options.constants)
.map_err(Box::new)?;
let module = module.as_ref();
let info = info.as_ref();

self.names.clear();
self.namer.reset(
Expand Down
Loading
Loading