我为我的每个项目都在GLTexture中进行了此类修复。 有一种方法可以在v5中制作您的自定义上传器。
现在最好的策略是DIY:
PIXI.glCore.GLTexture.prototype.upload = function(source)
{
this.bind();
var gl = this.gl;
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha);
var isVideo = !!source.videoWidth;
var newWidth = isVideo ? source.videoWidth : source.width;
var newHeight = isVideo ? source.videoHeight : source.height;
if(newHeight !== this.height || newWidth !== this.width || isVideo)
{
gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, this.type, source);
}
else
{
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.format, this.type, source);
}
this.width = newWidth;
this.height = newHeight;
};
将其放在项目的单独文件中,并将其命名为“ pixi-patch.js”。 我有数十个类似的补丁,分别用于我使用的不同库。
我建议我们为V5默认上传器添加特殊标志,“始终使用texImage2D”
@kurozael ping
嗨,是的,这很好,还是我们可以检测它是否像您的示例一样是视频?
顺便说一句,此问题还导致视频纹理变得极其缓慢:
@ivanpopelyshev非常感谢您。 让我发疯。 幸运的是,即使在TypeScript上修补upload
工作。 希望这样的事情将很快合并。
@englercj我能否得到您的确认,请确认您已更改为使用v5的texImage2D? 各种不同的PR相互引用,我认为这对于v5已解决,并且已经为v4提供了解决方法,因此可以将其关闭! 谢谢
此修补程序在chrome 70上不再起作用…另外,在Windows上的pixi5 / chrome70重新引入了原始问题
确认上述解决方案由于仅在Window计算机上更新了Chrome 70而停止工作。 OSX仍然可以正常工作。 @ivanpopelyshev可以重新打开吗,还是应该创建一个新的期刊?
由于此问题最近没有活动,因此已被自动标记为陈旧。 如果没有进一步的活动,它将关闭。 感谢您的贡献。
万一它可以帮助仍然遇到此问题的任何人,那肯定是texSubImage2D
和视频的问题。
@saschagehlich发布的链接对于帮助更深入地了解这一点非常有用。
上面的答案/补丁不再适用于PIXI v5,而是我们对BaseImageResource
进行了补丁,进行了类似的更改。
import { resources } from 'pixi.js'
resources.BaseImageResource.prototype.upload = function(renderer, baseTexture, glTexture, source) {
const gl = renderer.gl;
const width = baseTexture.realWidth;
const height = baseTexture.realHeight;
source = source || this.source;
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, baseTexture.premultiplyAlpha);
// add this line, check for video
const isVideo = !!source.videoWidth
if (!isVideo && baseTexture.target === gl.TEXTURE_2D && glTexture.width === width && glTexture.height === height)
{
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, baseTexture.format, baseTexture.type, source);
}
else
{
glTexture.width = width;
glTexture.height = height;
gl.texImage2D(baseTexture.target, 0, baseTexture.format, baseTexture.format, baseTexture.type, source);
}
return true
}
结果确实非常惊人。
之前
后
我知道这个问题是过时的,但是我想为某些资源类型绕过texSubImage2D
选择大声疾呼。 否则,我希望该解决方案可以帮助其他任何处理性能问题和视频的人。
由于此问题最近没有活动,因此已被自动标记为陈旧。 如果没有进一步的活动,它将关闭。 感谢您的贡献。
我只是碰碰这个,因为它仍然需要解决。
由于此问题最近没有活动,因此已被自动标记为陈旧。 如果没有进一步的活动,它将关闭。 感谢您的贡献。
最有用的评论
我为我的每个项目都在GLTexture中进行了此类修复。 有一种方法可以在v5中制作您的自定义上传器。
现在最好的策略是DIY:
将其放在项目的单独文件中,并将其命名为“ pixi-patch.js”。 我有数十个类似的补丁,分别用于我使用的不同库。