glsl-in: Add support for texelFetchOffset

This commit is contained in:
João Capucho
2022-02-24 17:05:49 +00:00
committed by Dzmitry Malyshau
parent 62f267a140
commit d449d2e665
3 changed files with 34 additions and 7 deletions

View File

@@ -306,7 +306,8 @@ pub fn inject_builtin(
f,
)
}
"texelFetch" => {
"texelFetch" | "texelFetchOffset" => {
let offset = "texelFetchOffset" == name;
let f = |kind, dim, arrayed, multi, _shadow| {
// Cube images aren't supported
if let Dim::Cube = dim {
@@ -322,7 +323,7 @@ pub fn inject_builtin(
let dim_value = image_dims_to_coords_size(dim);
let coordinates = make_coords_arg(dim_value + arrayed as usize, Sk::Sint);
let args = vec![
let mut args = vec![
image,
coordinates,
TypeInner::Scalar {
@@ -331,6 +332,10 @@ pub fn inject_builtin(
},
];
if offset {
args.push(make_coords_arg(dim_value, Sk::Sint));
}
declaration
.overloads
.push(module.add_builtin(args, MacroCall::ImageLoad { multi }))