[glsl-in] fix swizzle in a global const context

This commit is contained in:
teoxoy 2023-12-11 12:57:10 +01:00 committed by Teodor Tanasoaia
parent a0c2b25829
commit b47d4924a8
3 changed files with 46 additions and 1 deletions

View File

@ -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]
}
}
}

View 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);
}

View 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);
}