mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
glsl-in: Fix parameter not changing to depth
The conversion from sampled images to depth changed the `argument` type but didn't change the `parameter` type (`argument` without pointer indirection) causing 2+ deep propagation of depth images with function arguments to fail.
This commit is contained in:
@@ -2237,20 +2237,26 @@ pub fn sampled_to_depth(
|
||||
meta: Span,
|
||||
errors: &mut Vec<Error>,
|
||||
) {
|
||||
// Get the a mutable type handle of the underlying image storage
|
||||
let ty = match ctx[image] {
|
||||
Expression::GlobalVariable(handle) => &mut module.global_variables.get_mut(handle).ty,
|
||||
Expression::FunctionArgument(i) => {
|
||||
// Mark the function argument as carrying a depth texture
|
||||
ctx.parameters_info[i as usize].depth = true;
|
||||
// NOTE: We need to later also change the parameter type
|
||||
&mut ctx.arguments[i as usize].ty
|
||||
}
|
||||
_ => {
|
||||
// Only globals and function arguments are allowed to carry an image
|
||||
return errors.push(Error {
|
||||
kind: ErrorKind::SemanticError("Not a valid texture expression".into()),
|
||||
meta,
|
||||
})
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
match module.types[*ty].inner {
|
||||
// Update the image class to depth in case it already isn't
|
||||
TypeInner::Image {
|
||||
class,
|
||||
dim,
|
||||
@@ -2270,6 +2276,7 @@ pub fn sampled_to_depth(
|
||||
)
|
||||
}
|
||||
ImageClass::Depth { .. } => {}
|
||||
// Other image classes aren't allowed to be transformed to depth
|
||||
_ => errors.push(Error {
|
||||
kind: ErrorKind::SemanticError("Not a texture".into()),
|
||||
meta,
|
||||
@@ -2280,6 +2287,15 @@ pub fn sampled_to_depth(
|
||||
meta,
|
||||
}),
|
||||
};
|
||||
|
||||
// Copy the handle to allow borrowing the `ctx` again
|
||||
let ty = *ty;
|
||||
|
||||
// If the image was passed trough a function argument we also need to change
|
||||
// the corresponding parameter
|
||||
if let Expression::FunctionArgument(i) = ctx[image] {
|
||||
ctx.parameters[i as usize] = ty;
|
||||
}
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
|
||||
@@ -671,6 +671,13 @@ impl Parser {
|
||||
let overload_param_ty = &self.module.types[*overload_parameter].inner;
|
||||
let call_arg_ty = self.resolve_type(ctx, call_argument.0, call_argument.1)?;
|
||||
|
||||
log::trace!(
|
||||
"Testing parameter {}\n\tOverload = {:?}\n\tCall = {:?}",
|
||||
i,
|
||||
overload_param_ty,
|
||||
call_arg_ty
|
||||
);
|
||||
|
||||
// Storage images cannot be directly compared since while the access is part of the
|
||||
// type in naga's IR, in glsl they are a qualifier and don't enter in the match as
|
||||
// long as the access needed is satisfied.
|
||||
|
||||
Reference in New Issue
Block a user