Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glsl-in: texelFetch accept multisampled textures #1715

Merged
merged 1 commit into from
Feb 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/front/glsl/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,14 +443,20 @@ pub fn inject_builtin(declaration: &mut FunctionDeclaration, module: &mut Module
}
"texelFetch" => {
// bits layout
// bit 0 - dim part 1 - 1D/2D
// bit 1 - array
// bit 2 - dim part 2 - 3D
// bit 0 - array
// bit 1 - multisample
// bits 2 trough 3 - dims
//
// 0b100 is the latest since 3D arrayed images aren't allowed
for bits in 0..(0b101) {
let dim = bits & 0b1 | (bits & 0b100) >> 1;
let arrayed = bits & 0b10 == 0b10;
// 0b1000 is the latest since 3D images aren't allowed to be multisampled or arrayed
for bits in 0..=(0b1000) {
let arrayed = bits & 0b1 != 0;
let multi = bits & 0b10 != 0;
let dim = bits >> 2;

// Multisampled 1d images don't exist
if dim == 0b00 && multi {
continue;
}

let image = TypeInner::Image {
dim: match dim {
Expand All @@ -461,7 +467,7 @@ pub fn inject_builtin(declaration: &mut FunctionDeclaration, module: &mut Module
arrayed,
class: ImageClass::Sampled {
kind: Sk::Float,
multi: false,
multi,
},
};

Expand Down