Skip to content

Commit

Permalink
Force texImage2D upload for videos (#6088)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigtimebuddy committed Sep 13, 2019
1 parent add2870 commit 6220cc0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/core/src/textures/resources/BaseImageResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ export class BaseImageResource extends Resource
* @readonly
*/
this.source = source;

/**
* If set to `true`, will force `texImage2D` over `texSubImage2D` for uploading.
* Certain types of media (e.g. video) using `texImage2D` is more performant.
* @member {boolean}
* @default false
* @private
*/
this.noSubImage = false;
}

/**
Expand Down Expand Up @@ -64,7 +73,10 @@ export class BaseImageResource extends Resource

gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, baseTexture.premultiplyAlpha);

if (baseTexture.target === gl.TEXTURE_2D && glTexture.width === width && glTexture.height === height)
if (!this.noSubImage
&& baseTexture.target === gl.TEXTURE_2D
&& glTexture.width === width
&& glTexture.height === height)
{
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, baseTexture.format, baseTexture.type, source);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/textures/resources/VideoResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class VideoResource extends BaseImageResource

super(source);

this.noSubImage = true;
this._autoUpdate = true;
this._isAutoUpdating = false;
this._updateFPS = options.updateFPS || 0;
Expand Down

0 comments on commit 6220cc0

Please sign in to comment.