Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1030)

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 1490043002: Implementing Blink-side validation for WebGL 2 Samplers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed zmo@'s new feedback Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
index aae2e264cea6aa8a2a736600d699b7bc4c8b6cb3..6e32543059c28397f782d57412a0b2aedb3a4b5f 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
@@ -2047,6 +2047,33 @@ WebGLRenderbuffer* WebGLRenderingContextBase::ensureEmulatedStencilBuffer(GLenum
return renderbuffer->emulatedStencilBuffer();
}
+const WebGLSamplerState* WebGLRenderingContextBase::getTextureUnitSamplerState(GLenum target, GLuint unit) const
+{
+ ASSERT(unit < m_textureUnits.size());
+
+ WebGLTexture* texture = nullptr;
+
+ switch (target) {
+ case GL_TEXTURE_2D:
+ texture = m_textureUnits[unit].m_texture2DBinding;
+ break;
+ case GL_TEXTURE_CUBE_MAP:
+ texture = m_textureUnits[unit].m_textureCubeMapBinding;
+ break;
+ case GL_TEXTURE_2D_ARRAY:
+ texture = m_textureUnits[unit].m_texture2DArrayBinding;
+ break;
+ case GL_TEXTURE_3D:
+ texture = m_textureUnits[unit].m_texture3DBinding;
+ break;
+ }
+
+ if (texture)
+ return texture->getSamplerState();
+
+ return nullptr;
+}
+
void WebGLRenderingContextBase::setBoundVertexArrayObject(ScriptState* scriptState, WebGLVertexArrayObjectBase* arrayObject)
{
if (arrayObject)
@@ -5401,8 +5428,10 @@ void WebGLRenderingContextBase::handleTextureCompleteness(const char* functionNa
WebGLTexture::TextureExtensionFlag flag = static_cast<WebGLTexture::TextureExtensionFlag>((extensionEnabled(OESTextureFloatLinearName) ? WebGLTexture::TextureFloatLinearExtensionEnabled : 0)
| ((extensionEnabled(OESTextureHalfFloatLinearName) || isWebGL2OrHigher()) ? WebGLTexture::TextureHalfFloatLinearExtensionEnabled : 0));
for (unsigned ii = 0; ii < m_onePlusMaxNonDefaultTextureUnit; ++ii) {
- if ((m_textureUnits[ii].m_texture2DBinding.get() && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture(flag))
- || (m_textureUnits[ii].m_textureCubeMapBinding.get() && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag))) {
+ const WebGLSamplerState* samplerState2D = getTextureUnitSamplerState(GL_TEXTURE_2D, 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))
+ || (m_textureUnits[ii].m_textureCubeMapBinding.get() && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag, samplerStateCubeMap))) {
if (ii != m_activeTextureUnit) {
webContext()->activeTexture(GL_TEXTURE0 + ii);
resetActiveUnit = true;
@@ -5423,9 +5452,9 @@ void WebGLRenderingContextBase::handleTextureCompleteness(const char* functionNa
tex2D = m_textureUnits[ii].m_texture2DBinding.get();
texCubeMap = m_textureUnits[ii].m_textureCubeMapBinding.get();
}
- if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture(flag))
+ if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture(flag, samplerState2D))
webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(tex2D));
- if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag))
+ if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag, samplerStateCubeMap))
webContext()->bindTexture(GL_TEXTURE_CUBE_MAP, objectOrZero(texCubeMap));
}
}

Powered by Google App Engine
This is Rietveld 408576698