diff options
author | Pierre-Antoine LaFayette <plafayet@codeaurora.org> | 2011-12-29 15:13:33 +0100 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2013-01-20 18:38:26 -0800 |
commit | 70f026a42cf1bee061389fa6ce790ea1186f0703 (patch) | |
tree | b0de5b5676433d2382e7cf1307b54edc19fc42a5 /Source/ThirdParty/ANGLE/src/libGLESv2/Context.h | |
parent | a815c626d7df7e24ba9e0df27c27735d4e069ffd (diff) | |
download | external_webkit-70f026a42cf1bee061389fa6ce790ea1186f0703.zip external_webkit-70f026a42cf1bee061389fa6ce790ea1186f0703.tar.gz external_webkit-70f026a42cf1bee061389fa6ce790ea1186f0703.tar.bz2 |
WebGL implementation for Android
Implementation of WebGL in Android WebKit. Exposes a low level 3D
graphics API based on OpenGL ES 2.0 to JavaScript. WebGL is not compiled
by default. It can be enabled by setting ENABLE_WEBGL = true in your
device BoardConfig.mk or directly in external/webkit/Android.mk.
Includes runtime enablement through Browser Settings -> Labs menu.
Enable WebGL debug logs and FPS timing with: adb shell setprop debug.webgl 1
Includes Cross-origin resource sharing support.
Includes fixes for the following Khronos WebGL 1.0.1. tests:
- premultiplyalpha-test.html
- struct-nesting-exceeds-maximum.html
- index-validation.html
- context-attributes-alpha-depth-stencil-antialias.html
- program-test.html
- object-deletion-behaviour.html
Squashed patches:
-----------------------------------------------------------
WebGL implementation for Android
Implementation of WebGL in Android WebKit. Exposes a low level 3D
graphics API based on OpenGL ES 2.0 to JavaScript. WebGL is not compiled
by default. It can be enabled by setting ENABLE_WEBGL = true in your
device BoardConfig.mk or directly in external/webkit/Android.mk. It is
also disabled by default (in WebSettings.cpp) as required by Khronos
until it reaches 100% conformance.
--
From: Anders Edenbrandt <anders.edenbrandt@sonyericsson.com>
Date: Thu, 26 Jan 2012 11:48:41 +0100
WebGL bug fixes and updates
Some updates:
- stability fixes
- image decoder
- redesign of how the FBOs are used
- other bug fixes
--
From: Anders Edenbrandt <anders.edenbrandt@sonyericsson.com>
Date: Tue, 31 Jan 2012 17:20:13 +0100
WebGL code cleanup and bug fixes
--
From: Anders Edenbrandt <anders.edenbrandt@sonyericsson.com>
Date: Thu Mar 15 10:15:33 2012 +0100
More improvements and bug fixes
Updates:
- cleaned up buffer handling, allowing for arbitrary number of buffers
- removed rect from invalidation
- removed screen update request from drawGL
- releasing buffers when the browser is paused
- added missing method 'slice' for typed arrays
- fixed bug in bindFramebuffer
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=c72ff2aa562941d94ceb51ba685d60809ca882a6
Updates to fix some test failures in Khronos Conformance Test Suite:
- Increase max identifier length in shaders to 256
- Add length check on uniforms and attributes
- Add minimal support for compressed textures
(that is, just return the correct error codes)
- Add support for Uint8ClampedByteArray
- Modify how error checking is done on framebuffer operations
- Activate the GL_OES_packed_depth_stencil extension
- Activate the GL_OES_texture_float extension
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=5bfe05848c12a2894697fbb503cfa79981eb96bd
Fix WebGL 1.0.1 premultiplyalpha-test conformance test
Fixing bug with toDataURL when called against a Canvas in which WebGL
content is being rendered and make sure paintRenderingResultsToImageData
isn't used for the premultiplied case.
ihttps://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=5834a1e00f89d898a7a0039d47916b196e40a2c8
Update ANGLE to r1009 to fix WebGL 1.0.1 conformance test
Fixes struct-nesting-exceeds-maximum Khronos WebGL conformance test.
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=ae2392db6360b41a5717f3770a9e63b1bcea45d6
vertexAttribPointer needs to reject large negative offsets
https://bugs.webkit.org/show_bug.cgi?id=85117
Reviewed by Kenneth Russell.
Source/WebCore:
* html/canvas/WebGLRenderingContext.cpp: Use long long for GLsizeiptr and GLintptr
(WebCore):
(WebCore::WebGLRenderingContext::bufferData):
(WebCore::WebGLRenderingContext::bufferSubData):
(WebCore::WebGLRenderingContext::drawElements):
(WebCore::WebGLRenderingContext::getVertexAttribOffset):
(WebCore::WebGLRenderingContext::vertexAttribPointer):
* html/canvas/WebGLRenderingContext.h: Ditto
(WebGLRenderingContext):
* html/canvas/WebGLRenderingContext.idl: Ditto
LayoutTests:
* fast/canvas/webgl/index-validation-expected.txt:
* fast/canvas/webgl/index-validation.html: Add a test case for large negative offset.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@116374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=b3a02a0942a0e2c44d23961382145fad6016b2ef
Fix for context-attributes-alpha-depth-stencil-antialias
Support for alpha, depth and stencil to fix WebGL Khronos 1.0.1
conformance test. Report back that antialiasing is not supported on our
platform.
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=22e98195ac73e7e12a59d5b9a42dfc4e2252b475
WebGLRenderingContext should defer caching program info
https://bugs.webkit.org/show_bug.cgi?id=83513
Reviewed by Kenneth Russell.
* html/canvas/WebGLProgram.cpp:
(WebCore::WebGLProgram::WebGLProgram):
(WebCore::WebGLProgram::numActiveAttribLocations): call cacheInfoIfNeeded();
(WebCore::WebGLProgram::getActiveAttribLocation): Ditto.
(WebCore::WebGLProgram::isUsingVertexAttrib0): Ditto.
(WebCore::WebGLProgram::getLinkStatus): Ditto.
(WebCore):
(WebCore::WebGLProgram::cacheActiveAttribLocations):
(WebCore::WebGLProgram::cacheInfoIfNeeded): Cache link status, active attire locations, etc if needed.
(WebCore::WebGLProgram::increaseLinkCount): also invalidate cached info.
* html/canvas/WebGLProgram.h:
(WebGLProgram):
* html/canvas/WebGLRenderingContext.cpp:
(WebCore):
(WebCore::WebGLRenderingContext::linkProgram): Do not cache program info immediately.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113915 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=66bc9c1b9eb5151b1b236199d0eeb17df0557b47
Runtime enablement of WebGL
Hooks up with the Java side to enable/disable WebGL through the debug
menu.
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=75aab57859de45a0aaec5a7cad41a12111e9a82e
Support the usage of CORS for WebGL and the 2D canvas
Factor CORS request preparation out of DocumentThreadableLoader
https://bugs.webkit.org/show_bug.cgi?id=61209
2011-05-20 Adam Barth <abarth@webkit.org>
Reviewed by Alexey Proskuryakov.
Factor CORS request preparation out of DocumentThreadableLoader
https://bugs.webkit.org/show_bug.cgi?id=61209
DocumentThreadableLoader has two jobs:
1) Proxy loads between threads.
2) Run the CORS state machine.
This patch begins the work of separating those concerns, allowing CORS
to be used elsewhere in the loading pipeline. In particular, this
patch moves knowledge of how to prepare CORS requests out of
DocumentThreadableLoder.
* loader/CrossOriginAccessControl.cpp:
(WebCore::isOnAccessControlSimpleRequestHeaderWhitelist):
(WebCore::updateRequestForAccessControl):
(WebCore::createAccessControlPreflightRequest):
* loader/CrossOriginAccessControl.h:
* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
(WebCore::DocumentThreadableLoader::makeSimpleCrossOriginAccessRequest):
(WebCore::DocumentThreadableLoader::makeCrossOriginAccessRequestWithPreflight):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86980 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add rel type prerender to distinguish prerender from prefetch
https://bugs.webkit.org/show_bug.cgi?id=61079
2011-05-21 Gavin Peters <gavinp@chromium.org>
Reviewed by Adam Barth.
Add rel type prerender to distinguish prerender from prefetch
https://bugs.webkit.org/show_bug.cgi?id=61079
Chrome right now uses <link rel=prefetch ...> for one of two things,
to warm the cache in the same way as firefox, or to launch a speculative
rendering of a web page, for faster "loading" when the user navigates to it.
This new rel type will let us distinguish the two cases; the rel type prerender
isn't used on the web today, but the Google Web Search example prerendering application
is ready to experiment with it.
* fast/dom/HTMLLinkElement/prerender-expected.txt: Added.
* fast/dom/HTMLLinkElement/prerender.html: Added.
* platform/gtk/Skipped:
* platform/mac/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
2011-05-21 Gavin Peters <gavinp@chromium.org>
Reviewed by Adam Barth.
Add rel type prerender to distinguish prerender from prefetch
https://bugs.webkit.org/show_bug.cgi?id=61079
Chrome right now uses <link rel=prefetch ...> for one of two things,
to warm the cache in the same way as firefox, or to launch a speculative
rendering of a web page, for faster "loading" when the user navigates to it.
This new rel type will let us distinguish the two cases; the rel type prerender
isn't used on the web today, but the Google Web Search example prerendering application
is ready to experiment with it.
Test: fast/dom/HTMLLinkElement/prerender.html
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::tokenizeRelAttribute):
(WebCore::HTMLLinkElement::process):
* html/HTMLLinkElement.h:
(WebCore::HTMLLinkElement::RelAttribute::RelAttribute):
* loader/cache/CachedResource.cpp:
(WebCore::defaultPriorityForResourceType):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::isLinkResource):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::createResource):
(WebCore::CachedResourceLoader::requestLinkResource):
(WebCore::CachedResourceLoader::canRequest):
* loader/cache/CachedResourceLoader.h:
* loader/cache/CachedResourceRequest.cpp:
(WebCore::cachedResourceTypeToTargetType):
(WebCore::CachedResourceRequest::load):
* platform/network/ResourceRequestBase.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@87020 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Make CachedResource take a ResourceRequest instead of just a url string.
2011-05-24 Nate Chapin <japhet@chromium.org>
Reviewed by Adam Barth.
Change CachedResources to take a ResourceRequest instead of
a url in their constructors and provide a very minimal set of
cases for avoiding reusing a CachedResource. The ResourceRequest
part of this change requires pushing responsibility
for calling Document::completeURL() to the caller, instead of
CachedResourceLoader, since ResourceRequest ASSERTs if it
is constructed with an invalid url.
https://bugs.webkit.org/show_bug.cgi?id=61318
Refactor, no new tests.
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::addFontFaceRule):
* css/CSSImageValue.cpp:
(WebCore::CSSImageValue::cachedImage):
* css/CSSImportRule.cpp:
(WebCore::CSSImportRule::insertedIntoParent):
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::checkStyleSheet):
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::requestScript):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process):
* loader/ImageLoader.cpp:
(WebCore::ImageLoader::updateFromElement):
* loader/cache/CachedCSSStyleSheet.cpp:
(WebCore::CachedCSSStyleSheet::CachedCSSStyleSheet):
(WebCore::CachedCSSStyleSheet::didAddClient):
(WebCore::CachedCSSStyleSheet::checkNotify):
* loader/cache/CachedCSSStyleSheet.h:
* loader/cache/CachedFont.cpp:
(WebCore::CachedFont::CachedFont):
* loader/cache/CachedFont.h:
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::CachedImage):
(WebCore::CachedImage::checkShouldPaintBrokenImage):
* loader/cache/CachedImage.h:
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::CachedResource):
(WebCore::reuseRequest):
(WebCore::CachedResource::allowReuseOfRequest):
(WebCore::CachedResource::removeClient):
(WebCore::CachedResource::canUseCacheValidator):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::resourceRequest):
(WebCore::CachedResource::url):
* loader/cache/CachedResourceLoader.cpp:
* loader/cache/CachedResourceLoader.h:
* loader/cache/CachedResourceRequest.cpp:
(WebCore::CachedResourceRequest::load):
* loader/cache/CachedScript.cpp:
(WebCore::CachedScript::CachedScript):
* loader/cache/CachedScript.h:
* loader/cache/CachedXSLStyleSheet.cpp:
(WebCore::CachedXSLStyleSheet::CachedXSLStyleSheet):
(WebCore::CachedXSLStyleSheet::didAddClient):
(WebCore::CachedXSLStyleSheet::checkNotify):
* loader/cache/CachedXSLStyleSheet.h:
* svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::requestImageResource):
* svg/SVGFontFaceUriElement.cpp:
(WebCore::SVGFontFaceUriElement::loadFont):
* xml/XSLImportRule.cpp:
(WebCore::XSLImportRule::loadSheet):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@87239 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Support cross-origin property for images
2011-05-26 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel.
Support cross-origin property for images
https://bugs.webkit.org/show_bug.cgi?id=61015
Test various cases involving CORS requests and canvas tainting.
* http/tests/security/canvas-remote-read-remote-image-allowed-expected.txt: Added.
* http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials-expected.txt: Added.
* http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials.html: Added.
* http/tests/security/canvas-remote-read-remote-image-allowed.html: Added.
* http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin-expected.txt: Added.
* http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin.html: Added.
* http/tests/security/resources/abe-allow-credentials.php: Added.
* http/tests/security/resources/abe-allow-star.php: Added.
2011-05-26 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel.
Support cross-origin property for images
https://bugs.webkit.org/show_bug.cgi?id=61015
This patch add support for the crossorigin attribute of images and
teaches 2D canvas to respect that flag and not taint a canvas if the
image drawn on the canvas is allowed by CORS.
While I was editing this code, I couldn't resist a couple touch-up
changes.
Tests: http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials.html
http/tests/security/canvas-remote-read-remote-image-allowed.html
http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin.html
* html/HTMLAttributeNames.in:
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::securityOrigin):
* html/HTMLCanvasElement.h:
* html/HTMLImageElement.idl:
* html/canvas/CanvasRenderingContext.cpp:
(WebCore::CanvasRenderingContext::checkOrigin):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::createPattern):
* loader/ImageLoader.cpp:
(WebCore::ImageLoader::updateFromElement):
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::passesAccessControlCheck):
* loader/cache/CachedResource.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@87473 268f45cc-cd09-0410-ab3c-d52691b4dbfc
HTMLVideoElement::currentSrc() should return a KURL
2011-05-27 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel.
HTMLVideoElement::currentSrc() should return a KURL
https://bugs.webkit.org/show_bug.cgi?id=61578
I suspect we got into this mess because the author of this code didn't
know about the URL attribute in WebKit IDL, which is super useful!
Bad news: The line of code in question seems to have another bug, which
I've documented in a FIXME. Let the yak shaving continue!
* html/HTMLMediaElement.cpp:
(WebCore::urlForLogging):
(WebCore::HTMLMediaElement::loadResource):
(WebCore::HTMLMediaElement::isSafeToLoadURL):
(WebCore::HTMLMediaElement::selectNextSourceChild):
(WebCore::HTMLMediaElement::getPluginProxyParams):
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::currentSrc):
(WebCore::HTMLMediaElement::currentURL):
* html/canvas/CanvasRenderingContext.cpp:
(WebCore::CanvasRenderingContext::checkOrigin):
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::absoluteMediaURL):
- This complete URL call was unnecessary because currentSrc is
already absolute.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@87539 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Disallow use of cross-domain media (images, video) in WebGL
2011-06-09 Kenneth Russell <kbr@google.com>
Reviewed by Adam Barth.
Disallow use of cross-domain media (images, video) in WebGL
https://bugs.webkit.org/show_bug.cgi?id=62257
Updated WebGL implementation to track recent spec updates in this area.
Tests: http/tests/security/webgl-remote-read-remote-image-allowed-with-credentials.html
http/tests/security/webgl-remote-read-remote-image-allowed.html
http/tests/security/webgl-remote-read-remote-image-blocked-no-crossorigin.html
* html/canvas/CanvasRenderingContext.cpp:
(WebCore::CanvasRenderingContext::wouldTaintOrigin):
(WebCore::CanvasRenderingContext::checkOrigin):
* html/canvas/CanvasRenderingContext.h:
(WebCore::CanvasRenderingContext::checkOrigin):
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::readPixels):
(WebCore::WebGLRenderingContext::texImage2D):
(WebCore::WebGLRenderingContext::videoFrameToImage):
(WebCore::WebGLRenderingContext::texSubImage2D):
* html/canvas/WebGLRenderingContext.h:
2011-06-09 Kenneth Russell <kbr@google.com>
Reviewed by Adam Barth.
Disallow use of cross-domain media (images, video) in WebGL
https://bugs.webkit.org/show_bug.cgi?id=62257
Updated origin-clean-conformance.html to track upstream version in
Khronos repository. Added new layout tests mirroring those added
in bug 61015 which verify that new CORS support for images is
working in the context of WebGL.
Verified new tests in WebKit and Chromium. Skipped tests on
platforms where WebGL is disabled.
* http/tests/canvas/webgl/origin-clean-conformance-expected.txt:
* http/tests/canvas/webgl/origin-clean-conformance.html:
* http/tests/security/webgl-remote-read-remote-image-allowed-expected.txt: Added.
* http/tests/security/webgl-remote-read-remote-image-allowed-with-credentials-expected.txt: Added.
* http/tests/security/webgl-remote-read-remote-image-allowed-with-credentials.html: Added.
* http/tests/security/webgl-remote-read-remote-image-allowed.html: Added.
* http/tests/security/webgl-remote-read-remote-image-blocked-no-crossorigin-expected.txt: Added.
* http/tests/security/webgl-remote-read-remote-image-blocked-no-crossorigin.html: Added.
* platform/gtk/Skipped:
* platform/mac-leopard/Skipped:
* platform/mac-wk2/Skipped:
* platform/qt/Skipped:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@88489 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=0ddd7c1d91c08fbee6c99b79fa9971a7ac914384
Runtime enablement of WebGL logs
Allows enabling WebGL method level logging using:
adb shell setprop debug.webgl 1
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=307d4a2b5b20f2609497ceaea1eca2e29a8a781f
Adding WebGL FPS timing to logs
Samples WebGL average FPS every 15 frames and outputs to WebGL debug log.
TODO: Add setting to browser debug settings that overlays FPS on web
pages.
Postpone deleteRenderbuffer/deleteTexture until all framebuffer attachment points are removed.
https://bugs.webkit.org/show_bug.cgi?id=74741
Reviewed by Kenneth Russell.
Source/WebCore:
Use WebGLObject's attachment count mechanism to track if a renderbuffer/texture
is still attached to framebuffers, and if its deletion should be delated or not.
* html/canvas/WebGLFramebuffer.cpp:
(WebCore::WebGLFramebuffer::setAttachmentForBoundFramebuffer):
(WebCore::WebGLFramebuffer::getAttachment):
(WebCore::WebGLFramebuffer::removeAttachmentFromBoundFramebuffer):
(WebCore::WebGLFramebuffer::deleteObjectImpl):
(WebCore::WebGLFramebuffer::isBound):
* html/canvas/WebGLFramebuffer.h:
LayoutTests:
* fast/canvas/webgl/object-deletion-behaviour-expected.txt:
* fast/canvas/webgl/object-deletion-behaviour.html: synced with khronos side.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@103272 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=9def386340c74f2a745fb041b1cb11daa30d1a82
-----------------------------------------------------------
(cherry-picked from commit 6d9d732ff06a6b265d02b18d7034068a68ef0fde)
Conflicts:
Android.mk
Source/WebCore/ChangeLog
Change-Id: I3bbf993fe5a3d6cea53e019c8fa3912ecd2bd429
Diffstat (limited to 'Source/ThirdParty/ANGLE/src/libGLESv2/Context.h')
-rw-r--r-- | Source/ThirdParty/ANGLE/src/libGLESv2/Context.h | 217 |
1 files changed, 166 insertions, 51 deletions
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h b/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h index 2906664..8dccf0f 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -18,10 +18,12 @@ #include <d3d9.h> #include <map> +#include <hash_map> #include "common/angleutils.h" +#include "common/RefCountObject.h" #include "libGLESv2/ResourceManager.h" -#include "libGLESv2/RefCountObject.h" +#include "libGLESv2/HandleAllocator.h" namespace egl { @@ -46,23 +48,29 @@ class Renderbuffer; class RenderbufferStorage; class Colorbuffer; class Depthbuffer; +class StreamingIndexBuffer; class Stencilbuffer; class DepthStencilbuffer; class VertexDataManager; class IndexDataManager; class Blit; class Fence; +class Query; enum { + D3D9_MAX_FLOAT_CONSTANTS = 256, + D3D9_MAX_BOOL_CONSTANTS = 16, + D3D9_MAX_INT_CONSTANTS = 16, + MAX_VERTEX_ATTRIBS = 16, - MAX_VERTEX_UNIFORM_VECTORS = 256 - 2, // 256 is the minimum for SM2, and in practice the maximum for DX9. Reserve space for dx_HalfPixelSize and dx_DepthRange. + MAX_VERTEX_UNIFORM_VECTORS = D3D9_MAX_FLOAT_CONSTANTS - 2, // Reserve space for dx_HalfPixelSize and dx_DepthRange. MAX_VARYING_VECTORS_SM2 = 8, MAX_VARYING_VECTORS_SM3 = 10, - MAX_COMBINED_TEXTURE_IMAGE_UNITS = 16, - MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0, MAX_TEXTURE_IMAGE_UNITS = 16, - MAX_FRAGMENT_UNIFORM_VECTORS_SM2 = 32 - 3, // Reserve space for dx_Viewport, dx_Depth, and dx_DepthRange. dx_PointOrLines and dx_FrontCCW use separate bool registers. + MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF = 4, // For devices supporting vertex texture fetch + MAX_COMBINED_TEXTURE_IMAGE_UNITS_VTF = MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF, + MAX_FRAGMENT_UNIFORM_VECTORS_SM2 = 32 - 3, // Reserve space for dx_Coord, dx_Depth, and dx_DepthRange. dx_PointOrLines and dx_FrontCCW use separate bool registers. MAX_FRAGMENT_UNIFORM_VECTORS_SM3 = 224 - 3, MAX_DRAW_BUFFERS = 1, @@ -70,6 +78,14 @@ enum IMPLEMENTATION_COLOR_READ_TYPE = GL_UNSIGNED_SHORT_5_6_5 }; +enum QueryType +{ + QUERY_ANY_SAMPLES_PASSED, + QUERY_ANY_SAMPLES_PASSED_CONSERVATIVE, + + QUERY_TYPE_COUNT +}; + const float ALIASED_LINE_WIDTH_RANGE_MIN = 1.0f; const float ALIASED_LINE_WIDTH_RANGE_MAX = 1.0f; const float ALIASED_POINT_SIZE_RANGE_MIN = 1.0f; @@ -88,7 +104,7 @@ struct Color class VertexAttribute { public: - VertexAttribute() : mType(GL_FLOAT), mSize(0), mNormalized(false), mStride(0), mPointer(NULL), mArrayEnabled(false) + VertexAttribute() : mType(GL_FLOAT), mSize(0), mNormalized(false), mStride(0), mPointer(NULL), mArrayEnabled(false), mDivisor(0) { mCurrentValue[0] = 0.0f; mCurrentValue[1] = 0.0f; @@ -131,6 +147,7 @@ class VertexAttribute bool mArrayEnabled; // From glEnable/DisableVertexAttribArray float mCurrentValue[4]; // From glVertexAttrib + unsigned int mDivisor; }; typedef VertexAttribute VertexAttributeArray[MAX_VERTEX_ATTRIBS]; @@ -203,7 +220,7 @@ struct State bool colorMaskAlpha; bool depthMask; - int activeSampler; // Active texture unit selector - GL_TEXTURE0 + unsigned int activeSampler; // Active texture unit selector - GL_TEXTURE0 BindingPointer<Buffer> arrayBuffer; BindingPointer<Buffer> elementArrayBuffer; GLuint readFramebuffer; @@ -212,16 +229,53 @@ struct State GLuint currentProgram; VertexAttribute vertexAttribute[MAX_VERTEX_ATTRIBS]; - BindingPointer<Texture> samplerTexture[SAMPLER_TYPE_COUNT][MAX_TEXTURE_IMAGE_UNITS]; + BindingPointer<Texture> samplerTexture[TEXTURE_TYPE_COUNT][MAX_COMBINED_TEXTURE_IMAGE_UNITS_VTF]; + BindingPointer<Query> activeQuery[QUERY_TYPE_COUNT]; GLint unpackAlignment; GLint packAlignment; + bool packReverseRowOrder; +}; + +// Helper class to construct and cache vertex declarations +class VertexDeclarationCache +{ + public: + VertexDeclarationCache(); + ~VertexDeclarationCache(); + + GLenum applyDeclaration(IDirect3DDevice9 *device, TranslatedAttribute attributes[], Program *program, GLsizei instances, GLsizei *repeatDraw); + + void markStateDirty(); + + private: + UINT mMaxLru; + + enum { NUM_VERTEX_DECL_CACHE_ENTRIES = 16 }; + + struct VBData + { + unsigned int serial; + unsigned int stride; + unsigned int offset; + }; + + VBData mAppliedVBs[MAX_VERTEX_ATTRIBS]; + IDirect3DVertexDeclaration9 *mLastSetVDecl; + bool mInstancingEnabled; + + struct VertexDeclCacheEntry + { + D3DVERTEXELEMENT9 cachedElements[MAX_VERTEX_ATTRIBS + 1]; + UINT lruCount; + IDirect3DVertexDeclaration9 *vertexDeclaration; + } mVertexDeclCache[NUM_VERTEX_DECL_CACHE_ENTRIES]; }; class Context { public: - Context(const egl::Config *config, const gl::Context *shareContext); + Context(const egl::Config *config, const gl::Context *shareContext, bool notifyResets, bool robustAccess); ~Context(); @@ -229,6 +283,9 @@ class Context void markAllStateDirty(); + virtual void markContextLost(); + bool isContextLost(); + // State manipulation void setClearColor(float red, float green, float blue, float alpha); @@ -298,7 +355,7 @@ class Context void setColorMask(bool red, bool green, bool blue, bool alpha); void setDepthMask(bool mask); - void setActiveSampler(int active); + void setActiveSampler(unsigned int active); GLuint getReadFramebufferHandle() const; GLuint getDrawFramebufferHandle() const; @@ -306,6 +363,8 @@ class Context GLuint getArrayBufferHandle() const; + GLuint getActiveQuery(GLenum target) const; + void setEnableVertexAttribArray(unsigned int attribNum, bool enabled); const VertexAttribute &getVertexAttribState(unsigned int attribNum); void setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type, @@ -320,6 +379,9 @@ class Context void setPackAlignment(GLint alignment); GLint getPackAlignment() const; + void setPackReverseRowOrder(bool reverseRowOrder); + bool getPackReverseRowOrder() const; + // These create and destroy methods are merely pass-throughs to // ResourceManager, which owns these object types GLuint createBuffer(); @@ -341,6 +403,10 @@ class Context // Fences are owned by the Context. GLuint createFence(); void deleteFence(GLuint fence); + + // Queries are owned by the Context; + GLuint createQuery(); + void deleteQuery(GLuint query); void bindArrayBuffer(GLuint buffer); void bindElementArrayBuffer(GLuint buffer); @@ -351,11 +417,15 @@ class Context void bindRenderbuffer(GLuint renderbuffer); void useProgram(GLuint program); + void beginQuery(GLenum target, GLuint query); + void endQuery(GLenum target); + void setFramebufferZero(Framebuffer *framebuffer); void setRenderbufferStorage(RenderbufferStorage *renderbuffer); void setVertexAttrib(GLuint index, const GLfloat *values); + void setVertexAttribDivisor(GLuint index, GLuint divisor); Buffer *getBuffer(GLuint handle); Fence *getFence(GLuint handle); @@ -364,13 +434,14 @@ class Context Texture *getTexture(GLuint handle); Framebuffer *getFramebuffer(GLuint handle); Renderbuffer *getRenderbuffer(GLuint handle); + Query *getQuery(GLuint handle, bool create, GLenum type); Buffer *getArrayBuffer(); Buffer *getElementArrayBuffer(); Program *getCurrentProgram(); Texture2D *getTexture2D(); TextureCubeMap *getTextureCubeMap(); - Texture *getSamplerTexture(unsigned int sampler, SamplerType type); + Texture *getSamplerTexture(unsigned int sampler, TextureType type); Framebuffer *getReadFramebuffer(); Framebuffer *getDrawFramebuffer(); @@ -380,23 +451,13 @@ class Context bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams); - bool applyRenderTarget(bool ignoreViewport); - void applyState(GLenum drawMode); - GLenum applyVertexBuffer(GLint first, GLsizei count); - GLenum applyIndexBuffer(const void *indices, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo); - void applyShaders(); - void applyTextures(); - - void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels); + void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei *bufSize, void* pixels); void clear(GLbitfield mask); - void drawArrays(GLenum mode, GLint first, GLsizei count); - void drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices); - void finish(); - void flush(); + void drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances); + void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instances); + void sync(bool block); // flush/finish - // Draw the last segment of a line loop - void drawClosingLine(unsigned int first, unsigned int last); - void drawClosingLine(GLsizei count, GLenum type, const void *indices); + void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex); void recordInvalidEnum(); void recordInvalidValue(); @@ -405,9 +466,13 @@ class Context void recordInvalidFramebufferOperation(); GLenum getError(); + GLenum getResetStatus(); + virtual bool isResetNotificationEnabled(); bool supportsShaderModel3() const; int getMaximumVaryingVectors() const; + unsigned int getMaximumVertexTextureImageUnits() const; + unsigned int getMaximumCombinedTextureImageUnits() const; int getMaximumFragmentUniformVectors() const; int getMaximumRenderbufferDimension() const; int getMaximumTextureDimension() const; @@ -416,17 +481,23 @@ class Context GLsizei getMaxSupportedSamples() const; int getNearestSupportedSamples(D3DFORMAT format, int requested) const; const char *getExtensionString() const; + const char *getRendererString() const; bool supportsEventQueries() const; - bool supportsCompressedTextures() const; - bool supportsFloatTextures() const; - bool supportsFloatLinearFilter() const; - bool supportsFloatRenderableTextures() const; - bool supportsHalfFloatTextures() const; - bool supportsHalfFloatLinearFilter() const; - bool supportsHalfFloatRenderableTextures() const; + bool supportsOcclusionQueries() const; + bool supportsDXT1Textures() const; + bool supportsDXT3Textures() const; + bool supportsDXT5Textures() const; + bool supportsFloat32Textures() const; + bool supportsFloat32LinearFilter() const; + bool supportsFloat32RenderableTextures() const; + bool supportsFloat16Textures() const; + bool supportsFloat16LinearFilter() const; + bool supportsFloat16RenderableTextures() const; bool supportsLuminanceTextures() const; bool supportsLuminanceAlphaTextures() const; bool supports32bitIndices() const; + bool supportsNonPower2Texture() const; + bool supportsInstancing() const; void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, @@ -439,40 +510,59 @@ class Context private: DISALLOW_COPY_AND_ASSIGN(Context); - void lookupAttributeMapping(TranslatedAttribute *attributes); + bool applyRenderTarget(bool ignoreViewport); + void applyState(GLenum drawMode); + GLenum applyVertexBuffer(GLint first, GLsizei count, GLsizei instances, GLsizei *repeatDraw); + GLenum applyIndexBuffer(const GLvoid *indices, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo); + void applyShaders(); + void applyTextures(); + void applyTextures(SamplerType type); void detachBuffer(GLuint buffer); void detachTexture(GLuint texture); void detachFramebuffer(GLuint framebuffer); void detachRenderbuffer(GLuint renderbuffer); - Texture *getIncompleteTexture(SamplerType type); + Texture *getIncompleteTexture(TextureType type); bool cullSkipsDraw(GLenum drawMode); bool isTriangleMode(GLenum drawMode); + void initExtensionString(); + void initRendererString(); + const egl::Config *const mConfig; + egl::Display *mDisplay; + IDirect3DDevice9 *mDevice; - State mState; + State mState; BindingPointer<Texture2D> mTexture2DZero; BindingPointer<TextureCubeMap> mTextureCubeMapZero; - typedef std::map<GLuint, Framebuffer*> FramebufferMap; + typedef stdext::hash_map<GLuint, Framebuffer*> FramebufferMap; FramebufferMap mFramebufferMap; + HandleAllocator mFramebufferHandleAllocator; - typedef std::map<GLuint, Fence*> FenceMap; + typedef stdext::hash_map<GLuint, Fence*> FenceMap; FenceMap mFenceMap; + HandleAllocator mFenceHandleAllocator; + + typedef stdext::hash_map<GLuint, Query*> QueryMap; + QueryMap mQueryMap; + HandleAllocator mQueryHandleAllocator; - void initExtensionString(); std::string mExtensionString; + std::string mRendererString; VertexDataManager *mVertexDataManager; IndexDataManager *mIndexDataManager; Blit *mBlit; + + StreamingIndexBuffer *mLineLoopIB; - BindingPointer<Texture> mIncompleteTextures[SAMPLER_TYPE_COUNT]; + BindingPointer<Texture> mIncompleteTextures[TEXTURE_TYPE_COUNT]; // Recorded errors bool mInvalidEnum; @@ -481,15 +571,33 @@ class Context bool mOutOfMemory; bool mInvalidFramebufferOperation; + // Current/lost context flags bool mHasBeenCurrent; - - unsigned int mAppliedProgram; + bool mContextLost; + GLenum mResetStatus; + GLenum mResetStrategy; + bool mRobustAccess; + + unsigned int mAppliedTextureSerialPS[MAX_TEXTURE_IMAGE_UNITS]; + unsigned int mAppliedTextureSerialVS[MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF]; + unsigned int mAppliedProgramSerial; unsigned int mAppliedRenderTargetSerial; unsigned int mAppliedDepthbufferSerial; unsigned int mAppliedStencilbufferSerial; + unsigned int mAppliedIBSerial; bool mDepthStencilInitialized; + bool mViewportInitialized; + D3DVIEWPORT9 mSetViewport; + bool mRenderTargetDescInitialized; + D3DSURFACE_DESC mRenderTargetDesc; + bool mDxUniformsDirty; + Program *mCachedCurrentProgram; + Framebuffer *mBoundDrawFramebuffer; bool mSupportsShaderModel3; + bool mSupportsVertexTexture; + bool mSupportsNonPower2Texture; + bool mSupportsInstancing; int mMaxRenderbufferDimension; int mMaxTextureDimension; int mMaxCubeTextureDimension; @@ -497,16 +605,20 @@ class Context std::map<D3DFORMAT, bool *> mMultiSampleSupport; GLsizei mMaxSupportedSamples; bool mSupportsEventQueries; - bool mSupportsCompressedTextures; - bool mSupportsFloatTextures; - bool mSupportsFloatLinearFilter; - bool mSupportsFloatRenderableTextures; - bool mSupportsHalfFloatTextures; - bool mSupportsHalfFloatLinearFilter; - bool mSupportsHalfFloatRenderableTextures; + bool mSupportsOcclusionQueries; + bool mSupportsDXT1Textures; + bool mSupportsDXT3Textures; + bool mSupportsDXT5Textures; + bool mSupportsFloat32Textures; + bool mSupportsFloat32LinearFilter; + bool mSupportsFloat32RenderableTextures; + bool mSupportsFloat16Textures; + bool mSupportsFloat16LinearFilter; + bool mSupportsFloat16RenderableTextures; bool mSupportsLuminanceTextures; bool mSupportsLuminanceAlphaTextures; bool mSupports32bitIndices; + int mNumCompressedTextureFormats; // state caching flags bool mClearStateDirty; @@ -527,17 +639,20 @@ class Context D3DCAPS9 mDeviceCaps; ResourceManager *mResourceManager; + + VertexDeclarationCache mVertexDeclarationCache; }; } extern "C" { // Exported functions for use by EGL -gl::Context *glCreateContext(const egl::Config *config, const gl::Context *shareContext); +gl::Context *glCreateContext(const egl::Config *config, const gl::Context *shareContext, bool notifyResets, bool robustAccess); void glDestroyContext(gl::Context *context); void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *surface); gl::Context *glGetCurrentContext(); __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname); +bool __stdcall glBindTexImage(egl::Surface *surface); } #endif // INCLUDE_CONTEXT_H_ |