mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 16:24:24 +00:00
[glsl-in] fix swizzle in a global const context
This commit is contained in:
parent
a0c2b25829
commit
b47d4924a8
@ -1478,7 +1478,11 @@ impl Index<Handle<Expression>> for Context<'_> {
|
||||
type Output = Expression;
|
||||
|
||||
fn index(&self, index: Handle<Expression>) -> &Self::Output {
|
||||
&self.expressions[index]
|
||||
if self.is_const {
|
||||
&self.module.const_expressions[index]
|
||||
} else {
|
||||
&self.expressions[index]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
15
naga/tests/in/glsl/const-global-swizzle.frag
Normal file
15
naga/tests/in/glsl/const-global-swizzle.frag
Normal file
@ -0,0 +1,15 @@
|
||||
// ISSUE: #4773
|
||||
#version 450
|
||||
|
||||
#define MIX2(c) c.xy
|
||||
|
||||
layout(location = 0) in vec2 v_Uv;
|
||||
|
||||
layout(location = 0) out vec4 o_Target;
|
||||
|
||||
const vec2 blank = MIX2(vec2(0.0, 1.0));
|
||||
|
||||
void main() {
|
||||
vec2 col = MIX2(v_Uv) * blank;
|
||||
o_Target = vec4(col, 0.0, 1.0);
|
||||
}
|
26
naga/tests/out/wgsl/const-global-swizzle.frag.wgsl
Normal file
26
naga/tests/out/wgsl/const-global-swizzle.frag.wgsl
Normal file
@ -0,0 +1,26 @@
|
||||
struct FragmentOutput {
|
||||
@location(0) o_Target: vec4<f32>,
|
||||
}
|
||||
|
||||
const blank: vec2<f32> = vec2<f32>(0f, 1f);
|
||||
|
||||
var<private> v_Uv_1: vec2<f32>;
|
||||
var<private> o_Target: vec4<f32>;
|
||||
|
||||
fn main_1() {
|
||||
var col: vec2<f32>;
|
||||
|
||||
let _e3 = v_Uv_1;
|
||||
col = (_e3.xy * blank);
|
||||
let _e7 = col;
|
||||
o_Target = vec4<f32>(_e7.x, _e7.y, 0f, 1f);
|
||||
return;
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn main(@location(0) v_Uv: vec2<f32>) -> FragmentOutput {
|
||||
v_Uv_1 = v_Uv;
|
||||
main_1();
|
||||
let _e9 = o_Target;
|
||||
return FragmentOutput(_e9);
|
||||
}
|
Loading…
Reference in New Issue
Block a user