[glsl-in] Add support for texture function with LOD bias

This commit is contained in:
Jasper St. Pierre
2021-06-30 09:25:56 -07:00
committed by João Capucho
parent ef1194d69a
commit fbab3a3ba5
2 changed files with 3 additions and 2 deletions

View File

@@ -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,

View File

@@ -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,