Changeset 152351 in webkit
- Timestamp:
- Jul 3, 2013 5:59:55 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r152350 r152351 1 2013-07-03 Przemyslaw Szymanski <p.szymanski3@samsung.com> 2 3 TextureUnit code optimization 4 https://bugs.webkit.org/show_bug.cgi?id=117868 5 6 Reviewed by Noam Rosenthal. 7 8 According to OpenGL ES 2.0 specification it is not possible to use both 9 texture2D and textureCubeMap in one texture unit. 10 This patch reduces amount of code, slightly increases rendering performance 11 and makes WebKit more consistent with OpenGL. 12 13 No new tests. Covered by existing tests: 14 LayoutTests/webgl/conformance/textures/tex-image-webgl.html 15 LayoutTests/webgl/conformance/textures/texture-complete.html 16 17 * html/canvas/WebGLRenderingContext.cpp: 18 (WebCore::WebGLRenderingContext::~WebGLRenderingContext): 19 (WebCore::WebGLRenderingContext::reshape): 20 (WebCore::WebGLRenderingContext::bindTexture): 21 (WebCore::WebGLRenderingContext::deleteTexture): 22 (WebCore::WebGLRenderingContext::getParameter): 23 (WebCore::WebGLRenderingContext::handleNPOTTextures): 24 (WebCore::WebGLRenderingContext::validateTextureBinding): 25 (WebCore::WebGLRenderingContext::restoreCurrentTexture2D): 26 * html/canvas/WebGLRenderingContext.h: 27 1 28 2013-07-03 Christophe Dumez <ch.dumez@sisa.samsung.com> 2 29 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp
r151947 r152351 608 608 m_renderbufferBinding = 0; 609 609 610 for (size_t i = 0; i < m_textureUnits.size(); ++i) { 611 m_textureUnits[i].m_texture2DBinding = 0; 612 m_textureUnits[i].m_textureCubeMapBinding = 0; 613 } 610 for (size_t i = 0; i < m_textureUnits.size(); ++i) 611 m_textureUnits[i].m_textureBinding = 0; 614 612 615 613 m_blackTexture2D = 0; … … 817 815 m_context->reshape(width, height); 818 816 819 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, objectOrZero(m_textureUnits[m_activeTextureUnit].m_texture 2DBinding.get()));817 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, objectOrZero(m_textureUnits[m_activeTextureUnit].m_textureBinding.get())); 820 818 m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, objectOrZero(m_renderbufferBinding.get())); 821 819 if (m_framebufferBinding) … … 1015 1013 GC3Dint maxLevel = 0; 1016 1014 if (target == GraphicsContext3D::TEXTURE_2D) { 1017 m_textureUnits[m_activeTextureUnit].m_texture 2DBinding = texture;1015 m_textureUnits[m_activeTextureUnit].m_textureBinding = texture; 1018 1016 maxLevel = m_maxTextureLevel; 1019 1017 … … 1022 1020 1023 1021 } else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP) { 1024 m_textureUnits[m_activeTextureUnit].m_texture CubeMapBinding = texture;1022 m_textureUnits[m_activeTextureUnit].m_textureBinding = texture; 1025 1023 maxLevel = m_maxCubeMapTextureLevel; 1026 1024 } else { … … 1636 1634 return; 1637 1635 for (size_t i = 0; i < m_textureUnits.size(); ++i) { 1638 if (texture == m_textureUnits[i].m_texture2DBinding) 1639 m_textureUnits[i].m_texture2DBinding = 0; 1640 if (texture == m_textureUnits[i].m_textureCubeMapBinding) 1641 m_textureUnits[i].m_textureCubeMapBinding = 0; 1636 if (texture == m_textureUnits[i].m_textureBinding) 1637 m_textureUnits[i].m_textureBinding = 0; 1642 1638 } 1643 1639 if (m_framebufferBinding) … … 2693 2689 return getIntParameter(pname); 2694 2690 case GraphicsContext3D::TEXTURE_BINDING_2D: 2695 return WebGLGetInfo(PassRefPtr<WebGLTexture>(m_textureUnits[m_activeTextureUnit].m_texture 2DBinding));2691 return WebGLGetInfo(PassRefPtr<WebGLTexture>(m_textureUnits[m_activeTextureUnit].m_textureBinding)); 2696 2692 case GraphicsContext3D::TEXTURE_BINDING_CUBE_MAP: 2697 return WebGLGetInfo(PassRefPtr<WebGLTexture>(m_textureUnits[m_activeTextureUnit].m_texture CubeMapBinding));2693 return WebGLGetInfo(PassRefPtr<WebGLTexture>(m_textureUnits[m_activeTextureUnit].m_textureBinding)); 2698 2694 case GraphicsContext3D::UNPACK_ALIGNMENT: 2699 2695 return getIntParameter(pname); … … 4803 4799 bool resetActiveUnit = false; 4804 4800 for (unsigned ii = 0; ii < m_textureUnits.size(); ++ii) { 4805 if ((m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture()) 4806 || (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture())) { 4801 if (m_textureUnits[ii].m_textureBinding && m_textureUnits[ii].m_textureBinding->needToUseBlackTexture()) { 4807 4802 if (ii != m_activeTextureUnit) { 4808 4803 m_context->activeTexture(ii); … … 4812 4807 resetActiveUnit = false; 4813 4808 } 4814 WebGLTexture* tex 2D;4815 WebGLTexture* texCubeMap;4809 WebGLTexture* texture = 0; 4810 GC3Denum target = m_textureUnits[ii].m_textureBinding->getTarget(); 4816 4811 if (prepareToDraw) { 4817 4812 String msg(String("texture bound to texture unit ") + String::number(ii) 4818 4813 + " is not renderable. It maybe non-power-of-2 and have incompatible texture filtering or is not 'texture complete'"); 4819 4814 printGLWarningToConsole(functionName, msg.utf8().data()); 4820 tex2D = m_blackTexture2D.get(); 4821 texCubeMap = m_blackTextureCubeMap.get(); 4822 } else { 4823 tex2D = m_textureUnits[ii].m_texture2DBinding.get(); 4824 texCubeMap = m_textureUnits[ii].m_textureCubeMapBinding.get(); 4825 } 4826 if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture()) 4827 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, objectOrZero(tex2D)); 4828 if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture()) 4829 m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, objectOrZero(texCubeMap)); 4815 if (target == GraphicsContext3D::TEXTURE_2D) 4816 texture = m_blackTexture2D.get(); 4817 else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP) 4818 texture = m_blackTextureCubeMap.get(); 4819 } else 4820 texture = m_textureUnits[ii].m_textureBinding.get(); 4821 m_context->bindTexture(target, objectOrZero(texture)); 4830 4822 } 4831 4823 } … … 4892 4884 WebGLTexture* WebGLRenderingContext::validateTextureBinding(const char* functionName, GC3Denum target, bool useSixEnumsForCubeMap) 4893 4885 { 4894 WebGLTexture* tex = 0;4895 4886 switch (target) { 4896 4887 case GraphicsContext3D::TEXTURE_2D: 4897 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get();4898 4888 break; 4899 4889 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X: … … 4907 4897 return 0; 4908 4898 } 4909 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get();4910 4899 break; 4911 4900 case GraphicsContext3D::TEXTURE_CUBE_MAP: … … 4914 4903 return 0; 4915 4904 } 4916 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get();4917 4905 break; 4918 4906 default: … … 4920 4908 return 0; 4921 4909 } 4910 WebGLTexture* tex = m_textureUnits[m_activeTextureUnit].m_textureBinding.get(); 4922 4911 if (!tex) 4923 4912 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "no texture"); … … 6030 6019 { 6031 6020 ExceptionCode ec; 6032 bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureUnits[m_activeTextureUnit].m_texture 2DBinding.get(), ec);6021 bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureUnits[m_activeTextureUnit].m_textureBinding.get(), ec); 6033 6022 } 6034 6023 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h
r151947 r152351 450 450 RefPtr<WebGLFramebuffer> m_framebufferBinding; 451 451 RefPtr<WebGLRenderbuffer> m_renderbufferBinding; 452 class TextureUnitState { 453 public: 454 RefPtr<WebGLTexture> m_texture2DBinding; 455 RefPtr<WebGLTexture> m_textureCubeMapBinding; 452 struct TextureUnitState { 453 RefPtr<WebGLTexture> m_textureBinding; 456 454 }; 457 455 Vector<TextureUnitState> m_textureUnits;
Note: See TracChangeset
for help on using the changeset viewer.