Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aardgoose committed Jul 14, 2024
1 parent 5e739e4 commit b2f0e59
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/renderers/webgpu/utils/WebGPUTextureUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ class WebGPUTextureUtils {
const dimension = this._getDimension( texture );
const format = texture.internalFormat || options.format || getFormat( texture, backend.device );

const sampleCount = options.sampleCount !== undefined ? options.sampleCount : 1;
let sampleCount = options.sampleCount !== undefined ? options.sampleCount : 1;

// sampleCount = backend.utils.getSampleCount( sampleCount );
sampleCount = backend.utils.getSampleCount( sampleCount );

const primarySampleCount = texture.isRenderTargetTexture && ! texture.isMultisampleRenderTargetTexture ? 1 : sampleCount;

Expand Down
33 changes: 33 additions & 0 deletions src/renderers/webgpu/utils/WebGPUUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,39 @@ class WebGPUUtils {

}

getSampleCount( sampleCount ) {

let count = 1;

if ( sampleCount > 1 ) {

// WebGPU only supports power-of-two sample counts and 2 is not a valid value
count = Math.pow( 2, Math.floor( Math.log2( sampleCount ) ) );

if ( count === 2 ) {

count = 4;

}

}

return count;

}

getSampleCountRenderContext( renderContext ) {

if ( renderContext.textures !== null ) {

return this.getSampleCount( renderContext.sampleCount );

}

return this.getSampleCount( this.backend.renderer.samples );

}

}

export default WebGPUUtils;

0 comments on commit b2f0e59

Please sign in to comment.