From fbab3a3ba52d0764459d890ad69238bc567ef725 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 30 Jun 2021 09:25:56 -0700 Subject: [PATCH] [glsl-in] Add support for texture function with LOD bias --- src/front/glsl/functions.rs | 4 ++-- src/front/glsl/parser_tests.rs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/front/glsl/functions.rs b/src/front/glsl/functions.rs index 36cf739854..d10796266b 100644 --- a/src/front/glsl/functions.rs +++ b/src/front/glsl/functions.rs @@ -152,7 +152,7 @@ impl Program<'_> { Ok(Some(args[0].0)) } "texture" => { - if args.len() != 2 { + if !(2..=3).contains(&args.len()) { return Err(ErrorKind::wrong_function_args(name, 2, args.len(), meta)); } if let Some(sampler) = ctx.samplers.get(&args[0].0).copied() { @@ -163,7 +163,7 @@ impl Program<'_> { coordinate: args[1].0, array_index: None, //TODO offset: None, //TODO - level: SampleLevel::Auto, + level: args.get(2).map_or(SampleLevel::Auto, |&(expr, _)| SampleLevel::Bias(expr)), depth_ref: None, }, body, diff --git a/src/front/glsl/parser_tests.rs b/src/front/glsl/parser_tests.rs index f555ec2dce..6bf6f78bfb 100644 --- a/src/front/glsl/parser_tests.rs +++ b/src/front/glsl/parser_tests.rs @@ -271,6 +271,7 @@ fn textures() { layout(set = 1, binding = 2) uniform sampler tex_sampler; void main() { o_color = texture(sampler2D(tex, tex_sampler), v_uv); + o_color.a = texture(sampler2D(tex, tex_sampler), v_uv, 2.0).a; } "#, &entry_points,