Skip to content

Commit

Permalink
[Fix] Fixes handling uf (u/i)sampler2DArray shader translation for We…
Browse files Browse the repository at this point in the history
…bGPU (#7120)

Co-authored-by: Martin Valigursky <[email protected]>
  • Loading branch information
mvaligursky and Martin Valigursky committed Nov 20, 2024
1 parent 38dea6d commit c04b62d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/platform/graphics/bind-group-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,19 +359,17 @@ class BindGroupFormat {

let textureType = textureDimensionInfo[format.textureDimension];
Debug.assert(textureType, 'Unsupported texture type', format.textureDimension);
const isArray = textureType === 'texture2DArray';

const sampleTypePrefix = format.sampleType === SAMPLETYPE_UINT ? 'u' : (format.sampleType === SAMPLETYPE_INT ? 'i' : '');
textureType = `${sampleTypePrefix}${textureType}`;

// handle texture2DArray by renaming the texture object and defining a replacement macro
let namePostfix = '';
let extraCode = '';
if (textureType === 'texture2DArray') {
if (isArray) {
namePostfix = '_texture';
extraCode = `#define ${format.name} sampler2DArray(${format.name}${namePostfix}, ${format.name}_sampler)\n`;
}

if (format.sampleType === SAMPLETYPE_INT) {
textureType = `i${textureType}`;
} else if (format.sampleType === SAMPLETYPE_UINT) {
textureType = `u${textureType}`;
extraCode = `#define ${format.name} ${sampleTypePrefix}sampler2DArray(${format.name}${namePostfix}, ${format.name}_sampler)\n`;
}

code += `layout(set = ${bindGroup}, binding = ${format.slot}) uniform ${textureType} ${format.name}${namePostfix};\n`;
Expand Down

0 comments on commit c04b62d

Please sign in to comment.