Skip to content

Commit

Permalink
WebGPUTextures: Fix image orientation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed Sep 3, 2020
1 parent 8277a52 commit 63a0b7b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion examples/jsm/renderers/webgpu/WebGPUTextures.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ class WebGPUTextures {

} else {

if ( textureProperties.textureGPU !== undefined ) {

// TODO: Avoid calling of destroy() in certain scenarios. When only the contents of a texture
// are updated, a call of _uploadTexture() should be sufficient. However, if the user changes
// the dimensions of the texture, format or usage, a new instance of GPUTexture is required.

textureProperties.textureGPU.destroy();

}

textureProperties.textureGPU = this._createTexture( texture );
textureProperties.version = texture.version;
updated = true;
Expand Down Expand Up @@ -183,7 +193,11 @@ class WebGPUTextures {
if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ) {

createImageBitmap( image, 0, 0, width, height ).then( imageBitmap => {
const options = {};

options.imageOrientation = ( texture.flipY === true ) ? 'flipY' : 'none';

createImageBitmap( image, 0, 0, width, height, options ).then( imageBitmap => {

this._uploadTexture( imageBitmap, textureGPU );

Expand Down

0 comments on commit 63a0b7b

Please sign in to comment.