Commit 72a030e5 authored by zmo's avatar zmo Committed by Commit bot

Remove blink side NPOT/incomplete texture handling.

We do it in command buffer so it's duplicated validation.

BUG=570453
TEST=webgl_conformance
R=kbr@chromium.org,bajones@chromium.org

Review URL: https://codereview.chromium.org/1639103002

Cr-Commit-Position: refs/heads/master@{#371711}
parent ba1c4ef5
...@@ -5524,14 +5524,16 @@ ScriptValue WebGLRenderingContextBase::getWebGLIntArrayParameter(ScriptState* sc ...@@ -5524,14 +5524,16 @@ ScriptValue WebGLRenderingContextBase::getWebGLIntArrayParameter(ScriptState* sc
void WebGLRenderingContextBase::handleTextureCompleteness(const char* functionName, bool prepareToDraw) void WebGLRenderingContextBase::handleTextureCompleteness(const char* functionName, bool prepareToDraw)
{ {
// All calling functions check isContextLost, so a duplicate check is not needed here. // All calling functions check isContextLost, so a duplicate check is not needed here.
// We only handle the situation with float/half_float textures here. Other situations are handled in command buffer.
bool resetActiveUnit = false; bool resetActiveUnit = false;
WebGLTexture::TextureExtensionFlag flag = static_cast<WebGLTexture::TextureExtensionFlag>((extensionEnabled(OESTextureFloatLinearName) ? WebGLTexture::TextureFloatLinearExtensionEnabled : 0) WebGLTexture::TextureExtensionFlag flag = static_cast<WebGLTexture::TextureExtensionFlag>((extensionEnabled(OESTextureFloatLinearName) ? WebGLTexture::TextureFloatLinearExtensionEnabled : 0)
| ((extensionEnabled(OESTextureHalfFloatLinearName) || isWebGL2OrHigher()) ? WebGLTexture::TextureHalfFloatLinearExtensionEnabled : 0)); | ((extensionEnabled(OESTextureHalfFloatLinearName) || isWebGL2OrHigher()) ? WebGLTexture::TextureHalfFloatLinearExtensionEnabled : 0));
for (unsigned ii = 0; ii < m_onePlusMaxNonDefaultTextureUnit; ++ii) { for (unsigned ii = 0; ii < m_onePlusMaxNonDefaultTextureUnit; ++ii) {
const WebGLSamplerState* samplerState2D = getTextureUnitSamplerState(GL_TEXTURE_2D, ii); const WebGLSamplerState* samplerState2D = getTextureUnitSamplerState(GL_TEXTURE_2D, ii);
const WebGLSamplerState* samplerStateCubeMap = getTextureUnitSamplerState(GL_TEXTURE_CUBE_MAP, ii); const WebGLSamplerState* samplerStateCubeMap = getTextureUnitSamplerState(GL_TEXTURE_CUBE_MAP, ii);
if ((m_textureUnits[ii].m_texture2DBinding.get() && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture(flag, samplerState2D)) bool needToUseBlackTex2D = (m_textureUnits[ii].m_texture2DBinding.get() && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture(flag, samplerState2D));
|| (m_textureUnits[ii].m_textureCubeMapBinding.get() && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag, samplerStateCubeMap))) { bool needToUseBlackTexCubeMap = (m_textureUnits[ii].m_textureCubeMapBinding.get() && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag, samplerStateCubeMap));
if (needToUseBlackTex2D || needToUseBlackTexCubeMap) {
if (ii != m_activeTextureUnit) { if (ii != m_activeTextureUnit) {
webContext()->activeTexture(GL_TEXTURE0 + ii); webContext()->activeTexture(GL_TEXTURE0 + ii);
resetActiveUnit = true; resetActiveUnit = true;
...@@ -5543,8 +5545,7 @@ void WebGLRenderingContextBase::handleTextureCompleteness(const char* functionNa ...@@ -5543,8 +5545,7 @@ void WebGLRenderingContextBase::handleTextureCompleteness(const char* functionNa
WebGLTexture* texCubeMap; WebGLTexture* texCubeMap;
if (prepareToDraw) { if (prepareToDraw) {
String msg(String("texture bound to texture unit ") + String::number(ii) String msg(String("texture bound to texture unit ") + String::number(ii)
+ " is not renderable. It maybe non-power-of-2 and have incompatible texture filtering or is not 'texture complete'." + " is not renderable. Texture is Float or Half Float type with linear filtering while OES_float_linear or OES_half_float_linear extension is not enabled.");
+ " Or the texture is Float or Half Float type with linear filtering while OES_float_linear or OES_half_float_linear extension is not enabled.");
emitGLWarning(functionName, msg.utf8().data()); emitGLWarning(functionName, msg.utf8().data());
tex2D = m_blackTexture2D.get(); tex2D = m_blackTexture2D.get();
texCubeMap = m_blackTextureCubeMap.get(); texCubeMap = m_blackTextureCubeMap.get();
...@@ -5552,9 +5553,9 @@ void WebGLRenderingContextBase::handleTextureCompleteness(const char* functionNa ...@@ -5552,9 +5553,9 @@ void WebGLRenderingContextBase::handleTextureCompleteness(const char* functionNa
tex2D = m_textureUnits[ii].m_texture2DBinding.get(); tex2D = m_textureUnits[ii].m_texture2DBinding.get();
texCubeMap = m_textureUnits[ii].m_textureCubeMapBinding.get(); texCubeMap = m_textureUnits[ii].m_textureCubeMapBinding.get();
} }
if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture(flag, samplerState2D)) if (needToUseBlackTex2D)
webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(tex2D)); webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(tex2D));
if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag, samplerStateCubeMap)) if (needToUseBlackTexCubeMap)
webContext()->bindTexture(GL_TEXTURE_CUBE_MAP, objectOrZero(texCubeMap)); webContext()->bindTexture(GL_TEXTURE_CUBE_MAP, objectOrZero(texCubeMap));
} }
} }
......
...@@ -40,7 +40,6 @@ WebGLTexture::WebGLTexture(WebGLRenderingContextBase* ctx) ...@@ -40,7 +40,6 @@ WebGLTexture::WebGLTexture(WebGLRenderingContextBase* ctx)
, m_isNPOT(false) , m_isNPOT(false)
, m_isCubeComplete(false) , m_isCubeComplete(false)
, m_isComplete(false) , m_isComplete(false)
, m_needToUseBlackTexture(false)
, m_isFloatType(false) , m_isFloatType(false)
, m_isHalfFloatType(false) , m_isHalfFloatType(false)
, m_isWebGL2OrHigher(ctx->isWebGL2OrHigher()) , m_isWebGL2OrHigher(ctx->isWebGL2OrHigher())
...@@ -228,7 +227,6 @@ void WebGLTexture::generateMipmapLevelInfo() ...@@ -228,7 +227,6 @@ void WebGLTexture::generateMipmapLevelInfo()
} }
m_isComplete = true; m_isComplete = true;
} }
m_needToUseBlackTexture = false;
} }
GLenum WebGLTexture::getInternalFormat(GLenum target, GLint level) const GLenum WebGLTexture::getInternalFormat(GLenum target, GLint level) const
...@@ -301,8 +299,6 @@ bool WebGLTexture::needToUseBlackTexture(TextureExtensionFlag flag, const WebGLS ...@@ -301,8 +299,6 @@ bool WebGLTexture::needToUseBlackTexture(TextureExtensionFlag flag, const WebGLS
ASSERT(samplerState); ASSERT(samplerState);
if (!object()) if (!object())
return false; return false;
if (m_needToUseBlackTexture)
return true;
if ((m_isFloatType && !(flag & TextureFloatLinearExtensionEnabled)) || (m_isHalfFloatType && !(flag && TextureHalfFloatLinearExtensionEnabled))) { if ((m_isFloatType && !(flag & TextureFloatLinearExtensionEnabled)) || (m_isHalfFloatType && !(flag && TextureHalfFloatLinearExtensionEnabled))) {
if (samplerState->magFilter != GL_NEAREST || (samplerState->minFilter != GL_NEAREST && samplerState->minFilter != GL_NEAREST_MIPMAP_NEAREST)) if (samplerState->magFilter != GL_NEAREST || (samplerState->minFilter != GL_NEAREST && samplerState->minFilter != GL_NEAREST_MIPMAP_NEAREST))
return true; return true;
...@@ -437,21 +433,6 @@ void WebGLTexture::update() ...@@ -437,21 +433,6 @@ void WebGLTexture::update()
} }
m_isFloatType = m_info[0][0].type == GL_FLOAT; m_isFloatType = m_info[0][0].type == GL_FLOAT;
m_isHalfFloatType = m_info[0][0].type == GL_HALF_FLOAT_OES; m_isHalfFloatType = m_info[0][0].type == GL_HALF_FLOAT_OES;
m_needToUseBlackTexture = false;
// If it is a Cube texture, check Cube Completeness first
if (m_info.size() > 1 && !m_isCubeComplete)
m_needToUseBlackTexture = true;
if (!m_isWebGL2OrHigher) {
// We can do these checks up front in WebGL 1 because there's no separate samplers.
// NPOT
if (m_isNPOT && ((m_samplerState.minFilter != GL_NEAREST && m_samplerState.minFilter != GL_LINEAR)
|| m_samplerState.wrapS != GL_CLAMP_TO_EDGE || m_samplerState.wrapT != GL_CLAMP_TO_EDGE))
m_needToUseBlackTexture = true;
// Completeness
if (!m_isComplete && m_samplerState.minFilter != GL_NEAREST && m_samplerState.minFilter != GL_LINEAR)
m_needToUseBlackTexture = true;
}
} }
const WebGLTexture::LevelInfo* WebGLTexture::getLevelInfo(GLenum target, GLint level) const const WebGLTexture::LevelInfo* WebGLTexture::getLevelInfo(GLenum target, GLint level) const
......
...@@ -150,7 +150,6 @@ private: ...@@ -150,7 +150,6 @@ private:
bool m_isNPOT; bool m_isNPOT;
bool m_isCubeComplete; bool m_isCubeComplete;
bool m_isComplete; bool m_isComplete;
bool m_needToUseBlackTexture;
bool m_isFloatType; bool m_isFloatType;
bool m_isHalfFloatType; bool m_isHalfFloatType;
bool m_isWebGL2OrHigher; bool m_isWebGL2OrHigher;
......
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