- Revision
- 158798
- Author
- [email protected]
- Date
- 2013-11-06 15:08:56 -0800 (Wed, 06 Nov 2013)
Log Message
[WebGL] We should not allow generateMipMap on compressed textures
https://bugs.webkit.org/show_bug.cgi?id=123915
<rdar://problem/15201274>
Reviewed by Dean Jackson.
Found by existing conformance/extensions/webgl-compressed-texture-s3tc.html
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::compressedTexImage2D): Set compressed flag.
(WebCore::WebGLRenderingContext::compressedTexSubImage2D): Ditto.
(WebCore::WebGLRenderingContext::generateMipmap): For Apple builds, check state
of compressed flag and generate appropriate WebGL error if necessary.
* html/canvas/WebGLTexture.cpp:
(WebCore::WebGLTexture::WebGLTexture): Set compressed flag to false by default
(WebCore::WebGLTexture::isCompressed): Added
(WebCore::WebGLTexture::setCompressed): Added
* html/canvas/WebGLTexture.h:
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::generateMipmap): Switch implementation to use proper
glGenerateMipmaps, rather than the glGenerateMipmapsEXT method.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (158797 => 158798)
--- trunk/Source/WebCore/ChangeLog 2013-11-06 23:04:39 UTC (rev 158797)
+++ trunk/Source/WebCore/ChangeLog 2013-11-06 23:08:56 UTC (rev 158798)
@@ -1,3 +1,27 @@
+2013-11-06 Brent Fulgham <[email protected]>
+
+ [WebGL] We should not allow generateMipMap on compressed textures
+ https://bugs.webkit.org/show_bug.cgi?id=123915
+ <rdar://problem/15201274>
+
+ Reviewed by Dean Jackson.
+
+ Found by existing conformance/extensions/webgl-compressed-texture-s3tc.html
+
+ * html/canvas/WebGLRenderingContext.cpp:
+ (WebCore::WebGLRenderingContext::compressedTexImage2D): Set compressed flag.
+ (WebCore::WebGLRenderingContext::compressedTexSubImage2D): Ditto.
+ (WebCore::WebGLRenderingContext::generateMipmap): For Apple builds, check state
+ of compressed flag and generate appropriate WebGL error if necessary.
+ * html/canvas/WebGLTexture.cpp:
+ (WebCore::WebGLTexture::WebGLTexture): Set compressed flag to false by default
+ (WebCore::WebGLTexture::isCompressed): Added
+ (WebCore::WebGLTexture::setCompressed): Added
+ * html/canvas/WebGLTexture.h:
+ * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
+ (WebCore::GraphicsContext3D::generateMipmap): Switch implementation to use proper
+ glGenerateMipmaps, rather than the glGenerateMipmapsEXT method.
+
2013-11-06 Joseph Pecoraro <[email protected]>
Web Inspector: Changes to CodeGeneratorInspectorStrings.py should rebuild inspector generated files
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (158797 => 158798)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp 2013-11-06 23:04:39 UTC (rev 158797)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp 2013-11-06 23:08:56 UTC (rev 158798)
@@ -1340,6 +1340,7 @@
graphicsContext3D()->compressedTexImage2D(target, level, internalformat, width, height,
border, data->byteLength(), data->baseAddress());
tex->setLevelInfo(target, level, internalformat, width, height, GraphicsContext3D::UNSIGNED_BYTE);
+ tex->setCompressed();
cleanupAfterGraphicsCall(false);
}
@@ -1371,6 +1372,7 @@
graphicsContext3D()->compressedTexSubImage2D(target, level, xoffset, yoffset,
width, height, format, data->byteLength(), data->baseAddress());
+ tex->setCompressed();
cleanupAfterGraphicsCall(false);
}
@@ -2222,6 +2224,11 @@
synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "generateMipmap", "level 0 not power of 2 or not all the same size");
return;
}
+ // FIXME: https://bugs.webkit.org/show_bug.cgi?id=123916. Compressed textures should be allowed in WebGL 2:
+ if (tex->isCompressed()) {
+ synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "generateMipmap", "trying to generate mipmaps from compressed texture");
+ return;
+ }
if (!validateSettableTexFormat("generateMipmap", tex->getInternalFormat(target, 0)))
return;
Modified: trunk/Source/WebCore/html/canvas/WebGLTexture.cpp (158797 => 158798)
--- trunk/Source/WebCore/html/canvas/WebGLTexture.cpp 2013-11-06 23:04:39 UTC (rev 158797)
+++ trunk/Source/WebCore/html/canvas/WebGLTexture.cpp 2013-11-06 23:08:56 UTC (rev 158798)
@@ -50,6 +50,7 @@
, m_isNPOT(false)
, m_isComplete(false)
, m_needToUseBlackTexture(false)
+ , m_isCompressed(false)
{
setObject(ctx->graphicsContext3D()->createTexture());
}
@@ -239,6 +240,19 @@
return m_needToUseBlackTexture;
}
+bool WebGLTexture::isCompressed() const
+{
+ if (!object())
+ return false;
+ return m_isCompressed;
+}
+
+void WebGLTexture::setCompressed()
+{
+ ASSERT(object());
+ m_isCompressed = true;
+}
+
void WebGLTexture::deleteObjectImpl(GraphicsContext3D* context3d, Platform3DObject object)
{
context3d->deleteTexture(object);
Modified: trunk/Source/WebCore/html/canvas/WebGLTexture.h (158797 => 158798)
--- trunk/Source/WebCore/html/canvas/WebGLTexture.h 2013-11-06 23:04:39 UTC (rev 158797)
+++ trunk/Source/WebCore/html/canvas/WebGLTexture.h 2013-11-06 23:08:56 UTC (rev 158798)
@@ -66,6 +66,9 @@
// Determine if texture sampling should always return [0, 0, 0, 1] (OpenGL ES 2.0 Sec 3.8.2).
bool needToUseBlackTexture() const;
+ bool isCompressed() const;
+ void setCompressed();
+
bool hasEverBeenBound() const { return object() && m_target; }
static GC3Dint computeLevelCount(GC3Dsizei width, GC3Dsizei height);
@@ -123,6 +126,7 @@
bool m_isNPOT;
bool m_isComplete;
bool m_needToUseBlackTexture;
+ bool m_isCompressed;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp (158797 => 158798)
--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp 2013-11-06 23:04:39 UTC (rev 158797)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp 2013-11-06 23:08:56 UTC (rev 158798)
@@ -665,7 +665,7 @@
void GraphicsContext3D::generateMipmap(GC3Denum target)
{
makeContextCurrent();
- ::glGenerateMipmapEXT(target);
+ ::glGenerateMipmap(target);
}
bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo& info)