Commit 52cb2a1a by Yan, Shaobo Committed by Commit Bot

Allow SamplerVideoWEBGL can sampler compatible texture type

For current WEBGL_video_image implementation, VideoImage texture type translates to its native texture type in blink layer. A refactory for this implementation is required but is complicated and need much time. Currently, we need a workaround in ANGLE to support this extension. Current end2end tests can monitor this workaround well. BUG=chromium:776222, angleproject:3889 Change-Id: I864bc2734cfffc8c5aea6166466767e3fb31c1c7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1989864 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent c4053a9e
......@@ -109,6 +109,26 @@ TextureManager *AllocateOrGetSharedTextureManager(const State *shareContextState
}
}
// TODO(https://anglebug.com/3889): Remove this helper function after blink and chromium part
// refactory done.
bool IsTextureCompatibleWithSampler(TextureType texture, TextureType sampler)
{
if (sampler == texture)
{
return true;
}
if (sampler == TextureType::VideoImage)
{
if (texture == TextureType::VideoImage || texture == TextureType::_2D)
{
return true;
}
}
return false;
}
int gIDCounter = 1;
} // namespace
......@@ -1151,7 +1171,7 @@ void State::setSamplerTexture(const Context *context, TextureType type, Texture
mSamplerTextures[type][mActiveSampler].set(context, texture);
if (mProgram && mProgram->getActiveSamplersMask()[mActiveSampler] &&
mProgram->getActiveSamplerTypes()[mActiveSampler] == type)
IsTextureCompatibleWithSampler(type, mProgram->getActiveSamplerTypes()[mActiveSampler]))
{
updateActiveTexture(context, mActiveSampler, texture);
}
......@@ -2627,6 +2647,28 @@ void State::getBooleani_v(GLenum target, GLuint index, GLboolean *data)
}
}
// TODO(https://anglebug.com/3889): Remove this helper function after blink and chromium part
// refactory done.
Texture *State::getTextureForActiveSampler(TextureType type, size_t index)
{
if (type != TextureType::VideoImage)
{
return mSamplerTextures[type][index].get();
}
ASSERT(type == TextureType::VideoImage);
Texture *candidateTexture = mSamplerTextures[type][index].get();
if (candidateTexture->getWidth(TextureTarget::VideoImage, 0) == 0 ||
candidateTexture->getHeight(TextureTarget::VideoImage, 0) == 0 ||
candidateTexture->getDepth(TextureTarget::VideoImage, 0) == 0)
{
return mSamplerTextures[TextureType::_2D][index].get();
}
return mSamplerTextures[type][index].get();
}
angle::Result State::syncTexturesInit(const Context *context)
{
ASSERT(mRobustResourceInit);
......@@ -2835,7 +2877,7 @@ angle::Result State::onProgramExecutableChange(const Context *context, Program *
if (type == TextureType::InvalidEnum)
continue;
Texture *texture = mSamplerTextures[type][textureIndex].get();
Texture *texture = getTextureForActiveSampler(type, textureIndex);
updateActiveTexture(context, textureIndex, texture);
}
......@@ -2903,7 +2945,7 @@ void State::onActiveTextureChange(const Context *context, size_t textureUnit)
TextureType type = mProgram->getActiveSamplerTypes()[textureUnit];
if (type != TextureType::InvalidEnum)
{
Texture *activeTexture = mSamplerTextures[type][textureUnit].get();
Texture *activeTexture = getTextureForActiveSampler(type, textureUnit);
updateActiveTexture(context, textureUnit, activeTexture);
}
}
......@@ -2916,7 +2958,7 @@ void State::onActiveTextureStateChange(const Context *context, size_t textureUni
TextureType type = mProgram->getActiveSamplerTypes()[textureUnit];
if (type != TextureType::InvalidEnum)
{
Texture *activeTexture = mSamplerTextures[type][textureUnit].get();
Texture *activeTexture = getTextureForActiveSampler(type, textureUnit);
const Sampler *sampler = mSamplers[textureUnit].get();
updateActiveTextureState(context, textureUnit, sampler, activeTexture);
}
......
......@@ -722,6 +722,7 @@ class State : angle::NonCopyable
size_t textureIndex,
const Sampler *sampler,
Texture *texture);
Texture *getTextureForActiveSampler(TextureType type, size_t index);
// Functions to synchronize dirty states
angle::Result syncTexturesInit(const Context *context);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment