summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libGLESv2
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@intopalo.com>2015-04-08 17:04:36 +0300
committerAndrew Knight <qt@panimo.net>2015-04-09 10:31:12 +0000
commita218a252c4200cfe7048de81a46f7e48349084d5 (patch)
treec1a82865d97e610cd0abb3a1360408363b38205b /src/3rdparty/angle/src/libGLESv2
parent331ddacfca90c91c5b44484bf3c78e2aa5b85947 (diff)
Upgrade ANGLE to 2.1~99f075dade7c
This aligns with Chromium branch 2356. This version brings more complete OpenGL ES 3 support as well as various bug fixes and performance improvements. The following changes were made to earlier patches: -0000-General-fixes-for-ANGLE-2.1 Removed. All changes are now handled elsewhere. +0001-ANGLE-Improve-Windows-Phone-support Consolidated remaining parts from 0009/0010. +0002-ANGLE-Fix-compilation-with-MinGW Remaining issues from patch 0016. +0003-ANGLE-Fix-compilation-with-MSVC2010 Remaining issues from patch 0015. +0004-ANGLE-Dynamically-load-D3D-compiler-from-list Renamed from patch 0008. +0005-ANGLE-Add-support-for-querying-platform-device Renamed from patch 0013. -0004-Make-it-possible-to-link-ANGLE-statically-for-single Removed. Fixed by adding defines to project files. -0008-ANGLE-Dynamically-load-D3D-compiler-from-a-list-or-t Renamed to patch 0005. -0009-ANGLE-Support-WinRT Removed. Mostly fixed upstream; remaining parts in patch 0001. -0010-ANGLE-Enable-D3D11-for-feature-level-9-cards Removed. Mostly fixed upstream; remaining parts in patch 0001. -0012-ANGLE-fix-semantic-index-lookup Removed. Fixed upstream. -0013-ANGLE-Add-support-for-querying-platform-device Renamed to patch 0005. -0014-Let-ANGLE-use-multithreaded-devices-if-necessary Removed. No longer needed. -0015-ANGLE-Fix-angle-d3d11-on-MSVC2010 Moved remaining parts to patch 0003. -0016-ANGLE-Fix-compilation-with-MinGW-D3D11 Moved remaining parts to patch 0002. -0017-ANGLE-Fix-compilation-with-D3D9 Removed. Fixed upstream. -0018-ANGLE-Fix-releasing-textures-after-we-kill-D3D11 Removed. Fixed upstream. -0019-ANGLE-Fix-handling-of-shader-source-with-fixed-lengt Removed. Fixed upstream. -0020-ANGLE-Do-not-use-std-strlen Removed. Fixed upstream. -0020-ANGLE-Fix-compilation-with-MSVC2013-Update4 Removed. Fixed upstream. [ChangeLog][Third-party libraries] ANGLE was updated to Chromium branch 2356 (2.1~99f075dade7c). Change-Id: I32ccbfe95e10986bd94be7191dfd53445ea09158 Task-number: QTBUG-44815 Task-number: QTBUG-37660 Task-number: QTBUG-44694 Task-number: QTBUG-42443 Reviewed-by: Andrew Knight <qt@panimo.net> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'src/3rdparty/angle/src/libGLESv2')
-rw-r--r--src/3rdparty/angle/src/libGLESv2/BinaryStream.h208
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Buffer.cpp128
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Buffer.h74
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Caps.cpp425
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Caps.h273
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Context.cpp1769
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Context.h291
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Data.cpp51
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Data.h38
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Error.cpp48
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Error.h39
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Fence.cpp116
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Fence.h75
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Float16ToFloat32.cpp2203
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Float16ToFloat32.py78
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Framebuffer.cpp672
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Framebuffer.h126
-rw-r--r--src/3rdparty/angle/src/libGLESv2/FramebufferAttachment.cpp230
-rw-r--r--src/3rdparty/angle/src/libGLESv2/FramebufferAttachment.h132
-rw-r--r--src/3rdparty/angle/src/libGLESv2/HandleAllocator.cpp63
-rw-r--r--src/3rdparty/angle/src/libGLESv2/HandleAllocator.h44
-rw-r--r--src/3rdparty/angle/src/libGLESv2/ImageIndex.cpp148
-rw-r--r--src/3rdparty/angle/src/libGLESv2/ImageIndex.h68
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Program.cpp668
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Program.h151
-rw-r--r--src/3rdparty/angle/src/libGLESv2/ProgramBinary.cpp1233
-rw-r--r--src/3rdparty/angle/src/libGLESv2/ProgramBinary.h237
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Query.cpp50
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Query.h48
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Renderbuffer.cpp119
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Renderbuffer.h71
-rw-r--r--src/3rdparty/angle/src/libGLESv2/ResourceManager.cpp427
-rw-r--r--src/3rdparty/angle/src/libGLESv2/ResourceManager.h115
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Sampler.cpp43
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Sampler.h60
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Shader.cpp219
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Shader.h118
-rw-r--r--src/3rdparty/angle/src/libGLESv2/State.cpp1464
-rw-r--r--src/3rdparty/angle/src/libGLESv2/State.h325
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Texture.cpp1012
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Texture.h241
-rw-r--r--src/3rdparty/angle/src/libGLESv2/TransformFeedback.cpp71
-rw-r--r--src/3rdparty/angle/src/libGLESv2/TransformFeedback.h51
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Uniform.cpp105
-rw-r--r--src/3rdparty/angle/src/libGLESv2/Uniform.h79
-rw-r--r--src/3rdparty/angle/src/libGLESv2/VertexArray.cpp96
-rw-r--r--src/3rdparty/angle/src/libGLESv2/VertexArray.h62
-rw-r--r--src/3rdparty/angle/src/libGLESv2/VertexAttribute.cpp55
-rw-r--r--src/3rdparty/angle/src/libGLESv2/VertexAttribute.h119
-rw-r--r--src/3rdparty/angle/src/libGLESv2/angletypes.cpp210
-rw-r--r--src/3rdparty/angle/src/libGLESv2/angletypes.h257
-rw-r--r--src/3rdparty/angle/src/libGLESv2/constants.h44
-rw-r--r--src/3rdparty/angle/src/libGLESv2/entry_points_egl.cpp1127
-rw-r--r--src/3rdparty/angle/src/libGLESv2/entry_points_egl.h74
-rw-r--r--src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp271
-rw-r--r--src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.h30
-rw-r--r--src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0.cpp4318
-rw-r--r--src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0.h163
-rw-r--r--src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp1058
-rw-r--r--src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0_ext.h78
-rw-r--r--src/3rdparty/angle/src/libGLESv2/entry_points_gles_3_0.cpp3394
-rw-r--r--src/3rdparty/angle/src/libGLESv2/entry_points_gles_3_0.h125
-rw-r--r--src/3rdparty/angle/src/libGLESv2/entry_points_gles_3_0_ext.cpp14
-rw-r--r--src/3rdparty/angle/src/libGLESv2/entry_points_gles_3_0_ext.h23
-rw-r--r--src/3rdparty/angle/src/libGLESv2/formatutils.cpp629
-rw-r--r--src/3rdparty/angle/src/libGLESv2/formatutils.h106
-rw-r--r--src/3rdparty/angle/src/libGLESv2/global_state.cpp235
-rw-r--r--src/3rdparty/angle/src/libGLESv2/global_state.h49
-rw-r--r--src/3rdparty/angle/src/libGLESv2/libGLESv2.cpp8423
-rw-r--r--src/3rdparty/angle/src/libGLESv2/libGLESv2.def12
-rw-r--r--src/3rdparty/angle/src/libGLESv2/libGLESv2.rc103
-rw-r--r--src/3rdparty/angle/src/libGLESv2/libGLESv2_mingw32.def12
-rw-r--r--src/3rdparty/angle/src/libGLESv2/libGLESv2d.def12
-rw-r--r--src/3rdparty/angle/src/libGLESv2/libGLESv2d_mingw32.def12
-rw-r--r--src/3rdparty/angle/src/libGLESv2/main.cpp186
-rw-r--r--src/3rdparty/angle/src/libGLESv2/main.h61
-rw-r--r--src/3rdparty/angle/src/libGLESv2/queryconversions.cpp147
-rw-r--r--src/3rdparty/angle/src/libGLESv2/queryconversions.h17
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/BufferImpl.h35
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/FenceImpl.h52
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/Image.cpp46
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/Image.h79
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/IndexRangeCache.cpp128
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/IndexRangeCache.h64
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/ProgramImpl.cpp146
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/ProgramImpl.h127
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/QueryImpl.h42
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget.cpp36
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget.h53
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/RenderbufferImpl.cpp21
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/RenderbufferImpl.h41
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp172
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/Renderer.h193
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/ShaderExecutable.h78
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/ShaderImpl.h55
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/SwapChain.h56
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/TextureImpl.h64
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/TransformFeedbackImpl.h31
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/VertexArrayImpl.h32
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/Workarounds.h39
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/copyimage.cpp22
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/copyimage.h35
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/copyimage.inl32
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/copyvertex.h35
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/copyvertex.inl288
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/BufferD3D.cpp88
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/BufferD3D.h59
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/DynamicHLSL.cpp1148
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/DynamicHLSL.h101
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/HLSLCompiler.cpp333
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/HLSLCompiler.h56
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/ImageD3D.cpp26
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/ImageD3D.h50
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/IndexBuffer.cpp199
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/IndexBuffer.h112
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/IndexDataManager.cpp271
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/IndexDataManager.h71
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/MemoryBuffer.cpp74
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/MemoryBuffer.h36
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/ProgramD3D.cpp1925
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/ProgramD3D.h219
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/RenderbufferD3D.cpp108
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/RenderbufferD3D.h51
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/RendererD3D.cpp801
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/RendererD3D.h197
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/ShaderD3D.cpp481
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/ShaderD3D.h98
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/TextureD3D.cpp2813
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/TextureD3D.h335
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/TextureStorage.cpp39
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/TextureStorage.h66
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/TransformFeedbackD3D.cpp38
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/TransformFeedbackD3D.h32
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/VertexBuffer.cpp307
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/VertexBuffer.h144
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/VertexDataManager.cpp354
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/VertexDataManager.h96
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.cpp1047
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.h123
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.cpp983
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.h105
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.cpp556
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.h87
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Fence11.cpp232
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Fence11.h62
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Image11.cpp634
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Image11.h87
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.cpp162
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.h53
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/InputLayoutCache.cpp255
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/InputLayoutCache.h101
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.cpp304
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.h88
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Query11.cpp157
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Query11.h44
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/RenderStateCache.cpp439
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/RenderStateCache.h113
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/RenderTarget11.cpp404
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/RenderTarget11.h110
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp3422
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h362
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.cpp110
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.h61
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.cpp675
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.h82
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.cpp2112
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.h298
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/VertexArray11.h42
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/VertexBuffer11.cpp214
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/VertexBuffer11.h52
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.cpp1075
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.h84
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.cpp1228
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.h189
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/BufferToTexture11.hlsl76
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Clear11.hlsl106
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Passthrough2D11.hlsl111
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Passthrough3D11.hlsl146
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Swizzle11.hlsl99
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Blit9.cpp679
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Blit9.h97
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Buffer9.cpp122
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Buffer9.h52
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Fence9.cpp91
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Fence9.h37
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Image9.cpp792
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Image9.h77
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.cpp173
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.h53
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Query9.cpp144
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Query9.h43
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.cpp148
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.h89
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp3171
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Renderer9.h352
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderCache.h110
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderExecutable9.cpp53
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderExecutable9.h39
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.cpp422
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.h58
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.cpp472
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.h114
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexArray9.h43
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexBuffer9.cpp239
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexBuffer9.h54
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.cpp237
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.h59
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/formatutils9.cpp588
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/formatutils9.h74
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/renderer9_utils.cpp558
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/renderer9_utils.h86
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/Blit.ps33
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/Blit.vs43
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/generatemip.h28
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/generatemip.inl266
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/imageformats.h2029
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/loadimage.cpp661
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/loadimage.h193
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/loadimage.inl156
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/loadimageSSE2.cpp118
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/vertexconversion.h197
-rw-r--r--src/3rdparty/angle/src/libGLESv2/validationES.cpp1954
-rw-r--r--src/3rdparty/angle/src/libGLESv2/validationES.h92
-rw-r--r--src/3rdparty/angle/src/libGLESv2/validationES2.cpp980
-rw-r--r--src/3rdparty/angle/src/libGLESv2/validationES2.h34
-rw-r--r--src/3rdparty/angle/src/libGLESv2/validationES3.cpp1286
-rw-r--r--src/3rdparty/angle/src/libGLESv2/validationES3.h44
227 files changed, 11398 insertions, 71190 deletions
diff --git a/src/3rdparty/angle/src/libGLESv2/BinaryStream.h b/src/3rdparty/angle/src/libGLESv2/BinaryStream.h
deleted file mode 100644
index 4f7f5f2c85..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/BinaryStream.h
+++ /dev/null
@@ -1,208 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// BinaryStream.h: Provides binary serialization of simple types.
-
-#ifndef LIBGLESV2_BINARYSTREAM_H_
-#define LIBGLESV2_BINARYSTREAM_H_
-
-#include "common/angleutils.h"
-#include "common/mathutil.h"
-
-#include <cstddef>
-#include <string>
-#include <vector>
-#include <stdint.h>
-
-namespace gl
-{
-
-class BinaryInputStream
-{
- public:
- BinaryInputStream(const void *data, size_t length)
- {
- mError = false;
- mOffset = 0;
- mData = static_cast<const uint8_t*>(data);
- mLength = length;
- }
-
- // readInt will generate an error for bool types
- template <class IntT>
- IntT readInt()
- {
- int value;
- read(&value);
- return static_cast<IntT>(value);
- }
-
- template <class IntT>
- void readInt(IntT *outValue)
- {
- *outValue = readInt<IntT>();
- }
-
- bool readBool()
- {
- int value;
- read(&value);
- return (value > 0);
- }
-
- void readBool(bool *outValue)
- {
- *outValue = readBool();
- }
-
- void readBytes(unsigned char outArray[], size_t count)
- {
- read<unsigned char>(outArray, count);
- }
-
- std::string readString()
- {
- std::string outString;
- readString(&outString);
- return outString;
- }
-
- void readString(std::string *v)
- {
- size_t length;
- readInt(&length);
-
- if (mError)
- {
- return;
- }
-
- if (mOffset + length > mLength)
- {
- mError = true;
- return;
- }
-
- v->assign(reinterpret_cast<const char *>(mData) + mOffset, length);
- mOffset += length;
- }
-
- void skip(size_t length)
- {
- if (mOffset + length > mLength)
- {
- mError = true;
- return;
- }
-
- mOffset += length;
- }
-
- size_t offset() const
- {
- return mOffset;
- }
-
- bool error() const
- {
- return mError;
- }
-
- bool endOfStream() const
- {
- return mOffset == mLength;
- }
-
- const uint8_t *data()
- {
- return mData;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(BinaryInputStream);
- bool mError;
- size_t mOffset;
- const uint8_t *mData;
- size_t mLength;
-
- template <typename T>
- void read(T *v, size_t num)
- {
- META_ASSERT(std::is_fundamental<T>::value);
-
- size_t length = num * sizeof(T);
-
- if (mOffset + length > mLength)
- {
- mError = true;
- return;
- }
-
- memcpy(v, mData + mOffset, length);
- mOffset += length;
- }
-
- template <typename T>
- void read(T *v)
- {
- read(v, 1);
- }
-
-};
-
-class BinaryOutputStream
-{
- public:
- BinaryOutputStream()
- {
- }
-
- // writeInt also handles bool types
- template <class IntT>
- void writeInt(IntT param)
- {
- ASSERT(rx::IsIntegerCastSafe<int>(param));
- int intValue = static_cast<int>(param);
- write(&intValue, 1);
- }
-
- void writeString(const std::string &v)
- {
- writeInt(v.length());
- write(v.c_str(), v.length());
- }
-
- void writeBytes(const unsigned char *bytes, size_t count)
- {
- write(bytes, count);
- }
-
- size_t length() const
- {
- return mData.size();
- }
-
- const void* data() const
- {
- return mData.size() ? &mData[0] : NULL;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(BinaryOutputStream);
- std::vector<char> mData;
-
- template <typename T>
- void write(const T *v, size_t num)
- {
- META_ASSERT(std::is_fundamental<T>::value);
- const char *asBytes = reinterpret_cast<const char*>(v);
- mData.insert(mData.end(), asBytes, asBytes + num * sizeof(T));
- }
-
-};
-}
-
-#endif // LIBGLESV2_BINARYSTREAM_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/Buffer.cpp b/src/3rdparty/angle/src/libGLESv2/Buffer.cpp
deleted file mode 100644
index 3b2a1a912a..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Buffer.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// Buffer.cpp: Implements the gl::Buffer class, representing storage of vertex and/or
-// index data. Implements GL buffer objects and related functionality.
-// [OpenGL ES 2.0.24] section 2.9 page 21.
-
-#include "libGLESv2/Buffer.h"
-#include "libGLESv2/renderer/BufferImpl.h"
-#include "libGLESv2/renderer/Renderer.h"
-
-namespace gl
-{
-
-Buffer::Buffer(rx::BufferImpl *impl, GLuint id)
- : RefCountObject(id),
- mBuffer(impl),
- mUsage(GL_DYNAMIC_DRAW),
- mSize(0),
- mAccessFlags(0),
- mMapped(GL_FALSE),
- mMapPointer(NULL),
- mMapOffset(0),
- mMapLength(0)
-{
-}
-
-Buffer::~Buffer()
-{
- SafeDelete(mBuffer);
-}
-
-Error Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage)
-{
- gl::Error error = mBuffer->setData(data, size, usage);
- if (error.isError())
- {
- return error;
- }
-
- mIndexRangeCache.clear();
- mUsage = usage;
- mSize = size;
-
- return error;
-}
-
-Error Buffer::bufferSubData(const void *data, GLsizeiptr size, GLintptr offset)
-{
- gl::Error error = mBuffer->setSubData(data, size, offset);
- if (error.isError())
- {
- return error;
- }
-
- mIndexRangeCache.invalidateRange(offset, size);
-
- return error;
-}
-
-Error Buffer::copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size)
-{
- gl::Error error = mBuffer->copySubData(source->getImplementation(), sourceOffset, destOffset, size);
- if (error.isError())
- {
- return error;
- }
-
- mIndexRangeCache.invalidateRange(destOffset, size);
-
- return error;
-}
-
-Error Buffer::mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access)
-{
- ASSERT(!mMapped);
- ASSERT(offset + length <= mSize);
-
- Error error = mBuffer->map(offset, length, access, &mMapPointer);
- if (error.isError())
- {
- mMapPointer = NULL;
- return error;
- }
-
- mMapped = GL_TRUE;
- mMapOffset = static_cast<GLint64>(offset);
- mMapLength = static_cast<GLint64>(length);
- mAccessFlags = static_cast<GLint>(access);
-
- if ((access & GL_MAP_WRITE_BIT) > 0)
- {
- mIndexRangeCache.invalidateRange(offset, length);
- }
-
- return error;
-}
-
-Error Buffer::unmap()
-{
- ASSERT(mMapped);
-
- Error error = mBuffer->unmap();
- if (error.isError())
- {
- return error;
- }
-
- mMapped = GL_FALSE;
- mMapPointer = NULL;
- mMapOffset = 0;
- mMapLength = 0;
- mAccessFlags = 0;
-
- return error;
-}
-
-void Buffer::markTransformFeedbackUsage()
-{
- // TODO: Only used by the DX11 backend. Refactor to a more appropriate place.
- mBuffer->markTransformFeedbackUsage();
- mIndexRangeCache.clear();
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/Buffer.h b/src/3rdparty/angle/src/libGLESv2/Buffer.h
deleted file mode 100644
index daa862ca0d..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Buffer.h
+++ /dev/null
@@ -1,74 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// Buffer.h: Defines the gl::Buffer class, representing storage of vertex and/or
-// index data. Implements GL buffer objects and related functionality.
-// [OpenGL ES 2.0.24] section 2.9 page 21.
-
-#ifndef LIBGLESV2_BUFFER_H_
-#define LIBGLESV2_BUFFER_H_
-
-#include "libGLESv2/Error.h"
-
-#include "common/angleutils.h"
-#include "common/RefCountObject.h"
-#include "libGLESv2/renderer/IndexRangeCache.h"
-
-namespace rx
-{
-class BufferImpl;
-};
-
-namespace gl
-{
-
-class Buffer : public RefCountObject
-{
- public:
- Buffer(rx::BufferImpl *impl, GLuint id);
-
- virtual ~Buffer();
-
- Error bufferData(const void *data, GLsizeiptr size, GLenum usage);
- Error bufferSubData(const void *data, GLsizeiptr size, GLintptr offset);
- Error copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size);
- Error mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access);
- Error unmap();
-
- GLenum getUsage() const { return mUsage; }
- GLint getAccessFlags() const { return mAccessFlags; }
- GLboolean isMapped() const { return mMapped; }
- GLvoid *getMapPointer() const { return mMapPointer; }
- GLint64 getMapOffset() const { return mMapOffset; }
- GLint64 getMapLength() const { return mMapLength; }
- GLint64 getSize() const { return mSize; }
-
- rx::BufferImpl *getImplementation() const { return mBuffer; }
-
- void markTransformFeedbackUsage();
-
- rx::IndexRangeCache *getIndexRangeCache() { return &mIndexRangeCache; }
- const rx::IndexRangeCache *getIndexRangeCache() const { return &mIndexRangeCache; }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Buffer);
-
- rx::BufferImpl *mBuffer;
-
- GLenum mUsage;
- GLint64 mSize;
- GLint mAccessFlags;
- GLboolean mMapped;
- GLvoid *mMapPointer;
- GLint64 mMapOffset;
- GLint64 mMapLength;
-
- rx::IndexRangeCache mIndexRangeCache;
-};
-
-}
-
-#endif // LIBGLESV2_BUFFER_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/Caps.cpp b/src/3rdparty/angle/src/libGLESv2/Caps.cpp
deleted file mode 100644
index 983800c0e6..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Caps.cpp
+++ /dev/null
@@ -1,425 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-#include "libGLESv2/Caps.h"
-#include "common/debug.h"
-#include "common/angleutils.h"
-
-#include "angle_gl.h"
-
-#include <algorithm>
-#include <sstream>
-
-namespace gl
-{
-
-TextureCaps::TextureCaps()
- : texturable(false),
- filterable(false),
- renderable(false),
- sampleCounts()
-{
-}
-
-GLuint TextureCaps::getMaxSamples() const
-{
- return !sampleCounts.empty() ? *sampleCounts.rbegin() : 0;
-}
-
-GLuint TextureCaps::getNearestSamples(GLuint requestedSamples) const
-{
- if (requestedSamples == 0)
- {
- return 0;
- }
-
- for (SupportedSampleSet::const_iterator i = sampleCounts.begin(); i != sampleCounts.end(); i++)
- {
- GLuint samples = *i;
- if (samples >= requestedSamples)
- {
- return samples;
- }
- }
-
- return 0;
-}
-
-void TextureCapsMap::insert(GLenum internalFormat, const TextureCaps &caps)
-{
- mCapsMap.insert(std::make_pair(internalFormat, caps));
-}
-
-void TextureCapsMap::remove(GLenum internalFormat)
-{
- InternalFormatToCapsMap::iterator i = mCapsMap.find(internalFormat);
- if (i != mCapsMap.end())
- {
- mCapsMap.erase(i);
- }
-}
-
-const TextureCaps &TextureCapsMap::get(GLenum internalFormat) const
-{
- static TextureCaps defaultUnsupportedTexture;
- InternalFormatToCapsMap::const_iterator iter = mCapsMap.find(internalFormat);
- return (iter != mCapsMap.end()) ? iter->second : defaultUnsupportedTexture;
-}
-
-TextureCapsMap::const_iterator TextureCapsMap::begin() const
-{
- return mCapsMap.begin();
-}
-
-TextureCapsMap::const_iterator TextureCapsMap::end() const
-{
- return mCapsMap.end();
-}
-
-size_t TextureCapsMap::size() const
-{
- return mCapsMap.size();
-}
-
-Extensions::Extensions()
- : elementIndexUint(false),
- packedDepthStencil(false),
- getProgramBinary(false),
- rgb8rgba8(false),
- textureFormatBGRA8888(false),
- readFormatBGRA(false),
- pixelBufferObject(false),
- mapBuffer(false),
- mapBufferRange(false),
- textureHalfFloat(false),
- textureHalfFloatLinear(false),
- textureFloat(false),
- textureFloatLinear(false),
- textureRG(false),
- textureCompressionDXT1(false),
- textureCompressionDXT3(false),
- textureCompressionDXT5(false),
- depthTextures(false),
- textureNPOT(false),
- drawBuffers(false),
- textureStorage(false),
- textureFilterAnisotropic(false),
- maxTextureAnisotropy(false),
- occlusionQueryBoolean(false),
- fence(false),
- timerQuery(false),
- robustness(false),
- blendMinMax(false),
- framebufferBlit(false),
- framebufferMultisample(false),
- instancedArrays(false),
- packReverseRowOrder(false),
- standardDerivatives(false),
- shaderTextureLOD(false),
- fragDepth(false),
- textureUsage(false),
- translatedShaderSource(false),
- colorBufferFloat(false)
-{
-}
-
-static void InsertExtensionString(const std::string &extension, bool supported, std::vector<std::string> *extensionVector)
-{
- if (supported)
- {
- extensionVector->push_back(extension);
- }
-}
-
-std::vector<std::string> Extensions::getStrings() const
-{
- std::vector<std::string> extensionStrings;
-
- // | Extension name | Supported flag | Output vector |
- InsertExtensionString("GL_OES_element_index_uint", elementIndexUint, &extensionStrings);
- InsertExtensionString("GL_OES_packed_depth_stencil", packedDepthStencil, &extensionStrings);
- InsertExtensionString("GL_OES_get_program_binary", getProgramBinary, &extensionStrings);
- InsertExtensionString("GL_OES_rgb8_rgba8", rgb8rgba8, &extensionStrings);
- InsertExtensionString("GL_EXT_texture_format_BGRA8888", textureFormatBGRA8888, &extensionStrings);
- InsertExtensionString("GL_EXT_read_format_bgra", readFormatBGRA, &extensionStrings);
- InsertExtensionString("GL_NV_pixel_buffer_object", pixelBufferObject, &extensionStrings);
- InsertExtensionString("GL_OES_mapbuffer", mapBuffer, &extensionStrings);
- InsertExtensionString("GL_EXT_map_buffer_range", mapBufferRange, &extensionStrings);
- InsertExtensionString("GL_OES_texture_half_float", textureHalfFloat, &extensionStrings);
- InsertExtensionString("GL_OES_texture_half_float_linear", textureHalfFloatLinear, &extensionStrings);
- InsertExtensionString("GL_OES_texture_float", textureFloat, &extensionStrings);
- InsertExtensionString("GL_OES_texture_float_linear", textureFloatLinear, &extensionStrings);
- InsertExtensionString("GL_EXT_texture_rg", textureRG, &extensionStrings);
- InsertExtensionString("GL_EXT_texture_compression_dxt1", textureCompressionDXT1, &extensionStrings);
- InsertExtensionString("GL_ANGLE_texture_compression_dxt3", textureCompressionDXT3, &extensionStrings);
- InsertExtensionString("GL_ANGLE_texture_compression_dxt5", textureCompressionDXT5, &extensionStrings);
- InsertExtensionString("GL_EXT_sRGB", sRGB, &extensionStrings);
- InsertExtensionString("GL_ANGLE_depth_texture", depthTextures, &extensionStrings);
- InsertExtensionString("GL_EXT_texture_storage", textureStorage, &extensionStrings);
- InsertExtensionString("GL_OES_texture_npot", textureNPOT, &extensionStrings);
- InsertExtensionString("GL_EXT_draw_buffers", drawBuffers, &extensionStrings);
- InsertExtensionString("GL_EXT_texture_filter_anisotropic", textureFilterAnisotropic, &extensionStrings);
- InsertExtensionString("GL_EXT_occlusion_query_boolean", occlusionQueryBoolean, &extensionStrings);
- InsertExtensionString("GL_NV_fence", fence, &extensionStrings);
- InsertExtensionString("GL_ANGLE_timer_query", timerQuery, &extensionStrings);
- InsertExtensionString("GL_EXT_robustness", robustness, &extensionStrings);
- InsertExtensionString("GL_EXT_blend_minmax", blendMinMax, &extensionStrings);
- InsertExtensionString("GL_ANGLE_framebuffer_blit", framebufferBlit, &extensionStrings);
- InsertExtensionString("GL_ANGLE_framebuffer_multisample", framebufferMultisample, &extensionStrings);
- InsertExtensionString("GL_ANGLE_instanced_arrays", instancedArrays, &extensionStrings);
- InsertExtensionString("GL_ANGLE_pack_reverse_row_order", packReverseRowOrder, &extensionStrings);
- InsertExtensionString("GL_OES_standard_derivatives", standardDerivatives, &extensionStrings);
- InsertExtensionString("GL_EXT_shader_texture_lod", shaderTextureLOD, &extensionStrings);
- InsertExtensionString("GL_EXT_frag_depth", fragDepth, &extensionStrings);
- InsertExtensionString("GL_ANGLE_texture_usage", textureUsage, &extensionStrings);
- InsertExtensionString("GL_ANGLE_translated_shader_source", translatedShaderSource, &extensionStrings);
- InsertExtensionString("GL_EXT_color_buffer_float", colorBufferFloat, &extensionStrings);
-
- return extensionStrings;
-}
-
-static bool GetFormatSupport(const TextureCapsMap &textureCaps, const std::vector<GLenum> &requiredFormats,
- bool requiresTexturing, bool requiresFiltering, bool requiresRendering)
-{
- for (size_t i = 0; i < requiredFormats.size(); i++)
- {
- const TextureCaps &cap = textureCaps.get(requiredFormats[i]);
-
- if (requiresTexturing && !cap.texturable)
- {
- return false;
- }
-
- if (requiresFiltering && !cap.filterable)
- {
- return false;
- }
-
- if (requiresRendering && !cap.renderable)
- {
- return false;
- }
- }
-
- return true;
-}
-
-// Checks for GL_OES_rgb8_rgba8 support
-static bool DetermineRGB8AndRGBA8TextureSupport(const TextureCapsMap &textureCaps)
-{
- std::vector<GLenum> requiredFormats;
- requiredFormats.push_back(GL_RGB8);
- requiredFormats.push_back(GL_RGBA8);
-
- return GetFormatSupport(textureCaps, requiredFormats, true, true, true);
-}
-
-// Checks for GL_EXT_texture_format_BGRA8888 support
-static bool DetermineBGRA8TextureSupport(const TextureCapsMap &textureCaps)
-{
- std::vector<GLenum> requiredFormats;
- requiredFormats.push_back(GL_BGRA8_EXT);
-
- return GetFormatSupport(textureCaps, requiredFormats, true, true, true);
-}
-
-// Checks for GL_OES_texture_half_float support
-static bool DetermineHalfFloatTextureSupport(const TextureCapsMap &textureCaps)
-{
- std::vector<GLenum> requiredFormats;
- requiredFormats.push_back(GL_RGB16F);
- requiredFormats.push_back(GL_RGBA16F);
-
- return GetFormatSupport(textureCaps, requiredFormats, true, false, true);
-}
-
-// Checks for GL_OES_texture_half_float_linear support
-static bool DetermineHalfFloatTextureFilteringSupport(const TextureCapsMap &textureCaps)
-{
- std::vector<GLenum> requiredFormats;
- requiredFormats.push_back(GL_RGB16F);
- requiredFormats.push_back(GL_RGBA16F);
-
- return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
-}
-
-// Checks for GL_OES_texture_float support
-static bool DetermineFloatTextureSupport(const TextureCapsMap &textureCaps)
-{
- std::vector<GLenum> requiredFormats;
- requiredFormats.push_back(GL_RGB32F);
- requiredFormats.push_back(GL_RGBA32F);
-
- return GetFormatSupport(textureCaps, requiredFormats, true, false, true);
-}
-
-// Checks for GL_OES_texture_float_linear support
-static bool DetermineFloatTextureFilteringSupport(const TextureCapsMap &textureCaps)
-{
- std::vector<GLenum> requiredFormats;
- requiredFormats.push_back(GL_RGB32F);
- requiredFormats.push_back(GL_RGBA32F);
-
- return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
-}
-
-// Checks for GL_EXT_texture_rg support
-static bool DetermineRGTextureSupport(const TextureCapsMap &textureCaps, bool checkHalfFloatFormats, bool checkFloatFormats)
-{
- std::vector<GLenum> requiredFormats;
- requiredFormats.push_back(GL_R8);
- requiredFormats.push_back(GL_RG8);
- if (checkHalfFloatFormats)
- {
- requiredFormats.push_back(GL_R16F);
- requiredFormats.push_back(GL_RG16F);
- }
- if (checkFloatFormats)
- {
- requiredFormats.push_back(GL_R32F);
- requiredFormats.push_back(GL_RG32F);
- }
-
- return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
-}
-
-// Check for GL_EXT_texture_compression_dxt1
-static bool DetermineDXT1TextureSupport(const TextureCapsMap &textureCaps)
-{
- std::vector<GLenum> requiredFormats;
- requiredFormats.push_back(GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
- requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
-
- return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
-}
-
-// Check for GL_ANGLE_texture_compression_dxt3
-static bool DetermineDXT3TextureSupport(const TextureCapsMap &textureCaps)
-{
- std::vector<GLenum> requiredFormats;
- requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE);
-
- return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
-}
-
-// Check for GL_ANGLE_texture_compression_dxt5
-static bool DetermineDXT5TextureSupport(const TextureCapsMap &textureCaps)
-{
- std::vector<GLenum> requiredFormats;
- requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE);
-
- return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
-}
-
-// Check for GL_ANGLE_texture_compression_dxt5
-static bool DetermineSRGBTextureSupport(const TextureCapsMap &textureCaps)
-{
- std::vector<GLenum> requiredFilterFormats;
- requiredFilterFormats.push_back(GL_SRGB8);
- requiredFilterFormats.push_back(GL_SRGB8_ALPHA8);
-
- std::vector<GLenum> requiredRenderFormats;
- requiredRenderFormats.push_back(GL_SRGB8_ALPHA8);
-
- return GetFormatSupport(textureCaps, requiredFilterFormats, true, true, false) &&
- GetFormatSupport(textureCaps, requiredRenderFormats, true, false, true);
-}
-
-// Check for GL_ANGLE_depth_texture
-static bool DetermineDepthTextureSupport(const TextureCapsMap &textureCaps)
-{
- std::vector<GLenum> requiredFormats;
- requiredFormats.push_back(GL_DEPTH_COMPONENT16);
- requiredFormats.push_back(GL_DEPTH_COMPONENT32_OES);
- requiredFormats.push_back(GL_DEPTH24_STENCIL8_OES);
-
- return GetFormatSupport(textureCaps, requiredFormats, true, true, true);
-}
-
-// Check for GL_EXT_color_buffer_float
-static bool DetermineColorBufferFloatSupport(const TextureCapsMap &textureCaps)
-{
- std::vector<GLenum> requiredFormats;
- requiredFormats.push_back(GL_R16F);
- requiredFormats.push_back(GL_RG16F);
- requiredFormats.push_back(GL_RGBA16F);
- requiredFormats.push_back(GL_R32F);
- requiredFormats.push_back(GL_RG32F);
- requiredFormats.push_back(GL_RGBA32F);
- requiredFormats.push_back(GL_R11F_G11F_B10F);
-
- return GetFormatSupport(textureCaps, requiredFormats, true, false, true);
-}
-
-void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps)
-{
- rgb8rgba8 = DetermineRGB8AndRGBA8TextureSupport(textureCaps);
- textureFormatBGRA8888 = DetermineBGRA8TextureSupport(textureCaps);
- textureHalfFloat = DetermineHalfFloatTextureSupport(textureCaps);
- textureHalfFloatLinear = DetermineHalfFloatTextureFilteringSupport(textureCaps);
- textureFloat = DetermineFloatTextureSupport(textureCaps);
- textureFloatLinear = DetermineFloatTextureFilteringSupport(textureCaps);
- textureRG = DetermineRGTextureSupport(textureCaps, textureHalfFloat, textureFloat);
- textureCompressionDXT1 = DetermineDXT1TextureSupport(textureCaps);
- textureCompressionDXT3 = DetermineDXT3TextureSupport(textureCaps);
- textureCompressionDXT5 = DetermineDXT5TextureSupport(textureCaps);
- sRGB = DetermineSRGBTextureSupport(textureCaps);
- depthTextures = DetermineDepthTextureSupport(textureCaps);
- colorBufferFloat = DetermineColorBufferFloatSupport(textureCaps);
-}
-
-Caps::Caps()
- : maxElementIndex(0),
- max3DTextureSize(0),
- max2DTextureSize(0),
- maxArrayTextureLayers(0),
- maxLODBias(0),
- maxCubeMapTextureSize(0),
- maxRenderbufferSize(0),
- maxDrawBuffers(0),
- maxColorAttachments(0),
- maxViewportWidth(0),
- maxViewportHeight(0),
- minAliasedPointSize(0),
- maxAliasedPointSize(0),
- minAliasedLineWidth(0),
- // Table 6.29
- maxElementsIndices(0),
- maxElementsVertices(0),
- maxServerWaitTimeout(0),
- // Table 6.31
- maxVertexAttributes(0),
- maxVertexUniformComponents(0),
- maxVertexUniformVectors(0),
- maxVertexUniformBlocks(0),
- maxVertexOutputComponents(0),
- maxVertexTextureImageUnits(0),
- // Table 6.32
- maxFragmentUniformComponents(0),
- maxFragmentUniformVectors(0),
- maxFragmentUniformBlocks(0),
- maxFragmentInputComponents(0),
- maxTextureImageUnits(0),
- minProgramTexelOffset(0),
- maxProgramTexelOffset(0),
-
- maxUniformBufferBindings(0),
- maxUniformBlockSize(0),
- uniformBufferOffsetAlignment(0),
- maxCombinedUniformBlocks(0),
- maxCombinedVertexUniformComponents(0),
- maxCombinedFragmentUniformComponents(0),
- maxVaryingComponents(0),
- maxVaryingVectors(0),
- maxCombinedTextureImageUnits(0),
-
- maxTransformFeedbackInterleavedComponents(0),
- maxTransformFeedbackSeparateAttributes(0),
- maxTransformFeedbackSeparateComponents(0)
-{
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/Caps.h b/src/3rdparty/angle/src/libGLESv2/Caps.h
deleted file mode 100644
index a00e554176..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Caps.h
+++ /dev/null
@@ -1,273 +0,0 @@
-#ifndef LIBGLESV2_CAPS_H
-#define LIBGLESV2_CAPS_H
-
-//
-// Copyright (c) 2014 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.
-//
-
-#include "angle_gl.h"
-
-#include <set>
-#include <unordered_map>
-#include <vector>
-#include <string>
-
-namespace gl
-{
-
-typedef std::set<GLuint> SupportedSampleSet;
-
-struct TextureCaps
-{
- TextureCaps();
-
- // Supports for basic texturing: glTexImage, glTexSubImage, etc
- bool texturable;
-
- // Support for linear or anisotropic filtering
- bool filterable;
-
- // Support for being used as a framebuffer attachment or renderbuffer format
- bool renderable;
-
- SupportedSampleSet sampleCounts;
-
- // Get the maximum number of samples supported
- GLuint getMaxSamples() const;
-
- // Get the number of supported samples that is at least as many as requested. Returns 0 if
- // there are no sample counts available
- GLuint getNearestSamples(GLuint requestedSamples) const;
-};
-
-class TextureCapsMap
-{
- public:
- typedef std::unordered_map<GLenum, TextureCaps>::const_iterator const_iterator;
-
- void insert(GLenum internalFormat, const TextureCaps &caps);
- void remove(GLenum internalFormat);
-
- const TextureCaps &get(GLenum internalFormat) const;
-
- const_iterator begin() const;
- const_iterator end() const;
-
- size_t size() const;
-
- private:
- typedef std::unordered_map<GLenum, TextureCaps> InternalFormatToCapsMap;
- InternalFormatToCapsMap mCapsMap;
-};
-
-struct Extensions
-{
- Extensions();
-
- // Generate a vector of supported extension strings
- std::vector<std::string> getStrings() const;
-
- // Set all texture related extension support based on the supported textures.
- // Determines support for:
- // GL_OES_rgb8_rgba8
- // GL_EXT_texture_format_BGRA8888
- // GL_OES_texture_half_float, GL_OES_texture_half_float_linear
- // GL_OES_texture_float, GL_OES_texture_float_linear
- // GL_EXT_texture_rg
- // GL_EXT_texture_compression_dxt1, GL_ANGLE_texture_compression_dxt3, GL_ANGLE_texture_compression_dxt5
- // GL_EXT_sRGB
- // GL_ANGLE_depth_texture
- // GL_EXT_color_buffer_float
- void setTextureExtensionSupport(const TextureCapsMap &textureCaps);
-
- // ES2 Extension support
-
- // GL_OES_element_index_uint
- bool elementIndexUint;
-
- // GL_OES_packed_depth_stencil
- bool packedDepthStencil;
-
- // GL_OES_get_program_binary
- bool getProgramBinary;
-
- // GL_OES_rgb8_rgba8
- // Implies that TextureCaps for GL_RGB8 and GL_RGBA8 exist
- bool rgb8rgba8;
-
- // GL_EXT_texture_format_BGRA8888
- // Implies that TextureCaps for GL_BGRA8 exist
- bool textureFormatBGRA8888;
-
- // GL_EXT_read_format_bgra
- bool readFormatBGRA;
-
- // GL_NV_pixel_buffer_object
- bool pixelBufferObject;
-
- // GL_OES_mapbuffer and GL_EXT_map_buffer_range
- bool mapBuffer;
- bool mapBufferRange;
-
- // GL_OES_texture_half_float and GL_OES_texture_half_float_linear
- // Implies that TextureCaps for GL_RGB16F, GL_RGBA16F, GL_ALPHA32F_EXT, GL_LUMINANCE32F_EXT and
- // GL_LUMINANCE_ALPHA32F_EXT exist
- bool textureHalfFloat;
- bool textureHalfFloatLinear;
-
- // GL_OES_texture_float and GL_OES_texture_float_linear
- // Implies that TextureCaps for GL_RGB32F, GL_RGBA32F, GL_ALPHA16F_EXT, GL_LUMINANCE16F_EXT and
- // GL_LUMINANCE_ALPHA16F_EXT exist
- bool textureFloat;
- bool textureFloatLinear;
-
- // GL_EXT_texture_rg
- // Implies that TextureCaps for GL_R8, GL_RG8 (and floating point R/RG texture formats if floating point extensions
- // are also present) exist
- bool textureRG;
-
- // GL_EXT_texture_compression_dxt1, GL_ANGLE_texture_compression_dxt3 and GL_ANGLE_texture_compression_dxt5
- // Implies that TextureCaps for GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
- // GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE and GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE
- bool textureCompressionDXT1;
- bool textureCompressionDXT3;
- bool textureCompressionDXT5;
-
- // GL_EXT_sRGB
- // Implies that TextureCaps for GL_SRGB8_ALPHA8 and GL_SRGB8 exist
- // TODO: Don't advertise this extension in ES3
- bool sRGB;
-
- // GL_ANGLE_depth_texture
- bool depthTextures;
-
- // GL_EXT_texture_storage
- bool textureStorage;
-
- // GL_OES_texture_npot
- bool textureNPOT;
-
- // GL_EXT_draw_buffers
- bool drawBuffers;
-
- // GL_EXT_texture_filter_anisotropic
- bool textureFilterAnisotropic;
- GLfloat maxTextureAnisotropy;
-
- // GL_EXT_occlusion_query_boolean
- bool occlusionQueryBoolean;
-
- // GL_NV_fence
- bool fence;
-
- // GL_ANGLE_timer_query
- bool timerQuery;
-
- // GL_EXT_robustness
- bool robustness;
-
- // GL_EXT_blend_minmax
- bool blendMinMax;
-
- // GL_ANGLE_framebuffer_blit
- bool framebufferBlit;
-
- // GL_ANGLE_framebuffer_multisample
- bool framebufferMultisample;
- GLuint maxSamples;
-
- // GL_ANGLE_instanced_arrays
- bool instancedArrays;
-
- // GL_ANGLE_pack_reverse_row_order
- bool packReverseRowOrder;
-
- // GL_OES_standard_derivatives
- bool standardDerivatives;
-
- // GL_EXT_shader_texture_lod
- bool shaderTextureLOD;
-
- // GL_EXT_frag_depth
- bool fragDepth;
-
- // GL_ANGLE_texture_usage
- bool textureUsage;
-
- // GL_ANGLE_translated_shader_source
- bool translatedShaderSource;
-
- // ES3 Extension support
-
- // GL_EXT_color_buffer_float
- bool colorBufferFloat;
-};
-
-struct Caps
-{
- Caps();
-
- // Table 6.28, implementation dependent values
- GLuint64 maxElementIndex;
- GLuint max3DTextureSize;
- GLuint max2DTextureSize;
- GLuint maxArrayTextureLayers;
- GLfloat maxLODBias;
- GLuint maxCubeMapTextureSize;
- GLuint maxRenderbufferSize;
- GLuint maxDrawBuffers;
- GLuint maxColorAttachments;
- GLuint maxViewportWidth;
- GLuint maxViewportHeight;
- GLfloat minAliasedPointSize;
- GLfloat maxAliasedPointSize;
- GLfloat minAliasedLineWidth;
- GLfloat maxAliasedLineWidth;
-
- // Table 6.29, implementation dependent values (cont.)
- GLuint maxElementsIndices;
- GLuint maxElementsVertices;
- std::vector<GLenum> compressedTextureFormats;
- std::vector<GLenum> programBinaryFormats;
- std::vector<GLenum> shaderBinaryFormats;
- GLuint64 maxServerWaitTimeout;
-
- // Table 6.31, implementation dependent vertex shader limits
- GLuint maxVertexAttributes;
- GLuint maxVertexUniformComponents;
- GLuint maxVertexUniformVectors;
- GLuint maxVertexUniformBlocks;
- GLuint maxVertexOutputComponents;
- GLuint maxVertexTextureImageUnits;
-
- // Table 6.32, implementation dependent fragment shader limits
- GLuint maxFragmentUniformComponents;
- GLuint maxFragmentUniformVectors;
- GLuint maxFragmentUniformBlocks;
- GLuint maxFragmentInputComponents;
- GLuint maxTextureImageUnits;
- GLint minProgramTexelOffset;
- GLint maxProgramTexelOffset;
-
- // Table 6.33, implementation dependent aggregate shader limits
- GLuint maxUniformBufferBindings;
- GLuint64 maxUniformBlockSize;
- GLuint uniformBufferOffsetAlignment;
- GLuint maxCombinedUniformBlocks;
- GLuint64 maxCombinedVertexUniformComponents;
- GLuint64 maxCombinedFragmentUniformComponents;
- GLuint maxVaryingComponents;
- GLuint maxVaryingVectors;
- GLuint maxCombinedTextureImageUnits;
-
- // Table 6.34, implementation dependent transform feedback limits
- GLuint maxTransformFeedbackInterleavedComponents;
- GLuint maxTransformFeedbackSeparateAttributes;
- GLuint maxTransformFeedbackSeparateComponents;
-};
-
-}
-
-#endif // LIBGLESV2_CAPS_H
diff --git a/src/3rdparty/angle/src/libGLESv2/Context.cpp b/src/3rdparty/angle/src/libGLESv2/Context.cpp
deleted file mode 100644
index 3772da6f42..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Context.cpp
+++ /dev/null
@@ -1,1769 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// Context.cpp: Implements the gl::Context class, managing all GL state and performing
-// rendering operations. It is the GLES2 specific implementation of EGLContext.
-
-#include "libGLESv2/Context.h"
-
-#include "common/utilities.h"
-#include "common/platform.h"
-#include "libGLESv2/Buffer.h"
-#include "libGLESv2/Fence.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/FramebufferAttachment.h"
-#include "libGLESv2/Renderbuffer.h"
-#include "libGLESv2/Program.h"
-#include "libGLESv2/ProgramBinary.h"
-#include "libGLESv2/Query.h"
-#include "libGLESv2/ResourceManager.h"
-#include "libGLESv2/Sampler.h"
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/TransformFeedback.h"
-#include "libGLESv2/VertexArray.h"
-#include "libGLESv2/formatutils.h"
-#include "libGLESv2/main.h"
-#include "libGLESv2/validationES.h"
-#include "libGLESv2/renderer/Renderer.h"
-
-#include "libEGL/Surface.h"
-
-#include <sstream>
-#include <iterator>
-
-namespace gl
-{
-
-Context::Context(int clientVersion, const Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess)
- : mRenderer(renderer)
-{
- ASSERT(robustAccess == false); // Unimplemented
-
- initCaps(clientVersion);
- mState.initialize(mCaps, clientVersion);
-
- mClientVersion = clientVersion;
-
- mFenceNVHandleAllocator.setBaseHandle(0);
-
- if (shareContext != NULL)
- {
- mResourceManager = shareContext->mResourceManager;
- mResourceManager->addRef();
- }
- else
- {
- mResourceManager = new ResourceManager(mRenderer);
- }
-
- // [OpenGL ES 2.0.24] section 3.7 page 83:
- // In the initial state, TEXTURE_2D and TEXTURE_CUBE_MAP have twodimensional
- // and cube map texture state vectors respectively associated with them.
- // In order that access to these initial textures not be lost, they are treated as texture
- // objects all of whose names are 0.
-
- Texture2D *zeroTexture2D = new Texture2D(mRenderer->createTexture(GL_TEXTURE_2D), 0);
- mZeroTextures[GL_TEXTURE_2D].set(zeroTexture2D);
-
- TextureCubeMap *zeroTextureCube = new TextureCubeMap(mRenderer->createTexture(GL_TEXTURE_CUBE_MAP), 0);
- mZeroTextures[GL_TEXTURE_CUBE_MAP].set(zeroTextureCube);
-
- if (mClientVersion >= 3)
- {
- // TODO: These could also be enabled via extension
- Texture3D *zeroTexture3D = new Texture3D(mRenderer->createTexture(GL_TEXTURE_3D), 0);
- mZeroTextures[GL_TEXTURE_3D].set(zeroTexture3D);
-
- Texture2DArray *zeroTexture2DArray = new Texture2DArray(mRenderer->createTexture(GL_TEXTURE_2D_ARRAY), 0);
- mZeroTextures[GL_TEXTURE_2D_ARRAY].set(zeroTexture2DArray);
- }
-
- mState.initializeZeroTextures(mZeroTextures);
-
- bindVertexArray(0);
- bindArrayBuffer(0);
- bindElementArrayBuffer(0);
-
- bindReadFramebuffer(0);
- bindDrawFramebuffer(0);
- bindRenderbuffer(0);
-
- bindGenericUniformBuffer(0);
- for (unsigned int i = 0; i < mCaps.maxCombinedUniformBlocks; i++)
- {
- bindIndexedUniformBuffer(0, i, 0, -1);
- }
-
- bindGenericTransformFeedbackBuffer(0);
- for (unsigned int i = 0; i < mCaps.maxTransformFeedbackSeparateAttributes; i++)
- {
- bindIndexedTransformFeedbackBuffer(0, i, 0, -1);
- }
-
- bindCopyReadBuffer(0);
- bindCopyWriteBuffer(0);
- bindPixelPackBuffer(0);
- bindPixelUnpackBuffer(0);
-
- // [OpenGL ES 3.0.2] section 2.14.1 pg 85:
- // In the initial state, a default transform feedback object is bound and treated as
- // a transform feedback object with a name of zero. That object is bound any time
- // BindTransformFeedback is called with id of zero
- mTransformFeedbackZero.set(new TransformFeedback(mRenderer->createTransformFeedback(), 0));
- bindTransformFeedback(0);
-
- mHasBeenCurrent = false;
- mContextLost = false;
- mResetStatus = GL_NO_ERROR;
- mResetStrategy = (notifyResets ? GL_LOSE_CONTEXT_ON_RESET_EXT : GL_NO_RESET_NOTIFICATION_EXT);
- mRobustAccess = robustAccess;
-}
-
-Context::~Context()
-{
- GLuint currentProgram = mState.getCurrentProgramId();
- if (currentProgram != 0)
- {
- Program *programObject = mResourceManager->getProgram(currentProgram);
- if (programObject)
- {
- programObject->release();
- }
- currentProgram = 0;
- }
- mState.setCurrentProgram(0, NULL);
-
- while (!mFramebufferMap.empty())
- {
- deleteFramebuffer(mFramebufferMap.begin()->first);
- }
-
- while (!mFenceNVMap.empty())
- {
- deleteFenceNV(mFenceNVMap.begin()->first);
- }
-
- while (!mQueryMap.empty())
- {
- deleteQuery(mQueryMap.begin()->first);
- }
-
- while (!mVertexArrayMap.empty())
- {
- deleteVertexArray(mVertexArrayMap.begin()->first);
- }
-
- mTransformFeedbackZero.set(NULL);
- while (!mTransformFeedbackMap.empty())
- {
- deleteTransformFeedback(mTransformFeedbackMap.begin()->first);
- }
-
- for (TextureMap::iterator i = mZeroTextures.begin(); i != mZeroTextures.end(); i++)
- {
- i->second.set(NULL);
- }
- mZeroTextures.clear();
-
- if (mResourceManager)
- {
- mResourceManager->release();
- }
-}
-
-void Context::makeCurrent(egl::Surface *surface)
-{
- if (!mHasBeenCurrent)
- {
- initRendererString();
- initExtensionStrings();
-
- mState.setViewportParams(0, 0, surface->getWidth(), surface->getHeight());
- mState.setScissorParams(0, 0, surface->getWidth(), surface->getHeight());
-
- mHasBeenCurrent = true;
- }
-
- // Wrap the existing swapchain resources into GL objects and assign them to the '0' names
- rx::SwapChain *swapchain = surface->getSwapChain();
-
- rx::RenderbufferImpl *colorbufferZero = mRenderer->createRenderbuffer(swapchain, false);
- rx::RenderbufferImpl *depthStencilbufferZero = mRenderer->createRenderbuffer(swapchain, true);
- Framebuffer *framebufferZero = new DefaultFramebuffer(colorbufferZero, depthStencilbufferZero);
-
- setFramebufferZero(framebufferZero);
-}
-
-// NOTE: this function should not assume that this context is current!
-void Context::markContextLost()
-{
- if (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT)
- mResetStatus = GL_UNKNOWN_CONTEXT_RESET_EXT;
- mContextLost = true;
-}
-
-bool Context::isContextLost()
-{
- return mContextLost;
-}
-
-GLuint Context::createBuffer()
-{
- return mResourceManager->createBuffer();
-}
-
-GLuint Context::createProgram()
-{
- return mResourceManager->createProgram();
-}
-
-GLuint Context::createShader(GLenum type)
-{
- return mResourceManager->createShader(getData(), type);
-}
-
-GLuint Context::createTexture()
-{
- return mResourceManager->createTexture();
-}
-
-GLuint Context::createRenderbuffer()
-{
- return mResourceManager->createRenderbuffer();
-}
-
-GLsync Context::createFenceSync()
-{
- GLuint handle = mResourceManager->createFenceSync();
-
- return reinterpret_cast<GLsync>(handle);
-}
-
-GLuint Context::createVertexArray()
-{
- GLuint handle = mVertexArrayHandleAllocator.allocate();
-
- // Although the spec states VAO state is not initialized until the object is bound,
- // we create it immediately. The resulting behaviour is transparent to the application,
- // since it's not currently possible to access the state until the object is bound.
- VertexArray *vertexArray = new VertexArray(mRenderer->createVertexArray(), handle, MAX_VERTEX_ATTRIBS);
- mVertexArrayMap[handle] = vertexArray;
- return handle;
-}
-
-GLuint Context::createSampler()
-{
- return mResourceManager->createSampler();
-}
-
-GLuint Context::createTransformFeedback()
-{
- GLuint handle = mTransformFeedbackAllocator.allocate();
- TransformFeedback *transformFeedback = new TransformFeedback(mRenderer->createTransformFeedback(), handle);
- transformFeedback->addRef();
- mTransformFeedbackMap[handle] = transformFeedback;
- return handle;
-}
-
-// Returns an unused framebuffer name
-GLuint Context::createFramebuffer()
-{
- GLuint handle = mFramebufferHandleAllocator.allocate();
-
- mFramebufferMap[handle] = NULL;
-
- return handle;
-}
-
-GLuint Context::createFenceNV()
-{
- GLuint handle = mFenceNVHandleAllocator.allocate();
-
- mFenceNVMap[handle] = new FenceNV(mRenderer->createFenceNV());
-
- return handle;
-}
-
-// Returns an unused query name
-GLuint Context::createQuery()
-{
- GLuint handle = mQueryHandleAllocator.allocate();
-
- mQueryMap[handle] = NULL;
-
- return handle;
-}
-
-void Context::deleteBuffer(GLuint buffer)
-{
- if (mResourceManager->getBuffer(buffer))
- {
- detachBuffer(buffer);
- }
-
- mResourceManager->deleteBuffer(buffer);
-}
-
-void Context::deleteShader(GLuint shader)
-{
- mResourceManager->deleteShader(shader);
-}
-
-void Context::deleteProgram(GLuint program)
-{
- mResourceManager->deleteProgram(program);
-}
-
-void Context::deleteTexture(GLuint texture)
-{
- if (mResourceManager->getTexture(texture))
- {
- detachTexture(texture);
- }
-
- mResourceManager->deleteTexture(texture);
-}
-
-void Context::deleteRenderbuffer(GLuint renderbuffer)
-{
- if (mResourceManager->getRenderbuffer(renderbuffer))
- {
- detachRenderbuffer(renderbuffer);
- }
-
- mResourceManager->deleteRenderbuffer(renderbuffer);
-}
-
-void Context::deleteFenceSync(GLsync fenceSync)
-{
- // The spec specifies the underlying Fence object is not deleted until all current
- // wait commands finish. However, since the name becomes invalid, we cannot query the fence,
- // and since our API is currently designed for being called from a single thread, we can delete
- // the fence immediately.
- mResourceManager->deleteFenceSync(reinterpret_cast<uintptr_t>(fenceSync));
-}
-
-void Context::deleteVertexArray(GLuint vertexArray)
-{
- VertexArrayMap::iterator vertexArrayObject = mVertexArrayMap.find(vertexArray);
-
- if (vertexArrayObject != mVertexArrayMap.end())
- {
- detachVertexArray(vertexArray);
-
- mVertexArrayHandleAllocator.release(vertexArrayObject->first);
- delete vertexArrayObject->second;
- mVertexArrayMap.erase(vertexArrayObject);
- }
-}
-
-void Context::deleteSampler(GLuint sampler)
-{
- if (mResourceManager->getSampler(sampler))
- {
- detachSampler(sampler);
- }
-
- mResourceManager->deleteSampler(sampler);
-}
-
-void Context::deleteTransformFeedback(GLuint transformFeedback)
-{
- TransformFeedbackMap::const_iterator iter = mTransformFeedbackMap.find(transformFeedback);
- if (iter != mTransformFeedbackMap.end())
- {
- detachTransformFeedback(transformFeedback);
- mTransformFeedbackAllocator.release(transformFeedback);
- iter->second->release();
- mTransformFeedbackMap.erase(iter);
- }
-}
-
-void Context::deleteFramebuffer(GLuint framebuffer)
-{
- FramebufferMap::iterator framebufferObject = mFramebufferMap.find(framebuffer);
-
- if (framebufferObject != mFramebufferMap.end())
- {
- detachFramebuffer(framebuffer);
-
- mFramebufferHandleAllocator.release(framebufferObject->first);
- delete framebufferObject->second;
- mFramebufferMap.erase(framebufferObject);
- }
-}
-
-void Context::deleteFenceNV(GLuint fence)
-{
- FenceNVMap::iterator fenceObject = mFenceNVMap.find(fence);
-
- if (fenceObject != mFenceNVMap.end())
- {
- mFenceNVHandleAllocator.release(fenceObject->first);
- delete fenceObject->second;
- mFenceNVMap.erase(fenceObject);
- }
-}
-
-void Context::deleteQuery(GLuint query)
-{
- QueryMap::iterator queryObject = mQueryMap.find(query);
- if (queryObject != mQueryMap.end())
- {
- mQueryHandleAllocator.release(queryObject->first);
- if (queryObject->second)
- {
- queryObject->second->release();
- }
- mQueryMap.erase(queryObject);
- }
-}
-
-Buffer *Context::getBuffer(GLuint handle)
-{
- return mResourceManager->getBuffer(handle);
-}
-
-Shader *Context::getShader(GLuint handle) const
-{
- return mResourceManager->getShader(handle);
-}
-
-Program *Context::getProgram(GLuint handle) const
-{
- return mResourceManager->getProgram(handle);
-}
-
-Texture *Context::getTexture(GLuint handle) const
-{
- return mResourceManager->getTexture(handle);
-}
-
-Renderbuffer *Context::getRenderbuffer(GLuint handle)
-{
- return mResourceManager->getRenderbuffer(handle);
-}
-
-FenceSync *Context::getFenceSync(GLsync handle) const
-{
- return mResourceManager->getFenceSync(reinterpret_cast<uintptr_t>(handle));
-}
-
-VertexArray *Context::getVertexArray(GLuint handle) const
-{
- VertexArrayMap::const_iterator vertexArray = mVertexArrayMap.find(handle);
-
- if (vertexArray == mVertexArrayMap.end())
- {
- return NULL;
- }
- else
- {
- return vertexArray->second;
- }
-}
-
-Sampler *Context::getSampler(GLuint handle) const
-{
- return mResourceManager->getSampler(handle);
-}
-
-TransformFeedback *Context::getTransformFeedback(GLuint handle) const
-{
- if (handle == 0)
- {
- return mTransformFeedbackZero.get();
- }
- else
- {
- TransformFeedbackMap::const_iterator iter = mTransformFeedbackMap.find(handle);
- return (iter != mTransformFeedbackMap.end()) ? iter->second : NULL;
- }
-}
-
-bool Context::isSampler(GLuint samplerName) const
-{
- return mResourceManager->isSampler(samplerName);
-}
-
-void Context::bindArrayBuffer(unsigned int buffer)
-{
- mResourceManager->checkBufferAllocation(buffer);
-
- mState.setArrayBufferBinding(getBuffer(buffer));
-}
-
-void Context::bindElementArrayBuffer(unsigned int buffer)
-{
- mResourceManager->checkBufferAllocation(buffer);
-
- mState.getVertexArray()->setElementArrayBuffer(getBuffer(buffer));
-}
-
-void Context::bindTexture(GLenum target, GLuint handle)
-{
- Texture *texture = NULL;
-
- if (handle == 0)
- {
- texture = mZeroTextures[target].get();
- }
- else
- {
- mResourceManager->checkTextureAllocation(handle, target);
- texture = getTexture(handle);
- }
-
- ASSERT(texture);
-
- mState.setSamplerTexture(target, texture);
-}
-
-void Context::bindReadFramebuffer(GLuint framebuffer)
-{
- if (!getFramebuffer(framebuffer))
- {
- mFramebufferMap[framebuffer] = new Framebuffer(framebuffer);
- }
-
- mState.setReadFramebufferBinding(getFramebuffer(framebuffer));
-}
-
-void Context::bindDrawFramebuffer(GLuint framebuffer)
-{
- if (!getFramebuffer(framebuffer))
- {
- mFramebufferMap[framebuffer] = new Framebuffer(framebuffer);
- }
-
- mState.setDrawFramebufferBinding(getFramebuffer(framebuffer));
-}
-
-void Context::bindRenderbuffer(GLuint renderbuffer)
-{
- mResourceManager->checkRenderbufferAllocation(renderbuffer);
-
- mState.setRenderbufferBinding(getRenderbuffer(renderbuffer));
-}
-
-void Context::bindVertexArray(GLuint vertexArray)
-{
- if (!getVertexArray(vertexArray))
- {
- VertexArray *vertexArrayObject = new VertexArray(mRenderer->createVertexArray(), vertexArray, MAX_VERTEX_ATTRIBS);
- mVertexArrayMap[vertexArray] = vertexArrayObject;
- }
-
- mState.setVertexArrayBinding(getVertexArray(vertexArray));
-}
-
-void Context::bindSampler(GLuint textureUnit, GLuint sampler)
-{
- ASSERT(textureUnit < mCaps.maxCombinedTextureImageUnits);
- mResourceManager->checkSamplerAllocation(sampler);
-
- mState.setSamplerBinding(textureUnit, getSampler(sampler));
-}
-
-void Context::bindGenericUniformBuffer(GLuint buffer)
-{
- mResourceManager->checkBufferAllocation(buffer);
-
- mState.setGenericUniformBufferBinding(getBuffer(buffer));
-}
-
-void Context::bindIndexedUniformBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size)
-{
- mResourceManager->checkBufferAllocation(buffer);
-
- mState.setIndexedUniformBufferBinding(index, getBuffer(buffer), offset, size);
-}
-
-void Context::bindGenericTransformFeedbackBuffer(GLuint buffer)
-{
- mResourceManager->checkBufferAllocation(buffer);
-
- mState.setGenericTransformFeedbackBufferBinding(getBuffer(buffer));
-}
-
-void Context::bindIndexedTransformFeedbackBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size)
-{
- mResourceManager->checkBufferAllocation(buffer);
-
- mState.setIndexedTransformFeedbackBufferBinding(index, getBuffer(buffer), offset, size);
-}
-
-void Context::bindCopyReadBuffer(GLuint buffer)
-{
- mResourceManager->checkBufferAllocation(buffer);
-
- mState.setCopyReadBufferBinding(getBuffer(buffer));
-}
-
-void Context::bindCopyWriteBuffer(GLuint buffer)
-{
- mResourceManager->checkBufferAllocation(buffer);
-
- mState.setCopyWriteBufferBinding(getBuffer(buffer));
-}
-
-void Context::bindPixelPackBuffer(GLuint buffer)
-{
- mResourceManager->checkBufferAllocation(buffer);
-
- mState.setPixelPackBufferBinding(getBuffer(buffer));
-}
-
-void Context::bindPixelUnpackBuffer(GLuint buffer)
-{
- mResourceManager->checkBufferAllocation(buffer);
-
- mState.setPixelUnpackBufferBinding(getBuffer(buffer));
-}
-
-void Context::useProgram(GLuint program)
-{
- GLuint priorProgramId = mState.getCurrentProgramId();
- Program *priorProgram = mResourceManager->getProgram(priorProgramId);
-
- if (priorProgramId != program)
- {
- mState.setCurrentProgram(program, mResourceManager->getProgram(program));
-
- if (priorProgram)
- {
- priorProgram->release();
- }
- }
-}
-
-Error Context::linkProgram(GLuint program)
-{
- Program *programObject = mResourceManager->getProgram(program);
-
- Error error = programObject->link(getData());
- if (error.isError())
- {
- return error;
- }
-
- // if the current program was relinked successfully we
- // need to install the new executables
- if (programObject->isLinked() && program == mState.getCurrentProgramId())
- {
- mState.setCurrentProgramBinary(programObject->getProgramBinary());
- }
-
- return Error(GL_NO_ERROR);
-}
-
-Error Context::setProgramBinary(GLuint program, GLenum binaryFormat, const void *binary, GLint length)
-{
- Program *programObject = mResourceManager->getProgram(program);
-
- Error error = programObject->setProgramBinary(binaryFormat, binary, length);
- if (error.isError())
- {
- return error;
- }
-
- // if the current program was reloaded successfully we
- // need to install the new executables
- if (programObject->isLinked() && program == mState.getCurrentProgramId())
- {
- mState.setCurrentProgramBinary(programObject->getProgramBinary());
- }
-
- return Error(GL_NO_ERROR);
-}
-
-void Context::bindTransformFeedback(GLuint transformFeedback)
-{
- mState.setTransformFeedbackBinding(getTransformFeedback(transformFeedback));
-}
-
-Error Context::beginQuery(GLenum target, GLuint query)
-{
- Query *queryObject = getQuery(query, true, target);
- ASSERT(queryObject);
-
- // begin query
- Error error = queryObject->begin();
- if (error.isError())
- {
- return error;
- }
-
- // set query as active for specified target only if begin succeeded
- mState.setActiveQuery(target, queryObject);
-
- return Error(GL_NO_ERROR);
-}
-
-Error Context::endQuery(GLenum target)
-{
- Query *queryObject = mState.getActiveQuery(target);
- ASSERT(queryObject);
-
- gl::Error error = queryObject->end();
-
- // Always unbind the query, even if there was an error. This may delete the query object.
- mState.setActiveQuery(target, NULL);
-
- return error;
-}
-
-void Context::setFramebufferZero(Framebuffer *buffer)
-{
- // First, check to see if the old default framebuffer
- // was set for draw or read framebuffer, and change
- // the bindings to point to the new one before deleting it.
- if (mState.getDrawFramebuffer()->id() == 0)
- {
- mState.setDrawFramebufferBinding(buffer);
- }
-
- if (mState.getReadFramebuffer()->id() == 0)
- {
- mState.setReadFramebufferBinding(buffer);
- }
-
- delete mFramebufferMap[0];
- mFramebufferMap[0] = buffer;
-}
-
-Framebuffer *Context::getFramebuffer(unsigned int handle) const
-{
- FramebufferMap::const_iterator framebuffer = mFramebufferMap.find(handle);
-
- if (framebuffer == mFramebufferMap.end())
- {
- return NULL;
- }
- else
- {
- return framebuffer->second;
- }
-}
-
-FenceNV *Context::getFenceNV(unsigned int handle)
-{
- FenceNVMap::iterator fence = mFenceNVMap.find(handle);
-
- if (fence == mFenceNVMap.end())
- {
- return NULL;
- }
- else
- {
- return fence->second;
- }
-}
-
-Query *Context::getQuery(unsigned int handle, bool create, GLenum type)
-{
- QueryMap::iterator query = mQueryMap.find(handle);
-
- if (query == mQueryMap.end())
- {
- return NULL;
- }
- else
- {
- if (!query->second && create)
- {
- query->second = new Query(mRenderer->createQuery(type), handle);
- query->second->addRef();
- }
- return query->second;
- }
-}
-
-Texture *Context::getTargetTexture(GLenum target) const
-{
- if (!ValidTextureTarget(this, target))
- {
- return NULL;
- }
-
- switch (target)
- {
- case GL_TEXTURE_2D: return getTexture2D();
- case GL_TEXTURE_CUBE_MAP: return getTextureCubeMap();
- case GL_TEXTURE_3D: return getTexture3D();
- case GL_TEXTURE_2D_ARRAY: return getTexture2DArray();
- default: return NULL;
- }
-}
-
-Texture2D *Context::getTexture2D() const
-{
- return static_cast<Texture2D*>(getSamplerTexture(mState.getActiveSampler(), GL_TEXTURE_2D));
-}
-
-TextureCubeMap *Context::getTextureCubeMap() const
-{
- return static_cast<TextureCubeMap*>(getSamplerTexture(mState.getActiveSampler(), GL_TEXTURE_CUBE_MAP));
-}
-
-Texture3D *Context::getTexture3D() const
-{
- return static_cast<Texture3D*>(getSamplerTexture(mState.getActiveSampler(), GL_TEXTURE_3D));
-}
-
-Texture2DArray *Context::getTexture2DArray() const
-{
- return static_cast<Texture2DArray*>(getSamplerTexture(mState.getActiveSampler(), GL_TEXTURE_2D_ARRAY));
-}
-
-Texture *Context::getSamplerTexture(unsigned int sampler, GLenum type) const
-{
- return mState.getSamplerTexture(sampler, type);
-}
-
-void Context::getBooleanv(GLenum pname, GLboolean *params)
-{
- switch (pname)
- {
- case GL_SHADER_COMPILER: *params = GL_TRUE; break;
- case GL_CONTEXT_ROBUST_ACCESS_EXT: *params = mRobustAccess ? GL_TRUE : GL_FALSE; break;
- default:
- mState.getBooleanv(pname, params);
- break;
- }
-}
-
-void Context::getFloatv(GLenum pname, GLfloat *params)
-{
- // Queries about context capabilities and maximums are answered by Context.
- // Queries about current GL state values are answered by State.
- switch (pname)
- {
- case GL_ALIASED_LINE_WIDTH_RANGE:
- params[0] = mCaps.minAliasedLineWidth;
- params[1] = mCaps.maxAliasedLineWidth;
- break;
- case GL_ALIASED_POINT_SIZE_RANGE:
- params[0] = mCaps.minAliasedPointSize;
- params[1] = mCaps.maxAliasedPointSize;
- break;
- case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
- ASSERT(mExtensions.textureFilterAnisotropic);
- *params = mExtensions.maxTextureAnisotropy;
- break;
- default:
- mState.getFloatv(pname, params);
- break;
- }
-}
-
-void Context::getIntegerv(GLenum pname, GLint *params)
-{
- // Queries about context capabilities and maximums are answered by Context.
- // Queries about current GL state values are answered by State.
-
- switch (pname)
- {
- case GL_MAX_VERTEX_ATTRIBS: *params = mCaps.maxVertexAttributes; break;
- case GL_MAX_VERTEX_UNIFORM_VECTORS: *params = mCaps.maxVertexUniformVectors; break;
- case GL_MAX_VERTEX_UNIFORM_COMPONENTS: *params = mCaps.maxVertexUniformComponents; break;
- case GL_MAX_VARYING_VECTORS: *params = mCaps.maxVaryingVectors; break;
- case GL_MAX_VARYING_COMPONENTS: *params = mCaps.maxVertexOutputComponents; break;
- case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: *params = mCaps.maxCombinedTextureImageUnits; break;
- case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: *params = mCaps.maxVertexTextureImageUnits; break;
- case GL_MAX_TEXTURE_IMAGE_UNITS: *params = mCaps.maxTextureImageUnits; break;
- case GL_MAX_FRAGMENT_UNIFORM_VECTORS: *params = mCaps.maxFragmentUniformVectors; break;
- case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: *params = mCaps.maxFragmentInputComponents; break;
- case GL_MAX_RENDERBUFFER_SIZE: *params = mCaps.maxRenderbufferSize; break;
- case GL_MAX_COLOR_ATTACHMENTS_EXT: *params = mCaps.maxColorAttachments; break;
- case GL_MAX_DRAW_BUFFERS_EXT: *params = mCaps.maxDrawBuffers; break;
- //case GL_FRAMEBUFFER_BINDING: // now equivalent to GL_DRAW_FRAMEBUFFER_BINDING_ANGLE
- case GL_SUBPIXEL_BITS: *params = 4; break;
- case GL_MAX_TEXTURE_SIZE: *params = mCaps.max2DTextureSize; break;
- case GL_MAX_CUBE_MAP_TEXTURE_SIZE: *params = mCaps.maxCubeMapTextureSize; break;
- case GL_MAX_3D_TEXTURE_SIZE: *params = mCaps.max3DTextureSize; break;
- case GL_MAX_ARRAY_TEXTURE_LAYERS: *params = mCaps.maxArrayTextureLayers; break;
- case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: *params = mCaps.uniformBufferOffsetAlignment; break;
- case GL_MAX_UNIFORM_BUFFER_BINDINGS: *params = mCaps.maxUniformBufferBindings; break;
- case GL_MAX_VERTEX_UNIFORM_BLOCKS: *params = mCaps.maxVertexUniformBlocks; break;
- case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: *params = mCaps.maxFragmentUniformBlocks; break;
- case GL_MAX_COMBINED_UNIFORM_BLOCKS: *params = mCaps.maxCombinedTextureImageUnits; break;
- case GL_MAJOR_VERSION: *params = mClientVersion; break;
- case GL_MINOR_VERSION: *params = 0; break;
- case GL_MAX_ELEMENTS_INDICES: *params = mCaps.maxElementsIndices; break;
- case GL_MAX_ELEMENTS_VERTICES: *params = mCaps.maxElementsVertices; break;
- case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: *params = mCaps.maxTransformFeedbackInterleavedComponents; break;
- case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: *params = mCaps.maxTransformFeedbackSeparateAttributes; break;
- case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: *params = mCaps.maxTransformFeedbackSeparateComponents; break;
- case GL_NUM_COMPRESSED_TEXTURE_FORMATS: *params = mCaps.compressedTextureFormats.size(); break;
- case GL_MAX_SAMPLES_ANGLE: *params = mExtensions.maxSamples; break;
- case GL_IMPLEMENTATION_COLOR_READ_TYPE:
- case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
- {
- GLenum internalFormat, format, type;
- getCurrentReadFormatType(&internalFormat, &format, &type);
- if (pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT)
- *params = format;
- else
- *params = type;
- }
- break;
- case GL_MAX_VIEWPORT_DIMS:
- {
- params[0] = mCaps.maxViewportWidth;
- params[1] = mCaps.maxViewportHeight;
- }
- break;
- case GL_COMPRESSED_TEXTURE_FORMATS:
- std::copy(mCaps.compressedTextureFormats.begin(), mCaps.compressedTextureFormats.end(), params);
- break;
- case GL_RESET_NOTIFICATION_STRATEGY_EXT:
- *params = mResetStrategy;
- break;
- case GL_NUM_SHADER_BINARY_FORMATS:
- *params = mCaps.shaderBinaryFormats.size();
- break;
- case GL_SHADER_BINARY_FORMATS:
- std::copy(mCaps.shaderBinaryFormats.begin(), mCaps.shaderBinaryFormats.end(), params);
- break;
- case GL_NUM_PROGRAM_BINARY_FORMATS:
- *params = mCaps.programBinaryFormats.size();
- break;
- case GL_PROGRAM_BINARY_FORMATS:
- std::copy(mCaps.programBinaryFormats.begin(), mCaps.programBinaryFormats.end(), params);
- break;
- case GL_NUM_EXTENSIONS:
- *params = static_cast<GLint>(mExtensionStrings.size());
- break;
- default:
- mState.getIntegerv(getData(), pname, params);
- break;
- }
-}
-
-void Context::getInteger64v(GLenum pname, GLint64 *params)
-{
- // Queries about context capabilities and maximums are answered by Context.
- // Queries about current GL state values are answered by State.
- switch (pname)
- {
- case GL_MAX_ELEMENT_INDEX:
- *params = mCaps.maxElementIndex;
- break;
- case GL_MAX_UNIFORM_BLOCK_SIZE:
- *params = mCaps.maxUniformBlockSize;
- break;
- case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS:
- *params = mCaps.maxCombinedVertexUniformComponents;
- break;
- case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS:
- *params = mCaps.maxCombinedFragmentUniformComponents;
- break;
- case GL_MAX_SERVER_WAIT_TIMEOUT:
- *params = mCaps.maxServerWaitTimeout;
- break;
- default:
- UNREACHABLE();
- break;
- }
-}
-
-bool Context::getIndexedIntegerv(GLenum target, GLuint index, GLint *data)
-{
- // Queries about context capabilities and maximums are answered by Context.
- // Queries about current GL state values are answered by State.
- // Indexed integer queries all refer to current state, so this function is a
- // mere passthrough.
- return mState.getIndexedIntegerv(target, index, data);
-}
-
-bool Context::getIndexedInteger64v(GLenum target, GLuint index, GLint64 *data)
-{
- // Queries about context capabilities and maximums are answered by Context.
- // Queries about current GL state values are answered by State.
- // Indexed integer queries all refer to current state, so this function is a
- // mere passthrough.
- return mState.getIndexedInteger64v(target, index, data);
-}
-
-bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams)
-{
- if (pname >= GL_DRAW_BUFFER0_EXT && pname <= GL_DRAW_BUFFER15_EXT)
- {
- *type = GL_INT;
- *numParams = 1;
- return true;
- }
-
- // Please note: the query type returned for DEPTH_CLEAR_VALUE in this implementation
- // is FLOAT rather than INT, as would be suggested by the GL ES 2.0 spec. This is due
- // to the fact that it is stored internally as a float, and so would require conversion
- // if returned from Context::getIntegerv. Since this conversion is already implemented
- // in the case that one calls glGetIntegerv to retrieve a float-typed state variable, we
- // place DEPTH_CLEAR_VALUE with the floats. This should make no difference to the calling
- // application.
- switch (pname)
- {
- case GL_COMPRESSED_TEXTURE_FORMATS:
- {
- *type = GL_INT;
- *numParams = mCaps.compressedTextureFormats.size();
- }
- return true;
- case GL_PROGRAM_BINARY_FORMATS_OES:
- {
- *type = GL_INT;
- *numParams = mCaps.programBinaryFormats.size();
- }
- return true;
- case GL_SHADER_BINARY_FORMATS:
- {
- *type = GL_INT;
- *numParams = mCaps.shaderBinaryFormats.size();
- }
- return true;
- case GL_MAX_VERTEX_ATTRIBS:
- case GL_MAX_VERTEX_UNIFORM_VECTORS:
- case GL_MAX_VARYING_VECTORS:
- case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
- case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
- case GL_MAX_TEXTURE_IMAGE_UNITS:
- case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
- case GL_MAX_RENDERBUFFER_SIZE:
- case GL_MAX_COLOR_ATTACHMENTS_EXT:
- case GL_MAX_DRAW_BUFFERS_EXT:
- case GL_NUM_SHADER_BINARY_FORMATS:
- case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
- case GL_ARRAY_BUFFER_BINDING:
- //case GL_FRAMEBUFFER_BINDING: // equivalent to DRAW_FRAMEBUFFER_BINDING_ANGLE
- case GL_DRAW_FRAMEBUFFER_BINDING_ANGLE:
- case GL_READ_FRAMEBUFFER_BINDING_ANGLE:
- case GL_RENDERBUFFER_BINDING:
- case GL_CURRENT_PROGRAM:
- case GL_PACK_ALIGNMENT:
- case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
- case GL_UNPACK_ALIGNMENT:
- case GL_GENERATE_MIPMAP_HINT:
- case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
- case GL_RED_BITS:
- case GL_GREEN_BITS:
- case GL_BLUE_BITS:
- case GL_ALPHA_BITS:
- case GL_DEPTH_BITS:
- case GL_STENCIL_BITS:
- case GL_ELEMENT_ARRAY_BUFFER_BINDING:
- case GL_CULL_FACE_MODE:
- case GL_FRONT_FACE:
- case GL_ACTIVE_TEXTURE:
- case GL_STENCIL_FUNC:
- case GL_STENCIL_VALUE_MASK:
- case GL_STENCIL_REF:
- case GL_STENCIL_FAIL:
- case GL_STENCIL_PASS_DEPTH_FAIL:
- case GL_STENCIL_PASS_DEPTH_PASS:
- case GL_STENCIL_BACK_FUNC:
- case GL_STENCIL_BACK_VALUE_MASK:
- case GL_STENCIL_BACK_REF:
- case GL_STENCIL_BACK_FAIL:
- case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
- case GL_STENCIL_BACK_PASS_DEPTH_PASS:
- case GL_DEPTH_FUNC:
- case GL_BLEND_SRC_RGB:
- case GL_BLEND_SRC_ALPHA:
- case GL_BLEND_DST_RGB:
- case GL_BLEND_DST_ALPHA:
- case GL_BLEND_EQUATION_RGB:
- case GL_BLEND_EQUATION_ALPHA:
- case GL_STENCIL_WRITEMASK:
- case GL_STENCIL_BACK_WRITEMASK:
- case GL_STENCIL_CLEAR_VALUE:
- case GL_SUBPIXEL_BITS:
- case GL_MAX_TEXTURE_SIZE:
- case GL_MAX_CUBE_MAP_TEXTURE_SIZE:
- case GL_SAMPLE_BUFFERS:
- case GL_SAMPLES:
- case GL_IMPLEMENTATION_COLOR_READ_TYPE:
- case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
- case GL_TEXTURE_BINDING_2D:
- case GL_TEXTURE_BINDING_CUBE_MAP:
- case GL_RESET_NOTIFICATION_STRATEGY_EXT:
- case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
- {
- *type = GL_INT;
- *numParams = 1;
- }
- return true;
- case GL_MAX_SAMPLES_ANGLE:
- {
- if (mExtensions.framebufferMultisample)
- {
- *type = GL_INT;
- *numParams = 1;
- }
- else
- {
- return false;
- }
- }
- return true;
- case GL_PIXEL_PACK_BUFFER_BINDING:
- case GL_PIXEL_UNPACK_BUFFER_BINDING:
- {
- if (mExtensions.pixelBufferObject)
- {
- *type = GL_INT;
- *numParams = 1;
- }
- else
- {
- return false;
- }
- }
- return true;
- case GL_MAX_VIEWPORT_DIMS:
- {
- *type = GL_INT;
- *numParams = 2;
- }
- return true;
- case GL_VIEWPORT:
- case GL_SCISSOR_BOX:
- {
- *type = GL_INT;
- *numParams = 4;
- }
- return true;
- case GL_SHADER_COMPILER:
- case GL_SAMPLE_COVERAGE_INVERT:
- case GL_DEPTH_WRITEMASK:
- case GL_CULL_FACE: // CULL_FACE through DITHER are natural to IsEnabled,
- case GL_POLYGON_OFFSET_FILL: // but can be retrieved through the Get{Type}v queries.
- case GL_SAMPLE_ALPHA_TO_COVERAGE: // For this purpose, they are treated here as bool-natural
- case GL_SAMPLE_COVERAGE:
- case GL_SCISSOR_TEST:
- case GL_STENCIL_TEST:
- case GL_DEPTH_TEST:
- case GL_BLEND:
- case GL_DITHER:
- case GL_CONTEXT_ROBUST_ACCESS_EXT:
- {
- *type = GL_BOOL;
- *numParams = 1;
- }
- return true;
- case GL_COLOR_WRITEMASK:
- {
- *type = GL_BOOL;
- *numParams = 4;
- }
- return true;
- case GL_POLYGON_OFFSET_FACTOR:
- case GL_POLYGON_OFFSET_UNITS:
- case GL_SAMPLE_COVERAGE_VALUE:
- case GL_DEPTH_CLEAR_VALUE:
- case GL_LINE_WIDTH:
- {
- *type = GL_FLOAT;
- *numParams = 1;
- }
- return true;
- case GL_ALIASED_LINE_WIDTH_RANGE:
- case GL_ALIASED_POINT_SIZE_RANGE:
- case GL_DEPTH_RANGE:
- {
- *type = GL_FLOAT;
- *numParams = 2;
- }
- return true;
- case GL_COLOR_CLEAR_VALUE:
- case GL_BLEND_COLOR:
- {
- *type = GL_FLOAT;
- *numParams = 4;
- }
- return true;
- case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
- if (!mExtensions.maxTextureAnisotropy)
- {
- return false;
- }
- *type = GL_FLOAT;
- *numParams = 1;
- return true;
- }
-
- if (mClientVersion < 3)
- {
- return false;
- }
-
- // Check for ES3.0+ parameter names
- switch (pname)
- {
- case GL_MAX_UNIFORM_BUFFER_BINDINGS:
- case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT:
- case GL_UNIFORM_BUFFER_BINDING:
- case GL_TRANSFORM_FEEDBACK_BINDING:
- case GL_COPY_READ_BUFFER_BINDING:
- case GL_COPY_WRITE_BUFFER_BINDING:
- case GL_TEXTURE_BINDING_3D:
- case GL_TEXTURE_BINDING_2D_ARRAY:
- case GL_MAX_3D_TEXTURE_SIZE:
- case GL_MAX_ARRAY_TEXTURE_LAYERS:
- case GL_MAX_VERTEX_UNIFORM_BLOCKS:
- case GL_MAX_FRAGMENT_UNIFORM_BLOCKS:
- case GL_MAX_COMBINED_UNIFORM_BLOCKS:
- case GL_MAX_VARYING_COMPONENTS:
- case GL_VERTEX_ARRAY_BINDING:
- case GL_MAX_VERTEX_UNIFORM_COMPONENTS:
- case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS:
- case GL_NUM_EXTENSIONS:
- case GL_MAJOR_VERSION:
- case GL_MINOR_VERSION:
- case GL_MAX_ELEMENTS_INDICES:
- case GL_MAX_ELEMENTS_VERTICES:
- case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:
- case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:
- case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:
- {
- *type = GL_INT;
- *numParams = 1;
- }
- return true;
-
- case GL_MAX_ELEMENT_INDEX:
- case GL_MAX_UNIFORM_BLOCK_SIZE:
- case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS:
- case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS:
- case GL_MAX_SERVER_WAIT_TIMEOUT:
- {
- *type = GL_INT_64_ANGLEX;
- *numParams = 1;
- }
- return true;
-
- case GL_TRANSFORM_FEEDBACK_ACTIVE:
- case GL_TRANSFORM_FEEDBACK_PAUSED:
- {
- *type = GL_BOOL;
- *numParams = 1;
- }
- return true;
- }
-
- return false;
-}
-
-bool Context::getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams)
-{
- if (mClientVersion < 3)
- {
- return false;
- }
-
- switch (target)
- {
- case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
- case GL_UNIFORM_BUFFER_BINDING:
- {
- *type = GL_INT;
- *numParams = 1;
- }
- return true;
- case GL_TRANSFORM_FEEDBACK_BUFFER_START:
- case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
- case GL_UNIFORM_BUFFER_START:
- case GL_UNIFORM_BUFFER_SIZE:
- {
- *type = GL_INT_64_ANGLEX;
- *numParams = 1;
- }
- }
-
- return false;
-}
-
-Error Context::clear(GLbitfield mask)
-{
- if (mState.isRasterizerDiscardEnabled())
- {
- return Error(GL_NO_ERROR);
- }
-
- return mRenderer->clear(getData(), mask);
-}
-
-Error Context::clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values)
-{
- if (mState.isRasterizerDiscardEnabled())
- {
- return Error(GL_NO_ERROR);
- }
-
- return mRenderer->clearBufferfv(getData(), buffer, drawbuffer, values);
-}
-
-Error Context::clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values)
-{
- if (mState.isRasterizerDiscardEnabled())
- {
- return Error(GL_NO_ERROR);
- }
-
- return mRenderer->clearBufferuiv(getData(), buffer, drawbuffer, values);
-}
-
-Error Context::clearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *values)
-{
- if (mState.isRasterizerDiscardEnabled())
- {
- return Error(GL_NO_ERROR);
- }
-
- return mRenderer->clearBufferiv(getData(), buffer, drawbuffer, values);
-}
-
-Error Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
-{
- if (mState.isRasterizerDiscardEnabled())
- {
- return Error(GL_NO_ERROR);
- }
-
- return mRenderer->clearBufferfi(getData(), buffer, drawbuffer, depth, stencil);
-}
-
-Error Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
- GLenum format, GLenum type, GLsizei *bufSize, void* pixels)
-{
- return mRenderer->readPixels(getData(), x, y, width, height, format, type, bufSize, pixels);
-}
-
-Error Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances)
-{
- return mRenderer->drawArrays(getData(), mode, first, count, instances);
-}
-
-Error Context::drawElements(GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices, GLsizei instances,
- const rx::RangeUI &indexRange)
-{
- return mRenderer->drawElements(getData(), mode, count, type, indices, instances, indexRange);
-}
-
-// Implements glFlush when block is false, glFinish when block is true
-Error Context::sync(bool block)
-{
- return mRenderer->sync(block);
-}
-
-void Context::recordError(const Error &error)
-{
- if (error.isError())
- {
- mErrors.insert(error.getCode());
- }
-}
-
-// Get one of the recorded errors and clear its flag, if any.
-// [OpenGL ES 2.0.24] section 2.5 page 13.
-GLenum Context::getError()
-{
- if (mErrors.empty())
- {
- return GL_NO_ERROR;
- }
- else
- {
- GLenum error = *mErrors.begin();
- mErrors.erase(mErrors.begin());
- return error;
- }
-}
-
-GLenum Context::getResetStatus()
-{
- //TODO(jmadill): needs MANGLE reworking
- if (mResetStatus == GL_NO_ERROR && !mContextLost)
- {
- // mResetStatus will be set by the markContextLost callback
- // in the case a notification is sent
- mRenderer->testDeviceLost(true);
- }
-
- GLenum status = mResetStatus;
-
- if (mResetStatus != GL_NO_ERROR)
- {
- ASSERT(mContextLost);
-
- if (mRenderer->testDeviceResettable())
- {
- mResetStatus = GL_NO_ERROR;
- }
- }
-
- return status;
-}
-
-bool Context::isResetNotificationEnabled()
-{
- return (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT);
-}
-
-int Context::getClientVersion() const
-{
- return mClientVersion;
-}
-
-const Caps &Context::getCaps() const
-{
- return mCaps;
-}
-
-const TextureCapsMap &Context::getTextureCaps() const
-{
- return mTextureCaps;
-}
-
-const Extensions &Context::getExtensions() const
-{
- return mExtensions;
-}
-
-void Context::getCurrentReadFormatType(GLenum *internalFormat, GLenum *format, GLenum *type)
-{
- Framebuffer *framebuffer = mState.getReadFramebuffer();
- ASSERT(framebuffer && framebuffer->completeness(getData()) == GL_FRAMEBUFFER_COMPLETE);
-
- FramebufferAttachment *attachment = framebuffer->getReadColorbuffer();
- ASSERT(attachment);
-
- GLenum actualFormat = attachment->getActualFormat();
- const InternalFormat &actualFormatInfo = GetInternalFormatInfo(actualFormat);
-
- *internalFormat = actualFormat;
- *format = actualFormatInfo.format;
- *type = actualFormatInfo.type;
-}
-
-void Context::detachTexture(GLuint texture)
-{
- // Simple pass-through to State's detachTexture method, as textures do not require
- // allocation map management either here or in the resource manager at detach time.
- // Zero textures are held by the Context, and we don't attempt to request them from
- // the State.
- mState.detachTexture(mZeroTextures, texture);
-}
-
-void Context::detachBuffer(GLuint buffer)
-{
- // Buffer detachment is handled by Context, because the buffer must also be
- // attached from any VAOs in existence, and Context holds the VAO map.
-
- // [OpenGL ES 2.0.24] section 2.9 page 22:
- // If a buffer object is deleted while it is bound, all bindings to that object in the current context
- // (i.e. in the thread that called Delete-Buffers) are reset to zero.
-
- mState.removeArrayBufferBinding(buffer);
-
- // mark as freed among the vertex array objects
- for (auto vaoIt = mVertexArrayMap.begin(); vaoIt != mVertexArrayMap.end(); vaoIt++)
- {
- vaoIt->second->detachBuffer(buffer);
- }
-}
-
-void Context::detachFramebuffer(GLuint framebuffer)
-{
- // Framebuffer detachment is handled by Context, because 0 is a valid
- // Framebuffer object, and a pointer to it must be passed from Context
- // to State at binding time.
-
- // [OpenGL ES 2.0.24] section 4.4 page 107:
- // If a framebuffer that is currently bound to the target FRAMEBUFFER is deleted, it is as though
- // BindFramebuffer had been executed with the target of FRAMEBUFFER and framebuffer of zero.
-
- if (mState.removeReadFramebufferBinding(framebuffer))
- {
- bindReadFramebuffer(0);
- }
-
- if (mState.removeDrawFramebufferBinding(framebuffer))
- {
- bindDrawFramebuffer(0);
- }
-}
-
-void Context::detachRenderbuffer(GLuint renderbuffer)
-{
- mState.detachRenderbuffer(renderbuffer);
-}
-
-void Context::detachVertexArray(GLuint vertexArray)
-{
- // Vertex array detachment is handled by Context, because 0 is a valid
- // VAO, and a pointer to it must be passed from Context to State at
- // binding time.
-
- // [OpenGL ES 3.0.2] section 2.10 page 43:
- // If a vertex array object that is currently bound is deleted, the binding
- // for that object reverts to zero and the default vertex array becomes current.
- if (mState.removeVertexArrayBinding(vertexArray))
- {
- bindVertexArray(0);
- }
-}
-
-void Context::detachTransformFeedback(GLuint transformFeedback)
-{
- mState.detachTransformFeedback(transformFeedback);
-}
-
-void Context::detachSampler(GLuint sampler)
-{
- mState.detachSampler(sampler);
-}
-
-void Context::setVertexAttribDivisor(GLuint index, GLuint divisor)
-{
- mState.getVertexArray()->setVertexAttribDivisor(index, divisor);
-}
-
-void Context::samplerParameteri(GLuint sampler, GLenum pname, GLint param)
-{
- mResourceManager->checkSamplerAllocation(sampler);
-
- Sampler *samplerObject = getSampler(sampler);
- ASSERT(samplerObject);
-
- switch (pname)
- {
- case GL_TEXTURE_MIN_FILTER: samplerObject->setMinFilter(static_cast<GLenum>(param)); break;
- case GL_TEXTURE_MAG_FILTER: samplerObject->setMagFilter(static_cast<GLenum>(param)); break;
- case GL_TEXTURE_WRAP_S: samplerObject->setWrapS(static_cast<GLenum>(param)); break;
- case GL_TEXTURE_WRAP_T: samplerObject->setWrapT(static_cast<GLenum>(param)); break;
- case GL_TEXTURE_WRAP_R: samplerObject->setWrapR(static_cast<GLenum>(param)); break;
- case GL_TEXTURE_MIN_LOD: samplerObject->setMinLod(static_cast<GLfloat>(param)); break;
- case GL_TEXTURE_MAX_LOD: samplerObject->setMaxLod(static_cast<GLfloat>(param)); break;
- case GL_TEXTURE_COMPARE_MODE: samplerObject->setComparisonMode(static_cast<GLenum>(param)); break;
- case GL_TEXTURE_COMPARE_FUNC: samplerObject->setComparisonFunc(static_cast<GLenum>(param)); break;
- default: UNREACHABLE(); break;
- }
-}
-
-void Context::samplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
-{
- mResourceManager->checkSamplerAllocation(sampler);
-
- Sampler *samplerObject = getSampler(sampler);
- ASSERT(samplerObject);
-
- switch (pname)
- {
- case GL_TEXTURE_MIN_FILTER: samplerObject->setMinFilter(uiround<GLenum>(param)); break;
- case GL_TEXTURE_MAG_FILTER: samplerObject->setMagFilter(uiround<GLenum>(param)); break;
- case GL_TEXTURE_WRAP_S: samplerObject->setWrapS(uiround<GLenum>(param)); break;
- case GL_TEXTURE_WRAP_T: samplerObject->setWrapT(uiround<GLenum>(param)); break;
- case GL_TEXTURE_WRAP_R: samplerObject->setWrapR(uiround<GLenum>(param)); break;
- case GL_TEXTURE_MIN_LOD: samplerObject->setMinLod(param); break;
- case GL_TEXTURE_MAX_LOD: samplerObject->setMaxLod(param); break;
- case GL_TEXTURE_COMPARE_MODE: samplerObject->setComparisonMode(uiround<GLenum>(param)); break;
- case GL_TEXTURE_COMPARE_FUNC: samplerObject->setComparisonFunc(uiround<GLenum>(param)); break;
- default: UNREACHABLE(); break;
- }
-}
-
-GLint Context::getSamplerParameteri(GLuint sampler, GLenum pname)
-{
- mResourceManager->checkSamplerAllocation(sampler);
-
- Sampler *samplerObject = getSampler(sampler);
- ASSERT(samplerObject);
-
- switch (pname)
- {
- case GL_TEXTURE_MIN_FILTER: return static_cast<GLint>(samplerObject->getMinFilter());
- case GL_TEXTURE_MAG_FILTER: return static_cast<GLint>(samplerObject->getMagFilter());
- case GL_TEXTURE_WRAP_S: return static_cast<GLint>(samplerObject->getWrapS());
- case GL_TEXTURE_WRAP_T: return static_cast<GLint>(samplerObject->getWrapT());
- case GL_TEXTURE_WRAP_R: return static_cast<GLint>(samplerObject->getWrapR());
- case GL_TEXTURE_MIN_LOD: return uiround<GLint>(samplerObject->getMinLod());
- case GL_TEXTURE_MAX_LOD: return uiround<GLint>(samplerObject->getMaxLod());
- case GL_TEXTURE_COMPARE_MODE: return static_cast<GLint>(samplerObject->getComparisonMode());
- case GL_TEXTURE_COMPARE_FUNC: return static_cast<GLint>(samplerObject->getComparisonFunc());
- default: UNREACHABLE(); return 0;
- }
-}
-
-GLfloat Context::getSamplerParameterf(GLuint sampler, GLenum pname)
-{
- mResourceManager->checkSamplerAllocation(sampler);
-
- Sampler *samplerObject = getSampler(sampler);
- ASSERT(samplerObject);
-
- switch (pname)
- {
- case GL_TEXTURE_MIN_FILTER: return static_cast<GLfloat>(samplerObject->getMinFilter());
- case GL_TEXTURE_MAG_FILTER: return static_cast<GLfloat>(samplerObject->getMagFilter());
- case GL_TEXTURE_WRAP_S: return static_cast<GLfloat>(samplerObject->getWrapS());
- case GL_TEXTURE_WRAP_T: return static_cast<GLfloat>(samplerObject->getWrapT());
- case GL_TEXTURE_WRAP_R: return static_cast<GLfloat>(samplerObject->getWrapR());
- case GL_TEXTURE_MIN_LOD: return samplerObject->getMinLod();
- case GL_TEXTURE_MAX_LOD: return samplerObject->getMaxLod();
- case GL_TEXTURE_COMPARE_MODE: return static_cast<GLfloat>(samplerObject->getComparisonMode());
- case GL_TEXTURE_COMPARE_FUNC: return static_cast<GLfloat>(samplerObject->getComparisonFunc());
- default: UNREACHABLE(); return 0;
- }
-}
-
-void Context::initRendererString()
-{
- std::ostringstream rendererString;
- rendererString << "ANGLE (";
- rendererString << mRenderer->getRendererDescription();
- rendererString << ")";
-
- mRendererString = MakeStaticString(rendererString.str());
-}
-
-const std::string &Context::getRendererString() const
-{
- return mRendererString;
-}
-
-void Context::initExtensionStrings()
-{
- mExtensionStrings = mExtensions.getStrings();
-
- std::ostringstream combinedStringStream;
- std::copy(mExtensionStrings.begin(), mExtensionStrings.end(), std::ostream_iterator<std::string>(combinedStringStream, " "));
- mExtensionString = combinedStringStream.str();
-}
-
-const std::string &Context::getExtensionString() const
-{
- return mExtensionString;
-}
-
-const std::string &Context::getExtensionString(size_t idx) const
-{
- return mExtensionStrings[idx];
-}
-
-size_t Context::getExtensionStringCount() const
-{
- return mExtensionStrings.size();
-}
-
-Error Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
- GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
- GLbitfield mask, GLenum filter)
-{
- return mRenderer->blitFramebuffer(getData(), srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1, mask, filter);
-}
-
-void Context::releaseShaderCompiler()
-{
- mRenderer->releaseShaderCompiler();
-}
-
-void Context::initCaps(GLuint clientVersion)
-{
- mCaps = mRenderer->getRendererCaps();
-
- mExtensions = mRenderer->getRendererExtensions();
-
- if (clientVersion < 3)
- {
- // Disable ES3+ extensions
- mExtensions.colorBufferFloat = false;
- }
-
- if (clientVersion > 2)
- {
- // FIXME(geofflang): Don't support EXT_sRGB in non-ES2 contexts
- //mExtensions.sRGB = false;
- }
-
- // Apply implementation limits
- mCaps.maxVertexAttributes = std::min<GLuint>(mCaps.maxVertexAttributes, MAX_VERTEX_ATTRIBS);
- mCaps.maxVertexUniformBlocks = std::min<GLuint>(mCaps.maxVertexUniformBlocks, IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS);
- mCaps.maxVertexOutputComponents = std::min<GLuint>(mCaps.maxVertexOutputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4);
-
- mCaps.maxFragmentInputComponents = std::min<GLuint>(mCaps.maxFragmentInputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4);
-
- GLuint maxSamples = 0;
- mCaps.compressedTextureFormats.clear();
-
- const TextureCapsMap &rendererFormats = mRenderer->getRendererTextureCaps();
- for (TextureCapsMap::const_iterator i = rendererFormats.begin(); i != rendererFormats.end(); i++)
- {
- GLenum format = i->first;
- TextureCaps formatCaps = i->second;
-
- const InternalFormat &formatInfo = GetInternalFormatInfo(format);
-
- // Update the format caps based on the client version and extensions
- formatCaps.texturable = formatInfo.textureSupport(clientVersion, mExtensions);
- formatCaps.renderable = formatInfo.renderSupport(clientVersion, mExtensions);
- formatCaps.filterable = formatInfo.filterSupport(clientVersion, mExtensions);
-
- // OpenGL ES does not support multisampling with integer formats
- if (!formatInfo.renderSupport || formatInfo.componentType == GL_INT || formatInfo.componentType == GL_UNSIGNED_INT)
- {
- formatCaps.sampleCounts.clear();
- }
- maxSamples = std::max(maxSamples, formatCaps.getMaxSamples());
-
- if (formatCaps.texturable && formatInfo.compressed)
- {
- mCaps.compressedTextureFormats.push_back(format);
- }
-
- mTextureCaps.insert(format, formatCaps);
- }
-
- mExtensions.maxSamples = maxSamples;
-}
-
-Data Context::getData() const
-{
- return Data(mClientVersion, mState, mCaps, mTextureCaps, mExtensions, mResourceManager);
-}
-
-}
-
-extern "C"
-{
-gl::Context *glCreateContext(int clientVersion, const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess)
-{
- return new gl::Context(clientVersion, shareContext, renderer, notifyResets, robustAccess);
-}
-
-void glDestroyContext(gl::Context *context)
-{
- delete context;
-
- if (context == gl::getContext())
- {
- gl::makeCurrent(NULL, NULL, NULL);
- }
-}
-
-void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *surface)
-{
- gl::makeCurrent(context, display, surface);
-}
-
-gl::Context *glGetCurrentContext()
-{
- return gl::getContext();
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/Context.h b/src/3rdparty/angle/src/libGLESv2/Context.h
deleted file mode 100644
index 0699592d91..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Context.h
+++ /dev/null
@@ -1,291 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// Context.h: Defines the gl::Context class, managing all GL state and performing
-// rendering operations. It is the GLES2 specific implementation of EGLContext.
-
-#ifndef LIBGLESV2_CONTEXT_H_
-#define LIBGLESV2_CONTEXT_H_
-
-#include "common/angleutils.h"
-#include "common/RefCountObject.h"
-#include "libGLESv2/Caps.h"
-#include "libGLESv2/Constants.h"
-#include "libGLESv2/Data.h"
-#include "libGLESv2/Error.h"
-#include "libGLESv2/HandleAllocator.h"
-#include "libGLESv2/VertexAttribute.h"
-#include "libGLESv2/angletypes.h"
-
-#include "angle_gl.h"
-
-#include <string>
-#include <set>
-#include <map>
-#include <unordered_map>
-#include <array>
-
-namespace rx
-{
-class Renderer;
-}
-
-namespace egl
-{
-class Surface;
-}
-
-namespace gl
-{
-class Shader;
-class Program;
-class ProgramBinary;
-class Texture;
-class Texture2D;
-class TextureCubeMap;
-class Texture3D;
-class Texture2DArray;
-class Framebuffer;
-class Renderbuffer;
-class FenceNV;
-class FenceSync;
-class Query;
-class ResourceManager;
-class Buffer;
-struct VertexAttribute;
-class VertexArray;
-class Sampler;
-class TransformFeedback;
-
-class Context
-{
- public:
- Context(int clientVersion, const Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess);
-
- virtual ~Context();
-
- void makeCurrent(egl::Surface *surface);
-
- virtual void markContextLost();
- bool isContextLost();
-
- // These create and destroy methods are merely pass-throughs to
- // ResourceManager, which owns these object types
- GLuint createBuffer();
- GLuint createShader(GLenum type);
- GLuint createProgram();
- GLuint createTexture();
- GLuint createRenderbuffer();
- GLuint createSampler();
- GLuint createTransformFeedback();
- GLsync createFenceSync();
-
- void deleteBuffer(GLuint buffer);
- void deleteShader(GLuint shader);
- void deleteProgram(GLuint program);
- void deleteTexture(GLuint texture);
- void deleteRenderbuffer(GLuint renderbuffer);
- void deleteSampler(GLuint sampler);
- void deleteTransformFeedback(GLuint transformFeedback);
- void deleteFenceSync(GLsync fenceSync);
-
- // Framebuffers are owned by the Context, so these methods do not pass through
- GLuint createFramebuffer();
- void deleteFramebuffer(GLuint framebuffer);
-
- // NV Fences are owned by the Context.
- GLuint createFenceNV();
- void deleteFenceNV(GLuint fence);
-
- // Queries are owned by the Context;
- GLuint createQuery();
- void deleteQuery(GLuint query);
-
- // Vertex arrays are owned by the Context
- GLuint createVertexArray();
- void deleteVertexArray(GLuint vertexArray);
-
- void bindArrayBuffer(GLuint buffer);
- void bindElementArrayBuffer(GLuint buffer);
- void bindTexture(GLenum target, GLuint handle);
- void bindReadFramebuffer(GLuint framebuffer);
- void bindDrawFramebuffer(GLuint framebuffer);
- void bindRenderbuffer(GLuint renderbuffer);
- void bindVertexArray(GLuint vertexArray);
- void bindSampler(GLuint textureUnit, GLuint sampler);
- void bindGenericUniformBuffer(GLuint buffer);
- void bindIndexedUniformBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size);
- void bindGenericTransformFeedbackBuffer(GLuint buffer);
- void bindIndexedTransformFeedbackBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size);
- void bindCopyReadBuffer(GLuint buffer);
- void bindCopyWriteBuffer(GLuint buffer);
- void bindPixelPackBuffer(GLuint buffer);
- void bindPixelUnpackBuffer(GLuint buffer);
- void useProgram(GLuint program);
- Error linkProgram(GLuint program);
- Error setProgramBinary(GLuint program, GLenum binaryFormat, const void *binary, GLint length);
- void bindTransformFeedback(GLuint transformFeedback);
-
- Error beginQuery(GLenum target, GLuint query);
- Error endQuery(GLenum target);
-
- void setFramebufferZero(Framebuffer *framebuffer);
-
- void setVertexAttribDivisor(GLuint index, GLuint divisor);
-
- void samplerParameteri(GLuint sampler, GLenum pname, GLint param);
- void samplerParameterf(GLuint sampler, GLenum pname, GLfloat param);
- GLint getSamplerParameteri(GLuint sampler, GLenum pname);
- GLfloat getSamplerParameterf(GLuint sampler, GLenum pname);
-
- Buffer *getBuffer(GLuint handle);
- FenceNV *getFenceNV(GLuint handle);
- FenceSync *getFenceSync(GLsync handle) const;
- Shader *getShader(GLuint handle) const;
- Program *getProgram(GLuint handle) const;
- Texture *getTexture(GLuint handle) const;
- Framebuffer *getFramebuffer(GLuint handle) const;
- Renderbuffer *getRenderbuffer(GLuint handle);
- VertexArray *getVertexArray(GLuint handle) const;
- Sampler *getSampler(GLuint handle) const;
- Query *getQuery(GLuint handle, bool create, GLenum type);
- TransformFeedback *getTransformFeedback(GLuint handle) const;
-
- Texture *getTargetTexture(GLenum target) const;
- Texture2D *getTexture2D() const;
- TextureCubeMap *getTextureCubeMap() const;
- Texture3D *getTexture3D() const;
- Texture2DArray *getTexture2DArray() const;
-
- Texture *getSamplerTexture(unsigned int sampler, GLenum type) const;
-
- bool isSampler(GLuint samplerName) const;
-
- void getBooleanv(GLenum pname, GLboolean *params);
- void getFloatv(GLenum pname, GLfloat *params);
- void getIntegerv(GLenum pname, GLint *params);
- void getInteger64v(GLenum pname, GLint64 *params);
-
- bool getIndexedIntegerv(GLenum target, GLuint index, GLint *data);
- bool getIndexedInteger64v(GLenum target, GLuint index, GLint64 *data);
-
- bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams);
- bool getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams);
-
- Error clear(GLbitfield mask);
- Error clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values);
- Error clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values);
- Error clearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *values);
- Error clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
-
- Error readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei *bufSize, void* pixels);
- Error drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances);
- Error drawElements(GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices, GLsizei instances,
- const rx::RangeUI &indexRange);
- Error sync(bool block); // flush/finish
-
- void recordError(const Error &error);
-
- GLenum getError();
- GLenum getResetStatus();
- virtual bool isResetNotificationEnabled();
-
- virtual int getClientVersion() const;
-
- const Caps &getCaps() const;
- const TextureCapsMap &getTextureCaps() const;
- const Extensions &getExtensions() const;
-
- const std::string &getRendererString() const;
-
- const std::string &getExtensionString() const;
- const std::string &getExtensionString(size_t idx) const;
- size_t getExtensionStringCount() const;
-
- void getCurrentReadFormatType(GLenum *internalFormat, GLenum *format, GLenum *type);
-
- Error blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
- GLbitfield mask, GLenum filter);
-
- rx::Renderer *getRenderer() { return mRenderer; }
-
- State &getState() { return mState; }
- const State &getState() const { return mState; }
-
- Data getData() const;
-
- void releaseShaderCompiler();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Context);
-
- void detachBuffer(GLuint buffer);
- void detachTexture(GLuint texture);
- void detachFramebuffer(GLuint framebuffer);
- void detachRenderbuffer(GLuint renderbuffer);
- void detachVertexArray(GLuint vertexArray);
- void detachTransformFeedback(GLuint transformFeedback);
- void detachSampler(GLuint sampler);
-
- void initRendererString();
- void initExtensionStrings();
-
- void initCaps(GLuint clientVersion);
-
- // Caps to use for validation
- Caps mCaps;
- TextureCapsMap mTextureCaps;
- Extensions mExtensions;
-
- rx::Renderer *const mRenderer;
- State mState;
-
- int mClientVersion;
-
- TextureMap mZeroTextures;
-
- typedef std::unordered_map<GLuint, Framebuffer*> FramebufferMap;
- FramebufferMap mFramebufferMap;
- HandleAllocator mFramebufferHandleAllocator;
-
- typedef std::unordered_map<GLuint, FenceNV*> FenceNVMap;
- FenceNVMap mFenceNVMap;
- HandleAllocator mFenceNVHandleAllocator;
-
- typedef std::unordered_map<GLuint, Query*> QueryMap;
- QueryMap mQueryMap;
- HandleAllocator mQueryHandleAllocator;
-
- typedef std::unordered_map<GLuint, VertexArray*> VertexArrayMap;
- VertexArrayMap mVertexArrayMap;
- HandleAllocator mVertexArrayHandleAllocator;
-
- BindingPointer<TransformFeedback> mTransformFeedbackZero;
- typedef std::unordered_map<GLuint, TransformFeedback*> TransformFeedbackMap;
- TransformFeedbackMap mTransformFeedbackMap;
- HandleAllocator mTransformFeedbackAllocator;
-
- std::string mRendererString;
- std::string mExtensionString;
- std::vector<std::string> mExtensionStrings;
-
- // Recorded errors
- typedef std::set<GLenum> ErrorSet;
- ErrorSet mErrors;
-
- // Current/lost context flags
- bool mHasBeenCurrent;
- bool mContextLost;
- GLenum mResetStatus;
- GLenum mResetStrategy;
- bool mRobustAccess;
-
- ResourceManager *mResourceManager;
-};
-}
-
-#endif // INCLUDE_CONTEXT_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/Data.cpp b/src/3rdparty/angle/src/libGLESv2/Data.cpp
deleted file mode 100644
index 3ddf591d77..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Data.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// Data.cpp: Container class for all GL relevant state, caps and objects
-
-#include "libGLESv2/Data.h"
-#include "libGLESv2/ResourceManager.h"
-
-namespace gl
-{
-
-Data::Data(GLint clientVersionIn, const State &stateIn, const Caps &capsIn,
- const TextureCapsMap &textureCapsIn, const Extensions &extensionsIn,
- const ResourceManager *resourceManagerIn)
- : clientVersion(clientVersionIn),
- state(&stateIn),
- caps(&capsIn),
- textureCaps(&textureCapsIn),
- extensions(&extensionsIn),
- resourceManager(resourceManagerIn)
-{}
-
-Data::~Data()
-{
-}
-
-Data::Data(const Data &other)
- : clientVersion(other.clientVersion),
- state(other.state),
- caps(other.caps),
- textureCaps(other.textureCaps),
- extensions(other.extensions),
- resourceManager(other.resourceManager)
-{
-}
-
-Data &Data::operator=(const Data &other)
-{
- clientVersion = other.clientVersion;
- state = other.state;
- caps = other.caps;
- textureCaps = other.textureCaps;
- extensions = other.extensions;
- resourceManager = other.resourceManager;
- return *this;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/Data.h b/src/3rdparty/angle/src/libGLESv2/Data.h
deleted file mode 100644
index 9234403e13..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Data.h
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// Data.h: Container class for all GL relevant state, caps and objects
-
-#ifndef LIBGLESV2_DATA_H_
-#define LIBGLESV2_DATA_H_
-
-#include "libGLESv2/State.h"
-
-namespace gl
-{
-
-struct Data
-{
- public:
- Data(GLint clientVersion, const State &state, const Caps &caps,
- const TextureCapsMap &textureCaps, const Extensions &extensions,
- const ResourceManager *resourceManager);
- ~Data();
-
- Data(const Data &other);
- Data &operator=(const Data &other);
-
- GLint clientVersion;
- const State *state;
- const Caps *caps;
- const TextureCapsMap *textureCaps;
- const Extensions *extensions;
- const ResourceManager *resourceManager;
-};
-
-}
-
-#endif // LIBGLESV2_DATA_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/Error.cpp b/src/3rdparty/angle/src/libGLESv2/Error.cpp
deleted file mode 100644
index cc7d17eb37..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Error.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// Error.cpp: Implements the gl::Error class which encapsulates an OpenGL error
-// and optional error message.
-
-#include "libGLESv2/Error.h"
-
-#include "common/angleutils.h"
-
-#include <cstdarg>
-
-namespace gl
-{
-
-Error::Error(GLenum errorCode)
- : mCode(errorCode),
- mMessage()
-{
-}
-
-Error::Error(GLenum errorCode, const char *msg, ...)
- : mCode(errorCode),
- mMessage()
-{
- va_list vararg;
- va_start(vararg, msg);
- mMessage = FormatString(msg, vararg);
- va_end(vararg);
-}
-
-Error::Error(const Error &other)
- : mCode(other.mCode),
- mMessage(other.mMessage)
-{
-}
-
-Error &Error::operator=(const Error &other)
-{
- mCode = other.mCode;
- mMessage = other.mMessage;
- return *this;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/Error.h b/src/3rdparty/angle/src/libGLESv2/Error.h
deleted file mode 100644
index b70b5a531c..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Error.h
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// Copyright (c) 2014 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.
-
-// Error.h: Defines the gl::Error class which encapsulates an OpenGL error
-// and optional error message.
-
-#ifndef LIBGLESV2_ERROR_H_
-#define LIBGLESV2_ERROR_H_
-
-#include "angle_gl.h"
-
-#include <string>
-
-namespace gl
-{
-
-class Error
-{
- public:
- explicit Error(GLenum errorCode);
- Error(GLenum errorCode, const char *msg, ...);
- Error(const Error &other);
- Error &operator=(const Error &other);
-
- GLenum getCode() const { return mCode; }
- bool isError() const { return (mCode != GL_NO_ERROR); }
-
- const std::string &getMessage() const { return mMessage; }
-
- private:
- GLenum mCode;
- std::string mMessage;
-};
-
-}
-
-#endif // LIBGLESV2_ERROR_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/Fence.cpp b/src/3rdparty/angle/src/libGLESv2/Fence.cpp
deleted file mode 100644
index 966a327de5..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Fence.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-//
-// Copyright (c) 2002-2013 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.
-//
-
-// Fence.cpp: Implements the gl::FenceNV and gl::FenceSync classes, which support the GL_NV_fence
-// extension and GLES3 sync objects.
-
-#include "libGLESv2/Fence.h"
-#include "libGLESv2/renderer/FenceImpl.h"
-#include "libGLESv2/renderer/Renderer.h"
-#include "libGLESv2/main.h"
-#include "common/utilities.h"
-
-#include "angle_gl.h"
-
-namespace gl
-{
-
-FenceNV::FenceNV(rx::FenceNVImpl *impl)
- : mFence(impl),
- mIsSet(false),
- mStatus(GL_FALSE),
- mCondition(GL_NONE)
-{
-}
-
-FenceNV::~FenceNV()
-{
- SafeDelete(mFence);
-}
-
-GLboolean FenceNV::isFence() const
-{
- // GL_NV_fence spec:
- // A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an existing fence.
- return (mIsSet ? GL_TRUE : GL_FALSE);
-}
-
-Error FenceNV::setFence(GLenum condition)
-{
- Error error = mFence->set();
- if (error.isError())
- {
- return error;
- }
-
- mCondition = condition;
- mStatus = GL_FALSE;
- mIsSet = true;
-
- return Error(GL_NO_ERROR);
-}
-
-Error FenceNV::testFence(GLboolean *outResult)
-{
- // Flush the command buffer by default
- Error error = mFence->test(true, &mStatus);
- if (error.isError())
- {
- return error;
- }
-
- *outResult = mStatus;
- return Error(GL_NO_ERROR);
-}
-
-Error FenceNV::finishFence()
-{
- ASSERT(mIsSet);
-
- return mFence->finishFence(&mStatus);
-}
-
-FenceSync::FenceSync(rx::FenceSyncImpl *impl, GLuint id)
- : RefCountObject(id),
- mFence(impl),
- mCondition(GL_NONE)
-{
-}
-
-FenceSync::~FenceSync()
-{
- SafeDelete(mFence);
-}
-
-Error FenceSync::set(GLenum condition)
-{
- Error error = mFence->set();
- if (error.isError())
- {
- return error;
- }
-
- mCondition = condition;
- return Error(GL_NO_ERROR);
-}
-
-Error FenceSync::clientWait(GLbitfield flags, GLuint64 timeout, GLenum *outResult)
-{
- ASSERT(mCondition != GL_NONE);
- return mFence->clientWait(flags, timeout, outResult);
-}
-
-Error FenceSync::serverWait(GLbitfield flags, GLuint64 timeout)
-{
- return mFence->serverWait(flags, timeout);
-}
-
-Error FenceSync::getStatus(GLint *outResult) const
-{
- return mFence->getStatus(outResult);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/Fence.h b/src/3rdparty/angle/src/libGLESv2/Fence.h
deleted file mode 100644
index fd565e96a6..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Fence.h
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-// Copyright (c) 2002-2013 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.
-//
-
-// Fence.h: Defines the gl::FenceNV and gl::FenceSync classes, which support the GL_NV_fence
-// extension and GLES3 sync objects.
-
-#ifndef LIBGLESV2_FENCE_H_
-#define LIBGLESV2_FENCE_H_
-
-#include "libGLESv2/Error.h"
-
-#include "common/angleutils.h"
-#include "common/RefCountObject.h"
-
-namespace rx
-{
-class FenceNVImpl;
-class FenceSyncImpl;
-}
-
-namespace gl
-{
-
-class FenceNV
-{
- public:
- explicit FenceNV(rx::FenceNVImpl *impl);
- virtual ~FenceNV();
-
- GLboolean isFence() const;
- Error setFence(GLenum condition);
- Error testFence(GLboolean *outResult);
- Error finishFence();
-
- GLboolean getStatus() const { return mStatus; }
- GLuint getCondition() const { return mCondition; }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FenceNV);
-
- rx::FenceNVImpl *mFence;
-
- bool mIsSet;
-
- GLboolean mStatus;
- GLenum mCondition;
-};
-
-class FenceSync : public RefCountObject
-{
- public:
- explicit FenceSync(rx::FenceSyncImpl *impl, GLuint id);
- virtual ~FenceSync();
-
- Error set(GLenum condition);
- Error clientWait(GLbitfield flags, GLuint64 timeout, GLenum *outResult);
- Error serverWait(GLbitfield flags, GLuint64 timeout);
- Error getStatus(GLint *outResult) const;
-
- GLuint getCondition() const { return mCondition; }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FenceSync);
-
- rx::FenceSyncImpl *mFence;
-
- GLenum mCondition;
-};
-
-}
-
-#endif // LIBGLESV2_FENCE_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/Float16ToFloat32.cpp b/src/3rdparty/angle/src/libGLESv2/Float16ToFloat32.cpp
deleted file mode 100644
index 5bf7b3fce8..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Float16ToFloat32.cpp
+++ /dev/null
@@ -1,2203 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// This file is automatically generated.
-
-namespace gl
-{
-
-const static unsigned g_mantissa[2048] = {
- 0x00000000,
- 0x33800000,
- 0x34000000,
- 0x34400000,
- 0x34800000,
- 0x34a00000,
- 0x34c00000,
- 0x34e00000,
- 0x35000000,
- 0x35100000,
- 0x35200000,
- 0x35300000,
- 0x35400000,
- 0x35500000,
- 0x35600000,
- 0x35700000,
- 0x35800000,
- 0x35880000,
- 0x35900000,
- 0x35980000,
- 0x35a00000,
- 0x35a80000,
- 0x35b00000,
- 0x35b80000,
- 0x35c00000,
- 0x35c80000,
- 0x35d00000,
- 0x35d80000,
- 0x35e00000,
- 0x35e80000,
- 0x35f00000,
- 0x35f80000,
- 0x36000000,
- 0x36040000,
- 0x36080000,
- 0x360c0000,
- 0x36100000,
- 0x36140000,
- 0x36180000,
- 0x361c0000,
- 0x36200000,
- 0x36240000,
- 0x36280000,
- 0x362c0000,
- 0x36300000,
- 0x36340000,
- 0x36380000,
- 0x363c0000,
- 0x36400000,
- 0x36440000,
- 0x36480000,
- 0x364c0000,
- 0x36500000,
- 0x36540000,
- 0x36580000,
- 0x365c0000,
- 0x36600000,
- 0x36640000,
- 0x36680000,
- 0x366c0000,
- 0x36700000,
- 0x36740000,
- 0x36780000,
- 0x367c0000,
- 0x36800000,
- 0x36820000,
- 0x36840000,
- 0x36860000,
- 0x36880000,
- 0x368a0000,
- 0x368c0000,
- 0x368e0000,
- 0x36900000,
- 0x36920000,
- 0x36940000,
- 0x36960000,
- 0x36980000,
- 0x369a0000,
- 0x369c0000,
- 0x369e0000,
- 0x36a00000,
- 0x36a20000,
- 0x36a40000,
- 0x36a60000,
- 0x36a80000,
- 0x36aa0000,
- 0x36ac0000,
- 0x36ae0000,
- 0x36b00000,
- 0x36b20000,
- 0x36b40000,
- 0x36b60000,
- 0x36b80000,
- 0x36ba0000,
- 0x36bc0000,
- 0x36be0000,
- 0x36c00000,
- 0x36c20000,
- 0x36c40000,
- 0x36c60000,
- 0x36c80000,
- 0x36ca0000,
- 0x36cc0000,
- 0x36ce0000,
- 0x36d00000,
- 0x36d20000,
- 0x36d40000,
- 0x36d60000,
- 0x36d80000,
- 0x36da0000,
- 0x36dc0000,
- 0x36de0000,
- 0x36e00000,
- 0x36e20000,
- 0x36e40000,
- 0x36e60000,
- 0x36e80000,
- 0x36ea0000,
- 0x36ec0000,
- 0x36ee0000,
- 0x36f00000,
- 0x36f20000,
- 0x36f40000,
- 0x36f60000,
- 0x36f80000,
- 0x36fa0000,
- 0x36fc0000,
- 0x36fe0000,
- 0x37000000,
- 0x37010000,
- 0x37020000,
- 0x37030000,
- 0x37040000,
- 0x37050000,
- 0x37060000,
- 0x37070000,
- 0x37080000,
- 0x37090000,
- 0x370a0000,
- 0x370b0000,
- 0x370c0000,
- 0x370d0000,
- 0x370e0000,
- 0x370f0000,
- 0x37100000,
- 0x37110000,
- 0x37120000,
- 0x37130000,
- 0x37140000,
- 0x37150000,
- 0x37160000,
- 0x37170000,
- 0x37180000,
- 0x37190000,
- 0x371a0000,
- 0x371b0000,
- 0x371c0000,
- 0x371d0000,
- 0x371e0000,
- 0x371f0000,
- 0x37200000,
- 0x37210000,
- 0x37220000,
- 0x37230000,
- 0x37240000,
- 0x37250000,
- 0x37260000,
- 0x37270000,
- 0x37280000,
- 0x37290000,
- 0x372a0000,
- 0x372b0000,
- 0x372c0000,
- 0x372d0000,
- 0x372e0000,
- 0x372f0000,
- 0x37300000,
- 0x37310000,
- 0x37320000,
- 0x37330000,
- 0x37340000,
- 0x37350000,
- 0x37360000,
- 0x37370000,
- 0x37380000,
- 0x37390000,
- 0x373a0000,
- 0x373b0000,
- 0x373c0000,
- 0x373d0000,
- 0x373e0000,
- 0x373f0000,
- 0x37400000,
- 0x37410000,
- 0x37420000,
- 0x37430000,
- 0x37440000,
- 0x37450000,
- 0x37460000,
- 0x37470000,
- 0x37480000,
- 0x37490000,
- 0x374a0000,
- 0x374b0000,
- 0x374c0000,
- 0x374d0000,
- 0x374e0000,
- 0x374f0000,
- 0x37500000,
- 0x37510000,
- 0x37520000,
- 0x37530000,
- 0x37540000,
- 0x37550000,
- 0x37560000,
- 0x37570000,
- 0x37580000,
- 0x37590000,
- 0x375a0000,
- 0x375b0000,
- 0x375c0000,
- 0x375d0000,
- 0x375e0000,
- 0x375f0000,
- 0x37600000,
- 0x37610000,
- 0x37620000,
- 0x37630000,
- 0x37640000,
- 0x37650000,
- 0x37660000,
- 0x37670000,
- 0x37680000,
- 0x37690000,
- 0x376a0000,
- 0x376b0000,
- 0x376c0000,
- 0x376d0000,
- 0x376e0000,
- 0x376f0000,
- 0x37700000,
- 0x37710000,
- 0x37720000,
- 0x37730000,
- 0x37740000,
- 0x37750000,
- 0x37760000,
- 0x37770000,
- 0x37780000,
- 0x37790000,
- 0x377a0000,
- 0x377b0000,
- 0x377c0000,
- 0x377d0000,
- 0x377e0000,
- 0x377f0000,
- 0x37800000,
- 0x37808000,
- 0x37810000,
- 0x37818000,
- 0x37820000,
- 0x37828000,
- 0x37830000,
- 0x37838000,
- 0x37840000,
- 0x37848000,
- 0x37850000,
- 0x37858000,
- 0x37860000,
- 0x37868000,
- 0x37870000,
- 0x37878000,
- 0x37880000,
- 0x37888000,
- 0x37890000,
- 0x37898000,
- 0x378a0000,
- 0x378a8000,
- 0x378b0000,
- 0x378b8000,
- 0x378c0000,
- 0x378c8000,
- 0x378d0000,
- 0x378d8000,
- 0x378e0000,
- 0x378e8000,
- 0x378f0000,
- 0x378f8000,
- 0x37900000,
- 0x37908000,
- 0x37910000,
- 0x37918000,
- 0x37920000,
- 0x37928000,
- 0x37930000,
- 0x37938000,
- 0x37940000,
- 0x37948000,
- 0x37950000,
- 0x37958000,
- 0x37960000,
- 0x37968000,
- 0x37970000,
- 0x37978000,
- 0x37980000,
- 0x37988000,
- 0x37990000,
- 0x37998000,
- 0x379a0000,
- 0x379a8000,
- 0x379b0000,
- 0x379b8000,
- 0x379c0000,
- 0x379c8000,
- 0x379d0000,
- 0x379d8000,
- 0x379e0000,
- 0x379e8000,
- 0x379f0000,
- 0x379f8000,
- 0x37a00000,
- 0x37a08000,
- 0x37a10000,
- 0x37a18000,
- 0x37a20000,
- 0x37a28000,
- 0x37a30000,
- 0x37a38000,
- 0x37a40000,
- 0x37a48000,
- 0x37a50000,
- 0x37a58000,
- 0x37a60000,
- 0x37a68000,
- 0x37a70000,
- 0x37a78000,
- 0x37a80000,
- 0x37a88000,
- 0x37a90000,
- 0x37a98000,
- 0x37aa0000,
- 0x37aa8000,
- 0x37ab0000,
- 0x37ab8000,
- 0x37ac0000,
- 0x37ac8000,
- 0x37ad0000,
- 0x37ad8000,
- 0x37ae0000,
- 0x37ae8000,
- 0x37af0000,
- 0x37af8000,
- 0x37b00000,
- 0x37b08000,
- 0x37b10000,
- 0x37b18000,
- 0x37b20000,
- 0x37b28000,
- 0x37b30000,
- 0x37b38000,
- 0x37b40000,
- 0x37b48000,
- 0x37b50000,
- 0x37b58000,
- 0x37b60000,
- 0x37b68000,
- 0x37b70000,
- 0x37b78000,
- 0x37b80000,
- 0x37b88000,
- 0x37b90000,
- 0x37b98000,
- 0x37ba0000,
- 0x37ba8000,
- 0x37bb0000,
- 0x37bb8000,
- 0x37bc0000,
- 0x37bc8000,
- 0x37bd0000,
- 0x37bd8000,
- 0x37be0000,
- 0x37be8000,
- 0x37bf0000,
- 0x37bf8000,
- 0x37c00000,
- 0x37c08000,
- 0x37c10000,
- 0x37c18000,
- 0x37c20000,
- 0x37c28000,
- 0x37c30000,
- 0x37c38000,
- 0x37c40000,
- 0x37c48000,
- 0x37c50000,
- 0x37c58000,
- 0x37c60000,
- 0x37c68000,
- 0x37c70000,
- 0x37c78000,
- 0x37c80000,
- 0x37c88000,
- 0x37c90000,
- 0x37c98000,
- 0x37ca0000,
- 0x37ca8000,
- 0x37cb0000,
- 0x37cb8000,
- 0x37cc0000,
- 0x37cc8000,
- 0x37cd0000,
- 0x37cd8000,
- 0x37ce0000,
- 0x37ce8000,
- 0x37cf0000,
- 0x37cf8000,
- 0x37d00000,
- 0x37d08000,
- 0x37d10000,
- 0x37d18000,
- 0x37d20000,
- 0x37d28000,
- 0x37d30000,
- 0x37d38000,
- 0x37d40000,
- 0x37d48000,
- 0x37d50000,
- 0x37d58000,
- 0x37d60000,
- 0x37d68000,
- 0x37d70000,
- 0x37d78000,
- 0x37d80000,
- 0x37d88000,
- 0x37d90000,
- 0x37d98000,
- 0x37da0000,
- 0x37da8000,
- 0x37db0000,
- 0x37db8000,
- 0x37dc0000,
- 0x37dc8000,
- 0x37dd0000,
- 0x37dd8000,
- 0x37de0000,
- 0x37de8000,
- 0x37df0000,
- 0x37df8000,
- 0x37e00000,
- 0x37e08000,
- 0x37e10000,
- 0x37e18000,
- 0x37e20000,
- 0x37e28000,
- 0x37e30000,
- 0x37e38000,
- 0x37e40000,
- 0x37e48000,
- 0x37e50000,
- 0x37e58000,
- 0x37e60000,
- 0x37e68000,
- 0x37e70000,
- 0x37e78000,
- 0x37e80000,
- 0x37e88000,
- 0x37e90000,
- 0x37e98000,
- 0x37ea0000,
- 0x37ea8000,
- 0x37eb0000,
- 0x37eb8000,
- 0x37ec0000,
- 0x37ec8000,
- 0x37ed0000,
- 0x37ed8000,
- 0x37ee0000,
- 0x37ee8000,
- 0x37ef0000,
- 0x37ef8000,
- 0x37f00000,
- 0x37f08000,
- 0x37f10000,
- 0x37f18000,
- 0x37f20000,
- 0x37f28000,
- 0x37f30000,
- 0x37f38000,
- 0x37f40000,
- 0x37f48000,
- 0x37f50000,
- 0x37f58000,
- 0x37f60000,
- 0x37f68000,
- 0x37f70000,
- 0x37f78000,
- 0x37f80000,
- 0x37f88000,
- 0x37f90000,
- 0x37f98000,
- 0x37fa0000,
- 0x37fa8000,
- 0x37fb0000,
- 0x37fb8000,
- 0x37fc0000,
- 0x37fc8000,
- 0x37fd0000,
- 0x37fd8000,
- 0x37fe0000,
- 0x37fe8000,
- 0x37ff0000,
- 0x37ff8000,
- 0x38000000,
- 0x38004000,
- 0x38008000,
- 0x3800c000,
- 0x38010000,
- 0x38014000,
- 0x38018000,
- 0x3801c000,
- 0x38020000,
- 0x38024000,
- 0x38028000,
- 0x3802c000,
- 0x38030000,
- 0x38034000,
- 0x38038000,
- 0x3803c000,
- 0x38040000,
- 0x38044000,
- 0x38048000,
- 0x3804c000,
- 0x38050000,
- 0x38054000,
- 0x38058000,
- 0x3805c000,
- 0x38060000,
- 0x38064000,
- 0x38068000,
- 0x3806c000,
- 0x38070000,
- 0x38074000,
- 0x38078000,
- 0x3807c000,
- 0x38080000,
- 0x38084000,
- 0x38088000,
- 0x3808c000,
- 0x38090000,
- 0x38094000,
- 0x38098000,
- 0x3809c000,
- 0x380a0000,
- 0x380a4000,
- 0x380a8000,
- 0x380ac000,
- 0x380b0000,
- 0x380b4000,
- 0x380b8000,
- 0x380bc000,
- 0x380c0000,
- 0x380c4000,
- 0x380c8000,
- 0x380cc000,
- 0x380d0000,
- 0x380d4000,
- 0x380d8000,
- 0x380dc000,
- 0x380e0000,
- 0x380e4000,
- 0x380e8000,
- 0x380ec000,
- 0x380f0000,
- 0x380f4000,
- 0x380f8000,
- 0x380fc000,
- 0x38100000,
- 0x38104000,
- 0x38108000,
- 0x3810c000,
- 0x38110000,
- 0x38114000,
- 0x38118000,
- 0x3811c000,
- 0x38120000,
- 0x38124000,
- 0x38128000,
- 0x3812c000,
- 0x38130000,
- 0x38134000,
- 0x38138000,
- 0x3813c000,
- 0x38140000,
- 0x38144000,
- 0x38148000,
- 0x3814c000,
- 0x38150000,
- 0x38154000,
- 0x38158000,
- 0x3815c000,
- 0x38160000,
- 0x38164000,
- 0x38168000,
- 0x3816c000,
- 0x38170000,
- 0x38174000,
- 0x38178000,
- 0x3817c000,
- 0x38180000,
- 0x38184000,
- 0x38188000,
- 0x3818c000,
- 0x38190000,
- 0x38194000,
- 0x38198000,
- 0x3819c000,
- 0x381a0000,
- 0x381a4000,
- 0x381a8000,
- 0x381ac000,
- 0x381b0000,
- 0x381b4000,
- 0x381b8000,
- 0x381bc000,
- 0x381c0000,
- 0x381c4000,
- 0x381c8000,
- 0x381cc000,
- 0x381d0000,
- 0x381d4000,
- 0x381d8000,
- 0x381dc000,
- 0x381e0000,
- 0x381e4000,
- 0x381e8000,
- 0x381ec000,
- 0x381f0000,
- 0x381f4000,
- 0x381f8000,
- 0x381fc000,
- 0x38200000,
- 0x38204000,
- 0x38208000,
- 0x3820c000,
- 0x38210000,
- 0x38214000,
- 0x38218000,
- 0x3821c000,
- 0x38220000,
- 0x38224000,
- 0x38228000,
- 0x3822c000,
- 0x38230000,
- 0x38234000,
- 0x38238000,
- 0x3823c000,
- 0x38240000,
- 0x38244000,
- 0x38248000,
- 0x3824c000,
- 0x38250000,
- 0x38254000,
- 0x38258000,
- 0x3825c000,
- 0x38260000,
- 0x38264000,
- 0x38268000,
- 0x3826c000,
- 0x38270000,
- 0x38274000,
- 0x38278000,
- 0x3827c000,
- 0x38280000,
- 0x38284000,
- 0x38288000,
- 0x3828c000,
- 0x38290000,
- 0x38294000,
- 0x38298000,
- 0x3829c000,
- 0x382a0000,
- 0x382a4000,
- 0x382a8000,
- 0x382ac000,
- 0x382b0000,
- 0x382b4000,
- 0x382b8000,
- 0x382bc000,
- 0x382c0000,
- 0x382c4000,
- 0x382c8000,
- 0x382cc000,
- 0x382d0000,
- 0x382d4000,
- 0x382d8000,
- 0x382dc000,
- 0x382e0000,
- 0x382e4000,
- 0x382e8000,
- 0x382ec000,
- 0x382f0000,
- 0x382f4000,
- 0x382f8000,
- 0x382fc000,
- 0x38300000,
- 0x38304000,
- 0x38308000,
- 0x3830c000,
- 0x38310000,
- 0x38314000,
- 0x38318000,
- 0x3831c000,
- 0x38320000,
- 0x38324000,
- 0x38328000,
- 0x3832c000,
- 0x38330000,
- 0x38334000,
- 0x38338000,
- 0x3833c000,
- 0x38340000,
- 0x38344000,
- 0x38348000,
- 0x3834c000,
- 0x38350000,
- 0x38354000,
- 0x38358000,
- 0x3835c000,
- 0x38360000,
- 0x38364000,
- 0x38368000,
- 0x3836c000,
- 0x38370000,
- 0x38374000,
- 0x38378000,
- 0x3837c000,
- 0x38380000,
- 0x38384000,
- 0x38388000,
- 0x3838c000,
- 0x38390000,
- 0x38394000,
- 0x38398000,
- 0x3839c000,
- 0x383a0000,
- 0x383a4000,
- 0x383a8000,
- 0x383ac000,
- 0x383b0000,
- 0x383b4000,
- 0x383b8000,
- 0x383bc000,
- 0x383c0000,
- 0x383c4000,
- 0x383c8000,
- 0x383cc000,
- 0x383d0000,
- 0x383d4000,
- 0x383d8000,
- 0x383dc000,
- 0x383e0000,
- 0x383e4000,
- 0x383e8000,
- 0x383ec000,
- 0x383f0000,
- 0x383f4000,
- 0x383f8000,
- 0x383fc000,
- 0x38400000,
- 0x38404000,
- 0x38408000,
- 0x3840c000,
- 0x38410000,
- 0x38414000,
- 0x38418000,
- 0x3841c000,
- 0x38420000,
- 0x38424000,
- 0x38428000,
- 0x3842c000,
- 0x38430000,
- 0x38434000,
- 0x38438000,
- 0x3843c000,
- 0x38440000,
- 0x38444000,
- 0x38448000,
- 0x3844c000,
- 0x38450000,
- 0x38454000,
- 0x38458000,
- 0x3845c000,
- 0x38460000,
- 0x38464000,
- 0x38468000,
- 0x3846c000,
- 0x38470000,
- 0x38474000,
- 0x38478000,
- 0x3847c000,
- 0x38480000,
- 0x38484000,
- 0x38488000,
- 0x3848c000,
- 0x38490000,
- 0x38494000,
- 0x38498000,
- 0x3849c000,
- 0x384a0000,
- 0x384a4000,
- 0x384a8000,
- 0x384ac000,
- 0x384b0000,
- 0x384b4000,
- 0x384b8000,
- 0x384bc000,
- 0x384c0000,
- 0x384c4000,
- 0x384c8000,
- 0x384cc000,
- 0x384d0000,
- 0x384d4000,
- 0x384d8000,
- 0x384dc000,
- 0x384e0000,
- 0x384e4000,
- 0x384e8000,
- 0x384ec000,
- 0x384f0000,
- 0x384f4000,
- 0x384f8000,
- 0x384fc000,
- 0x38500000,
- 0x38504000,
- 0x38508000,
- 0x3850c000,
- 0x38510000,
- 0x38514000,
- 0x38518000,
- 0x3851c000,
- 0x38520000,
- 0x38524000,
- 0x38528000,
- 0x3852c000,
- 0x38530000,
- 0x38534000,
- 0x38538000,
- 0x3853c000,
- 0x38540000,
- 0x38544000,
- 0x38548000,
- 0x3854c000,
- 0x38550000,
- 0x38554000,
- 0x38558000,
- 0x3855c000,
- 0x38560000,
- 0x38564000,
- 0x38568000,
- 0x3856c000,
- 0x38570000,
- 0x38574000,
- 0x38578000,
- 0x3857c000,
- 0x38580000,
- 0x38584000,
- 0x38588000,
- 0x3858c000,
- 0x38590000,
- 0x38594000,
- 0x38598000,
- 0x3859c000,
- 0x385a0000,
- 0x385a4000,
- 0x385a8000,
- 0x385ac000,
- 0x385b0000,
- 0x385b4000,
- 0x385b8000,
- 0x385bc000,
- 0x385c0000,
- 0x385c4000,
- 0x385c8000,
- 0x385cc000,
- 0x385d0000,
- 0x385d4000,
- 0x385d8000,
- 0x385dc000,
- 0x385e0000,
- 0x385e4000,
- 0x385e8000,
- 0x385ec000,
- 0x385f0000,
- 0x385f4000,
- 0x385f8000,
- 0x385fc000,
- 0x38600000,
- 0x38604000,
- 0x38608000,
- 0x3860c000,
- 0x38610000,
- 0x38614000,
- 0x38618000,
- 0x3861c000,
- 0x38620000,
- 0x38624000,
- 0x38628000,
- 0x3862c000,
- 0x38630000,
- 0x38634000,
- 0x38638000,
- 0x3863c000,
- 0x38640000,
- 0x38644000,
- 0x38648000,
- 0x3864c000,
- 0x38650000,
- 0x38654000,
- 0x38658000,
- 0x3865c000,
- 0x38660000,
- 0x38664000,
- 0x38668000,
- 0x3866c000,
- 0x38670000,
- 0x38674000,
- 0x38678000,
- 0x3867c000,
- 0x38680000,
- 0x38684000,
- 0x38688000,
- 0x3868c000,
- 0x38690000,
- 0x38694000,
- 0x38698000,
- 0x3869c000,
- 0x386a0000,
- 0x386a4000,
- 0x386a8000,
- 0x386ac000,
- 0x386b0000,
- 0x386b4000,
- 0x386b8000,
- 0x386bc000,
- 0x386c0000,
- 0x386c4000,
- 0x386c8000,
- 0x386cc000,
- 0x386d0000,
- 0x386d4000,
- 0x386d8000,
- 0x386dc000,
- 0x386e0000,
- 0x386e4000,
- 0x386e8000,
- 0x386ec000,
- 0x386f0000,
- 0x386f4000,
- 0x386f8000,
- 0x386fc000,
- 0x38700000,
- 0x38704000,
- 0x38708000,
- 0x3870c000,
- 0x38710000,
- 0x38714000,
- 0x38718000,
- 0x3871c000,
- 0x38720000,
- 0x38724000,
- 0x38728000,
- 0x3872c000,
- 0x38730000,
- 0x38734000,
- 0x38738000,
- 0x3873c000,
- 0x38740000,
- 0x38744000,
- 0x38748000,
- 0x3874c000,
- 0x38750000,
- 0x38754000,
- 0x38758000,
- 0x3875c000,
- 0x38760000,
- 0x38764000,
- 0x38768000,
- 0x3876c000,
- 0x38770000,
- 0x38774000,
- 0x38778000,
- 0x3877c000,
- 0x38780000,
- 0x38784000,
- 0x38788000,
- 0x3878c000,
- 0x38790000,
- 0x38794000,
- 0x38798000,
- 0x3879c000,
- 0x387a0000,
- 0x387a4000,
- 0x387a8000,
- 0x387ac000,
- 0x387b0000,
- 0x387b4000,
- 0x387b8000,
- 0x387bc000,
- 0x387c0000,
- 0x387c4000,
- 0x387c8000,
- 0x387cc000,
- 0x387d0000,
- 0x387d4000,
- 0x387d8000,
- 0x387dc000,
- 0x387e0000,
- 0x387e4000,
- 0x387e8000,
- 0x387ec000,
- 0x387f0000,
- 0x387f4000,
- 0x387f8000,
- 0x387fc000,
- 0x38000000,
- 0x38002000,
- 0x38004000,
- 0x38006000,
- 0x38008000,
- 0x3800a000,
- 0x3800c000,
- 0x3800e000,
- 0x38010000,
- 0x38012000,
- 0x38014000,
- 0x38016000,
- 0x38018000,
- 0x3801a000,
- 0x3801c000,
- 0x3801e000,
- 0x38020000,
- 0x38022000,
- 0x38024000,
- 0x38026000,
- 0x38028000,
- 0x3802a000,
- 0x3802c000,
- 0x3802e000,
- 0x38030000,
- 0x38032000,
- 0x38034000,
- 0x38036000,
- 0x38038000,
- 0x3803a000,
- 0x3803c000,
- 0x3803e000,
- 0x38040000,
- 0x38042000,
- 0x38044000,
- 0x38046000,
- 0x38048000,
- 0x3804a000,
- 0x3804c000,
- 0x3804e000,
- 0x38050000,
- 0x38052000,
- 0x38054000,
- 0x38056000,
- 0x38058000,
- 0x3805a000,
- 0x3805c000,
- 0x3805e000,
- 0x38060000,
- 0x38062000,
- 0x38064000,
- 0x38066000,
- 0x38068000,
- 0x3806a000,
- 0x3806c000,
- 0x3806e000,
- 0x38070000,
- 0x38072000,
- 0x38074000,
- 0x38076000,
- 0x38078000,
- 0x3807a000,
- 0x3807c000,
- 0x3807e000,
- 0x38080000,
- 0x38082000,
- 0x38084000,
- 0x38086000,
- 0x38088000,
- 0x3808a000,
- 0x3808c000,
- 0x3808e000,
- 0x38090000,
- 0x38092000,
- 0x38094000,
- 0x38096000,
- 0x38098000,
- 0x3809a000,
- 0x3809c000,
- 0x3809e000,
- 0x380a0000,
- 0x380a2000,
- 0x380a4000,
- 0x380a6000,
- 0x380a8000,
- 0x380aa000,
- 0x380ac000,
- 0x380ae000,
- 0x380b0000,
- 0x380b2000,
- 0x380b4000,
- 0x380b6000,
- 0x380b8000,
- 0x380ba000,
- 0x380bc000,
- 0x380be000,
- 0x380c0000,
- 0x380c2000,
- 0x380c4000,
- 0x380c6000,
- 0x380c8000,
- 0x380ca000,
- 0x380cc000,
- 0x380ce000,
- 0x380d0000,
- 0x380d2000,
- 0x380d4000,
- 0x380d6000,
- 0x380d8000,
- 0x380da000,
- 0x380dc000,
- 0x380de000,
- 0x380e0000,
- 0x380e2000,
- 0x380e4000,
- 0x380e6000,
- 0x380e8000,
- 0x380ea000,
- 0x380ec000,
- 0x380ee000,
- 0x380f0000,
- 0x380f2000,
- 0x380f4000,
- 0x380f6000,
- 0x380f8000,
- 0x380fa000,
- 0x380fc000,
- 0x380fe000,
- 0x38100000,
- 0x38102000,
- 0x38104000,
- 0x38106000,
- 0x38108000,
- 0x3810a000,
- 0x3810c000,
- 0x3810e000,
- 0x38110000,
- 0x38112000,
- 0x38114000,
- 0x38116000,
- 0x38118000,
- 0x3811a000,
- 0x3811c000,
- 0x3811e000,
- 0x38120000,
- 0x38122000,
- 0x38124000,
- 0x38126000,
- 0x38128000,
- 0x3812a000,
- 0x3812c000,
- 0x3812e000,
- 0x38130000,
- 0x38132000,
- 0x38134000,
- 0x38136000,
- 0x38138000,
- 0x3813a000,
- 0x3813c000,
- 0x3813e000,
- 0x38140000,
- 0x38142000,
- 0x38144000,
- 0x38146000,
- 0x38148000,
- 0x3814a000,
- 0x3814c000,
- 0x3814e000,
- 0x38150000,
- 0x38152000,
- 0x38154000,
- 0x38156000,
- 0x38158000,
- 0x3815a000,
- 0x3815c000,
- 0x3815e000,
- 0x38160000,
- 0x38162000,
- 0x38164000,
- 0x38166000,
- 0x38168000,
- 0x3816a000,
- 0x3816c000,
- 0x3816e000,
- 0x38170000,
- 0x38172000,
- 0x38174000,
- 0x38176000,
- 0x38178000,
- 0x3817a000,
- 0x3817c000,
- 0x3817e000,
- 0x38180000,
- 0x38182000,
- 0x38184000,
- 0x38186000,
- 0x38188000,
- 0x3818a000,
- 0x3818c000,
- 0x3818e000,
- 0x38190000,
- 0x38192000,
- 0x38194000,
- 0x38196000,
- 0x38198000,
- 0x3819a000,
- 0x3819c000,
- 0x3819e000,
- 0x381a0000,
- 0x381a2000,
- 0x381a4000,
- 0x381a6000,
- 0x381a8000,
- 0x381aa000,
- 0x381ac000,
- 0x381ae000,
- 0x381b0000,
- 0x381b2000,
- 0x381b4000,
- 0x381b6000,
- 0x381b8000,
- 0x381ba000,
- 0x381bc000,
- 0x381be000,
- 0x381c0000,
- 0x381c2000,
- 0x381c4000,
- 0x381c6000,
- 0x381c8000,
- 0x381ca000,
- 0x381cc000,
- 0x381ce000,
- 0x381d0000,
- 0x381d2000,
- 0x381d4000,
- 0x381d6000,
- 0x381d8000,
- 0x381da000,
- 0x381dc000,
- 0x381de000,
- 0x381e0000,
- 0x381e2000,
- 0x381e4000,
- 0x381e6000,
- 0x381e8000,
- 0x381ea000,
- 0x381ec000,
- 0x381ee000,
- 0x381f0000,
- 0x381f2000,
- 0x381f4000,
- 0x381f6000,
- 0x381f8000,
- 0x381fa000,
- 0x381fc000,
- 0x381fe000,
- 0x38200000,
- 0x38202000,
- 0x38204000,
- 0x38206000,
- 0x38208000,
- 0x3820a000,
- 0x3820c000,
- 0x3820e000,
- 0x38210000,
- 0x38212000,
- 0x38214000,
- 0x38216000,
- 0x38218000,
- 0x3821a000,
- 0x3821c000,
- 0x3821e000,
- 0x38220000,
- 0x38222000,
- 0x38224000,
- 0x38226000,
- 0x38228000,
- 0x3822a000,
- 0x3822c000,
- 0x3822e000,
- 0x38230000,
- 0x38232000,
- 0x38234000,
- 0x38236000,
- 0x38238000,
- 0x3823a000,
- 0x3823c000,
- 0x3823e000,
- 0x38240000,
- 0x38242000,
- 0x38244000,
- 0x38246000,
- 0x38248000,
- 0x3824a000,
- 0x3824c000,
- 0x3824e000,
- 0x38250000,
- 0x38252000,
- 0x38254000,
- 0x38256000,
- 0x38258000,
- 0x3825a000,
- 0x3825c000,
- 0x3825e000,
- 0x38260000,
- 0x38262000,
- 0x38264000,
- 0x38266000,
- 0x38268000,
- 0x3826a000,
- 0x3826c000,
- 0x3826e000,
- 0x38270000,
- 0x38272000,
- 0x38274000,
- 0x38276000,
- 0x38278000,
- 0x3827a000,
- 0x3827c000,
- 0x3827e000,
- 0x38280000,
- 0x38282000,
- 0x38284000,
- 0x38286000,
- 0x38288000,
- 0x3828a000,
- 0x3828c000,
- 0x3828e000,
- 0x38290000,
- 0x38292000,
- 0x38294000,
- 0x38296000,
- 0x38298000,
- 0x3829a000,
- 0x3829c000,
- 0x3829e000,
- 0x382a0000,
- 0x382a2000,
- 0x382a4000,
- 0x382a6000,
- 0x382a8000,
- 0x382aa000,
- 0x382ac000,
- 0x382ae000,
- 0x382b0000,
- 0x382b2000,
- 0x382b4000,
- 0x382b6000,
- 0x382b8000,
- 0x382ba000,
- 0x382bc000,
- 0x382be000,
- 0x382c0000,
- 0x382c2000,
- 0x382c4000,
- 0x382c6000,
- 0x382c8000,
- 0x382ca000,
- 0x382cc000,
- 0x382ce000,
- 0x382d0000,
- 0x382d2000,
- 0x382d4000,
- 0x382d6000,
- 0x382d8000,
- 0x382da000,
- 0x382dc000,
- 0x382de000,
- 0x382e0000,
- 0x382e2000,
- 0x382e4000,
- 0x382e6000,
- 0x382e8000,
- 0x382ea000,
- 0x382ec000,
- 0x382ee000,
- 0x382f0000,
- 0x382f2000,
- 0x382f4000,
- 0x382f6000,
- 0x382f8000,
- 0x382fa000,
- 0x382fc000,
- 0x382fe000,
- 0x38300000,
- 0x38302000,
- 0x38304000,
- 0x38306000,
- 0x38308000,
- 0x3830a000,
- 0x3830c000,
- 0x3830e000,
- 0x38310000,
- 0x38312000,
- 0x38314000,
- 0x38316000,
- 0x38318000,
- 0x3831a000,
- 0x3831c000,
- 0x3831e000,
- 0x38320000,
- 0x38322000,
- 0x38324000,
- 0x38326000,
- 0x38328000,
- 0x3832a000,
- 0x3832c000,
- 0x3832e000,
- 0x38330000,
- 0x38332000,
- 0x38334000,
- 0x38336000,
- 0x38338000,
- 0x3833a000,
- 0x3833c000,
- 0x3833e000,
- 0x38340000,
- 0x38342000,
- 0x38344000,
- 0x38346000,
- 0x38348000,
- 0x3834a000,
- 0x3834c000,
- 0x3834e000,
- 0x38350000,
- 0x38352000,
- 0x38354000,
- 0x38356000,
- 0x38358000,
- 0x3835a000,
- 0x3835c000,
- 0x3835e000,
- 0x38360000,
- 0x38362000,
- 0x38364000,
- 0x38366000,
- 0x38368000,
- 0x3836a000,
- 0x3836c000,
- 0x3836e000,
- 0x38370000,
- 0x38372000,
- 0x38374000,
- 0x38376000,
- 0x38378000,
- 0x3837a000,
- 0x3837c000,
- 0x3837e000,
- 0x38380000,
- 0x38382000,
- 0x38384000,
- 0x38386000,
- 0x38388000,
- 0x3838a000,
- 0x3838c000,
- 0x3838e000,
- 0x38390000,
- 0x38392000,
- 0x38394000,
- 0x38396000,
- 0x38398000,
- 0x3839a000,
- 0x3839c000,
- 0x3839e000,
- 0x383a0000,
- 0x383a2000,
- 0x383a4000,
- 0x383a6000,
- 0x383a8000,
- 0x383aa000,
- 0x383ac000,
- 0x383ae000,
- 0x383b0000,
- 0x383b2000,
- 0x383b4000,
- 0x383b6000,
- 0x383b8000,
- 0x383ba000,
- 0x383bc000,
- 0x383be000,
- 0x383c0000,
- 0x383c2000,
- 0x383c4000,
- 0x383c6000,
- 0x383c8000,
- 0x383ca000,
- 0x383cc000,
- 0x383ce000,
- 0x383d0000,
- 0x383d2000,
- 0x383d4000,
- 0x383d6000,
- 0x383d8000,
- 0x383da000,
- 0x383dc000,
- 0x383de000,
- 0x383e0000,
- 0x383e2000,
- 0x383e4000,
- 0x383e6000,
- 0x383e8000,
- 0x383ea000,
- 0x383ec000,
- 0x383ee000,
- 0x383f0000,
- 0x383f2000,
- 0x383f4000,
- 0x383f6000,
- 0x383f8000,
- 0x383fa000,
- 0x383fc000,
- 0x383fe000,
- 0x38400000,
- 0x38402000,
- 0x38404000,
- 0x38406000,
- 0x38408000,
- 0x3840a000,
- 0x3840c000,
- 0x3840e000,
- 0x38410000,
- 0x38412000,
- 0x38414000,
- 0x38416000,
- 0x38418000,
- 0x3841a000,
- 0x3841c000,
- 0x3841e000,
- 0x38420000,
- 0x38422000,
- 0x38424000,
- 0x38426000,
- 0x38428000,
- 0x3842a000,
- 0x3842c000,
- 0x3842e000,
- 0x38430000,
- 0x38432000,
- 0x38434000,
- 0x38436000,
- 0x38438000,
- 0x3843a000,
- 0x3843c000,
- 0x3843e000,
- 0x38440000,
- 0x38442000,
- 0x38444000,
- 0x38446000,
- 0x38448000,
- 0x3844a000,
- 0x3844c000,
- 0x3844e000,
- 0x38450000,
- 0x38452000,
- 0x38454000,
- 0x38456000,
- 0x38458000,
- 0x3845a000,
- 0x3845c000,
- 0x3845e000,
- 0x38460000,
- 0x38462000,
- 0x38464000,
- 0x38466000,
- 0x38468000,
- 0x3846a000,
- 0x3846c000,
- 0x3846e000,
- 0x38470000,
- 0x38472000,
- 0x38474000,
- 0x38476000,
- 0x38478000,
- 0x3847a000,
- 0x3847c000,
- 0x3847e000,
- 0x38480000,
- 0x38482000,
- 0x38484000,
- 0x38486000,
- 0x38488000,
- 0x3848a000,
- 0x3848c000,
- 0x3848e000,
- 0x38490000,
- 0x38492000,
- 0x38494000,
- 0x38496000,
- 0x38498000,
- 0x3849a000,
- 0x3849c000,
- 0x3849e000,
- 0x384a0000,
- 0x384a2000,
- 0x384a4000,
- 0x384a6000,
- 0x384a8000,
- 0x384aa000,
- 0x384ac000,
- 0x384ae000,
- 0x384b0000,
- 0x384b2000,
- 0x384b4000,
- 0x384b6000,
- 0x384b8000,
- 0x384ba000,
- 0x384bc000,
- 0x384be000,
- 0x384c0000,
- 0x384c2000,
- 0x384c4000,
- 0x384c6000,
- 0x384c8000,
- 0x384ca000,
- 0x384cc000,
- 0x384ce000,
- 0x384d0000,
- 0x384d2000,
- 0x384d4000,
- 0x384d6000,
- 0x384d8000,
- 0x384da000,
- 0x384dc000,
- 0x384de000,
- 0x384e0000,
- 0x384e2000,
- 0x384e4000,
- 0x384e6000,
- 0x384e8000,
- 0x384ea000,
- 0x384ec000,
- 0x384ee000,
- 0x384f0000,
- 0x384f2000,
- 0x384f4000,
- 0x384f6000,
- 0x384f8000,
- 0x384fa000,
- 0x384fc000,
- 0x384fe000,
- 0x38500000,
- 0x38502000,
- 0x38504000,
- 0x38506000,
- 0x38508000,
- 0x3850a000,
- 0x3850c000,
- 0x3850e000,
- 0x38510000,
- 0x38512000,
- 0x38514000,
- 0x38516000,
- 0x38518000,
- 0x3851a000,
- 0x3851c000,
- 0x3851e000,
- 0x38520000,
- 0x38522000,
- 0x38524000,
- 0x38526000,
- 0x38528000,
- 0x3852a000,
- 0x3852c000,
- 0x3852e000,
- 0x38530000,
- 0x38532000,
- 0x38534000,
- 0x38536000,
- 0x38538000,
- 0x3853a000,
- 0x3853c000,
- 0x3853e000,
- 0x38540000,
- 0x38542000,
- 0x38544000,
- 0x38546000,
- 0x38548000,
- 0x3854a000,
- 0x3854c000,
- 0x3854e000,
- 0x38550000,
- 0x38552000,
- 0x38554000,
- 0x38556000,
- 0x38558000,
- 0x3855a000,
- 0x3855c000,
- 0x3855e000,
- 0x38560000,
- 0x38562000,
- 0x38564000,
- 0x38566000,
- 0x38568000,
- 0x3856a000,
- 0x3856c000,
- 0x3856e000,
- 0x38570000,
- 0x38572000,
- 0x38574000,
- 0x38576000,
- 0x38578000,
- 0x3857a000,
- 0x3857c000,
- 0x3857e000,
- 0x38580000,
- 0x38582000,
- 0x38584000,
- 0x38586000,
- 0x38588000,
- 0x3858a000,
- 0x3858c000,
- 0x3858e000,
- 0x38590000,
- 0x38592000,
- 0x38594000,
- 0x38596000,
- 0x38598000,
- 0x3859a000,
- 0x3859c000,
- 0x3859e000,
- 0x385a0000,
- 0x385a2000,
- 0x385a4000,
- 0x385a6000,
- 0x385a8000,
- 0x385aa000,
- 0x385ac000,
- 0x385ae000,
- 0x385b0000,
- 0x385b2000,
- 0x385b4000,
- 0x385b6000,
- 0x385b8000,
- 0x385ba000,
- 0x385bc000,
- 0x385be000,
- 0x385c0000,
- 0x385c2000,
- 0x385c4000,
- 0x385c6000,
- 0x385c8000,
- 0x385ca000,
- 0x385cc000,
- 0x385ce000,
- 0x385d0000,
- 0x385d2000,
- 0x385d4000,
- 0x385d6000,
- 0x385d8000,
- 0x385da000,
- 0x385dc000,
- 0x385de000,
- 0x385e0000,
- 0x385e2000,
- 0x385e4000,
- 0x385e6000,
- 0x385e8000,
- 0x385ea000,
- 0x385ec000,
- 0x385ee000,
- 0x385f0000,
- 0x385f2000,
- 0x385f4000,
- 0x385f6000,
- 0x385f8000,
- 0x385fa000,
- 0x385fc000,
- 0x385fe000,
- 0x38600000,
- 0x38602000,
- 0x38604000,
- 0x38606000,
- 0x38608000,
- 0x3860a000,
- 0x3860c000,
- 0x3860e000,
- 0x38610000,
- 0x38612000,
- 0x38614000,
- 0x38616000,
- 0x38618000,
- 0x3861a000,
- 0x3861c000,
- 0x3861e000,
- 0x38620000,
- 0x38622000,
- 0x38624000,
- 0x38626000,
- 0x38628000,
- 0x3862a000,
- 0x3862c000,
- 0x3862e000,
- 0x38630000,
- 0x38632000,
- 0x38634000,
- 0x38636000,
- 0x38638000,
- 0x3863a000,
- 0x3863c000,
- 0x3863e000,
- 0x38640000,
- 0x38642000,
- 0x38644000,
- 0x38646000,
- 0x38648000,
- 0x3864a000,
- 0x3864c000,
- 0x3864e000,
- 0x38650000,
- 0x38652000,
- 0x38654000,
- 0x38656000,
- 0x38658000,
- 0x3865a000,
- 0x3865c000,
- 0x3865e000,
- 0x38660000,
- 0x38662000,
- 0x38664000,
- 0x38666000,
- 0x38668000,
- 0x3866a000,
- 0x3866c000,
- 0x3866e000,
- 0x38670000,
- 0x38672000,
- 0x38674000,
- 0x38676000,
- 0x38678000,
- 0x3867a000,
- 0x3867c000,
- 0x3867e000,
- 0x38680000,
- 0x38682000,
- 0x38684000,
- 0x38686000,
- 0x38688000,
- 0x3868a000,
- 0x3868c000,
- 0x3868e000,
- 0x38690000,
- 0x38692000,
- 0x38694000,
- 0x38696000,
- 0x38698000,
- 0x3869a000,
- 0x3869c000,
- 0x3869e000,
- 0x386a0000,
- 0x386a2000,
- 0x386a4000,
- 0x386a6000,
- 0x386a8000,
- 0x386aa000,
- 0x386ac000,
- 0x386ae000,
- 0x386b0000,
- 0x386b2000,
- 0x386b4000,
- 0x386b6000,
- 0x386b8000,
- 0x386ba000,
- 0x386bc000,
- 0x386be000,
- 0x386c0000,
- 0x386c2000,
- 0x386c4000,
- 0x386c6000,
- 0x386c8000,
- 0x386ca000,
- 0x386cc000,
- 0x386ce000,
- 0x386d0000,
- 0x386d2000,
- 0x386d4000,
- 0x386d6000,
- 0x386d8000,
- 0x386da000,
- 0x386dc000,
- 0x386de000,
- 0x386e0000,
- 0x386e2000,
- 0x386e4000,
- 0x386e6000,
- 0x386e8000,
- 0x386ea000,
- 0x386ec000,
- 0x386ee000,
- 0x386f0000,
- 0x386f2000,
- 0x386f4000,
- 0x386f6000,
- 0x386f8000,
- 0x386fa000,
- 0x386fc000,
- 0x386fe000,
- 0x38700000,
- 0x38702000,
- 0x38704000,
- 0x38706000,
- 0x38708000,
- 0x3870a000,
- 0x3870c000,
- 0x3870e000,
- 0x38710000,
- 0x38712000,
- 0x38714000,
- 0x38716000,
- 0x38718000,
- 0x3871a000,
- 0x3871c000,
- 0x3871e000,
- 0x38720000,
- 0x38722000,
- 0x38724000,
- 0x38726000,
- 0x38728000,
- 0x3872a000,
- 0x3872c000,
- 0x3872e000,
- 0x38730000,
- 0x38732000,
- 0x38734000,
- 0x38736000,
- 0x38738000,
- 0x3873a000,
- 0x3873c000,
- 0x3873e000,
- 0x38740000,
- 0x38742000,
- 0x38744000,
- 0x38746000,
- 0x38748000,
- 0x3874a000,
- 0x3874c000,
- 0x3874e000,
- 0x38750000,
- 0x38752000,
- 0x38754000,
- 0x38756000,
- 0x38758000,
- 0x3875a000,
- 0x3875c000,
- 0x3875e000,
- 0x38760000,
- 0x38762000,
- 0x38764000,
- 0x38766000,
- 0x38768000,
- 0x3876a000,
- 0x3876c000,
- 0x3876e000,
- 0x38770000,
- 0x38772000,
- 0x38774000,
- 0x38776000,
- 0x38778000,
- 0x3877a000,
- 0x3877c000,
- 0x3877e000,
- 0x38780000,
- 0x38782000,
- 0x38784000,
- 0x38786000,
- 0x38788000,
- 0x3878a000,
- 0x3878c000,
- 0x3878e000,
- 0x38790000,
- 0x38792000,
- 0x38794000,
- 0x38796000,
- 0x38798000,
- 0x3879a000,
- 0x3879c000,
- 0x3879e000,
- 0x387a0000,
- 0x387a2000,
- 0x387a4000,
- 0x387a6000,
- 0x387a8000,
- 0x387aa000,
- 0x387ac000,
- 0x387ae000,
- 0x387b0000,
- 0x387b2000,
- 0x387b4000,
- 0x387b6000,
- 0x387b8000,
- 0x387ba000,
- 0x387bc000,
- 0x387be000,
- 0x387c0000,
- 0x387c2000,
- 0x387c4000,
- 0x387c6000,
- 0x387c8000,
- 0x387ca000,
- 0x387cc000,
- 0x387ce000,
- 0x387d0000,
- 0x387d2000,
- 0x387d4000,
- 0x387d6000,
- 0x387d8000,
- 0x387da000,
- 0x387dc000,
- 0x387de000,
- 0x387e0000,
- 0x387e2000,
- 0x387e4000,
- 0x387e6000,
- 0x387e8000,
- 0x387ea000,
- 0x387ec000,
- 0x387ee000,
- 0x387f0000,
- 0x387f2000,
- 0x387f4000,
- 0x387f6000,
- 0x387f8000,
- 0x387fa000,
- 0x387fc000,
- 0x387fe000,
-};
-
-const static unsigned g_exponent[64] = {
- 0x00000000,
- 0x00800000,
- 0x01000000,
- 0x01800000,
- 0x02000000,
- 0x02800000,
- 0x03000000,
- 0x03800000,
- 0x04000000,
- 0x04800000,
- 0x05000000,
- 0x05800000,
- 0x06000000,
- 0x06800000,
- 0x07000000,
- 0x07800000,
- 0x08000000,
- 0x08800000,
- 0x09000000,
- 0x09800000,
- 0x0a000000,
- 0x0a800000,
- 0x0b000000,
- 0x0b800000,
- 0x0c000000,
- 0x0c800000,
- 0x0d000000,
- 0x0d800000,
- 0x0e000000,
- 0x0e800000,
- 0x0f000000,
- 0x47800000,
- 0x80000000,
- 0x80800000,
- 0x81000000,
- 0x81800000,
- 0x82000000,
- 0x82800000,
- 0x83000000,
- 0x83800000,
- 0x84000000,
- 0x84800000,
- 0x85000000,
- 0x85800000,
- 0x86000000,
- 0x86800000,
- 0x87000000,
- 0x87800000,
- 0x88000000,
- 0x88800000,
- 0x89000000,
- 0x89800000,
- 0x8a000000,
- 0x8a800000,
- 0x8b000000,
- 0x8b800000,
- 0x8c000000,
- 0x8c800000,
- 0x8d000000,
- 0x8d800000,
- 0x8e000000,
- 0x8e800000,
- 0x8f000000,
- 0xc7800000,
-};
-
-const static unsigned g_offset[64] = {
- 0x00000000,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000000,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
- 0x00000400,
-};
-
-float float16ToFloat32(unsigned short h)
-{
- unsigned i32 = g_mantissa[g_offset[h >> 10] + (h & 0x3ff)] + g_exponent[h >> 10];
- return *(float*) &i32;
-}
-}
-
diff --git a/src/3rdparty/angle/src/libGLESv2/Float16ToFloat32.py b/src/3rdparty/angle/src/libGLESv2/Float16ToFloat32.py
deleted file mode 100644
index cf039bfc21..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Float16ToFloat32.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright (c) 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.
-#
-
-# This script generates a function that converts 16-bit precision floating
-# point numbers to 32-bit.
-# It is based on ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf.
-
-def convertMantissa(i):
- if i == 0:
- return 0
- elif i < 1024:
- m = i << 13
- e = 0
- while not (m & 0x00800000):
- e -= 0x00800000
- m = m << 1
- m &= ~0x00800000
- e += 0x38800000
- return m | e
- else:
- return 0x38000000 + ((i - 1024) << 13)
-
-def convertExponent(i):
- if i == 0:
- return 0
- elif i in range(1, 31):
- return i << 23
- elif i == 31:
- return 0x47800000
- elif i == 32:
- return 0x80000000
- elif i in range(33, 63):
- return 0x80000000 + ((i - 32) << 23)
- else:
- return 0xC7800000
-
-def convertOffset(i):
- if i == 0 or i == 32:
- return 0
- else:
- return 1024
-
-print """//
-// Copyright (c) 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.
-//
-
-// This file is automatically generated.
-
-namespace gl
-{
-"""
-
-print "const static unsigned g_mantissa[2048] = {"
-for i in range(0, 2048):
- print " %#010x," % convertMantissa(i)
-print "};\n"
-
-print "const static unsigned g_exponent[64] = {"
-for i in range(0, 64):
- print " %#010x," % convertExponent(i)
-print "};\n"
-
-print "const static unsigned g_offset[64] = {"
-for i in range(0, 64):
- print " %#010x," % convertOffset(i)
-print "};\n"
-
-print """float float16ToFloat32(unsigned short h)
-{
- unsigned i32 = g_mantissa[g_offset[h >> 10] + (h & 0x3ff)] + g_exponent[h >> 10];
- return *(float*) &i32;
-}
-}
-"""
diff --git a/src/3rdparty/angle/src/libGLESv2/Framebuffer.cpp b/src/3rdparty/angle/src/libGLESv2/Framebuffer.cpp
deleted file mode 100644
index 3d57262e3c..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Framebuffer.cpp
+++ /dev/null
@@ -1,672 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// Framebuffer.cpp: Implements the gl::Framebuffer class. Implements GL framebuffer
-// objects and related functionality. [OpenGL ES 2.0.24] section 4.4 page 105.
-
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/main.h"
-#include "libGLESv2/formatutils.h"
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/Context.h"
-#include "libGLESv2/Renderbuffer.h"
-#include "libGLESv2/FramebufferAttachment.h"
-#include "libGLESv2/renderer/Renderer.h"
-#include "libGLESv2/renderer/RenderTarget.h"
-#include "libGLESv2/renderer/RenderbufferImpl.h"
-#include "libGLESv2/renderer/Workarounds.h"
-#include "libGLESv2/renderer/d3d/TextureD3D.h"
-#include "libGLESv2/renderer/d3d/RenderbufferD3D.h"
-
-#include "common/utilities.h"
-
-namespace rx
-{
-// TODO: Move these functions, and the D3D-specific header inclusions above,
-// to FramebufferD3D.
-gl::Error GetAttachmentRenderTarget(gl::FramebufferAttachment *attachment, RenderTarget **outRT)
-{
- if (attachment->isTexture())
- {
- gl::Texture *texture = attachment->getTexture();
- ASSERT(texture);
- TextureD3D *textureD3D = TextureD3D::makeTextureD3D(texture->getImplementation());
- const gl::ImageIndex *index = attachment->getTextureImageIndex();
- ASSERT(index);
- return textureD3D->getRenderTarget(*index, outRT);
- }
- else
- {
- gl::Renderbuffer *renderbuffer = attachment->getRenderbuffer();
- ASSERT(renderbuffer);
- RenderbufferD3D *renderbufferD3D = RenderbufferD3D::makeRenderbufferD3D(renderbuffer->getImplementation());
- *outRT = renderbufferD3D->getRenderTarget();
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-// Note: RenderTarget serials should ideally be in the RenderTargets themselves.
-unsigned int GetAttachmentSerial(gl::FramebufferAttachment *attachment)
-{
- if (attachment->isTexture())
- {
- gl::Texture *texture = attachment->getTexture();
- ASSERT(texture);
- TextureD3D *textureD3D = TextureD3D::makeTextureD3D(texture->getImplementation());
- const gl::ImageIndex *index = attachment->getTextureImageIndex();
- ASSERT(index);
- return textureD3D->getRenderTargetSerial(*index);
- }
-
- gl::Renderbuffer *renderbuffer = attachment->getRenderbuffer();
- ASSERT(renderbuffer);
- RenderbufferD3D *renderbufferD3D = RenderbufferD3D::makeRenderbufferD3D(renderbuffer->getImplementation());
- return renderbufferD3D->getRenderTargetSerial();
-}
-
-}
-
-namespace gl
-{
-
-Framebuffer::Framebuffer(GLuint id)
- : mId(id),
- mReadBufferState(GL_COLOR_ATTACHMENT0_EXT),
- mDepthbuffer(NULL),
- mStencilbuffer(NULL)
-{
- for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
- {
- mColorbuffers[colorAttachment] = NULL;
- mDrawBufferStates[colorAttachment] = GL_NONE;
- }
- mDrawBufferStates[0] = GL_COLOR_ATTACHMENT0_EXT;
-}
-
-Framebuffer::~Framebuffer()
-{
- for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
- {
- SafeDelete(mColorbuffers[colorAttachment]);
- }
- SafeDelete(mDepthbuffer);
- SafeDelete(mStencilbuffer);
-}
-
-void Framebuffer::detachTexture(GLuint textureId)
-{
- for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
- {
- FramebufferAttachment *attachment = mColorbuffers[colorAttachment];
-
- if (attachment && attachment->isTextureWithId(textureId))
- {
- SafeDelete(mColorbuffers[colorAttachment]);
- }
- }
-
- if (mDepthbuffer && mDepthbuffer->isTextureWithId(textureId))
- {
- SafeDelete(mDepthbuffer);
- }
-
- if (mStencilbuffer && mStencilbuffer->isTextureWithId(textureId))
- {
- SafeDelete(mStencilbuffer);
- }
-}
-
-void Framebuffer::detachRenderbuffer(GLuint renderbufferId)
-{
- for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
- {
- FramebufferAttachment *attachment = mColorbuffers[colorAttachment];
-
- if (attachment && attachment->isRenderbufferWithId(renderbufferId))
- {
- SafeDelete(mColorbuffers[colorAttachment]);
- }
- }
-
- if (mDepthbuffer && mDepthbuffer->isRenderbufferWithId(renderbufferId))
- {
- SafeDelete(mDepthbuffer);
- }
-
- if (mStencilbuffer && mStencilbuffer->isRenderbufferWithId(renderbufferId))
- {
- SafeDelete(mStencilbuffer);
- }
-}
-
-FramebufferAttachment *Framebuffer::getColorbuffer(unsigned int colorAttachment) const
-{
- ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS);
- return mColorbuffers[colorAttachment];
-}
-
-FramebufferAttachment *Framebuffer::getDepthbuffer() const
-{
- return mDepthbuffer;
-}
-
-FramebufferAttachment *Framebuffer::getStencilbuffer() const
-{
- return mStencilbuffer;
-}
-
-FramebufferAttachment *Framebuffer::getDepthStencilBuffer() const
-{
- return (hasValidDepthStencil() ? mDepthbuffer : NULL);
-}
-
-FramebufferAttachment *Framebuffer::getDepthOrStencilbuffer() const
-{
- FramebufferAttachment *depthstencilbuffer = mDepthbuffer;
-
- if (!depthstencilbuffer)
- {
- depthstencilbuffer = mStencilbuffer;
- }
-
- return depthstencilbuffer;
-}
-
-FramebufferAttachment *Framebuffer::getReadColorbuffer() const
-{
- // Will require more logic if glReadBuffers is supported
- return mColorbuffers[0];
-}
-
-GLenum Framebuffer::getReadColorbufferType() const
-{
- // Will require more logic if glReadBuffers is supported
- return (mColorbuffers[0] ? mColorbuffers[0]->type() : GL_NONE);
-}
-
-FramebufferAttachment *Framebuffer::getFirstColorbuffer() const
-{
- for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
- {
- if (mColorbuffers[colorAttachment])
- {
- return mColorbuffers[colorAttachment];
- }
- }
-
- return NULL;
-}
-
-FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const
-{
- if (attachment >= GL_COLOR_ATTACHMENT0 && attachment <= GL_COLOR_ATTACHMENT15)
- {
- return getColorbuffer(attachment - GL_COLOR_ATTACHMENT0);
- }
- else
- {
- switch (attachment)
- {
- case GL_DEPTH_ATTACHMENT:
- return getDepthbuffer();
- case GL_STENCIL_ATTACHMENT:
- return getStencilbuffer();
- case GL_DEPTH_STENCIL_ATTACHMENT:
- return getDepthStencilBuffer();
- default:
- UNREACHABLE();
- return NULL;
- }
- }
-}
-
-GLenum Framebuffer::getDrawBufferState(unsigned int colorAttachment) const
-{
- return mDrawBufferStates[colorAttachment];
-}
-
-void Framebuffer::setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer)
-{
- mDrawBufferStates[colorAttachment] = drawBuffer;
-}
-
-bool Framebuffer::isEnabledColorAttachment(unsigned int colorAttachment) const
-{
- return (mColorbuffers[colorAttachment] && mDrawBufferStates[colorAttachment] != GL_NONE);
-}
-
-bool Framebuffer::hasEnabledColorAttachment() const
-{
- for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
- {
- if (isEnabledColorAttachment(colorAttachment))
- {
- return true;
- }
- }
-
- return false;
-}
-
-bool Framebuffer::hasStencil() const
-{
- return (mStencilbuffer && mStencilbuffer->getStencilSize() > 0);
-}
-
-bool Framebuffer::usingExtendedDrawBuffers() const
-{
- for (unsigned int colorAttachment = 1; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
- {
- if (isEnabledColorAttachment(colorAttachment))
- {
- return true;
- }
- }
-
- return false;
-}
-
-GLenum Framebuffer::completeness(const gl::Data &data) const
-{
- int width = 0;
- int height = 0;
- unsigned int colorbufferSize = 0;
- int samples = -1;
- bool missingAttachment = true;
-
- for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
- {
- const FramebufferAttachment *colorbuffer = mColorbuffers[colorAttachment];
-
- if (colorbuffer)
- {
- if (colorbuffer->getWidth() == 0 || colorbuffer->getHeight() == 0)
- {
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
- }
-
- GLenum internalformat = colorbuffer->getInternalFormat();
- const TextureCaps &formatCaps = data.textureCaps->get(internalformat);
- const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat);
- if (colorbuffer->isTexture())
- {
- if (!formatCaps.renderable)
- {
- return GL_FRAMEBUFFER_UNSUPPORTED;
- }
-
- if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0)
- {
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
- }
- }
- else
- {
- if (!formatCaps.renderable || formatInfo.depthBits > 0 || formatInfo.stencilBits > 0)
- {
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
- }
- }
-
- if (!missingAttachment)
- {
- // all color attachments must have the same width and height
- if (colorbuffer->getWidth() != width || colorbuffer->getHeight() != height)
- {
- return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
- }
-
- // APPLE_framebuffer_multisample, which EXT_draw_buffers refers to, requires that
- // all color attachments have the same number of samples for the FBO to be complete.
- if (colorbuffer->getSamples() != samples)
- {
- return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT;
- }
-
- // in GLES 2.0, all color attachments attachments must have the same number of bitplanes
- // in GLES 3.0, there is no such restriction
- if (data.clientVersion < 3)
- {
- if (formatInfo.pixelBytes != colorbufferSize)
- {
- return GL_FRAMEBUFFER_UNSUPPORTED;
- }
- }
-
- // D3D11 does not allow for overlapping RenderTargetViews, so ensure uniqueness
- for (unsigned int previousColorAttachment = 0; previousColorAttachment < colorAttachment; previousColorAttachment++)
- {
- const FramebufferAttachment *previousAttachment = mColorbuffers[previousColorAttachment];
-
- if (previousAttachment &&
- (colorbuffer->id() == previousAttachment->id() &&
- colorbuffer->type() == previousAttachment->type()))
- {
- return GL_FRAMEBUFFER_UNSUPPORTED;
- }
- }
- }
- else
- {
- width = colorbuffer->getWidth();
- height = colorbuffer->getHeight();
- samples = colorbuffer->getSamples();
- colorbufferSize = formatInfo.pixelBytes;
- missingAttachment = false;
- }
- }
- }
-
- if (mDepthbuffer)
- {
- if (mDepthbuffer->getWidth() == 0 || mDepthbuffer->getHeight() == 0)
- {
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
- }
-
- GLenum internalformat = mDepthbuffer->getInternalFormat();
- const TextureCaps &formatCaps = data.textureCaps->get(internalformat);
- const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat);
- if (mDepthbuffer->isTexture())
- {
- // depth texture attachments require OES/ANGLE_depth_texture
- if (!data.extensions->depthTextures)
- {
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
- }
-
- if (!formatCaps.renderable)
- {
- return GL_FRAMEBUFFER_UNSUPPORTED;
- }
-
- if (formatInfo.depthBits == 0)
- {
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
- }
- }
- else
- {
- if (!formatCaps.renderable || formatInfo.depthBits == 0)
- {
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
- }
- }
-
- if (missingAttachment)
- {
- width = mDepthbuffer->getWidth();
- height = mDepthbuffer->getHeight();
- samples = mDepthbuffer->getSamples();
- missingAttachment = false;
- }
- else if (width != mDepthbuffer->getWidth() || height != mDepthbuffer->getHeight())
- {
- return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
- }
- else if (samples != mDepthbuffer->getSamples())
- {
- return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE;
- }
- }
-
- if (mStencilbuffer)
- {
- if (mStencilbuffer->getWidth() == 0 || mStencilbuffer->getHeight() == 0)
- {
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
- }
-
- GLenum internalformat = mStencilbuffer->getInternalFormat();
- const TextureCaps &formatCaps = data.textureCaps->get(internalformat);
- const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat);
- if (mStencilbuffer->isTexture())
- {
- // texture stencil attachments come along as part
- // of OES_packed_depth_stencil + OES/ANGLE_depth_texture
- if (!data.extensions->depthTextures)
- {
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
- }
-
- if (!formatCaps.renderable)
- {
- return GL_FRAMEBUFFER_UNSUPPORTED;
- }
-
- if (formatInfo.stencilBits == 0)
- {
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
- }
- }
- else
- {
- if (!formatCaps.renderable || formatInfo.stencilBits == 0)
- {
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
- }
- }
-
- if (missingAttachment)
- {
- width = mStencilbuffer->getWidth();
- height = mStencilbuffer->getHeight();
- samples = mStencilbuffer->getSamples();
- missingAttachment = false;
- }
- else if (width != mStencilbuffer->getWidth() || height != mStencilbuffer->getHeight())
- {
- return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
- }
- else if (samples != mStencilbuffer->getSamples())
- {
- return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE;
- }
- }
-
- // if we have both a depth and stencil buffer, they must refer to the same object
- // since we only support packed_depth_stencil and not separate depth and stencil
- if (mDepthbuffer && mStencilbuffer && !hasValidDepthStencil())
- {
- return GL_FRAMEBUFFER_UNSUPPORTED;
- }
-
- // we need to have at least one attachment to be complete
- if (missingAttachment)
- {
- return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
- }
-
- return GL_FRAMEBUFFER_COMPLETE;
-}
-
-Error Framebuffer::invalidate(const Caps &caps, GLsizei numAttachments, const GLenum *attachments)
-{
- GLuint maxDimension = caps.maxRenderbufferSize;
- return invalidateSub(numAttachments, attachments, 0, 0, maxDimension, maxDimension);
-}
-
-Error Framebuffer::invalidateSub(GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height)
-{
- for (GLsizei attachIndex = 0; attachIndex < numAttachments; ++attachIndex)
- {
- GLenum attachmentTarget = attachments[attachIndex];
-
- FramebufferAttachment *attachment = (attachmentTarget == GL_DEPTH_STENCIL_ATTACHMENT) ? getDepthOrStencilbuffer()
- : getAttachment(attachmentTarget);
-
- if (attachment)
- {
- rx::RenderTarget *renderTarget = NULL;
- Error error = rx::GetAttachmentRenderTarget(attachment, &renderTarget);
- if (error.isError())
- {
- return error;
- }
-
- renderTarget->invalidate(x, y, width, height);
- }
- }
-
- return Error(GL_NO_ERROR);
-}
-
-DefaultFramebuffer::DefaultFramebuffer(rx::RenderbufferImpl *colorbuffer, rx::RenderbufferImpl *depthStencil)
- : Framebuffer(0)
-{
- Renderbuffer *colorRenderbuffer = new Renderbuffer(colorbuffer, 0);
- mColorbuffers[0] = new RenderbufferAttachment(GL_BACK, colorRenderbuffer);
-
- Renderbuffer *depthStencilBuffer = new Renderbuffer(depthStencil, 0);
-
- // Make a new attachment objects to ensure we do not double-delete
- // See angle issue 686
- mDepthbuffer = (depthStencilBuffer->getDepthSize() != 0 ? new RenderbufferAttachment(GL_DEPTH_ATTACHMENT, depthStencilBuffer) : NULL);
- mStencilbuffer = (depthStencilBuffer->getStencilSize() != 0 ? new RenderbufferAttachment(GL_STENCIL_ATTACHMENT, depthStencilBuffer) : NULL);
-
- mDrawBufferStates[0] = GL_BACK;
- mReadBufferState = GL_BACK;
-}
-
-int Framebuffer::getSamples(const gl::Data &data) const
-{
- if (completeness(data) == GL_FRAMEBUFFER_COMPLETE)
- {
- // for a complete framebuffer, all attachments must have the same sample count
- // in this case return the first nonzero sample size
- for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
- {
- if (mColorbuffers[colorAttachment])
- {
- return mColorbuffers[colorAttachment]->getSamples();
- }
- }
- }
-
- return 0;
-}
-
-bool Framebuffer::hasValidDepthStencil() const
-{
- // A valid depth-stencil attachment has the same resource bound to both the
- // depth and stencil attachment points.
- return (mDepthbuffer && mStencilbuffer &&
- mDepthbuffer->type() == mStencilbuffer->type() &&
- mDepthbuffer->id() == mStencilbuffer->id());
-}
-
-ColorbufferInfo Framebuffer::getColorbuffersForRender(const rx::Workarounds &workarounds) const
-{
- ColorbufferInfo colorbuffersForRender;
-
- for (size_t colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; ++colorAttachment)
- {
- GLenum drawBufferState = mDrawBufferStates[colorAttachment];
- FramebufferAttachment *colorbuffer = mColorbuffers[colorAttachment];
-
- if (colorbuffer != NULL && drawBufferState != GL_NONE)
- {
- ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + colorAttachment));
- colorbuffersForRender.push_back(colorbuffer);
- }
- else if (!workarounds.mrtPerfWorkaround)
- {
- colorbuffersForRender.push_back(NULL);
- }
- }
-
- return colorbuffersForRender;
-}
-
-void Framebuffer::setTextureAttachment(GLenum attachment, Texture *texture, const ImageIndex &imageIndex)
-{
- setAttachment(attachment, new TextureAttachment(attachment, texture, imageIndex));
-}
-
-void Framebuffer::setRenderbufferAttachment(GLenum attachment, Renderbuffer *renderbuffer)
-{
- setAttachment(attachment, new RenderbufferAttachment(attachment, renderbuffer));
-}
-
-void Framebuffer::setNULLAttachment(GLenum attachment)
-{
- setAttachment(attachment, NULL);
-}
-
-void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj)
-{
- if (attachment >= GL_COLOR_ATTACHMENT0 && attachment < (GL_COLOR_ATTACHMENT0 + IMPLEMENTATION_MAX_DRAW_BUFFERS))
- {
- size_t colorAttachment = attachment - GL_COLOR_ATTACHMENT0;
- SafeDelete(mColorbuffers[colorAttachment]);
- mColorbuffers[colorAttachment] = attachmentObj;
- }
- else if (attachment == GL_DEPTH_ATTACHMENT)
- {
- SafeDelete(mDepthbuffer);
- mDepthbuffer = attachmentObj;
- }
- else if (attachment == GL_STENCIL_ATTACHMENT)
- {
- SafeDelete(mStencilbuffer);
- mStencilbuffer = attachmentObj;
- }
- else if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
- {
- SafeDelete(mDepthbuffer);
- SafeDelete(mStencilbuffer);
-
- // ensure this is a legitimate depth+stencil format
- if (attachmentObj && attachmentObj->getDepthSize() > 0 && attachmentObj->getStencilSize() > 0)
- {
- mDepthbuffer = attachmentObj;
-
- // Make a new attachment object to ensure we do not double-delete
- // See angle issue 686
- if (attachmentObj->isTexture())
- {
- mStencilbuffer = new TextureAttachment(GL_DEPTH_STENCIL_ATTACHMENT, attachmentObj->getTexture(),
- *attachmentObj->getTextureImageIndex());
- }
- else
- {
- mStencilbuffer = new RenderbufferAttachment(GL_DEPTH_STENCIL_ATTACHMENT, attachmentObj->getRenderbuffer());
- }
- }
- }
- else
- {
- UNREACHABLE();
- }
-}
-
-GLenum DefaultFramebuffer::completeness(const gl::Data &) const
-{
- // The default framebuffer *must* always be complete, though it may not be
- // subject to the same rules as application FBOs. ie, it could have 0x0 size.
- return GL_FRAMEBUFFER_COMPLETE;
-}
-
-FramebufferAttachment *DefaultFramebuffer::getAttachment(GLenum attachment) const
-{
- switch (attachment)
- {
- case GL_COLOR:
- case GL_BACK:
- return getColorbuffer(0);
- case GL_DEPTH:
- return getDepthbuffer();
- case GL_STENCIL:
- return getStencilbuffer();
- case GL_DEPTH_STENCIL:
- return getDepthStencilBuffer();
- default:
- UNREACHABLE();
- return NULL;
- }
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/Framebuffer.h b/src/3rdparty/angle/src/libGLESv2/Framebuffer.h
deleted file mode 100644
index d0fe8935ea..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Framebuffer.h
+++ /dev/null
@@ -1,126 +0,0 @@
-//
-// Copyright (c) 2002-2013 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.
-//
-
-// Framebuffer.h: Defines the gl::Framebuffer class. Implements GL framebuffer
-// objects and related functionality. [OpenGL ES 2.0.24] section 4.4 page 105.
-
-#ifndef LIBGLESV2_FRAMEBUFFER_H_
-#define LIBGLESV2_FRAMEBUFFER_H_
-
-#include "libGLESv2/Error.h"
-
-#include "common/angleutils.h"
-#include "common/RefCountObject.h"
-#include "Constants.h"
-
-#include <vector>
-
-namespace rx
-{
-class RenderbufferImpl;
-struct Workarounds;
-}
-
-namespace gl
-{
-class FramebufferAttachment;
-class Texture;
-class Renderbuffer;
-struct ImageIndex;
-struct Caps;
-struct Extensions;
-class TextureCapsMap;
-struct Data;
-
-typedef std::vector<FramebufferAttachment *> ColorbufferInfo;
-
-class Framebuffer
-{
- public:
- Framebuffer(GLuint id);
- virtual ~Framebuffer();
-
- GLuint id() const { return mId; }
-
- void setTextureAttachment(GLenum attachment, Texture *texture, const ImageIndex &imageIndex);
- void setRenderbufferAttachment(GLenum attachment, Renderbuffer *renderbuffer);
- void setNULLAttachment(GLenum attachment);
-
- void detachTexture(GLuint texture);
- void detachRenderbuffer(GLuint renderbuffer);
-
- FramebufferAttachment *getColorbuffer(unsigned int colorAttachment) const;
- FramebufferAttachment *getDepthbuffer() const;
- FramebufferAttachment *getStencilbuffer() const;
- FramebufferAttachment *getDepthStencilBuffer() const;
- FramebufferAttachment *getDepthOrStencilbuffer() const;
- FramebufferAttachment *getReadColorbuffer() const;
- GLenum getReadColorbufferType() const;
- FramebufferAttachment *getFirstColorbuffer() const;
-
- virtual FramebufferAttachment *getAttachment(GLenum attachment) const;
-
- GLenum getDrawBufferState(unsigned int colorAttachment) const;
- void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
-
- bool isEnabledColorAttachment(unsigned int colorAttachment) const;
- bool hasEnabledColorAttachment() const;
- bool hasStencil() const;
- int getSamples(const gl::Data &data) const;
- bool usingExtendedDrawBuffers() const;
-
- virtual GLenum completeness(const gl::Data &data) const;
- bool hasValidDepthStencil() const;
-
- Error invalidate(const Caps &caps, GLsizei numAttachments, const GLenum *attachments);
- Error invalidateSub(GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);
-
- // Use this method to retrieve the color buffer map when doing rendering.
- // It will apply a workaround for poor shader performance on some systems
- // by compacting the list to skip NULL values.
- ColorbufferInfo getColorbuffersForRender(const rx::Workarounds &workarounds) const;
-
- protected:
- GLuint mId;
-
- FramebufferAttachment *mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
- GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS];
- GLenum mReadBufferState;
-
- FramebufferAttachment *mDepthbuffer;
- FramebufferAttachment *mStencilbuffer;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Framebuffer);
-
- void setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj);
-};
-
-class DefaultFramebuffer : public Framebuffer
-{
- public:
- DefaultFramebuffer(rx::RenderbufferImpl *colorbuffer, rx::RenderbufferImpl *depthStencil);
-
- GLenum completeness(const gl::Data &data) const override;
- virtual FramebufferAttachment *getAttachment(GLenum attachment) const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
-};
-
-}
-
-namespace rx
-{
-class RenderTarget;
-
-// TODO: place this in FramebufferD3D.h
-gl::Error GetAttachmentRenderTarget(gl::FramebufferAttachment *attachment, RenderTarget **outRT);
-unsigned int GetAttachmentSerial(gl::FramebufferAttachment *attachment);
-
-}
-
-#endif // LIBGLESV2_FRAMEBUFFER_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/FramebufferAttachment.cpp b/src/3rdparty/angle/src/libGLESv2/FramebufferAttachment.cpp
deleted file mode 100644
index 894884a6d8..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/FramebufferAttachment.cpp
+++ /dev/null
@@ -1,230 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// FramebufferAttachment.cpp: the gl::FramebufferAttachment class and its derived classes
-// objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108.
-
-#include "libGLESv2/FramebufferAttachment.h"
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/formatutils.h"
-#include "libGLESv2/Renderbuffer.h"
-#include "libGLESv2/renderer/RenderTarget.h"
-#include "libGLESv2/renderer/Renderer.h"
-#include "libGLESv2/renderer/d3d/TextureStorage.h"
-
-#include "common/utilities.h"
-
-namespace gl
-{
-
-////// FramebufferAttachment Implementation //////
-
-FramebufferAttachment::FramebufferAttachment(GLenum binding)
- : mBinding(binding)
-{
-}
-
-FramebufferAttachment::~FramebufferAttachment()
-{
-}
-
-GLuint FramebufferAttachment::getRedSize() const
-{
- return (GetInternalFormatInfo(getInternalFormat()).redBits > 0) ? GetInternalFormatInfo(getActualFormat()).redBits : 0;
-}
-
-GLuint FramebufferAttachment::getGreenSize() const
-{
- return (GetInternalFormatInfo(getInternalFormat()).greenBits > 0) ? GetInternalFormatInfo(getActualFormat()).greenBits : 0;
-}
-
-GLuint FramebufferAttachment::getBlueSize() const
-{
- return (GetInternalFormatInfo(getInternalFormat()).blueBits > 0) ? GetInternalFormatInfo(getActualFormat()).blueBits : 0;
-}
-
-GLuint FramebufferAttachment::getAlphaSize() const
-{
- return (GetInternalFormatInfo(getInternalFormat()).alphaBits > 0) ? GetInternalFormatInfo(getActualFormat()).alphaBits : 0;
-}
-
-GLuint FramebufferAttachment::getDepthSize() const
-{
- return (GetInternalFormatInfo(getInternalFormat()).depthBits > 0) ? GetInternalFormatInfo(getActualFormat()).depthBits : 0;
-}
-
-GLuint FramebufferAttachment::getStencilSize() const
-{
- return (GetInternalFormatInfo(getInternalFormat()).stencilBits > 0) ? GetInternalFormatInfo(getActualFormat()).stencilBits : 0;
-}
-
-GLenum FramebufferAttachment::getComponentType() const
-{
- return GetInternalFormatInfo(getActualFormat()).componentType;
-}
-
-GLenum FramebufferAttachment::getColorEncoding() const
-{
- return GetInternalFormatInfo(getActualFormat()).colorEncoding;
-}
-
-bool FramebufferAttachment::isTexture() const
-{
- return (type() != GL_RENDERBUFFER);
-}
-
-///// TextureAttachment Implementation ////////
-
-TextureAttachment::TextureAttachment(GLenum binding, Texture *texture, const ImageIndex &index)
- : FramebufferAttachment(binding),
- mIndex(index)
-{
- mTexture.set(texture);
-}
-
-TextureAttachment::~TextureAttachment()
-{
- mTexture.set(NULL);
-}
-
-GLsizei TextureAttachment::getSamples() const
-{
- return 0;
-}
-
-GLuint TextureAttachment::id() const
-{
- return mTexture->id();
-}
-
-GLsizei TextureAttachment::getWidth() const
-{
- return mTexture->getWidth(mIndex);
-}
-
-GLsizei TextureAttachment::getHeight() const
-{
- return mTexture->getHeight(mIndex);
-}
-
-GLenum TextureAttachment::getInternalFormat() const
-{
- return mTexture->getInternalFormat(mIndex);
-}
-
-GLenum TextureAttachment::getActualFormat() const
-{
- return mTexture->getActualFormat(mIndex);
-}
-
-GLenum TextureAttachment::type() const
-{
- return mIndex.type;
-}
-
-GLint TextureAttachment::mipLevel() const
-{
- return mIndex.mipIndex;
-}
-
-GLint TextureAttachment::layer() const
-{
- return mIndex.layerIndex;
-}
-
-Texture *TextureAttachment::getTexture()
-{
- return mTexture.get();
-}
-
-const ImageIndex *TextureAttachment::getTextureImageIndex() const
-{
- return &mIndex;
-}
-
-Renderbuffer *TextureAttachment::getRenderbuffer()
-{
- UNREACHABLE();
- return NULL;
-}
-
-////// RenderbufferAttachment Implementation //////
-
-RenderbufferAttachment::RenderbufferAttachment(GLenum binding, Renderbuffer *renderbuffer)
- : FramebufferAttachment(binding)
-{
- ASSERT(renderbuffer);
- mRenderbuffer.set(renderbuffer);
-}
-
-RenderbufferAttachment::~RenderbufferAttachment()
-{
- mRenderbuffer.set(NULL);
-}
-
-GLsizei RenderbufferAttachment::getWidth() const
-{
- return mRenderbuffer->getWidth();
-}
-
-GLsizei RenderbufferAttachment::getHeight() const
-{
- return mRenderbuffer->getHeight();
-}
-
-GLenum RenderbufferAttachment::getInternalFormat() const
-{
- return mRenderbuffer->getInternalFormat();
-}
-
-GLenum RenderbufferAttachment::getActualFormat() const
-{
- return mRenderbuffer->getActualFormat();
-}
-
-GLsizei RenderbufferAttachment::getSamples() const
-{
- return mRenderbuffer->getSamples();
-}
-
-GLuint RenderbufferAttachment::id() const
-{
- return mRenderbuffer->id();
-}
-
-GLenum RenderbufferAttachment::type() const
-{
- return GL_RENDERBUFFER;
-}
-
-GLint RenderbufferAttachment::mipLevel() const
-{
- return 0;
-}
-
-GLint RenderbufferAttachment::layer() const
-{
- return 0;
-}
-
-Texture *RenderbufferAttachment::getTexture()
-{
- UNREACHABLE();
- return NULL;
-}
-
-const ImageIndex *RenderbufferAttachment::getTextureImageIndex() const
-{
- UNREACHABLE();
- return NULL;
-}
-
-Renderbuffer *RenderbufferAttachment::getRenderbuffer()
-{
- return mRenderbuffer.get();
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/FramebufferAttachment.h b/src/3rdparty/angle/src/libGLESv2/FramebufferAttachment.h
deleted file mode 100644
index 8d2dafa7ee..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/FramebufferAttachment.h
+++ /dev/null
@@ -1,132 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// FramebufferAttachment.h: Defines the wrapper class gl::FramebufferAttachment, as well as the
-// objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108.
-
-#ifndef LIBGLESV2_FRAMEBUFFERATTACHMENT_H_
-#define LIBGLESV2_FRAMEBUFFERATTACHMENT_H_
-
-#include "common/angleutils.h"
-#include "common/RefCountObject.h"
-#include "Texture.h"
-
-#include "angle_gl.h"
-
-namespace gl
-{
-class Renderbuffer;
-
-// FramebufferAttachment implements a GL framebuffer attachment.
-// Attachments are "light" containers, which store pointers to ref-counted GL objects.
-// We support GL texture (2D/3D/Cube/2D array) and renderbuffer object attachments.
-// Note: Our old naming scheme used the term "Renderbuffer" for both GL renderbuffers and for
-// framebuffer attachments, which confused their usage.
-
-class FramebufferAttachment
-{
- public:
- explicit FramebufferAttachment(GLenum binding);
- virtual ~FramebufferAttachment();
-
- // Helper methods
- GLuint getRedSize() const;
- GLuint getGreenSize() const;
- GLuint getBlueSize() const;
- GLuint getAlphaSize() const;
- GLuint getDepthSize() const;
- GLuint getStencilSize() const;
- GLenum getComponentType() const;
- GLenum getColorEncoding() const;
- bool isTexture() const;
-
- bool isTextureWithId(GLuint textureId) const { return isTexture() && id() == textureId; }
- bool isRenderbufferWithId(GLuint renderbufferId) const { return !isTexture() && id() == renderbufferId; }
-
- GLenum getBinding() const { return mBinding; }
-
- // Child class interface
- virtual GLsizei getWidth() const = 0;
- virtual GLsizei getHeight() const = 0;
- virtual GLenum getInternalFormat() const = 0;
- virtual GLenum getActualFormat() const = 0;
- virtual GLsizei getSamples() const = 0;
-
- virtual GLuint id() const = 0;
- virtual GLenum type() const = 0;
- virtual GLint mipLevel() const = 0;
- virtual GLint layer() const = 0;
-
- virtual Texture *getTexture() = 0;
- virtual const ImageIndex *getTextureImageIndex() const = 0;
- virtual Renderbuffer *getRenderbuffer() = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FramebufferAttachment);
-
- GLenum mBinding;
-};
-
-class TextureAttachment : public FramebufferAttachment
-{
- public:
- TextureAttachment(GLenum binding, Texture *texture, const ImageIndex &index);
- virtual ~TextureAttachment();
-
- virtual GLsizei getSamples() const;
- virtual GLuint id() const;
-
- virtual GLsizei getWidth() const;
- virtual GLsizei getHeight() const;
- virtual GLenum getInternalFormat() const;
- virtual GLenum getActualFormat() const;
-
- virtual GLenum type() const;
- virtual GLint mipLevel() const;
- virtual GLint layer() const;
-
- virtual Texture *getTexture();
- virtual const ImageIndex *getTextureImageIndex() const;
- virtual Renderbuffer *getRenderbuffer();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureAttachment);
-
- BindingPointer<Texture> mTexture;
- ImageIndex mIndex;
-};
-
-class RenderbufferAttachment : public FramebufferAttachment
-{
- public:
- RenderbufferAttachment(GLenum binding, Renderbuffer *renderbuffer);
-
- virtual ~RenderbufferAttachment();
-
- virtual GLsizei getWidth() const;
- virtual GLsizei getHeight() const;
- virtual GLenum getInternalFormat() const;
- virtual GLenum getActualFormat() const;
- virtual GLsizei getSamples() const;
-
- virtual GLuint id() const;
- virtual GLenum type() const;
- virtual GLint mipLevel() const;
- virtual GLint layer() const;
-
- virtual Texture *getTexture();
- virtual const ImageIndex *getTextureImageIndex() const;
- virtual Renderbuffer *getRenderbuffer();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment);
-
- BindingPointer<Renderbuffer> mRenderbuffer;
-};
-
-}
-
-#endif // LIBGLESV2_FRAMEBUFFERATTACHMENT_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/HandleAllocator.cpp b/src/3rdparty/angle/src/libGLESv2/HandleAllocator.cpp
deleted file mode 100644
index c498f8a178..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/HandleAllocator.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-//
-// Copyright (c) 2002-2011 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.
-//
-
-// HandleAllocator.cpp: Implements the gl::HandleAllocator class, which is used
-// to allocate GL handles.
-
-#include "libGLESv2/HandleAllocator.h"
-
-#include "libGLESv2/main.h"
-
-namespace gl
-{
-
-HandleAllocator::HandleAllocator() : mBaseValue(1), mNextValue(1)
-{
-}
-
-HandleAllocator::~HandleAllocator()
-{
-}
-
-void HandleAllocator::setBaseHandle(GLuint value)
-{
- ASSERT(mBaseValue == mNextValue);
- mBaseValue = value;
- mNextValue = value;
-}
-
-GLuint HandleAllocator::allocate()
-{
- if (mFreeValues.size())
- {
- GLuint handle = mFreeValues.back();
- mFreeValues.pop_back();
- return handle;
- }
- return mNextValue++;
-}
-
-void HandleAllocator::release(GLuint handle)
-{
- if (handle == mNextValue - 1)
- {
- // Don't drop below base value
- if(mNextValue > mBaseValue)
- {
- mNextValue--;
- }
- }
- else
- {
- // Only free handles that we own - don't drop below the base value
- if (handle >= mBaseValue)
- {
- mFreeValues.push_back(handle);
- }
- }
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/HandleAllocator.h b/src/3rdparty/angle/src/libGLESv2/HandleAllocator.h
deleted file mode 100644
index a89cc86775..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/HandleAllocator.h
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-// Copyright (c) 2002-2011 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.
-//
-
-// HandleAllocator.h: Defines the gl::HandleAllocator class, which is used to
-// allocate GL handles.
-
-#ifndef LIBGLESV2_HANDLEALLOCATOR_H_
-#define LIBGLESV2_HANDLEALLOCATOR_H_
-
-#include "common/angleutils.h"
-
-#include "angle_gl.h"
-
-#include <vector>
-
-namespace gl
-{
-
-class HandleAllocator
-{
- public:
- HandleAllocator();
- virtual ~HandleAllocator();
-
- void setBaseHandle(GLuint value);
-
- GLuint allocate();
- void release(GLuint handle);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(HandleAllocator);
-
- GLuint mBaseValue;
- GLuint mNextValue;
- typedef std::vector<GLuint> HandleList;
- HandleList mFreeValues;
-};
-
-}
-
-#endif // LIBGLESV2_HANDLEALLOCATOR_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/ImageIndex.cpp b/src/3rdparty/angle/src/libGLESv2/ImageIndex.cpp
deleted file mode 100644
index b45cd9c169..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/ImageIndex.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// ImageIndex.cpp: Implementation for ImageIndex methods.
-
-#include "libGLESv2/ImageIndex.h"
-#include "libGLESv2/Texture.h"
-#include "common/utilities.h"
-
-namespace gl
-{
-
-ImageIndex::ImageIndex(const ImageIndex &other)
- : type(other.type),
- mipIndex(other.mipIndex),
- layerIndex(other.layerIndex)
-{}
-
-ImageIndex &ImageIndex::operator=(const ImageIndex &other)
-{
- type = other.type;
- mipIndex = other.mipIndex;
- layerIndex = other.layerIndex;
- return *this;
-}
-
-ImageIndex ImageIndex::Make2D(GLint mipIndex)
-{
- return ImageIndex(GL_TEXTURE_2D, mipIndex, ENTIRE_LEVEL);
-}
-
-ImageIndex ImageIndex::MakeCube(GLenum target, GLint mipIndex)
-{
- ASSERT(gl::IsCubemapTextureTarget(target));
- return ImageIndex(target, mipIndex, TextureCubeMap::targetToLayerIndex(target));
-}
-
-ImageIndex ImageIndex::Make2DArray(GLint mipIndex, GLint layerIndex)
-{
- return ImageIndex(GL_TEXTURE_2D_ARRAY, mipIndex, layerIndex);
-}
-
-ImageIndex ImageIndex::Make3D(GLint mipIndex, GLint layerIndex)
-{
- return ImageIndex(GL_TEXTURE_3D, mipIndex, layerIndex);
-}
-
-ImageIndex ImageIndex::MakeInvalid()
-{
- return ImageIndex(GL_NONE, -1, -1);
-}
-
-ImageIndex::ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn)
- : type(typeIn),
- mipIndex(mipIndexIn),
- layerIndex(layerIndexIn)
-{}
-
-ImageIndexIterator ImageIndexIterator::Make2D(GLint minMip, GLint maxMip)
-{
- return ImageIndexIterator(GL_TEXTURE_2D, rx::Range<GLint>(minMip, maxMip),
- rx::Range<GLint>(ImageIndex::ENTIRE_LEVEL, ImageIndex::ENTIRE_LEVEL), NULL);
-}
-
-ImageIndexIterator ImageIndexIterator::MakeCube(GLint minMip, GLint maxMip)
-{
- return ImageIndexIterator(GL_TEXTURE_CUBE_MAP, rx::Range<GLint>(minMip, maxMip), rx::Range<GLint>(0, 6), NULL);
-}
-
-ImageIndexIterator ImageIndexIterator::Make3D(GLint minMip, GLint maxMip,
- GLint minLayer, GLint maxLayer)
-{
- return ImageIndexIterator(GL_TEXTURE_3D, rx::Range<GLint>(minMip, maxMip), rx::Range<GLint>(minLayer, maxLayer), NULL);
-}
-
-ImageIndexIterator ImageIndexIterator::Make2DArray(GLint minMip, GLint maxMip,
- const GLsizei *layerCounts)
-{
- return ImageIndexIterator(GL_TEXTURE_2D_ARRAY, rx::Range<GLint>(minMip, maxMip),
- rx::Range<GLint>(0, IMPLEMENTATION_MAX_2D_ARRAY_TEXTURE_LAYERS), layerCounts);
-}
-
-ImageIndexIterator::ImageIndexIterator(GLenum type, const rx::Range<GLint> &mipRange,
- const rx::Range<GLint> &layerRange, const GLsizei *layerCounts)
- : mType(type),
- mMipRange(mipRange),
- mLayerRange(layerRange),
- mLayerCounts(layerCounts),
- mCurrentMip(mipRange.start),
- mCurrentLayer(layerRange.start)
-{}
-
-GLint ImageIndexIterator::maxLayer() const
-{
- return (mLayerCounts ? static_cast<GLint>(mLayerCounts[mCurrentMip]) : mLayerRange.end);
-}
-
-ImageIndex ImageIndexIterator::next()
-{
- ASSERT(hasNext());
-
- ImageIndex value = current();
-
- // Iterate layers in the inner loop for now. We can add switchable
- // layer or mip iteration if we need it.
-
- if (mCurrentLayer != ImageIndex::ENTIRE_LEVEL)
- {
- if (mCurrentLayer < maxLayer()-1)
- {
- mCurrentLayer++;
- }
- else if (mCurrentMip < mMipRange.end-1)
- {
- mCurrentMip++;
- mCurrentLayer = mLayerRange.start;
- }
- }
- else if (mCurrentMip < mMipRange.end-1)
- {
- mCurrentMip++;
- mCurrentLayer = mLayerRange.start;
- }
-
- return value;
-}
-
-ImageIndex ImageIndexIterator::current() const
-{
- ImageIndex value(mType, mCurrentMip, mCurrentLayer);
-
- if (mType == GL_TEXTURE_CUBE_MAP)
- {
- value.type = TextureCubeMap::layerIndexToTarget(mCurrentLayer);
- }
-
- return value;
-}
-
-bool ImageIndexIterator::hasNext() const
-{
- return (mCurrentMip < mMipRange.end || mCurrentLayer < maxLayer());
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/ImageIndex.h b/src/3rdparty/angle/src/libGLESv2/ImageIndex.h
deleted file mode 100644
index 8bb14fd555..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/ImageIndex.h
+++ /dev/null
@@ -1,68 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// ImageIndex.h: A helper struct for indexing into an Image array
-
-#ifndef LIBGLESV2_IMAGE_INDEX_H_
-#define LIBGLESV2_IMAGE_INDEX_H_
-
-#include "angle_gl.h"
-#include "common/mathutil.h"
-
-namespace gl
-{
-
-struct ImageIndex
-{
- GLenum type;
- GLint mipIndex;
- GLint layerIndex;
-
- ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn);
- ImageIndex(const ImageIndex &other);
- ImageIndex &operator=(const ImageIndex &other);
-
- bool hasLayer() const { return layerIndex != ENTIRE_LEVEL; }
-
- static ImageIndex Make2D(GLint mipIndex);
- static ImageIndex MakeCube(GLenum target, GLint mipIndex);
- static ImageIndex Make2DArray(GLint mipIndex, GLint layerIndex);
- static ImageIndex Make3D(GLint mipIndex, GLint layerIndex = ENTIRE_LEVEL);
- static ImageIndex MakeInvalid();
-
- static const GLint ENTIRE_LEVEL = static_cast<GLint>(-1);
-};
-
-class ImageIndexIterator
-{
- public:
- static ImageIndexIterator Make2D(GLint minMip, GLint maxMip);
- static ImageIndexIterator MakeCube(GLint minMip, GLint maxMip);
- static ImageIndexIterator Make3D(GLint minMip, GLint maxMip, GLint minLayer, GLint maxLayer);
- static ImageIndexIterator Make2DArray(GLint minMip, GLint maxMip, const GLsizei *layerCounts);
-
- ImageIndex next();
- ImageIndex current() const;
- bool hasNext() const;
-
- private:
-
- ImageIndexIterator(GLenum type, const rx::Range<GLint> &mipRange,
- const rx::Range<GLint> &layerRange, const GLsizei *layerCounts);
-
- GLint maxLayer() const;
-
- GLenum mType;
- rx::Range<GLint> mMipRange;
- rx::Range<GLint> mLayerRange;
- const GLsizei *mLayerCounts;
- GLint mCurrentMip;
- GLint mCurrentLayer;
-};
-
-}
-
-#endif // LIBGLESV2_IMAGE_INDEX_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/Program.cpp b/src/3rdparty/angle/src/libGLESv2/Program.cpp
deleted file mode 100644
index 3faa8c56f6..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Program.cpp
+++ /dev/null
@@ -1,668 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// Program.cpp: Implements the gl::Program class. Implements GL program objects
-// and related functionality. [OpenGL ES 2.0.24] section 2.10.3 page 28.
-
-#include "libGLESv2/Program.h"
-#include "libGLESv2/ProgramBinary.h"
-#include "libGLESv2/ResourceManager.h"
-#include "libGLESv2/renderer/Renderer.h"
-
-namespace gl
-{
-const char * const g_fakepath = "C:\\fakepath";
-
-AttributeBindings::AttributeBindings()
-{
-}
-
-AttributeBindings::~AttributeBindings()
-{
-}
-
-InfoLog::InfoLog() : mInfoLog(NULL)
-{
-}
-
-InfoLog::~InfoLog()
-{
- delete[] mInfoLog;
-}
-
-
-int InfoLog::getLength() const
-{
- if (!mInfoLog)
- {
- return 0;
- }
- else
- {
- return strlen(mInfoLog) + 1;
- }
-}
-
-void InfoLog::getLog(GLsizei bufSize, GLsizei *length, char *infoLog)
-{
- int index = 0;
-
- if (bufSize > 0)
- {
- if (mInfoLog)
- {
- index = std::min(bufSize - 1, (int)strlen(mInfoLog));
- memcpy(infoLog, mInfoLog, index);
- }
-
- infoLog[index] = '\0';
- }
-
- if (length)
- {
- *length = index;
- }
-}
-
-// append a santized message to the program info log.
-// The D3D compiler includes a fake file path in some of the warning or error
-// messages, so lets remove all occurrences of this fake file path from the log.
-void InfoLog::appendSanitized(const char *message)
-{
- std::string msg(message);
-
- size_t found;
- do
- {
- found = msg.find(g_fakepath);
- if (found != std::string::npos)
- {
- msg.erase(found, strlen(g_fakepath));
- }
- }
- while (found != std::string::npos);
-
- append("%s", msg.c_str());
-}
-
-void InfoLog::append(const char *format, ...)
-{
- if (!format)
- {
- return;
- }
-
- va_list vararg;
- va_start(vararg, format);
- size_t infoLength = vsnprintf(NULL, 0, format, vararg);
- va_end(vararg);
-
- char *logPointer = NULL;
-
- if (!mInfoLog)
- {
- mInfoLog = new char[infoLength + 2];
- logPointer = mInfoLog;
- }
- else
- {
- size_t currentlogLength = strlen(mInfoLog);
- char *newLog = new char[currentlogLength + infoLength + 2];
- strcpy(newLog, mInfoLog);
-
- delete[] mInfoLog;
- mInfoLog = newLog;
-
- logPointer = mInfoLog + currentlogLength;
- }
-
- va_start(vararg, format);
- vsnprintf(logPointer, infoLength, format, vararg);
- va_end(vararg);
-
- logPointer[infoLength] = 0;
- strcpy(logPointer + infoLength, "\n");
-}
-
-void InfoLog::reset()
-{
- if (mInfoLog)
- {
- delete [] mInfoLog;
- mInfoLog = NULL;
- }
-}
-
-Program::Program(rx::Renderer *renderer, ResourceManager *manager, GLuint handle) : mResourceManager(manager), mHandle(handle)
-{
- mFragmentShader = NULL;
- mVertexShader = NULL;
- mProgramBinary.set(NULL);
- mDeleteStatus = false;
- mLinked = false;
- mRefCount = 0;
- mRenderer = renderer;
-
- resetUniformBlockBindings();
-}
-
-Program::~Program()
-{
- unlink(true);
-
- if (mVertexShader != NULL)
- {
- mVertexShader->release();
- }
-
- if (mFragmentShader != NULL)
- {
- mFragmentShader->release();
- }
-}
-
-bool Program::attachShader(Shader *shader)
-{
- if (shader->getType() == GL_VERTEX_SHADER)
- {
- if (mVertexShader)
- {
- return false;
- }
-
- mVertexShader = shader;
- mVertexShader->addRef();
- }
- else if (shader->getType() == GL_FRAGMENT_SHADER)
- {
- if (mFragmentShader)
- {
- return false;
- }
-
- mFragmentShader = shader;
- mFragmentShader->addRef();
- }
- else UNREACHABLE();
-
- return true;
-}
-
-bool Program::detachShader(Shader *shader)
-{
- if (shader->getType() == GL_VERTEX_SHADER)
- {
- if (mVertexShader != shader)
- {
- return false;
- }
-
- mVertexShader->release();
- mVertexShader = NULL;
- }
- else if (shader->getType() == GL_FRAGMENT_SHADER)
- {
- if (mFragmentShader != shader)
- {
- return false;
- }
-
- mFragmentShader->release();
- mFragmentShader = NULL;
- }
- else UNREACHABLE();
-
- return true;
-}
-
-int Program::getAttachedShadersCount() const
-{
- return (mVertexShader ? 1 : 0) + (mFragmentShader ? 1 : 0);
-}
-
-void AttributeBindings::bindAttributeLocation(GLuint index, const char *name)
-{
- if (index < MAX_VERTEX_ATTRIBS)
- {
- for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
- {
- mAttributeBinding[i].erase(name);
- }
-
- mAttributeBinding[index].insert(name);
- }
-}
-
-void Program::bindAttributeLocation(GLuint index, const char *name)
-{
- mAttributeBindings.bindAttributeLocation(index, name);
-}
-
-// Links the HLSL code of the vertex and pixel shader by matching up their varyings,
-// compiling them into binaries, determining the attribute mappings, and collecting
-// a list of uniforms
-Error Program::link(const Data &data)
-{
- unlink(false);
-
- mInfoLog.reset();
- resetUniformBlockBindings();
-
- mProgramBinary.set(new ProgramBinary(mRenderer->createProgram()));
- LinkResult result = mProgramBinary->link(data, mInfoLog, mAttributeBindings, mFragmentShader, mVertexShader,
- mTransformFeedbackVaryings, mTransformFeedbackBufferMode);
- if (result.error.isError())
- {
- return result.error;
- }
-
- mLinked = result.linkSuccess;
- return gl::Error(GL_NO_ERROR);
-}
-
-int AttributeBindings::getAttributeBinding(const std::string &name) const
-{
- for (int location = 0; location < MAX_VERTEX_ATTRIBS; location++)
- {
- if (mAttributeBinding[location].find(name) != mAttributeBinding[location].end())
- {
- return location;
- }
- }
-
- return -1;
-}
-
-// Returns the program object to an unlinked state, before re-linking, or at destruction
-void Program::unlink(bool destroy)
-{
- if (destroy) // Object being destructed
- {
- if (mFragmentShader)
- {
- mFragmentShader->release();
- mFragmentShader = NULL;
- }
-
- if (mVertexShader)
- {
- mVertexShader->release();
- mVertexShader = NULL;
- }
- }
-
- mProgramBinary.set(NULL);
- mLinked = false;
-}
-
-bool Program::isLinked()
-{
- return mLinked;
-}
-
-ProgramBinary* Program::getProgramBinary() const
-{
- return mProgramBinary.get();
-}
-
-Error Program::setProgramBinary(GLenum binaryFormat, const void *binary, GLsizei length)
-{
- unlink(false);
-
- mInfoLog.reset();
-
- mProgramBinary.set(new ProgramBinary(mRenderer->createProgram()));
- LinkResult result = mProgramBinary->load(mInfoLog, binaryFormat, binary, length);
- if (result.error.isError())
- {
- mProgramBinary.set(NULL);
- return result.error;
- }
-
- mLinked = result.linkSuccess;
- return Error(GL_NO_ERROR);
-}
-
-void Program::release()
-{
- mRefCount--;
-
- if (mRefCount == 0 && mDeleteStatus)
- {
- mResourceManager->deleteProgram(mHandle);
- }
-}
-
-void Program::addRef()
-{
- mRefCount++;
-}
-
-unsigned int Program::getRefCount() const
-{
- return mRefCount;
-}
-
-GLint Program::getProgramBinaryLength() const
-{
- ProgramBinary *programBinary = mProgramBinary.get();
- if (programBinary)
- {
- return programBinary->getLength();
- }
- else
- {
- return 0;
- }
-}
-
-int Program::getInfoLogLength() const
-{
- return mInfoLog.getLength();
-}
-
-void Program::getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog)
-{
- return mInfoLog.getLog(bufSize, length, infoLog);
-}
-
-void Program::getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders)
-{
- int total = 0;
-
- if (mVertexShader)
- {
- if (total < maxCount)
- {
- shaders[total] = mVertexShader->getHandle();
- }
-
- total++;
- }
-
- if (mFragmentShader)
- {
- if (total < maxCount)
- {
- shaders[total] = mFragmentShader->getHandle();
- }
-
- total++;
- }
-
- if (count)
- {
- *count = total;
- }
-}
-
-void Program::getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
-{
- ProgramBinary *programBinary = getProgramBinary();
- if (programBinary)
- {
- programBinary->getActiveAttribute(index, bufsize, length, size, type, name);
- }
- else
- {
- if (bufsize > 0)
- {
- name[0] = '\0';
- }
-
- if (length)
- {
- *length = 0;
- }
-
- *type = GL_NONE;
- *size = 1;
- }
-}
-
-GLint Program::getActiveAttributeCount()
-{
- ProgramBinary *programBinary = getProgramBinary();
- if (programBinary)
- {
- return programBinary->getActiveAttributeCount();
- }
- else
- {
- return 0;
- }
-}
-
-GLint Program::getActiveAttributeMaxLength()
-{
- ProgramBinary *programBinary = getProgramBinary();
- if (programBinary)
- {
- return programBinary->getActiveAttributeMaxLength();
- }
- else
- {
- return 0;
- }
-}
-
-void Program::getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
-{
- ProgramBinary *programBinary = getProgramBinary();
- if (programBinary)
- {
- return programBinary->getActiveUniform(index, bufsize, length, size, type, name);
- }
- else
- {
- if (bufsize > 0)
- {
- name[0] = '\0';
- }
-
- if (length)
- {
- *length = 0;
- }
-
- *size = 0;
- *type = GL_NONE;
- }
-}
-
-GLint Program::getActiveUniformCount()
-{
- ProgramBinary *programBinary = getProgramBinary();
- if (programBinary)
- {
- return programBinary->getActiveUniformCount();
- }
- else
- {
- return 0;
- }
-}
-
-GLint Program::getActiveUniformMaxLength()
-{
- ProgramBinary *programBinary = getProgramBinary();
- if (programBinary)
- {
- return programBinary->getActiveUniformMaxLength();
- }
- else
- {
- return 0;
- }
-}
-
-void Program::flagForDeletion()
-{
- mDeleteStatus = true;
-}
-
-bool Program::isFlaggedForDeletion() const
-{
- return mDeleteStatus;
-}
-
-void Program::validate(const Caps &caps)
-{
- mInfoLog.reset();
-
- ProgramBinary *programBinary = getProgramBinary();
- if (isLinked() && programBinary)
- {
- programBinary->validate(mInfoLog, caps);
- }
- else
- {
- mInfoLog.append("Program has not been successfully linked.");
- }
-}
-
-bool Program::isValidated() const
-{
- ProgramBinary *programBinary = mProgramBinary.get();
- if (programBinary)
- {
- return programBinary->isValidated();
- }
- else
- {
- return false;
- }
-}
-
-GLint Program::getActiveUniformBlockCount()
-{
- ProgramBinary *programBinary = getProgramBinary();
- if (programBinary)
- {
- return static_cast<GLint>(programBinary->getActiveUniformBlockCount());
- }
- else
- {
- return 0;
- }
-}
-
-GLint Program::getActiveUniformBlockMaxLength()
-{
- ProgramBinary *programBinary = getProgramBinary();
- if (programBinary)
- {
- return static_cast<GLint>(programBinary->getActiveUniformBlockMaxLength());
- }
- else
- {
- return 0;
- }
-}
-
-void Program::bindUniformBlock(GLuint uniformBlockIndex, GLuint uniformBlockBinding)
-{
- mUniformBlockBindings[uniformBlockIndex] = uniformBlockBinding;
-}
-
-GLuint Program::getUniformBlockBinding(GLuint uniformBlockIndex) const
-{
- return mUniformBlockBindings[uniformBlockIndex];
-}
-
-void Program::resetUniformBlockBindings()
-{
- for (unsigned int blockId = 0; blockId < IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS; blockId++)
- {
- mUniformBlockBindings[blockId] = 0;
- }
-}
-
-void Program::setTransformFeedbackVaryings(GLsizei count, const GLchar *const *varyings, GLenum bufferMode)
-{
- mTransformFeedbackVaryings.resize(count);
- for (GLsizei i = 0; i < count; i++)
- {
- mTransformFeedbackVaryings[i] = varyings[i];
- }
-
- mTransformFeedbackBufferMode = bufferMode;
-}
-
-void Program::getTransformFeedbackVarying(GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name) const
-{
- ProgramBinary *programBinary = getProgramBinary();
- if (programBinary && index < programBinary->getTransformFeedbackVaryingCount())
- {
- const LinkedVarying &varying = programBinary->getTransformFeedbackVarying(index);
- GLsizei lastNameIdx = std::min(bufSize - 1, static_cast<GLsizei>(varying.name.length()));
- if (length)
- {
- *length = lastNameIdx;
- }
- if (size)
- {
- *size = varying.size;
- }
- if (type)
- {
- *type = varying.type;
- }
- if (name)
- {
- memcpy(name, varying.name.c_str(), lastNameIdx);
- name[lastNameIdx] = '\0';
- }
- }
-}
-
-GLsizei Program::getTransformFeedbackVaryingCount() const
-{
- ProgramBinary *programBinary = getProgramBinary();
- if (programBinary)
- {
- return static_cast<GLsizei>(programBinary->getTransformFeedbackVaryingCount());
- }
- else
- {
- return 0;
- }
-}
-
-GLsizei Program::getTransformFeedbackVaryingMaxLength() const
-{
- ProgramBinary *programBinary = getProgramBinary();
- if (programBinary)
- {
- GLsizei maxSize = 0;
- for (size_t i = 0; i < programBinary->getTransformFeedbackVaryingCount(); i++)
- {
- const LinkedVarying &varying = programBinary->getTransformFeedbackVarying(i);
- maxSize = std::max(maxSize, static_cast<GLsizei>(varying.name.length() + 1));
- }
-
- return maxSize;
- }
- else
- {
- return 0;
- }
-}
-
-GLenum Program::getTransformFeedbackBufferMode() const
-{
- ProgramBinary *programBinary = getProgramBinary();
- if (programBinary)
- {
- return programBinary->getTransformFeedbackBufferMode();
- }
- else
- {
- return mTransformFeedbackBufferMode;
- }
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/Program.h b/src/3rdparty/angle/src/libGLESv2/Program.h
deleted file mode 100644
index b92349eeef..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Program.h
+++ /dev/null
@@ -1,151 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// Program.h: Defines the gl::Program class. Implements GL program objects
-// and related functionality. [OpenGL ES 2.0.24] section 2.10.3 page 28.
-
-#ifndef LIBGLESV2_PROGRAM_H_
-#define LIBGLESV2_PROGRAM_H_
-
-#include "common/angleutils.h"
-#include "common/RefCountObject.h"
-#include "libGLESv2/Constants.h"
-#include "libGLESv2/ProgramBinary.h"
-
-#include <GLES2/gl2.h>
-
-#include <vector>
-#include <string>
-#include <set>
-
-namespace rx
-{
-class Renderer;
-}
-
-namespace gl
-{
-struct Caps;
-struct Data;
-class ResourceManager;
-class Shader;
-
-extern const char * const g_fakepath;
-
-class AttributeBindings
-{
- public:
- AttributeBindings();
- ~AttributeBindings();
-
- void bindAttributeLocation(GLuint index, const char *name);
- int getAttributeBinding(const std::string &name) const;
-
- private:
- std::set<std::string> mAttributeBinding[MAX_VERTEX_ATTRIBS];
-};
-
-class InfoLog
-{
- public:
- InfoLog();
- ~InfoLog();
-
- int getLength() const;
- void getLog(GLsizei bufSize, GLsizei *length, char *infoLog);
-
- void appendSanitized(const char *message);
- void append(const char *info, ...);
- void reset();
- private:
- DISALLOW_COPY_AND_ASSIGN(InfoLog);
- char *mInfoLog;
-};
-
-class Program
-{
- public:
- Program(rx::Renderer *renderer, ResourceManager *manager, GLuint handle);
-
- ~Program();
-
- bool attachShader(Shader *shader);
- bool detachShader(Shader *shader);
- int getAttachedShadersCount() const;
-
- void bindAttributeLocation(GLuint index, const char *name);
-
- Error link(const Data &data);
- bool isLinked();
- Error setProgramBinary(GLenum binaryFormat, const void *binary, GLsizei length);
- ProgramBinary *getProgramBinary() const;
-
- int getInfoLogLength() const;
- void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog);
- void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders);
-
- void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
- GLint getActiveAttributeCount();
- GLint getActiveAttributeMaxLength();
-
- void getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
- GLint getActiveUniformCount();
- GLint getActiveUniformMaxLength();
-
- GLint getActiveUniformBlockCount();
- GLint getActiveUniformBlockMaxLength();
-
- void bindUniformBlock(GLuint uniformBlockIndex, GLuint uniformBlockBinding);
- GLuint getUniformBlockBinding(GLuint uniformBlockIndex) const;
-
- void setTransformFeedbackVaryings(GLsizei count, const GLchar *const *varyings, GLenum bufferMode);
- void getTransformFeedbackVarying(GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name) const;
- GLsizei getTransformFeedbackVaryingCount() const;
- GLsizei getTransformFeedbackVaryingMaxLength() const;
- GLenum getTransformFeedbackBufferMode() const;
-
- void addRef();
- void release();
- unsigned int getRefCount() const;
- void flagForDeletion();
- bool isFlaggedForDeletion() const;
-
- void validate(const Caps &caps);
- bool isValidated() const;
-
- GLint getProgramBinaryLength() const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Program);
-
- void unlink(bool destroy = false);
- void resetUniformBlockBindings();
-
- Shader *mFragmentShader;
- Shader *mVertexShader;
-
- AttributeBindings mAttributeBindings;
-
- GLuint mUniformBlockBindings[IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS];
-
- std::vector<std::string> mTransformFeedbackVaryings;
- GLuint mTransformFeedbackBufferMode;
-
- BindingPointer<ProgramBinary> mProgramBinary;
- bool mLinked;
- bool mDeleteStatus; // Flag to indicate that the program can be deleted when no longer in use
-
- unsigned int mRefCount;
-
- ResourceManager *mResourceManager;
- rx::Renderer *mRenderer;
- const GLuint mHandle;
-
- InfoLog mInfoLog;
-};
-}
-
-#endif // LIBGLESV2_PROGRAM_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/ProgramBinary.cpp b/src/3rdparty/angle/src/libGLESv2/ProgramBinary.cpp
deleted file mode 100644
index 6d64b38b56..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/ProgramBinary.cpp
+++ /dev/null
@@ -1,1233 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// Program.cpp: Implements the gl::Program class. Implements GL program objects
-// and related functionality. [OpenGL ES 2.0.24] section 2.10.3 page 28.
-
-#include "libGLESv2/BinaryStream.h"
-#include "libGLESv2/ProgramBinary.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/FramebufferAttachment.h"
-#include "libGLESv2/Renderbuffer.h"
-#include "libGLESv2/renderer/ShaderExecutable.h"
-
-#include "common/debug.h"
-#include "common/version.h"
-#include "common/utilities.h"
-#include "common/platform.h"
-
-#include "libGLESv2/main.h"
-#include "libGLESv2/Shader.h"
-#include "libGLESv2/Program.h"
-#include "libGLESv2/renderer/ProgramImpl.h"
-#include "libGLESv2/renderer/d3d/ShaderD3D.h"
-#include "libGLESv2/Context.h"
-#include "libGLESv2/Buffer.h"
-#include "common/blocklayout.h"
-#include "common/features.h"
-
-namespace gl
-{
-
-namespace
-{
-
-unsigned int ParseAndStripArrayIndex(std::string* name)
-{
- unsigned int subscript = GL_INVALID_INDEX;
-
- // Strip any trailing array operator and retrieve the subscript
- size_t open = name->find_last_of('[');
- size_t close = name->find_last_of(']');
- if (open != std::string::npos && close == name->length() - 1)
- {
- subscript = atoi(name->substr(open + 1).c_str());
- name->erase(open);
- }
-
- return subscript;
-}
-
-}
-
-VariableLocation::VariableLocation(const std::string &name, unsigned int element, unsigned int index)
- : name(name), element(element), index(index)
-{
-}
-
-LinkedVarying::LinkedVarying()
-{
-}
-
-LinkedVarying::LinkedVarying(const std::string &name, GLenum type, GLsizei size, const std::string &semanticName,
- unsigned int semanticIndex, unsigned int semanticIndexCount)
- : name(name), type(type), size(size), semanticName(semanticName), semanticIndex(semanticIndex), semanticIndexCount(semanticIndexCount)
-{
-}
-
-LinkResult::LinkResult(bool linkSuccess, const Error &error)
- : linkSuccess(linkSuccess),
- error(error)
-{
-}
-
-unsigned int ProgramBinary::mCurrentSerial = 1;
-
-ProgramBinary::ProgramBinary(rx::ProgramImpl *impl)
- : RefCountObject(0),
- mProgram(impl),
- mValidated(false),
- mSerial(issueSerial())
-{
- ASSERT(impl);
-
- for (int index = 0; index < MAX_VERTEX_ATTRIBS; index++)
- {
- mSemanticIndex[index] = -1;
- }
-}
-
-ProgramBinary::~ProgramBinary()
-{
- reset();
- SafeDelete(mProgram);
-}
-
-unsigned int ProgramBinary::getSerial() const
-{
- return mSerial;
-}
-
-unsigned int ProgramBinary::issueSerial()
-{
- return mCurrentSerial++;
-}
-
-GLuint ProgramBinary::getAttributeLocation(const char *name)
-{
- if (name)
- {
- for (int index = 0; index < MAX_VERTEX_ATTRIBS; index++)
- {
- if (mLinkedAttribute[index].name == std::string(name))
- {
- return index;
- }
- }
- }
-
- return -1;
-}
-
-int ProgramBinary::getSemanticIndex(int attributeIndex)
-{
- ASSERT(attributeIndex >= 0 && attributeIndex < MAX_VERTEX_ATTRIBS);
-
- return mSemanticIndex[attributeIndex];
-}
-
-// Returns one more than the highest sampler index used.
-GLint ProgramBinary::getUsedSamplerRange(SamplerType type)
-{
- return mProgram->getUsedSamplerRange(type);
-}
-
-bool ProgramBinary::usesPointSize() const
-{
- return mProgram->usesPointSize();
-}
-
-GLint ProgramBinary::getSamplerMapping(SamplerType type, unsigned int samplerIndex, const Caps &caps)
-{
- return mProgram->getSamplerMapping(type, samplerIndex, caps);
-}
-
-GLenum ProgramBinary::getSamplerTextureType(SamplerType type, unsigned int samplerIndex)
-{
- return mProgram->getSamplerTextureType(type, samplerIndex);
-}
-
-GLint ProgramBinary::getUniformLocation(std::string name)
-{
- return mProgram->getUniformLocation(name);
-}
-
-GLuint ProgramBinary::getUniformIndex(std::string name)
-{
- return mProgram->getUniformIndex(name);
-}
-
-GLuint ProgramBinary::getUniformBlockIndex(std::string name)
-{
- return mProgram->getUniformBlockIndex(name);
-}
-
-UniformBlock *ProgramBinary::getUniformBlockByIndex(GLuint blockIndex)
-{
- return mProgram->getUniformBlockByIndex(blockIndex);
-}
-
-GLint ProgramBinary::getFragDataLocation(const char *name) const
-{
- std::string baseName(name);
- unsigned int arrayIndex;
- arrayIndex = ParseAndStripArrayIndex(&baseName);
-
- for (auto locationIt = mOutputVariables.begin(); locationIt != mOutputVariables.end(); locationIt++)
- {
- const VariableLocation &outputVariable = locationIt->second;
-
- if (outputVariable.name == baseName && (arrayIndex == GL_INVALID_INDEX || arrayIndex == outputVariable.element))
- {
- return static_cast<GLint>(locationIt->first);
- }
- }
-
- return -1;
-}
-
-size_t ProgramBinary::getTransformFeedbackVaryingCount() const
-{
- return mProgram->getTransformFeedbackLinkedVaryings().size();
-}
-
-const LinkedVarying &ProgramBinary::getTransformFeedbackVarying(size_t idx) const
-{
- return mProgram->getTransformFeedbackLinkedVaryings()[idx];
-}
-
-GLenum ProgramBinary::getTransformFeedbackBufferMode() const
-{
- return mProgram->getTransformFeedbackBufferMode();
-}
-
-void ProgramBinary::setUniform1fv(GLint location, GLsizei count, const GLfloat *v) {
- mProgram->setUniform1fv(location, count, v);
-}
-
-void ProgramBinary::setUniform2fv(GLint location, GLsizei count, const GLfloat *v) {
- mProgram->setUniform2fv(location, count, v);
-}
-
-void ProgramBinary::setUniform3fv(GLint location, GLsizei count, const GLfloat *v) {
- mProgram->setUniform3fv(location, count, v);
-}
-
-void ProgramBinary::setUniform4fv(GLint location, GLsizei count, const GLfloat *v) {
- mProgram->setUniform4fv(location, count, v);
-}
-
-void ProgramBinary::setUniform1iv(GLint location, GLsizei count, const GLint *v) {
- mProgram->setUniform1iv(location, count, v);
-}
-
-void ProgramBinary::setUniform2iv(GLint location, GLsizei count, const GLint *v) {
- mProgram->setUniform2iv(location, count, v);
-}
-
-void ProgramBinary::setUniform3iv(GLint location, GLsizei count, const GLint *v) {
- mProgram->setUniform3iv(location, count, v);
-}
-
-void ProgramBinary::setUniform4iv(GLint location, GLsizei count, const GLint *v) {
- mProgram->setUniform4iv(location, count, v);
-}
-
-void ProgramBinary::setUniform1uiv(GLint location, GLsizei count, const GLuint *v) {
- mProgram->setUniform1uiv(location, count, v);
-}
-
-void ProgramBinary::setUniform2uiv(GLint location, GLsizei count, const GLuint *v) {
- mProgram->setUniform2uiv(location, count, v);
-}
-
-void ProgramBinary::setUniform3uiv(GLint location, GLsizei count, const GLuint *v) {
- mProgram->setUniform3uiv(location, count, v);
-}
-
-void ProgramBinary::setUniform4uiv(GLint location, GLsizei count, const GLuint *v) {
- mProgram->setUniform4uiv(location, count, v);
-}
-
-void ProgramBinary::setUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) {
- mProgram->setUniformMatrix2fv(location, count, transpose, v);
-}
-
-void ProgramBinary::setUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) {
- mProgram->setUniformMatrix3fv(location, count, transpose, v);
-}
-
-void ProgramBinary::setUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) {
- mProgram->setUniformMatrix4fv(location, count, transpose, v);
-}
-
-void ProgramBinary::setUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) {
- mProgram->setUniformMatrix2x3fv(location, count, transpose, v);
-}
-
-void ProgramBinary::setUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) {
- mProgram->setUniformMatrix2x4fv(location, count, transpose, v);
-}
-
-void ProgramBinary::setUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) {
- mProgram->setUniformMatrix3x2fv(location, count, transpose, v);
-}
-
-void ProgramBinary::setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) {
- mProgram->setUniformMatrix3x4fv(location, count, transpose, v);
-}
-
-void ProgramBinary::setUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) {
- mProgram->setUniformMatrix4x2fv(location, count, transpose, v);
-}
-
-void ProgramBinary::setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *v) {
- mProgram->setUniformMatrix4x3fv(location, count, transpose, v);
-}
-
-void ProgramBinary::getUniformfv(GLint location, GLfloat *v) {
- mProgram->getUniformfv(location, v);
-}
-
-void ProgramBinary::getUniformiv(GLint location, GLint *v) {
- mProgram->getUniformiv(location, v);
-}
-
-void ProgramBinary::getUniformuiv(GLint location, GLuint *v) {
- mProgram->getUniformuiv(location, v);
-}
-
-void ProgramBinary::updateSamplerMapping()
-{
- return mProgram->updateSamplerMapping();
-}
-
-// Applies all the uniforms set for this program object to the renderer
-Error ProgramBinary::applyUniforms()
-{
- return mProgram->applyUniforms();
-}
-
-Error ProgramBinary::applyUniformBuffers(const std::vector<gl::Buffer*> boundBuffers, const Caps &caps)
-{
- return mProgram->applyUniformBuffers(boundBuffers, caps);
-}
-
-bool ProgramBinary::linkVaryings(InfoLog &infoLog, Shader *fragmentShader, Shader *vertexShader)
-{
- std::vector<PackedVarying> &fragmentVaryings = fragmentShader->getVaryings();
- std::vector<PackedVarying> &vertexVaryings = vertexShader->getVaryings();
-
- for (size_t fragVaryingIndex = 0; fragVaryingIndex < fragmentVaryings.size(); fragVaryingIndex++)
- {
- PackedVarying *input = &fragmentVaryings[fragVaryingIndex];
- bool matched = false;
-
- // Built-in varyings obey special rules
- if (input->isBuiltIn())
- {
- continue;
- }
-
- for (size_t vertVaryingIndex = 0; vertVaryingIndex < vertexVaryings.size(); vertVaryingIndex++)
- {
- PackedVarying *output = &vertexVaryings[vertVaryingIndex];
- if (output->name == input->name)
- {
- if (!linkValidateVaryings(infoLog, output->name, *input, *output))
- {
- return false;
- }
-
- output->registerIndex = input->registerIndex;
- output->columnIndex = input->columnIndex;
-
- matched = true;
- break;
- }
- }
-
- // We permit unmatched, unreferenced varyings
- if (!matched && input->staticUse)
- {
- infoLog.append("Fragment varying %s does not match any vertex varying", input->name.c_str());
- return false;
- }
- }
-
- return true;
-}
-
-LinkResult ProgramBinary::load(InfoLog &infoLog, GLenum binaryFormat, const void *binary, GLsizei length)
-{
-#if ANGLE_PROGRAM_BINARY_LOAD == ANGLE_DISABLED
- return LinkResult(false, Error(GL_NO_ERROR));
-#else
- ASSERT(binaryFormat == mProgram->getBinaryFormat());
-
- reset();
-
- BinaryInputStream stream(binary, length);
-
- GLenum format = stream.readInt<GLenum>();
- if (format != mProgram->getBinaryFormat())
- {
- infoLog.append("Invalid program binary format.");
- return LinkResult(false, Error(GL_NO_ERROR));
- }
-
- int majorVersion = stream.readInt<int>();
- int minorVersion = stream.readInt<int>();
- if (majorVersion != ANGLE_MAJOR_VERSION || minorVersion != ANGLE_MINOR_VERSION)
- {
- infoLog.append("Invalid program binary version.");
- return LinkResult(false, Error(GL_NO_ERROR));
- }
-
- unsigned char commitString[ANGLE_COMMIT_HASH_SIZE];
- stream.readBytes(commitString, ANGLE_COMMIT_HASH_SIZE);
- if (memcmp(commitString, ANGLE_COMMIT_HASH, sizeof(unsigned char) * ANGLE_COMMIT_HASH_SIZE) != 0)
- {
- infoLog.append("Invalid program binary version.");
- return LinkResult(false, Error(GL_NO_ERROR));
- }
-
- int compileFlags = stream.readInt<int>();
- if (compileFlags != ANGLE_COMPILE_OPTIMIZATION_LEVEL)
- {
- infoLog.append("Mismatched compilation flags.");
- return LinkResult(false, Error(GL_NO_ERROR));
- }
-
- for (int i = 0; i < MAX_VERTEX_ATTRIBS; ++i)
- {
- stream.readInt(&mLinkedAttribute[i].type);
- stream.readString(&mLinkedAttribute[i].name);
- stream.readInt(&mProgram->getShaderAttributes()[i].type);
- stream.readString(&mProgram->getShaderAttributes()[i].name);
- stream.readInt(&mSemanticIndex[i]);
- }
-
- initAttributesByLayout();
-
- LinkResult result = mProgram->load(infoLog, &stream);
- if (result.error.isError() || !result.linkSuccess)
- {
- return result;
- }
-
- return LinkResult(true, Error(GL_NO_ERROR));
-#endif // #if ANGLE_PROGRAM_BINARY_LOAD == ANGLE_ENABLED
-}
-
-Error ProgramBinary::save(GLenum *binaryFormat, void *binary, GLsizei bufSize, GLsizei *length)
-{
- if (binaryFormat)
- {
- *binaryFormat = mProgram->getBinaryFormat();
- }
-
- BinaryOutputStream stream;
-
- stream.writeInt(mProgram->getBinaryFormat());
- stream.writeInt(ANGLE_MAJOR_VERSION);
- stream.writeInt(ANGLE_MINOR_VERSION);
- stream.writeBytes(reinterpret_cast<const unsigned char*>(ANGLE_COMMIT_HASH), ANGLE_COMMIT_HASH_SIZE);
- stream.writeInt(ANGLE_COMPILE_OPTIMIZATION_LEVEL);
-
- for (unsigned int i = 0; i < MAX_VERTEX_ATTRIBS; ++i)
- {
- stream.writeInt(mLinkedAttribute[i].type);
- stream.writeString(mLinkedAttribute[i].name);
- stream.writeInt(mProgram->getShaderAttributes()[i].type);
- stream.writeString(mProgram->getShaderAttributes()[i].name);
- stream.writeInt(mSemanticIndex[i]);
- }
-
- mProgram->save(&stream);
-
- GLsizei streamLength = stream.length();
- const void *streamData = stream.data();
-
- if (streamLength > bufSize)
- {
- if (length)
- {
- *length = 0;
- }
-
- // TODO: This should be moved to the validation layer but computing the size of the binary before saving
- // it causes the save to happen twice. It may be possible to write the binary to a separate buffer, validate
- // sizes and then copy it.
- return Error(GL_INVALID_OPERATION);
- }
-
- if (binary)
- {
- char *ptr = (char*) binary;
-
- memcpy(ptr, streamData, streamLength);
- ptr += streamLength;
-
- ASSERT(ptr - streamLength == binary);
- }
-
- if (length)
- {
- *length = streamLength;
- }
-
- return Error(GL_NO_ERROR);
-}
-
-GLint ProgramBinary::getLength()
-{
- GLint length;
- Error error = save(NULL, NULL, INT_MAX, &length);
- if (error.isError())
- {
- return 0;
- }
-
- return length;
-}
-
-LinkResult ProgramBinary::link(const Data &data, InfoLog &infoLog, const AttributeBindings &attributeBindings,
- Shader *fragmentShader, Shader *vertexShader,
- const std::vector<std::string> &transformFeedbackVaryings,
- GLenum transformFeedbackBufferMode)
-{
- if (!fragmentShader || !fragmentShader->isCompiled())
- {
- return LinkResult(false, Error(GL_NO_ERROR));
- }
- ASSERT(fragmentShader->getType() == GL_FRAGMENT_SHADER);
-
- if (!vertexShader || !vertexShader->isCompiled())
- {
- return LinkResult(false, Error(GL_NO_ERROR));
- }
- ASSERT(vertexShader->getType() == GL_VERTEX_SHADER);
-
- reset();
-
- int registers;
- std::vector<LinkedVarying> linkedVaryings;
- LinkResult result = mProgram->link(data, infoLog, fragmentShader, vertexShader, transformFeedbackVaryings, transformFeedbackBufferMode,
- &registers, &linkedVaryings, &mOutputVariables);
- if (result.error.isError() || !result.linkSuccess)
- {
- return result;
- }
-
- if (!linkAttributes(infoLog, attributeBindings, vertexShader))
- {
- return LinkResult(false, Error(GL_NO_ERROR));
- }
-
- if (!mProgram->linkUniforms(infoLog, *vertexShader, *fragmentShader, *data.caps))
- {
- return LinkResult(false, Error(GL_NO_ERROR));
- }
-
- if (!linkUniformBlocks(infoLog, *vertexShader, *fragmentShader, *data.caps))
- {
- return LinkResult(false, Error(GL_NO_ERROR));
- }
-
- if (!gatherTransformFeedbackLinkedVaryings(infoLog, linkedVaryings, transformFeedbackVaryings,
- transformFeedbackBufferMode, &mProgram->getTransformFeedbackLinkedVaryings(), *data.caps))
- {
- return LinkResult(false, Error(GL_NO_ERROR));
- }
-
- // TODO: The concept of "executables" is D3D only, and as such this belongs in ProgramD3D. It must be called,
- // however, last in this function, so it can't simply be moved to ProgramD3D::link without further shuffling.
- result = mProgram->compileProgramExecutables(infoLog, fragmentShader, vertexShader, registers);
- if (result.error.isError() || !result.linkSuccess)
- {
- infoLog.append("Failed to create D3D shaders.");
- reset();
- return result;
- }
-
- return LinkResult(true, Error(GL_NO_ERROR));
-}
-
-bool ProgramBinary::linkUniformBlocks(gl::InfoLog &infoLog, const gl::Shader &vertexShader, const gl::Shader &fragmentShader,
- const gl::Caps &caps)
-{
- const std::vector<sh::InterfaceBlock> &vertexInterfaceBlocks = vertexShader.getInterfaceBlocks();
- const std::vector<sh::InterfaceBlock> &fragmentInterfaceBlocks = fragmentShader.getInterfaceBlocks();
-
- // Check that interface blocks defined in the vertex and fragment shaders are identical
- typedef std::map<std::string, const sh::InterfaceBlock*> UniformBlockMap;
- UniformBlockMap linkedUniformBlocks;
-
- for (unsigned int blockIndex = 0; blockIndex < vertexInterfaceBlocks.size(); blockIndex++)
- {
- const sh::InterfaceBlock &vertexInterfaceBlock = vertexInterfaceBlocks[blockIndex];
- linkedUniformBlocks[vertexInterfaceBlock.name] = &vertexInterfaceBlock;
- }
-
- for (unsigned int blockIndex = 0; blockIndex < fragmentInterfaceBlocks.size(); blockIndex++)
- {
- const sh::InterfaceBlock &fragmentInterfaceBlock = fragmentInterfaceBlocks[blockIndex];
- UniformBlockMap::const_iterator entry = linkedUniformBlocks.find(fragmentInterfaceBlock.name);
- if (entry != linkedUniformBlocks.end())
- {
- const sh::InterfaceBlock &vertexInterfaceBlock = *entry->second;
- if (!areMatchingInterfaceBlocks(infoLog, vertexInterfaceBlock, fragmentInterfaceBlock))
- {
- return false;
- }
- }
- }
-
- for (unsigned int blockIndex = 0; blockIndex < vertexInterfaceBlocks.size(); blockIndex++)
- {
- const sh::InterfaceBlock &interfaceBlock = vertexInterfaceBlocks[blockIndex];
-
- // Note: shared and std140 layouts are always considered active
- if (interfaceBlock.staticUse || interfaceBlock.layout != sh::BLOCKLAYOUT_PACKED)
- {
- if (!mProgram->defineUniformBlock(infoLog, vertexShader, interfaceBlock, caps))
- {
- return false;
- }
- }
- }
-
- for (unsigned int blockIndex = 0; blockIndex < fragmentInterfaceBlocks.size(); blockIndex++)
- {
- const sh::InterfaceBlock &interfaceBlock = fragmentInterfaceBlocks[blockIndex];
-
- // Note: shared and std140 layouts are always considered active
- if (interfaceBlock.staticUse || interfaceBlock.layout != sh::BLOCKLAYOUT_PACKED)
- {
- if (!mProgram->defineUniformBlock(infoLog, fragmentShader, interfaceBlock, caps))
- {
- return false;
- }
- }
- }
-
- return true;
-}
-
-bool ProgramBinary::areMatchingInterfaceBlocks(gl::InfoLog &infoLog, const sh::InterfaceBlock &vertexInterfaceBlock,
- const sh::InterfaceBlock &fragmentInterfaceBlock)
-{
- const char* blockName = vertexInterfaceBlock.name.c_str();
-
- // validate blocks for the same member types
- if (vertexInterfaceBlock.fields.size() != fragmentInterfaceBlock.fields.size())
- {
- infoLog.append("Types for interface block '%s' differ between vertex and fragment shaders", blockName);
- return false;
- }
-
- if (vertexInterfaceBlock.arraySize != fragmentInterfaceBlock.arraySize)
- {
- infoLog.append("Array sizes differ for interface block '%s' between vertex and fragment shaders", blockName);
- return false;
- }
-
- if (vertexInterfaceBlock.layout != fragmentInterfaceBlock.layout || vertexInterfaceBlock.isRowMajorLayout != fragmentInterfaceBlock.isRowMajorLayout)
- {
- infoLog.append("Layout qualifiers differ for interface block '%s' between vertex and fragment shaders", blockName);
- return false;
- }
-
- const unsigned int numBlockMembers = vertexInterfaceBlock.fields.size();
- for (unsigned int blockMemberIndex = 0; blockMemberIndex < numBlockMembers; blockMemberIndex++)
- {
- const sh::InterfaceBlockField &vertexMember = vertexInterfaceBlock.fields[blockMemberIndex];
- const sh::InterfaceBlockField &fragmentMember = fragmentInterfaceBlock.fields[blockMemberIndex];
-
- if (vertexMember.name != fragmentMember.name)
- {
- infoLog.append("Name mismatch for field %d of interface block '%s': (in vertex: '%s', in fragment: '%s')",
- blockMemberIndex, blockName, vertexMember.name.c_str(), fragmentMember.name.c_str());
- return false;
- }
-
- std::string memberName = "interface block '" + vertexInterfaceBlock.name + "' member '" + vertexMember.name + "'";
- if (!gl::ProgramBinary::linkValidateInterfaceBlockFields(infoLog, memberName, vertexMember, fragmentMember))
- {
- return false;
- }
- }
-
- return true;
-}
-
-// Determines the mapping between GL attributes and Direct3D 9 vertex stream usage indices
-bool ProgramBinary::linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, const Shader *vertexShader)
-{
- const rx::ShaderD3D *vertexShaderD3D = rx::ShaderD3D::makeShaderD3D(vertexShader->getImplementation());
-
- unsigned int usedLocations = 0;
- const std::vector<sh::Attribute> &shaderAttributes = vertexShader->getActiveAttributes();
-
- // Link attributes that have a binding location
- for (unsigned int attributeIndex = 0; attributeIndex < shaderAttributes.size(); attributeIndex++)
- {
- const sh::Attribute &attribute = shaderAttributes[attributeIndex];
-
- ASSERT(attribute.staticUse);
-
- const int location = attribute.location == -1 ? attributeBindings.getAttributeBinding(attribute.name) : attribute.location;
-
- mProgram->getShaderAttributes()[attributeIndex] = attribute;
-
- if (location != -1) // Set by glBindAttribLocation or by location layout qualifier
- {
- const int rows = VariableRegisterCount(attribute.type);
-
- if (rows + location > MAX_VERTEX_ATTRIBS)
- {
- infoLog.append("Active attribute (%s) at location %d is too big to fit", attribute.name.c_str(), location);
-
- return false;
- }
-
- for (int row = 0; row < rows; row++)
- {
- const int rowLocation = location + row;
- sh::ShaderVariable &linkedAttribute = mLinkedAttribute[rowLocation];
-
- // In GLSL 3.00, attribute aliasing produces a link error
- // In GLSL 1.00, attribute aliasing is allowed
- if (mProgram->getShaderVersion() >= 300)
- {
- if (!linkedAttribute.name.empty())
- {
- infoLog.append("Attribute '%s' aliases attribute '%s' at location %d", attribute.name.c_str(), linkedAttribute.name.c_str(), rowLocation);
- return false;
- }
- }
-
- linkedAttribute = attribute;
- usedLocations |= 1 << rowLocation;
- }
- }
- }
-
- // Link attributes that don't have a binding location
- for (unsigned int attributeIndex = 0; attributeIndex < shaderAttributes.size(); attributeIndex++)
- {
- const sh::Attribute &attribute = shaderAttributes[attributeIndex];
-
- ASSERT(attribute.staticUse);
-
- const int location = attribute.location == -1 ? attributeBindings.getAttributeBinding(attribute.name) : attribute.location;
-
- if (location == -1) // Not set by glBindAttribLocation or by location layout qualifier
- {
- int rows = VariableRegisterCount(attribute.type);
- int availableIndex = AllocateFirstFreeBits(&usedLocations, rows, MAX_VERTEX_ATTRIBS);
-
- if (availableIndex == -1 || availableIndex + rows > MAX_VERTEX_ATTRIBS)
- {
- infoLog.append("Too many active attributes (%s)", attribute.name.c_str());
-
- return false; // Fail to link
- }
-
- mLinkedAttribute[availableIndex] = attribute;
- }
- }
-
- for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; )
- {
- int index = vertexShaderD3D->getSemanticIndex(mLinkedAttribute[attributeIndex].name);
- int rows = VariableRegisterCount(mLinkedAttribute[attributeIndex].type);
-
- for (int r = 0; r < rows; r++)
- {
- mSemanticIndex[attributeIndex++] = index++;
- }
- }
-
- initAttributesByLayout();
-
- return true;
-}
-
-bool ProgramBinary::linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const sh::ShaderVariable &vertexVariable,
- const sh::ShaderVariable &fragmentVariable, bool validatePrecision)
-{
- if (vertexVariable.type != fragmentVariable.type)
- {
- infoLog.append("Types for %s differ between vertex and fragment shaders", variableName.c_str());
- return false;
- }
- if (vertexVariable.arraySize != fragmentVariable.arraySize)
- {
- infoLog.append("Array sizes for %s differ between vertex and fragment shaders", variableName.c_str());
- return false;
- }
- if (validatePrecision && vertexVariable.precision != fragmentVariable.precision)
- {
- infoLog.append("Precisions for %s differ between vertex and fragment shaders", variableName.c_str());
- return false;
- }
-
- if (vertexVariable.fields.size() != fragmentVariable.fields.size())
- {
- infoLog.append("Structure lengths for %s differ between vertex and fragment shaders", variableName.c_str());
- return false;
- }
- const unsigned int numMembers = vertexVariable.fields.size();
- for (unsigned int memberIndex = 0; memberIndex < numMembers; memberIndex++)
- {
- const sh::ShaderVariable &vertexMember = vertexVariable.fields[memberIndex];
- const sh::ShaderVariable &fragmentMember = fragmentVariable.fields[memberIndex];
-
- if (vertexMember.name != fragmentMember.name)
- {
- infoLog.append("Name mismatch for field '%d' of %s: (in vertex: '%s', in fragment: '%s')",
- memberIndex, variableName.c_str(),
- vertexMember.name.c_str(), fragmentMember.name.c_str());
- return false;
- }
-
- const std::string memberName = variableName.substr(0, variableName.length() - 1) + "." +
- vertexMember.name + "'";
-
- if (!linkValidateVariablesBase(infoLog, vertexMember.name, vertexMember, fragmentMember, validatePrecision))
- {
- return false;
- }
- }
-
- return true;
-}
-
-bool ProgramBinary::linkValidateUniforms(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform)
-{
- if (!linkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform, true))
- {
- return false;
- }
-
- return true;
-}
-
-bool ProgramBinary::linkValidateVaryings(InfoLog &infoLog, const std::string &varyingName, const sh::Varying &vertexVarying, const sh::Varying &fragmentVarying)
-{
- if (!linkValidateVariablesBase(infoLog, varyingName, vertexVarying, fragmentVarying, false))
- {
- return false;
- }
-
- if (vertexVarying.interpolation != fragmentVarying.interpolation)
- {
- infoLog.append("Interpolation types for %s differ between vertex and fragment shaders", varyingName.c_str());
- return false;
- }
-
- return true;
-}
-
-bool ProgramBinary::linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform)
-{
- if (!linkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform, true))
- {
- return false;
- }
-
- if (vertexUniform.isRowMajorLayout != fragmentUniform.isRowMajorLayout)
- {
- infoLog.append("Matrix packings for %s differ between vertex and fragment shaders", uniformName.c_str());
- return false;
- }
-
- return true;
-}
-
-bool ProgramBinary::gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, const std::vector<LinkedVarying> &linkedVaryings,
- const std::vector<std::string> &transformFeedbackVaryingNames,
- GLenum transformFeedbackBufferMode,
- std::vector<LinkedVarying> *outTransformFeedbackLinkedVaryings,
- const Caps &caps) const
-{
- size_t totalComponents = 0;
-
- // Gather the linked varyings that are used for transform feedback, they should all exist.
- outTransformFeedbackLinkedVaryings->clear();
- for (size_t i = 0; i < transformFeedbackVaryingNames.size(); i++)
- {
- bool found = false;
- for (size_t j = 0; j < linkedVaryings.size(); j++)
- {
- if (transformFeedbackVaryingNames[i] == linkedVaryings[j].name)
- {
- for (size_t k = 0; k < outTransformFeedbackLinkedVaryings->size(); k++)
- {
- if (outTransformFeedbackLinkedVaryings->at(k).name == linkedVaryings[j].name)
- {
- infoLog.append("Two transform feedback varyings specify the same output variable (%s).", linkedVaryings[j].name.c_str());
- return false;
- }
- }
-
- size_t componentCount = linkedVaryings[j].semanticIndexCount * 4;
- if (transformFeedbackBufferMode == GL_SEPARATE_ATTRIBS &&
- componentCount > caps.maxTransformFeedbackSeparateComponents)
- {
- infoLog.append("Transform feedback varying's %s components (%u) exceed the maximum separate components (%u).",
- linkedVaryings[j].name.c_str(), componentCount, caps.maxTransformFeedbackSeparateComponents);
- return false;
- }
-
- totalComponents += componentCount;
-
- outTransformFeedbackLinkedVaryings->push_back(linkedVaryings[j]);
- found = true;
- break;
- }
- }
-
- // All transform feedback varyings are expected to exist since packVaryings checks for them.
- ASSERT(found);
- }
-
- if (transformFeedbackBufferMode == GL_INTERLEAVED_ATTRIBS && totalComponents > caps.maxTransformFeedbackInterleavedComponents)
- {
- infoLog.append("Transform feedback varying total components (%u) exceed the maximum interleaved components (%u).",
- totalComponents, caps.maxTransformFeedbackInterleavedComponents);
- return false;
- }
-
- return true;
-}
-
-bool ProgramBinary::isValidated() const
-{
- return mValidated;
-}
-
-void ProgramBinary::getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const
-{
- // Skip over inactive attributes
- unsigned int activeAttribute = 0;
- unsigned int attribute;
- for (attribute = 0; attribute < MAX_VERTEX_ATTRIBS; attribute++)
- {
- if (mLinkedAttribute[attribute].name.empty())
- {
- continue;
- }
-
- if (activeAttribute == index)
- {
- break;
- }
-
- activeAttribute++;
- }
-
- if (bufsize > 0)
- {
- const char *string = mLinkedAttribute[attribute].name.c_str();
-
- strncpy(name, string, bufsize);
- name[bufsize - 1] = '\0';
-
- if (length)
- {
- *length = strlen(name);
- }
- }
-
- *size = 1; // Always a single 'type' instance
-
- *type = mLinkedAttribute[attribute].type;
-}
-
-GLint ProgramBinary::getActiveAttributeCount() const
-{
- int count = 0;
-
- for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
- {
- if (!mLinkedAttribute[attributeIndex].name.empty())
- {
- count++;
- }
- }
-
- return count;
-}
-
-GLint ProgramBinary::getActiveAttributeMaxLength() const
-{
- int maxLength = 0;
-
- for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
- {
- if (!mLinkedAttribute[attributeIndex].name.empty())
- {
- maxLength = std::max((int)(mLinkedAttribute[attributeIndex].name.length() + 1), maxLength);
- }
- }
-
- return maxLength;
-}
-
-void ProgramBinary::getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const
-{
- ASSERT(index < mProgram->getUniforms().size()); // index must be smaller than getActiveUniformCount()
-
- if (bufsize > 0)
- {
- std::string string = mProgram->getUniforms()[index]->name;
-
- if (mProgram->getUniforms()[index]->isArray())
- {
- string += "[0]";
- }
-
- strncpy(name, string.c_str(), bufsize);
- name[bufsize - 1] = '\0';
-
- if (length)
- {
- *length = strlen(name);
- }
- }
-
- *size = mProgram->getUniforms()[index]->elementCount();
-
- *type = mProgram->getUniforms()[index]->type;
-}
-
-GLint ProgramBinary::getActiveUniformCount() const
-{
- return mProgram->getUniforms().size();
-}
-
-GLint ProgramBinary::getActiveUniformMaxLength() const
-{
- int maxLength = 0;
-
- unsigned int numUniforms = mProgram->getUniforms().size();
- for (unsigned int uniformIndex = 0; uniformIndex < numUniforms; uniformIndex++)
- {
- if (!mProgram->getUniforms()[uniformIndex]->name.empty())
- {
- int length = (int)(mProgram->getUniforms()[uniformIndex]->name.length() + 1);
- if (mProgram->getUniforms()[uniformIndex]->isArray())
- {
- length += 3; // Counting in "[0]".
- }
- maxLength = std::max(length, maxLength);
- }
- }
-
- return maxLength;
-}
-
-GLint ProgramBinary::getActiveUniformi(GLuint index, GLenum pname) const
-{
- const gl::LinkedUniform& uniform = *mProgram->getUniforms()[index];
-
- switch (pname)
- {
- case GL_UNIFORM_TYPE: return static_cast<GLint>(uniform.type);
- case GL_UNIFORM_SIZE: return static_cast<GLint>(uniform.elementCount());
- case GL_UNIFORM_NAME_LENGTH: return static_cast<GLint>(uniform.name.size() + 1 + (uniform.isArray() ? 3 : 0));
- case GL_UNIFORM_BLOCK_INDEX: return uniform.blockIndex;
-
- case GL_UNIFORM_OFFSET: return uniform.blockInfo.offset;
- case GL_UNIFORM_ARRAY_STRIDE: return uniform.blockInfo.arrayStride;
- case GL_UNIFORM_MATRIX_STRIDE: return uniform.blockInfo.matrixStride;
- case GL_UNIFORM_IS_ROW_MAJOR: return static_cast<GLint>(uniform.blockInfo.isRowMajorMatrix);
-
- default:
- UNREACHABLE();
- break;
- }
- return 0;
-}
-
-bool ProgramBinary::isValidUniformLocation(GLint location) const
-{
- ASSERT(rx::IsIntegerCastSafe<GLint>(mProgram->getUniformIndices().size()));
- return (location >= 0 && location < static_cast<GLint>(mProgram->getUniformIndices().size()));
-}
-
-LinkedUniform *ProgramBinary::getUniformByLocation(GLint location) const
-{
- return mProgram->getUniformByLocation(location);
-}
-
-LinkedUniform *ProgramBinary::getUniformByName(const std::string &name) const
-{
- return mProgram->getUniformByName(name);
-}
-
-void ProgramBinary::getActiveUniformBlockName(GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName) const
-{
- ASSERT(uniformBlockIndex < mProgram->getUniformBlocks().size()); // index must be smaller than getActiveUniformBlockCount()
-
- const UniformBlock &uniformBlock = *mProgram->getUniformBlocks()[uniformBlockIndex];
-
- if (bufSize > 0)
- {
- std::string string = uniformBlock.name;
-
- if (uniformBlock.isArrayElement())
- {
- string += ArrayString(uniformBlock.elementIndex);
- }
-
- strncpy(uniformBlockName, string.c_str(), bufSize);
- uniformBlockName[bufSize - 1] = '\0';
-
- if (length)
- {
- *length = strlen(uniformBlockName);
- }
- }
-}
-
-void ProgramBinary::getActiveUniformBlockiv(GLuint uniformBlockIndex, GLenum pname, GLint *params) const
-{
- ASSERT(uniformBlockIndex < mProgram->getUniformBlocks().size()); // index must be smaller than getActiveUniformBlockCount()
-
- const UniformBlock &uniformBlock = *mProgram->getUniformBlocks()[uniformBlockIndex];
-
- switch (pname)
- {
- case GL_UNIFORM_BLOCK_DATA_SIZE:
- *params = static_cast<GLint>(uniformBlock.dataSize);
- break;
- case GL_UNIFORM_BLOCK_NAME_LENGTH:
- *params = static_cast<GLint>(uniformBlock.name.size() + 1 + (uniformBlock.isArrayElement() ? 3 : 0));
- break;
- case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
- *params = static_cast<GLint>(uniformBlock.memberUniformIndexes.size());
- break;
- case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
- {
- for (unsigned int blockMemberIndex = 0; blockMemberIndex < uniformBlock.memberUniformIndexes.size(); blockMemberIndex++)
- {
- params[blockMemberIndex] = static_cast<GLint>(uniformBlock.memberUniformIndexes[blockMemberIndex]);
- }
- }
- break;
- case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
- *params = static_cast<GLint>(uniformBlock.isReferencedByVertexShader());
- break;
- case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
- *params = static_cast<GLint>(uniformBlock.isReferencedByFragmentShader());
- break;
- default: UNREACHABLE();
- }
-}
-
-GLuint ProgramBinary::getActiveUniformBlockCount() const
-{
- return mProgram->getUniformBlocks().size();
-}
-
-GLuint ProgramBinary::getActiveUniformBlockMaxLength() const
-{
- unsigned int maxLength = 0;
-
- unsigned int numUniformBlocks = mProgram->getUniformBlocks().size();
- for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < numUniformBlocks; uniformBlockIndex++)
- {
- const UniformBlock &uniformBlock = *mProgram->getUniformBlocks()[uniformBlockIndex];
- if (!uniformBlock.name.empty())
- {
- const unsigned int length = uniformBlock.name.length() + 1;
-
- // Counting in "[0]".
- const unsigned int arrayLength = (uniformBlock.isArrayElement() ? 3 : 0);
-
- maxLength = std::max(length + arrayLength, maxLength);
- }
- }
-
- return maxLength;
-}
-
-void ProgramBinary::validate(InfoLog &infoLog, const Caps &caps)
-{
- applyUniforms();
- if (!validateSamplers(&infoLog, caps))
- {
- mValidated = false;
- }
- else
- {
- mValidated = true;
- }
-}
-
-bool ProgramBinary::validateSamplers(InfoLog *infoLog, const Caps &caps)
-{
- return mProgram->validateSamplers(infoLog, caps);
-}
-
-struct AttributeSorter
-{
- AttributeSorter(const int (&semanticIndices)[MAX_VERTEX_ATTRIBS])
- : originalIndices(semanticIndices)
- {
- }
-
- bool operator()(int a, int b)
- {
- if (originalIndices[a] == -1) return false;
- if (originalIndices[b] == -1) return true;
- return (originalIndices[a] < originalIndices[b]);
- }
-
- const int (&originalIndices)[MAX_VERTEX_ATTRIBS];
-};
-
-void ProgramBinary::initAttributesByLayout()
-{
- for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
- {
- mAttributesByLayout[i] = i;
- }
-
- std::sort(&mAttributesByLayout[0], &mAttributesByLayout[MAX_VERTEX_ATTRIBS], AttributeSorter(mSemanticIndex));
-}
-
-void ProgramBinary::sortAttributesByLayout(rx::TranslatedAttribute attributes[MAX_VERTEX_ATTRIBS], int sortedSemanticIndices[MAX_VERTEX_ATTRIBS]) const
-{
- rx::TranslatedAttribute oldTranslatedAttributes[MAX_VERTEX_ATTRIBS];
-
- for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
- {
- oldTranslatedAttributes[i] = attributes[i];
- }
-
- for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
- {
- int oldIndex = mAttributesByLayout[i];
- sortedSemanticIndices[i] = oldIndex;
- attributes[i] = oldTranslatedAttributes[oldIndex];
- }
-}
-
-void ProgramBinary::reset()
-{
- mOutputVariables.clear();
-
- mProgram->reset();
-
- mValidated = false;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/ProgramBinary.h b/src/3rdparty/angle/src/libGLESv2/ProgramBinary.h
deleted file mode 100644
index 3142d66c6d..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/ProgramBinary.h
+++ /dev/null
@@ -1,237 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// Program.h: Defines the gl::Program class. Implements GL program objects
-// and related functionality. [OpenGL ES 2.0.24] section 2.10.3 page 28.
-
-#ifndef LIBGLESV2_PROGRAM_BINARY_H_
-#define LIBGLESV2_PROGRAM_BINARY_H_
-
-#include "common/RefCountObject.h"
-#include "angletypes.h"
-#include "common/mathutil.h"
-#include "libGLESv2/Uniform.h"
-#include "libGLESv2/Shader.h"
-#include "libGLESv2/Constants.h"
-#include "libGLESv2/renderer/d3d/VertexDataManager.h"
-#include "libGLESv2/renderer/d3d/DynamicHLSL.h"
-
-#include "angle_gl.h"
-
-#include <string>
-#include <vector>
-
-namespace sh
-{
-class HLSLBlockEncoder;
-}
-
-#include <GLES3/gl3.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
-#include <string>
-#include <vector>
-
-namespace rx
-{
-class ShaderExecutable;
-struct TranslatedAttribute;
-class UniformStorage;
-class ProgramImpl;
-}
-
-namespace gl
-{
-struct Caps;
-class Shader;
-class InfoLog;
-class AttributeBindings;
-class Buffer;
-class Framebuffer;
-struct Data;
-
-// Struct used for correlating uniforms/elements of uniform arrays to handles
-struct VariableLocation
-{
- VariableLocation()
- {
- }
-
- VariableLocation(const std::string &name, unsigned int element, unsigned int index);
-
- std::string name;
- unsigned int element;
- unsigned int index;
-};
-
-struct LinkedVarying
-{
- LinkedVarying();
- LinkedVarying(const std::string &name, GLenum type, GLsizei size, const std::string &semanticName,
- unsigned int semanticIndex, unsigned int semanticIndexCount);
-
- // Original GL name
- std::string name;
-
- GLenum type;
- GLsizei size;
-
- // DirectX semantic information
- std::string semanticName;
- unsigned int semanticIndex;
- unsigned int semanticIndexCount;
-};
-
-struct LinkResult
-{
- bool linkSuccess;
- Error error;
-
- LinkResult(bool linkSuccess, const Error &error);
-};
-
-// This is the result of linking a program. It is the state that would be passed to ProgramBinary.
-class ProgramBinary : public RefCountObject
-{
- public:
- explicit ProgramBinary(rx::ProgramImpl *impl);
- ~ProgramBinary();
-
- rx::ProgramImpl *getImplementation() { return mProgram; }
- const rx::ProgramImpl *getImplementation() const { return mProgram; }
-
- GLuint getAttributeLocation(const char *name);
- int getSemanticIndex(int attributeIndex);
-
- GLint getSamplerMapping(SamplerType type, unsigned int samplerIndex, const Caps &caps);
- GLenum getSamplerTextureType(SamplerType type, unsigned int samplerIndex);
- GLint getUsedSamplerRange(SamplerType type);
- bool usesPointSize() const;
-
- GLint getUniformLocation(std::string name);
- GLuint getUniformIndex(std::string name);
- GLuint getUniformBlockIndex(std::string name);
- void setUniform1fv(GLint location, GLsizei count, const GLfloat *v);
- void setUniform2fv(GLint location, GLsizei count, const GLfloat *v);
- void setUniform3fv(GLint location, GLsizei count, const GLfloat *v);
- void setUniform4fv(GLint location, GLsizei count, const GLfloat *v);
- void setUniform1iv(GLint location, GLsizei count, const GLint *v);
- void setUniform2iv(GLint location, GLsizei count, const GLint *v);
- void setUniform3iv(GLint location, GLsizei count, const GLint *v);
- void setUniform4iv(GLint location, GLsizei count, const GLint *v);
- void setUniform1uiv(GLint location, GLsizei count, const GLuint *v);
- void setUniform2uiv(GLint location, GLsizei count, const GLuint *v);
- void setUniform3uiv(GLint location, GLsizei count, const GLuint *v);
- void setUniform4uiv(GLint location, GLsizei count, const GLuint *v);
- void setUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- void setUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- void setUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- void setUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- void setUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- void setUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- void setUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- void setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- void setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-
- void getUniformfv(GLint location, GLfloat *params);
- void getUniformiv(GLint location, GLint *params);
- void getUniformuiv(GLint location, GLuint *params);
-
- Error applyUniforms();
- Error applyUniformBuffers(const std::vector<Buffer*> boundBuffers, const Caps &caps);
-
- LinkResult load(InfoLog &infoLog, GLenum binaryFormat, const void *binary, GLsizei length);
- Error save(GLenum *binaryFormat, void *binary, GLsizei bufSize, GLsizei *length);
- GLint getLength();
-
- LinkResult link(const Data &data, InfoLog &infoLog, const AttributeBindings &attributeBindings,
- Shader *fragmentShader, Shader *vertexShader,
- const std::vector<std::string> &transformFeedbackVaryings,
- GLenum transformFeedbackBufferMode);
-
- void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const;
- GLint getActiveAttributeCount() const;
- GLint getActiveAttributeMaxLength() const;
-
- void getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const;
- GLint getActiveUniformCount() const;
- GLint getActiveUniformMaxLength() const;
- GLint getActiveUniformi(GLuint index, GLenum pname) const;
- bool isValidUniformLocation(GLint location) const;
- LinkedUniform *getUniformByLocation(GLint location) const;
- LinkedUniform *getUniformByName(const std::string &name) const;
-
- void getActiveUniformBlockName(GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName) const;
- void getActiveUniformBlockiv(GLuint uniformBlockIndex, GLenum pname, GLint *params) const;
- GLuint getActiveUniformBlockCount() const;
- GLuint getActiveUniformBlockMaxLength() const;
- UniformBlock *getUniformBlockByIndex(GLuint blockIndex);
-
- GLint getFragDataLocation(const char *name) const;
-
- size_t getTransformFeedbackVaryingCount() const;
- const LinkedVarying &getTransformFeedbackVarying(size_t idx) const;
- GLenum getTransformFeedbackBufferMode() const;
-
- void validate(InfoLog &infoLog, const Caps &caps);
- bool validateSamplers(InfoLog *infoLog, const Caps &caps);
- bool isValidated() const;
- void updateSamplerMapping();
-
- unsigned int getSerial() const;
-
- void initAttributesByLayout();
- void sortAttributesByLayout(rx::TranslatedAttribute attributes[MAX_VERTEX_ATTRIBS], int sortedSemanticIndices[MAX_VERTEX_ATTRIBS]) const;
-
- static bool linkVaryings(InfoLog &infoLog, Shader *fragmentShader, Shader *vertexShader);
- static bool linkValidateUniforms(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform);
- static bool linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ProgramBinary);
-
- void reset();
-
- bool linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, const Shader *vertexShader);
- bool linkUniformBlocks(InfoLog &infoLog, const Shader &vertexShader, const Shader &fragmentShader, const Caps &caps);
- bool areMatchingInterfaceBlocks(gl::InfoLog &infoLog, const sh::InterfaceBlock &vertexInterfaceBlock,
- const sh::InterfaceBlock &fragmentInterfaceBlock);
-
- static bool linkValidateVariablesBase(InfoLog &infoLog,
- const std::string &variableName,
- const sh::ShaderVariable &vertexVariable,
- const sh::ShaderVariable &fragmentVariable,
- bool validatePrecision);
-
- static bool linkValidateVaryings(InfoLog &infoLog, const std::string &varyingName, const sh::Varying &vertexVarying, const sh::Varying &fragmentVarying);
- bool gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, const std::vector<LinkedVarying> &linkedVaryings,
- const std::vector<std::string> &transformFeedbackVaryingNames,
- GLenum transformFeedbackBufferMode,
- std::vector<LinkedVarying> *outTransformFeedbackLinkedVaryings,
- const Caps &caps) const;
- bool assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex, const Caps &caps);
- void defineOutputVariables(Shader *fragmentShader);
-
- rx::ProgramImpl *mProgram;
-
- sh::Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS];
- int mSemanticIndex[MAX_VERTEX_ATTRIBS];
- int mAttributesByLayout[MAX_VERTEX_ATTRIBS];
-
- std::map<int, VariableLocation> mOutputVariables;
-
- bool mValidated;
-
- const unsigned int mSerial;
-
- static unsigned int issueSerial();
- static unsigned int mCurrentSerial;
-};
-
-}
-
-#endif // LIBGLESV2_PROGRAM_BINARY_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/Query.cpp b/src/3rdparty/angle/src/libGLESv2/Query.cpp
deleted file mode 100644
index 4ee3525509..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Query.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// Query.cpp: Implements the gl::Query class
-
-#include "libGLESv2/Query.h"
-#include "libGLESv2/renderer/QueryImpl.h"
-
-namespace gl
-{
-Query::Query(rx::QueryImpl *impl, GLuint id)
- : RefCountObject(id),
- mQuery(impl)
-{
-}
-
-Query::~Query()
-{
- SafeDelete(mQuery);
-}
-
-Error Query::begin()
-{
- return mQuery->begin();
-}
-
-Error Query::end()
-{
- return mQuery->end();
-}
-
-Error Query::getResult(GLuint *params)
-{
- return mQuery->getResult(params);
-}
-
-Error Query::isResultAvailable(GLuint *available)
-{
- return mQuery->isResultAvailable(available);
-}
-
-GLenum Query::getType() const
-{
- return mQuery->getType();
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/Query.h b/src/3rdparty/angle/src/libGLESv2/Query.h
deleted file mode 100644
index a7ec404f85..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Query.h
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// Query.h: Defines the gl::Query class
-
-#ifndef LIBGLESV2_QUERY_H_
-#define LIBGLESV2_QUERY_H_
-
-#include "libGLESv2/Error.h"
-#include "common/angleutils.h"
-#include "common/RefCountObject.h"
-
-#include "angle_gl.h"
-
-namespace rx
-{
-class QueryImpl;
-}
-
-namespace gl
-{
-
-class Query : public RefCountObject
-{
- public:
- Query(rx::QueryImpl *impl, GLuint id);
- virtual ~Query();
-
- Error begin();
- Error end();
-
- Error getResult(GLuint *params);
- Error isResultAvailable(GLuint *available);
-
- GLenum getType() const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Query);
-
- rx::QueryImpl *mQuery;
-};
-
-}
-
-#endif // LIBGLESV2_QUERY_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/Renderbuffer.cpp b/src/3rdparty/angle/src/libGLESv2/Renderbuffer.cpp
deleted file mode 100644
index 911a389dfa..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Renderbuffer.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-//
-// 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.
-//
-
-// Renderbuffer.cpp: Implements the renderer-agnostic gl::Renderbuffer class,
-// GL renderbuffer objects and related functionality.
-// [OpenGL ES 2.0.24] section 4.4.3 page 108.
-
-#include "libGLESv2/Renderbuffer.h"
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/formatutils.h"
-#include "libGLESv2/FramebufferAttachment.h"
-#include "libGLESv2/renderer/d3d/RendererD3D.h"
-#include "libGLESv2/renderer/RenderTarget.h"
-#include "libGLESv2/renderer/RenderbufferImpl.h"
-
-#include "common/utilities.h"
-
-namespace gl
-{
-Renderbuffer::Renderbuffer(rx::RenderbufferImpl *impl, GLuint id)
- : RefCountObject(id),
- mRenderbuffer(impl)
-{
- ASSERT(mRenderbuffer);
-
- mWidth = mRenderbuffer->getWidth();
- mHeight = mRenderbuffer->getHeight();
- mInternalFormat = mRenderbuffer->getInternalFormat();
- mActualFormat = mRenderbuffer->getActualFormat();
- mSamples = mRenderbuffer->getSamples();
-}
-
-Renderbuffer::~Renderbuffer()
-{
- SafeDelete(mRenderbuffer);
-}
-
-Error Renderbuffer::setStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples)
-{
- Error error = mRenderbuffer->setStorage(width, height, internalformat, samples);
- if (error.isError())
- {
- return error;
- }
-
- mWidth = width;
- mHeight = height;
- mInternalFormat = internalformat;
- mSamples = samples;
- mActualFormat = mRenderbuffer->getActualFormat();
-
- return Error(GL_NO_ERROR);
-}
-
-rx::RenderbufferImpl *Renderbuffer::getImplementation()
-{
- ASSERT(mRenderbuffer);
- return mRenderbuffer;
-}
-
-GLsizei Renderbuffer::getWidth() const
-{
- return mWidth;
-}
-
-GLsizei Renderbuffer::getHeight() const
-{
- return mHeight;
-}
-
-GLenum Renderbuffer::getInternalFormat() const
-{
- return mInternalFormat;
-}
-
-GLenum Renderbuffer::getActualFormat() const
-{
- return mActualFormat;
-}
-
-GLsizei Renderbuffer::getSamples() const
-{
- return mSamples;
-}
-
-GLuint Renderbuffer::getRedSize() const
-{
- return GetInternalFormatInfo(getActualFormat()).redBits;
-}
-
-GLuint Renderbuffer::getGreenSize() const
-{
- return GetInternalFormatInfo(getActualFormat()).greenBits;
-}
-
-GLuint Renderbuffer::getBlueSize() const
-{
- return GetInternalFormatInfo(getActualFormat()).blueBits;
-}
-
-GLuint Renderbuffer::getAlphaSize() const
-{
- return GetInternalFormatInfo(getActualFormat()).alphaBits;
-}
-
-GLuint Renderbuffer::getDepthSize() const
-{
- return GetInternalFormatInfo(getActualFormat()).depthBits;
-}
-
-GLuint Renderbuffer::getStencilSize() const
-{
- return GetInternalFormatInfo(getActualFormat()).stencilBits;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/Renderbuffer.h b/src/3rdparty/angle/src/libGLESv2/Renderbuffer.h
deleted file mode 100644
index e9f12af3ce..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Renderbuffer.h
+++ /dev/null
@@ -1,71 +0,0 @@
-//
-// Copyright (c) 2002-2010 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.
-//
-
-// Renderbuffer.h: Defines the renderer-agnostic container class gl::Renderbuffer.
-// Implements GL renderbuffer objects and related functionality.
-// [OpenGL ES 2.0.24] section 4.4.3 page 108.
-
-#ifndef LIBGLESV2_RENDERBUFFER_H_
-#define LIBGLESV2_RENDERBUFFER_H_
-
-#include "angle_gl.h"
-
-#include "libGLESv2/Error.h"
-
-#include "common/angleutils.h"
-#include "common/RefCountObject.h"
-
-namespace rx
-{
-class RenderbufferImpl;
-}
-
-namespace gl
-{
-class FramebufferAttachment;
-
-// A GL renderbuffer object is usually used as a depth or stencil buffer attachment
-// for a framebuffer object. The renderbuffer itself is a distinct GL object, see
-// FramebufferAttachment and Framebuffer for how they are applied to an FBO via an
-// attachment point.
-
-class Renderbuffer : public RefCountObject
-{
- public:
- Renderbuffer(rx::RenderbufferImpl *impl, GLuint id);
- virtual ~Renderbuffer();
-
- Error setStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples);
-
- rx::RenderbufferImpl *getImplementation();
-
- GLsizei getWidth() const;
- GLsizei getHeight() const;
- GLenum getInternalFormat() const;
- GLenum getActualFormat() const;
- GLsizei getSamples() const;
- GLuint getRedSize() const;
- GLuint getGreenSize() const;
- GLuint getBlueSize() const;
- GLuint getAlphaSize() const;
- GLuint getDepthSize() const;
- GLuint getStencilSize() const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Renderbuffer);
-
- rx::RenderbufferImpl *mRenderbuffer;
-
- GLsizei mWidth;
- GLsizei mHeight;
- GLenum mInternalFormat;
- GLenum mActualFormat;
- GLsizei mSamples;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERBUFFER_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/ResourceManager.cpp b/src/3rdparty/angle/src/libGLESv2/ResourceManager.cpp
deleted file mode 100644
index 38d53cad81..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/ResourceManager.cpp
+++ /dev/null
@@ -1,427 +0,0 @@
-//
-// Copyright (c) 2002-2013 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.
-//
-
-// ResourceManager.cpp: Implements the gl::ResourceManager class, which tracks and
-// retrieves objects which may be shared by multiple Contexts.
-
-#include "libGLESv2/ResourceManager.h"
-
-#include "libGLESv2/Buffer.h"
-#include "libGLESv2/Program.h"
-#include "libGLESv2/Renderbuffer.h"
-#include "libGLESv2/Shader.h"
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/Sampler.h"
-#include "libGLESv2/Fence.h"
-#include "libGLESv2/renderer/Renderer.h"
-
-namespace gl
-{
-ResourceManager::ResourceManager(rx::Renderer *renderer)
- : mRenderer(renderer),
- mRefCount(1)
-{
-}
-
-ResourceManager::~ResourceManager()
-{
- while (!mBufferMap.empty())
- {
- deleteBuffer(mBufferMap.begin()->first);
- }
-
- while (!mProgramMap.empty())
- {
- deleteProgram(mProgramMap.begin()->first);
- }
-
- while (!mShaderMap.empty())
- {
- deleteShader(mShaderMap.begin()->first);
- }
-
- while (!mRenderbufferMap.empty())
- {
- deleteRenderbuffer(mRenderbufferMap.begin()->first);
- }
-
- while (!mTextureMap.empty())
- {
- deleteTexture(mTextureMap.begin()->first);
- }
-
- while (!mSamplerMap.empty())
- {
- deleteSampler(mSamplerMap.begin()->first);
- }
-
- while (!mFenceSyncMap.empty())
- {
- deleteFenceSync(mFenceSyncMap.begin()->first);
- }
-}
-
-void ResourceManager::addRef()
-{
- mRefCount++;
-}
-
-void ResourceManager::release()
-{
- if (--mRefCount == 0)
- {
- delete this;
- }
-}
-
-// Returns an unused buffer name
-GLuint ResourceManager::createBuffer()
-{
- GLuint handle = mBufferHandleAllocator.allocate();
-
- mBufferMap[handle] = NULL;
-
- return handle;
-}
-
-// Returns an unused shader/program name
-GLuint ResourceManager::createShader(const gl::Data &data, GLenum type)
-{
- GLuint handle = mProgramShaderHandleAllocator.allocate();
-
- if (type == GL_VERTEX_SHADER || type == GL_FRAGMENT_SHADER)
- {
- mShaderMap[handle] = new Shader(this, mRenderer->createShader(data, type), type, handle);
- }
- else UNREACHABLE();
-
- return handle;
-}
-
-// Returns an unused program/shader name
-GLuint ResourceManager::createProgram()
-{
- GLuint handle = mProgramShaderHandleAllocator.allocate();
-
- mProgramMap[handle] = new Program(mRenderer, this, handle);
-
- return handle;
-}
-
-// Returns an unused texture name
-GLuint ResourceManager::createTexture()
-{
- GLuint handle = mTextureHandleAllocator.allocate();
-
- mTextureMap[handle] = NULL;
-
- return handle;
-}
-
-// Returns an unused renderbuffer name
-GLuint ResourceManager::createRenderbuffer()
-{
- GLuint handle = mRenderbufferHandleAllocator.allocate();
-
- mRenderbufferMap[handle] = NULL;
-
- return handle;
-}
-
-// Returns an unused sampler name
-GLuint ResourceManager::createSampler()
-{
- GLuint handle = mSamplerHandleAllocator.allocate();
-
- mSamplerMap[handle] = NULL;
-
- return handle;
-}
-
-// Returns the next unused fence name, and allocates the fence
-GLuint ResourceManager::createFenceSync()
-{
- GLuint handle = mFenceSyncHandleAllocator.allocate();
-
- FenceSync *fenceSync = new FenceSync(mRenderer->createFenceSync(), handle);
- fenceSync->addRef();
- mFenceSyncMap[handle] = fenceSync;
-
- return handle;
-}
-
-void ResourceManager::deleteBuffer(GLuint buffer)
-{
- BufferMap::iterator bufferObject = mBufferMap.find(buffer);
-
- if (bufferObject != mBufferMap.end())
- {
- mBufferHandleAllocator.release(bufferObject->first);
- if (bufferObject->second) bufferObject->second->release();
- mBufferMap.erase(bufferObject);
- }
-}
-
-void ResourceManager::deleteShader(GLuint shader)
-{
- ShaderMap::iterator shaderObject = mShaderMap.find(shader);
-
- if (shaderObject != mShaderMap.end())
- {
- if (shaderObject->second->getRefCount() == 0)
- {
- mProgramShaderHandleAllocator.release(shaderObject->first);
- delete shaderObject->second;
- mShaderMap.erase(shaderObject);
- }
- else
- {
- shaderObject->second->flagForDeletion();
- }
- }
-}
-
-void ResourceManager::deleteProgram(GLuint program)
-{
- ProgramMap::iterator programObject = mProgramMap.find(program);
-
- if (programObject != mProgramMap.end())
- {
- if (programObject->second->getRefCount() == 0)
- {
- mProgramShaderHandleAllocator.release(programObject->first);
- delete programObject->second;
- mProgramMap.erase(programObject);
- }
- else
- {
- programObject->second->flagForDeletion();
- }
- }
-}
-
-void ResourceManager::deleteTexture(GLuint texture)
-{
- TextureMap::iterator textureObject = mTextureMap.find(texture);
-
- if (textureObject != mTextureMap.end())
- {
- mTextureHandleAllocator.release(textureObject->first);
- if (textureObject->second) textureObject->second->release();
- mTextureMap.erase(textureObject);
- }
-}
-
-void ResourceManager::deleteRenderbuffer(GLuint renderbuffer)
-{
- RenderbufferMap::iterator renderbufferObject = mRenderbufferMap.find(renderbuffer);
-
- if (renderbufferObject != mRenderbufferMap.end())
- {
- mRenderbufferHandleAllocator.release(renderbufferObject->first);
- if (renderbufferObject->second) renderbufferObject->second->release();
- mRenderbufferMap.erase(renderbufferObject);
- }
-}
-
-void ResourceManager::deleteSampler(GLuint sampler)
-{
- auto samplerObject = mSamplerMap.find(sampler);
-
- if (samplerObject != mSamplerMap.end())
- {
- mSamplerHandleAllocator.release(samplerObject->first);
- if (samplerObject->second) samplerObject->second->release();
- mSamplerMap.erase(samplerObject);
- }
-}
-
-void ResourceManager::deleteFenceSync(GLuint fenceSync)
-{
- auto fenceObjectIt = mFenceSyncMap.find(fenceSync);
-
- if (fenceObjectIt != mFenceSyncMap.end())
- {
- mFenceSyncHandleAllocator.release(fenceObjectIt->first);
- if (fenceObjectIt->second) fenceObjectIt->second->release();
- mFenceSyncMap.erase(fenceObjectIt);
- }
-}
-
-Buffer *ResourceManager::getBuffer(unsigned int handle)
-{
- BufferMap::iterator buffer = mBufferMap.find(handle);
-
- if (buffer == mBufferMap.end())
- {
- return NULL;
- }
- else
- {
- return buffer->second;
- }
-}
-
-Shader *ResourceManager::getShader(unsigned int handle)
-{
- ShaderMap::iterator shader = mShaderMap.find(handle);
-
- if (shader == mShaderMap.end())
- {
- return NULL;
- }
- else
- {
- return shader->second;
- }
-}
-
-Texture *ResourceManager::getTexture(unsigned int handle)
-{
- if (handle == 0) return NULL;
-
- TextureMap::iterator texture = mTextureMap.find(handle);
-
- if (texture == mTextureMap.end())
- {
- return NULL;
- }
- else
- {
- return texture->second;
- }
-}
-
-Program *ResourceManager::getProgram(unsigned int handle) const
-{
- ProgramMap::const_iterator program = mProgramMap.find(handle);
-
- if (program == mProgramMap.end())
- {
- return NULL;
- }
- else
- {
- return program->second;
- }
-}
-
-Renderbuffer *ResourceManager::getRenderbuffer(unsigned int handle)
-{
- RenderbufferMap::iterator renderbuffer = mRenderbufferMap.find(handle);
-
- if (renderbuffer == mRenderbufferMap.end())
- {
- return NULL;
- }
- else
- {
- return renderbuffer->second;
- }
-}
-
-Sampler *ResourceManager::getSampler(unsigned int handle)
-{
- auto sampler = mSamplerMap.find(handle);
-
- if (sampler == mSamplerMap.end())
- {
- return NULL;
- }
- else
- {
- return sampler->second;
- }
-}
-
-FenceSync *ResourceManager::getFenceSync(unsigned int handle)
-{
- auto fenceObjectIt = mFenceSyncMap.find(handle);
-
- if (fenceObjectIt == mFenceSyncMap.end())
- {
- return NULL;
- }
- else
- {
- return fenceObjectIt->second;
- }
-}
-
-void ResourceManager::setRenderbuffer(GLuint handle, Renderbuffer *buffer)
-{
- mRenderbufferMap[handle] = buffer;
-}
-
-void ResourceManager::checkBufferAllocation(unsigned int buffer)
-{
- if (buffer != 0 && !getBuffer(buffer))
- {
- Buffer *bufferObject = new Buffer(mRenderer->createBuffer(), buffer);
- mBufferMap[buffer] = bufferObject;
- bufferObject->addRef();
- }
-}
-
-void ResourceManager::checkTextureAllocation(GLuint texture, GLenum type)
-{
- if (!getTexture(texture) && texture != 0)
- {
- Texture *textureObject;
-
- if (type == GL_TEXTURE_2D)
- {
- textureObject = new Texture2D(mRenderer->createTexture(GL_TEXTURE_2D), texture);
- }
- else if (type == GL_TEXTURE_CUBE_MAP)
- {
- textureObject = new TextureCubeMap(mRenderer->createTexture(GL_TEXTURE_CUBE_MAP), texture);
- }
- else if (type == GL_TEXTURE_3D)
- {
- textureObject = new Texture3D(mRenderer->createTexture(GL_TEXTURE_3D), texture);
- }
- else if (type == GL_TEXTURE_2D_ARRAY)
- {
- textureObject = new Texture2DArray(mRenderer->createTexture(GL_TEXTURE_2D_ARRAY), texture);
- }
- else
- {
- UNREACHABLE();
- return;
- }
-
- mTextureMap[texture] = textureObject;
- textureObject->addRef();
- }
-}
-
-void ResourceManager::checkRenderbufferAllocation(GLuint renderbuffer)
-{
- if (renderbuffer != 0 && !getRenderbuffer(renderbuffer))
- {
- Renderbuffer *renderbufferObject = new Renderbuffer(mRenderer->createRenderbuffer(), renderbuffer);
- mRenderbufferMap[renderbuffer] = renderbufferObject;
- renderbufferObject->addRef();
- }
-}
-
-void ResourceManager::checkSamplerAllocation(GLuint sampler)
-{
- if (sampler != 0 && !getSampler(sampler))
- {
- Sampler *samplerObject = new Sampler(sampler);
- mSamplerMap[sampler] = samplerObject;
- samplerObject->addRef();
- }
-}
-
-bool ResourceManager::isSampler(GLuint sampler)
-{
- return mSamplerMap.find(sampler) != mSamplerMap.end();
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/ResourceManager.h b/src/3rdparty/angle/src/libGLESv2/ResourceManager.h
deleted file mode 100644
index acad29b51d..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/ResourceManager.h
+++ /dev/null
@@ -1,115 +0,0 @@
-//
-// Copyright (c) 2002-2013 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.
-//
-
-// ResourceManager.h : Defines the ResourceManager class, which tracks objects
-// shared by multiple GL contexts.
-
-#ifndef LIBGLESV2_RESOURCEMANAGER_H_
-#define LIBGLESV2_RESOURCEMANAGER_H_
-
-#include "common/angleutils.h"
-#include "libGLESv2/angletypes.h"
-#include "libGLESv2/HandleAllocator.h"
-
-#include "angle_gl.h"
-
-#include <unordered_map>
-
-namespace rx
-{
-class Renderer;
-}
-
-namespace gl
-{
-class Buffer;
-class Shader;
-class Program;
-class Texture;
-class Renderbuffer;
-class Sampler;
-class FenceSync;
-struct Data;
-
-class ResourceManager
-{
- public:
- explicit ResourceManager(rx::Renderer *renderer);
- ~ResourceManager();
-
- void addRef();
- void release();
-
- GLuint createBuffer();
- GLuint createShader(const gl::Data &data, GLenum type);
- GLuint createProgram();
- GLuint createTexture();
- GLuint createRenderbuffer();
- GLuint createSampler();
- GLuint createFenceSync();
-
- void deleteBuffer(GLuint buffer);
- void deleteShader(GLuint shader);
- void deleteProgram(GLuint program);
- void deleteTexture(GLuint texture);
- void deleteRenderbuffer(GLuint renderbuffer);
- void deleteSampler(GLuint sampler);
- void deleteFenceSync(GLuint fenceSync);
-
- Buffer *getBuffer(GLuint handle);
- Shader *getShader(GLuint handle);
- Program *getProgram(GLuint handle) const;
- Texture *getTexture(GLuint handle);
- Renderbuffer *getRenderbuffer(GLuint handle);
- Sampler *getSampler(GLuint handle);
- FenceSync *getFenceSync(GLuint handle);
-
- void setRenderbuffer(GLuint handle, Renderbuffer *renderbuffer);
-
- void checkBufferAllocation(unsigned int buffer);
- void checkTextureAllocation(GLuint texture, GLenum type);
- void checkRenderbufferAllocation(GLuint renderbuffer);
- void checkSamplerAllocation(GLuint sampler);
-
- bool isSampler(GLuint sampler);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ResourceManager);
-
- rx::Renderer *mRenderer;
- std::size_t mRefCount;
-
- typedef std::unordered_map<GLuint, Buffer*> BufferMap;
- BufferMap mBufferMap;
- HandleAllocator mBufferHandleAllocator;
-
- typedef std::unordered_map<GLuint, Shader*> ShaderMap;
- ShaderMap mShaderMap;
-
- typedef std::unordered_map<GLuint, Program*> ProgramMap;
- ProgramMap mProgramMap;
- HandleAllocator mProgramShaderHandleAllocator;
-
- typedef std::unordered_map<GLuint, Texture*> TextureMap;
- TextureMap mTextureMap;
- HandleAllocator mTextureHandleAllocator;
-
- typedef std::unordered_map<GLuint, Renderbuffer*> RenderbufferMap;
- RenderbufferMap mRenderbufferMap;
- HandleAllocator mRenderbufferHandleAllocator;
-
- typedef std::unordered_map<GLuint, Sampler*> SamplerMap;
- SamplerMap mSamplerMap;
- HandleAllocator mSamplerHandleAllocator;
-
- typedef std::unordered_map<GLuint, FenceSync*> FenceMap;
- FenceMap mFenceSyncMap;
- HandleAllocator mFenceSyncHandleAllocator;
-};
-
-}
-
-#endif // LIBGLESV2_RESOURCEMANAGER_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/Sampler.cpp b/src/3rdparty/angle/src/libGLESv2/Sampler.cpp
deleted file mode 100644
index b906e65557..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Sampler.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// Sampler.cpp : Implements the Sampler class, which represents a GLES 3
-// sampler object. Sampler objects store some state needed to sample textures.
-
-#include "libGLESv2/Sampler.h"
-#include "libGLESv2/angletypes.h"
-
-namespace gl
-{
-
-Sampler::Sampler(GLuint id)
- : RefCountObject(id),
- mMinFilter(GL_NEAREST_MIPMAP_LINEAR),
- mMagFilter(GL_LINEAR),
- mWrapS(GL_REPEAT),
- mWrapT(GL_REPEAT),
- mWrapR(GL_REPEAT),
- mMinLod(-1000.0f),
- mMaxLod(1000.0f),
- mComparisonMode(GL_NONE),
- mComparisonFunc(GL_LEQUAL)
-{
-}
-
-void Sampler::getState(SamplerState *samplerState) const
-{
- samplerState->minFilter = mMinFilter;
- samplerState->magFilter = mMagFilter;
- samplerState->wrapS = mWrapS;
- samplerState->wrapT = mWrapT;
- samplerState->wrapR = mWrapR;
- samplerState->minLod = mMinLod;
- samplerState->maxLod = mMaxLod;
- samplerState->compareMode = mComparisonMode;
- samplerState->compareFunc = mComparisonFunc;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/Sampler.h b/src/3rdparty/angle/src/libGLESv2/Sampler.h
deleted file mode 100644
index 257bc25d22..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Sampler.h
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// Sampler.h : Defines the Sampler class, which represents a GLES 3
-// sampler object. Sampler objects store some state needed to sample textures.
-
-#ifndef LIBGLESV2_SAMPLER_H_
-#define LIBGLESV2_SAMPLER_H_
-
-#include "common/RefCountObject.h"
-
-namespace gl
-{
-struct SamplerState;
-
-class Sampler : public RefCountObject
-{
- public:
- Sampler(GLuint id);
-
- void setMinFilter(GLenum minFilter) { mMinFilter = minFilter; }
- void setMagFilter(GLenum magFilter) { mMagFilter = magFilter; }
- void setWrapS(GLenum wrapS) { mWrapS = wrapS; }
- void setWrapT(GLenum wrapT) { mWrapT = wrapT; }
- void setWrapR(GLenum wrapR) { mWrapR = wrapR; }
- void setMinLod(GLfloat minLod) { mMinLod = minLod; }
- void setMaxLod(GLfloat maxLod) { mMaxLod = maxLod; }
- void setComparisonMode(GLenum comparisonMode) { mComparisonMode = comparisonMode; }
- void setComparisonFunc(GLenum comparisonFunc) { mComparisonFunc = comparisonFunc; }
-
- GLenum getMinFilter() const { return mMinFilter; }
- GLenum getMagFilter() const { return mMagFilter; }
- GLenum getWrapS() const { return mWrapS; }
- GLenum getWrapT() const { return mWrapT; }
- GLenum getWrapR() const { return mWrapR; }
- GLfloat getMinLod() const { return mMinLod; }
- GLfloat getMaxLod() const { return mMaxLod; }
- GLenum getComparisonMode() const { return mComparisonMode; }
- GLenum getComparisonFunc() const { return mComparisonFunc; }
-
- void getState(SamplerState *samplerState) const;
-
- private:
- GLenum mMinFilter;
- GLenum mMagFilter;
- GLenum mWrapS;
- GLenum mWrapT;
- GLenum mWrapR;
- GLfloat mMinLod;
- GLfloat mMaxLod;
- GLenum mComparisonMode;
- GLenum mComparisonFunc;
-};
-
-}
-
-#endif // LIBGLESV2_SAMPLER_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/Shader.cpp b/src/3rdparty/angle/src/libGLESv2/Shader.cpp
deleted file mode 100644
index 024ef8fb7c..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Shader.cpp
+++ /dev/null
@@ -1,219 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// Shader.cpp: Implements the gl::Shader class and its derived classes
-// VertexShader and FragmentShader. Implements GL shader objects and related
-// functionality. [OpenGL ES 2.0.24] section 2.10 page 24 and section 3.8 page 84.
-
-#include "libGLESv2/Shader.h"
-#include "libGLESv2/renderer/Renderer.h"
-#include "libGLESv2/renderer/ShaderImpl.h"
-#include "libGLESv2/Constants.h"
-#include "libGLESv2/ResourceManager.h"
-
-#include "common/utilities.h"
-
-#include "GLSLANG/ShaderLang.h"
-
-#include <sstream>
-
-namespace gl
-{
-
-Shader::Shader(ResourceManager *manager, rx::ShaderImpl *impl, GLenum type, GLuint handle)
- : mShader(impl),
- mType(type),
- mHandle(handle),
- mResourceManager(manager),
- mRefCount(0),
- mDeleteStatus(false),
- mCompiled(false)
-{
- ASSERT(impl);
-}
-
-Shader::~Shader()
-{
- SafeDelete(mShader);
-}
-
-GLuint Shader::getHandle() const
-{
- return mHandle;
-}
-
-void Shader::setSource(GLsizei count, const char *const *string, const GLint *length)
-{
- std::ostringstream stream;
-
- for (int i = 0; i < count; i++)
- {
- if (length == nullptr || length[i] < 0)
- {
- stream.write(string[i], strlen(string[i]));
- }
- else
- {
- stream.write(string[i], length[i]);
- }
- }
-
- mSource = stream.str();
-}
-
-int Shader::getInfoLogLength() const
-{
- return mShader->getInfoLog().empty() ? 0 : (mShader->getInfoLog().length() + 1);
-}
-
-void Shader::getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog) const
-{
- int index = 0;
-
- if (bufSize > 0)
- {
- index = std::min(bufSize - 1, static_cast<GLsizei>(mShader->getInfoLog().length()));
- memcpy(infoLog, mShader->getInfoLog().c_str(), index);
-
- infoLog[index] = '\0';
- }
-
- if (length)
- {
- *length = index;
- }
-}
-
-int Shader::getSourceLength() const
-{
- return mSource.empty() ? 0 : (mSource.length() + 1);
-}
-
-int Shader::getTranslatedSourceLength() const
-{
- return mShader->getTranslatedSource().empty() ? 0 : (mShader->getTranslatedSource().length() + 1);
-}
-
-void Shader::getSourceImpl(const std::string &source, GLsizei bufSize, GLsizei *length, char *buffer)
-{
- int index = 0;
-
- if (bufSize > 0)
- {
- index = std::min(bufSize - 1, static_cast<GLsizei>(source.length()));
- memcpy(buffer, source.c_str(), index);
-
- buffer[index] = '\0';
- }
-
- if (length)
- {
- *length = index;
- }
-}
-
-void Shader::getSource(GLsizei bufSize, GLsizei *length, char *buffer) const
-{
- getSourceImpl(mSource, bufSize, length, buffer);
-}
-
-void Shader::getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer) const
-{
- getSourceImpl(mShader->getTranslatedSource(), bufSize, length, buffer);
-}
-
-void Shader::getTranslatedSourceWithDebugInfo(GLsizei bufSize, GLsizei *length, char *buffer) const
-{
- std::string debugInfo(mShader->getDebugInfo());
- getSourceImpl(debugInfo, bufSize, length, buffer);
-}
-
-void Shader::compile(const gl::Data &data)
-{
- mCompiled = mShader->compile(data, mSource);
-}
-
-void Shader::addRef()
-{
- mRefCount++;
-}
-
-void Shader::release()
-{
- mRefCount--;
-
- if (mRefCount == 0 && mDeleteStatus)
- {
- mResourceManager->deleteShader(mHandle);
- }
-}
-
-unsigned int Shader::getRefCount() const
-{
- return mRefCount;
-}
-
-bool Shader::isFlaggedForDeletion() const
-{
- return mDeleteStatus;
-}
-
-void Shader::flagForDeletion()
-{
- mDeleteStatus = true;
-}
-
-const std::vector<gl::PackedVarying> &Shader::getVaryings() const
-{
- return mShader->getVaryings();
-}
-
-const std::vector<sh::Uniform> &Shader::getUniforms() const
-{
- return mShader->getUniforms();
-}
-
-const std::vector<sh::InterfaceBlock> &Shader::getInterfaceBlocks() const
-{
- return mShader->getInterfaceBlocks();
-}
-
-const std::vector<sh::Attribute> &Shader::getActiveAttributes() const
-{
- return mShader->getActiveAttributes();
-}
-
-const std::vector<sh::Attribute> &Shader::getActiveOutputVariables() const
-{
- return mShader->getActiveOutputVariables();
-}
-
-std::vector<gl::PackedVarying> &Shader::getVaryings()
-{
- return mShader->getVaryings();
-}
-
-std::vector<sh::Uniform> &Shader::getUniforms()
-{
- return mShader->getUniforms();
-}
-
-std::vector<sh::InterfaceBlock> &Shader::getInterfaceBlocks()
-{
- return mShader->getInterfaceBlocks();
-}
-
-std::vector<sh::Attribute> &Shader::getActiveAttributes()
-{
- return mShader->getActiveAttributes();
-}
-
-std::vector<sh::Attribute> &Shader::getActiveOutputVariables()
-{
- return mShader->getActiveOutputVariables();
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/Shader.h b/src/3rdparty/angle/src/libGLESv2/Shader.h
deleted file mode 100644
index 904217dab8..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Shader.h
+++ /dev/null
@@ -1,118 +0,0 @@
-//
-// Copyright (c) 2002-2013 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.
-//
-
-// Shader.h: Defines the abstract gl::Shader class and its concrete derived
-// classes VertexShader and FragmentShader. Implements GL shader objects and
-// related functionality. [OpenGL ES 2.0.24] section 2.10 page 24 and section
-// 3.8 page 84.
-
-#ifndef LIBGLESV2_SHADER_H_
-#define LIBGLESV2_SHADER_H_
-
-
-#include <string>
-#include <list>
-#include <vector>
-
-#include "angle_gl.h"
-#include <GLSLANG/ShaderLang.h>
-
-#include "common/angleutils.h"
-#include "libGLESv2/angletypes.h"
-
-namespace rx
-{
-class ShaderImpl;
-}
-
-namespace gl
-{
-class ResourceManager;
-struct Data;
-
-struct PackedVarying : public sh::Varying
-{
- unsigned int registerIndex; // Assigned during link
- unsigned int columnIndex; // Assigned during link, defaults to 0
-
- PackedVarying(const sh::Varying &varying)
- : sh::Varying(varying),
- registerIndex(GL_INVALID_INDEX),
- columnIndex(0)
- {}
-
- bool registerAssigned() const { return registerIndex != GL_INVALID_INDEX; }
- bool isBuiltIn() const { return name.compare(0, 3, "gl_") == 0; }
-
- void resetRegisterAssignment()
- {
- registerIndex = GL_INVALID_INDEX;
- }
-};
-
-class Shader
-{
- public:
- Shader(ResourceManager *manager, rx::ShaderImpl *impl, GLenum type, GLuint handle);
-
- virtual ~Shader();
-
- GLenum getType() const { return mType; }
- GLuint getHandle() const;
-
- rx::ShaderImpl *getImplementation() { return mShader; }
- const rx::ShaderImpl *getImplementation() const { return mShader; }
-
- void deleteSource();
- void setSource(GLsizei count, const char *const *string, const GLint *length);
- int getInfoLogLength() const;
- void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog) const;
- int getSourceLength() const;
- void getSource(GLsizei bufSize, GLsizei *length, char *buffer) const;
- int getTranslatedSourceLength() const;
- void getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer) const;
- void getTranslatedSourceWithDebugInfo(GLsizei bufSize, GLsizei *length, char *buffer) const;
-
- void compile(const gl::Data &data);
- bool isCompiled() const { return mCompiled; }
-
- void addRef();
- void release();
- unsigned int getRefCount() const;
- bool isFlaggedForDeletion() const;
- void flagForDeletion();
-
- const std::vector<gl::PackedVarying> &getVaryings() const;
- const std::vector<sh::Uniform> &getUniforms() const;
- const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const;
- const std::vector<sh::Attribute> &getActiveAttributes() const;
- const std::vector<sh::Attribute> &getActiveOutputVariables() const;
-
- std::vector<gl::PackedVarying> &getVaryings();
- std::vector<sh::Uniform> &getUniforms();
- std::vector<sh::InterfaceBlock> &getInterfaceBlocks();
- std::vector<sh::Attribute> &getActiveAttributes();
- std::vector<sh::Attribute> &getActiveOutputVariables();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Shader);
-
- static void getSourceImpl(const std::string &source, GLsizei bufSize, GLsizei *length, char *buffer);
-
- rx::ShaderImpl *mShader;
- const GLuint mHandle;
- const GLenum mType;
- std::string mSource;
- unsigned int mRefCount; // Number of program objects this shader is attached to
- bool mDeleteStatus; // Flag to indicate that the shader can be deleted when no longer in use
- bool mCompiled; // Indicates if this shader has been successfully compiled
-
- ResourceManager *mResourceManager;
-};
-
-}
-
-#endif // LIBGLESV2_SHADER_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/State.cpp b/src/3rdparty/angle/src/libGLESv2/State.cpp
deleted file mode 100644
index b5b62f5848..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/State.cpp
+++ /dev/null
@@ -1,1464 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// State.cpp: Implements the State class, encapsulating raw GL state.
-
-#include "libGLESv2/State.h"
-
-#include "libGLESv2/Context.h"
-#include "libGLESv2/Caps.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/FramebufferAttachment.h"
-#include "libGLESv2/Query.h"
-#include "libGLESv2/VertexArray.h"
-#include "libGLESv2/formatutils.h"
-#include "libGLESv2/renderer/RenderTarget.h"
-
-namespace gl
-{
-
-State::State()
-{
- mMaxDrawBuffers = 0;
- mMaxCombinedTextureImageUnits = 0;
-}
-
-State::~State()
-{
- reset();
-}
-
-void State::initialize(const Caps& caps, GLuint clientVersion)
-{
- mMaxDrawBuffers = caps.maxDrawBuffers;
- mMaxCombinedTextureImageUnits = caps.maxCombinedTextureImageUnits;
-
- setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
-
- mDepthClearValue = 1.0f;
- mStencilClearValue = 0;
-
- mRasterizer.rasterizerDiscard = false;
- mRasterizer.cullFace = false;
- mRasterizer.cullMode = GL_BACK;
- mRasterizer.frontFace = GL_CCW;
- mRasterizer.polygonOffsetFill = false;
- mRasterizer.polygonOffsetFactor = 0.0f;
- mRasterizer.polygonOffsetUnits = 0.0f;
- mRasterizer.pointDrawMode = false;
- mRasterizer.multiSample = false;
- mScissorTest = false;
- mScissor.x = 0;
- mScissor.y = 0;
- mScissor.width = 0;
- mScissor.height = 0;
-
- mBlend.blend = false;
- mBlend.sourceBlendRGB = GL_ONE;
- mBlend.sourceBlendAlpha = GL_ONE;
- mBlend.destBlendRGB = GL_ZERO;
- mBlend.destBlendAlpha = GL_ZERO;
- mBlend.blendEquationRGB = GL_FUNC_ADD;
- mBlend.blendEquationAlpha = GL_FUNC_ADD;
- mBlend.sampleAlphaToCoverage = false;
- mBlend.dither = true;
-
- mBlendColor.red = 0;
- mBlendColor.green = 0;
- mBlendColor.blue = 0;
- mBlendColor.alpha = 0;
-
- mDepthStencil.depthTest = false;
- mDepthStencil.depthFunc = GL_LESS;
- mDepthStencil.depthMask = true;
- mDepthStencil.stencilTest = false;
- mDepthStencil.stencilFunc = GL_ALWAYS;
- mDepthStencil.stencilMask = -1;
- mDepthStencil.stencilWritemask = -1;
- mDepthStencil.stencilBackFunc = GL_ALWAYS;
- mDepthStencil.stencilBackMask = -1;
- mDepthStencil.stencilBackWritemask = -1;
- mDepthStencil.stencilFail = GL_KEEP;
- mDepthStencil.stencilPassDepthFail = GL_KEEP;
- mDepthStencil.stencilPassDepthPass = GL_KEEP;
- mDepthStencil.stencilBackFail = GL_KEEP;
- mDepthStencil.stencilBackPassDepthFail = GL_KEEP;
- mDepthStencil.stencilBackPassDepthPass = GL_KEEP;
-
- mStencilRef = 0;
- mStencilBackRef = 0;
-
- mSampleCoverage = false;
- mSampleCoverageValue = 1.0f;
- mSampleCoverageInvert = false;
- mGenerateMipmapHint = GL_DONT_CARE;
- mFragmentShaderDerivativeHint = GL_DONT_CARE;
-
- mLineWidth = 1.0f;
-
- mViewport.x = 0;
- mViewport.y = 0;
- mViewport.width = 0;
- mViewport.height = 0;
- mNearZ = 0.0f;
- mFarZ = 1.0f;
-
- mBlend.colorMaskRed = true;
- mBlend.colorMaskGreen = true;
- mBlend.colorMaskBlue = true;
- mBlend.colorMaskAlpha = true;
-
- mActiveSampler = 0;
-
- const GLfloat defaultFloatValues[] = { 0.0f, 0.0f, 0.0f, 1.0f };
- mVertexAttribCurrentValues.resize(caps.maxVertexAttributes);
- for (size_t attribIndex = 0; attribIndex < mVertexAttribCurrentValues.size(); ++attribIndex)
- {
- mVertexAttribCurrentValues[attribIndex].setFloatValues(defaultFloatValues);
- }
-
- mUniformBuffers.resize(caps.maxCombinedUniformBlocks);
- mTransformFeedbackBuffers.resize(caps.maxTransformFeedbackSeparateAttributes);
-
- mSamplerTextures[GL_TEXTURE_2D].resize(caps.maxCombinedTextureImageUnits);
- mSamplerTextures[GL_TEXTURE_CUBE_MAP].resize(caps.maxCombinedTextureImageUnits);
- if (clientVersion >= 3)
- {
- // TODO: These could also be enabled via extension
- mSamplerTextures[GL_TEXTURE_2D_ARRAY].resize(caps.maxCombinedTextureImageUnits);
- mSamplerTextures[GL_TEXTURE_3D].resize(caps.maxCombinedTextureImageUnits);
- }
-
- mSamplers.resize(caps.maxCombinedTextureImageUnits);
-
- mActiveQueries[GL_ANY_SAMPLES_PASSED].set(NULL);
- mActiveQueries[GL_ANY_SAMPLES_PASSED_CONSERVATIVE].set(NULL);
- mActiveQueries[GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN].set(NULL);
-
- mCurrentProgramId = 0;
- mCurrentProgramBinary.set(NULL);
-
- mReadFramebuffer = NULL;
- mDrawFramebuffer = NULL;
-}
-
-void State::reset()
-{
- for (TextureBindingMap::iterator bindingVec = mSamplerTextures.begin(); bindingVec != mSamplerTextures.end(); bindingVec++)
- {
- TextureBindingVector &textureVector = bindingVec->second;
- for (size_t textureIdx = 0; textureIdx < textureVector.size(); textureIdx++)
- {
- textureVector[textureIdx].set(NULL);
- }
- }
- for (size_t samplerIdx = 0; samplerIdx < mSamplers.size(); samplerIdx++)
- {
- mSamplers[samplerIdx].set(NULL);
- }
-
- mArrayBuffer.set(NULL);
- mRenderbuffer.set(NULL);
-
- mTransformFeedback.set(NULL);
-
- for (State::ActiveQueryMap::iterator i = mActiveQueries.begin(); i != mActiveQueries.end(); i++)
- {
- i->second.set(NULL);
- }
-
- mGenericUniformBuffer.set(NULL);
- mGenericTransformFeedbackBuffer.set(NULL);
- for (BufferVector::iterator bufItr = mUniformBuffers.begin(); bufItr != mUniformBuffers.end(); ++bufItr)
- {
- bufItr->set(NULL);
- }
-
- for (BufferVector::iterator bufItr = mTransformFeedbackBuffers.begin(); bufItr != mTransformFeedbackBuffers.end(); ++bufItr)
- {
- bufItr->set(NULL);
- }
-
- mCopyReadBuffer.set(NULL);
- mCopyWriteBuffer.set(NULL);
-
- mPack.pixelBuffer.set(NULL);
- mUnpack.pixelBuffer.set(NULL);
-}
-
-const RasterizerState &State::getRasterizerState() const
-{
- return mRasterizer;
-}
-
-const BlendState &State::getBlendState() const
-{
- return mBlend;
-}
-
-const DepthStencilState &State::getDepthStencilState() const
-{
- return mDepthStencil;
-}
-
-void State::setClearColor(float red, float green, float blue, float alpha)
-{
- mColorClearValue.red = red;
- mColorClearValue.green = green;
- mColorClearValue.blue = blue;
- mColorClearValue.alpha = alpha;
-}
-
-void State::setClearDepth(float depth)
-{
- mDepthClearValue = depth;
-}
-
-void State::setClearStencil(int stencil)
-{
- mStencilClearValue = stencil;
-}
-
-ClearParameters State::getClearParameters(GLbitfield mask) const
-{
- ClearParameters clearParams = { 0 };
- for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++)
- {
- clearParams.clearColor[i] = false;
- }
- clearParams.colorFClearValue = mColorClearValue;
- clearParams.colorClearType = GL_FLOAT;
- clearParams.colorMaskRed = mBlend.colorMaskRed;
- clearParams.colorMaskGreen = mBlend.colorMaskGreen;
- clearParams.colorMaskBlue = mBlend.colorMaskBlue;
- clearParams.colorMaskAlpha = mBlend.colorMaskAlpha;
- clearParams.clearDepth = false;
- clearParams.depthClearValue = mDepthClearValue;
- clearParams.clearStencil = false;
- clearParams.stencilClearValue = mStencilClearValue;
- clearParams.stencilWriteMask = mDepthStencil.stencilWritemask;
- clearParams.scissorEnabled = mScissorTest;
- clearParams.scissor = mScissor;
-
- const Framebuffer *framebufferObject = getDrawFramebuffer();
- if (mask & GL_COLOR_BUFFER_BIT)
- {
- if (framebufferObject->hasEnabledColorAttachment())
- {
- for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++)
- {
- clearParams.clearColor[i] = true;
- }
- }
- }
-
- if (mask & GL_DEPTH_BUFFER_BIT)
- {
- if (mDepthStencil.depthMask && framebufferObject->getDepthbuffer() != NULL)
- {
- clearParams.clearDepth = true;
- }
- }
-
- if (mask & GL_STENCIL_BUFFER_BIT)
- {
- if (framebufferObject->getStencilbuffer() != NULL)
- {
- GLenum stencilActualFormat = framebufferObject->getStencilbuffer()->getActualFormat();
- if (GetInternalFormatInfo(stencilActualFormat).stencilBits > 0)
- {
- clearParams.clearStencil = true;
- }
- }
- }
-
- return clearParams;
-}
-
-void State::setColorMask(bool red, bool green, bool blue, bool alpha)
-{
- mBlend.colorMaskRed = red;
- mBlend.colorMaskGreen = green;
- mBlend.colorMaskBlue = blue;
- mBlend.colorMaskAlpha = alpha;
-}
-
-void State::setDepthMask(bool mask)
-{
- mDepthStencil.depthMask = mask;
-}
-
-bool State::isRasterizerDiscardEnabled() const
-{
- return mRasterizer.rasterizerDiscard;
-}
-
-void State::setRasterizerDiscard(bool enabled)
-{
- mRasterizer.rasterizerDiscard = enabled;
-}
-
-bool State::isCullFaceEnabled() const
-{
- return mRasterizer.cullFace;
-}
-
-void State::setCullFace(bool enabled)
-{
- mRasterizer.cullFace = enabled;
-}
-
-void State::setCullMode(GLenum mode)
-{
- mRasterizer.cullMode = mode;
-}
-
-void State::setFrontFace(GLenum front)
-{
- mRasterizer.frontFace = front;
-}
-
-bool State::isDepthTestEnabled() const
-{
- return mDepthStencil.depthTest;
-}
-
-void State::setDepthTest(bool enabled)
-{
- mDepthStencil.depthTest = enabled;
-}
-
-void State::setDepthFunc(GLenum depthFunc)
-{
- mDepthStencil.depthFunc = depthFunc;
-}
-
-void State::setDepthRange(float zNear, float zFar)
-{
- mNearZ = zNear;
- mFarZ = zFar;
-}
-
-void State::getDepthRange(float *zNear, float *zFar) const
-{
- *zNear = mNearZ;
- *zFar = mFarZ;
-}
-
-bool State::isBlendEnabled() const
-{
- return mBlend.blend;
-}
-
-void State::setBlend(bool enabled)
-{
- mBlend.blend = enabled;
-}
-
-void State::setBlendFactors(GLenum sourceRGB, GLenum destRGB, GLenum sourceAlpha, GLenum destAlpha)
-{
- mBlend.sourceBlendRGB = sourceRGB;
- mBlend.destBlendRGB = destRGB;
- mBlend.sourceBlendAlpha = sourceAlpha;
- mBlend.destBlendAlpha = destAlpha;
-}
-
-void State::setBlendColor(float red, float green, float blue, float alpha)
-{
- mBlendColor.red = red;
- mBlendColor.green = green;
- mBlendColor.blue = blue;
- mBlendColor.alpha = alpha;
-}
-
-void State::setBlendEquation(GLenum rgbEquation, GLenum alphaEquation)
-{
- mBlend.blendEquationRGB = rgbEquation;
- mBlend.blendEquationAlpha = alphaEquation;
-}
-
-const ColorF &State::getBlendColor() const
-{
- return mBlendColor;
-}
-
-bool State::isStencilTestEnabled() const
-{
- return mDepthStencil.stencilTest;
-}
-
-void State::setStencilTest(bool enabled)
-{
- mDepthStencil.stencilTest = enabled;
-}
-
-void State::setStencilParams(GLenum stencilFunc, GLint stencilRef, GLuint stencilMask)
-{
- mDepthStencil.stencilFunc = stencilFunc;
- mStencilRef = (stencilRef > 0) ? stencilRef : 0;
- mDepthStencil.stencilMask = stencilMask;
-}
-
-void State::setStencilBackParams(GLenum stencilBackFunc, GLint stencilBackRef, GLuint stencilBackMask)
-{
- mDepthStencil.stencilBackFunc = stencilBackFunc;
- mStencilBackRef = (stencilBackRef > 0) ? stencilBackRef : 0;
- mDepthStencil.stencilBackMask = stencilBackMask;
-}
-
-void State::setStencilWritemask(GLuint stencilWritemask)
-{
- mDepthStencil.stencilWritemask = stencilWritemask;
-}
-
-void State::setStencilBackWritemask(GLuint stencilBackWritemask)
-{
- mDepthStencil.stencilBackWritemask = stencilBackWritemask;
-}
-
-void State::setStencilOperations(GLenum stencilFail, GLenum stencilPassDepthFail, GLenum stencilPassDepthPass)
-{
- mDepthStencil.stencilFail = stencilFail;
- mDepthStencil.stencilPassDepthFail = stencilPassDepthFail;
- mDepthStencil.stencilPassDepthPass = stencilPassDepthPass;
-}
-
-void State::setStencilBackOperations(GLenum stencilBackFail, GLenum stencilBackPassDepthFail, GLenum stencilBackPassDepthPass)
-{
- mDepthStencil.stencilBackFail = stencilBackFail;
- mDepthStencil.stencilBackPassDepthFail = stencilBackPassDepthFail;
- mDepthStencil.stencilBackPassDepthPass = stencilBackPassDepthPass;
-}
-
-GLint State::getStencilRef() const
-{
- return mStencilRef;
-}
-
-GLint State::getStencilBackRef() const
-{
- return mStencilBackRef;
-}
-
-bool State::isPolygonOffsetFillEnabled() const
-{
- return mRasterizer.polygonOffsetFill;
-}
-
-void State::setPolygonOffsetFill(bool enabled)
-{
- mRasterizer.polygonOffsetFill = enabled;
-}
-
-void State::setPolygonOffsetParams(GLfloat factor, GLfloat units)
-{
- // An application can pass NaN values here, so handle this gracefully
- mRasterizer.polygonOffsetFactor = factor != factor ? 0.0f : factor;
- mRasterizer.polygonOffsetUnits = units != units ? 0.0f : units;
-}
-
-bool State::isSampleAlphaToCoverageEnabled() const
-{
- return mBlend.sampleAlphaToCoverage;
-}
-
-void State::setSampleAlphaToCoverage(bool enabled)
-{
- mBlend.sampleAlphaToCoverage = enabled;
-}
-
-bool State::isSampleCoverageEnabled() const
-{
- return mSampleCoverage;
-}
-
-void State::setSampleCoverage(bool enabled)
-{
- mSampleCoverage = enabled;
-}
-
-void State::setSampleCoverageParams(GLclampf value, bool invert)
-{
- mSampleCoverageValue = value;
- mSampleCoverageInvert = invert;
-}
-
-void State::getSampleCoverageParams(GLclampf *value, bool *invert) const
-{
- ASSERT(value != NULL && invert != NULL);
-
- *value = mSampleCoverageValue;
- *invert = mSampleCoverageInvert;
-}
-
-bool State::isScissorTestEnabled() const
-{
- return mScissorTest;
-}
-
-void State::setScissorTest(bool enabled)
-{
- mScissorTest = enabled;
-}
-
-void State::setScissorParams(GLint x, GLint y, GLsizei width, GLsizei height)
-{
- mScissor.x = x;
- mScissor.y = y;
- mScissor.width = width;
- mScissor.height = height;
-}
-
-const Rectangle &State::getScissor() const
-{
- return mScissor;
-}
-
-bool State::isDitherEnabled() const
-{
- return mBlend.dither;
-}
-
-void State::setDither(bool enabled)
-{
- mBlend.dither = enabled;
-}
-
-void State::setEnableFeature(GLenum feature, bool enabled)
-{
- switch (feature)
- {
- case GL_CULL_FACE: setCullFace(enabled); break;
- case GL_POLYGON_OFFSET_FILL: setPolygonOffsetFill(enabled); break;
- case GL_SAMPLE_ALPHA_TO_COVERAGE: setSampleAlphaToCoverage(enabled); break;
- case GL_SAMPLE_COVERAGE: setSampleCoverage(enabled); break;
- case GL_SCISSOR_TEST: setScissorTest(enabled); break;
- case GL_STENCIL_TEST: setStencilTest(enabled); break;
- case GL_DEPTH_TEST: setDepthTest(enabled); break;
- case GL_BLEND: setBlend(enabled); break;
- case GL_DITHER: setDither(enabled); break;
- case GL_PRIMITIVE_RESTART_FIXED_INDEX: UNIMPLEMENTED(); break;
- case GL_RASTERIZER_DISCARD: setRasterizerDiscard(enabled); break;
- default: UNREACHABLE();
- }
-}
-
-bool State::getEnableFeature(GLenum feature)
-{
- switch (feature)
- {
- case GL_CULL_FACE: return isCullFaceEnabled();
- case GL_POLYGON_OFFSET_FILL: return isPolygonOffsetFillEnabled();
- case GL_SAMPLE_ALPHA_TO_COVERAGE: return isSampleAlphaToCoverageEnabled();
- case GL_SAMPLE_COVERAGE: return isSampleCoverageEnabled();
- case GL_SCISSOR_TEST: return isScissorTestEnabled();
- case GL_STENCIL_TEST: return isStencilTestEnabled();
- case GL_DEPTH_TEST: return isDepthTestEnabled();
- case GL_BLEND: return isBlendEnabled();
- case GL_DITHER: return isDitherEnabled();
- case GL_PRIMITIVE_RESTART_FIXED_INDEX: UNIMPLEMENTED(); return false;
- case GL_RASTERIZER_DISCARD: return isRasterizerDiscardEnabled();
- default: UNREACHABLE(); return false;
- }
-}
-
-void State::setLineWidth(GLfloat width)
-{
- mLineWidth = width;
-}
-
-void State::setGenerateMipmapHint(GLenum hint)
-{
- mGenerateMipmapHint = hint;
-}
-
-void State::setFragmentShaderDerivativeHint(GLenum hint)
-{
- mFragmentShaderDerivativeHint = hint;
- // TODO: Propagate the hint to shader translator so we can write
- // ddx, ddx_coarse, or ddx_fine depending on the hint.
- // Ignore for now. It is valid for implementations to ignore hint.
-}
-
-void State::setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height)
-{
- mViewport.x = x;
- mViewport.y = y;
- mViewport.width = width;
- mViewport.height = height;
-}
-
-const Rectangle &State::getViewport() const
-{
- return mViewport;
-}
-
-void State::setActiveSampler(unsigned int active)
-{
- mActiveSampler = active;
-}
-
-unsigned int State::getActiveSampler() const
-{
- return mActiveSampler;
-}
-
-void State::setSamplerTexture(GLenum type, Texture *texture)
-{
- mSamplerTextures[type][mActiveSampler].set(texture);
-}
-
-Texture *State::getSamplerTexture(unsigned int sampler, GLenum type) const
-{
- return mSamplerTextures.at(type)[sampler].get();
-}
-
-GLuint State::getSamplerTextureId(unsigned int sampler, GLenum type) const
-{
- return mSamplerTextures.at(type)[sampler].id();
-}
-
-void State::detachTexture(const TextureMap &zeroTextures, GLuint texture)
-{
- // Textures have a detach method on State rather than a simple
- // removeBinding, because the zero/null texture objects are managed
- // separately, and don't have to go through the Context's maps or
- // the ResourceManager.
-
- // [OpenGL ES 2.0.24] section 3.8 page 84:
- // If a texture object is deleted, it is as if all texture units which are bound to that texture object are
- // rebound to texture object zero
-
- for (TextureBindingMap::iterator bindingVec = mSamplerTextures.begin(); bindingVec != mSamplerTextures.end(); bindingVec++)
- {
- GLenum textureType = bindingVec->first;
- TextureBindingVector &textureVector = bindingVec->second;
- for (size_t textureIdx = 0; textureIdx < textureVector.size(); textureIdx++)
- {
- BindingPointer<Texture> &binding = textureVector[textureIdx];
- if (binding.id() == texture)
- {
- // Zero textures are the "default" textures instead of NULL
- binding.set(zeroTextures.at(textureType).get());
- }
- }
- }
-
- // [OpenGL ES 2.0.24] section 4.4 page 112:
- // If a texture object is deleted while its image is attached to the currently bound framebuffer, then it is
- // as if Texture2DAttachment had been called, with a texture of 0, for each attachment point to which this
- // image was attached in the currently bound framebuffer.
-
- if (mReadFramebuffer)
- {
- mReadFramebuffer->detachTexture(texture);
- }
-
- if (mDrawFramebuffer)
- {
- mDrawFramebuffer->detachTexture(texture);
- }
-}
-
-void State::initializeZeroTextures(const TextureMap &zeroTextures)
-{
- for (TextureMap::const_iterator i = zeroTextures.begin(); i != zeroTextures.end(); i++)
- {
- TextureBindingVector &samplerTextureArray = mSamplerTextures[i->first];
-
- for (size_t textureUnit = 0; textureUnit < samplerTextureArray.size(); ++textureUnit)
- {
- samplerTextureArray[textureUnit].set(i->second.get());
- }
- }
-}
-
-void State::setSamplerBinding(GLuint textureUnit, Sampler *sampler)
-{
- mSamplers[textureUnit].set(sampler);
-}
-
-GLuint State::getSamplerId(GLuint textureUnit) const
-{
- ASSERT(textureUnit < mSamplers.size());
- return mSamplers[textureUnit].id();
-}
-
-Sampler *State::getSampler(GLuint textureUnit) const
-{
- return mSamplers[textureUnit].get();
-}
-
-void State::detachSampler(GLuint sampler)
-{
- // [OpenGL ES 3.0.2] section 3.8.2 pages 123-124:
- // If a sampler object that is currently bound to one or more texture units is
- // deleted, it is as though BindSampler is called once for each texture unit to
- // which the sampler is bound, with unit set to the texture unit and sampler set to zero.
- for (size_t textureUnit = 0; textureUnit < mSamplers.size(); textureUnit++)
- {
- BindingPointer<Sampler> &samplerBinding = mSamplers[textureUnit];
- if (samplerBinding.id() == sampler)
- {
- samplerBinding.set(NULL);
- }
- }
-}
-
-void State::setRenderbufferBinding(Renderbuffer *renderbuffer)
-{
- mRenderbuffer.set(renderbuffer);
-}
-
-GLuint State::getRenderbufferId() const
-{
- return mRenderbuffer.id();
-}
-
-Renderbuffer *State::getCurrentRenderbuffer()
-{
- return mRenderbuffer.get();
-}
-
-void State::detachRenderbuffer(GLuint renderbuffer)
-{
- // [OpenGL ES 2.0.24] section 4.4 page 109:
- // If a renderbuffer that is currently bound to RENDERBUFFER is deleted, it is as though BindRenderbuffer
- // had been executed with the target RENDERBUFFER and name of zero.
-
- if (mRenderbuffer.id() == renderbuffer)
- {
- mRenderbuffer.set(NULL);
- }
-
- // [OpenGL ES 2.0.24] section 4.4 page 111:
- // If a renderbuffer object is deleted while its image is attached to the currently bound framebuffer,
- // then it is as if FramebufferRenderbuffer had been called, with a renderbuffer of 0, for each attachment
- // point to which this image was attached in the currently bound framebuffer.
-
- Framebuffer *readFramebuffer = mReadFramebuffer;
- Framebuffer *drawFramebuffer = mDrawFramebuffer;
-
- if (readFramebuffer)
- {
- readFramebuffer->detachRenderbuffer(renderbuffer);
- }
-
- if (drawFramebuffer && drawFramebuffer != readFramebuffer)
- {
- drawFramebuffer->detachRenderbuffer(renderbuffer);
- }
-
-}
-
-void State::setReadFramebufferBinding(Framebuffer *framebuffer)
-{
- mReadFramebuffer = framebuffer;
-}
-
-void State::setDrawFramebufferBinding(Framebuffer *framebuffer)
-{
- mDrawFramebuffer = framebuffer;
-}
-
-Framebuffer *State::getTargetFramebuffer(GLenum target) const
-{
- switch (target)
- {
- case GL_READ_FRAMEBUFFER_ANGLE: return mReadFramebuffer;
- case GL_DRAW_FRAMEBUFFER_ANGLE:
- case GL_FRAMEBUFFER: return mDrawFramebuffer;
- default: UNREACHABLE(); return NULL;
- }
-}
-
-Framebuffer *State::getReadFramebuffer()
-{
- return mReadFramebuffer;
-}
-
-Framebuffer *State::getDrawFramebuffer()
-{
- return mDrawFramebuffer;
-}
-
-const Framebuffer *State::getReadFramebuffer() const
-{
- return mReadFramebuffer;
-}
-
-const Framebuffer *State::getDrawFramebuffer() const
-{
- return mDrawFramebuffer;
-}
-
-bool State::removeReadFramebufferBinding(GLuint framebuffer)
-{
- if (mReadFramebuffer->id() == framebuffer)
- {
- mReadFramebuffer = NULL;
- return true;
- }
-
- return false;
-}
-
-bool State::removeDrawFramebufferBinding(GLuint framebuffer)
-{
- if (mDrawFramebuffer->id() == framebuffer)
- {
- mDrawFramebuffer = NULL;
- return true;
- }
-
- return false;
-}
-
-void State::setVertexArrayBinding(VertexArray *vertexArray)
-{
- mVertexArray = vertexArray;
-}
-
-GLuint State::getVertexArrayId() const
-{
- ASSERT(mVertexArray != NULL);
- return mVertexArray->id();
-}
-
-VertexArray *State::getVertexArray() const
-{
- ASSERT(mVertexArray != NULL);
- return mVertexArray;
-}
-
-bool State::removeVertexArrayBinding(GLuint vertexArray)
-{
- if (mVertexArray->id() == vertexArray)
- {
- mVertexArray = NULL;
- return true;
- }
-
- return false;
-}
-
-void State::setCurrentProgram(GLuint programId, Program *newProgram)
-{
- mCurrentProgramId = programId; // set new ID before trying to delete program binary; otherwise it will only be flagged for deletion
- mCurrentProgramBinary.set(NULL);
-
- if (newProgram)
- {
- newProgram->addRef();
- mCurrentProgramBinary.set(newProgram->getProgramBinary());
- }
-}
-
-void State::setCurrentProgramBinary(ProgramBinary *binary)
-{
- mCurrentProgramBinary.set(binary);
-}
-
-GLuint State::getCurrentProgramId() const
-{
- return mCurrentProgramId;
-}
-
-ProgramBinary *State::getCurrentProgramBinary() const
-{
- return mCurrentProgramBinary.get();
-}
-
-void State::setTransformFeedbackBinding(TransformFeedback *transformFeedback)
-{
- mTransformFeedback.set(transformFeedback);
-}
-
-TransformFeedback *State::getCurrentTransformFeedback() const
-{
- return mTransformFeedback.get();
-}
-
-void State::detachTransformFeedback(GLuint transformFeedback)
-{
- if (mTransformFeedback.id() == transformFeedback)
- {
- mTransformFeedback.set(NULL);
- }
-}
-
-bool State::isQueryActive() const
-{
- for (State::ActiveQueryMap::const_iterator i = mActiveQueries.begin();
- i != mActiveQueries.end(); i++)
- {
- if (i->second.get() != NULL)
- {
- return true;
- }
- }
-
- return false;
-}
-
-void State::setActiveQuery(GLenum target, Query *query)
-{
- mActiveQueries[target].set(query);
-}
-
-GLuint State::getActiveQueryId(GLenum target) const
-{
- const Query *query = getActiveQuery(target);
- return (query ? query->id() : 0u);
-}
-
-Query *State::getActiveQuery(GLenum target) const
-{
- // All query types should already exist in the activeQueries map
- ASSERT(mActiveQueries.find(target) != mActiveQueries.end());
-
- return mActiveQueries.at(target).get();
-}
-
-void State::setArrayBufferBinding(Buffer *buffer)
-{
- mArrayBuffer.set(buffer);
-}
-
-GLuint State::getArrayBufferId() const
-{
- return mArrayBuffer.id();
-}
-
-bool State::removeArrayBufferBinding(GLuint buffer)
-{
- if (mArrayBuffer.id() == buffer)
- {
- mArrayBuffer.set(NULL);
- return true;
- }
-
- return false;
-}
-
-void State::setGenericUniformBufferBinding(Buffer *buffer)
-{
- mGenericUniformBuffer.set(buffer);
-}
-
-void State::setIndexedUniformBufferBinding(GLuint index, Buffer *buffer, GLintptr offset, GLsizeiptr size)
-{
- mUniformBuffers[index].set(buffer, offset, size);
-}
-
-GLuint State::getIndexedUniformBufferId(GLuint index) const
-{
- ASSERT(static_cast<size_t>(index) < mUniformBuffers.size());
-
- return mUniformBuffers[index].id();
-}
-
-Buffer *State::getIndexedUniformBuffer(GLuint index) const
-{
- ASSERT(static_cast<size_t>(index) < mUniformBuffers.size());
-
- return mUniformBuffers[index].get();
-}
-
-void State::setGenericTransformFeedbackBufferBinding(Buffer *buffer)
-{
- mGenericTransformFeedbackBuffer.set(buffer);
-}
-
-void State::setIndexedTransformFeedbackBufferBinding(GLuint index, Buffer *buffer, GLintptr offset, GLsizeiptr size)
-{
- mTransformFeedbackBuffers[index].set(buffer, offset, size);
-}
-
-GLuint State::getIndexedTransformFeedbackBufferId(GLuint index) const
-{
- ASSERT(static_cast<size_t>(index) < mTransformFeedbackBuffers.size());
-
- return mTransformFeedbackBuffers[index].id();
-}
-
-Buffer *State::getIndexedTransformFeedbackBuffer(GLuint index) const
-{
- ASSERT(static_cast<size_t>(index) < mTransformFeedbackBuffers.size());
-
- return mTransformFeedbackBuffers[index].get();
-}
-
-GLuint State::getIndexedTransformFeedbackBufferOffset(GLuint index) const
-{
- ASSERT(static_cast<size_t>(index) < mTransformFeedbackBuffers.size());
-
- return mTransformFeedbackBuffers[index].getOffset();
-}
-
-size_t State::getTransformFeedbackBufferIndexRange() const
-{
- return mTransformFeedbackBuffers.size();
-}
-
-void State::setCopyReadBufferBinding(Buffer *buffer)
-{
- mCopyReadBuffer.set(buffer);
-}
-
-void State::setCopyWriteBufferBinding(Buffer *buffer)
-{
- mCopyWriteBuffer.set(buffer);
-}
-
-void State::setPixelPackBufferBinding(Buffer *buffer)
-{
- mPack.pixelBuffer.set(buffer);
-}
-
-void State::setPixelUnpackBufferBinding(Buffer *buffer)
-{
- mUnpack.pixelBuffer.set(buffer);
-}
-
-Buffer *State::getTargetBuffer(GLenum target) const
-{
- switch (target)
- {
- case GL_ARRAY_BUFFER: return mArrayBuffer.get();
- case GL_COPY_READ_BUFFER: return mCopyReadBuffer.get();
- case GL_COPY_WRITE_BUFFER: return mCopyWriteBuffer.get();
- case GL_ELEMENT_ARRAY_BUFFER: return getVertexArray()->getElementArrayBuffer();
- case GL_PIXEL_PACK_BUFFER: return mPack.pixelBuffer.get();
- case GL_PIXEL_UNPACK_BUFFER: return mUnpack.pixelBuffer.get();
- case GL_TRANSFORM_FEEDBACK_BUFFER: return mGenericTransformFeedbackBuffer.get();
- case GL_UNIFORM_BUFFER: return mGenericUniformBuffer.get();
- default: UNREACHABLE(); return NULL;
- }
-}
-
-void State::setEnableVertexAttribArray(unsigned int attribNum, bool enabled)
-{
- getVertexArray()->enableAttribute(attribNum, enabled);
-}
-
-void State::setVertexAttribf(GLuint index, const GLfloat values[4])
-{
- ASSERT(static_cast<size_t>(index) < mVertexAttribCurrentValues.size());
- mVertexAttribCurrentValues[index].setFloatValues(values);
-}
-
-void State::setVertexAttribu(GLuint index, const GLuint values[4])
-{
- ASSERT(static_cast<size_t>(index) < mVertexAttribCurrentValues.size());
- mVertexAttribCurrentValues[index].setUnsignedIntValues(values);
-}
-
-void State::setVertexAttribi(GLuint index, const GLint values[4])
-{
- ASSERT(static_cast<size_t>(index) < mVertexAttribCurrentValues.size());
- mVertexAttribCurrentValues[index].setIntValues(values);
-}
-
-void State::setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type, bool normalized,
- bool pureInteger, GLsizei stride, const void *pointer)
-{
- getVertexArray()->setAttributeState(attribNum, boundBuffer, size, type, normalized, pureInteger, stride, pointer);
-}
-
-const VertexAttribute &State::getVertexAttribState(unsigned int attribNum) const
-{
- return getVertexArray()->getVertexAttribute(attribNum);
-}
-
-const VertexAttribCurrentValueData &State::getVertexAttribCurrentValue(unsigned int attribNum) const
-{
- ASSERT(static_cast<size_t>(attribNum) < mVertexAttribCurrentValues.size());
- return mVertexAttribCurrentValues[attribNum];
-}
-
-const void *State::getVertexAttribPointer(unsigned int attribNum) const
-{
- return getVertexArray()->getVertexAttribute(attribNum).pointer;
-}
-
-void State::setPackAlignment(GLint alignment)
-{
- mPack.alignment = alignment;
-}
-
-GLint State::getPackAlignment() const
-{
- return mPack.alignment;
-}
-
-void State::setPackReverseRowOrder(bool reverseRowOrder)
-{
- mPack.reverseRowOrder = reverseRowOrder;
-}
-
-bool State::getPackReverseRowOrder() const
-{
- return mPack.reverseRowOrder;
-}
-
-const PixelPackState &State::getPackState() const
-{
- return mPack;
-}
-
-void State::setUnpackAlignment(GLint alignment)
-{
- mUnpack.alignment = alignment;
-}
-
-GLint State::getUnpackAlignment() const
-{
- return mUnpack.alignment;
-}
-
-const PixelUnpackState &State::getUnpackState() const
-{
- return mUnpack;
-}
-
-void State::getBooleanv(GLenum pname, GLboolean *params)
-{
- switch (pname)
- {
- case GL_SAMPLE_COVERAGE_INVERT: *params = mSampleCoverageInvert; break;
- case GL_DEPTH_WRITEMASK: *params = mDepthStencil.depthMask; break;
- case GL_COLOR_WRITEMASK:
- params[0] = mBlend.colorMaskRed;
- params[1] = mBlend.colorMaskGreen;
- params[2] = mBlend.colorMaskBlue;
- params[3] = mBlend.colorMaskAlpha;
- break;
- case GL_CULL_FACE: *params = mRasterizer.cullFace; break;
- case GL_POLYGON_OFFSET_FILL: *params = mRasterizer.polygonOffsetFill; break;
- case GL_SAMPLE_ALPHA_TO_COVERAGE: *params = mBlend.sampleAlphaToCoverage; break;
- case GL_SAMPLE_COVERAGE: *params = mSampleCoverage; break;
- case GL_SCISSOR_TEST: *params = mScissorTest; break;
- case GL_STENCIL_TEST: *params = mDepthStencil.stencilTest; break;
- case GL_DEPTH_TEST: *params = mDepthStencil.depthTest; break;
- case GL_BLEND: *params = mBlend.blend; break;
- case GL_DITHER: *params = mBlend.dither; break;
- case GL_TRANSFORM_FEEDBACK_ACTIVE: *params = getCurrentTransformFeedback()->isStarted(); break;
- case GL_TRANSFORM_FEEDBACK_PAUSED: *params = getCurrentTransformFeedback()->isPaused(); break;
- default:
- UNREACHABLE();
- break;
- }
-}
-
-void State::getFloatv(GLenum pname, GLfloat *params)
-{
- // Please note: DEPTH_CLEAR_VALUE is included in our internal getFloatv implementation
- // because it is stored as a float, despite the fact that the GL ES 2.0 spec names
- // GetIntegerv as its native query function. As it would require conversion in any
- // case, this should make no difference to the calling application.
- switch (pname)
- {
- case GL_LINE_WIDTH: *params = mLineWidth; break;
- case GL_SAMPLE_COVERAGE_VALUE: *params = mSampleCoverageValue; break;
- case GL_DEPTH_CLEAR_VALUE: *params = mDepthClearValue; break;
- case GL_POLYGON_OFFSET_FACTOR: *params = mRasterizer.polygonOffsetFactor; break;
- case GL_POLYGON_OFFSET_UNITS: *params = mRasterizer.polygonOffsetUnits; break;
- case GL_DEPTH_RANGE:
- params[0] = mNearZ;
- params[1] = mFarZ;
- break;
- case GL_COLOR_CLEAR_VALUE:
- params[0] = mColorClearValue.red;
- params[1] = mColorClearValue.green;
- params[2] = mColorClearValue.blue;
- params[3] = mColorClearValue.alpha;
- break;
- case GL_BLEND_COLOR:
- params[0] = mBlendColor.red;
- params[1] = mBlendColor.green;
- params[2] = mBlendColor.blue;
- params[3] = mBlendColor.alpha;
- break;
- default:
- UNREACHABLE();
- break;
- }
-}
-
-void State::getIntegerv(const gl::Data &data, GLenum pname, GLint *params)
-{
- if (pname >= GL_DRAW_BUFFER0_EXT && pname <= GL_DRAW_BUFFER15_EXT)
- {
- unsigned int colorAttachment = (pname - GL_DRAW_BUFFER0_EXT);
- ASSERT(colorAttachment < mMaxDrawBuffers);
- Framebuffer *framebuffer = mDrawFramebuffer;
- *params = framebuffer->getDrawBufferState(colorAttachment);
- return;
- }
-
- // Please note: DEPTH_CLEAR_VALUE is not included in our internal getIntegerv implementation
- // because it is stored as a float, despite the fact that the GL ES 2.0 spec names
- // GetIntegerv as its native query function. As it would require conversion in any
- // case, this should make no difference to the calling application. You may find it in
- // State::getFloatv.
- switch (pname)
- {
- case GL_ARRAY_BUFFER_BINDING: *params = mArrayBuffer.id(); break;
- case GL_ELEMENT_ARRAY_BUFFER_BINDING: *params = getVertexArray()->getElementArrayBufferId(); break;
- //case GL_FRAMEBUFFER_BINDING: // now equivalent to GL_DRAW_FRAMEBUFFER_BINDING_ANGLE
- case GL_DRAW_FRAMEBUFFER_BINDING_ANGLE: *params = mDrawFramebuffer->id(); break;
- case GL_READ_FRAMEBUFFER_BINDING_ANGLE: *params = mReadFramebuffer->id(); break;
- case GL_RENDERBUFFER_BINDING: *params = mRenderbuffer.id(); break;
- case GL_VERTEX_ARRAY_BINDING: *params = mVertexArray->id(); break;
- case GL_CURRENT_PROGRAM: *params = mCurrentProgramId; break;
- case GL_PACK_ALIGNMENT: *params = mPack.alignment; break;
- case GL_PACK_REVERSE_ROW_ORDER_ANGLE: *params = mPack.reverseRowOrder; break;
- case GL_UNPACK_ALIGNMENT: *params = mUnpack.alignment; break;
- case GL_GENERATE_MIPMAP_HINT: *params = mGenerateMipmapHint; break;
- case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: *params = mFragmentShaderDerivativeHint; break;
- case GL_ACTIVE_TEXTURE: *params = (mActiveSampler + GL_TEXTURE0); break;
- case GL_STENCIL_FUNC: *params = mDepthStencil.stencilFunc; break;
- case GL_STENCIL_REF: *params = mStencilRef; break;
- case GL_STENCIL_VALUE_MASK: *params = clampToInt(mDepthStencil.stencilMask); break;
- case GL_STENCIL_BACK_FUNC: *params = mDepthStencil.stencilBackFunc; break;
- case GL_STENCIL_BACK_REF: *params = mStencilBackRef; break;
- case GL_STENCIL_BACK_VALUE_MASK: *params = clampToInt(mDepthStencil.stencilBackMask); break;
- case GL_STENCIL_FAIL: *params = mDepthStencil.stencilFail; break;
- case GL_STENCIL_PASS_DEPTH_FAIL: *params = mDepthStencil.stencilPassDepthFail; break;
- case GL_STENCIL_PASS_DEPTH_PASS: *params = mDepthStencil.stencilPassDepthPass; break;
- case GL_STENCIL_BACK_FAIL: *params = mDepthStencil.stencilBackFail; break;
- case GL_STENCIL_BACK_PASS_DEPTH_FAIL: *params = mDepthStencil.stencilBackPassDepthFail; break;
- case GL_STENCIL_BACK_PASS_DEPTH_PASS: *params = mDepthStencil.stencilBackPassDepthPass; break;
- case GL_DEPTH_FUNC: *params = mDepthStencil.depthFunc; break;
- case GL_BLEND_SRC_RGB: *params = mBlend.sourceBlendRGB; break;
- case GL_BLEND_SRC_ALPHA: *params = mBlend.sourceBlendAlpha; break;
- case GL_BLEND_DST_RGB: *params = mBlend.destBlendRGB; break;
- case GL_BLEND_DST_ALPHA: *params = mBlend.destBlendAlpha; break;
- case GL_BLEND_EQUATION_RGB: *params = mBlend.blendEquationRGB; break;
- case GL_BLEND_EQUATION_ALPHA: *params = mBlend.blendEquationAlpha; break;
- case GL_STENCIL_WRITEMASK: *params = clampToInt(mDepthStencil.stencilWritemask); break;
- case GL_STENCIL_BACK_WRITEMASK: *params = clampToInt(mDepthStencil.stencilBackWritemask); break;
- case GL_STENCIL_CLEAR_VALUE: *params = mStencilClearValue; break;
- case GL_SAMPLE_BUFFERS:
- case GL_SAMPLES:
- {
- gl::Framebuffer *framebuffer = mDrawFramebuffer;
- if (framebuffer->completeness(data) == GL_FRAMEBUFFER_COMPLETE)
- {
- switch (pname)
- {
- case GL_SAMPLE_BUFFERS:
- if (framebuffer->getSamples(data) != 0)
- {
- *params = 1;
- }
- else
- {
- *params = 0;
- }
- break;
- case GL_SAMPLES:
- *params = framebuffer->getSamples(data);
- break;
- }
- }
- else
- {
- *params = 0;
- }
- }
- break;
- case GL_VIEWPORT:
- params[0] = mViewport.x;
- params[1] = mViewport.y;
- params[2] = mViewport.width;
- params[3] = mViewport.height;
- break;
- case GL_SCISSOR_BOX:
- params[0] = mScissor.x;
- params[1] = mScissor.y;
- params[2] = mScissor.width;
- params[3] = mScissor.height;
- break;
- case GL_CULL_FACE_MODE: *params = mRasterizer.cullMode; break;
- case GL_FRONT_FACE: *params = mRasterizer.frontFace; break;
- case GL_RED_BITS:
- case GL_GREEN_BITS:
- case GL_BLUE_BITS:
- case GL_ALPHA_BITS:
- {
- gl::Framebuffer *framebuffer = getDrawFramebuffer();
- gl::FramebufferAttachment *colorbuffer = framebuffer->getFirstColorbuffer();
-
- if (colorbuffer)
- {
- switch (pname)
- {
- case GL_RED_BITS: *params = colorbuffer->getRedSize(); break;
- case GL_GREEN_BITS: *params = colorbuffer->getGreenSize(); break;
- case GL_BLUE_BITS: *params = colorbuffer->getBlueSize(); break;
- case GL_ALPHA_BITS: *params = colorbuffer->getAlphaSize(); break;
- }
- }
- else
- {
- *params = 0;
- }
- }
- break;
- case GL_DEPTH_BITS:
- {
- gl::Framebuffer *framebuffer = getDrawFramebuffer();
- gl::FramebufferAttachment *depthbuffer = framebuffer->getDepthbuffer();
-
- if (depthbuffer)
- {
- *params = depthbuffer->getDepthSize();
- }
- else
- {
- *params = 0;
- }
- }
- break;
- case GL_STENCIL_BITS:
- {
- gl::Framebuffer *framebuffer = getDrawFramebuffer();
- gl::FramebufferAttachment *stencilbuffer = framebuffer->getStencilbuffer();
-
- if (stencilbuffer)
- {
- *params = stencilbuffer->getStencilSize();
- }
- else
- {
- *params = 0;
- }
- }
- break;
- case GL_TEXTURE_BINDING_2D:
- ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits);
- *params = mSamplerTextures.at(GL_TEXTURE_2D)[mActiveSampler].id();
- break;
- case GL_TEXTURE_BINDING_CUBE_MAP:
- ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits);
- *params = mSamplerTextures.at(GL_TEXTURE_CUBE_MAP)[mActiveSampler].id();
- break;
- case GL_TEXTURE_BINDING_3D:
- ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits);
- *params = mSamplerTextures.at(GL_TEXTURE_3D)[mActiveSampler].id();
- break;
- case GL_TEXTURE_BINDING_2D_ARRAY:
- ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits);
- *params = mSamplerTextures.at(GL_TEXTURE_2D_ARRAY)[mActiveSampler].id();
- break;
- case GL_UNIFORM_BUFFER_BINDING:
- *params = mGenericUniformBuffer.id();
- break;
- case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
- *params = mGenericTransformFeedbackBuffer.id();
- break;
- case GL_COPY_READ_BUFFER_BINDING:
- *params = mCopyReadBuffer.id();
- break;
- case GL_COPY_WRITE_BUFFER_BINDING:
- *params = mCopyWriteBuffer.id();
- break;
- case GL_PIXEL_PACK_BUFFER_BINDING:
- *params = mPack.pixelBuffer.id();
- break;
- case GL_PIXEL_UNPACK_BUFFER_BINDING:
- *params = mUnpack.pixelBuffer.id();
- break;
- default:
- UNREACHABLE();
- break;
- }
-}
-
-bool State::getIndexedIntegerv(GLenum target, GLuint index, GLint *data)
-{
- switch (target)
- {
- case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
- if (static_cast<size_t>(index) < mTransformFeedbackBuffers.size())
- {
- *data = mTransformFeedbackBuffers[index].id();
- }
- break;
- case GL_UNIFORM_BUFFER_BINDING:
- if (static_cast<size_t>(index) < mUniformBuffers.size())
- {
- *data = mUniformBuffers[index].id();
- }
- break;
- default:
- return false;
- }
-
- return true;
-}
-
-bool State::getIndexedInteger64v(GLenum target, GLuint index, GLint64 *data)
-{
- switch (target)
- {
- case GL_TRANSFORM_FEEDBACK_BUFFER_START:
- if (static_cast<size_t>(index) < mTransformFeedbackBuffers.size())
- {
- *data = mTransformFeedbackBuffers[index].getOffset();
- }
- break;
- case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
- if (static_cast<size_t>(index) < mTransformFeedbackBuffers.size())
- {
- *data = mTransformFeedbackBuffers[index].getSize();
- }
- break;
- case GL_UNIFORM_BUFFER_START:
- if (static_cast<size_t>(index) < mUniformBuffers.size())
- {
- *data = mUniformBuffers[index].getOffset();
- }
- break;
- case GL_UNIFORM_BUFFER_SIZE:
- if (static_cast<size_t>(index) < mUniformBuffers.size())
- {
- *data = mUniformBuffers[index].getSize();
- }
- break;
- default:
- return false;
- }
-
- return true;
-}
-
-bool State::hasMappedBuffer(GLenum target) const
-{
- if (target == GL_ARRAY_BUFFER)
- {
- for (size_t attribIndex = 0; attribIndex < mVertexAttribCurrentValues.size(); attribIndex++)
- {
- const gl::VertexAttribute &vertexAttrib = getVertexAttribState(static_cast<unsigned int>(attribIndex));
- gl::Buffer *boundBuffer = vertexAttrib.buffer.get();
- if (vertexAttrib.enabled && boundBuffer && boundBuffer->isMapped())
- {
- return true;
- }
- }
-
- return false;
- }
- else
- {
- Buffer *buffer = getTargetBuffer(target);
- return (buffer && buffer->isMapped());
- }
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/State.h b/src/3rdparty/angle/src/libGLESv2/State.h
deleted file mode 100644
index c3e6106bd8..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/State.h
+++ /dev/null
@@ -1,325 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// State.h: Defines the State class, encapsulating raw GL state
-
-#ifndef LIBGLESV2_STATE_H_
-#define LIBGLESV2_STATE_H_
-
-#include "common/angleutils.h"
-#include "common/RefCountObject.h"
-#include "libGLESv2/angletypes.h"
-#include "libGLESv2/VertexAttribute.h"
-#include "libGLESv2/Renderbuffer.h"
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/TransformFeedback.h"
-#include "libGLESv2/Program.h"
-#include "libGLESv2/Sampler.h"
-
-namespace gl
-{
-class Query;
-class VertexArray;
-class Context;
-struct Caps;
-struct Data;
-
-typedef std::map< GLenum, BindingPointer<Texture> > TextureMap;
-
-class State
-{
- public:
- State();
- ~State();
-
- void initialize(const Caps& caps, GLuint clientVersion);
- void reset();
-
- // State chunk getters
- const RasterizerState &getRasterizerState() const;
- const BlendState &getBlendState() const;
- const DepthStencilState &getDepthStencilState() const;
-
- // Clear behavior setters & state parameter block generation function
- void setClearColor(float red, float green, float blue, float alpha);
- void setClearDepth(float depth);
- void setClearStencil(int stencil);
- ClearParameters getClearParameters(GLbitfield mask) const;
-
- // Write mask manipulation
- void setColorMask(bool red, bool green, bool blue, bool alpha);
- void setDepthMask(bool mask);
-
- // Discard toggle & query
- bool isRasterizerDiscardEnabled() const;
- void setRasterizerDiscard(bool enabled);
-
- // Face culling state manipulation
- bool isCullFaceEnabled() const;
- void setCullFace(bool enabled);
- void setCullMode(GLenum mode);
- void setFrontFace(GLenum front);
-
- // Depth test state manipulation
- bool isDepthTestEnabled() const;
- void setDepthTest(bool enabled);
- void setDepthFunc(GLenum depthFunc);
- void setDepthRange(float zNear, float zFar);
- void getDepthRange(float *zNear, float *zFar) const;
-
- // Blend state manipulation
- bool isBlendEnabled() const;
- void setBlend(bool enabled);
- void setBlendFactors(GLenum sourceRGB, GLenum destRGB, GLenum sourceAlpha, GLenum destAlpha);
- void setBlendColor(float red, float green, float blue, float alpha);
- void setBlendEquation(GLenum rgbEquation, GLenum alphaEquation);
- const ColorF &getBlendColor() const;
-
- // Stencil state maniupulation
- bool isStencilTestEnabled() const;
- void setStencilTest(bool enabled);
- void setStencilParams(GLenum stencilFunc, GLint stencilRef, GLuint stencilMask);
- void setStencilBackParams(GLenum stencilBackFunc, GLint stencilBackRef, GLuint stencilBackMask);
- void setStencilWritemask(GLuint stencilWritemask);
- void setStencilBackWritemask(GLuint stencilBackWritemask);
- void setStencilOperations(GLenum stencilFail, GLenum stencilPassDepthFail, GLenum stencilPassDepthPass);
- void setStencilBackOperations(GLenum stencilBackFail, GLenum stencilBackPassDepthFail, GLenum stencilBackPassDepthPass);
- GLint getStencilRef() const;
- GLint getStencilBackRef() const;
-
- // Depth bias/polygon offset state manipulation
- bool isPolygonOffsetFillEnabled() const;
- void setPolygonOffsetFill(bool enabled);
- void setPolygonOffsetParams(GLfloat factor, GLfloat units);
-
- // Multisample coverage state manipulation
- bool isSampleAlphaToCoverageEnabled() const;
- void setSampleAlphaToCoverage(bool enabled);
- bool isSampleCoverageEnabled() const;
- void setSampleCoverage(bool enabled);
- void setSampleCoverageParams(GLclampf value, bool invert);
- void getSampleCoverageParams(GLclampf *value, bool *invert) const;
-
- // Scissor test state toggle & query
- bool isScissorTestEnabled() const;
- void setScissorTest(bool enabled);
- void setScissorParams(GLint x, GLint y, GLsizei width, GLsizei height);
- const Rectangle &getScissor() const;
-
- // Dither state toggle & query
- bool isDitherEnabled() const;
- void setDither(bool enabled);
-
- // Generic state toggle & query
- void setEnableFeature(GLenum feature, bool enabled);
- bool getEnableFeature(GLenum feature);
-
- // Line width state setter
- void setLineWidth(GLfloat width);
-
- // Hint setters
- void setGenerateMipmapHint(GLenum hint);
- void setFragmentShaderDerivativeHint(GLenum hint);
-
- // Viewport state setter/getter
- void setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height);
- const Rectangle &getViewport() const;
-
- // Texture binding & active texture unit manipulation
- void setActiveSampler(unsigned int active);
- unsigned int getActiveSampler() const;
- void setSamplerTexture(GLenum type, Texture *texture);
- Texture *getSamplerTexture(unsigned int sampler, GLenum type) const;
- GLuint getSamplerTextureId(unsigned int sampler, GLenum type) const;
- void detachTexture(const TextureMap &zeroTextures, GLuint texture);
- void initializeZeroTextures(const TextureMap &zeroTextures);
-
- // Sampler object binding manipulation
- void setSamplerBinding(GLuint textureUnit, Sampler *sampler);
- GLuint getSamplerId(GLuint textureUnit) const;
- Sampler *getSampler(GLuint textureUnit) const;
- void detachSampler(GLuint sampler);
-
- // Renderbuffer binding manipulation
- void setRenderbufferBinding(Renderbuffer *renderbuffer);
- GLuint getRenderbufferId() const;
- Renderbuffer *getCurrentRenderbuffer();
- void detachRenderbuffer(GLuint renderbuffer);
-
- // Framebuffer binding manipulation
- void setReadFramebufferBinding(Framebuffer *framebuffer);
- void setDrawFramebufferBinding(Framebuffer *framebuffer);
- Framebuffer *getTargetFramebuffer(GLenum target) const;
- Framebuffer *getReadFramebuffer();
- Framebuffer *getDrawFramebuffer();
- const Framebuffer *getReadFramebuffer() const;
- const Framebuffer *getDrawFramebuffer() const;
- bool removeReadFramebufferBinding(GLuint framebuffer);
- bool removeDrawFramebufferBinding(GLuint framebuffer);
-
- // Vertex array object binding manipulation
- void setVertexArrayBinding(VertexArray *vertexArray);
- GLuint getVertexArrayId() const;
- VertexArray *getVertexArray() const;
- bool removeVertexArrayBinding(GLuint vertexArray);
-
- // Program binding manipulation
- void setCurrentProgram(GLuint programId, Program *newProgram);
- void setCurrentProgramBinary(ProgramBinary *binary);
- GLuint getCurrentProgramId() const;
- ProgramBinary *getCurrentProgramBinary() const;
-
- // Transform feedback object (not buffer) binding manipulation
- void setTransformFeedbackBinding(TransformFeedback *transformFeedback);
- TransformFeedback *getCurrentTransformFeedback() const;
- void detachTransformFeedback(GLuint transformFeedback);
-
- // Query binding manipulation
- bool isQueryActive() const;
- void setActiveQuery(GLenum target, Query *query);
- GLuint getActiveQueryId(GLenum target) const;
- Query *getActiveQuery(GLenum target) const;
-
- //// Typed buffer binding point manipulation ////
- // GL_ARRAY_BUFFER
- void setArrayBufferBinding(Buffer *buffer);
- GLuint getArrayBufferId() const;
- bool removeArrayBufferBinding(GLuint buffer);
-
- // GL_UNIFORM_BUFFER - Both indexed and generic targets
- void setGenericUniformBufferBinding(Buffer *buffer);
- void setIndexedUniformBufferBinding(GLuint index, Buffer *buffer, GLintptr offset, GLsizeiptr size);
- GLuint getIndexedUniformBufferId(GLuint index) const;
- Buffer *getIndexedUniformBuffer(GLuint index) const;
-
- // GL_TRANSFORM_FEEDBACK_BUFFER - Both indexed and generic targets
- void setGenericTransformFeedbackBufferBinding(Buffer *buffer);
- void setIndexedTransformFeedbackBufferBinding(GLuint index, Buffer *buffer, GLintptr offset, GLsizeiptr size);
- GLuint getIndexedTransformFeedbackBufferId(GLuint index) const;
- Buffer *getIndexedTransformFeedbackBuffer(GLuint index) const;
- GLuint getIndexedTransformFeedbackBufferOffset(GLuint index) const;
- size_t getTransformFeedbackBufferIndexRange() const;
-
- // GL_COPY_[READ/WRITE]_BUFFER
- void setCopyReadBufferBinding(Buffer *buffer);
- void setCopyWriteBufferBinding(Buffer *buffer);
-
- // GL_PIXEL[PACK/UNPACK]_BUFFER
- void setPixelPackBufferBinding(Buffer *buffer);
- void setPixelUnpackBufferBinding(Buffer *buffer);
-
- // Retrieve typed buffer by target (non-indexed)
- Buffer *getTargetBuffer(GLenum target) const;
-
- // Vertex attrib manipulation
- void setEnableVertexAttribArray(unsigned int attribNum, bool enabled);
- void setVertexAttribf(GLuint index, const GLfloat values[4]);
- void setVertexAttribu(GLuint index, const GLuint values[4]);
- void setVertexAttribi(GLuint index, const GLint values[4]);
- void setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type,
- bool normalized, bool pureInteger, GLsizei stride, const void *pointer);
- const VertexAttribute &getVertexAttribState(unsigned int attribNum) const;
- const VertexAttribCurrentValueData &getVertexAttribCurrentValue(unsigned int attribNum) const;
- const void *getVertexAttribPointer(unsigned int attribNum) const;
-
- // Pixel pack state manipulation
- void setPackAlignment(GLint alignment);
- GLint getPackAlignment() const;
- void setPackReverseRowOrder(bool reverseRowOrder);
- bool getPackReverseRowOrder() const;
- const PixelPackState &getPackState() const;
-
- // Pixel unpack state manipulation
- void setUnpackAlignment(GLint alignment);
- GLint getUnpackAlignment() const;
- const PixelUnpackState &getUnpackState() const;
-
- // State query functions
- void getBooleanv(GLenum pname, GLboolean *params);
- void getFloatv(GLenum pname, GLfloat *params);
- void getIntegerv(const gl::Data &data, GLenum pname, GLint *params);
- bool getIndexedIntegerv(GLenum target, GLuint index, GLint *data);
- bool getIndexedInteger64v(GLenum target, GLuint index, GLint64 *data);
-
- bool hasMappedBuffer(GLenum target) const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(State);
-
- // Cached values from Context's caps
- GLuint mMaxDrawBuffers;
- GLuint mMaxCombinedTextureImageUnits;
-
- ColorF mColorClearValue;
- GLclampf mDepthClearValue;
- int mStencilClearValue;
-
- RasterizerState mRasterizer;
- bool mScissorTest;
- Rectangle mScissor;
-
- BlendState mBlend;
- ColorF mBlendColor;
- bool mSampleCoverage;
- GLclampf mSampleCoverageValue;
- bool mSampleCoverageInvert;
-
- DepthStencilState mDepthStencil;
- GLint mStencilRef;
- GLint mStencilBackRef;
-
- GLfloat mLineWidth;
-
- GLenum mGenerateMipmapHint;
- GLenum mFragmentShaderDerivativeHint;
-
- Rectangle mViewport;
- float mNearZ;
- float mFarZ;
-
- BindingPointer<Buffer> mArrayBuffer;
- Framebuffer *mReadFramebuffer;
- Framebuffer *mDrawFramebuffer;
- BindingPointer<Renderbuffer> mRenderbuffer;
- GLuint mCurrentProgramId;
- BindingPointer<ProgramBinary> mCurrentProgramBinary;
-
- typedef std::vector<VertexAttribCurrentValueData> VertexAttribVector;
- VertexAttribVector mVertexAttribCurrentValues; // From glVertexAttrib
- VertexArray *mVertexArray;
-
- // Texture and sampler bindings
- size_t mActiveSampler; // Active texture unit selector - GL_TEXTURE0
-
- typedef std::vector< BindingPointer<Texture> > TextureBindingVector;
- typedef std::map<GLenum, TextureBindingVector> TextureBindingMap;
- TextureBindingMap mSamplerTextures;
-
- typedef std::vector< BindingPointer<Sampler> > SamplerBindingVector;
- SamplerBindingVector mSamplers;
-
- typedef std::map< GLenum, BindingPointer<Query> > ActiveQueryMap;
- ActiveQueryMap mActiveQueries;
-
- BindingPointer<Buffer> mGenericUniformBuffer;
- typedef std::vector< OffsetBindingPointer<Buffer> > BufferVector;
- BufferVector mUniformBuffers;
-
- BindingPointer<TransformFeedback> mTransformFeedback;
- BindingPointer<Buffer> mGenericTransformFeedbackBuffer;
- BufferVector mTransformFeedbackBuffers;
-
- BindingPointer<Buffer> mCopyReadBuffer;
- BindingPointer<Buffer> mCopyWriteBuffer;
-
- PixelUnpackState mUnpack;
- PixelPackState mPack;
-};
-
-}
-
-#endif // LIBGLESV2_STATE_H_
-
diff --git a/src/3rdparty/angle/src/libGLESv2/Texture.cpp b/src/3rdparty/angle/src/libGLESv2/Texture.cpp
deleted file mode 100644
index cd4fc4e32a..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Texture.cpp
+++ /dev/null
@@ -1,1012 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// Texture.cpp: Implements the gl::Texture class and its derived classes
-// Texture2D and TextureCubeMap. Implements GL texture objects and related
-// functionality. [OpenGL ES 2.0.24] section 3.7 page 63.
-
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/main.h"
-#include "libGLESv2/Context.h"
-#include "libGLESv2/formatutils.h"
-#include "libGLESv2/ImageIndex.h"
-#include "libGLESv2/Renderbuffer.h"
-#include "libGLESv2/renderer/Image.h"
-#include "libGLESv2/renderer/d3d/TextureStorage.h"
-
-#include "libEGL/Surface.h"
-
-#include "common/mathutil.h"
-#include "common/utilities.h"
-
-namespace gl
-{
-
-bool IsMipmapFiltered(const gl::SamplerState &samplerState)
-{
- switch (samplerState.minFilter)
- {
- case GL_NEAREST:
- case GL_LINEAR:
- return false;
- case GL_NEAREST_MIPMAP_NEAREST:
- case GL_LINEAR_MIPMAP_NEAREST:
- case GL_NEAREST_MIPMAP_LINEAR:
- case GL_LINEAR_MIPMAP_LINEAR:
- return true;
- default: UNREACHABLE();
- return false;
- }
-}
-
-bool IsPointSampled(const gl::SamplerState &samplerState)
-{
- return (samplerState.magFilter == GL_NEAREST && (samplerState.minFilter == GL_NEAREST || samplerState.minFilter == GL_NEAREST_MIPMAP_NEAREST));
-}
-
-unsigned int Texture::mCurrentTextureSerial = 1;
-
-Texture::Texture(rx::TextureImpl *impl, GLuint id, GLenum target)
- : RefCountObject(id),
- mTexture(impl),
- mTextureSerial(issueTextureSerial()),
- mUsage(GL_NONE),
- mImmutableLevelCount(0),
- mTarget(target)
-{
-}
-
-Texture::~Texture()
-{
- SafeDelete(mTexture);
-}
-
-GLenum Texture::getTarget() const
-{
- return mTarget;
-}
-
-void Texture::setUsage(GLenum usage)
-{
- mUsage = usage;
- getImplementation()->setUsage(usage);
-}
-
-GLenum Texture::getUsage() const
-{
- return mUsage;
-}
-
-GLint Texture::getBaseLevelWidth() const
-{
- const rx::Image *baseImage = getBaseLevelImage();
- return (baseImage ? baseImage->getWidth() : 0);
-}
-
-GLint Texture::getBaseLevelHeight() const
-{
- const rx::Image *baseImage = getBaseLevelImage();
- return (baseImage ? baseImage->getHeight() : 0);
-}
-
-GLint Texture::getBaseLevelDepth() const
-{
- const rx::Image *baseImage = getBaseLevelImage();
- return (baseImage ? baseImage->getDepth() : 0);
-}
-
-// Note: "base level image" is loosely defined to be any image from the base level,
-// where in the base of 2D array textures and cube maps there are several. Don't use
-// the base level image for anything except querying texture format and size.
-GLenum Texture::getBaseLevelInternalFormat() const
-{
- const rx::Image *baseImage = getBaseLevelImage();
- return (baseImage ? baseImage->getInternalFormat() : GL_NONE);
-}
-
-GLsizei Texture::getWidth(const ImageIndex &index) const
-{
- rx::Image *image = mTexture->getImage(index);
- return image->getWidth();
-}
-
-GLsizei Texture::getHeight(const ImageIndex &index) const
-{
- rx::Image *image = mTexture->getImage(index);
- return image->getHeight();
-}
-
-GLenum Texture::getInternalFormat(const ImageIndex &index) const
-{
- rx::Image *image = mTexture->getImage(index);
- return image->getInternalFormat();
-}
-
-GLenum Texture::getActualFormat(const ImageIndex &index) const
-{
- rx::Image *image = mTexture->getImage(index);
- return image->getActualFormat();
-}
-
-Error Texture::generateMipmaps()
-{
- return getImplementation()->generateMipmaps();
-}
-
-Error Texture::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
- GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
-{
- return mTexture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, source);
-}
-
-unsigned int Texture::getTextureSerial() const
-{
- return mTextureSerial;
-}
-
-unsigned int Texture::issueTextureSerial()
-{
- return mCurrentTextureSerial++;
-}
-
-bool Texture::isImmutable() const
-{
- return (mImmutableLevelCount > 0);
-}
-
-int Texture::immutableLevelCount()
-{
- return mImmutableLevelCount;
-}
-
-int Texture::mipLevels() const
-{
- return log2(std::max(std::max(getBaseLevelWidth(), getBaseLevelHeight()), getBaseLevelDepth())) + 1;
-}
-
-const rx::Image *Texture::getBaseLevelImage() const
-{
- return (getImplementation()->getLayerCount(0) > 0 ? getImplementation()->getImage(0, 0) : NULL);
-}
-
-Texture2D::Texture2D(rx::TextureImpl *impl, GLuint id)
- : Texture(impl, id, GL_TEXTURE_2D)
-{
- mSurface = NULL;
-}
-
-Texture2D::~Texture2D()
-{
- if (mSurface)
- {
- mSurface->setBoundTexture(NULL);
- mSurface = NULL;
- }
-}
-
-GLsizei Texture2D::getWidth(GLint level) const
-{
- if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mTexture->getImage(level, 0)->getWidth();
- else
- return 0;
-}
-
-GLsizei Texture2D::getHeight(GLint level) const
-{
- if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mTexture->getImage(level, 0)->getHeight();
- else
- return 0;
-}
-
-GLenum Texture2D::getInternalFormat(GLint level) const
-{
- if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mTexture->getImage(level, 0)->getInternalFormat();
- else
- return GL_NONE;
-}
-
-GLenum Texture2D::getActualFormat(GLint level) const
-{
- if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mTexture->getImage(level, 0)->getActualFormat();
- else
- return GL_NONE;
-}
-
-Error Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
-{
- releaseTexImage();
-
- return mTexture->setImage(GL_TEXTURE_2D, level, width, height, 1, internalFormat, format, type, unpack, pixels);
-}
-
-void Texture2D::bindTexImage(egl::Surface *surface)
-{
- releaseTexImage();
-
- mTexture->bindTexImage(surface);
-
- mSurface = surface;
- mSurface->setBoundTexture(this);
-}
-
-void Texture2D::releaseTexImage()
-{
- if (mSurface)
- {
- mSurface->setBoundTexture(NULL);
- mSurface = NULL;
-
- mTexture->releaseTexImage();
- }
-}
-
-Error Texture2D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize,
- const PixelUnpackState &unpack, const void *pixels)
-{
- releaseTexImage();
-
- return mTexture->setCompressedImage(GL_TEXTURE_2D, level, format, width, height, 1, imageSize, unpack, pixels);
-}
-
-Error Texture2D::subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
-{
- return mTexture->subImage(GL_TEXTURE_2D, level, xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels);
-}
-
-Error Texture2D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
- GLenum format, GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels)
-{
- return mTexture->subImageCompressed(GL_TEXTURE_2D, level, xoffset, yoffset, 0, width, height, 1, format, imageSize, unpack, pixels);
-}
-
-Error Texture2D::copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height,
- Framebuffer *source)
-{
- releaseTexImage();
-
- return mTexture->copyImage(GL_TEXTURE_2D, level, format, x, y, width, height, source);
-}
-
-Error Texture2D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
-{
- Error error = mTexture->storage(GL_TEXTURE_2D, levels, internalformat, width, height, 1);
- if (error.isError())
- {
- return error;
- }
-
- mImmutableLevelCount = levels;
-
- return Error(GL_NO_ERROR);
-}
-
-// Tests for 2D texture sampling completeness. [OpenGL ES 2.0.24] section 3.8.2 page 85.
-bool Texture2D::isSamplerComplete(const SamplerState &samplerState, const TextureCapsMap &textureCaps, const Extensions &extensions, int clientVersion) const
-{
- GLsizei width = getBaseLevelWidth();
- GLsizei height = getBaseLevelHeight();
-
- if (width <= 0 || height <= 0)
- {
- return false;
- }
-
- if (!textureCaps.get(getInternalFormat(0)).filterable && !IsPointSampled(samplerState))
- {
- return false;
- }
-
- bool npotSupport = extensions.textureNPOT;
-
- if (!npotSupport)
- {
- if ((samplerState.wrapS != GL_CLAMP_TO_EDGE && !gl::isPow2(width)) ||
- (samplerState.wrapT != GL_CLAMP_TO_EDGE && !gl::isPow2(height)))
- {
- return false;
- }
- }
-
- if (IsMipmapFiltered(samplerState))
- {
- if (!npotSupport)
- {
- if (!gl::isPow2(width) || !gl::isPow2(height))
- {
- return false;
- }
- }
-
- if (!isMipmapComplete())
- {
- return false;
- }
- }
-
- // OpenGLES 3.0.2 spec section 3.8.13 states that a texture is not mipmap complete if:
- // The internalformat specified for the texture arrays is a sized internal depth or
- // depth and stencil format (see table 3.13), the value of TEXTURE_COMPARE_-
- // MODE is NONE, and either the magnification filter is not NEAREST or the mini-
- // fication filter is neither NEAREST nor NEAREST_MIPMAP_NEAREST.
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(getInternalFormat(0));
- if (formatInfo.depthBits > 0 && clientVersion > 2)
- {
- if (samplerState.compareMode == GL_NONE)
- {
- if ((samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST) ||
- samplerState.magFilter != GL_NEAREST)
- {
- return false;
- }
- }
- }
-
- return true;
-}
-
-bool Texture2D::isCompressed(GLint level) const
-{
- return GetInternalFormatInfo(getInternalFormat(level)).compressed;
-}
-
-bool Texture2D::isDepth(GLint level) const
-{
- return GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0;
-}
-
-Error Texture2D::generateMipmaps()
-{
- releaseTexImage();
-
- return mTexture->generateMipmaps();
-}
-
-// Tests for 2D texture (mipmap) completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
-bool Texture2D::isMipmapComplete() const
-{
- int levelCount = mipLevels();
-
- for (int level = 0; level < levelCount; level++)
- {
- if (!isLevelComplete(level))
- {
- return false;
- }
- }
-
- return true;
-}
-
-bool Texture2D::isLevelComplete(int level) const
-{
- if (isImmutable())
- {
- return true;
- }
-
- const rx::Image *baseImage = getBaseLevelImage();
-
- GLsizei width = baseImage->getWidth();
- GLsizei height = baseImage->getHeight();
-
- if (width <= 0 || height <= 0)
- {
- return false;
- }
-
- // The base image level is complete if the width and height are positive
- if (level == 0)
- {
- return true;
- }
-
- ASSERT(level >= 1 && level < IMPLEMENTATION_MAX_TEXTURE_LEVELS && mTexture->getImage(level, 0) != NULL);
- rx::Image *image = mTexture->getImage(level, 0);
-
- if (image->getInternalFormat() != baseImage->getInternalFormat())
- {
- return false;
- }
-
- if (image->getWidth() != std::max(1, width >> level))
- {
- return false;
- }
-
- if (image->getHeight() != std::max(1, height >> level))
- {
- return false;
- }
-
- return true;
-}
-
-TextureCubeMap::TextureCubeMap(rx::TextureImpl *impl, GLuint id)
- : Texture(impl, id, GL_TEXTURE_CUBE_MAP)
-{
-}
-
-TextureCubeMap::~TextureCubeMap()
-{
-}
-
-GLsizei TextureCubeMap::getWidth(GLenum target, GLint level) const
-{
- if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mTexture->getImage(level, targetToLayerIndex(target))->getWidth();
- else
- return 0;
-}
-
-GLsizei TextureCubeMap::getHeight(GLenum target, GLint level) const
-{
- if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mTexture->getImage(level, targetToLayerIndex(target))->getHeight();
- else
- return 0;
-}
-
-GLenum TextureCubeMap::getInternalFormat(GLenum target, GLint level) const
-{
- if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mTexture->getImage(level, targetToLayerIndex(target))->getInternalFormat();
- else
- return GL_NONE;
-}
-
-GLenum TextureCubeMap::getActualFormat(GLenum target, GLint level) const
-{
- if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mTexture->getImage(level, targetToLayerIndex(target))->getActualFormat();
- else
- return GL_NONE;
-}
-
-Error TextureCubeMap::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
-{
- return mTexture->setImage(target, level, width, height, 1, internalFormat, format, type, unpack, pixels);
-}
-
-Error TextureCubeMap::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height,
- GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels)
-{
- return mTexture->setCompressedImage(target, level, format, width, height, 1, imageSize, unpack, pixels);
-}
-
-Error TextureCubeMap::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
-{
- return mTexture->subImage(target, level, xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels);
-}
-
-Error TextureCubeMap::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height, GLenum format,
- GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels)
-{
- return mTexture->subImageCompressed(target, level, xoffset, yoffset, 0, width, height, 1, format, imageSize, unpack, pixels);
-}
-
-// Tests for cube texture completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
-bool TextureCubeMap::isCubeComplete() const
-{
- int baseWidth = getBaseLevelWidth();
- int baseHeight = getBaseLevelHeight();
- GLenum baseFormat = getBaseLevelInternalFormat();
-
- if (baseWidth <= 0 || baseWidth != baseHeight)
- {
- return false;
- }
-
- for (int faceIndex = 1; faceIndex < 6; faceIndex++)
- {
- const rx::Image *faceBaseImage = mTexture->getImage(0, faceIndex);
-
- if (faceBaseImage->getWidth() != baseWidth ||
- faceBaseImage->getHeight() != baseHeight ||
- faceBaseImage->getInternalFormat() != baseFormat )
- {
- return false;
- }
- }
-
- return true;
-}
-
-bool TextureCubeMap::isCompressed(GLenum target, GLint level) const
-{
- return GetInternalFormatInfo(getInternalFormat(target, level)).compressed;
-}
-
-bool TextureCubeMap::isDepth(GLenum target, GLint level) const
-{
- return GetInternalFormatInfo(getInternalFormat(target, level)).depthBits > 0;
-}
-
-Error TextureCubeMap::copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y,
- GLsizei width, GLsizei height, Framebuffer *source)
-{
- return mTexture->copyImage(target, level, format, x, y, width, height, source);
-}
-
-Error TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size)
-{
- Error error = mTexture->storage(GL_TEXTURE_CUBE_MAP, levels, internalformat, size, size, 1);
- if (error.isError())
- {
- return error;
- }
-
- mImmutableLevelCount = levels;
-
- return Error(GL_NO_ERROR);
-}
-
-// Tests for texture sampling completeness
-bool TextureCubeMap::isSamplerComplete(const SamplerState &samplerState, const TextureCapsMap &textureCaps, const Extensions &extensions, int clientVersion) const
-{
- int size = getBaseLevelWidth();
-
- bool mipmapping = IsMipmapFiltered(samplerState);
-
- if (!textureCaps.get(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0)).filterable && !IsPointSampled(samplerState))
- {
- return false;
- }
-
- if (!gl::isPow2(size) && !extensions.textureNPOT)
- {
- if (samplerState.wrapS != GL_CLAMP_TO_EDGE || samplerState.wrapT != GL_CLAMP_TO_EDGE || mipmapping)
- {
- return false;
- }
- }
-
- if (!mipmapping)
- {
- if (!isCubeComplete())
- {
- return false;
- }
- }
- else
- {
- if (!isMipmapComplete()) // Also tests for isCubeComplete()
- {
- return false;
- }
- }
-
- return true;
-}
-
-int TextureCubeMap::targetToLayerIndex(GLenum target)
-{
- META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_X - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 1);
- META_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_Y - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 2);
- META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 3);
- META_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_Z - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 4);
- META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 5);
-
- return target - GL_TEXTURE_CUBE_MAP_POSITIVE_X;
-}
-
-GLenum TextureCubeMap::layerIndexToTarget(GLint layer)
-{
- META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_X - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 1);
- META_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_Y - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 2);
- META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 3);
- META_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_Z - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 4);
- META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 5);
-
- return GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer;
-}
-
-bool TextureCubeMap::isMipmapComplete() const
-{
- if (isImmutable())
- {
- return true;
- }
-
- if (!isCubeComplete())
- {
- return false;
- }
-
- int levelCount = mipLevels();
-
- for (int face = 0; face < 6; face++)
- {
- for (int level = 1; level < levelCount; level++)
- {
- if (!isFaceLevelComplete(face, level))
- {
- return false;
- }
- }
- }
-
- return true;
-}
-
-bool TextureCubeMap::isFaceLevelComplete(int faceIndex, int level) const
-{
- ASSERT(level >= 0 && faceIndex < 6 && level < IMPLEMENTATION_MAX_TEXTURE_LEVELS && mTexture->getImage(level, faceIndex) != NULL);
-
- if (isImmutable())
- {
- return true;
- }
-
- int baseSize = getBaseLevelWidth();
-
- if (baseSize <= 0)
- {
- return false;
- }
-
- // "isCubeComplete" checks for base level completeness and we must call that
- // to determine if any face at level 0 is complete. We omit that check here
- // to avoid re-checking cube-completeness for every face at level 0.
- if (level == 0)
- {
- return true;
- }
-
- // Check that non-zero levels are consistent with the base level.
- const rx::Image *faceLevelImage = mTexture->getImage(level, faceIndex);
-
- if (faceLevelImage->getInternalFormat() != getBaseLevelInternalFormat())
- {
- return false;
- }
-
- if (faceLevelImage->getWidth() != std::max(1, baseSize >> level))
- {
- return false;
- }
-
- return true;
-}
-
-
-Texture3D::Texture3D(rx::TextureImpl *impl, GLuint id)
- : Texture(impl, id, GL_TEXTURE_3D)
-{
-}
-
-Texture3D::~Texture3D()
-{
-}
-
-GLsizei Texture3D::getWidth(GLint level) const
-{
- return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level, 0)->getWidth() : 0;
-}
-
-GLsizei Texture3D::getHeight(GLint level) const
-{
- return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level, 0)->getHeight() : 0;
-}
-
-GLsizei Texture3D::getDepth(GLint level) const
-{
- return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level, 0)->getDepth() : 0;
-}
-
-GLenum Texture3D::getInternalFormat(GLint level) const
-{
- return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level, 0)->getInternalFormat() : GL_NONE;
-}
-
-GLenum Texture3D::getActualFormat(GLint level) const
-{
- return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level, 0)->getActualFormat() : GL_NONE;
-}
-
-bool Texture3D::isCompressed(GLint level) const
-{
- return GetInternalFormatInfo(getInternalFormat(level)).compressed;
-}
-
-bool Texture3D::isDepth(GLint level) const
-{
- return GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0;
-}
-
-Error Texture3D::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
-{
- return mTexture->setImage(GL_TEXTURE_3D, level, width, height, depth, internalFormat, format, type, unpack, pixels);
-}
-
-Error Texture3D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth,
- GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels)
-{
- return mTexture->setCompressedImage(GL_TEXTURE_3D, level, format, width, height, depth, imageSize, unpack, pixels);
-}
-
-Error Texture3D::subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
-{
- return mTexture->subImage(GL_TEXTURE_3D, level, xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels);
-}
-
-Error Texture3D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth, GLenum format,
- GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels)
-{
- return mTexture->subImageCompressed(GL_TEXTURE_3D, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, unpack, pixels);
-}
-
-Error Texture3D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
-{
- Error error = mTexture->storage(GL_TEXTURE_3D, levels, internalformat, width, height, depth);
- if (error.isError())
- {
- return error;
- }
-
- mImmutableLevelCount = levels;
-
- return Error(GL_NO_ERROR);
-}
-
-bool Texture3D::isSamplerComplete(const SamplerState &samplerState, const TextureCapsMap &textureCaps, const Extensions &extensions, int clientVersion) const
-{
- GLsizei width = getBaseLevelWidth();
- GLsizei height = getBaseLevelHeight();
- GLsizei depth = getBaseLevelDepth();
-
- if (width <= 0 || height <= 0 || depth <= 0)
- {
- return false;
- }
-
- if (!textureCaps.get(getInternalFormat(0)).filterable && !IsPointSampled(samplerState))
- {
- return false;
- }
-
- if (IsMipmapFiltered(samplerState) && !isMipmapComplete())
- {
- return false;
- }
-
- return true;
-}
-
-bool Texture3D::isMipmapComplete() const
-{
- int levelCount = mipLevels();
-
- for (int level = 0; level < levelCount; level++)
- {
- if (!isLevelComplete(level))
- {
- return false;
- }
- }
-
- return true;
-}
-
-bool Texture3D::isLevelComplete(int level) const
-{
- ASSERT(level >= 0 && level < IMPLEMENTATION_MAX_TEXTURE_LEVELS && mTexture->getImage(level, 0) != NULL);
-
- if (isImmutable())
- {
- return true;
- }
-
- GLsizei width = getBaseLevelWidth();
- GLsizei height = getBaseLevelHeight();
- GLsizei depth = getBaseLevelDepth();
-
- if (width <= 0 || height <= 0 || depth <= 0)
- {
- return false;
- }
-
- if (level == 0)
- {
- return true;
- }
-
- rx::Image *levelImage = mTexture->getImage(level, 0);
-
- if (levelImage->getInternalFormat() != getBaseLevelInternalFormat())
- {
- return false;
- }
-
- if (levelImage->getWidth() != std::max(1, width >> level))
- {
- return false;
- }
-
- if (levelImage->getHeight() != std::max(1, height >> level))
- {
- return false;
- }
-
- if (levelImage->getDepth() != std::max(1, depth >> level))
- {
- return false;
- }
-
- return true;
-}
-
-Texture2DArray::Texture2DArray(rx::TextureImpl *impl, GLuint id)
- : Texture(impl, id, GL_TEXTURE_2D_ARRAY)
-{
-}
-
-Texture2DArray::~Texture2DArray()
-{
-}
-
-GLsizei Texture2DArray::getWidth(GLint level) const
-{
- return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS && mTexture->getLayerCount(level) > 0) ? mTexture->getImage(level, 0)->getWidth() : 0;
-}
-
-GLsizei Texture2DArray::getHeight(GLint level) const
-{
- return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS && mTexture->getLayerCount(level) > 0) ? mTexture->getImage(level, 0)->getHeight() : 0;
-}
-
-GLsizei Texture2DArray::getLayers(GLint level) const
-{
- return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getLayerCount(level) : 0;
-}
-
-GLenum Texture2DArray::getInternalFormat(GLint level) const
-{
- return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS && mTexture->getLayerCount(level) > 0) ? mTexture->getImage(level, 0)->getInternalFormat() : GL_NONE;
-}
-
-GLenum Texture2DArray::getActualFormat(GLint level) const
-{
- return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS && mTexture->getLayerCount(level) > 0) ? mTexture->getImage(level, 0)->getActualFormat() : GL_NONE;
-}
-
-bool Texture2DArray::isCompressed(GLint level) const
-{
- return GetInternalFormatInfo(getInternalFormat(level)).compressed;
-}
-
-bool Texture2DArray::isDepth(GLint level) const
-{
- return GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0;
-}
-
-Error Texture2DArray::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
-{
- return mTexture->setImage(GL_TEXTURE_2D_ARRAY, level, width, height, depth, internalFormat, format, type, unpack, pixels);
-}
-
-Error Texture2DArray::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth,
- GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels)
-{
- return mTexture->setCompressedImage(GL_TEXTURE_2D_ARRAY, level, format, width, height, depth, imageSize, unpack, pixels);
-}
-
-Error Texture2DArray::subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
-{
- return mTexture->subImage(GL_TEXTURE_2D_ARRAY, level, xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels);
-}
-
-Error Texture2DArray::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth, GLenum format,
- GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels)
-{
- return mTexture->subImageCompressed(GL_TEXTURE_2D_ARRAY, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, unpack, pixels);
-}
-
-Error Texture2DArray::storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
-{
- Error error = mTexture->storage(GL_TEXTURE_2D_ARRAY, levels, internalformat, width, height, depth);
- if (error.isError())
- {
- return error;
- }
-
- mImmutableLevelCount = levels;
-
- return Error(GL_NO_ERROR);
-}
-
-bool Texture2DArray::isSamplerComplete(const SamplerState &samplerState, const TextureCapsMap &textureCaps, const Extensions &extensions, int clientVersion) const
-{
- GLsizei width = getBaseLevelWidth();
- GLsizei height = getBaseLevelHeight();
- GLsizei depth = getLayers(0);
-
- if (width <= 0 || height <= 0 || depth <= 0)
- {
- return false;
- }
-
- if (!textureCaps.get(getBaseLevelInternalFormat()).filterable && !IsPointSampled(samplerState))
- {
- return false;
- }
-
- if (IsMipmapFiltered(samplerState) && !isMipmapComplete())
- {
- return false;
- }
-
- return true;
-}
-
-bool Texture2DArray::isMipmapComplete() const
-{
- int levelCount = mipLevels();
-
- for (int level = 1; level < levelCount; level++)
- {
- if (!isLevelComplete(level))
- {
- return false;
- }
- }
-
- return true;
-}
-
-bool Texture2DArray::isLevelComplete(int level) const
-{
- ASSERT(level >= 0 && level < IMPLEMENTATION_MAX_TEXTURE_LEVELS);
-
- if (isImmutable())
- {
- return true;
- }
-
- GLsizei width = getBaseLevelWidth();
- GLsizei height = getBaseLevelHeight();
- GLsizei layers = getLayers(0);
-
- if (width <= 0 || height <= 0 || layers <= 0)
- {
- return false;
- }
-
- if (level == 0)
- {
- return true;
- }
-
- if (getInternalFormat(level) != getInternalFormat(0))
- {
- return false;
- }
-
- if (getWidth(level) != std::max(1, width >> level))
- {
- return false;
- }
-
- if (getHeight(level) != std::max(1, height >> level))
- {
- return false;
- }
-
- if (getLayers(level) != layers)
- {
- return false;
- }
-
- return true;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/Texture.h b/src/3rdparty/angle/src/libGLESv2/Texture.h
deleted file mode 100644
index 66d4df8015..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Texture.h
+++ /dev/null
@@ -1,241 +0,0 @@
-//
-// Copyright (c) 2002-2013 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.
-//
-
-// Texture.h: Defines the abstract gl::Texture class and its concrete derived
-// classes Texture2D and TextureCubeMap. Implements GL texture objects and
-// related functionality. [OpenGL ES 2.0.24] section 3.7 page 63.
-
-#ifndef LIBGLESV2_TEXTURE_H_
-#define LIBGLESV2_TEXTURE_H_
-
-#include "common/debug.h"
-#include "common/RefCountObject.h"
-#include "libGLESv2/angletypes.h"
-#include "libGLESv2/Constants.h"
-#include "libGLESv2/renderer/TextureImpl.h"
-#include "libGLESv2/Caps.h"
-
-#include "angle_gl.h"
-
-#include <vector>
-
-namespace egl
-{
-class Surface;
-}
-
-namespace rx
-{
-class TextureStorageInterface;
-class Image;
-}
-
-namespace gl
-{
-class Framebuffer;
-class FramebufferAttachment;
-struct ImageIndex;
-
-bool IsMipmapFiltered(const gl::SamplerState &samplerState);
-
-class Texture : public RefCountObject
-{
- public:
- Texture(rx::TextureImpl *impl, GLuint id, GLenum target);
-
- virtual ~Texture();
-
- GLenum getTarget() const;
-
- const SamplerState &getSamplerState() const { return mSamplerState; }
- SamplerState &getSamplerState() { return mSamplerState; }
-
- void setUsage(GLenum usage);
- GLenum getUsage() const;
-
- GLint getBaseLevelWidth() const;
- GLint getBaseLevelHeight() const;
- GLint getBaseLevelDepth() const;
- GLenum getBaseLevelInternalFormat() const;
-
- GLsizei getWidth(const ImageIndex &index) const;
- GLsizei getHeight(const ImageIndex &index) const;
- GLenum getInternalFormat(const ImageIndex &index) const;
- GLenum getActualFormat(const ImageIndex &index) const;
-
- virtual bool isSamplerComplete(const SamplerState &samplerState, const TextureCapsMap &textureCaps, const Extensions &extensions, int clientVersion) const = 0;
-
- virtual Error generateMipmaps();
-
- virtual Error copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
-
- // Texture serials provide a unique way of identifying a Texture that isn't a raw pointer.
- // "id" is not good enough, as Textures can be deleted, then re-allocated with the same id.
- unsigned int getTextureSerial() const;
-
- bool isImmutable() const;
- GLsizei immutableLevelCount();
-
- rx::TextureImpl *getImplementation() { return mTexture; }
- const rx::TextureImpl *getImplementation() const { return mTexture; }
-
- static const GLuint INCOMPLETE_TEXTURE_ID = static_cast<GLuint>(-1); // Every texture takes an id at creation time. The value is arbitrary because it is never registered with the resource manager.
-
- protected:
- int mipLevels() const;
- const rx::Image *getBaseLevelImage() const;
- static unsigned int issueTextureSerial();
-
- rx::TextureImpl *mTexture;
-
- SamplerState mSamplerState;
- GLenum mUsage;
-
- GLsizei mImmutableLevelCount;
-
- GLenum mTarget;
-
- const unsigned int mTextureSerial;
- static unsigned int mCurrentTextureSerial;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Texture);
-};
-
-class Texture2D : public Texture
-{
- public:
- Texture2D(rx::TextureImpl *impl, GLuint id);
-
- virtual ~Texture2D();
-
- GLsizei getWidth(GLint level) const;
- GLsizei getHeight(GLint level) const;
- GLenum getInternalFormat(GLint level) const;
- GLenum getActualFormat(GLint level) const;
- bool isCompressed(GLint level) const;
- bool isDepth(GLint level) const;
-
- Error setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
- Error setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels);
- Error subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
- Error subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels);
- Error copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
- Error storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
-
- virtual bool isSamplerComplete(const SamplerState &samplerState, const TextureCapsMap &textureCaps, const Extensions &extensions, int clientVersion) const;
- virtual void bindTexImage(egl::Surface *surface);
- virtual void releaseTexImage();
-
- virtual Error generateMipmaps();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Texture2D);
-
- bool isMipmapComplete() const;
- bool isLevelComplete(int level) const;
-
- egl::Surface *mSurface;
-};
-
-class TextureCubeMap : public Texture
-{
- public:
- TextureCubeMap(rx::TextureImpl *impl, GLuint id);
-
- virtual ~TextureCubeMap();
-
- GLsizei getWidth(GLenum target, GLint level) const;
- GLsizei getHeight(GLenum target, GLint level) const;
- GLenum getInternalFormat(GLenum target, GLint level) const;
- GLenum getActualFormat(GLenum target, GLint level) const;
- bool isCompressed(GLenum target, GLint level) const;
- bool isDepth(GLenum target, GLint level) const;
-
- Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
- Error setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels);
- Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
- Error subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels);
- Error copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
- Error storage(GLsizei levels, GLenum internalformat, GLsizei size);
-
- virtual bool isSamplerComplete(const SamplerState &samplerState, const TextureCapsMap &textureCaps, const Extensions &extensions, int clientVersion) const;
-
- bool isCubeComplete() const;
-
- static int targetToLayerIndex(GLenum target);
- static GLenum layerIndexToTarget(GLint layer);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureCubeMap);
-
- bool isMipmapComplete() const;
- bool isFaceLevelComplete(int faceIndex, int level) const;
-};
-
-class Texture3D : public Texture
-{
- public:
- Texture3D(rx::TextureImpl *impl, GLuint id);
-
- virtual ~Texture3D();
-
- GLsizei getWidth(GLint level) const;
- GLsizei getHeight(GLint level) const;
- GLsizei getDepth(GLint level) const;
- GLenum getInternalFormat(GLint level) const;
- GLenum getActualFormat(GLint level) const;
- bool isCompressed(GLint level) const;
- bool isDepth(GLint level) const;
-
- Error setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
- Error setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels);
- Error subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
- Error subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels);
- Error storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-
- virtual bool isSamplerComplete(const SamplerState &samplerState, const TextureCapsMap &textureCaps, const Extensions &extensions, int clientVersion) const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Texture3D);
-
- bool isMipmapComplete() const;
- bool isLevelComplete(int level) const;
-};
-
-class Texture2DArray : public Texture
-{
- public:
- Texture2DArray(rx::TextureImpl *impl, GLuint id);
-
- virtual ~Texture2DArray();
-
- GLsizei getWidth(GLint level) const;
- GLsizei getHeight(GLint level) const;
- GLsizei getLayers(GLint level) const;
- GLenum getInternalFormat(GLint level) const;
- GLenum getActualFormat(GLint level) const;
- bool isCompressed(GLint level) const;
- bool isDepth(GLint level) const;
-
- Error setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
- Error setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels);
- Error subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
- Error subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels);
- Error storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-
- virtual bool isSamplerComplete(const SamplerState &samplerState, const TextureCapsMap &textureCaps, const Extensions &extensions, int clientVersion) const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Texture2DArray);
-
- bool isMipmapComplete() const;
- bool isLevelComplete(int level) const;
-};
-
-}
-
-#endif // LIBGLESV2_TEXTURE_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/TransformFeedback.cpp b/src/3rdparty/angle/src/libGLESv2/TransformFeedback.cpp
deleted file mode 100644
index bfa7072326..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/TransformFeedback.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-#include "libGLESv2/TransformFeedback.h"
-#include "libGLESv2/renderer/TransformFeedbackImpl.h"
-
-namespace gl
-{
-
-TransformFeedback::TransformFeedback(rx::TransformFeedbackImpl* impl, GLuint id)
- : RefCountObject(id),
- mTransformFeedback(impl),
- mStarted(GL_FALSE),
- mPrimitiveMode(GL_NONE),
- mPaused(GL_FALSE)
-{
- ASSERT(impl != NULL);
-}
-
-TransformFeedback::~TransformFeedback()
-{
- SafeDelete(mTransformFeedback);
-}
-
-void TransformFeedback::start(GLenum primitiveMode)
-{
- mStarted = GL_TRUE;
- mPrimitiveMode = primitiveMode;
- mPaused = GL_FALSE;
- mTransformFeedback->begin(primitiveMode);
-}
-
-void TransformFeedback::stop()
-{
- mStarted = GL_FALSE;
- mPrimitiveMode = GL_NONE;
- mPaused = GL_FALSE;
- mTransformFeedback->end();
-}
-
-GLboolean TransformFeedback::isStarted() const
-{
- return mStarted;
-}
-
-GLenum TransformFeedback::getDrawMode() const
-{
- return mPrimitiveMode;
-}
-
-void TransformFeedback::pause()
-{
- mPaused = GL_TRUE;
- mTransformFeedback->pause();
-}
-
-void TransformFeedback::resume()
-{
- mPaused = GL_FALSE;
- mTransformFeedback->resume();
-}
-
-GLboolean TransformFeedback::isPaused() const
-{
- return mPaused;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/TransformFeedback.h b/src/3rdparty/angle/src/libGLESv2/TransformFeedback.h
deleted file mode 100644
index 885a4fe172..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/TransformFeedback.h
+++ /dev/null
@@ -1,51 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-#ifndef LIBGLESV2_TRANSFORM_FEEDBACK_H_
-#define LIBGLESV2_TRANSFORM_FEEDBACK_H_
-
-#include "common/angleutils.h"
-#include "common/RefCountObject.h"
-
-#include "angle_gl.h"
-
-namespace rx
-{
-class TransformFeedbackImpl;
-}
-
-namespace gl
-{
-
-class TransformFeedback : public RefCountObject
-{
- public:
- TransformFeedback(rx::TransformFeedbackImpl* impl, GLuint id);
- virtual ~TransformFeedback();
-
- void start(GLenum primitiveMode);
- void stop();
- GLboolean isStarted() const;
-
- GLenum getDrawMode() const;
-
- void pause();
- void resume();
- GLboolean isPaused() const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TransformFeedback);
-
- rx::TransformFeedbackImpl* mTransformFeedback;
-
- GLboolean mStarted;
- GLenum mPrimitiveMode;
- GLboolean mPaused;
-};
-
-}
-
-#endif // LIBGLESV2_TRANSFORM_FEEDBACK_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/Uniform.cpp b/src/3rdparty/angle/src/libGLESv2/Uniform.cpp
deleted file mode 100644
index bd0cd2eeec..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Uniform.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-//
-// Copyright (c) 2010-2013 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.
-//
-
-#include "libGLESv2/Uniform.h"
-
-#include "common/utilities.h"
-
-namespace gl
-{
-
-LinkedUniform::LinkedUniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize,
- const int blockIndex, const sh::BlockMemberInfo &blockInfo)
- : type(type),
- precision(precision),
- name(name),
- arraySize(arraySize),
- blockIndex(blockIndex),
- blockInfo(blockInfo),
- data(NULL),
- dirty(true),
- psRegisterIndex(GL_INVALID_INDEX),
- vsRegisterIndex(GL_INVALID_INDEX),
- registerCount(0),
- registerElement(0)
-{
- // We use data storage for default block uniforms to cache values that are sent to D3D during rendering
- // Uniform blocks/buffers are treated separately by the Renderer (ES3 path only)
- if (isInDefaultBlock())
- {
- size_t bytes = dataSize();
- data = new unsigned char[bytes];
- memset(data, 0, bytes);
- registerCount = VariableRowCount(type) * elementCount();
- }
-}
-
-LinkedUniform::~LinkedUniform()
-{
- delete[] data;
-}
-
-bool LinkedUniform::isArray() const
-{
- return arraySize > 0;
-}
-
-unsigned int LinkedUniform::elementCount() const
-{
- return arraySize > 0 ? arraySize : 1;
-}
-
-bool LinkedUniform::isReferencedByVertexShader() const
-{
- return vsRegisterIndex != GL_INVALID_INDEX;
-}
-
-bool LinkedUniform::isReferencedByFragmentShader() const
-{
- return psRegisterIndex != GL_INVALID_INDEX;
-}
-
-bool LinkedUniform::isInDefaultBlock() const
-{
- return blockIndex == -1;
-}
-
-size_t LinkedUniform::dataSize() const
-{
- ASSERT(type != GL_STRUCT_ANGLEX);
- return VariableInternalSize(type) * elementCount();
-}
-
-bool LinkedUniform::isSampler() const
-{
- return IsSampler(type);
-}
-
-UniformBlock::UniformBlock(const std::string &name, unsigned int elementIndex, unsigned int dataSize)
- : name(name),
- elementIndex(elementIndex),
- dataSize(dataSize),
- psRegisterIndex(GL_INVALID_INDEX),
- vsRegisterIndex(GL_INVALID_INDEX)
-{
-}
-
-bool UniformBlock::isArrayElement() const
-{
- return elementIndex != GL_INVALID_INDEX;
-}
-
-bool UniformBlock::isReferencedByVertexShader() const
-{
- return vsRegisterIndex != GL_INVALID_INDEX;
-}
-
-bool UniformBlock::isReferencedByFragmentShader() const
-{
- return psRegisterIndex != GL_INVALID_INDEX;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/Uniform.h b/src/3rdparty/angle/src/libGLESv2/Uniform.h
deleted file mode 100644
index 633d70bb19..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/Uniform.h
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// Copyright (c) 2010-2013 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.
-//
-
-#ifndef LIBGLESV2_UNIFORM_H_
-#define LIBGLESV2_UNIFORM_H_
-
-#include "common/debug.h"
-#include "common/blocklayout.h"
-
-#include "libGLESv2/angletypes.h"
-
-#include "angle_gl.h"
-
-#include <string>
-#include <vector>
-
-namespace gl
-{
-
-// Helper struct representing a single shader uniform
-struct LinkedUniform
-{
- LinkedUniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize, const int blockIndex, const sh::BlockMemberInfo &blockInfo);
-
- ~LinkedUniform();
-
- bool isArray() const;
- unsigned int elementCount() const;
- bool isReferencedByVertexShader() const;
- bool isReferencedByFragmentShader() const;
- bool isInDefaultBlock() const;
- size_t dataSize() const;
- bool isSampler() const;
-
- const GLenum type;
- const GLenum precision;
- const std::string name;
- const unsigned int arraySize;
- const int blockIndex;
- const sh::BlockMemberInfo blockInfo;
-
- unsigned char *data;
- bool dirty;
-
- unsigned int psRegisterIndex;
- unsigned int vsRegisterIndex;
- unsigned int registerCount;
-
- // Register "elements" are used for uniform structs in ES3, to appropriately identify single uniforms
- // inside aggregate types, which are packed according C-like structure rules.
- unsigned int registerElement;
-};
-
-// Helper struct representing a single shader uniform block
-struct UniformBlock
-{
- // use GL_INVALID_INDEX for non-array elements
- UniformBlock(const std::string &name, unsigned int elementIndex, unsigned int dataSize);
-
- bool isArrayElement() const;
- bool isReferencedByVertexShader() const;
- bool isReferencedByFragmentShader() const;
-
- const std::string name;
- const unsigned int elementIndex;
- const unsigned int dataSize;
-
- std::vector<unsigned int> memberUniformIndexes;
-
- unsigned int psRegisterIndex;
- unsigned int vsRegisterIndex;
-};
-
-}
-
-#endif // LIBGLESV2_UNIFORM_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/VertexArray.cpp b/src/3rdparty/angle/src/libGLESv2/VertexArray.cpp
deleted file mode 100644
index f8ca661062..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/VertexArray.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-// Implementation of the state class for mananging GLES 3 Vertex Array Objects.
-//
-
-#include "libGLESv2/VertexArray.h"
-#include "libGLESv2/Buffer.h"
-#include "libGLESv2/renderer/VertexArrayImpl.h"
-
-namespace gl
-{
-
-VertexArray::VertexArray(rx::VertexArrayImpl *impl, GLuint id, size_t maxAttribs)
- : mId(id),
- mVertexArray(impl),
- mVertexAttributes(maxAttribs)
-{
- ASSERT(impl != NULL);
-}
-
-VertexArray::~VertexArray()
-{
- SafeDelete(mVertexArray);
-
- for (size_t i = 0; i < getMaxAttribs(); i++)
- {
- mVertexAttributes[i].buffer.set(NULL);
- }
- mElementArrayBuffer.set(NULL);
-}
-
-GLuint VertexArray::id() const
-{
- return mId;
-}
-
-void VertexArray::detachBuffer(GLuint bufferName)
-{
- for (size_t attribute = 0; attribute < getMaxAttribs(); attribute++)
- {
- if (mVertexAttributes[attribute].buffer.id() == bufferName)
- {
- mVertexAttributes[attribute].buffer.set(NULL);
- }
- }
-
- if (mElementArrayBuffer.id() == bufferName)
- {
- mElementArrayBuffer.set(NULL);
- }
-}
-
-const VertexAttribute& VertexArray::getVertexAttribute(size_t attributeIndex) const
-{
- ASSERT(attributeIndex < getMaxAttribs());
- return mVertexAttributes[attributeIndex];
-}
-
-void VertexArray::setVertexAttribDivisor(GLuint index, GLuint divisor)
-{
- ASSERT(index < getMaxAttribs());
- mVertexAttributes[index].divisor = divisor;
- mVertexArray->setAttributeDivisor(index, divisor);
-}
-
-void VertexArray::enableAttribute(unsigned int attributeIndex, bool enabledState)
-{
- ASSERT(attributeIndex < getMaxAttribs());
- mVertexAttributes[attributeIndex].enabled = enabledState;
- mVertexArray->enableAttribute(attributeIndex, enabledState);
-}
-
-void VertexArray::setAttributeState(unsigned int attributeIndex, gl::Buffer *boundBuffer, GLint size, GLenum type,
- bool normalized, bool pureInteger, GLsizei stride, const void *pointer)
-{
- ASSERT(attributeIndex < getMaxAttribs());
- mVertexAttributes[attributeIndex].buffer.set(boundBuffer);
- mVertexAttributes[attributeIndex].size = size;
- mVertexAttributes[attributeIndex].type = type;
- mVertexAttributes[attributeIndex].normalized = normalized;
- mVertexAttributes[attributeIndex].pureInteger = pureInteger;
- mVertexAttributes[attributeIndex].stride = stride;
- mVertexAttributes[attributeIndex].pointer = pointer;
- mVertexArray->setAttribute(attributeIndex, mVertexAttributes[attributeIndex]);
-}
-
-void VertexArray::setElementArrayBuffer(Buffer *buffer)
-{
- mElementArrayBuffer.set(buffer);
- mVertexArray->setElementArrayBuffer(buffer);
-}
-
-} \ No newline at end of file
diff --git a/src/3rdparty/angle/src/libGLESv2/VertexArray.h b/src/3rdparty/angle/src/libGLESv2/VertexArray.h
deleted file mode 100644
index a724c0be1c..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/VertexArray.h
+++ /dev/null
@@ -1,62 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-// This class contains prototypes for representing GLES 3 Vertex Array Objects:
-//
-// The buffer objects that are to be used by the vertex stage of the GL are collected
-// together to form a vertex array object. All state related to the definition of data used
-// by the vertex processor is encapsulated in a vertex array object.
-//
-
-#ifndef LIBGLESV2_VERTEXARRAY_H_
-#define LIBGLESV2_VERTEXARRAY_H_
-
-#include "common/RefCountObject.h"
-#include "libGLESv2/Constants.h"
-#include "libGLESv2/VertexAttribute.h"
-
-#include <vector>
-
-namespace rx
-{
-class VertexArrayImpl;
-}
-
-namespace gl
-{
-class Buffer;
-
-class VertexArray
-{
- public:
- VertexArray(rx::VertexArrayImpl *impl, GLuint id, size_t maxAttribs);
- ~VertexArray();
-
- GLuint id() const;
-
- const VertexAttribute& getVertexAttribute(size_t attributeIndex) const;
- void detachBuffer(GLuint bufferName);
- void setVertexAttribDivisor(GLuint index, GLuint divisor);
- void enableAttribute(unsigned int attributeIndex, bool enabledState);
- void setAttributeState(unsigned int attributeIndex, gl::Buffer *boundBuffer, GLint size, GLenum type,
- bool normalized, bool pureInteger, GLsizei stride, const void *pointer);
-
- const VertexAttribute* getVertexAttributes() const { return &mVertexAttributes[0]; }
- Buffer *getElementArrayBuffer() const { return mElementArrayBuffer.get(); }
- void setElementArrayBuffer(Buffer *buffer);
- GLuint getElementArrayBufferId() const { return mElementArrayBuffer.id(); }
- size_t getMaxAttribs() const { return mVertexAttributes.size(); }
-
- private:
- GLuint mId;
-
- rx::VertexArrayImpl *mVertexArray;
- std::vector<VertexAttribute> mVertexAttributes;
- BindingPointer<Buffer> mElementArrayBuffer;
-};
-
-}
-
-#endif // LIBGLESV2_VERTEXARRAY_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/VertexAttribute.cpp b/src/3rdparty/angle/src/libGLESv2/VertexAttribute.cpp
deleted file mode 100644
index 1096856b8a..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/VertexAttribute.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-//
-// Copyright 2014 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.
-//
-// Implementation of the state class for mananging GLES 3 Vertex Array Objects.
-//
-
-#include "libGLESv2/VertexAttribute.h"
-
-namespace gl
-{
-
-VertexAttribute::VertexAttribute()
- : enabled(false),
- type(GL_FLOAT),
- size(4),
- normalized(false),
- pureInteger(false),
- stride(0),
- pointer(NULL),
- divisor(0)
-{
-}
-
-size_t ComputeVertexAttributeTypeSize(const VertexAttribute& attrib)
-{
- GLuint size = attrib.size;
- switch (attrib.type)
- {
- case GL_BYTE: return size * sizeof(GLbyte);
- case GL_UNSIGNED_BYTE: return size * sizeof(GLubyte);
- case GL_SHORT: return size * sizeof(GLshort);
- case GL_UNSIGNED_SHORT: return size * sizeof(GLushort);
- case GL_INT: return size * sizeof(GLint);
- case GL_UNSIGNED_INT: return size * sizeof(GLuint);
- case GL_INT_2_10_10_10_REV: return 4;
- case GL_UNSIGNED_INT_2_10_10_10_REV: return 4;
- case GL_FIXED: return size * sizeof(GLfixed);
- case GL_HALF_FLOAT: return size * sizeof(GLhalf);
- case GL_FLOAT: return size * sizeof(GLfloat);
- default: UNREACHABLE(); return size * sizeof(GLfloat);
- }
-}
-
-size_t ComputeVertexAttributeStride(const VertexAttribute& attrib)
-{
- if (!attrib.enabled)
- {
- return 16;
- }
- return attrib.stride ? attrib.stride : ComputeVertexAttributeTypeSize(attrib);
-}
-
-} \ No newline at end of file
diff --git a/src/3rdparty/angle/src/libGLESv2/VertexAttribute.h b/src/3rdparty/angle/src/libGLESv2/VertexAttribute.h
deleted file mode 100644
index e9757b618b..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/VertexAttribute.h
+++ /dev/null
@@ -1,119 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-// Helper structure describing a single vertex attribute
-//
-
-#ifndef LIBGLESV2_VERTEXATTRIBUTE_H_
-#define LIBGLESV2_VERTEXATTRIBUTE_H_
-
-#include "libGLESv2/Buffer.h"
-
-namespace gl
-{
-
-struct VertexAttribute
-{
- bool enabled; // From glEnable/DisableVertexAttribArray
-
- GLenum type;
- GLuint size;
- bool normalized;
- bool pureInteger;
- GLuint stride; // 0 means natural stride
-
- union
- {
- const GLvoid *pointer;
- GLintptr offset;
- };
- BindingPointer<Buffer> buffer; // Captured when glVertexAttribPointer is called.
-
- GLuint divisor;
-
- VertexAttribute();
-};
-
-template <typename T>
-T QuerySingleVertexAttributeParameter(const VertexAttribute& attrib, GLenum pname)
-{
- switch (pname)
- {
- case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
- return static_cast<T>(attrib.enabled ? GL_TRUE : GL_FALSE);
- case GL_VERTEX_ATTRIB_ARRAY_SIZE:
- return static_cast<T>(attrib.size);
- case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
- return static_cast<T>(attrib.stride);
- case GL_VERTEX_ATTRIB_ARRAY_TYPE:
- return static_cast<T>(attrib.type);
- case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
- return static_cast<T>(attrib.normalized ? GL_TRUE : GL_FALSE);
- case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
- return static_cast<T>(attrib.buffer.id());
- case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
- return static_cast<T>(attrib.divisor);
- case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
- return static_cast<T>(attrib.pureInteger ? GL_TRUE : GL_FALSE);
- default:
- UNREACHABLE();
- return static_cast<T>(0);
- }
-}
-
-size_t ComputeVertexAttributeTypeSize(const VertexAttribute& attrib);
-size_t ComputeVertexAttributeStride(const VertexAttribute& attrib);
-
-struct VertexAttribCurrentValueData
-{
- union
- {
- GLfloat FloatValues[4];
- GLint IntValues[4];
- GLuint UnsignedIntValues[4];
- };
- GLenum Type;
-
- void setFloatValues(const GLfloat floatValues[4])
- {
- for (unsigned int valueIndex = 0; valueIndex < 4; valueIndex++)
- {
- FloatValues[valueIndex] = floatValues[valueIndex];
- }
- Type = GL_FLOAT;
- }
-
- void setIntValues(const GLint intValues[4])
- {
- for (unsigned int valueIndex = 0; valueIndex < 4; valueIndex++)
- {
- IntValues[valueIndex] = intValues[valueIndex];
- }
- Type = GL_INT;
- }
-
- void setUnsignedIntValues(const GLuint unsignedIntValues[4])
- {
- for (unsigned int valueIndex = 0; valueIndex < 4; valueIndex++)
- {
- UnsignedIntValues[valueIndex] = unsignedIntValues[valueIndex];
- }
- Type = GL_UNSIGNED_INT;
- }
-
- bool operator==(const VertexAttribCurrentValueData &other)
- {
- return (Type == other.Type && memcmp(FloatValues, other.FloatValues, sizeof(float) * 4) == 0);
- }
-
- bool operator!=(const VertexAttribCurrentValueData &other)
- {
- return !(*this == other);
- }
-};
-
-}
-
-#endif // LIBGLESV2_VERTEXATTRIBUTE_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/angletypes.cpp b/src/3rdparty/angle/src/libGLESv2/angletypes.cpp
deleted file mode 100644
index 5a0cfc5ad9..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/angletypes.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// angletypes.h : Defines a variety of structures and enum types that are used throughout libGLESv2
-
-#include "libGLESv2/angletypes.h"
-#include "libGLESv2/ProgramBinary.h"
-#include "libGLESv2/VertexAttribute.h"
-#include "libGLESv2/State.h"
-#include "libGLESv2/VertexArray.h"
-
-#include <float.h>
-
-namespace gl
-{
-
-SamplerState::SamplerState()
- : minFilter(GL_NEAREST_MIPMAP_LINEAR),
- magFilter(GL_LINEAR),
- wrapS(GL_REPEAT),
- wrapT(GL_REPEAT),
- wrapR(GL_REPEAT),
- maxAnisotropy(1.0f),
- baseLevel(0),
- maxLevel(1000),
- minLod(-FLT_MAX),
- maxLod(FLT_MAX),
- compareMode(GL_NONE),
- compareFunc(GL_LEQUAL),
- swizzleRed(GL_RED),
- swizzleGreen(GL_GREEN),
- swizzleBlue(GL_BLUE),
- swizzleAlpha(GL_ALPHA)
-{}
-
-bool SamplerState::swizzleRequired() const
-{
- return swizzleRed != GL_RED || swizzleGreen != GL_GREEN ||
- swizzleBlue != GL_BLUE || swizzleAlpha != GL_ALPHA;
-}
-
-static void MinMax(int a, int b, int *minimum, int *maximum)
-{
- if (a < b)
- {
- *minimum = a;
- *maximum = b;
- }
- else
- {
- *minimum = b;
- *maximum = a;
- }
-}
-
-bool ClipRectangle(const Rectangle &source, const Rectangle &clip, Rectangle *intersection)
-{
- int minSourceX, maxSourceX, minSourceY, maxSourceY;
- MinMax(source.x, source.x + source.width, &minSourceX, &maxSourceX);
- MinMax(source.y, source.y + source.height, &minSourceY, &maxSourceY);
-
- int minClipX, maxClipX, minClipY, maxClipY;
- MinMax(clip.x, clip.x + clip.width, &minClipX, &maxClipX);
- MinMax(clip.y, clip.y + clip.height, &minClipY, &maxClipY);
-
- if (minSourceX >= maxClipX || maxSourceX <= minClipX || minSourceY >= maxClipY || maxSourceY <= minClipY)
- {
- if (intersection)
- {
- intersection->x = minSourceX;
- intersection->y = maxSourceY;
- intersection->width = maxSourceX - minSourceX;
- intersection->height = maxSourceY - minSourceY;
- }
-
- return false;
- }
- else
- {
- if (intersection)
- {
- intersection->x = std::max(minSourceX, minClipX);
- intersection->y = std::max(minSourceY, minClipY);
- intersection->width = std::min(maxSourceX, maxClipX) - std::max(minSourceX, minClipX);
- intersection->height = std::min(maxSourceY, maxClipY) - std::max(minSourceY, minClipY);
- }
-
- return true;
- }
-}
-
-VertexFormat::VertexFormat()
- : mType(GL_NONE),
- mNormalized(GL_FALSE),
- mComponents(0),
- mPureInteger(false)
-{}
-
-VertexFormat::VertexFormat(GLenum type, GLboolean normalized, GLuint components, bool pureInteger)
- : mType(type),
- mNormalized(normalized),
- mComponents(components),
- mPureInteger(pureInteger)
-{
- // Float data can not be normalized, so ignore the user setting
- if (mType == GL_FLOAT || mType == GL_HALF_FLOAT || mType == GL_FIXED)
- {
- mNormalized = GL_FALSE;
- }
-}
-
-VertexFormat::VertexFormat(const VertexAttribute &attrib)
- : mType(attrib.type),
- mNormalized(attrib.normalized ? GL_TRUE : GL_FALSE),
- mComponents(attrib.size),
- mPureInteger(attrib.pureInteger)
-{
- // Ensure we aren't initializing a vertex format which should be using
- // the current-value type
- ASSERT(attrib.enabled);
-
- // Float data can not be normalized, so ignore the user setting
- if (mType == GL_FLOAT || mType == GL_HALF_FLOAT || mType == GL_FIXED)
- {
- mNormalized = GL_FALSE;
- }
-}
-
-VertexFormat::VertexFormat(const VertexAttribute &attrib, GLenum currentValueType)
- : mType(attrib.type),
- mNormalized(attrib.normalized ? GL_TRUE : GL_FALSE),
- mComponents(attrib.size),
- mPureInteger(attrib.pureInteger)
-{
- if (!attrib.enabled)
- {
- mType = currentValueType;
- mNormalized = GL_FALSE;
- mComponents = 4;
- mPureInteger = (currentValueType != GL_FLOAT);
- }
-
- // Float data can not be normalized, so ignore the user setting
- if (mType == GL_FLOAT || mType == GL_HALF_FLOAT || mType == GL_FIXED)
- {
- mNormalized = GL_FALSE;
- }
-}
-
-void VertexFormat::GetInputLayout(VertexFormat *inputLayout,
- ProgramBinary *programBinary,
- const State &state)
-{
- const VertexAttribute *vertexAttributes = state.getVertexArray()->getVertexAttributes();
- for (unsigned int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
- {
- int semanticIndex = programBinary->getSemanticIndex(attributeIndex);
-
- if (semanticIndex != -1)
- {
- inputLayout[semanticIndex] = VertexFormat(vertexAttributes[attributeIndex], state.getVertexAttribCurrentValue(attributeIndex).Type);
- }
- }
-}
-
-bool VertexFormat::operator==(const VertexFormat &other) const
-{
- return (mType == other.mType &&
- mComponents == other.mComponents &&
- mNormalized == other.mNormalized &&
- mPureInteger == other.mPureInteger );
-}
-
-bool VertexFormat::operator!=(const VertexFormat &other) const
-{
- return !(*this == other);
-}
-
-bool VertexFormat::operator<(const VertexFormat& other) const
-{
- if (mType != other.mType)
- {
- return mType < other.mType;
- }
- if (mNormalized != other.mNormalized)
- {
- return mNormalized < other.mNormalized;
- }
- if (mComponents != other.mComponents)
- {
- return mComponents < other.mComponents;
- }
- return mPureInteger < other.mPureInteger;
-}
-
-bool Box::operator==(const Box &other) const
-{
- return (x == other.x && y == other.y && z == other.z &&
- width == other.width && height == other.height && depth == other.depth);
-}
-
-bool Box::operator!=(const Box &other) const
-{
- return !(*this == other);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/angletypes.h b/src/3rdparty/angle/src/libGLESv2/angletypes.h
deleted file mode 100644
index 78fe6b0e26..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/angletypes.h
+++ /dev/null
@@ -1,257 +0,0 @@
-//
-// Copyright (c) 2012-2013 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.
-//
-
-// angletypes.h : Defines a variety of structures and enum types that are used throughout libGLESv2
-
-#ifndef LIBGLESV2_ANGLETYPES_H_
-#define LIBGLESV2_ANGLETYPES_H_
-
-#include "libGLESv2/Constants.h"
-#include "common/RefCountObject.h"
-
-namespace gl
-{
-class Buffer;
-class State;
-class ProgramBinary;
-struct VertexAttribute;
-struct VertexAttribCurrentValueData;
-
-enum SamplerType
-{
- SAMPLER_PIXEL,
- SAMPLER_VERTEX
-};
-
-template <typename T>
-struct Color
-{
- T red;
- T green;
- T blue;
- T alpha;
-
- Color() : red(0), green(0), blue(0), alpha(0) { }
- Color(T r, T g, T b, T a) : red(r), green(g), blue(b), alpha(a) { }
-};
-
-typedef Color<float> ColorF;
-typedef Color<int> ColorI;
-typedef Color<unsigned int> ColorUI;
-
-struct Rectangle
-{
- int x;
- int y;
- int width;
- int height;
-
- Rectangle() : x(0), y(0), width(0), height(0) { }
- Rectangle(int x_in, int y_in, int width_in, int height_in) : x(x_in), y(y_in), width(width_in), height(height_in) { }
-};
-
-bool ClipRectangle(const Rectangle &source, const Rectangle &clip, Rectangle *intersection);
-
-struct Box
-{
- int x;
- int y;
- int z;
- int width;
- int height;
- int depth;
-
- Box() : x(0), y(0), z(0), width(0), height(0), depth(0) { }
- Box(int x_in, int y_in, int z_in, int width_in, int height_in, int depth_in) : x(x_in), y(y_in), z(z_in), width(width_in), height(height_in), depth(depth_in) { }
- bool operator==(const Box &other) const;
- bool operator!=(const Box &other) const;
-};
-
-struct Extents
-{
- int width;
- int height;
- int depth;
-
- Extents() : width(0), height(0), depth(0) { }
- Extents(int width_, int height_, int depth_) : width(width_), height(height_), depth(depth_) { }
-};
-
-struct RasterizerState
-{
- bool cullFace;
- GLenum cullMode;
- GLenum frontFace;
-
- bool polygonOffsetFill;
- GLfloat polygonOffsetFactor;
- GLfloat polygonOffsetUnits;
-
- bool pointDrawMode;
- bool multiSample;
-
- bool rasterizerDiscard;
-};
-
-struct BlendState
-{
- bool blend;
- GLenum sourceBlendRGB;
- GLenum destBlendRGB;
- GLenum sourceBlendAlpha;
- GLenum destBlendAlpha;
- GLenum blendEquationRGB;
- GLenum blendEquationAlpha;
-
- bool colorMaskRed;
- bool colorMaskGreen;
- bool colorMaskBlue;
- bool colorMaskAlpha;
-
- bool sampleAlphaToCoverage;
-
- bool dither;
-};
-
-struct DepthStencilState
-{
- bool depthTest;
- GLenum depthFunc;
- bool depthMask;
-
- bool stencilTest;
- GLenum stencilFunc;
- GLuint stencilMask;
- GLenum stencilFail;
- GLenum stencilPassDepthFail;
- GLenum stencilPassDepthPass;
- GLuint stencilWritemask;
- GLenum stencilBackFunc;
- GLuint stencilBackMask;
- GLenum stencilBackFail;
- GLenum stencilBackPassDepthFail;
- GLenum stencilBackPassDepthPass;
- GLuint stencilBackWritemask;
-};
-
-struct SamplerState
-{
- SamplerState();
-
- GLenum minFilter;
- GLenum magFilter;
- GLenum wrapS;
- GLenum wrapT;
- GLenum wrapR;
- float maxAnisotropy;
-
- GLint baseLevel;
- GLint maxLevel;
- GLfloat minLod;
- GLfloat maxLod;
-
- GLenum compareMode;
- GLenum compareFunc;
-
- GLenum swizzleRed;
- GLenum swizzleGreen;
- GLenum swizzleBlue;
- GLenum swizzleAlpha;
-
- bool swizzleRequired() const;
-};
-
-struct ClearParameters
-{
- bool clearColor[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS];
- ColorF colorFClearValue;
- ColorI colorIClearValue;
- ColorUI colorUIClearValue;
- GLenum colorClearType;
- bool colorMaskRed;
- bool colorMaskGreen;
- bool colorMaskBlue;
- bool colorMaskAlpha;
-
- bool clearDepth;
- float depthClearValue;
-
- bool clearStencil;
- GLint stencilClearValue;
- GLuint stencilWriteMask;
-
- bool scissorEnabled;
- Rectangle scissor;
-};
-
-struct PixelUnpackState
-{
- BindingPointer<Buffer> pixelBuffer;
- GLint alignment;
-
- PixelUnpackState()
- : alignment(4)
- {}
-
- explicit PixelUnpackState(GLint alignmentIn)
- : alignment(alignmentIn)
- {}
-};
-
-struct PixelPackState
-{
- BindingPointer<Buffer> pixelBuffer;
- GLint alignment;
- bool reverseRowOrder;
-
- PixelPackState()
- : alignment(4),
- reverseRowOrder(false)
- {}
-
- explicit PixelPackState(GLint alignmentIn, bool reverseRowOrderIn)
- : alignment(alignmentIn),
- reverseRowOrder(reverseRowOrderIn)
- {}
-};
-
-struct VertexFormat
-{
- GLenum mType;
- GLboolean mNormalized;
- GLuint mComponents;
- bool mPureInteger;
-
- VertexFormat();
- VertexFormat(GLenum type, GLboolean normalized, GLuint components, bool pureInteger);
- explicit VertexFormat(const VertexAttribute &attribute);
- VertexFormat(const VertexAttribute &attribute, GLenum currentValueType);
-
- static void GetInputLayout(VertexFormat *inputLayout,
- ProgramBinary *programBinary,
- const State& currentValues);
-
- bool operator==(const VertexFormat &other) const;
- bool operator!=(const VertexFormat &other) const;
- bool operator<(const VertexFormat& other) const;
-};
-
-}
-
-namespace rx
-{
-
-enum VertexConversionType
-{
- VERTEX_CONVERT_NONE = 0,
- VERTEX_CONVERT_CPU = 1,
- VERTEX_CONVERT_GPU = 2,
- VERTEX_CONVERT_BOTH = 3
-};
-
-}
-
-#endif // LIBGLESV2_ANGLETYPES_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/constants.h b/src/3rdparty/angle/src/libGLESv2/constants.h
deleted file mode 100644
index 69c4823fb2..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/constants.h
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// Contants.h: Defines some implementation specific and gl constants
-
-#ifndef LIBGLESV2_CONSTANTS_H_
-#define LIBGLESV2_CONSTANTS_H_
-
-namespace gl
-{
-
-enum
-{
- MAX_VERTEX_ATTRIBS = 16,
-
- // Implementation upper limits, real maximums depend on the hardware
- IMPLEMENTATION_MAX_VARYING_VECTORS = 32,
- IMPLEMENTATION_MAX_DRAW_BUFFERS = 8,
- IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS = IMPLEMENTATION_MAX_DRAW_BUFFERS + 2, // 2 extra for depth and/or stencil buffers
-
- IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS = 16,
- IMPLEMENTATION_MAX_FRAGMENT_SHADER_UNIFORM_BUFFERS = 16,
- IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS = IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS +
- IMPLEMENTATION_MAX_FRAGMENT_SHADER_UNIFORM_BUFFERS,
-
- IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS = 4,
-
- // These are the maximums the implementation can support
- // The actual GL caps are limited by the device caps
- // and should be queried from the Context
- IMPLEMENTATION_MAX_2D_TEXTURE_SIZE = 16384,
- IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE = 16384,
- IMPLEMENTATION_MAX_3D_TEXTURE_SIZE = 2048,
- IMPLEMENTATION_MAX_2D_ARRAY_TEXTURE_LAYERS = 2048,
-
- IMPLEMENTATION_MAX_TEXTURE_LEVELS = 15 // 1+log2 of MAX_TEXTURE_SIZE
-};
-
-}
-
-#endif // LIBGLESV2_CONSTANTS_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_egl.cpp b/src/3rdparty/angle/src/libGLESv2/entry_points_egl.cpp
new file mode 100644
index 0000000000..a6db1585e7
--- /dev/null
+++ b/src/3rdparty/angle/src/libGLESv2/entry_points_egl.cpp
@@ -0,0 +1,1127 @@
+//
+// Copyright(c) 2014 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.
+//
+
+// entry_points_egl.cpp : Implements the EGL entry points.
+
+#include "libGLESv2/entry_points_egl.h"
+#include "libGLESv2/entry_points_egl_ext.h"
+#include "libGLESv2/entry_points_gles_2_0_ext.h"
+#include "libGLESv2/entry_points_gles_3_0_ext.h"
+#include "libGLESv2/global_state.h"
+
+#include "libANGLE/Context.h"
+#include "libANGLE/Display.h"
+#include "libANGLE/Texture.h"
+#include "libANGLE/Surface.h"
+#include "libANGLE/validationEGL.h"
+
+#include "common/debug.h"
+#include "common/version.h"
+
+#include <EGL/eglext.h>
+
+namespace egl
+{
+
+// EGL 1.0
+EGLint EGLAPIENTRY GetError(void)
+{
+ EVENT("()");
+
+ EGLint error = GetGlobalError();
+ SetGlobalError(Error(EGL_SUCCESS));
+ return error;
+}
+
+EGLDisplay EGLAPIENTRY GetDisplay(EGLNativeDisplayType display_id)
+{
+ EVENT("(EGLNativeDisplayType display_id = 0x%0.8p)", display_id);
+
+ return Display::getDisplay(display_id, AttributeMap());
+}
+
+EGLBoolean EGLAPIENTRY Initialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint *major = 0x%0.8p, EGLint *minor = 0x%0.8p)",
+ dpy, major, minor);
+
+ if (dpy == EGL_NO_DISPLAY)
+ {
+ SetGlobalError(Error(EGL_BAD_DISPLAY));
+ return EGL_FALSE;
+ }
+
+ Display *display = static_cast<Display*>(dpy);
+
+ Error error = display->initialize();
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ if (major) *major = 1;
+ if (minor) *minor = 4;
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY Terminate(EGLDisplay dpy)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p)", dpy);
+
+ if (dpy == EGL_NO_DISPLAY)
+ {
+ SetGlobalError(Error(EGL_BAD_DISPLAY));
+ return EGL_FALSE;
+ }
+
+ Display *display = static_cast<Display*>(dpy);
+ gl::Context *context = GetGlobalContext();
+
+ if (display->isValidContext(context))
+ {
+ SetGlobalContext(NULL);
+ SetGlobalDisplay(NULL);
+ }
+
+ display->terminate();
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+const char *EGLAPIENTRY QueryString(EGLDisplay dpy, EGLint name)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint name = %d)", dpy, name);
+
+ Display *display = static_cast<Display*>(dpy);
+ if (!(display == EGL_NO_DISPLAY && name == EGL_EXTENSIONS))
+ {
+ Error error = ValidateDisplay(display);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return NULL;
+ }
+ }
+
+ const char *result;
+ switch (name)
+ {
+ case EGL_CLIENT_APIS:
+ result = "OpenGL_ES";
+ break;
+ case EGL_EXTENSIONS:
+ if (display == EGL_NO_DISPLAY)
+ {
+ result = Display::getClientExtensionString().c_str();
+ }
+ else
+ {
+ result = display->getExtensionString().c_str();
+ }
+ break;
+ case EGL_VENDOR:
+ result = display->getVendorString().c_str();
+ break;
+ case EGL_VERSION:
+ result = "1.4 (ANGLE " ANGLE_VERSION_STRING ")";
+ break;
+ default:
+ SetGlobalError(Error(EGL_BAD_PARAMETER));
+ return NULL;
+ }
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return result;
+}
+
+EGLBoolean EGLAPIENTRY GetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig *configs = 0x%0.8p, "
+ "EGLint config_size = %d, EGLint *num_config = 0x%0.8p)",
+ dpy, configs, config_size, num_config);
+
+ Display *display = static_cast<Display*>(dpy);
+
+ Error error = ValidateDisplay(display);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ if (!num_config)
+ {
+ SetGlobalError(Error(EGL_BAD_PARAMETER));
+ return EGL_FALSE;
+ }
+
+ std::vector<const Config*> filteredConfigs = display->getConfigs(AttributeMap());
+ if (configs)
+ {
+ filteredConfigs.resize(std::min<size_t>(filteredConfigs.size(), config_size));
+ for (size_t i = 0; i < filteredConfigs.size(); i++)
+ {
+ configs[i] = const_cast<Config*>(filteredConfigs[i]);
+ }
+ }
+ *num_config = filteredConfigs.size();
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY ChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p, "
+ "EGLConfig *configs = 0x%0.8p, EGLint config_size = %d, EGLint *num_config = 0x%0.8p)",
+ dpy, attrib_list, configs, config_size, num_config);
+
+ Display *display = static_cast<Display*>(dpy);
+
+ Error error = ValidateDisplay(display);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ if (!num_config)
+ {
+ SetGlobalError(Error(EGL_BAD_PARAMETER));
+ return EGL_FALSE;
+ }
+
+ std::vector<const Config*> filteredConfigs = display->getConfigs(AttributeMap(attrib_list));
+ if (configs)
+ {
+ filteredConfigs.resize(std::min<size_t>(filteredConfigs.size(), config_size));
+ for (size_t i = 0; i < filteredConfigs.size(); i++)
+ {
+ configs[i] = const_cast<Config*>(filteredConfigs[i]);
+ }
+ }
+ *num_config = filteredConfigs.size();
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)",
+ dpy, config, attribute, value);
+
+ Display *display = static_cast<Display*>(dpy);
+ Config *configuration = static_cast<Config*>(config);
+
+ Error error = ValidateConfig(display, configuration);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ if (!display->getConfigAttrib(configuration, attribute, value))
+ {
+ SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ return EGL_FALSE;
+ }
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+EGLSurface EGLAPIENTRY CreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLNativeWindowType win = 0x%0.8p, "
+ "const EGLint *attrib_list = 0x%0.8p)", dpy, config, win, attrib_list);
+
+ Display *display = static_cast<Display*>(dpy);
+ Config *configuration = static_cast<Config*>(config);
+ AttributeMap attributes(attrib_list);
+
+ Error error = ValidateCreateWindowSurface(display, configuration, win, attributes);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_NO_SURFACE;
+ }
+
+ egl::Surface *surface = nullptr;
+ error = display->createWindowSurface(configuration, win, attributes, &surface);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_NO_SURFACE;
+ }
+
+ return static_cast<EGLSurface>(surface);
+}
+
+EGLSurface EGLAPIENTRY CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p)",
+ dpy, config, attrib_list);
+
+ Display *display = static_cast<Display*>(dpy);
+ Config *configuration = static_cast<Config*>(config);
+ AttributeMap attributes(attrib_list);
+
+ Error error = ValidateCreatePbufferSurface(display, configuration, attributes);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_NO_SURFACE;
+ }
+
+ egl::Surface *surface = nullptr;
+ error = display->createPbufferSurface(configuration, attributes, &surface);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_NO_SURFACE;
+ }
+
+ return static_cast<EGLSurface>(surface);
+}
+
+EGLSurface EGLAPIENTRY CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLNativePixmapType pixmap = 0x%0.8p, "
+ "const EGLint *attrib_list = 0x%0.8p)", dpy, config, pixmap, attrib_list);
+
+ Display *display = static_cast<Display*>(dpy);
+ Config *configuration = static_cast<Config*>(config);
+
+ Error error = ValidateConfig(display, configuration);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_NO_SURFACE;
+ }
+
+ UNIMPLEMENTED(); // FIXME
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_NO_SURFACE;
+}
+
+EGLBoolean EGLAPIENTRY DestroySurface(EGLDisplay dpy, EGLSurface surface)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p)", dpy, surface);
+
+ Display *display = static_cast<Display*>(dpy);
+ Surface *eglSurface = static_cast<Surface*>(surface);
+
+ Error error = ValidateSurface(display, eglSurface);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ if (surface == EGL_NO_SURFACE)
+ {
+ SetGlobalError(Error(EGL_BAD_SURFACE));
+ return EGL_FALSE;
+ }
+
+ display->destroySurface((Surface*)surface);
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)",
+ dpy, surface, attribute, value);
+
+ Display *display = static_cast<Display*>(dpy);
+ Surface *eglSurface = (Surface*)surface;
+
+ Error error = ValidateSurface(display, eglSurface);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ if (surface == EGL_NO_SURFACE)
+ {
+ SetGlobalError(Error(EGL_BAD_SURFACE));
+ return EGL_FALSE;
+ }
+
+ switch (attribute)
+ {
+ case EGL_VG_ALPHA_FORMAT:
+ UNIMPLEMENTED(); // FIXME
+ break;
+ case EGL_VG_COLORSPACE:
+ UNIMPLEMENTED(); // FIXME
+ break;
+ case EGL_CONFIG_ID:
+ *value = eglSurface->getConfig()->configID;
+ break;
+ case EGL_HEIGHT:
+ *value = eglSurface->getHeight();
+ break;
+ case EGL_HORIZONTAL_RESOLUTION:
+ UNIMPLEMENTED(); // FIXME
+ break;
+ case EGL_LARGEST_PBUFFER:
+ UNIMPLEMENTED(); // FIXME
+ break;
+ case EGL_MIPMAP_TEXTURE:
+ UNIMPLEMENTED(); // FIXME
+ break;
+ case EGL_MIPMAP_LEVEL:
+ UNIMPLEMENTED(); // FIXME
+ break;
+ case EGL_MULTISAMPLE_RESOLVE:
+ UNIMPLEMENTED(); // FIXME
+ break;
+ case EGL_PIXEL_ASPECT_RATIO:
+ *value = eglSurface->getPixelAspectRatio();
+ break;
+ case EGL_RENDER_BUFFER:
+ *value = eglSurface->getRenderBuffer();
+ break;
+ case EGL_SWAP_BEHAVIOR:
+ *value = eglSurface->getSwapBehavior();
+ break;
+ case EGL_TEXTURE_FORMAT:
+ *value = eglSurface->getTextureFormat();
+ break;
+ case EGL_TEXTURE_TARGET:
+ *value = eglSurface->getTextureTarget();
+ break;
+ case EGL_VERTICAL_RESOLUTION:
+ UNIMPLEMENTED(); // FIXME
+ break;
+ case EGL_WIDTH:
+ *value = eglSurface->getWidth();
+ break;
+ case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
+ if (!display->getExtensions().postSubBuffer)
+ {
+ SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ return EGL_FALSE;
+ }
+ *value = eglSurface->isPostSubBufferSupported();
+ break;
+ case EGL_FIXED_SIZE_ANGLE:
+ if (!display->getExtensions().windowFixedSize)
+ {
+ SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ return EGL_FALSE;
+ }
+ *value = eglSurface->isFixedSize();
+ break;
+ default:
+ SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ return EGL_FALSE;
+ }
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+EGLContext EGLAPIENTRY CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLContext share_context = 0x%0.8p, "
+ "const EGLint *attrib_list = 0x%0.8p)", dpy, config, share_context, attrib_list);
+
+ Display *display = static_cast<Display*>(dpy);
+ Config *configuration = static_cast<Config*>(config);
+ gl::Context* sharedGLContext = static_cast<gl::Context*>(share_context);
+ AttributeMap attributes(attrib_list);
+
+ Error error = ValidateCreateContext(display, configuration, sharedGLContext, attributes);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_NO_CONTEXT;
+ }
+
+ gl::Context *context = nullptr;
+ error = display->createContext(configuration, sharedGLContext, attributes, &context);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_NO_CONTEXT;
+ }
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return static_cast<EGLContext>(context);
+}
+
+EGLBoolean EGLAPIENTRY DestroyContext(EGLDisplay dpy, EGLContext ctx)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLContext ctx = 0x%0.8p)", dpy, ctx);
+
+ Display *display = static_cast<Display*>(dpy);
+ gl::Context *context = static_cast<gl::Context*>(ctx);
+
+ Error error = ValidateContext(display, context);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ if (ctx == EGL_NO_CONTEXT)
+ {
+ SetGlobalError(Error(EGL_BAD_CONTEXT));
+ return EGL_FALSE;
+ }
+
+ if (context == GetGlobalContext())
+ {
+ SetGlobalDisplay(NULL);
+ SetGlobalContext(NULL);
+ }
+
+ display->destroyContext(context);
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface draw = 0x%0.8p, EGLSurface read = 0x%0.8p, EGLContext ctx = 0x%0.8p)",
+ dpy, draw, read, ctx);
+
+ Display *display = static_cast<Display*>(dpy);
+ gl::Context *context = static_cast<gl::Context*>(ctx);
+
+ bool noContext = (ctx == EGL_NO_CONTEXT);
+ bool noSurface = (draw == EGL_NO_SURFACE || read == EGL_NO_SURFACE);
+ if (noContext != noSurface)
+ {
+ SetGlobalError(Error(EGL_BAD_MATCH));
+ return EGL_FALSE;
+ }
+
+ if (ctx != EGL_NO_CONTEXT)
+ {
+ Error error = ValidateContext(display, context);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+ }
+
+ if (dpy != EGL_NO_DISPLAY && display->isInitialized())
+ {
+ if (display->testDeviceLost())
+ {
+ display->notifyDeviceLost();
+ return EGL_FALSE;
+ }
+
+ if (display->isDeviceLost())
+ {
+ SetGlobalError(Error(EGL_CONTEXT_LOST));
+ return EGL_FALSE;
+ }
+ }
+
+ Surface *drawSurface = static_cast<Surface*>(draw);
+ if (draw != EGL_NO_SURFACE)
+ {
+ Error error = ValidateSurface(display, drawSurface);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+ }
+
+ Surface *readSurface = static_cast<Surface*>(read);
+ if (read != EGL_NO_SURFACE)
+ {
+ Error error = ValidateSurface(display, readSurface);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+ }
+
+ if (draw != read)
+ {
+ UNIMPLEMENTED(); // FIXME
+ }
+
+ SetGlobalDisplay(display);
+ SetGlobalDrawSurface(drawSurface);
+ SetGlobalReadSurface(readSurface);
+ SetGlobalContext(context);
+
+ if (context != nullptr && display != nullptr && drawSurface != nullptr)
+ {
+ display->makeCurrent(drawSurface, readSurface, context);
+ }
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+EGLSurface EGLAPIENTRY GetCurrentSurface(EGLint readdraw)
+{
+ EVENT("(EGLint readdraw = %d)", readdraw);
+
+ if (readdraw == EGL_READ)
+ {
+ SetGlobalError(Error(EGL_SUCCESS));
+ return GetGlobalReadSurface();
+ }
+ else if (readdraw == EGL_DRAW)
+ {
+ SetGlobalError(Error(EGL_SUCCESS));
+ return GetGlobalDrawSurface();
+ }
+ else
+ {
+ SetGlobalError(Error(EGL_BAD_PARAMETER));
+ return EGL_NO_SURFACE;
+ }
+}
+
+EGLDisplay EGLAPIENTRY GetCurrentDisplay(void)
+{
+ EVENT("()");
+
+ EGLDisplay dpy = GetGlobalDisplay();
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return dpy;
+}
+
+EGLBoolean EGLAPIENTRY QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLContext ctx = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)",
+ dpy, ctx, attribute, value);
+
+ Display *display = static_cast<Display*>(dpy);
+ gl::Context *context = static_cast<gl::Context*>(ctx);
+
+ Error error = ValidateContext(display, context);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ switch (attribute)
+ {
+ case EGL_CONFIG_ID:
+ *value = context->getConfigID();
+ break;
+ case EGL_CONTEXT_CLIENT_TYPE:
+ *value = context->getClientType();
+ break;
+ case EGL_CONTEXT_CLIENT_VERSION:
+ *value = context->getClientVersion();
+ break;
+ case EGL_RENDER_BUFFER:
+ *value = context->getRenderBuffer();
+ break;
+ default:
+ SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ return EGL_FALSE;
+ }
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY WaitGL(void)
+{
+ EVENT("()");
+
+ UNIMPLEMENTED(); // FIXME
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return 0;
+}
+
+EGLBoolean EGLAPIENTRY WaitNative(EGLint engine)
+{
+ EVENT("(EGLint engine = %d)", engine);
+
+ UNIMPLEMENTED(); // FIXME
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return 0;
+}
+
+EGLBoolean EGLAPIENTRY SwapBuffers(EGLDisplay dpy, EGLSurface surface)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p)", dpy, surface);
+
+ Display *display = static_cast<Display*>(dpy);
+ Surface *eglSurface = (Surface*)surface;
+
+ Error error = ValidateSurface(display, eglSurface);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ if (display->isDeviceLost())
+ {
+ SetGlobalError(Error(EGL_CONTEXT_LOST));
+ return EGL_FALSE;
+ }
+
+ if (surface == EGL_NO_SURFACE)
+ {
+ SetGlobalError(Error(EGL_BAD_SURFACE));
+ return EGL_FALSE;
+ }
+
+ error = eglSurface->swap();
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLNativePixmapType target = 0x%0.8p)", dpy, surface, target);
+
+ Display *display = static_cast<Display*>(dpy);
+ Surface *eglSurface = static_cast<Surface*>(surface);
+
+ Error error = ValidateSurface(display, eglSurface);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ if (display->isDeviceLost())
+ {
+ SetGlobalError(Error(EGL_CONTEXT_LOST));
+ return EGL_FALSE;
+ }
+
+ UNIMPLEMENTED(); // FIXME
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return 0;
+}
+
+// EGL 1.1
+EGLBoolean EGLAPIENTRY BindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint buffer = %d)", dpy, surface, buffer);
+
+ Display *display = static_cast<Display*>(dpy);
+ Surface *eglSurface = static_cast<Surface*>(surface);
+
+ Error error = ValidateSurface(display, eglSurface);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ if (buffer != EGL_BACK_BUFFER)
+ {
+ SetGlobalError(Error(EGL_BAD_PARAMETER));
+ return EGL_FALSE;
+ }
+
+ if (surface == EGL_NO_SURFACE || eglSurface->getType() == EGL_WINDOW_BIT)
+ {
+ SetGlobalError(Error(EGL_BAD_SURFACE));
+ return EGL_FALSE;
+ }
+
+ if (eglSurface->getBoundTexture())
+ {
+ SetGlobalError(Error(EGL_BAD_ACCESS));
+ return EGL_FALSE;
+ }
+
+ if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE)
+ {
+ SetGlobalError(Error(EGL_BAD_MATCH));
+ return EGL_FALSE;
+ }
+
+ gl::Context *context = GetGlobalContext();
+ if (context)
+ {
+ gl::Texture *textureObject = context->getTargetTexture(GL_TEXTURE_2D);
+ ASSERT(textureObject != NULL);
+
+ if (textureObject->isImmutable())
+ {
+ SetGlobalError(Error(EGL_BAD_MATCH));
+ return EGL_FALSE;
+ }
+
+ eglSurface->bindTexImage(textureObject, buffer);
+ }
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, EGLint value = %d)",
+ dpy, surface, attribute, value);
+
+ Display *display = static_cast<Display*>(dpy);
+ Surface *eglSurface = static_cast<Surface*>(surface);
+
+ Error error = ValidateSurface(display, eglSurface);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ UNIMPLEMENTED(); // FIXME
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint buffer = %d)", dpy, surface, buffer);
+
+ Display *display = static_cast<Display*>(dpy);
+ Surface *eglSurface = static_cast<Surface*>(surface);
+
+ Error error = ValidateSurface(display, eglSurface);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ if (buffer != EGL_BACK_BUFFER)
+ {
+ SetGlobalError(Error(EGL_BAD_PARAMETER));
+ return EGL_FALSE;
+ }
+
+ if (surface == EGL_NO_SURFACE || eglSurface->getType() == EGL_WINDOW_BIT)
+ {
+ SetGlobalError(Error(EGL_BAD_SURFACE));
+ return EGL_FALSE;
+ }
+
+ if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE)
+ {
+ SetGlobalError(Error(EGL_BAD_MATCH));
+ return EGL_FALSE;
+ }
+
+ gl::Texture *texture = eglSurface->getBoundTexture();
+
+ if (texture)
+ {
+ eglSurface->releaseTexImage(buffer);
+ }
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY SwapInterval(EGLDisplay dpy, EGLint interval)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint interval = %d)", dpy, interval);
+
+ Display *display = static_cast<Display*>(dpy);
+
+ Error error = ValidateDisplay(display);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ Surface *draw_surface = static_cast<Surface*>(GetGlobalDrawSurface());
+
+ if (draw_surface == NULL)
+ {
+ SetGlobalError(Error(EGL_BAD_SURFACE));
+ return EGL_FALSE;
+ }
+
+ const egl::Config *surfaceConfig = draw_surface->getConfig();
+ EGLint clampedInterval = std::min(std::max(interval, surfaceConfig->minSwapInterval), surfaceConfig->maxSwapInterval);
+
+ draw_surface->setSwapInterval(clampedInterval);
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+
+// EGL 1.2
+EGLBoolean EGLAPIENTRY BindAPI(EGLenum api)
+{
+ EVENT("(EGLenum api = 0x%X)", api);
+
+ switch (api)
+ {
+ case EGL_OPENGL_API:
+ case EGL_OPENVG_API:
+ SetGlobalError(Error(EGL_BAD_PARAMETER));
+ return EGL_FALSE; // Not supported by this implementation
+ case EGL_OPENGL_ES_API:
+ break;
+ default:
+ SetGlobalError(Error(EGL_BAD_PARAMETER));
+ return EGL_FALSE;
+ }
+
+ SetGlobalAPI(api);
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+EGLenum EGLAPIENTRY QueryAPI(void)
+{
+ EVENT("()");
+
+ EGLenum API = GetGlobalAPI();
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return API;
+}
+
+EGLSurface EGLAPIENTRY CreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLenum buftype = 0x%X, EGLClientBuffer buffer = 0x%0.8p, "
+ "EGLConfig config = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p)",
+ dpy, buftype, buffer, config, attrib_list);
+
+ Display *display = static_cast<Display*>(dpy);
+ Config *configuration = static_cast<Config*>(config);
+ AttributeMap attributes(attrib_list);
+
+ Error error = ValidateCreatePbufferFromClientBuffer(display, buftype, buffer, configuration, attributes);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_NO_SURFACE;
+ }
+
+ egl::Surface *surface = nullptr;
+ error = display->createPbufferFromClientBuffer(configuration, buffer, attributes, &surface);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_NO_SURFACE;
+ }
+
+ return static_cast<EGLSurface>(surface);
+}
+
+EGLBoolean EGLAPIENTRY ReleaseThread(void)
+{
+ EVENT("()");
+
+ MakeCurrent(EGL_NO_DISPLAY, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE);
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY WaitClient(void)
+{
+ EVENT("()");
+
+ UNIMPLEMENTED(); // FIXME
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return 0;
+}
+
+// EGL 1.4
+EGLContext EGLAPIENTRY GetCurrentContext(void)
+{
+ EVENT("()");
+
+ gl::Context *context = GetGlobalContext();
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return static_cast<EGLContext>(context);
+}
+
+// EGL 1.5
+EGLSync EGLAPIENTRY CreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLenum type = 0x%X, const EGLint* attrib_list = 0x%0.8p)", dpy, type, attrib_list);
+
+ UNIMPLEMENTED();
+ return EGL_NO_SYNC;
+}
+
+EGLBoolean EGLAPIENTRY DestroySync(EGLDisplay dpy, EGLSync sync)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSync sync = 0x%0.8p)", dpy, sync);
+
+ UNIMPLEMENTED();
+ return EGL_FALSE;
+}
+
+EGLint EGLAPIENTRY ClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSync sync = 0x%0.8p, EGLint flags = 0x%X, EGLTime timeout = %d)", dpy, sync, flags, timeout);
+
+ UNIMPLEMENTED();
+ return 0;
+}
+
+EGLBoolean EGLAPIENTRY GetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSync sync = 0x%0.8p, EGLint attribute = 0x%X, EGLAttrib *value = 0x%0.8p)", dpy, sync, attribute, value);
+
+ UNIMPLEMENTED();
+ return EGL_FALSE;
+}
+
+EGLImage EGLAPIENTRY CreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLContext ctx = 0x%0.8p, EGLenum target = 0x%X, "
+ "EGLClientBuffer buffer = 0x%0.8p, const EGLAttrib *attrib_list = 0x%0.8p)",
+ dpy, ctx, target, buffer, attrib_list);
+
+ UNIMPLEMENTED();
+ return EGL_NO_IMAGE;
+}
+
+EGLBoolean EGLAPIENTRY DestroyImage(EGLDisplay dpy, EGLImage image)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLImage image = 0x%0.8p)", dpy, image);
+
+ UNIMPLEMENTED();
+ return EGL_FALSE;
+}
+
+EGLDisplay EGLAPIENTRY GetPlatformDisplay(EGLenum platform, void *native_display, const EGLAttrib *attrib_list)
+{
+ EVENT("(EGLenum platform = %d, void* native_display = 0x%0.8p, const EGLint* attrib_list = 0x%0.8p)",
+ platform, native_display, attrib_list);
+
+ UNIMPLEMENTED();
+ return EGL_NO_DISPLAY;
+}
+
+EGLSurface EGLAPIENTRY CreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, void* native_window = 0x%0.8p, const EGLint* attrib_list = 0x%0.8p)",
+ dpy, config, native_window, attrib_list);
+
+ UNIMPLEMENTED();
+ return EGL_NO_SURFACE;
+}
+
+EGLSurface EGLAPIENTRY CreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, void* native_pixmap = 0x%0.8p, const EGLint* attrib_list = 0x%0.8p)",
+ dpy, config, native_pixmap, attrib_list);
+
+ UNIMPLEMENTED();
+ return EGL_NO_SURFACE;
+}
+
+EGLBoolean EGLAPIENTRY WaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSync sync = 0x%0.8p, EGLint flags = 0x%X)", dpy, sync, flags);
+
+ UNIMPLEMENTED();
+ return EGL_FALSE;
+}
+
+__eglMustCastToProperFunctionPointerType EGLAPIENTRY GetProcAddress(const char *procname)
+{
+ EVENT("(const char *procname = \"%s\")", procname);
+
+ struct Extension
+ {
+ const char *name;
+ __eglMustCastToProperFunctionPointerType address;
+ };
+
+ static const Extension extensions[] =
+ {
+ { "eglQuerySurfacePointerANGLE", (__eglMustCastToProperFunctionPointerType)QuerySurfacePointerANGLE },
+ { "eglPostSubBufferNV", (__eglMustCastToProperFunctionPointerType)PostSubBufferNV },
+ { "eglGetPlatformDisplayEXT", (__eglMustCastToProperFunctionPointerType)GetPlatformDisplayEXT },
+ { "glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)gl::BlitFramebufferANGLE },
+ { "glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)gl::RenderbufferStorageMultisampleANGLE },
+ { "glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)gl::DeleteFencesNV },
+ { "glGenFencesNV", (__eglMustCastToProperFunctionPointerType)gl::GenFencesNV },
+ { "glIsFenceNV", (__eglMustCastToProperFunctionPointerType)gl::IsFenceNV },
+ { "glTestFenceNV", (__eglMustCastToProperFunctionPointerType)gl::TestFenceNV },
+ { "glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)gl::GetFenceivNV },
+ { "glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)gl::FinishFenceNV },
+ { "glSetFenceNV", (__eglMustCastToProperFunctionPointerType)gl::SetFenceNV },
+ { "glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)gl::GetTranslatedShaderSourceANGLE },
+ { "glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)gl::TexStorage2DEXT },
+ { "glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)gl::GetGraphicsResetStatusEXT },
+ { "glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)gl::ReadnPixelsEXT },
+ { "glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)gl::GetnUniformfvEXT },
+ { "glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)gl::GetnUniformivEXT },
+ { "glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)gl::GenQueriesEXT },
+ { "glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)gl::DeleteQueriesEXT },
+ { "glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)gl::IsQueryEXT },
+ { "glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)gl::BeginQueryEXT },
+ { "glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)gl::EndQueryEXT },
+ { "glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)gl::GetQueryivEXT },
+ { "glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)gl::GetQueryObjectuivEXT },
+ { "glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)gl::DrawBuffersEXT },
+ { "glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)gl::VertexAttribDivisorANGLE },
+ { "glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)gl::DrawArraysInstancedANGLE },
+ { "glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)gl::DrawElementsInstancedANGLE },
+ { "glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)gl::GetProgramBinaryOES },
+ { "glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)gl::ProgramBinaryOES },
+ { "glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)gl::GetBufferPointervOES },
+ { "glMapBufferOES", (__eglMustCastToProperFunctionPointerType)gl::MapBufferOES },
+ { "glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)gl::UnmapBufferOES },
+ { "glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)gl::MapBufferRangeEXT },
+ { "glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)gl::FlushMappedBufferRangeEXT },
+ { "", NULL },
+ };
+
+ for (const Extension *extension = &extensions[0]; extension->address != nullptr; extension++)
+ {
+ if (strcmp(procname, extension->name) == 0)
+ {
+ return reinterpret_cast<__eglMustCastToProperFunctionPointerType>(extension->address);
+ }
+ }
+
+ return NULL;
+}
+
+}
diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_egl.h b/src/3rdparty/angle/src/libGLESv2/entry_points_egl.h
new file mode 100644
index 0000000000..259a209684
--- /dev/null
+++ b/src/3rdparty/angle/src/libGLESv2/entry_points_egl.h
@@ -0,0 +1,74 @@
+//
+// Copyright(c) 2014 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.
+//
+
+// entry_points_egl.h : Defines the EGL entry points.
+
+#ifndef LIBGLESV2_ENTRYPOINTSEGL_H_
+#define LIBGLESV2_ENTRYPOINTSEGL_H_
+
+#include <EGL/egl.h>
+#include <export.h>
+
+namespace egl
+{
+
+// EGL 1.0
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY ChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
+ANGLE_EXPORT EGLContext EGLAPIENTRY CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
+ANGLE_EXPORT EGLSurface EGLAPIENTRY CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
+ANGLE_EXPORT EGLSurface EGLAPIENTRY CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
+ANGLE_EXPORT EGLSurface EGLAPIENTRY CreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY DestroyContext(EGLDisplay dpy, EGLContext ctx);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY DestroySurface(EGLDisplay dpy, EGLSurface surface);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY GetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
+ANGLE_EXPORT EGLDisplay EGLAPIENTRY GetCurrentDisplay(void);
+ANGLE_EXPORT EGLSurface EGLAPIENTRY GetCurrentSurface(EGLint readdraw);
+ANGLE_EXPORT EGLDisplay EGLAPIENTRY GetDisplay(EGLNativeDisplayType display_id);
+ANGLE_EXPORT EGLint EGLAPIENTRY GetError(void);
+ANGLE_EXPORT __eglMustCastToProperFunctionPointerType EGLAPIENTRY GetProcAddress(const char *procname);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY Initialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
+ANGLE_EXPORT const char *EGLAPIENTRY QueryString(EGLDisplay dpy, EGLint name);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY SwapBuffers(EGLDisplay dpy, EGLSurface surface);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY Terminate(EGLDisplay dpy);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY WaitGL(void);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY WaitNative(EGLint engine);
+
+// EGL 1.1
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY BindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY SwapInterval(EGLDisplay dpy, EGLint interval);
+
+// EGL 1.2
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY BindAPI(EGLenum api);
+ANGLE_EXPORT EGLenum EGLAPIENTRY QueryAPI(void);
+ANGLE_EXPORT EGLSurface EGLAPIENTRY CreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY ReleaseThread(void);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY WaitClient(void);
+
+// EGL 1.4
+ANGLE_EXPORT EGLContext EGLAPIENTRY GetCurrentContext(void);
+
+// EGL 1.5
+ANGLE_EXPORT EGLSync EGLAPIENTRY CreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY DestroySync(EGLDisplay dpy, EGLSync sync);
+ANGLE_EXPORT EGLint EGLAPIENTRY ClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY GetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value);
+ANGLE_EXPORT EGLImage EGLAPIENTRY CreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY DestroyImage(EGLDisplay dpy, EGLImage image);
+ANGLE_EXPORT EGLDisplay EGLAPIENTRY GetPlatformDisplay(EGLenum platform, void *native_display, const EGLAttrib *attrib_list);
+ANGLE_EXPORT EGLSurface EGLAPIENTRY CreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list);
+ANGLE_EXPORT EGLSurface EGLAPIENTRY CreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list);
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY WaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags);
+
+}
+
+#endif // LIBGLESV2_ENTRYPOINTSEGL_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp b/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp
new file mode 100644
index 0000000000..ded73dbb48
--- /dev/null
+++ b/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp
@@ -0,0 +1,271 @@
+//
+// Copyright(c) 2014 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.
+//
+
+// entry_points_ext.cpp : Implements the EGL extension entry points.
+
+#include "libGLESv2/entry_points_egl_ext.h"
+#include "libGLESv2/global_state.h"
+
+#include "libANGLE/Display.h"
+#include "libANGLE/Surface.h"
+#include "libANGLE/validationEGL.h"
+
+#include "common/debug.h"
+
+namespace egl
+{
+
+// EGL_ANGLE_query_surface_pointer
+EGLBoolean EGLAPIENTRY QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, void **value = 0x%0.8p)",
+ dpy, surface, attribute, value);
+
+ Display *display = static_cast<Display*>(dpy);
+ Surface *eglSurface = static_cast<Surface*>(surface);
+
+ Error error = ValidateSurface(display, eglSurface);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ if (!display->getExtensions().querySurfacePointer)
+ {
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_FALSE;
+ }
+
+ if (surface == EGL_NO_SURFACE)
+ {
+ SetGlobalError(Error(EGL_BAD_SURFACE));
+ return EGL_FALSE;
+ }
+
+ // validate the attribute parameter
+ switch (attribute)
+ {
+ case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE:
+ if (!display->getExtensions().surfaceD3DTexture2DShareHandle)
+ {
+ SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ return EGL_FALSE;
+ }
+ break;
+
+ default:
+ SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ return EGL_FALSE;
+ }
+
+ error = eglSurface->querySurfacePointerANGLE(attribute, value);
+ SetGlobalError(error);
+ return (error.isError() ? EGL_FALSE : EGL_TRUE);
+}
+
+
+// EGL_NV_post_sub_buffer
+EGLBoolean EGLAPIENTRY PostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint x = %d, EGLint y = %d, EGLint width = %d, EGLint height = %d)", dpy, surface, x, y, width, height);
+
+ if (x < 0 || y < 0 || width < 0 || height < 0)
+ {
+ SetGlobalError(Error(EGL_BAD_PARAMETER));
+ return EGL_FALSE;
+ }
+
+ Display *display = static_cast<Display*>(dpy);
+ Surface *eglSurface = static_cast<Surface*>(surface);
+
+ Error error = ValidateSurface(display, eglSurface);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ if (display->isDeviceLost())
+ {
+ SetGlobalError(Error(EGL_CONTEXT_LOST));
+ return EGL_FALSE;
+ }
+
+ if (surface == EGL_NO_SURFACE)
+ {
+ SetGlobalError(Error(EGL_BAD_SURFACE));
+ return EGL_FALSE;
+ }
+
+ if (!display->getExtensions().postSubBuffer)
+ {
+ // Spec is not clear about how this should be handled.
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+ }
+
+ error = eglSurface->postSubBuffer(x, y, width, height);
+ if (error.isError())
+ {
+ SetGlobalError(error);
+ return EGL_FALSE;
+ }
+
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+}
+
+// EGL_EXT_platform_base
+EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_display, const EGLint *attrib_list)
+{
+ EVENT("(EGLenum platform = %d, void* native_display = 0x%0.8p, const EGLint* attrib_list = 0x%0.8p)",
+ platform, native_display, attrib_list);
+
+ const ClientExtensions &clientExtensions = Display::getClientExtensions();
+
+ switch (platform)
+ {
+ case EGL_PLATFORM_ANGLE_ANGLE:
+ if (!clientExtensions.platformANGLE)
+ {
+ SetGlobalError(Error(EGL_BAD_PARAMETER));
+ return EGL_NO_DISPLAY;
+ }
+ break;
+
+ default:
+ SetGlobalError(Error(EGL_BAD_CONFIG));
+ return EGL_NO_DISPLAY;
+ }
+
+ EGLint platformType = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
+ EGLint deviceType = EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE;
+ bool majorVersionSpecified = false;
+ bool minorVersionSpecified = false;
+ bool enableAutoTrimSpecified = false;
+
+ if (attrib_list)
+ {
+ for (const EGLint *curAttrib = attrib_list; curAttrib[0] != EGL_NONE; curAttrib += 2)
+ {
+ switch (curAttrib[0])
+ {
+ case EGL_PLATFORM_ANGLE_TYPE_ANGLE:
+ switch (curAttrib[1])
+ {
+ case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE:
+ break;
+
+ case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE:
+ case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE:
+ if (!clientExtensions.platformANGLED3D)
+ {
+ SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ return EGL_NO_DISPLAY;
+ }
+ break;
+
+ case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
+ case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
+ if (!clientExtensions.platformANGLEOpenGL)
+ {
+ SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ return EGL_NO_DISPLAY;
+ }
+ break;
+
+ default:
+ SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ return EGL_NO_DISPLAY;
+ }
+ platformType = curAttrib[1];
+ break;
+
+ case EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE:
+ if (curAttrib[1] != EGL_DONT_CARE)
+ {
+ majorVersionSpecified = true;
+ }
+ break;
+
+ case EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE:
+ if (curAttrib[1] != EGL_DONT_CARE)
+ {
+ minorVersionSpecified = true;
+ }
+ break;
+
+ case EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE:
+ switch (curAttrib[1])
+ {
+ case EGL_TRUE:
+ case EGL_FALSE:
+ break;
+ default:
+ SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ return EGL_NO_DISPLAY;
+ }
+ enableAutoTrimSpecified = true;
+ break;
+
+ case EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE:
+ if (!clientExtensions.platformANGLED3D)
+ {
+ SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ return EGL_NO_DISPLAY;
+ }
+
+ switch (curAttrib[1])
+ {
+ case EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE:
+ case EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE:
+ case EGL_PLATFORM_ANGLE_DEVICE_TYPE_REFERENCE_ANGLE:
+ case EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE:
+ break;
+
+ default:
+ SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ return EGL_NO_DISPLAY;
+ }
+ deviceType = curAttrib[1];
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ if (!majorVersionSpecified && minorVersionSpecified)
+ {
+ SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ return EGL_NO_DISPLAY;
+ }
+
+ if (deviceType == EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE &&
+ platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
+ {
+ SetGlobalError(Error(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE requires a device type of "
+ "EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE."));
+ return EGL_NO_DISPLAY;
+ }
+
+ if (enableAutoTrimSpecified &&
+ platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
+ {
+ SetGlobalError(Error(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE requires a device type of "
+ "EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE."));
+ return EGL_NO_DISPLAY;
+ }
+
+ SetGlobalError(Error(EGL_SUCCESS));
+
+ EGLNativeDisplayType displayId = static_cast<EGLNativeDisplayType>(native_display);
+ return Display::getDisplay(displayId, AttributeMap(attrib_list));
+}
+
+}
diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.h b/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.h
new file mode 100644
index 0000000000..9de1027082
--- /dev/null
+++ b/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.h
@@ -0,0 +1,30 @@
+//
+// Copyright(c) 2014 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.
+//
+
+// entry_points_egl_ext.h : Defines the EGL extension entry points.
+
+#ifndef LIBGLESV2_ENTRYPOINTSEGLEXT_H_
+#define LIBGLESV2_ENTRYPOINTSEGLEXT_H_
+
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <export.h>
+
+namespace egl
+{
+
+// EGL_ANGLE_query_surface_pointer
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
+
+// EGL_NV_post_sub_buffer
+ANGLE_EXPORT EGLBoolean EGLAPIENTRY PostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
+
+// EGL_EXT_platform_base
+ANGLE_EXPORT EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_display, const EGLint *attrib_list);
+
+}
+
+#endif // LIBGLESV2_ENTRYPOINTSEGLEXT_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0.cpp b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0.cpp
new file mode 100644
index 0000000000..6d3089ba4f
--- /dev/null
+++ b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0.cpp
@@ -0,0 +1,4318 @@
+//
+// Copyright(c) 2014 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.
+//
+
+// entry_points_gles_2_0.cpp : Implements the GLES 2.0 entry points.
+
+#include "libGLESv2/entry_points_gles_2_0.h"
+#include "libGLESv2/global_state.h"
+
+#include "libANGLE/formatutils.h"
+#include "libANGLE/Buffer.h"
+#include "libANGLE/Compiler.h"
+#include "libANGLE/Context.h"
+#include "libANGLE/Error.h"
+#include "libANGLE/Framebuffer.h"
+#include "libANGLE/Renderbuffer.h"
+#include "libANGLE/Shader.h"
+#include "libANGLE/Program.h"
+#include "libANGLE/Texture.h"
+#include "libANGLE/VertexArray.h"
+#include "libANGLE/VertexAttribute.h"
+#include "libANGLE/FramebufferAttachment.h"
+
+#include "libANGLE/validationES.h"
+#include "libANGLE/validationES2.h"
+#include "libANGLE/validationES3.h"
+#include "libANGLE/queryconversions.h"
+
+#include "common/debug.h"
+#include "common/utilities.h"
+#include "common/version.h"
+
+namespace gl
+{
+
+void GL_APIENTRY ActiveTexture(GLenum texture)
+{
+ EVENT("(GLenum texture = 0x%X)", texture);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ context->getState().setActiveSampler(texture - GL_TEXTURE0);
+ }
+}
+
+void GL_APIENTRY AttachShader(GLuint program, GLuint shader)
+{
+ EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Program *programObject = context->getProgram(program);
+ Shader *shaderObject = context->getShader(shader);
+
+ if (!programObject)
+ {
+ if (context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ if (!shaderObject)
+ {
+ if (context->getProgram(shader))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ if (!programObject->attachShader(shaderObject))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY BindAttribLocation(GLuint program, GLuint index, const GLchar* name)
+{
+ EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject)
+ {
+ if (context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ if (strncmp(name, "gl_", 3) == 0)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ programObject->bindAttributeLocation(index, name);
+ }
+}
+
+void GL_APIENTRY BindBuffer(GLenum target, GLuint buffer)
+{
+ EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidBufferTarget(context, target))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (target)
+ {
+ case GL_ARRAY_BUFFER:
+ context->bindArrayBuffer(buffer);
+ return;
+ case GL_ELEMENT_ARRAY_BUFFER:
+ context->bindElementArrayBuffer(buffer);
+ return;
+ case GL_COPY_READ_BUFFER:
+ context->bindCopyReadBuffer(buffer);
+ return;
+ case GL_COPY_WRITE_BUFFER:
+ context->bindCopyWriteBuffer(buffer);
+ return;
+ case GL_PIXEL_PACK_BUFFER:
+ context->bindPixelPackBuffer(buffer);
+ return;
+ case GL_PIXEL_UNPACK_BUFFER:
+ context->bindPixelUnpackBuffer(buffer);
+ return;
+ case GL_UNIFORM_BUFFER:
+ context->bindGenericUniformBuffer(buffer);
+ return;
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
+ context->bindGenericTransformFeedbackBuffer(buffer);
+ return;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY BindFramebuffer(GLenum target, GLuint framebuffer)
+{
+ EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidFramebufferTarget(target))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
+ {
+ context->bindReadFramebuffer(framebuffer);
+ }
+
+ if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
+ {
+ context->bindDrawFramebuffer(framebuffer);
+ }
+ }
+}
+
+void GL_APIENTRY BindRenderbuffer(GLenum target, GLuint renderbuffer)
+{
+ EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (target != GL_RENDERBUFFER)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ context->bindRenderbuffer(renderbuffer);
+ }
+}
+
+void GL_APIENTRY BindTexture(GLenum target, GLuint texture)
+{
+ EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Texture *textureObject = context->getTexture(texture);
+
+ if (textureObject && textureObject->getTarget() != target && texture != 0)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ switch (target)
+ {
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_CUBE_MAP:
+ break;
+
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_2D_ARRAY:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ context->bindTexture(target, texture);
+ }
+}
+
+void GL_APIENTRY BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+ EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
+ red, green, blue, alpha);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ context->getState().setBlendColor(clamp01(red), clamp01(green), clamp01(blue), clamp01(alpha));
+ }
+}
+
+void GL_APIENTRY BlendEquation(GLenum mode)
+{
+ BlendEquationSeparate(mode, mode);
+}
+
+void GL_APIENTRY BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
+{
+ EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ switch (modeRGB)
+ {
+ case GL_FUNC_ADD:
+ case GL_FUNC_SUBTRACT:
+ case GL_FUNC_REVERSE_SUBTRACT:
+ case GL_MIN:
+ case GL_MAX:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (modeAlpha)
+ {
+ case GL_FUNC_ADD:
+ case GL_FUNC_SUBTRACT:
+ case GL_FUNC_REVERSE_SUBTRACT:
+ case GL_MIN:
+ case GL_MAX:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ context->getState().setBlendEquation(modeRGB, modeAlpha);
+ }
+}
+
+void GL_APIENTRY BlendFunc(GLenum sfactor, GLenum dfactor)
+{
+ BlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
+}
+
+void GL_APIENTRY BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+{
+ EVENT("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)",
+ srcRGB, dstRGB, srcAlpha, dstAlpha);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ switch (srcRGB)
+ {
+ case GL_ZERO:
+ case GL_ONE:
+ case GL_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_COLOR:
+ case GL_DST_COLOR:
+ case GL_ONE_MINUS_DST_COLOR:
+ case GL_SRC_ALPHA:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ case GL_DST_ALPHA:
+ case GL_ONE_MINUS_DST_ALPHA:
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ case GL_SRC_ALPHA_SATURATE:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (dstRGB)
+ {
+ case GL_ZERO:
+ case GL_ONE:
+ case GL_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_COLOR:
+ case GL_DST_COLOR:
+ case GL_ONE_MINUS_DST_COLOR:
+ case GL_SRC_ALPHA:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ case GL_DST_ALPHA:
+ case GL_ONE_MINUS_DST_ALPHA:
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ break;
+
+ case GL_SRC_ALPHA_SATURATE:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (srcAlpha)
+ {
+ case GL_ZERO:
+ case GL_ONE:
+ case GL_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_COLOR:
+ case GL_DST_COLOR:
+ case GL_ONE_MINUS_DST_COLOR:
+ case GL_SRC_ALPHA:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ case GL_DST_ALPHA:
+ case GL_ONE_MINUS_DST_ALPHA:
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ case GL_SRC_ALPHA_SATURATE:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (dstAlpha)
+ {
+ case GL_ZERO:
+ case GL_ONE:
+ case GL_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_COLOR:
+ case GL_DST_COLOR:
+ case GL_ONE_MINUS_DST_COLOR:
+ case GL_SRC_ALPHA:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ case GL_DST_ALPHA:
+ case GL_ONE_MINUS_DST_ALPHA:
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ break;
+
+ case GL_SRC_ALPHA_SATURATE:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
+ dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
+
+ bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
+ dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
+
+ if (constantColorUsed && constantAlphaUsed)
+ {
+ ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR invalid under WebGL");
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ context->getState().setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
+ }
+}
+
+void GL_APIENTRY BufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
+{
+ EVENT("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p, GLenum usage = %d)",
+ target, size, data, usage);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (size < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ switch (usage)
+ {
+ case GL_STREAM_DRAW:
+ case GL_STATIC_DRAW:
+ case GL_DYNAMIC_DRAW:
+ break;
+
+ case GL_STREAM_READ:
+ case GL_STREAM_COPY:
+ case GL_STATIC_READ:
+ case GL_STATIC_COPY:
+ case GL_DYNAMIC_READ:
+ case GL_DYNAMIC_COPY:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (!ValidBufferTarget(context, target))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ Buffer *buffer = context->getState().getTargetBuffer(target);
+
+ if (!buffer)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ Error error = buffer->bufferData(data, size, usage);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
+{
+ EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p)",
+ target, offset, size, data);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (size < 0 || offset < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if (data == NULL)
+ {
+ return;
+ }
+
+ if (!ValidBufferTarget(context, target))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ Buffer *buffer = context->getState().getTargetBuffer(target);
+
+ if (!buffer)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (buffer->isMapped())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ // Check for possible overflow of size + offset
+ if (!rx::IsUnsignedAdditionSafe<size_t>(size, offset))
+ {
+ context->recordError(Error(GL_OUT_OF_MEMORY));
+ return;
+ }
+
+ if (size + offset > buffer->getSize())
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ Error error = buffer->bufferSubData(data, size, offset);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+GLenum GL_APIENTRY CheckFramebufferStatus(GLenum target)
+{
+ EVENT("(GLenum target = 0x%X)", target);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidFramebufferTarget(target))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return 0;
+ }
+
+ Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
+ ASSERT(framebuffer);
+
+ return framebuffer->checkStatus(context->getData());
+ }
+
+ return 0;
+}
+
+void GL_APIENTRY Clear(GLbitfield mask)
+{
+ EVENT("(GLbitfield mask = 0x%X)", mask);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
+ ASSERT(framebufferObject);
+
+ if (framebufferObject->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
+ {
+ context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
+ return;
+ }
+
+ if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ Error error = framebufferObject->clear(context->getData(), mask);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+ EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
+ red, green, blue, alpha);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ context->getState().setColorClearValue(red, green, blue, alpha);
+ }
+}
+
+void GL_APIENTRY ClearDepthf(GLclampf depth)
+{
+ EVENT("(GLclampf depth = %f)", depth);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ context->getState().setDepthClearValue(depth);
+ }
+}
+
+void GL_APIENTRY ClearStencil(GLint s)
+{
+ EVENT("(GLint s = %d)", s);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ context->getState().setStencilClearValue(s);
+ }
+}
+
+void GL_APIENTRY ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+{
+ EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
+ red, green, blue, alpha);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ context->getState().setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
+ }
+}
+
+void GL_APIENTRY CompileShader(GLuint shader)
+{
+ EVENT("(GLuint shader = %d)", shader);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Shader *shaderObject = context->getShader(shader);
+
+ if (!shaderObject)
+ {
+ if (context->getProgram(shader))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ shaderObject->compile(context->getCompiler());
+ }
+}
+
+void GL_APIENTRY CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
+ GLint border, GLsizei imageSize, const GLvoid* data)
+{
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
+ "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
+ target, level, internalformat, width, height, border, imageSize, data);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3 &&
+ !ValidateES2TexImageParameters(context, target, level, internalformat, true, false,
+ 0, 0, width, height, border, GL_NONE, GL_NONE, data))
+ {
+ return;
+ }
+
+ if (context->getClientVersion() >= 3 &&
+ !ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
+ 0, 0, 0, width, height, 1, border, GL_NONE, GL_NONE, data))
+ {
+ return;
+ }
+
+ const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat);
+ if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ Extents size(width, height, 1);
+ Texture *texture = context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target);
+ Error error = texture->setCompressedImage(target, level, internalformat, size, context->getState().getUnpackState(),
+ reinterpret_cast<const uint8_t *>(data));
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
+ GLenum format, GLsizei imageSize, const GLvoid* data)
+{
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
+ "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
+ "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
+ target, level, xoffset, yoffset, width, height, format, imageSize, data);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3 &&
+ !ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true,
+ xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
+ {
+ return;
+ }
+
+ if (context->getClientVersion() >= 3 &&
+ !ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
+ xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data))
+ {
+ return;
+ }
+
+ const InternalFormat &formatInfo = GetInternalFormatInfo(format);
+ if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+
+ Box area(xoffset, yoffset, 0, width, height, 1);
+ Texture *texture = context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target);
+ Error error = texture->setCompressedSubImage(target, level, area, format, context->getState().getUnpackState(),
+ reinterpret_cast<const uint8_t *>(data));
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
+{
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
+ "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
+ target, level, internalformat, x, y, width, height, border);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3 &&
+ !ValidateES2CopyTexImageParameters(context, target, level, internalformat, false,
+ 0, 0, x, y, width, height, border))
+ {
+ return;
+ }
+
+ if (context->getClientVersion() >= 3 &&
+ !ValidateES3CopyTexImageParameters(context, target, level, internalformat, false,
+ 0, 0, 0, x, y, width, height, border))
+ {
+ return;
+ }
+
+ Rectangle sourceArea(x, y, width, height);
+
+ const Framebuffer *framebuffer = context->getState().getReadFramebuffer();
+ Texture *texture = context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target);
+ Error error = texture->copyImage(target, level, sourceArea, internalformat, framebuffer);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
+ "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
+ target, level, xoffset, yoffset, x, y, width, height);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3 &&
+ !ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
+ xoffset, yoffset, x, y, width, height, 0))
+ {
+ return;
+ }
+
+ if (context->getClientVersion() >= 3 &&
+ !ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
+ xoffset, yoffset, 0, x, y, width, height, 0))
+ {
+ return;
+ }
+
+ Offset destOffset(xoffset, yoffset, 0);
+ Rectangle sourceArea(x, y, width, height);
+
+ const Framebuffer *framebuffer = context->getState().getReadFramebuffer();
+ Texture *texture = context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target);
+ Error error = texture->copySubImage(target, level, destOffset, sourceArea, framebuffer);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+GLuint GL_APIENTRY CreateProgram(void)
+{
+ EVENT("()");
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ return context->createProgram();
+ }
+
+ return 0;
+}
+
+GLuint GL_APIENTRY CreateShader(GLenum type)
+{
+ EVENT("(GLenum type = 0x%X)", type);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ switch (type)
+ {
+ case GL_FRAGMENT_SHADER:
+ case GL_VERTEX_SHADER:
+ return context->createShader(type);
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return 0;
+ }
+ }
+
+ return 0;
+}
+
+void GL_APIENTRY CullFace(GLenum mode)
+{
+ EVENT("(GLenum mode = 0x%X)", mode);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ switch (mode)
+ {
+ case GL_FRONT:
+ case GL_BACK:
+ case GL_FRONT_AND_BACK:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ context->getState().setCullMode(mode);
+ }
+}
+
+void GL_APIENTRY DeleteBuffers(GLsizei n, const GLuint* buffers)
+{
+ EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ context->deleteBuffer(buffers[i]);
+ }
+ }
+}
+
+void GL_APIENTRY DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
+{
+ EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ if (framebuffers[i] != 0)
+ {
+ context->deleteFramebuffer(framebuffers[i]);
+ }
+ }
+ }
+}
+
+void GL_APIENTRY DeleteProgram(GLuint program)
+{
+ EVENT("(GLuint program = %d)", program);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (program == 0)
+ {
+ return;
+ }
+
+ if (!context->getProgram(program))
+ {
+ if(context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ context->deleteProgram(program);
+ }
+}
+
+void GL_APIENTRY DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
+{
+ EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ context->deleteRenderbuffer(renderbuffers[i]);
+ }
+ }
+}
+
+void GL_APIENTRY DeleteShader(GLuint shader)
+{
+ EVENT("(GLuint shader = %d)", shader);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (shader == 0)
+ {
+ return;
+ }
+
+ if (!context->getShader(shader))
+ {
+ if(context->getProgram(shader))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ context->deleteShader(shader);
+ }
+}
+
+void GL_APIENTRY DeleteTextures(GLsizei n, const GLuint* textures)
+{
+ EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ if (textures[i] != 0)
+ {
+ context->deleteTexture(textures[i]);
+ }
+ }
+ }
+}
+
+void GL_APIENTRY DepthFunc(GLenum func)
+{
+ EVENT("(GLenum func = 0x%X)", func);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ switch (func)
+ {
+ case GL_NEVER:
+ case GL_ALWAYS:
+ case GL_LESS:
+ case GL_LEQUAL:
+ case GL_EQUAL:
+ case GL_GREATER:
+ case GL_GEQUAL:
+ case GL_NOTEQUAL:
+ context->getState().setDepthFunc(func);
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY DepthMask(GLboolean flag)
+{
+ EVENT("(GLboolean flag = %u)", flag);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ context->getState().setDepthMask(flag != GL_FALSE);
+ }
+}
+
+void GL_APIENTRY DepthRangef(GLclampf zNear, GLclampf zFar)
+{
+ EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ context->getState().setDepthRange(zNear, zFar);
+ }
+}
+
+void GL_APIENTRY DetachShader(GLuint program, GLuint shader)
+{
+ EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Program *programObject = context->getProgram(program);
+ Shader *shaderObject = context->getShader(shader);
+
+ if (!programObject)
+ {
+ Shader *shaderByProgramHandle;
+ shaderByProgramHandle = context->getShader(program);
+ if (!shaderByProgramHandle)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ }
+
+ if (!shaderObject)
+ {
+ Program *programByShaderHandle = context->getProgram(shader);
+ if (!programByShaderHandle)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ }
+
+ if (!programObject->detachShader(shaderObject))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY Disable(GLenum cap)
+{
+ EVENT("(GLenum cap = 0x%X)", cap);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidCap(context, cap))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ context->getState().setEnableFeature(cap, false);
+ }
+}
+
+void GL_APIENTRY DisableVertexAttribArray(GLuint index)
+{
+ EVENT("(GLuint index = %d)", index);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ context->getState().setEnableVertexAttribArray(index, false);
+ }
+}
+
+void GL_APIENTRY DrawArrays(GLenum mode, GLint first, GLsizei count)
+{
+ EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateDrawArrays(context, mode, first, count, 0))
+ {
+ return;
+ }
+
+ Error error = context->drawArrays(mode, first, count, 0);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
+{
+ EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p)",
+ mode, count, type, indices);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ rx::RangeUI indexRange;
+ if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange))
+ {
+ return;
+ }
+
+ Error error = context->drawElements(mode, count, type, indices, 0, indexRange);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY Enable(GLenum cap)
+{
+ EVENT("(GLenum cap = 0x%X)", cap);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidCap(context, cap))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ context->getState().setEnableFeature(cap, true);
+ }
+}
+
+void GL_APIENTRY EnableVertexAttribArray(GLuint index)
+{
+ EVENT("(GLuint index = %d)", index);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ context->getState().setEnableVertexAttribArray(index, true);
+ }
+}
+
+void GL_APIENTRY Finish(void)
+{
+ EVENT("()");
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Error error = context->finish();
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY Flush(void)
+{
+ EVENT("()");
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Error error = context->flush();
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+{
+ EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
+ "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidFramebufferTarget(target) || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (!ValidateFramebufferRenderbufferParameters(context, target, attachment, renderbuffertarget, renderbuffer))
+ {
+ return;
+ }
+
+ Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
+ ASSERT(framebuffer);
+
+ if (renderbuffer != 0)
+ {
+ Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
+ framebuffer->setRenderbufferAttachment(attachment, renderbufferObject);
+ }
+ else
+ {
+ framebuffer->setNULLAttachment(attachment);
+ }
+ }
+}
+
+void GL_APIENTRY FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+ EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
+ "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateFramebufferTexture2D(context, target, attachment, textarget, texture, level))
+ {
+ return;
+ }
+
+ Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
+ ASSERT(framebuffer);
+
+ if (texture != 0)
+ {
+ Texture *textureObj = context->getTexture(texture);
+
+ ImageIndex index = ImageIndex::MakeInvalid();
+
+ if (textarget == GL_TEXTURE_2D)
+ {
+ index = ImageIndex::Make2D(level);
+ }
+ else
+ {
+ ASSERT(IsCubeMapTextureTarget(textarget));
+ index = ImageIndex::MakeCube(textarget, level);
+ }
+
+ framebuffer->setTextureAttachment(attachment, textureObj, index);
+ }
+ else
+ {
+ framebuffer->setNULLAttachment(attachment);
+ }
+ }
+}
+
+void GL_APIENTRY FrontFace(GLenum mode)
+{
+ EVENT("(GLenum mode = 0x%X)", mode);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ switch (mode)
+ {
+ case GL_CW:
+ case GL_CCW:
+ context->getState().setFrontFace(mode);
+ break;
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY GenBuffers(GLsizei n, GLuint* buffers)
+{
+ EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ buffers[i] = context->createBuffer();
+ }
+ }
+}
+
+void GL_APIENTRY GenerateMipmap(GLenum target)
+{
+ EVENT("(GLenum target = 0x%X)", target);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidTextureTarget(context, target))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ Texture *texture = context->getTargetTexture(target);
+
+ if (texture == NULL)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ GLenum baseTarget = (target == GL_TEXTURE_CUBE_MAP) ? GL_TEXTURE_CUBE_MAP_POSITIVE_X : target;
+ GLenum internalFormat = texture->getInternalFormat(baseTarget, 0);
+ const TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat);
+ const InternalFormat &formatInfo = GetInternalFormatInfo(internalFormat);
+
+ // GenerateMipmap should not generate an INVALID_OPERATION for textures created with
+ // unsized formats or that are color renderable and filterable. Since we do not track if
+ // the texture was created with sized or unsized format (only sized formats are stored),
+ // it is not possible to make sure the the LUMA formats can generate mipmaps (they should
+ // be able to) because they aren't color renderable. Simply do a special case for LUMA
+ // textures since they're the only texture format that can be created with unsized formats
+ // that is not color renderable. New unsized formats are unlikely to be added, since ES2
+ // was the last version to use add them.
+ bool isLUMA = internalFormat == GL_LUMINANCE8_EXT ||
+ internalFormat == GL_LUMINANCE8_ALPHA8_EXT ||
+ internalFormat == GL_ALPHA8_EXT;
+
+ if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0 || !formatCaps.filterable ||
+ (!formatCaps.renderable && !isLUMA) || formatInfo.compressed)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ // GL_EXT_sRGB does not support mipmap generation on sRGB textures
+ if (context->getClientVersion() == 2 && formatInfo.colorEncoding == GL_SRGB)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ // Non-power of 2 ES2 check
+ if (!context->getExtensions().textureNPOT && (!isPow2(texture->getWidth(baseTarget, 0)) || !isPow2(texture->getHeight(baseTarget, 0))))
+ {
+ ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP));
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ // Cube completeness check
+ if (target == GL_TEXTURE_CUBE_MAP && !texture->isCubeComplete())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ Error error = texture->generateMipmaps();
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY GenFramebuffers(GLsizei n, GLuint* framebuffers)
+{
+ EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ framebuffers[i] = context->createFramebuffer();
+ }
+ }
+}
+
+void GL_APIENTRY GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
+{
+ EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ renderbuffers[i] = context->createRenderbuffer();
+ }
+ }
+}
+
+void GL_APIENTRY GenTextures(GLsizei n, GLuint* textures)
+{
+ EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ textures[i] = context->createTexture();
+ }
+ }
+}
+
+void GL_APIENTRY GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
+{
+ EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
+ "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
+ program, index, bufsize, length, size, type, name);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (bufsize < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject)
+ {
+ if (context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ if (index >= (GLuint)programObject->getActiveAttributeCount())
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ programObject->getActiveAttribute(index, bufsize, length, size, type, name);
+ }
+}
+
+void GL_APIENTRY GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
+{
+ EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
+ "GLsizei* length = 0x%0.8p, GLint* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
+ program, index, bufsize, length, size, type, name);
+
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (bufsize < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject)
+ {
+ if (context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ if (index >= (GLuint)programObject->getActiveUniformCount())
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ programObject->getActiveUniform(index, bufsize, length, size, type, name);
+ }
+}
+
+void GL_APIENTRY GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
+{
+ EVENT("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = 0x%0.8p, GLuint* shaders = 0x%0.8p)",
+ program, maxcount, count, shaders);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (maxcount < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject)
+ {
+ if (context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ return programObject->getAttachedShaders(maxcount, count, shaders);
+ }
+}
+
+GLint GL_APIENTRY GetAttribLocation(GLuint program, const GLchar* name)
+{
+ EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject)
+ {
+ if (context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return -1;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return -1;
+ }
+ }
+
+ if (!programObject->isLinked())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return -1;
+ }
+
+ return programObject->getAttributeLocation(name);
+ }
+
+ return -1;
+}
+
+void GL_APIENTRY GetBooleanv(GLenum pname, GLboolean* params)
+{
+ EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ GLenum nativeType;
+ unsigned int numParams = 0;
+ if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
+ {
+ return;
+ }
+
+ if (nativeType == GL_BOOL)
+ {
+ context->getBooleanv(pname, params);
+ }
+ else
+ {
+ CastStateValues(context, nativeType, pname, numParams, params);
+ }
+ }
+}
+
+void GL_APIENTRY GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+ EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidBufferTarget(context, target))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (!ValidBufferParameter(context, pname))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ Buffer *buffer = context->getState().getTargetBuffer(target);
+
+ if (!buffer)
+ {
+ // A null buffer means that "0" is bound to the requested buffer target
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ switch (pname)
+ {
+ case GL_BUFFER_USAGE:
+ *params = static_cast<GLint>(buffer->getUsage());
+ break;
+ case GL_BUFFER_SIZE:
+ *params = clampCast<GLint>(buffer->getSize());
+ break;
+ case GL_BUFFER_ACCESS_FLAGS:
+ *params = buffer->getAccessFlags();
+ break;
+ case GL_BUFFER_MAPPED:
+ *params = static_cast<GLint>(buffer->isMapped());
+ break;
+ case GL_BUFFER_MAP_OFFSET:
+ *params = clampCast<GLint>(buffer->getMapOffset());
+ break;
+ case GL_BUFFER_MAP_LENGTH:
+ *params = clampCast<GLint>(buffer->getMapLength());
+ break;
+ default: UNREACHABLE(); break;
+ }
+ }
+}
+
+GLenum GL_APIENTRY GetError(void)
+{
+ EVENT("()");
+
+ Context *context = GetGlobalContext();
+
+ if (context)
+ {
+ return context->getError();
+ }
+
+ return GL_NO_ERROR;
+}
+
+void GL_APIENTRY GetFloatv(GLenum pname, GLfloat* params)
+{
+ EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ GLenum nativeType;
+ unsigned int numParams = 0;
+ if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
+ {
+ return;
+ }
+
+ if (nativeType == GL_FLOAT)
+ {
+ context->getFloatv(pname, params);
+ }
+ else
+ {
+ CastStateValues(context, nativeType, pname, numParams, params);
+ }
+ }
+}
+
+void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
+{
+ EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
+ target, attachment, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidFramebufferTarget(target))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ int clientVersion = context->getClientVersion();
+
+ switch (pname)
+ {
+ case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
+ case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
+ case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
+ case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
+ break;
+
+ case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
+ if (clientVersion < 3 && !context->getExtensions().sRGB)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ break;
+
+ case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
+ case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
+ case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
+ case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
+ case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
+ case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
+ case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
+ case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
+ if (clientVersion < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ // Determine if the attachment is a valid enum
+ switch (attachment)
+ {
+ case GL_BACK:
+ case GL_FRONT:
+ case GL_DEPTH:
+ case GL_STENCIL:
+ case GL_DEPTH_STENCIL_ATTACHMENT:
+ if (clientVersion < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ break;
+
+ case GL_DEPTH_ATTACHMENT:
+ case GL_STENCIL_ATTACHMENT:
+ break;
+
+ default:
+ if (attachment < GL_COLOR_ATTACHMENT0_EXT ||
+ (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ break;
+ }
+
+ Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
+ ASSERT(framebuffer);
+
+ if (framebuffer->id() == 0)
+ {
+ if (clientVersion < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ switch (attachment)
+ {
+ case GL_BACK:
+ case GL_DEPTH:
+ case GL_STENCIL:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ }
+ else
+ {
+ if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
+ {
+ // Valid attachment query
+ }
+ else
+ {
+ switch (attachment)
+ {
+ case GL_DEPTH_ATTACHMENT:
+ case GL_STENCIL_ATTACHMENT:
+ break;
+
+ case GL_DEPTH_STENCIL_ATTACHMENT:
+ if (framebuffer->hasValidDepthStencil())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ }
+ }
+
+ const FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
+ if (attachmentObject)
+ {
+ ASSERT(attachmentObject->type() == GL_RENDERBUFFER ||
+ attachmentObject->type() == GL_TEXTURE ||
+ attachmentObject->type() == GL_FRAMEBUFFER_DEFAULT);
+
+ switch (pname)
+ {
+ case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
+ *params = attachmentObject->type();
+ break;
+
+ case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
+ if (attachmentObject->type() != GL_RENDERBUFFER && attachmentObject->type() != GL_TEXTURE)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = attachmentObject->id();
+ break;
+
+ case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
+ if (attachmentObject->type() != GL_TEXTURE)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = attachmentObject->mipLevel();
+ break;
+
+ case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
+ if (attachmentObject->type() != GL_TEXTURE)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = attachmentObject->cubeMapFace();
+ break;
+
+ case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
+ *params = attachmentObject->getRedSize();
+ break;
+
+ case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
+ *params = attachmentObject->getGreenSize();
+ break;
+
+ case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
+ *params = attachmentObject->getBlueSize();
+ break;
+
+ case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
+ *params = attachmentObject->getAlphaSize();
+ break;
+
+ case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
+ *params = attachmentObject->getDepthSize();
+ break;
+
+ case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
+ *params = attachmentObject->getStencilSize();
+ break;
+
+ case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
+ if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ *params = attachmentObject->getComponentType();
+ break;
+
+ case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
+ *params = attachmentObject->getColorEncoding();
+ break;
+
+ case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
+ if (attachmentObject->type() != GL_TEXTURE)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = attachmentObject->layer();
+ break;
+
+ default:
+ UNREACHABLE();
+ break;
+ }
+ }
+ else
+ {
+ // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
+ // is NONE, then querying any other pname will generate INVALID_ENUM.
+
+ // ES 3.0.2 spec pg 235 states that if the attachment type is none,
+ // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
+ // INVALID_OPERATION for all other pnames
+
+ switch (pname)
+ {
+ case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
+ *params = GL_NONE;
+ break;
+
+ case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
+ if (clientVersion < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = 0;
+ break;
+
+ default:
+ if (clientVersion < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ }
+ }
+ }
+}
+
+void GL_APIENTRY GetIntegerv(GLenum pname, GLint* params)
+{
+ EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ GLenum nativeType;
+ unsigned int numParams = 0;
+
+ if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
+ {
+ return;
+ }
+
+ if (nativeType == GL_INT)
+ {
+ context->getIntegerv(pname, params);
+ }
+ else
+ {
+ CastStateValues(context, nativeType, pname, numParams, params);
+ }
+ }
+}
+
+void GL_APIENTRY GetProgramiv(GLuint program, GLenum pname, GLint* params)
+{
+ EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if (context->getClientVersion() < 3)
+ {
+ switch (pname)
+ {
+ case GL_ACTIVE_UNIFORM_BLOCKS:
+ case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
+ case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
+ case GL_TRANSFORM_FEEDBACK_VARYINGS:
+ case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+
+ switch (pname)
+ {
+ case GL_DELETE_STATUS:
+ *params = programObject->isFlaggedForDeletion();
+ return;
+ case GL_LINK_STATUS:
+ *params = programObject->isLinked();
+ return;
+ case GL_VALIDATE_STATUS:
+ *params = programObject->isValidated();
+ return;
+ case GL_INFO_LOG_LENGTH:
+ *params = programObject->getInfoLogLength();
+ return;
+ case GL_ATTACHED_SHADERS:
+ *params = programObject->getAttachedShadersCount();
+ return;
+ case GL_ACTIVE_ATTRIBUTES:
+ *params = programObject->getActiveAttributeCount();
+ return;
+ case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
+ *params = programObject->getActiveAttributeMaxLength();
+ return;
+ case GL_ACTIVE_UNIFORMS:
+ *params = programObject->getActiveUniformCount();
+ return;
+ case GL_ACTIVE_UNIFORM_MAX_LENGTH:
+ *params = programObject->getActiveUniformMaxLength();
+ return;
+ case GL_PROGRAM_BINARY_LENGTH_OES:
+ *params = programObject->getBinaryLength();
+ return;
+ case GL_ACTIVE_UNIFORM_BLOCKS:
+ *params = programObject->getActiveUniformBlockCount();
+ return;
+ case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
+ *params = programObject->getActiveUniformBlockMaxLength();
+ break;
+ case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
+ *params = programObject->getTransformFeedbackBufferMode();
+ break;
+ case GL_TRANSFORM_FEEDBACK_VARYINGS:
+ *params = programObject->getTransformFeedbackVaryingCount();
+ break;
+ case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
+ *params = programObject->getTransformFeedbackVaryingMaxLength();
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
+{
+ EVENT("(GLuint program = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
+ program, bufsize, length, infolog);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (bufsize < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ programObject->getInfoLog(bufsize, length, infolog);
+ }
+}
+
+void GL_APIENTRY GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+ EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (target != GL_RENDERBUFFER)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (context->getState().getRenderbufferId() == 0)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ Renderbuffer *renderbuffer = context->getRenderbuffer(context->getState().getRenderbufferId());
+
+ switch (pname)
+ {
+ case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
+ case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
+ case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
+ case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
+ case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
+ case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
+ case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
+ case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
+ case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
+
+ case GL_RENDERBUFFER_SAMPLES_ANGLE:
+ if (!context->getExtensions().framebufferMultisample)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = renderbuffer->getSamples();
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY GetShaderiv(GLuint shader, GLenum pname, GLint* params)
+{
+ EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Shader *shaderObject = context->getShader(shader);
+
+ if (!shaderObject)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ switch (pname)
+ {
+ case GL_SHADER_TYPE:
+ *params = shaderObject->getType();
+ return;
+ case GL_DELETE_STATUS:
+ *params = shaderObject->isFlaggedForDeletion();
+ return;
+ case GL_COMPILE_STATUS:
+ *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
+ return;
+ case GL_INFO_LOG_LENGTH:
+ *params = shaderObject->getInfoLogLength();
+ return;
+ case GL_SHADER_SOURCE_LENGTH:
+ *params = shaderObject->getSourceLength();
+ return;
+ case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
+ *params = shaderObject->getTranslatedSourceLength();
+ return;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
+{
+ EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
+ shader, bufsize, length, infolog);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (bufsize < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ Shader *shaderObject = context->getShader(shader);
+
+ if (!shaderObject)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ shaderObject->getInfoLog(bufsize, length, infolog);
+ }
+}
+
+void GL_APIENTRY GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
+{
+ EVENT("(GLenum shadertype = 0x%X, GLenum precisiontype = 0x%X, GLint* range = 0x%0.8p, GLint* precision = 0x%0.8p)",
+ shadertype, precisiontype, range, precision);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ switch (shadertype)
+ {
+ case GL_VERTEX_SHADER:
+ switch (precisiontype)
+ {
+ case GL_LOW_FLOAT:
+ context->getCaps().vertexLowpFloat.get(range, precision);
+ break;
+ case GL_MEDIUM_FLOAT:
+ context->getCaps().vertexMediumpFloat.get(range, precision);
+ break;
+ case GL_HIGH_FLOAT:
+ context->getCaps().vertexHighpFloat.get(range, precision);
+ break;
+
+ case GL_LOW_INT:
+ context->getCaps().vertexLowpInt.get(range, precision);
+ break;
+ case GL_MEDIUM_INT:
+ context->getCaps().vertexMediumpInt.get(range, precision);
+ break;
+ case GL_HIGH_INT:
+ context->getCaps().vertexHighpInt.get(range, precision);
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ break;
+ case GL_FRAGMENT_SHADER:
+ switch (precisiontype)
+ {
+ case GL_LOW_FLOAT:
+ context->getCaps().fragmentLowpFloat.get(range, precision);
+ break;
+ case GL_MEDIUM_FLOAT:
+ context->getCaps().fragmentMediumpFloat.get(range, precision);
+ break;
+ case GL_HIGH_FLOAT:
+ context->getCaps().fragmentHighpFloat.get(range, precision);
+ break;
+
+ case GL_LOW_INT:
+ context->getCaps().fragmentLowpInt.get(range, precision);
+ break;
+ case GL_MEDIUM_INT:
+ context->getCaps().fragmentMediumpInt.get(range, precision);
+ break;
+ case GL_HIGH_INT:
+ context->getCaps().fragmentHighpInt.get(range, precision);
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ break;
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ }
+}
+
+void GL_APIENTRY GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
+{
+ EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
+ shader, bufsize, length, source);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (bufsize < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ Shader *shaderObject = context->getShader(shader);
+
+ if (!shaderObject)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ shaderObject->getSource(bufsize, length, source);
+ }
+}
+
+const GLubyte *GL_APIENTRY GetString(GLenum name)
+{
+ EVENT("(GLenum name = 0x%X)", name);
+
+ Context *context = GetValidGlobalContext();
+
+ switch (name)
+ {
+ case GL_VENDOR:
+ return (GLubyte*)"Google Inc.";
+
+ case GL_RENDERER:
+ return (GLubyte*)((context != NULL) ? context->getRendererString().c_str() : "ANGLE");
+
+ case GL_VERSION:
+ if (context->getClientVersion() == 2)
+ {
+ return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")";
+ }
+ else
+ {
+ return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")";
+ }
+
+ case GL_SHADING_LANGUAGE_VERSION:
+ if (context->getClientVersion() == 2)
+ {
+ return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")";
+ }
+ else
+ {
+ return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")";
+ }
+
+ case GL_EXTENSIONS:
+ return (GLubyte*)((context != NULL) ? context->getExtensionString().c_str() : "");
+
+ default:
+ if (context)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ }
+ return NULL;
+ }
+}
+
+void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
+{
+ EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", target, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Texture *texture = context->getTargetTexture(target);
+
+ if (!texture)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (pname)
+ {
+ case GL_TEXTURE_MAG_FILTER:
+ *params = (GLfloat)texture->getSamplerState().magFilter;
+ break;
+ case GL_TEXTURE_MIN_FILTER:
+ *params = (GLfloat)texture->getSamplerState().minFilter;
+ break;
+ case GL_TEXTURE_WRAP_S:
+ *params = (GLfloat)texture->getSamplerState().wrapS;
+ break;
+ case GL_TEXTURE_WRAP_T:
+ *params = (GLfloat)texture->getSamplerState().wrapT;
+ break;
+ case GL_TEXTURE_WRAP_R:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = (GLfloat)texture->getSamplerState().wrapR;
+ break;
+ case GL_TEXTURE_IMMUTABLE_FORMAT:
+ // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
+ *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
+ break;
+ case GL_TEXTURE_IMMUTABLE_LEVELS:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = (GLfloat)texture->immutableLevelCount();
+ break;
+ case GL_TEXTURE_USAGE_ANGLE:
+ *params = (GLfloat)texture->getUsage();
+ break;
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+ if (!context->getExtensions().textureFilterAnisotropic)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = (GLfloat)texture->getSamplerState().maxAnisotropy;
+ break;
+ case GL_TEXTURE_SWIZZLE_R:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = (GLfloat)texture->getSamplerState().swizzleRed;
+ break;
+ case GL_TEXTURE_SWIZZLE_G:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = (GLfloat)texture->getSamplerState().swizzleGreen;
+ break;
+ case GL_TEXTURE_SWIZZLE_B:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = (GLfloat)texture->getSamplerState().swizzleBlue;
+ break;
+ case GL_TEXTURE_SWIZZLE_A:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = (GLfloat)texture->getSamplerState().swizzleAlpha;
+ break;
+ case GL_TEXTURE_BASE_LEVEL:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = (GLfloat)texture->getSamplerState().baseLevel;
+ break;
+ case GL_TEXTURE_MAX_LEVEL:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = (GLfloat)texture->getSamplerState().maxLevel;
+ break;
+ case GL_TEXTURE_MIN_LOD:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = texture->getSamplerState().minLod;
+ break;
+ case GL_TEXTURE_MAX_LOD:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = texture->getSamplerState().maxLod;
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+ EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Texture *texture = context->getTargetTexture(target);
+
+ if (!texture)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (pname)
+ {
+ case GL_TEXTURE_MAG_FILTER:
+ *params = texture->getSamplerState().magFilter;
+ break;
+ case GL_TEXTURE_MIN_FILTER:
+ *params = texture->getSamplerState().minFilter;
+ break;
+ case GL_TEXTURE_WRAP_S:
+ *params = texture->getSamplerState().wrapS;
+ break;
+ case GL_TEXTURE_WRAP_T:
+ *params = texture->getSamplerState().wrapT;
+ break;
+ case GL_TEXTURE_WRAP_R:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = texture->getSamplerState().wrapR;
+ break;
+ case GL_TEXTURE_IMMUTABLE_FORMAT:
+ // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
+ *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
+ break;
+ case GL_TEXTURE_IMMUTABLE_LEVELS:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = static_cast<GLint>(texture->immutableLevelCount());
+ break;
+ case GL_TEXTURE_USAGE_ANGLE:
+ *params = texture->getUsage();
+ break;
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+ if (!context->getExtensions().textureFilterAnisotropic)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = (GLint)texture->getSamplerState().maxAnisotropy;
+ break;
+ case GL_TEXTURE_SWIZZLE_R:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = texture->getSamplerState().swizzleRed;
+ break;
+ case GL_TEXTURE_SWIZZLE_G:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = texture->getSamplerState().swizzleGreen;
+ break;
+ case GL_TEXTURE_SWIZZLE_B:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = texture->getSamplerState().swizzleBlue;
+ break;
+ case GL_TEXTURE_SWIZZLE_A:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = texture->getSamplerState().swizzleAlpha;
+ break;
+ case GL_TEXTURE_BASE_LEVEL:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = texture->getSamplerState().baseLevel;
+ break;
+ case GL_TEXTURE_MAX_LEVEL:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = texture->getSamplerState().maxLevel;
+ break;
+ case GL_TEXTURE_MIN_LOD:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = (GLint)texture->getSamplerState().minLod;
+ break;
+ case GL_TEXTURE_MAX_LOD:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ *params = (GLint)texture->getSamplerState().maxLod;
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY GetUniformfv(GLuint program, GLint location, GLfloat* params)
+{
+ EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateGetUniformfv(context, program, location, params))
+ {
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+ ASSERT(programObject);
+
+ programObject->getUniformfv(location, params);
+ }
+}
+
+void GL_APIENTRY GetUniformiv(GLuint program, GLint location, GLint* params)
+{
+ EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateGetUniformiv(context, program, location, params))
+ {
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+ ASSERT(programObject);
+
+ programObject->getUniformiv(location, params);
+ }
+}
+
+GLint GL_APIENTRY GetUniformLocation(GLuint program, const GLchar* name)
+{
+ EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (strstr(name, "gl_") == name)
+ {
+ return -1;
+ }
+
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject)
+ {
+ if (context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return -1;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return -1;
+ }
+ }
+
+ if (!programObject->isLinked())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return -1;
+ }
+
+ return programObject->getUniformLocation(name);
+ }
+
+ return -1;
+}
+
+void GL_APIENTRY GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
+{
+ EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if (!ValidateGetVertexAttribParameters(context, pname))
+ {
+ return;
+ }
+
+ if (pname == GL_CURRENT_VERTEX_ATTRIB)
+ {
+ const VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
+ for (int i = 0; i < 4; ++i)
+ {
+ params[i] = currentValueData.FloatValues[i];
+ }
+ }
+ else
+ {
+ const VertexAttribute &attribState = context->getState().getVertexArray()->getVertexAttribute(index);
+ *params = QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname);
+ }
+ }
+}
+
+void GL_APIENTRY GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
+{
+ EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if (!ValidateGetVertexAttribParameters(context, pname))
+ {
+ return;
+ }
+
+ if (pname == GL_CURRENT_VERTEX_ATTRIB)
+ {
+ const VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
+ for (int i = 0; i < 4; ++i)
+ {
+ float currentValue = currentValueData.FloatValues[i];
+ params[i] = iround<GLint>(currentValue);
+ }
+ }
+ else
+ {
+ const VertexAttribute &attribState = context->getState().getVertexArray()->getVertexAttribute(index);
+ *params = QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
+ }
+ }
+}
+
+void GL_APIENTRY GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
+{
+ EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ *pointer = const_cast<GLvoid*>(context->getState().getVertexAttribPointer(index));
+ }
+}
+
+void GL_APIENTRY Hint(GLenum target, GLenum mode)
+{
+ EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ switch (mode)
+ {
+ case GL_FASTEST:
+ case GL_NICEST:
+ case GL_DONT_CARE:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (target)
+ {
+ case GL_GENERATE_MIPMAP_HINT:
+ context->getState().setGenerateMipmapHint(mode);
+ break;
+
+ case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
+ context->getState().setFragmentShaderDerivativeHint(mode);
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+GLboolean GL_APIENTRY IsBuffer(GLuint buffer)
+{
+ EVENT("(GLuint buffer = %d)", buffer);
+
+ Context *context = GetValidGlobalContext();
+ if (context && buffer)
+ {
+ Buffer *bufferObject = context->getBuffer(buffer);
+
+ if (bufferObject)
+ {
+ return GL_TRUE;
+ }
+ }
+
+ return GL_FALSE;
+}
+
+GLboolean GL_APIENTRY IsEnabled(GLenum cap)
+{
+ EVENT("(GLenum cap = 0x%X)", cap);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidCap(context, cap))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return GL_FALSE;
+ }
+
+ return context->getState().getEnableFeature(cap);
+ }
+
+ return false;
+}
+
+GLboolean GL_APIENTRY IsFramebuffer(GLuint framebuffer)
+{
+ EVENT("(GLuint framebuffer = %d)", framebuffer);
+
+ Context *context = GetValidGlobalContext();
+ if (context && framebuffer)
+ {
+ Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
+
+ if (framebufferObject)
+ {
+ return GL_TRUE;
+ }
+ }
+
+ return GL_FALSE;
+}
+
+GLboolean GL_APIENTRY IsProgram(GLuint program)
+{
+ EVENT("(GLuint program = %d)", program);
+
+ Context *context = GetValidGlobalContext();
+ if (context && program)
+ {
+ Program *programObject = context->getProgram(program);
+
+ if (programObject)
+ {
+ return GL_TRUE;
+ }
+ }
+
+ return GL_FALSE;
+}
+
+GLboolean GL_APIENTRY IsRenderbuffer(GLuint renderbuffer)
+{
+ EVENT("(GLuint renderbuffer = %d)", renderbuffer);
+
+ Context *context = GetValidGlobalContext();
+ if (context && renderbuffer)
+ {
+ Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
+
+ if (renderbufferObject)
+ {
+ return GL_TRUE;
+ }
+ }
+
+ return GL_FALSE;
+}
+
+GLboolean GL_APIENTRY IsShader(GLuint shader)
+{
+ EVENT("(GLuint shader = %d)", shader);
+
+ Context *context = GetValidGlobalContext();
+ if (context && shader)
+ {
+ Shader *shaderObject = context->getShader(shader);
+
+ if (shaderObject)
+ {
+ return GL_TRUE;
+ }
+ }
+
+ return GL_FALSE;
+}
+
+GLboolean GL_APIENTRY IsTexture(GLuint texture)
+{
+ EVENT("(GLuint texture = %d)", texture);
+
+ Context *context = GetValidGlobalContext();
+ if (context && texture)
+ {
+ Texture *textureObject = context->getTexture(texture);
+
+ if (textureObject)
+ {
+ return GL_TRUE;
+ }
+ }
+
+ return GL_FALSE;
+}
+
+void GL_APIENTRY LineWidth(GLfloat width)
+{
+ EVENT("(GLfloat width = %f)", width);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (width <= 0.0f)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ context->getState().setLineWidth(width);
+ }
+}
+
+void GL_APIENTRY LinkProgram(GLuint program)
+{
+ EVENT("(GLuint program = %d)", program);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject)
+ {
+ if (context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ Error error = programObject->link(context->getData());
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY PixelStorei(GLenum pname, GLint param)
+{
+ EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ switch (pname)
+ {
+ case GL_UNPACK_IMAGE_HEIGHT:
+ case GL_UNPACK_SKIP_IMAGES:
+ case GL_UNPACK_ROW_LENGTH:
+ case GL_UNPACK_SKIP_ROWS:
+ case GL_UNPACK_SKIP_PIXELS:
+ case GL_PACK_ROW_LENGTH:
+ case GL_PACK_SKIP_ROWS:
+ case GL_PACK_SKIP_PIXELS:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+
+ if (param < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE, "Cannot use negative values in PixelStorei"));
+ return;
+ }
+
+ State &state = context->getState();
+
+ switch (pname)
+ {
+ case GL_UNPACK_ALIGNMENT:
+ if (param != 1 && param != 2 && param != 4 && param != 8)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ state.setUnpackAlignment(param);
+ break;
+
+ case GL_PACK_ALIGNMENT:
+ if (param != 1 && param != 2 && param != 4 && param != 8)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ state.setPackAlignment(param);
+ break;
+
+ case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
+ state.setPackReverseRowOrder(param != 0);
+ break;
+
+ case GL_UNPACK_ROW_LENGTH:
+ ASSERT(context->getClientVersion() >= 3);
+ state.setUnpackRowLength(param);
+ break;
+
+ case GL_UNPACK_IMAGE_HEIGHT:
+ ASSERT(context->getClientVersion() >= 3);
+ state.getUnpackState().imageHeight = param;
+ break;
+
+ case GL_UNPACK_SKIP_IMAGES:
+ ASSERT(context->getClientVersion() >= 3);
+ state.getUnpackState().skipImages = param;
+ break;
+
+ case GL_UNPACK_SKIP_ROWS:
+ ASSERT(context->getClientVersion() >= 3);
+ state.getUnpackState().skipRows = param;
+ break;
+
+ case GL_UNPACK_SKIP_PIXELS:
+ ASSERT(context->getClientVersion() >= 3);
+ state.getUnpackState().skipPixels = param;
+ break;
+
+ case GL_PACK_ROW_LENGTH:
+ ASSERT(context->getClientVersion() >= 3);
+ state.getPackState().rowLength = param;
+ break;
+
+ case GL_PACK_SKIP_ROWS:
+ ASSERT(context->getClientVersion() >= 3);
+ state.getPackState().skipRows = param;
+ break;
+
+ case GL_PACK_SKIP_PIXELS:
+ ASSERT(context->getClientVersion() >= 3);
+ state.getPackState().skipPixels = param;
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY PolygonOffset(GLfloat factor, GLfloat units)
+{
+ EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ context->getState().setPolygonOffsetParams(factor, units);
+ }
+}
+
+void GL_APIENTRY ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type, GLvoid* pixels)
+{
+ EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
+ "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
+ x, y, width, height, format, type, pixels);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (width < 0 || height < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if (!ValidateReadPixelsParameters(context, x, y, width, height,
+ format, type, NULL, pixels))
+ {
+ return;
+ }
+
+ Framebuffer *framebufferObject = context->getState().getReadFramebuffer();
+ ASSERT(framebufferObject);
+
+ Rectangle area(x, y, width, height);
+ Error error = framebufferObject->readPixels(context->getState(), area, format, type, pixels);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY ReleaseShaderCompiler(void)
+{
+ EVENT("()");
+
+ Context *context = GetValidGlobalContext();
+
+ if (context)
+ {
+ Compiler *compiler = context->getCompiler();
+ Error error = compiler->release();
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+{
+ EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
+ target, internalformat, width, height);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateRenderbufferStorageParametersANGLE(context, target, 0, internalformat,
+ width, height))
+ {
+ return;
+ }
+
+ Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
+ Error error = renderbuffer->setStorage(internalformat, width, height);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY SampleCoverage(GLclampf value, GLboolean invert)
+{
+ EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
+
+ Context* context = GetValidGlobalContext();
+
+ if (context)
+ {
+ context->getState().setSampleCoverageParams(clamp01(value), invert == GL_TRUE);
+ }
+}
+
+void GL_APIENTRY Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
+
+ Context* context = GetValidGlobalContext();
+ if (context)
+ {
+ if (width < 0 || height < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ context->getState().setScissorParams(x, y, width, height);
+ }
+}
+
+void GL_APIENTRY ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
+{
+ EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
+ "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
+ n, shaders, binaryformat, binary, length);
+
+ Context* context = GetValidGlobalContext();
+ if (context)
+ {
+ const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats;
+ if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) == shaderBinaryFormats.end())
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ // No binary shader formats are supported.
+ UNIMPLEMENTED();
+ }
+}
+
+void GL_APIENTRY ShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
+{
+ EVENT("(GLuint shader = %d, GLsizei count = %d, const GLchar** string = 0x%0.8p, const GLint* length = 0x%0.8p)",
+ shader, count, string, length);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (count < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ Shader *shaderObject = context->getShader(shader);
+
+ if (!shaderObject)
+ {
+ if (context->getProgram(shader))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ shaderObject->setSource(count, string, length);
+ }
+}
+
+void GL_APIENTRY StencilFunc(GLenum func, GLint ref, GLuint mask)
+{
+ StencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
+}
+
+void GL_APIENTRY StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
+{
+ EVENT("(GLenum face = 0x%X, GLenum func = 0x%X, GLint ref = %d, GLuint mask = %d)", face, func, ref, mask);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ switch (face)
+ {
+ case GL_FRONT:
+ case GL_BACK:
+ case GL_FRONT_AND_BACK:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (func)
+ {
+ case GL_NEVER:
+ case GL_ALWAYS:
+ case GL_LESS:
+ case GL_LEQUAL:
+ case GL_EQUAL:
+ case GL_GEQUAL:
+ case GL_GREATER:
+ case GL_NOTEQUAL:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
+ {
+ context->getState().setStencilParams(func, ref, mask);
+ }
+
+ if (face == GL_BACK || face == GL_FRONT_AND_BACK)
+ {
+ context->getState().setStencilBackParams(func, ref, mask);
+ }
+ }
+}
+
+void GL_APIENTRY StencilMask(GLuint mask)
+{
+ StencilMaskSeparate(GL_FRONT_AND_BACK, mask);
+}
+
+void GL_APIENTRY StencilMaskSeparate(GLenum face, GLuint mask)
+{
+ EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ switch (face)
+ {
+ case GL_FRONT:
+ case GL_BACK:
+ case GL_FRONT_AND_BACK:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
+ {
+ context->getState().setStencilWritemask(mask);
+ }
+
+ if (face == GL_BACK || face == GL_FRONT_AND_BACK)
+ {
+ context->getState().setStencilBackWritemask(mask);
+ }
+ }
+}
+
+void GL_APIENTRY StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
+{
+ StencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
+}
+
+void GL_APIENTRY StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+{
+ EVENT("(GLenum face = 0x%X, GLenum fail = 0x%X, GLenum zfail = 0x%X, GLenum zpas = 0x%Xs)",
+ face, fail, zfail, zpass);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ switch (face)
+ {
+ case GL_FRONT:
+ case GL_BACK:
+ case GL_FRONT_AND_BACK:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (fail)
+ {
+ case GL_ZERO:
+ case GL_KEEP:
+ case GL_REPLACE:
+ case GL_INCR:
+ case GL_DECR:
+ case GL_INVERT:
+ case GL_INCR_WRAP:
+ case GL_DECR_WRAP:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (zfail)
+ {
+ case GL_ZERO:
+ case GL_KEEP:
+ case GL_REPLACE:
+ case GL_INCR:
+ case GL_DECR:
+ case GL_INVERT:
+ case GL_INCR_WRAP:
+ case GL_DECR_WRAP:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (zpass)
+ {
+ case GL_ZERO:
+ case GL_KEEP:
+ case GL_REPLACE:
+ case GL_INCR:
+ case GL_DECR:
+ case GL_INVERT:
+ case GL_INCR_WRAP:
+ case GL_DECR_WRAP:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
+ {
+ context->getState().setStencilOperations(fail, zfail, zpass);
+ }
+
+ if (face == GL_BACK || face == GL_FRONT_AND_BACK)
+ {
+ context->getState().setStencilBackOperations(fail, zfail, zpass);
+ }
+ }
+}
+
+void GL_APIENTRY TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
+ GLint border, GLenum format, GLenum type, const GLvoid* pixels)
+{
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
+ "GLint border = %d, GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
+ target, level, internalformat, width, height, border, format, type, pixels);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3 &&
+ !ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
+ 0, 0, width, height, border, format, type, pixels))
+ {
+ return;
+ }
+
+ if (context->getClientVersion() >= 3 &&
+ !ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
+ 0, 0, 0, width, height, 1, border, format, type, pixels))
+ {
+ return;
+ }
+
+ Extents size(width, height, 1);
+ Texture *texture = context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target);
+ Error error = texture->setImage(target, level, internalformat, size, format, type, context->getState().getUnpackState(),
+ reinterpret_cast<const uint8_t *>(pixels));
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY TexParameterf(GLenum target, GLenum pname, GLfloat param)
+{
+ EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
+ {
+ return;
+ }
+
+ Texture *texture = context->getTargetTexture(target);
+
+ if (!texture)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (pname)
+ {
+ case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = uiround<GLenum>(param); break;
+ case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = uiround<GLenum>(param); break;
+ case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = uiround<GLenum>(param); break;
+ case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = uiround<GLenum>(param); break;
+ case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = uiround<GLenum>(param); break;
+ case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(uiround<GLenum>(param)); break;
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min(param, context->getExtensions().maxTextureAnisotropy); break;
+ case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = uiround<GLenum>(param); break;
+ case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = uiround<GLenum>(param); break;
+ case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = uiround<GLenum>(param); break;
+ case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = uiround<GLenum>(param); break;
+ case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = uiround<GLenum>(param); break;
+ case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = uiround<GLenum>(param); break;
+ case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = iround<GLint>(param); break;
+ case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = iround<GLint>(param); break;
+ case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = param; break;
+ case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = param; break;
+ default: UNREACHABLE(); break;
+ }
+ }
+}
+
+void GL_APIENTRY TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
+{
+ TexParameterf(target, pname, (GLfloat)*params);
+}
+
+void GL_APIENTRY TexParameteri(GLenum target, GLenum pname, GLint param)
+{
+ EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateTexParamParameters(context, pname, param))
+ {
+ return;
+ }
+
+ Texture *texture = context->getTargetTexture(target);
+
+ if (!texture)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (pname)
+ {
+ case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = (GLenum)param; break;
+ case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = (GLenum)param; break;
+ case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = (GLenum)param; break;
+ case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = (GLenum)param; break;
+ case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = (GLenum)param; break;
+ case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break;
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min((float)param, context->getExtensions().maxTextureAnisotropy); break;
+ case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = (GLenum)param; break;
+ case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = (GLenum)param; break;
+ case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = (GLenum)param; break;
+ case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = (GLenum)param; break;
+ case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = (GLenum)param; break;
+ case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = (GLenum)param; break;
+ case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = param; break;
+ case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = param; break;
+ case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = (GLfloat)param; break;
+ case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = (GLfloat)param; break;
+ default: UNREACHABLE(); break;
+ }
+ }
+}
+
+void GL_APIENTRY TexParameteriv(GLenum target, GLenum pname, const GLint* params)
+{
+ TexParameteri(target, pname, *params);
+}
+
+void GL_APIENTRY TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
+ GLenum format, GLenum type, const GLvoid* pixels)
+{
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
+ "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
+ "const GLvoid* pixels = 0x%0.8p)",
+ target, level, xoffset, yoffset, width, height, format, type, pixels);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3 &&
+ !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true,
+ xoffset, yoffset, width, height, 0, format, type, pixels))
+ {
+ return;
+ }
+
+ if (context->getClientVersion() >= 3 &&
+ !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
+ xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels))
+ {
+ return;
+ }
+
+ // Zero sized uploads are valid but no-ops
+ if (width == 0 || height == 0)
+ {
+ return;
+ }
+
+ Box area(xoffset, yoffset, 0, width, height, 1);
+ Texture *texture = context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target);
+ Error error = texture->setSubImage(target, level, area, format, type, context->getState().getUnpackState(),
+ reinterpret_cast<const uint8_t *>(pixels));
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY Uniform1f(GLint location, GLfloat x)
+{
+ Uniform1fv(location, 1, &x);
+}
+
+void GL_APIENTRY Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniform(context, GL_FLOAT, location, count))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniform1fv(location, count, v);
+ }
+}
+
+void GL_APIENTRY Uniform1i(GLint location, GLint x)
+{
+ Uniform1iv(location, 1, &x);
+}
+
+void GL_APIENTRY Uniform1iv(GLint location, GLsizei count, const GLint* v)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniform(context, GL_INT, location, count))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniform1iv(location, count, v);
+ }
+}
+
+void GL_APIENTRY Uniform2f(GLint location, GLfloat x, GLfloat y)
+{
+ GLfloat xy[2] = {x, y};
+
+ Uniform2fv(location, 1, xy);
+}
+
+void GL_APIENTRY Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniform2fv(location, count, v);
+ }
+}
+
+void GL_APIENTRY Uniform2i(GLint location, GLint x, GLint y)
+{
+ GLint xy[2] = {x, y};
+
+ Uniform2iv(location, 1, xy);
+}
+
+void GL_APIENTRY Uniform2iv(GLint location, GLsizei count, const GLint* v)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniform(context, GL_INT_VEC2, location, count))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniform2iv(location, count, v);
+ }
+}
+
+void GL_APIENTRY Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
+{
+ GLfloat xyz[3] = {x, y, z};
+
+ Uniform3fv(location, 1, xyz);
+}
+
+void GL_APIENTRY Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniform3fv(location, count, v);
+ }
+}
+
+void GL_APIENTRY Uniform3i(GLint location, GLint x, GLint y, GLint z)
+{
+ GLint xyz[3] = {x, y, z};
+
+ Uniform3iv(location, 1, xyz);
+}
+
+void GL_APIENTRY Uniform3iv(GLint location, GLsizei count, const GLint* v)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniform(context, GL_INT_VEC3, location, count))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniform3iv(location, count, v);
+ }
+}
+
+void GL_APIENTRY Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ GLfloat xyzw[4] = {x, y, z, w};
+
+ Uniform4fv(location, 1, xyzw);
+}
+
+void GL_APIENTRY Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniform4fv(location, count, v);
+ }
+}
+
+void GL_APIENTRY Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
+{
+ GLint xyzw[4] = {x, y, z, w};
+
+ Uniform4iv(location, 1, xyzw);
+}
+
+void GL_APIENTRY Uniform4iv(GLint location, GLsizei count, const GLint* v)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniform(context, GL_INT_VEC4, location, count))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniform4iv(location, count, v);
+ }
+}
+
+void GL_APIENTRY UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
+ location, count, transpose, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniformMatrix2fv(location, count, transpose, value);
+ }
+}
+
+void GL_APIENTRY UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
+ location, count, transpose, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniformMatrix3fv(location, count, transpose, value);
+ }
+}
+
+void GL_APIENTRY UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
+ location, count, transpose, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniformMatrix4fv(location, count, transpose, value);
+ }
+}
+
+void GL_APIENTRY UseProgram(GLuint program)
+{
+ EVENT("(GLuint program = %d)", program);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject && program != 0)
+ {
+ if (context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ if (program != 0 && !programObject->isLinked())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ context->useProgram(program);
+ }
+}
+
+void GL_APIENTRY ValidateProgram(GLuint program)
+{
+ EVENT("(GLuint program = %d)", program);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject)
+ {
+ if (context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ programObject->validate(context->getCaps());
+ }
+}
+
+void GL_APIENTRY VertexAttrib1f(GLuint index, GLfloat x)
+{
+ EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ GLfloat vals[4] = { x, 0, 0, 1 };
+ context->getState().setVertexAttribf(index, vals);
+ }
+}
+
+void GL_APIENTRY VertexAttrib1fv(GLuint index, const GLfloat* values)
+{
+ EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ GLfloat vals[4] = { values[0], 0, 0, 1 };
+ context->getState().setVertexAttribf(index, vals);
+ }
+}
+
+void GL_APIENTRY VertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
+{
+ EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ GLfloat vals[4] = { x, y, 0, 1 };
+ context->getState().setVertexAttribf(index, vals);
+ }
+}
+
+void GL_APIENTRY VertexAttrib2fv(GLuint index, const GLfloat* values)
+{
+ EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ GLfloat vals[4] = { values[0], values[1], 0, 1 };
+ context->getState().setVertexAttribf(index, vals);
+ }
+}
+
+void GL_APIENTRY VertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
+{
+ EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", index, x, y, z);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ GLfloat vals[4] = { x, y, z, 1 };
+ context->getState().setVertexAttribf(index, vals);
+ }
+}
+
+void GL_APIENTRY VertexAttrib3fv(GLuint index, const GLfloat* values)
+{
+ EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ GLfloat vals[4] = { values[0], values[1], values[2], 1 };
+ context->getState().setVertexAttribf(index, vals);
+ }
+}
+
+void GL_APIENTRY VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f, GLfloat w = %f)", index, x, y, z, w);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ GLfloat vals[4] = { x, y, z, w };
+ context->getState().setVertexAttribf(index, vals);
+ }
+}
+
+void GL_APIENTRY VertexAttrib4fv(GLuint index, const GLfloat* values)
+{
+ EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ context->getState().setVertexAttribf(index, values);
+ }
+}
+
+void GL_APIENTRY VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
+{
+ EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
+ "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
+ index, size, type, normalized, stride, ptr);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if (size < 1 || size > 4)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ switch (type)
+ {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_FIXED:
+ case GL_FLOAT:
+ break;
+
+ case GL_HALF_FLOAT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_INT_2_10_10_10_REV:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (stride < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ // [OpenGL ES 3.0.2] Section 2.8 page 24:
+ // An INVALID_OPERATION error is generated when a non-zero vertex array object
+ // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
+ // and the pointer argument is not NULL.
+ if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && ptr != NULL)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type,
+ normalized == GL_TRUE, false, stride, ptr);
+ }
+}
+
+void GL_APIENTRY Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (width < 0 || height < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ context->getState().setViewportParams(x, y, width, height);
+ }
+}
+
+}
diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0.h b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0.h
new file mode 100644
index 0000000000..eee5fb5468
--- /dev/null
+++ b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0.h
@@ -0,0 +1,163 @@
+//
+// Copyright(c) 2014 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.
+//
+
+// entry_points_gles_2_0.h : Defines the GLES 2.0 entry points.
+
+#ifndef LIBGLESV2_ENTRYPOINTGLES20_H_
+#define LIBGLESV2_ENTRYPOINTGLES20_H_
+
+#include <GLES2/gl2.h>
+#include <export.h>
+
+namespace gl
+{
+
+ANGLE_EXPORT void GL_APIENTRY ActiveTexture(GLenum texture);
+ANGLE_EXPORT void GL_APIENTRY AttachShader(GLuint program, GLuint shader);
+ANGLE_EXPORT void GL_APIENTRY BindAttribLocation(GLuint program, GLuint index, const GLchar* name);
+ANGLE_EXPORT void GL_APIENTRY BindBuffer(GLenum target, GLuint buffer);
+ANGLE_EXPORT void GL_APIENTRY BindFramebuffer(GLenum target, GLuint framebuffer);
+ANGLE_EXPORT void GL_APIENTRY BindRenderbuffer(GLenum target, GLuint renderbuffer);
+ANGLE_EXPORT void GL_APIENTRY BindTexture(GLenum target, GLuint texture);
+ANGLE_EXPORT void GL_APIENTRY BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+ANGLE_EXPORT void GL_APIENTRY BlendEquation(GLenum mode);
+ANGLE_EXPORT void GL_APIENTRY BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
+ANGLE_EXPORT void GL_APIENTRY BlendFunc(GLenum sfactor, GLenum dfactor);
+ANGLE_EXPORT void GL_APIENTRY BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+ANGLE_EXPORT void GL_APIENTRY BufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
+ANGLE_EXPORT void GL_APIENTRY BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
+ANGLE_EXPORT GLenum GL_APIENTRY CheckFramebufferStatus(GLenum target);
+ANGLE_EXPORT void GL_APIENTRY Clear(GLbitfield mask);
+ANGLE_EXPORT void GL_APIENTRY ClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+ANGLE_EXPORT void GL_APIENTRY ClearDepthf(GLfloat depth);
+ANGLE_EXPORT void GL_APIENTRY ClearStencil(GLint s);
+ANGLE_EXPORT void GL_APIENTRY ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+ANGLE_EXPORT void GL_APIENTRY CompileShader(GLuint shader);
+ANGLE_EXPORT void GL_APIENTRY CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
+ANGLE_EXPORT void GL_APIENTRY CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);
+ANGLE_EXPORT void GL_APIENTRY CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+ANGLE_EXPORT void GL_APIENTRY CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+ANGLE_EXPORT GLuint GL_APIENTRY CreateProgram(void);
+ANGLE_EXPORT GLuint GL_APIENTRY CreateShader(GLenum type);
+ANGLE_EXPORT void GL_APIENTRY CullFace(GLenum mode);
+ANGLE_EXPORT void GL_APIENTRY DeleteBuffers(GLsizei n, const GLuint* buffers);
+ANGLE_EXPORT void GL_APIENTRY DeleteFramebuffers(GLsizei n, const GLuint* framebuffers);
+ANGLE_EXPORT void GL_APIENTRY DeleteProgram(GLuint program);
+ANGLE_EXPORT void GL_APIENTRY DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers);
+ANGLE_EXPORT void GL_APIENTRY DeleteShader(GLuint shader);
+ANGLE_EXPORT void GL_APIENTRY DeleteTextures(GLsizei n, const GLuint* textures);
+ANGLE_EXPORT void GL_APIENTRY DepthFunc(GLenum func);
+ANGLE_EXPORT void GL_APIENTRY DepthMask(GLboolean flag);
+ANGLE_EXPORT void GL_APIENTRY DepthRangef(GLfloat n, GLfloat f);
+ANGLE_EXPORT void GL_APIENTRY DetachShader(GLuint program, GLuint shader);
+ANGLE_EXPORT void GL_APIENTRY Disable(GLenum cap);
+ANGLE_EXPORT void GL_APIENTRY DisableVertexAttribArray(GLuint index);
+ANGLE_EXPORT void GL_APIENTRY DrawArrays(GLenum mode, GLint first, GLsizei count);
+ANGLE_EXPORT void GL_APIENTRY DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
+ANGLE_EXPORT void GL_APIENTRY Enable(GLenum cap);
+ANGLE_EXPORT void GL_APIENTRY EnableVertexAttribArray(GLuint index);
+ANGLE_EXPORT void GL_APIENTRY Finish(void);
+ANGLE_EXPORT void GL_APIENTRY Flush(void);
+ANGLE_EXPORT void GL_APIENTRY FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+ANGLE_EXPORT void GL_APIENTRY FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+ANGLE_EXPORT void GL_APIENTRY FrontFace(GLenum mode);
+ANGLE_EXPORT void GL_APIENTRY GenBuffers(GLsizei n, GLuint* buffers);
+ANGLE_EXPORT void GL_APIENTRY GenerateMipmap(GLenum target);
+ANGLE_EXPORT void GL_APIENTRY GenFramebuffers(GLsizei n, GLuint* framebuffers);
+ANGLE_EXPORT void GL_APIENTRY GenRenderbuffers(GLsizei n, GLuint* renderbuffers);
+ANGLE_EXPORT void GL_APIENTRY GenTextures(GLsizei n, GLuint* textures);
+ANGLE_EXPORT void GL_APIENTRY GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+ANGLE_EXPORT void GL_APIENTRY GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+ANGLE_EXPORT void GL_APIENTRY GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
+ANGLE_EXPORT GLint GL_APIENTRY GetAttribLocation(GLuint program, const GLchar* name);
+ANGLE_EXPORT void GL_APIENTRY GetBooleanv(GLenum pname, GLboolean* params);
+ANGLE_EXPORT void GL_APIENTRY GetBufferParameteriv(GLenum target, GLenum pname, GLint* params);
+ANGLE_EXPORT GLenum GL_APIENTRY GetError(void);
+ANGLE_EXPORT void GL_APIENTRY GetFloatv(GLenum pname, GLfloat* params);
+ANGLE_EXPORT void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params);
+ANGLE_EXPORT void GL_APIENTRY GetIntegerv(GLenum pname, GLint* params);
+ANGLE_EXPORT void GL_APIENTRY GetProgramiv(GLuint program, GLenum pname, GLint* params);
+ANGLE_EXPORT void GL_APIENTRY GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+ANGLE_EXPORT void GL_APIENTRY GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params);
+ANGLE_EXPORT void GL_APIENTRY GetShaderiv(GLuint shader, GLenum pname, GLint* params);
+ANGLE_EXPORT void GL_APIENTRY GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+ANGLE_EXPORT void GL_APIENTRY GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+ANGLE_EXPORT void GL_APIENTRY GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
+ANGLE_EXPORT const GLubyte *GL_APIENTRY GetString(GLenum name);
+ANGLE_EXPORT void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params);
+ANGLE_EXPORT void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint* params);
+ANGLE_EXPORT void GL_APIENTRY GetUniformfv(GLuint program, GLint location, GLfloat* params);
+ANGLE_EXPORT void GL_APIENTRY GetUniformiv(GLuint program, GLint location, GLint* params);
+ANGLE_EXPORT GLint GL_APIENTRY GetUniformLocation(GLuint program, const GLchar* name);
+ANGLE_EXPORT void GL_APIENTRY GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params);
+ANGLE_EXPORT void GL_APIENTRY GetVertexAttribiv(GLuint index, GLenum pname, GLint* params);
+ANGLE_EXPORT void GL_APIENTRY GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer);
+ANGLE_EXPORT void GL_APIENTRY Hint(GLenum target, GLenum mode);
+ANGLE_EXPORT GLboolean GL_APIENTRY IsBuffer(GLuint buffer);
+ANGLE_EXPORT GLboolean GL_APIENTRY IsEnabled(GLenum cap);
+ANGLE_EXPORT GLboolean GL_APIENTRY IsFramebuffer(GLuint framebuffer);
+ANGLE_EXPORT GLboolean GL_APIENTRY IsProgram(GLuint program);
+ANGLE_EXPORT GLboolean GL_APIENTRY IsRenderbuffer(GLuint renderbuffer);
+ANGLE_EXPORT GLboolean GL_APIENTRY IsShader(GLuint shader);
+ANGLE_EXPORT GLboolean GL_APIENTRY IsTexture(GLuint texture);
+ANGLE_EXPORT void GL_APIENTRY LineWidth(GLfloat width);
+ANGLE_EXPORT void GL_APIENTRY LinkProgram(GLuint program);
+ANGLE_EXPORT void GL_APIENTRY PixelStorei(GLenum pname, GLint param);
+ANGLE_EXPORT void GL_APIENTRY PolygonOffset(GLfloat factor, GLfloat units);
+ANGLE_EXPORT void GL_APIENTRY ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
+ANGLE_EXPORT void GL_APIENTRY ReleaseShaderCompiler(void);
+ANGLE_EXPORT void GL_APIENTRY RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+ANGLE_EXPORT void GL_APIENTRY SampleCoverage(GLfloat value, GLboolean invert);
+ANGLE_EXPORT void GL_APIENTRY Scissor(GLint x, GLint y, GLsizei width, GLsizei height);
+ANGLE_EXPORT void GL_APIENTRY ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
+ANGLE_EXPORT void GL_APIENTRY ShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
+ANGLE_EXPORT void GL_APIENTRY StencilFunc(GLenum func, GLint ref, GLuint mask);
+ANGLE_EXPORT void GL_APIENTRY StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
+ANGLE_EXPORT void GL_APIENTRY StencilMask(GLuint mask);
+ANGLE_EXPORT void GL_APIENTRY StencilMaskSeparate(GLenum face, GLuint mask);
+ANGLE_EXPORT void GL_APIENTRY StencilOp(GLenum fail, GLenum zfail, GLenum zpass);
+ANGLE_EXPORT void GL_APIENTRY StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
+ANGLE_EXPORT void GL_APIENTRY TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+ANGLE_EXPORT void GL_APIENTRY TexParameterf(GLenum target, GLenum pname, GLfloat param);
+ANGLE_EXPORT void GL_APIENTRY TexParameterfv(GLenum target, GLenum pname, const GLfloat* params);
+ANGLE_EXPORT void GL_APIENTRY TexParameteri(GLenum target, GLenum pname, GLint param);
+ANGLE_EXPORT void GL_APIENTRY TexParameteriv(GLenum target, GLenum pname, const GLint* params);
+ANGLE_EXPORT void GL_APIENTRY TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
+ANGLE_EXPORT void GL_APIENTRY Uniform1f(GLint location, GLfloat x);
+ANGLE_EXPORT void GL_APIENTRY Uniform1fv(GLint location, GLsizei count, const GLfloat* v);
+ANGLE_EXPORT void GL_APIENTRY Uniform1i(GLint location, GLint x);
+ANGLE_EXPORT void GL_APIENTRY Uniform1iv(GLint location, GLsizei count, const GLint* v);
+ANGLE_EXPORT void GL_APIENTRY Uniform2f(GLint location, GLfloat x, GLfloat y);
+ANGLE_EXPORT void GL_APIENTRY Uniform2fv(GLint location, GLsizei count, const GLfloat* v);
+ANGLE_EXPORT void GL_APIENTRY Uniform2i(GLint location, GLint x, GLint y);
+ANGLE_EXPORT void GL_APIENTRY Uniform2iv(GLint location, GLsizei count, const GLint* v);
+ANGLE_EXPORT void GL_APIENTRY Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z);
+ANGLE_EXPORT void GL_APIENTRY Uniform3fv(GLint location, GLsizei count, const GLfloat* v);
+ANGLE_EXPORT void GL_APIENTRY Uniform3i(GLint location, GLint x, GLint y, GLint z);
+ANGLE_EXPORT void GL_APIENTRY Uniform3iv(GLint location, GLsizei count, const GLint* v);
+ANGLE_EXPORT void GL_APIENTRY Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+ANGLE_EXPORT void GL_APIENTRY Uniform4fv(GLint location, GLsizei count, const GLfloat* v);
+ANGLE_EXPORT void GL_APIENTRY Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w);
+ANGLE_EXPORT void GL_APIENTRY Uniform4iv(GLint location, GLsizei count, const GLint* v);
+ANGLE_EXPORT void GL_APIENTRY UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ANGLE_EXPORT void GL_APIENTRY UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ANGLE_EXPORT void GL_APIENTRY UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ANGLE_EXPORT void GL_APIENTRY UseProgram(GLuint program);
+ANGLE_EXPORT void GL_APIENTRY ValidateProgram(GLuint program);
+ANGLE_EXPORT void GL_APIENTRY VertexAttrib1f(GLuint indx, GLfloat x);
+ANGLE_EXPORT void GL_APIENTRY VertexAttrib1fv(GLuint indx, const GLfloat* values);
+ANGLE_EXPORT void GL_APIENTRY VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
+ANGLE_EXPORT void GL_APIENTRY VertexAttrib2fv(GLuint indx, const GLfloat* values);
+ANGLE_EXPORT void GL_APIENTRY VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
+ANGLE_EXPORT void GL_APIENTRY VertexAttrib3fv(GLuint indx, const GLfloat* values);
+ANGLE_EXPORT void GL_APIENTRY VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+ANGLE_EXPORT void GL_APIENTRY VertexAttrib4fv(GLuint indx, const GLfloat* values);
+ANGLE_EXPORT void GL_APIENTRY VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);
+ANGLE_EXPORT void GL_APIENTRY Viewport(GLint x, GLint y, GLsizei width, GLsizei height);
+
+}
+
+#endif // LIBGLESV2_ENTRYPOINTGLES20_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp
new file mode 100644
index 0000000000..8be6ae7d2f
--- /dev/null
+++ b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp
@@ -0,0 +1,1058 @@
+//
+// Copyright(c) 2014 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.
+//
+
+// entry_points_gles_2_0_ext.cpp : Implements the GLES 2.0 extension entry points.
+
+#include "libGLESv2/entry_points_gles_2_0_ext.h"
+#include "libGLESv2/global_state.h"
+
+#include "libANGLE/Buffer.h"
+#include "libANGLE/Context.h"
+#include "libANGLE/Error.h"
+#include "libANGLE/Fence.h"
+#include "libANGLE/Framebuffer.h"
+#include "libANGLE/Shader.h"
+#include "libANGLE/Query.h"
+
+#include "libANGLE/validationES.h"
+#include "libANGLE/validationES2.h"
+#include "libANGLE/validationES3.h"
+
+#include "common/debug.h"
+#include "common/utilities.h"
+
+namespace gl
+{
+
+void GL_APIENTRY BeginQueryEXT(GLenum target, GLuint id)
+{
+ EVENT("(GLenum target = 0x%X, GLuint %d)", target, id);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateBeginQuery(context, target, id))
+ {
+ return;
+ }
+
+ Error error = context->beginQuery(target, id);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY DeleteFencesNV(GLsizei n, const GLuint* fences)
+{
+ EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ context->deleteFenceNV(fences[i]);
+ }
+ }
+}
+
+void GL_APIENTRY DeleteQueriesEXT(GLsizei n, const GLuint *ids)
+{
+ EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ context->deleteQuery(ids[i]);
+ }
+ }
+}
+
+void GL_APIENTRY DrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
+{
+ EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateDrawArraysInstancedANGLE(context, mode, first, count, primcount))
+ {
+ return;
+ }
+
+ Error error = context->drawArrays(mode, first, count, primcount);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY DrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
+{
+ EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
+ mode, count, type, indices, primcount);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ rx::RangeUI indexRange;
+ if (!ValidateDrawElementsInstancedANGLE(context, mode, count, type, indices, primcount, &indexRange))
+ {
+ return;
+ }
+
+ Error error = context->drawElements(mode, count, type, indices, primcount, indexRange);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY EndQueryEXT(GLenum target)
+{
+ EVENT("GLenum target = 0x%X)", target);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateEndQuery(context, target))
+ {
+ return;
+ }
+
+ Error error = context->endQuery(target);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY FinishFenceNV(GLuint fence)
+{
+ EVENT("(GLuint fence = %d)", fence);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ FenceNV *fenceObject = context->getFenceNV(fence);
+
+ if (fenceObject == NULL)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (fenceObject->isFence() != GL_TRUE)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ fenceObject->finishFence();
+ }
+}
+
+void GL_APIENTRY GenFencesNV(GLsizei n, GLuint* fences)
+{
+ EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ fences[i] = context->createFenceNV();
+ }
+ }
+}
+
+void GL_APIENTRY GenQueriesEXT(GLsizei n, GLuint* ids)
+{
+ EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (GLsizei i = 0; i < n; i++)
+ {
+ ids[i] = context->createQuery();
+ }
+ }
+}
+
+void GL_APIENTRY GetFenceivNV(GLuint fence, GLenum pname, GLint *params)
+{
+ EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ FenceNV *fenceObject = context->getFenceNV(fence);
+
+ if (fenceObject == NULL)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (fenceObject->isFence() != GL_TRUE)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ switch (pname)
+ {
+ case GL_FENCE_STATUS_NV:
+ {
+ // GL_NV_fence spec:
+ // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
+ // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
+ GLboolean status = GL_TRUE;
+ if (fenceObject->getStatus() != GL_TRUE)
+ {
+ Error error = fenceObject->testFence(&status);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+ *params = status;
+ break;
+ }
+
+ case GL_FENCE_CONDITION_NV:
+ {
+ *params = static_cast<GLint>(fenceObject->getCondition());
+ break;
+ }
+
+ default:
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+ }
+}
+
+GLenum GL_APIENTRY GetGraphicsResetStatusEXT(void)
+{
+ EVENT("()");
+
+ Context *context = GetGlobalContext();
+
+ if (context)
+ {
+ return context->getResetStatus();
+ }
+
+ return GL_NO_ERROR;
+}
+
+void GL_APIENTRY GetQueryivEXT(GLenum target, GLenum pname, GLint *params)
+{
+ EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidQueryType(context, target))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (pname)
+ {
+ case GL_CURRENT_QUERY_EXT:
+ params[0] = context->getState().getActiveQueryId(target);
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY GetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
+{
+ EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Query *queryObject = context->getQuery(id, false, GL_NONE);
+
+ if (!queryObject)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (context->getState().getActiveQueryId(queryObject->getType()) == id)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ switch(pname)
+ {
+ case GL_QUERY_RESULT_EXT:
+ {
+ Error error = queryObject->getResult(params);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+ break;
+
+ case GL_QUERY_RESULT_AVAILABLE_EXT:
+ {
+ Error error = queryObject->isResultAvailable(params);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY GetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
+{
+ EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
+ shader, bufsize, length, source);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (bufsize < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ Shader *shaderObject = context->getShader(shader);
+
+ if (!shaderObject)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ // Only returns extra info if ANGLE_GENERATE_SHADER_DEBUG_INFO is defined
+ shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source);
+ }
+}
+
+void GL_APIENTRY GetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
+{
+ EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
+ program, location, bufSize, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateGetnUniformfvEXT(context, program, location, bufSize, params))
+ {
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+ ASSERT(programObject);
+
+ programObject->getUniformfv(location, params);
+ }
+}
+
+void GL_APIENTRY GetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
+{
+ EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
+ program, location, bufSize, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateGetnUniformivEXT(context, program, location, bufSize, params))
+ {
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+ ASSERT(programObject);
+
+ programObject->getUniformiv(location, params);
+ }
+}
+
+GLboolean GL_APIENTRY IsFenceNV(GLuint fence)
+{
+ EVENT("(GLuint fence = %d)", fence);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ FenceNV *fenceObject = context->getFenceNV(fence);
+
+ if (fenceObject == NULL)
+ {
+ return GL_FALSE;
+ }
+
+ return fenceObject->isFence();
+ }
+
+ return GL_FALSE;
+}
+
+GLboolean GL_APIENTRY IsQueryEXT(GLuint id)
+{
+ EVENT("(GLuint id = %d)", id);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
+ }
+
+ return GL_FALSE;
+}
+
+void GL_APIENTRY ReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type, GLsizei bufSize,
+ GLvoid *data)
+{
+ EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
+ "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
+ x, y, width, height, format, type, bufSize, data);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (width < 0 || height < 0 || bufSize < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if (!ValidateReadPixelsParameters(context, x, y, width, height,
+ format, type, &bufSize, data))
+ {
+ return;
+ }
+
+ Framebuffer *framebufferObject = context->getState().getReadFramebuffer();
+ ASSERT(framebufferObject);
+
+ Rectangle area(x, y, width, height);
+ Error error = framebufferObject->readPixels(context->getState(), area, format, type, data);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY RenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
+{
+ EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
+ target, samples, internalformat, width, height);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateRenderbufferStorageParametersANGLE(context, target, samples, internalformat,
+ width, height))
+ {
+ return;
+ }
+
+ Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
+ Error error = renderbuffer->setStorageMultisample(samples, internalformat, width, height);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY SetFenceNV(GLuint fence, GLenum condition)
+{
+ EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (condition != GL_ALL_COMPLETED_NV)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ FenceNV *fenceObject = context->getFenceNV(fence);
+
+ if (fenceObject == NULL)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ Error error = fenceObject->setFence(condition);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+GLboolean GL_APIENTRY TestFenceNV(GLuint fence)
+{
+ EVENT("(GLuint fence = %d)", fence);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ FenceNV *fenceObject = context->getFenceNV(fence);
+
+ if (fenceObject == NULL)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return GL_TRUE;
+ }
+
+ if (fenceObject->isFence() != GL_TRUE)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return GL_TRUE;
+ }
+
+ GLboolean result;
+ Error error = fenceObject->testFence(&result);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return GL_TRUE;
+ }
+
+ return result;
+ }
+
+ return GL_TRUE;
+}
+
+void GL_APIENTRY TexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
+{
+ EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
+ target, levels, internalformat, width, height);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!context->getExtensions().textureStorage)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (context->getClientVersion() < 3 &&
+ !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height))
+ {
+ return;
+ }
+
+ if (context->getClientVersion() >= 3 &&
+ !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
+ {
+ return;
+ }
+
+ Extents size(width, height, 1);
+ Texture *texture = context->getTargetTexture(target);
+ Error error = texture->setStorage(target, levels, internalformat, size);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY VertexAttribDivisorANGLE(GLuint index, GLuint divisor)
+{
+ EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ context->setVertexAttribDivisor(index, divisor);
+ }
+}
+
+void GL_APIENTRY BlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter)
+{
+ EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
+ "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
+ "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
+ srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1, mask, filter,
+ true))
+ {
+ return;
+ }
+
+ Framebuffer *readFramebuffer = context->getState().getReadFramebuffer();
+ ASSERT(readFramebuffer);
+
+ Framebuffer *drawFramebuffer = context->getState().getDrawFramebuffer();
+ ASSERT(drawFramebuffer);
+
+ Rectangle srcArea(srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0);
+ Rectangle dstArea(dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0);
+
+ Error error = drawFramebuffer->blit(context->getState(), srcArea, dstArea, mask, filter, readFramebuffer);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY TexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
+ GLint border, GLenum format, GLenum type, const GLvoid* pixels)
+{
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
+ "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
+ "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
+ target, level, internalformat, width, height, depth, border, format, type, pixels);
+
+ UNIMPLEMENTED(); // FIXME
+}
+
+void GL_APIENTRY GetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary)
+{
+ EVENT("(GLenum program = 0x%X, bufSize = %d, length = 0x%0.8p, binaryFormat = 0x%0.8p, binary = 0x%0.8p)",
+ program, bufSize, length, binaryFormat, binary);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject || !programObject->isLinked())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ Error error = programObject->saveBinary(binaryFormat, binary, bufSize, length);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY ProgramBinaryOES(GLuint program, GLenum binaryFormat, const void *binary, GLint length)
+{
+ EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
+ program, binaryFormat, binary, length);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ const std::vector<GLenum> &programBinaryFormats = context->getCaps().programBinaryFormats;
+ if (std::find(programBinaryFormats.begin(), programBinaryFormats.end(), binaryFormat) == programBinaryFormats.end())
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+ if (!programObject)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ Error error = programObject->loadBinary(binaryFormat, binary, length);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY DrawBuffersEXT(GLsizei n, const GLenum *bufs)
+{
+ EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (n < 0 || static_cast<GLuint>(n) > context->getCaps().maxDrawBuffers)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ ASSERT(context->getState().getDrawFramebuffer());
+
+ if (context->getState().getDrawFramebuffer()->id() == 0)
+ {
+ if (n != 1)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ }
+ else
+ {
+ for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
+ {
+ const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
+ if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ }
+ }
+
+ Framebuffer *framebuffer = context->getState().getDrawFramebuffer();
+ ASSERT(framebuffer);
+
+ framebuffer->setDrawBuffers(n, bufs);
+ }
+}
+
+void GL_APIENTRY GetBufferPointervOES(GLenum target, GLenum pname, void** params)
+{
+ EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidBufferTarget(context, target))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (pname != GL_BUFFER_MAP_POINTER)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ Buffer *buffer = context->getState().getTargetBuffer(target);
+
+ if (!buffer || !buffer->isMapped())
+ {
+ *params = NULL;
+ }
+ else
+ {
+ *params = buffer->getMapPointer();
+ }
+ }
+}
+
+void *GL_APIENTRY MapBufferOES(GLenum target, GLenum access)
+{
+ EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidBufferTarget(context, target))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return NULL;
+ }
+
+ Buffer *buffer = context->getState().getTargetBuffer(target);
+
+ if (buffer == NULL)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return NULL;
+ }
+
+ if (access != GL_WRITE_ONLY_OES)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return NULL;
+ }
+
+ if (buffer->isMapped())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return NULL;
+ }
+
+ Error error = buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return NULL;
+ }
+
+ return buffer->getMapPointer();
+ }
+
+ return NULL;
+}
+
+GLboolean GL_APIENTRY UnmapBufferOES(GLenum target)
+{
+ EVENT("(GLenum target = 0x%X)", target);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidBufferTarget(context, target))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return GL_FALSE;
+ }
+
+ Buffer *buffer = context->getState().getTargetBuffer(target);
+
+ if (buffer == NULL || !buffer->isMapped())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return GL_FALSE;
+ }
+
+ // TODO: detect if we had corruption. if so, throw an error and return false.
+
+ Error error = buffer->unmap();
+ if (error.isError())
+ {
+ context->recordError(error);
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+ }
+
+ return GL_FALSE;
+}
+
+void *GL_APIENTRY MapBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
+{
+ EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
+ target, offset, length, access);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidBufferTarget(context, target))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return NULL;
+ }
+
+ if (offset < 0 || length < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return NULL;
+ }
+
+ Buffer *buffer = context->getState().getTargetBuffer(target);
+
+ if (buffer == NULL)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return NULL;
+ }
+
+ // Check for buffer overflow
+ size_t offsetSize = static_cast<size_t>(offset);
+ size_t lengthSize = static_cast<size_t>(length);
+
+ if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
+ offsetSize + lengthSize > static_cast<size_t>(buffer->getSize()))
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return NULL;
+ }
+
+ // Check for invalid bits in the mask
+ GLbitfield allAccessBits = GL_MAP_READ_BIT |
+ GL_MAP_WRITE_BIT |
+ GL_MAP_INVALIDATE_RANGE_BIT |
+ GL_MAP_INVALIDATE_BUFFER_BIT |
+ GL_MAP_FLUSH_EXPLICIT_BIT |
+ GL_MAP_UNSYNCHRONIZED_BIT;
+
+ if (access & ~(allAccessBits))
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return NULL;
+ }
+
+ if (length == 0 || buffer->isMapped())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return NULL;
+ }
+
+ // Check for invalid bit combinations
+ if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return NULL;
+ }
+
+ GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT |
+ GL_MAP_INVALIDATE_BUFFER_BIT |
+ GL_MAP_UNSYNCHRONIZED_BIT;
+
+ if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return NULL;
+ }
+
+ if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return NULL;
+ }
+
+ Error error = buffer->mapRange(offset, length, access);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return NULL;
+ }
+
+ return buffer->getMapPointer();
+ }
+
+ return NULL;
+}
+
+void GL_APIENTRY FlushMappedBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length)
+{
+ EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (offset < 0 || length < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if (!ValidBufferTarget(context, target))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ Buffer *buffer = context->getState().getTargetBuffer(target);
+
+ if (buffer == NULL)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ // Check for buffer overflow
+ size_t offsetSize = static_cast<size_t>(offset);
+ size_t lengthSize = static_cast<size_t>(length);
+
+ if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
+ offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength()))
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ // We do not currently support a non-trivial implementation of FlushMappedBufferRange
+ }
+}
+
+}
diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0_ext.h b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0_ext.h
new file mode 100644
index 0000000000..816519fe1f
--- /dev/null
+++ b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0_ext.h
@@ -0,0 +1,78 @@
+//
+// Copyright(c) 2014 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.
+//
+
+// entry_points_gles_2_0_ext.h : Defines the GLES 2.0 extension entry points.
+
+#ifndef LIBGLESV2_ENTRYPOINTGLES20EXT_H_
+#define LIBGLESV2_ENTRYPOINTGLES20EXT_H_
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <export.h>
+
+namespace gl
+{
+
+// GL_ANGLE_framebuffer_blit
+ANGLE_EXPORT void GL_APIENTRY BlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+
+// GL_ANGLE_framebuffer_multisample
+ANGLE_EXPORT void GL_APIENTRY RenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+
+// GL_NV_fence
+ANGLE_EXPORT void GL_APIENTRY DeleteFencesNV(GLsizei n, const GLuint* fences);
+ANGLE_EXPORT void GL_APIENTRY GenFencesNV(GLsizei n, GLuint* fences);
+ANGLE_EXPORT GLboolean GL_APIENTRY IsFenceNV(GLuint fence);
+ANGLE_EXPORT GLboolean GL_APIENTRY TestFenceNV(GLuint fence);
+ANGLE_EXPORT void GL_APIENTRY GetFenceivNV(GLuint fence, GLenum pname, GLint *params);
+ANGLE_EXPORT void GL_APIENTRY FinishFenceNV(GLuint fence);
+ANGLE_EXPORT void GL_APIENTRY SetFenceNV(GLuint fence, GLenum condition);
+
+// GL_ANGLE_translated_shader_source
+ANGLE_EXPORT void GL_APIENTRY GetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
+
+// GL_EXT_texture_storage
+ANGLE_EXPORT void GL_APIENTRY TexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+
+// GL_EXT_robustness
+ANGLE_EXPORT GLenum GL_APIENTRY GetGraphicsResetStatusEXT(void);
+ANGLE_EXPORT void GL_APIENTRY ReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
+ANGLE_EXPORT void GL_APIENTRY GetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, float *params);
+ANGLE_EXPORT void GL_APIENTRY GetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint *params);
+
+// GL_EXT_occlusion_query_boolean
+ANGLE_EXPORT void GL_APIENTRY GenQueriesEXT(GLsizei n, GLuint *ids);
+ANGLE_EXPORT void GL_APIENTRY DeleteQueriesEXT(GLsizei n, const GLuint *ids);
+ANGLE_EXPORT GLboolean GL_APIENTRY IsQueryEXT(GLuint id);
+ANGLE_EXPORT void GL_APIENTRY BeginQueryEXT(GLenum target, GLuint id);
+ANGLE_EXPORT void GL_APIENTRY EndQueryEXT(GLenum target);
+ANGLE_EXPORT void GL_APIENTRY GetQueryivEXT(GLenum target, GLenum pname, GLint *params);
+ANGLE_EXPORT void GL_APIENTRY GetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params);
+
+// GL_EXT_draw_buffers
+ANGLE_EXPORT void GL_APIENTRY DrawBuffersEXT(GLsizei n, const GLenum *bufs);
+
+// GL_ANGLE_instanced_arrays
+ANGLE_EXPORT void GL_APIENTRY DrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+ANGLE_EXPORT void GL_APIENTRY DrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+ANGLE_EXPORT void GL_APIENTRY VertexAttribDivisorANGLE(GLuint index, GLuint divisor);
+
+// GL_OES_get_program_binary
+ANGLE_EXPORT void GL_APIENTRY GetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
+ANGLE_EXPORT void GL_APIENTRY ProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
+
+// GL_OES_mapbuffer
+ANGLE_EXPORT void *GL_APIENTRY MapBufferOES(GLenum target, GLenum access);
+ANGLE_EXPORT GLboolean GL_APIENTRY UnmapBufferOES(GLenum target);
+ANGLE_EXPORT void GL_APIENTRY GetBufferPointervOES(GLenum target, GLenum pname, GLvoid **params);
+
+// GL_EXT_map_buffer_range
+ANGLE_EXPORT void *GL_APIENTRY MapBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+ANGLE_EXPORT void GL_APIENTRY FlushMappedBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length);
+
+}
+
+#endif // LIBGLESV2_ENTRYPOINTGLES20EXT_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_gles_3_0.cpp b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_3_0.cpp
new file mode 100644
index 0000000000..d8bdcd2e50
--- /dev/null
+++ b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_3_0.cpp
@@ -0,0 +1,3394 @@
+//
+// Copyright(c) 2014 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.
+//
+
+// entry_points_gles_3_0.cpp : Implements the GLES 3.0 entry points.
+
+#include "libGLESv2/entry_points_gles_3_0.h"
+#include "libGLESv2/entry_points_gles_2_0_ext.h"
+#include "libGLESv2/global_state.h"
+
+#include "libANGLE/formatutils.h"
+#include "libANGLE/Buffer.h"
+#include "libANGLE/Context.h"
+#include "libANGLE/Error.h"
+#include "libANGLE/Fence.h"
+#include "libANGLE/Framebuffer.h"
+#include "libANGLE/Query.h"
+#include "libANGLE/VertexArray.h"
+
+#include "libANGLE/validationES.h"
+#include "libANGLE/validationES3.h"
+#include "libANGLE/queryconversions.h"
+
+#include "common/debug.h"
+
+namespace gl
+{
+
+void GL_APIENTRY ReadBuffer(GLenum mode)
+{
+ EVENT("(GLenum mode = 0x%X)", mode);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateReadBuffer(context, mode))
+ {
+ return;
+ }
+
+ Framebuffer *readFBO = context->getState().getReadFramebuffer();
+ readFBO->setReadBuffer(mode);
+ }
+}
+
+void GL_APIENTRY DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
+{
+ EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
+ "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ rx::RangeUI indexRange;
+ if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange))
+ {
+ return;
+ }
+ if (indexRange.end > end || indexRange.start < start)
+ {
+ // GL spec says that behavior in this case is undefined - generating an error is fine.
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ // As long as index validation is done, it doesn't matter whether the context receives a drawElements or
+ // a drawRangeElements call - the GL back-end is free to choose to call drawRangeElements based on the
+ // validated index range. If index validation is removed, adding drawRangeElements to the context interface
+ // should be reconsidered.
+ Error error = context->drawElements(mode, count, type, indices, 0, indexRange);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
+{
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
+ "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
+ "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
+ target, level, internalformat, width, height, depth, border, format, type, pixels);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ // validateES3TexImageFormat sets the error code if there is an error
+ if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
+ 0, 0, 0, width, height, depth, border, format, type, pixels))
+ {
+ return;
+ }
+
+ Extents size(width, height, depth);
+ Texture *texture = context->getTargetTexture(target);
+ Error error = texture->setImage(target, level, internalformat, size, format, type, context->getState().getUnpackState(),
+ reinterpret_cast<const uint8_t *>(pixels));
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
+{
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
+ "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
+ "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
+ target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ // validateES3TexImageFormat sets the error code if there is an error
+ if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
+ xoffset, yoffset, zoffset, width, height, depth, 0,
+ format, type, pixels))
+ {
+ return;
+ }
+
+ // Zero sized uploads are valid but no-ops
+ if (width == 0 || height == 0 || depth == 0)
+ {
+ return;
+ }
+
+ Box area(xoffset, yoffset, zoffset, width, height, depth);
+ Texture *texture = context->getTargetTexture(target);
+ Error error = texture->setSubImage(target, level, area, format, type, context->getState().getUnpackState(),
+ reinterpret_cast<const uint8_t *>(pixels));
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
+ "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
+ target, level, xoffset, yoffset, zoffset, x, y, width, height);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset,
+ x, y, width, height, 0))
+ {
+ return;
+ }
+
+ Offset destOffset(xoffset, yoffset, zoffset);
+ Rectangle sourceArea(x, y, width, height);
+
+ const Framebuffer *framebuffer = context->getState().getReadFramebuffer();
+ Texture *texture = context->getTargetTexture(target);
+ Error error = texture->copySubImage(target, level, destOffset, sourceArea, framebuffer);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
+{
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
+ "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
+ "const GLvoid* data = 0x%0.8p)",
+ target, level, internalformat, width, height, depth, border, imageSize, data);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat);
+ if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ // validateES3TexImageFormat sets the error code if there is an error
+ if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
+ 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
+ {
+ return;
+ }
+
+ Extents size(width, height, depth);
+ Texture *texture = context->getTargetTexture(target);
+ Error error = texture->setCompressedImage(target, level, internalformat, size, context->getState().getUnpackState(),
+ reinterpret_cast<const uint8_t *>(data));
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
+{
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
+ "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
+ "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
+ target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ const InternalFormat &formatInfo = GetInternalFormatInfo(format);
+ if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if (!data)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ // validateES3TexImageFormat sets the error code if there is an error
+ if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
+ 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data))
+ {
+ return;
+ }
+
+ // Zero sized uploads are valid but no-ops
+ if (width == 0 || height == 0)
+ {
+ return;
+ }
+
+ Box area(xoffset, yoffset, zoffset, width, height, depth);
+ Texture *texture = context->getTargetTexture(target);
+ Error error = texture->setCompressedSubImage(target, level, area, format, context->getState().getUnpackState(),
+ reinterpret_cast<const uint8_t *>(data));
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY GenQueries(GLsizei n, GLuint* ids)
+{
+ EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (GLsizei i = 0; i < n; i++)
+ {
+ ids[i] = context->createQuery();
+ }
+ }
+}
+
+void GL_APIENTRY DeleteQueries(GLsizei n, const GLuint* ids)
+{
+ EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (GLsizei i = 0; i < n; i++)
+ {
+ context->deleteQuery(ids[i]);
+ }
+ }
+}
+
+GLboolean GL_APIENTRY IsQuery(GLuint id)
+{
+ EVENT("(GLuint id = %u)", id);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return GL_FALSE;
+ }
+
+ return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
+ }
+
+ return GL_FALSE;
+}
+
+void GL_APIENTRY BeginQuery(GLenum target, GLuint id)
+{
+ EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidateBeginQuery(context, target, id))
+ {
+ return;
+ }
+
+ Error error = context->beginQuery(target, id);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY EndQuery(GLenum target)
+{
+ EVENT("(GLenum target = 0x%X)", target);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidateEndQuery(context, target))
+ {
+ return;
+ }
+
+ Error error = context->endQuery(target);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY GetQueryiv(GLenum target, GLenum pname, GLint* params)
+{
+ EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidQueryType(context, target))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (pname)
+ {
+ case GL_CURRENT_QUERY:
+ params[0] = static_cast<GLint>(context->getState().getActiveQueryId(target));
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
+{
+ EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ Query *queryObject = context->getQuery(id, false, GL_NONE);
+
+ if (!queryObject)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (context->getState().getActiveQueryId(queryObject->getType()) == id)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ switch(pname)
+ {
+ case GL_QUERY_RESULT_EXT:
+ {
+ Error error = queryObject->getResult(params);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+ break;
+
+ case GL_QUERY_RESULT_AVAILABLE_EXT:
+ {
+ Error error = queryObject->isResultAvailable(params);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+GLboolean GL_APIENTRY UnmapBuffer(GLenum target)
+{
+ EVENT("(GLenum target = 0x%X)", target);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return GL_FALSE;
+ }
+
+ return UnmapBufferOES(target);
+ }
+
+ return GL_FALSE;
+}
+
+void GL_APIENTRY GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
+{
+ EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ GetBufferPointervOES(target, pname, params);
+ }
+}
+
+void GL_APIENTRY DrawBuffers(GLsizei n, const GLenum* bufs)
+{
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ DrawBuffersEXT(n, bufs);
+ }
+}
+
+void GL_APIENTRY UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
+ location, count, transpose, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniformMatrix2x3fv(location, count, transpose, value);
+ }
+}
+
+void GL_APIENTRY UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
+ location, count, transpose, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniformMatrix3x2fv(location, count, transpose, value);
+ }
+}
+
+void GL_APIENTRY UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
+ location, count, transpose, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniformMatrix2x4fv(location, count, transpose, value);
+ }
+}
+
+void GL_APIENTRY UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
+ location, count, transpose, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniformMatrix4x2fv(location, count, transpose, value);
+ }
+}
+
+void GL_APIENTRY UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
+ location, count, transpose, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniformMatrix3x4fv(location, count, transpose, value);
+ }
+}
+
+void GL_APIENTRY UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
+ location, count, transpose, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniformMatrix4x3fv(location, count, transpose, value);
+ }
+}
+
+void GL_APIENTRY BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
+{
+ EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
+ "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
+ srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1, mask, filter,
+ false))
+ {
+ return;
+ }
+
+ Framebuffer *readFramebuffer = context->getState().getReadFramebuffer();
+ ASSERT(readFramebuffer);
+
+ Framebuffer *drawFramebuffer = context->getState().getDrawFramebuffer();
+ ASSERT(drawFramebuffer);
+
+ Rectangle srcArea(srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0);
+ Rectangle dstArea(dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0);
+
+ Error error = drawFramebuffer->blit(context->getState(), srcArea, dstArea, mask, filter, readFramebuffer);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
+{
+ EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
+ target, samples, internalformat, width, height);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidateES3RenderbufferStorageParameters(context, target, samples, internalformat, width, height))
+ {
+ return;
+ }
+
+ Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
+ renderbuffer->setStorageMultisample(samples, internalformat, width, height);
+ }
+}
+
+void GL_APIENTRY FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
+{
+ EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
+ target, attachment, texture, level, layer);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateFramebufferTextureLayer(context, target, attachment, texture,
+ level, layer))
+ {
+ return;
+ }
+
+ Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
+ ASSERT(framebuffer);
+
+ if (texture != 0)
+ {
+ Texture *textureObject = context->getTexture(texture);
+
+ ImageIndex index = ImageIndex::MakeInvalid();
+
+ if (textureObject->getTarget() == GL_TEXTURE_3D)
+ {
+ index = ImageIndex::Make3D(level, layer);
+ }
+ else
+ {
+ ASSERT(textureObject->getTarget() == GL_TEXTURE_2D_ARRAY);
+ index = ImageIndex::Make2DArray(level, layer);
+ }
+
+ framebuffer->setTextureAttachment(attachment, textureObject, index);
+ }
+ else
+ {
+ framebuffer->setNULLAttachment(attachment);
+ }
+ }
+}
+
+GLvoid *GL_APIENTRY MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
+{
+ EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
+ target, offset, length, access);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return NULL;
+ }
+
+ return MapBufferRangeEXT(target, offset, length, access);
+ }
+
+ return NULL;
+}
+
+void GL_APIENTRY FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
+{
+ EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ FlushMappedBufferRangeEXT(target, offset, length);
+ }
+}
+
+void GL_APIENTRY BindVertexArray(GLuint array)
+{
+ EVENT("(GLuint array = %u)", array);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ VertexArray *vao = context->getVertexArray(array);
+
+ if (!vao)
+ {
+ // The default VAO should always exist
+ ASSERT(array != 0);
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ context->bindVertexArray(array);
+ }
+}
+
+void GL_APIENTRY DeleteVertexArrays(GLsizei n, const GLuint* arrays)
+{
+ EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
+ {
+ if (arrays[arrayIndex] != 0)
+ {
+ context->deleteVertexArray(arrays[arrayIndex]);
+ }
+ }
+ }
+}
+
+void GL_APIENTRY GenVertexArrays(GLsizei n, GLuint* arrays)
+{
+ EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
+ {
+ arrays[arrayIndex] = context->createVertexArray();
+ }
+ }
+}
+
+GLboolean GL_APIENTRY IsVertexArray(GLuint array)
+{
+ EVENT("(GLuint array = %u)", array);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return GL_FALSE;
+ }
+
+ if (array == 0)
+ {
+ return GL_FALSE;
+ }
+
+ VertexArray *vao = context->getVertexArray(array);
+
+ return (vao != NULL ? GL_TRUE : GL_FALSE);
+ }
+
+ return GL_FALSE;
+}
+
+void GL_APIENTRY GetIntegeri_v(GLenum target, GLuint index, GLint* data)
+{
+ EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
+ target, index, data);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ const Caps &caps = context->getCaps();
+ switch (target)
+ {
+ case GL_TRANSFORM_FEEDBACK_BUFFER_START:
+ case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
+ case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
+ if (index >= caps.maxTransformFeedbackSeparateAttributes)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ break;
+
+ case GL_UNIFORM_BUFFER_START:
+ case GL_UNIFORM_BUFFER_SIZE:
+ case GL_UNIFORM_BUFFER_BINDING:
+ if (index >= caps.maxCombinedUniformBlocks)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (!(context->getIndexedIntegerv(target, index, data)))
+ {
+ GLenum nativeType;
+ unsigned int numParams = 0;
+ if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (numParams == 0)
+ {
+ return; // it is known that pname is valid, but there are no parameters to return
+ }
+
+ if (nativeType == GL_INT_64_ANGLEX)
+ {
+ GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min());
+ GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max());
+ GLint64 *int64Params = new GLint64[numParams];
+
+ context->getIndexedInteger64v(target, index, int64Params);
+
+ for (unsigned int i = 0; i < numParams; ++i)
+ {
+ GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue);
+ data[i] = static_cast<GLint>(clampedValue);
+ }
+
+ delete [] int64Params;
+ }
+ else
+ {
+ UNREACHABLE();
+ }
+ }
+ }
+}
+
+void GL_APIENTRY BeginTransformFeedback(GLenum primitiveMode)
+{
+ EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ switch (primitiveMode)
+ {
+ case GL_TRIANGLES:
+ case GL_LINES:
+ case GL_POINTS:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
+ ASSERT(transformFeedback != NULL);
+
+ if (transformFeedback->isStarted())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (transformFeedback->isPaused())
+ {
+ transformFeedback->resume();
+ }
+ else
+ {
+ transformFeedback->start(primitiveMode);
+ }
+ }
+}
+
+void GL_APIENTRY EndTransformFeedback(void)
+{
+ EVENT("(void)");
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
+ ASSERT(transformFeedback != NULL);
+
+ if (!transformFeedback->isStarted())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ transformFeedback->stop();
+ }
+}
+
+void GL_APIENTRY BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
+{
+ EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
+ target, index, buffer, offset, size);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ const Caps &caps = context->getCaps();
+ switch (target)
+ {
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
+ if (index >= caps.maxTransformFeedbackSeparateAttributes)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ break;
+
+ case GL_UNIFORM_BUFFER:
+ if (index >= caps.maxUniformBufferBindings)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (buffer != 0 && size <= 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ switch (target)
+ {
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
+ {
+ // size and offset must be a multiple of 4
+ if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ // Cannot bind a transform feedback buffer if the current transform feedback is active (3.0.4 pg 91 section 2.15.2)
+ TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
+ if (curTransformFeedback && curTransformFeedback->isStarted())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
+ context->bindGenericTransformFeedbackBuffer(buffer);
+ break;
+ }
+
+ case GL_UNIFORM_BUFFER:
+
+ // it is an error to bind an offset not a multiple of the alignment
+ if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ context->bindIndexedUniformBuffer(buffer, index, offset, size);
+ context->bindGenericUniformBuffer(buffer);
+ break;
+
+ default:
+ UNREACHABLE();
+ }
+ }
+}
+
+void GL_APIENTRY BindBufferBase(GLenum target, GLuint index, GLuint buffer)
+{
+ EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
+ target, index, buffer);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ const Caps &caps = context->getCaps();
+ switch (target)
+ {
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
+ if (index >= caps.maxTransformFeedbackSeparateAttributes)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ break;
+
+ case GL_UNIFORM_BUFFER:
+ if (index >= caps.maxUniformBufferBindings)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ switch (target)
+ {
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
+ {
+ // Cannot bind a transform feedback buffer if the current transform feedback is active (3.0.4 pg 91 section 2.15.2)
+ TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
+ if (curTransformFeedback && curTransformFeedback->isStarted())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
+ context->bindGenericTransformFeedbackBuffer(buffer);
+ break;
+ }
+ case GL_UNIFORM_BUFFER:
+ context->bindIndexedUniformBuffer(buffer, index, 0, 0);
+ context->bindGenericUniformBuffer(buffer);
+ break;
+
+ default:
+ UNREACHABLE();
+ }
+ }
+}
+
+void GL_APIENTRY TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
+{
+ EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
+ program, count, varyings, bufferMode);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (count < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ const Caps &caps = context->getCaps();
+ switch (bufferMode)
+ {
+ case GL_INTERLEAVED_ATTRIBS:
+ break;
+ case GL_SEPARATE_ATTRIBS:
+ if (static_cast<GLuint>(count) > caps.maxTransformFeedbackSeparateAttributes)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ break;
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (!ValidProgram(context, program))
+ {
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+ ASSERT(programObject);
+
+ programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
+ }
+}
+
+void GL_APIENTRY GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
+{
+ EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
+ "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
+ program, index, bufSize, length, size, type, name);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (bufSize < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if (!ValidProgram(context, program))
+ {
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+ ASSERT(programObject);
+
+ if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
+ }
+}
+
+void GL_APIENTRY VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
+{
+ EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
+ index, size, type, stride, pointer);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if (size < 1 || size > 4)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ switch (type)
+ {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_INT_2_10_10_10_REV:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (stride < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ // [OpenGL ES 3.0.2] Section 2.8 page 24:
+ // An INVALID_OPERATION error is generated when a non-zero vertex array object
+ // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
+ // and the pointer argument is not NULL.
+ if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true,
+ stride, pointer);
+ }
+}
+
+void GL_APIENTRY GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
+{
+ EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
+ index, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if (!ValidateGetVertexAttribParameters(context, pname))
+ {
+ return;
+ }
+
+ if (pname == GL_CURRENT_VERTEX_ATTRIB)
+ {
+ const VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
+ for (int i = 0; i < 4; ++i)
+ {
+ params[i] = currentValueData.IntValues[i];
+ }
+ }
+ else
+ {
+ const VertexAttribute &attribState = context->getState().getVertexArray()->getVertexAttribute(index);
+ *params = QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
+ }
+ }
+}
+
+void GL_APIENTRY GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
+{
+ EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
+ index, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if (!ValidateGetVertexAttribParameters(context, pname))
+ {
+ return;
+ }
+
+ if (pname == GL_CURRENT_VERTEX_ATTRIB)
+ {
+ const VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
+ for (int i = 0; i < 4; ++i)
+ {
+ params[i] = currentValueData.UnsignedIntValues[i];
+ }
+ }
+ else
+ {
+ const VertexAttribute &attribState = context->getState().getVertexArray()->getVertexAttribute(index);
+ *params = QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
+ }
+ }
+}
+
+void GL_APIENTRY VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
+{
+ EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
+ index, x, y, z, w);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ GLint vals[4] = { x, y, z, w };
+ context->getState().setVertexAttribi(index, vals);
+ }
+}
+
+void GL_APIENTRY VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
+{
+ EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
+ index, x, y, z, w);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ GLuint vals[4] = { x, y, z, w };
+ context->getState().setVertexAttribu(index, vals);
+ }
+}
+
+void GL_APIENTRY VertexAttribI4iv(GLuint index, const GLint* v)
+{
+ EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ context->getState().setVertexAttribi(index, v);
+ }
+}
+
+void GL_APIENTRY VertexAttribI4uiv(GLuint index, const GLuint* v)
+{
+ EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ context->getState().setVertexAttribu(index, v);
+ }
+}
+
+void GL_APIENTRY GetUniformuiv(GLuint program, GLint location, GLuint* params)
+{
+ EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
+ program, location, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateGetUniformuiv(context, program, location, params))
+ {
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+ ASSERT(programObject);
+
+ programObject->getUniformuiv(location, params);
+ }
+}
+
+GLint GL_APIENTRY GetFragDataLocation(GLuint program, const GLchar *name)
+{
+ EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
+ program, name);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return -1;
+ }
+
+ if (program == 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return -1;
+ }
+
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject || !programObject->isLinked())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return -1;
+ }
+
+ return programObject->getFragDataLocation(name);
+ }
+
+ return 0;
+}
+
+void GL_APIENTRY Uniform1ui(GLint location, GLuint v0)
+{
+ Uniform1uiv(location, 1, &v0);
+}
+
+void GL_APIENTRY Uniform2ui(GLint location, GLuint v0, GLuint v1)
+{
+ const GLuint xy[] = { v0, v1 };
+ Uniform2uiv(location, 1, xy);
+}
+
+void GL_APIENTRY Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
+{
+ const GLuint xyz[] = { v0, v1, v2 };
+ Uniform3uiv(location, 1, xyz);
+}
+
+void GL_APIENTRY Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
+{
+ const GLuint xyzw[] = { v0, v1, v2, v3 };
+ Uniform4uiv(location, 1, xyzw);
+}
+
+void GL_APIENTRY Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
+ location, count, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniform1uiv(location, count, value);
+ }
+}
+
+void GL_APIENTRY Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
+ location, count, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniform2uiv(location, count, value);
+ }
+}
+
+void GL_APIENTRY Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
+ location, count, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniform3uiv(location, count, value);
+ }
+}
+
+void GL_APIENTRY Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
+{
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
+ location, count, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC4, location, count))
+ {
+ return;
+ }
+
+ Program *program = context->getState().getProgram();
+ program->setUniform4uiv(location, count, value);
+ }
+}
+
+void GL_APIENTRY ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
+{
+ EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
+ buffer, drawbuffer, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateClearBuffer(context))
+ {
+ return;
+ }
+
+ switch (buffer)
+ {
+ case GL_COLOR:
+ if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ break;
+
+ case GL_STENCIL:
+ if (drawbuffer != 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
+ ASSERT(framebufferObject);
+
+ Error error = framebufferObject->clearBufferiv(context->getState(), buffer, drawbuffer, value);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
+{
+ EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
+ buffer, drawbuffer, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateClearBuffer(context))
+ {
+ return;
+ }
+
+ switch (buffer)
+ {
+ case GL_COLOR:
+ if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
+ ASSERT(framebufferObject);
+
+ Error error = framebufferObject->clearBufferuiv(context->getState(), buffer, drawbuffer, value);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
+{
+ EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
+ buffer, drawbuffer, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateClearBuffer(context))
+ {
+ return;
+ }
+
+ switch (buffer)
+ {
+ case GL_COLOR:
+ if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ break;
+
+ case GL_DEPTH:
+ if (drawbuffer != 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
+ ASSERT(framebufferObject);
+
+ Error error = framebufferObject->clearBufferfv(context->getState(), buffer, drawbuffer, value);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
+{
+ EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
+ buffer, drawbuffer, depth, stencil);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (!ValidateClearBuffer(context))
+ {
+ return;
+ }
+
+ switch (buffer)
+ {
+ case GL_DEPTH_STENCIL:
+ if (drawbuffer != 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
+ ASSERT(framebufferObject);
+
+ Error error = framebufferObject->clearBufferfi(context->getState(), buffer, drawbuffer, depth, stencil);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+const GLubyte *GL_APIENTRY GetStringi(GLenum name, GLuint index)
+{
+ EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return NULL;
+ }
+
+ if (name != GL_EXTENSIONS)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return NULL;
+ }
+
+ if (index >= context->getExtensionStringCount())
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return NULL;
+ }
+
+ return reinterpret_cast<const GLubyte*>(context->getExtensionString(index).c_str());
+ }
+
+ return NULL;
+}
+
+void GL_APIENTRY CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
+{
+ EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
+ readTarget, writeTarget, readOffset, writeOffset, size);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidBufferTarget(context, readTarget) || !ValidBufferTarget(context, writeTarget))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ Buffer *readBuffer = context->getState().getTargetBuffer(readTarget);
+ Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget);
+
+ if (!readBuffer || !writeBuffer)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ // Verify that readBuffer and writeBuffer are not currently mapped
+ if (readBuffer->isMapped() || writeBuffer->isMapped())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (readOffset < 0 || writeOffset < 0 || size < 0 ||
+ static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() ||
+ static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize())
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if (readBuffer == writeBuffer && std::abs(readOffset - writeOffset) < size)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ // if size is zero, the copy is a successful no-op
+ if (size > 0)
+ {
+ Error error = writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+ }
+}
+
+void GL_APIENTRY GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
+{
+ EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
+ program, uniformCount, uniformNames, uniformIndices);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (uniformCount < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject)
+ {
+ if (context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ if (!programObject->isLinked())
+ {
+ for (int uniformId = 0; uniformId < uniformCount; uniformId++)
+ {
+ uniformIndices[uniformId] = GL_INVALID_INDEX;
+ }
+ }
+ else
+ {
+ for (int uniformId = 0; uniformId < uniformCount; uniformId++)
+ {
+ uniformIndices[uniformId] = programObject->getUniformIndex(uniformNames[uniformId]);
+ }
+ }
+ }
+}
+
+void GL_APIENTRY GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
+{
+ EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
+ program, uniformCount, uniformIndices, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (uniformCount < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject)
+ {
+ if (context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ switch (pname)
+ {
+ case GL_UNIFORM_TYPE:
+ case GL_UNIFORM_SIZE:
+ case GL_UNIFORM_NAME_LENGTH:
+ case GL_UNIFORM_BLOCK_INDEX:
+ case GL_UNIFORM_OFFSET:
+ case GL_UNIFORM_ARRAY_STRIDE:
+ case GL_UNIFORM_MATRIX_STRIDE:
+ case GL_UNIFORM_IS_ROW_MAJOR:
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (uniformCount > programObject->getActiveUniformCount())
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (int uniformId = 0; uniformId < uniformCount; uniformId++)
+ {
+ const GLuint index = uniformIndices[uniformId];
+
+ if (index >= static_cast<GLuint>(programObject->getActiveUniformCount()))
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ for (int uniformId = 0; uniformId < uniformCount; uniformId++)
+ {
+ const GLuint index = uniformIndices[uniformId];
+ params[uniformId] = programObject->getActiveUniformi(index, pname);
+ }
+ }
+}
+
+GLuint GL_APIENTRY GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
+{
+ EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return GL_INVALID_INDEX;
+ }
+
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject)
+ {
+ if (context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return GL_INVALID_INDEX;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return GL_INVALID_INDEX;
+ }
+ }
+
+ return programObject->getUniformBlockIndex(uniformBlockName);
+ }
+
+ return 0;
+}
+
+void GL_APIENTRY GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
+{
+ EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
+ program, uniformBlockIndex, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject)
+ {
+ if (context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ if (uniformBlockIndex >= programObject->getActiveUniformBlockCount())
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ switch (pname)
+ {
+ case GL_UNIFORM_BLOCK_BINDING:
+ *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
+ break;
+
+ case GL_UNIFORM_BLOCK_DATA_SIZE:
+ case GL_UNIFORM_BLOCK_NAME_LENGTH:
+ case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
+ case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
+ case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
+ case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
+ programObject->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
+{
+ EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
+ program, uniformBlockIndex, bufSize, length, uniformBlockName);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject)
+ {
+ if (context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ if (uniformBlockIndex >= programObject->getActiveUniformBlockCount())
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ programObject->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
+ }
+}
+
+void GL_APIENTRY UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
+{
+ EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
+ program, uniformBlockIndex, uniformBlockBinding);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (uniformBlockBinding >= context->getCaps().maxUniformBufferBindings)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ Program *programObject = context->getProgram(program);
+
+ if (!programObject)
+ {
+ if (context->getShader(program))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+ else
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ }
+
+ // if never linked, there won't be any uniform blocks
+ if (uniformBlockIndex >= programObject->getActiveUniformBlockCount())
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
+ }
+}
+
+void GL_APIENTRY DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
+{
+ EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
+ mode, first, count, instanceCount);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidateDrawArraysInstanced(context, mode, first, count, instanceCount))
+ {
+ return;
+ }
+
+ Error error = context->drawArrays(mode, first, count, instanceCount);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
+{
+ EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
+ mode, count, type, indices, instanceCount);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ rx::RangeUI indexRange;
+ if (!ValidateDrawElementsInstanced(context, mode, count, type, indices, instanceCount, &indexRange))
+ {
+ return;
+ }
+
+ Error error = context->drawElements(mode, count, type, indices, instanceCount, indexRange);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+GLsync GL_APIENTRY FenceSync_(GLenum condition, GLbitfield flags)
+{
+ EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return 0;
+ }
+
+ if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return 0;
+ }
+
+ if (flags != 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return 0;
+ }
+
+ GLsync fenceSync = context->createFenceSync();
+
+ FenceSync *fenceSyncObject = context->getFenceSync(fenceSync);
+ Error error = fenceSyncObject->set(condition);
+ if (error.isError())
+ {
+ context->deleteFenceSync(fenceSync);
+ context->recordError(error);
+ return NULL;
+ }
+
+ return fenceSync;
+ }
+
+ return NULL;
+}
+
+GLboolean GL_APIENTRY IsSync(GLsync sync)
+{
+ EVENT("(GLsync sync = 0x%0.8p)", sync);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return GL_FALSE;
+ }
+
+ return (context->getFenceSync(sync) != NULL);
+ }
+
+ return GL_FALSE;
+}
+
+void GL_APIENTRY DeleteSync(GLsync sync)
+{
+ EVENT("(GLsync sync = 0x%0.8p)", sync);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync))
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ context->deleteFenceSync(sync);
+ }
+}
+
+GLenum GL_APIENTRY ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
+{
+ EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
+ sync, flags, timeout);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return GL_WAIT_FAILED;
+ }
+
+ if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return GL_WAIT_FAILED;
+ }
+
+ FenceSync *fenceSync = context->getFenceSync(sync);
+
+ if (!fenceSync)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return GL_WAIT_FAILED;
+ }
+
+ GLenum result = GL_WAIT_FAILED;
+ Error error = fenceSync->clientWait(flags, timeout, &result);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return GL_WAIT_FAILED;
+ }
+
+ return result;
+ }
+
+ return GL_FALSE;
+}
+
+void GL_APIENTRY WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
+{
+ EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
+ sync, flags, timeout);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (flags != 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ if (timeout != GL_TIMEOUT_IGNORED)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ FenceSync *fenceSync = context->getFenceSync(sync);
+
+ if (!fenceSync)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ Error error = fenceSync->serverWait(flags, timeout);
+ if (error.isError())
+ {
+ context->recordError(error);
+ }
+ }
+}
+
+void GL_APIENTRY GetInteger64v(GLenum pname, GLint64* params)
+{
+ EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
+ pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ GLenum nativeType;
+ unsigned int numParams = 0;
+ if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
+ {
+ return;
+ }
+
+ if (nativeType == GL_INT_64_ANGLEX)
+ {
+ context->getInteger64v(pname, params);
+ }
+ else
+ {
+ CastStateValues(context, nativeType, pname, numParams, params);
+ }
+ }
+}
+
+void GL_APIENTRY GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
+{
+ EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
+ sync, pname, bufSize, length, values);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (bufSize < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ FenceSync *fenceSync = context->getFenceSync(sync);
+
+ if (!fenceSync)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ switch (pname)
+ {
+ case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break;
+ case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break;
+ case GL_SYNC_FLAGS: values[0] = 0; break;
+
+ case GL_SYNC_STATUS:
+ {
+ Error error = fenceSync->getStatus(values);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ break;
+ }
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
+{
+ EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
+ target, index, data);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ const Caps &caps = context->getCaps();
+ switch (target)
+ {
+ case GL_TRANSFORM_FEEDBACK_BUFFER_START:
+ case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
+ case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
+ if (index >= caps.maxTransformFeedbackSeparateAttributes)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ break;
+
+ case GL_UNIFORM_BUFFER_START:
+ case GL_UNIFORM_BUFFER_SIZE:
+ case GL_UNIFORM_BUFFER_BINDING:
+ if (index >= caps.maxUniformBufferBindings)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (!(context->getIndexedInteger64v(target, index, data)))
+ {
+ GLenum nativeType;
+ unsigned int numParams = 0;
+ if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (numParams == 0)
+ return; // it is known that pname is valid, but there are no parameters to return
+
+ if (nativeType == GL_INT)
+ {
+ GLint *intParams = new GLint[numParams];
+
+ context->getIndexedIntegerv(target, index, intParams);
+
+ for (unsigned int i = 0; i < numParams; ++i)
+ {
+ data[i] = static_cast<GLint64>(intParams[i]);
+ }
+
+ delete [] intParams;
+ }
+ else
+ {
+ UNREACHABLE();
+ }
+ }
+ }
+}
+
+void GL_APIENTRY GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
+{
+ EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
+ target, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidBufferTarget(context, target))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (!ValidBufferParameter(context, pname))
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ Buffer *buffer = context->getState().getTargetBuffer(target);
+
+ if (!buffer)
+ {
+ // A null buffer means that "0" is bound to the requested buffer target
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ switch (pname)
+ {
+ case GL_BUFFER_USAGE:
+ *params = static_cast<GLint64>(buffer->getUsage());
+ break;
+ case GL_BUFFER_SIZE:
+ *params = buffer->getSize();
+ break;
+ case GL_BUFFER_ACCESS_FLAGS:
+ *params = static_cast<GLint64>(buffer->getAccessFlags());
+ break;
+ case GL_BUFFER_MAPPED:
+ *params = static_cast<GLint64>(buffer->isMapped());
+ break;
+ case GL_BUFFER_MAP_OFFSET:
+ *params = buffer->getMapOffset();
+ break;
+ case GL_BUFFER_MAP_LENGTH:
+ *params = buffer->getMapLength();
+ break;
+ default: UNREACHABLE(); break;
+ }
+ }
+}
+
+void GL_APIENTRY GenSamplers(GLsizei count, GLuint* samplers)
+{
+ EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (count < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (int i = 0; i < count; i++)
+ {
+ samplers[i] = context->createSampler();
+ }
+ }
+}
+
+void GL_APIENTRY DeleteSamplers(GLsizei count, const GLuint* samplers)
+{
+ EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (count < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ for (int i = 0; i < count; i++)
+ {
+ context->deleteSampler(samplers[i]);
+ }
+ }
+}
+
+GLboolean GL_APIENTRY IsSampler(GLuint sampler)
+{
+ EVENT("(GLuint sampler = %u)", sampler);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return GL_FALSE;
+ }
+
+ return context->isSampler(sampler);
+ }
+
+ return GL_FALSE;
+}
+
+void GL_APIENTRY BindSampler(GLuint unit, GLuint sampler)
+{
+ EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (sampler != 0 && !context->isSampler(sampler))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (unit >= context->getCaps().maxCombinedTextureImageUnits)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ context->bindSampler(unit, sampler);
+ }
+}
+
+void GL_APIENTRY SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
+{
+ EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidateSamplerObjectParameter(context, pname))
+ {
+ return;
+ }
+
+ if (!ValidateTexParamParameters(context, pname, param))
+ {
+ return;
+ }
+
+ if (!context->isSampler(sampler))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ context->samplerParameteri(sampler, pname, param);
+ }
+}
+
+void GL_APIENTRY SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
+{
+ SamplerParameteri(sampler, pname, *param);
+}
+
+void GL_APIENTRY SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
+{
+ EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidateSamplerObjectParameter(context, pname))
+ {
+ return;
+ }
+
+ if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
+ {
+ return;
+ }
+
+ if (!context->isSampler(sampler))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ context->samplerParameterf(sampler, pname, param);
+ }
+}
+
+void GL_APIENTRY SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
+{
+ SamplerParameterf(sampler, pname, *param);
+}
+
+void GL_APIENTRY GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
+{
+ EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidateSamplerObjectParameter(context, pname))
+ {
+ return;
+ }
+
+ if (!context->isSampler(sampler))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ *params = context->getSamplerParameteri(sampler, pname);
+ }
+}
+
+void GL_APIENTRY GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
+{
+ EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidateSamplerObjectParameter(context, pname))
+ {
+ return;
+ }
+
+ if (!context->isSampler(sampler))
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ *params = context->getSamplerParameterf(sampler, pname);
+ }
+}
+
+void GL_APIENTRY VertexAttribDivisor(GLuint index, GLuint divisor)
+{
+ EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ context->setVertexAttribDivisor(index, divisor);
+ }
+}
+
+void GL_APIENTRY BindTransformFeedback(GLenum target, GLuint id)
+{
+ EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ switch (target)
+ {
+ case GL_TRANSFORM_FEEDBACK:
+ {
+ // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
+ TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
+ if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1)
+ if (context->getTransformFeedback(id) == NULL)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ context->bindTransformFeedback(id);
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
+{
+ EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ context->deleteTransformFeedback(ids[i]);
+ }
+ }
+}
+
+void GL_APIENTRY GenTransformFeedbacks(GLsizei n, GLuint* ids)
+{
+ EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ ids[i] = context->createTransformFeedback();
+ }
+ }
+}
+
+GLboolean GL_APIENTRY IsTransformFeedback(GLuint id)
+{
+ EVENT("(GLuint id = %u)", id);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return GL_FALSE;
+ }
+
+ return ((context->getTransformFeedback(id) != NULL) ? GL_TRUE : GL_FALSE);
+ }
+
+ return GL_FALSE;
+}
+
+void GL_APIENTRY PauseTransformFeedback(void)
+{
+ EVENT("(void)");
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
+ ASSERT(transformFeedback != NULL);
+
+ // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86)
+ if (!transformFeedback->isStarted() || transformFeedback->isPaused())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ transformFeedback->pause();
+ }
+}
+
+void GL_APIENTRY ResumeTransformFeedback(void)
+{
+ EVENT("(void)");
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
+ ASSERT(transformFeedback != NULL);
+
+ // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86)
+ if (!transformFeedback->isStarted() || !transformFeedback->isPaused())
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ transformFeedback->resume();
+ }
+}
+
+void GL_APIENTRY GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
+{
+ EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
+ program, bufSize, length, binaryFormat, binary);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ // TODO: Pipe through to the OES extension for now, needs proper validation
+ return GetProgramBinaryOES(program, bufSize, length, binaryFormat, binary);
+ }
+}
+
+void GL_APIENTRY ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
+{
+ EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
+ program, binaryFormat, binary, length);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ // TODO: Pipe through to the OES extension for now, needs proper validation
+ return ProgramBinaryOES(program, binaryFormat, binary, length);
+ }
+}
+
+void GL_APIENTRY ProgramParameteri(GLuint program, GLenum pname, GLint value)
+{
+ EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
+ program, pname, value);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ // glProgramParameteri
+ UNIMPLEMENTED();
+ }
+}
+
+void GL_APIENTRY InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
+{
+ EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
+ target, numAttachments, attachments);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
+ {
+ return;
+ }
+
+ Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
+ ASSERT(framebuffer);
+
+ if (framebuffer->checkStatus(context->getData()) == GL_FRAMEBUFFER_COMPLETE)
+ {
+ Error error = framebuffer->invalidate(numAttachments, attachments);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+ }
+}
+
+void GL_APIENTRY InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
+ "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
+ target, numAttachments, attachments, x, y, width, height);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
+ {
+ return;
+ }
+
+ Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
+ ASSERT(framebuffer);
+
+ if (framebuffer->checkStatus(context->getData()) == GL_FRAMEBUFFER_COMPLETE)
+ {
+ Rectangle area(x, y, width, height);
+ Error error = framebuffer->invalidateSub(numAttachments, attachments, area);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+ }
+}
+
+void GL_APIENTRY TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
+{
+ EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
+ target, levels, internalformat, width, height);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
+ {
+ return;
+ }
+
+ Extents size(width, height, 1);
+ Texture *texture = context->getTargetTexture(target);
+ Error error = texture->setStorage(target, levels, internalformat, size);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
+{
+ EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
+ "GLsizei height = %d, GLsizei depth = %d)",
+ target, levels, internalformat, width, height, depth);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
+ {
+ return;
+ }
+
+ Extents size(width, height, depth);
+ Texture *texture = context->getTargetTexture(target);
+ Error error = texture->setStorage(target, levels, internalformat, size);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
+ }
+}
+
+void GL_APIENTRY GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
+{
+ EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
+ "GLint* params = 0x%0.8p)",
+ target, internalformat, pname, bufSize, params);
+
+ Context *context = GetValidGlobalContext();
+ if (context)
+ {
+ if (context->getClientVersion() < 3)
+ {
+ context->recordError(Error(GL_INVALID_OPERATION));
+ return;
+ }
+
+ const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
+ if (!formatCaps.renderable)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (target != GL_RENDERBUFFER)
+ {
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+
+ if (bufSize < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE));
+ return;
+ }
+
+ switch (pname)
+ {
+ case GL_NUM_SAMPLE_COUNTS:
+ if (bufSize != 0)
+ {
+ *params = formatCaps.sampleCounts.size();
+ }
+ break;
+
+ case GL_SAMPLES:
+ {
+ size_t returnCount = std::min<size_t>(bufSize, formatCaps.sampleCounts.size());
+ auto sampleReverseIt = formatCaps.sampleCounts.rbegin();
+ for (size_t sampleIndex = 0; sampleIndex < returnCount; ++sampleIndex)
+ {
+ params[sampleIndex] = *sampleReverseIt++;;
+ }
+ }
+ break;
+
+ default:
+ context->recordError(Error(GL_INVALID_ENUM));
+ return;
+ }
+ }
+}
+
+}
diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_gles_3_0.h b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_3_0.h
new file mode 100644
index 0000000000..09ca0e4641
--- /dev/null
+++ b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_3_0.h
@@ -0,0 +1,125 @@
+//
+// Copyright(c) 2014 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.
+//
+
+// entry_points_gles_3_0.h : Defines the GLES 3.0 entry points.
+
+#ifndef LIBGLESV2_ENTRYPOINTGLES30_H_
+#define LIBGLESV2_ENTRYPOINTGLES30_H_
+
+#include <GLES3/gl3.h>
+#include <export.h>
+
+namespace gl
+{
+
+ANGLE_EXPORT void GL_APIENTRY ReadBuffer(GLenum mode);
+ANGLE_EXPORT void GL_APIENTRY DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices);
+ANGLE_EXPORT void GL_APIENTRY TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+ANGLE_EXPORT void GL_APIENTRY TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
+ANGLE_EXPORT void GL_APIENTRY CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+ANGLE_EXPORT void GL_APIENTRY CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
+ANGLE_EXPORT void GL_APIENTRY CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
+ANGLE_EXPORT void GL_APIENTRY GenQueries(GLsizei n, GLuint* ids);
+ANGLE_EXPORT void GL_APIENTRY DeleteQueries(GLsizei n, const GLuint* ids);
+ANGLE_EXPORT GLboolean GL_APIENTRY IsQuery(GLuint id);
+ANGLE_EXPORT void GL_APIENTRY BeginQuery(GLenum target, GLuint id);
+ANGLE_EXPORT void GL_APIENTRY EndQuery(GLenum target);
+ANGLE_EXPORT void GL_APIENTRY GetQueryiv(GLenum target, GLenum pname, GLint* params);
+ANGLE_EXPORT void GL_APIENTRY GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params);
+ANGLE_EXPORT GLboolean GL_APIENTRY UnmapBuffer(GLenum target);
+ANGLE_EXPORT void GL_APIENTRY GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params);
+ANGLE_EXPORT void GL_APIENTRY DrawBuffers(GLsizei n, const GLenum* bufs);
+ANGLE_EXPORT void GL_APIENTRY UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ANGLE_EXPORT void GL_APIENTRY UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ANGLE_EXPORT void GL_APIENTRY UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ANGLE_EXPORT void GL_APIENTRY UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ANGLE_EXPORT void GL_APIENTRY UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ANGLE_EXPORT void GL_APIENTRY UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ANGLE_EXPORT void GL_APIENTRY BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+ANGLE_EXPORT void GL_APIENTRY RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+ANGLE_EXPORT void GL_APIENTRY FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+ANGLE_EXPORT GLvoid* GL_APIENTRY MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+ANGLE_EXPORT void GL_APIENTRY FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length);
+ANGLE_EXPORT void GL_APIENTRY BindVertexArray(GLuint array);
+ANGLE_EXPORT void GL_APIENTRY DeleteVertexArrays(GLsizei n, const GLuint* arrays);
+ANGLE_EXPORT void GL_APIENTRY GenVertexArrays(GLsizei n, GLuint* arrays);
+ANGLE_EXPORT GLboolean GL_APIENTRY IsVertexArray(GLuint array);
+ANGLE_EXPORT void GL_APIENTRY GetIntegeri_v(GLenum target, GLuint index, GLint* data);
+ANGLE_EXPORT void GL_APIENTRY BeginTransformFeedback(GLenum primitiveMode);
+ANGLE_EXPORT void GL_APIENTRY EndTransformFeedback(void);
+ANGLE_EXPORT void GL_APIENTRY BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+ANGLE_EXPORT void GL_APIENTRY BindBufferBase(GLenum target, GLuint index, GLuint buffer);
+ANGLE_EXPORT void GL_APIENTRY TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode);
+ANGLE_EXPORT void GL_APIENTRY GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name);
+ANGLE_EXPORT void GL_APIENTRY VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+ANGLE_EXPORT void GL_APIENTRY GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params);
+ANGLE_EXPORT void GL_APIENTRY GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params);
+ANGLE_EXPORT void GL_APIENTRY VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w);
+ANGLE_EXPORT void GL_APIENTRY VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+ANGLE_EXPORT void GL_APIENTRY VertexAttribI4iv(GLuint index, const GLint* v);
+ANGLE_EXPORT void GL_APIENTRY VertexAttribI4uiv(GLuint index, const GLuint* v);
+ANGLE_EXPORT void GL_APIENTRY GetUniformuiv(GLuint program, GLint location, GLuint* params);
+ANGLE_EXPORT GLint GL_APIENTRY GetFragDataLocation(GLuint program, const GLchar *name);
+ANGLE_EXPORT void GL_APIENTRY Uniform1ui(GLint location, GLuint v0);
+ANGLE_EXPORT void GL_APIENTRY Uniform2ui(GLint location, GLuint v0, GLuint v1);
+ANGLE_EXPORT void GL_APIENTRY Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2);
+ANGLE_EXPORT void GL_APIENTRY Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+ANGLE_EXPORT void GL_APIENTRY Uniform1uiv(GLint location, GLsizei count, const GLuint* value);
+ANGLE_EXPORT void GL_APIENTRY Uniform2uiv(GLint location, GLsizei count, const GLuint* value);
+ANGLE_EXPORT void GL_APIENTRY Uniform3uiv(GLint location, GLsizei count, const GLuint* value);
+ANGLE_EXPORT void GL_APIENTRY Uniform4uiv(GLint location, GLsizei count, const GLuint* value);
+ANGLE_EXPORT void GL_APIENTRY ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value);
+ANGLE_EXPORT void GL_APIENTRY ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value);
+ANGLE_EXPORT void GL_APIENTRY ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value);
+ANGLE_EXPORT void GL_APIENTRY ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
+ANGLE_EXPORT const GLubyte *GL_APIENTRY GetStringi(GLenum name, GLuint index);
+ANGLE_EXPORT void GL_APIENTRY CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+ANGLE_EXPORT void GL_APIENTRY GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices);
+ANGLE_EXPORT void GL_APIENTRY GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params);
+ANGLE_EXPORT GLuint GL_APIENTRY GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName);
+ANGLE_EXPORT void GL_APIENTRY GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params);
+ANGLE_EXPORT void GL_APIENTRY GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName);
+ANGLE_EXPORT void GL_APIENTRY UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
+ANGLE_EXPORT void GL_APIENTRY DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount);
+ANGLE_EXPORT void GL_APIENTRY DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount);
+ANGLE_EXPORT GLsync GL_APIENTRY FenceSync_(GLenum condition, GLbitfield flags);
+ANGLE_EXPORT GLboolean GL_APIENTRY IsSync(GLsync sync);
+ANGLE_EXPORT void GL_APIENTRY DeleteSync(GLsync sync);
+ANGLE_EXPORT GLenum GL_APIENTRY ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout);
+ANGLE_EXPORT void GL_APIENTRY WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout);
+ANGLE_EXPORT void GL_APIENTRY GetInteger64v(GLenum pname, GLint64* params);
+ANGLE_EXPORT void GL_APIENTRY GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values);
+ANGLE_EXPORT void GL_APIENTRY GetInteger64i_v(GLenum target, GLuint index, GLint64* data);
+ANGLE_EXPORT void GL_APIENTRY GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params);
+ANGLE_EXPORT void GL_APIENTRY GenSamplers(GLsizei count, GLuint* samplers);
+ANGLE_EXPORT void GL_APIENTRY DeleteSamplers(GLsizei count, const GLuint* samplers);
+ANGLE_EXPORT GLboolean GL_APIENTRY IsSampler(GLuint sampler);
+ANGLE_EXPORT void GL_APIENTRY BindSampler(GLuint unit, GLuint sampler);
+ANGLE_EXPORT void GL_APIENTRY SamplerParameteri(GLuint sampler, GLenum pname, GLint param);
+ANGLE_EXPORT void GL_APIENTRY SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param);
+ANGLE_EXPORT void GL_APIENTRY SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param);
+ANGLE_EXPORT void GL_APIENTRY SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param);
+ANGLE_EXPORT void GL_APIENTRY GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params);
+ANGLE_EXPORT void GL_APIENTRY GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params);
+ANGLE_EXPORT void GL_APIENTRY VertexAttribDivisor(GLuint index, GLuint divisor);
+ANGLE_EXPORT void GL_APIENTRY BindTransformFeedback(GLenum target, GLuint id);
+ANGLE_EXPORT void GL_APIENTRY DeleteTransformFeedbacks(GLsizei n, const GLuint* ids);
+ANGLE_EXPORT void GL_APIENTRY GenTransformFeedbacks(GLsizei n, GLuint* ids);
+ANGLE_EXPORT GLboolean GL_APIENTRY IsTransformFeedback(GLuint id);
+ANGLE_EXPORT void GL_APIENTRY PauseTransformFeedback(void);
+ANGLE_EXPORT void GL_APIENTRY ResumeTransformFeedback(void);
+ANGLE_EXPORT void GL_APIENTRY GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary);
+ANGLE_EXPORT void GL_APIENTRY ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length);
+ANGLE_EXPORT void GL_APIENTRY ProgramParameteri(GLuint program, GLenum pname, GLint value);
+ANGLE_EXPORT void GL_APIENTRY InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments);
+ANGLE_EXPORT void GL_APIENTRY InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height);
+ANGLE_EXPORT void GL_APIENTRY TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+ANGLE_EXPORT void GL_APIENTRY TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+ANGLE_EXPORT void GL_APIENTRY GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params);
+
+}
+
+#endif // LIBGLESV2_ENTRYPOINTGLES30_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_gles_3_0_ext.cpp b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_3_0_ext.cpp
new file mode 100644
index 0000000000..6f6983fd91
--- /dev/null
+++ b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_3_0_ext.cpp
@@ -0,0 +1,14 @@
+//
+// Copyright(c) 2014 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.
+//
+
+// entry_points_gles_3_0_ext.cpp : Implements the GLES 3.0 extension entry points.
+
+#include "libGLESv2/entry_points_gles_3_0_ext.h"
+#include "libGLESv2/global_state.h"
+
+namespace gl
+{
+}
diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_gles_3_0_ext.h b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_3_0_ext.h
new file mode 100644
index 0000000000..fec4c1298a
--- /dev/null
+++ b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_3_0_ext.h
@@ -0,0 +1,23 @@
+//
+// Copyright(c) 2014 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.
+//
+
+// entry_points_gles_3_0_ext.h : Defines the GLES 3.0 extension entry points.
+
+#ifndef LIBGLESV2_ENTRYPOINTGLES30EXT_H_
+#define LIBGLESV2_ENTRYPOINTGLES30EXT_H_
+
+#include <GLES3/gl3.h>
+#include <GLES3/gl3ext.h>
+#include <export.h>
+
+namespace gl
+{
+
+// No GLES 3.0 extensions yet
+
+}
+
+#endif // LIBGLESV2_ENTRYPOINTGLES30EXT_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/formatutils.cpp b/src/3rdparty/angle/src/libGLESv2/formatutils.cpp
deleted file mode 100644
index 8674d5337f..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/formatutils.cpp
+++ /dev/null
@@ -1,629 +0,0 @@
-//
-// Copyright (c) 2013-2014 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.
-//
-
-// formatutils.cpp: Queries for GL image formats.
-
-#include "common/mathutil.h"
-#include "libGLESv2/formatutils.h"
-#include "libGLESv2/Context.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/renderer/Renderer.h"
-#include "libGLESv2/renderer/imageformats.h"
-#include "libGLESv2/renderer/copyimage.h"
-
-namespace gl
-{
-
-// ES2 requires that format is equal to internal format at all glTex*Image2D entry points and the implementation
-// can decide the true, sized, internal format. The ES2FormatMap determines the internal format for all valid
-// format and type combinations.
-
-FormatType::FormatType()
- : internalFormat(GL_NONE),
- colorWriteFunction(NULL)
-{
-}
-
-typedef std::pair<GLenum, GLenum> FormatTypePair;
-typedef std::pair<FormatTypePair, FormatType> FormatPair;
-typedef std::map<FormatTypePair, FormatType> FormatMap;
-
-// A helper function to insert data into the format map with fewer characters.
-static inline void InsertFormatMapping(FormatMap *map, GLenum format, GLenum type, GLenum internalFormat, ColorWriteFunction writeFunc)
-{
- FormatType info;
- info.internalFormat = internalFormat;
- info.colorWriteFunction = writeFunc;
- map->insert(FormatPair(FormatTypePair(format, type), info));
-}
-
-FormatMap BuildFormatMap()
-{
- FormatMap map;
-
- using namespace rx;
-
- // | Format | Type | Internal format | Color write function |
- InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_BYTE, GL_RGBA8, WriteColor<R8G8B8A8, GLfloat> );
- InsertFormatMapping(&map, GL_RGBA, GL_BYTE, GL_RGBA8_SNORM, WriteColor<R8G8B8A8S, GLfloat> );
- InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_RGBA4, WriteColor<R4G4B4A4, GLfloat> );
- InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_RGB5_A1, WriteColor<R5G5B5A1, GLfloat> );
- InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_RGB10_A2, WriteColor<R10G10B10A2, GLfloat> );
- InsertFormatMapping(&map, GL_RGBA, GL_FLOAT, GL_RGBA32F, WriteColor<R32G32B32A32F, GLfloat>);
- InsertFormatMapping(&map, GL_RGBA, GL_HALF_FLOAT, GL_RGBA16F, WriteColor<R16G16B16A16F, GLfloat>);
- InsertFormatMapping(&map, GL_RGBA, GL_HALF_FLOAT_OES, GL_RGBA16F, WriteColor<R16G16B16A16F, GLfloat>);
-
- InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_RGBA8UI, WriteColor<R8G8B8A8, GLuint> );
- InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_BYTE, GL_RGBA8I, WriteColor<R8G8B8A8S, GLint> );
- InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_RGBA16UI, WriteColor<R16G16B16A16, GLuint> );
- InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_SHORT, GL_RGBA16I, WriteColor<R16G16B16A16S, GLint> );
- InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_RGBA32UI, WriteColor<R32G32B32A32, GLuint> );
- InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_INT, GL_RGBA32I, WriteColor<R32G32B32A32S, GLint> );
- InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_RGB10_A2UI, WriteColor<R10G10B10A2, GLuint> );
-
- InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_BYTE, GL_RGB8, WriteColor<R8G8B8, GLfloat> );
- InsertFormatMapping(&map, GL_RGB, GL_BYTE, GL_RGB8_SNORM, WriteColor<R8G8B8S, GLfloat> );
- InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_RGB565, WriteColor<R5G6B5, GLfloat> );
- InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_R11F_G11F_B10F, WriteColor<R11G11B10F, GLfloat> );
- InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_RGB9_E5, WriteColor<R9G9B9E5, GLfloat> );
- InsertFormatMapping(&map, GL_RGB, GL_FLOAT, GL_RGB32F, WriteColor<R32G32B32F, GLfloat> );
- InsertFormatMapping(&map, GL_RGB, GL_HALF_FLOAT, GL_RGB16F, WriteColor<R16G16B16F, GLfloat> );
- InsertFormatMapping(&map, GL_RGB, GL_HALF_FLOAT_OES, GL_RGB16F, WriteColor<R16G16B16F, GLfloat> );
-
- InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_RGB8UI, WriteColor<R8G8B8, GLuint> );
- InsertFormatMapping(&map, GL_RGB_INTEGER, GL_BYTE, GL_RGB8I, WriteColor<R8G8B8S, GLint> );
- InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_RGB16UI, WriteColor<R16G16B16, GLuint> );
- InsertFormatMapping(&map, GL_RGB_INTEGER, GL_SHORT, GL_RGB16I, WriteColor<R16G16B16S, GLint> );
- InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_RGB32UI, WriteColor<R32G32B32, GLuint> );
- InsertFormatMapping(&map, GL_RGB_INTEGER, GL_INT, GL_RGB32I, WriteColor<R32G32B32S, GLint> );
-
- InsertFormatMapping(&map, GL_RG, GL_UNSIGNED_BYTE, GL_RG8, WriteColor<R8G8, GLfloat> );
- InsertFormatMapping(&map, GL_RG, GL_BYTE, GL_RG8_SNORM, WriteColor<R8G8S, GLfloat> );
- InsertFormatMapping(&map, GL_RG, GL_FLOAT, GL_RG32F, WriteColor<R32G32F, GLfloat> );
- InsertFormatMapping(&map, GL_RG, GL_HALF_FLOAT, GL_RG16F, WriteColor<R16G16F, GLfloat> );
- InsertFormatMapping(&map, GL_RG, GL_HALF_FLOAT_OES, GL_RG16F, WriteColor<R16G16F, GLfloat> );
-
- InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_RG8UI, WriteColor<R8G8, GLuint> );
- InsertFormatMapping(&map, GL_RG_INTEGER, GL_BYTE, GL_RG8I, WriteColor<R8G8S, GLint> );
- InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_RG16UI, WriteColor<R16G16, GLuint> );
- InsertFormatMapping(&map, GL_RG_INTEGER, GL_SHORT, GL_RG16I, WriteColor<R16G16S, GLint> );
- InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_RG32UI, WriteColor<R32G32, GLuint> );
- InsertFormatMapping(&map, GL_RG_INTEGER, GL_INT, GL_RG32I, WriteColor<R32G32S, GLint> );
-
- InsertFormatMapping(&map, GL_RED, GL_UNSIGNED_BYTE, GL_R8, WriteColor<R8, GLfloat> );
- InsertFormatMapping(&map, GL_RED, GL_BYTE, GL_R8_SNORM, WriteColor<R8S, GLfloat> );
- InsertFormatMapping(&map, GL_RED, GL_FLOAT, GL_R32F, WriteColor<R32F, GLfloat> );
- InsertFormatMapping(&map, GL_RED, GL_HALF_FLOAT, GL_R16F, WriteColor<R16F, GLfloat> );
- InsertFormatMapping(&map, GL_RED, GL_HALF_FLOAT_OES, GL_R16F, WriteColor<R16F, GLfloat> );
-
- InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_R8UI, WriteColor<R8, GLuint> );
- InsertFormatMapping(&map, GL_RED_INTEGER, GL_BYTE, GL_R8I, WriteColor<R8S, GLint> );
- InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_R16UI, WriteColor<R16, GLuint> );
- InsertFormatMapping(&map, GL_RED_INTEGER, GL_SHORT, GL_R16I, WriteColor<R16S, GLint> );
- InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_R32UI, WriteColor<R32, GLuint> );
- InsertFormatMapping(&map, GL_RED_INTEGER, GL_INT, GL_R32I, WriteColor<R32S, GLint> );
-
- InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_LUMINANCE8_ALPHA8_EXT, WriteColor<L8A8, GLfloat> );
- InsertFormatMapping(&map, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LUMINANCE8_EXT, WriteColor<L8, GLfloat> );
- InsertFormatMapping(&map, GL_ALPHA, GL_UNSIGNED_BYTE, GL_ALPHA8_EXT, WriteColor<A8, GLfloat> );
- InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_LUMINANCE_ALPHA32F_EXT, WriteColor<L32A32F, GLfloat> );
- InsertFormatMapping(&map, GL_LUMINANCE, GL_FLOAT, GL_LUMINANCE32F_EXT, WriteColor<L32F, GLfloat> );
- InsertFormatMapping(&map, GL_ALPHA, GL_FLOAT, GL_ALPHA32F_EXT, WriteColor<A32F, GLfloat> );
- InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, GL_LUMINANCE_ALPHA16F_EXT, WriteColor<L16A16F, GLfloat> );
- InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_LUMINANCE_ALPHA16F_EXT, WriteColor<L16A16F, GLfloat> );
- InsertFormatMapping(&map, GL_LUMINANCE, GL_HALF_FLOAT, GL_LUMINANCE16F_EXT, WriteColor<L16F, GLfloat> );
- InsertFormatMapping(&map, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_LUMINANCE16F_EXT, WriteColor<L16F, GLfloat> );
- InsertFormatMapping(&map, GL_ALPHA, GL_HALF_FLOAT, GL_ALPHA16F_EXT, WriteColor<A16F, GLfloat> );
- InsertFormatMapping(&map, GL_ALPHA, GL_HALF_FLOAT_OES, GL_ALPHA16F_EXT, WriteColor<A16F, GLfloat> );
-
- InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_BGRA8_EXT, WriteColor<B8G8R8A8, GLfloat> );
- InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_BGRA4_ANGLEX, WriteColor<B4G4R4A4, GLfloat> );
- InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_BGR5_A1_ANGLEX, WriteColor<B5G5R5A1, GLfloat> );
-
- InsertFormatMapping(&map, GL_SRGB_EXT, GL_UNSIGNED_BYTE, GL_SRGB8, WriteColor<R8G8B8, GLfloat> );
- InsertFormatMapping(&map, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, GL_SRGB8_ALPHA8, WriteColor<R8G8B8A8, GLfloat> );
-
- InsertFormatMapping(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, NULL );
- InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, NULL );
- InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, NULL );
- InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, NULL );
-
- InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_DEPTH_COMPONENT16, NULL );
- InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_DEPTH_COMPONENT32_OES, NULL );
- InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT32F, NULL );
-
- InsertFormatMapping(&map, GL_STENCIL, GL_UNSIGNED_BYTE, GL_STENCIL_INDEX8, NULL );
-
- InsertFormatMapping(&map, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8, NULL );
- InsertFormatMapping(&map, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_DEPTH32F_STENCIL8, NULL );
-
- return map;
-}
-
-Type::Type()
- : bytes(0),
- specialInterpretation(false)
-{
-}
-
-// Map of sizes of input types
-typedef std::pair<GLenum, Type> TypeInfoPair;
-typedef std::map<GLenum, Type> TypeInfoMap;
-
-static inline void InsertTypeInfo(TypeInfoMap *map, GLenum type, GLuint bytes, bool specialInterpretation)
-{
- Type info;
- info.bytes = bytes;
- info.specialInterpretation = specialInterpretation;
-
- map->insert(std::make_pair(type, info));
-}
-
-bool operator<(const Type& a, const Type& b)
-{
- return memcmp(&a, &b, sizeof(Type)) < 0;
-}
-
-static TypeInfoMap BuildTypeInfoMap()
-{
- TypeInfoMap map;
-
- InsertTypeInfo(&map, GL_UNSIGNED_BYTE, 1, false);
- InsertTypeInfo(&map, GL_BYTE, 1, false);
- InsertTypeInfo(&map, GL_UNSIGNED_SHORT, 2, false);
- InsertTypeInfo(&map, GL_SHORT, 2, false);
- InsertTypeInfo(&map, GL_UNSIGNED_INT, 4, false);
- InsertTypeInfo(&map, GL_INT, 4, false);
- InsertTypeInfo(&map, GL_HALF_FLOAT, 2, false);
- InsertTypeInfo(&map, GL_HALF_FLOAT_OES, 2, false);
- InsertTypeInfo(&map, GL_FLOAT, 4, false);
- InsertTypeInfo(&map, GL_UNSIGNED_SHORT_5_6_5, 2, true );
- InsertTypeInfo(&map, GL_UNSIGNED_SHORT_4_4_4_4, 2, true );
- InsertTypeInfo(&map, GL_UNSIGNED_SHORT_5_5_5_1, 2, true );
- InsertTypeInfo(&map, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, 2, true );
- InsertTypeInfo(&map, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, 2, true );
- InsertTypeInfo(&map, GL_UNSIGNED_INT_2_10_10_10_REV, 4, true );
- InsertTypeInfo(&map, GL_UNSIGNED_INT_24_8, 4, true );
- InsertTypeInfo(&map, GL_UNSIGNED_INT_10F_11F_11F_REV, 4, true );
- InsertTypeInfo(&map, GL_UNSIGNED_INT_5_9_9_9_REV, 4, true );
- InsertTypeInfo(&map, GL_UNSIGNED_INT_24_8_OES, 4, true );
- InsertTypeInfo(&map, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, 8, true );
-
- return map;
-}
-
-// Information about internal formats
-static bool AlwaysSupported(GLuint, const Extensions &)
-{
- return true;
-}
-
-static bool UnimplementedSupport(GLuint, const Extensions &)
-{
- return false;
-}
-
-static bool NeverSupported(GLuint, const Extensions &)
-{
- return false;
-}
-
-template <GLuint minCoreGLVersion>
-static bool RequireES(GLuint clientVersion, const Extensions &)
-{
- return clientVersion >= minCoreGLVersion;
-}
-
-// Pointer to a boolean memeber of the Extensions struct
-typedef bool(Extensions::*ExtensionBool);
-
-// Check support for a single extension
-template <ExtensionBool bool1>
-static bool RequireExt(GLuint, const Extensions & extensions)
-{
- return extensions.*bool1;
-}
-
-// Check for a minimum client version or a single extension
-template <GLuint minCoreGLVersion, ExtensionBool bool1>
-static bool RequireESOrExt(GLuint clientVersion, const Extensions &extensions)
-{
- return clientVersion >= minCoreGLVersion || extensions.*bool1;
-}
-
-// Check for a minimum client version or two extensions
-template <GLuint minCoreGLVersion, ExtensionBool bool1, ExtensionBool bool2>
-static bool RequireESOrExtAndExt(GLuint clientVersion, const Extensions &extensions)
-{
- return clientVersion >= minCoreGLVersion || (extensions.*bool1 && extensions.*bool2);
-}
-
-// Check for a minimum client version or at least one of two extensions
-template <GLuint minCoreGLVersion, ExtensionBool bool1, ExtensionBool bool2>
-static bool RequireESOrExtOrExt(GLuint clientVersion, const Extensions &extensions)
-{
- return clientVersion >= minCoreGLVersion || extensions.*bool1 || extensions.*bool2;
-}
-
-// Check support for two extensions
-template <ExtensionBool bool1, ExtensionBool bool2>
-static bool RequireExtAndExt(GLuint, const Extensions &extensions)
-{
- return extensions.*bool1 && extensions.*bool2;
-}
-
-InternalFormat::InternalFormat()
- : redBits(0),
- greenBits(0),
- blueBits(0),
- luminanceBits(0),
- alphaBits(0),
- sharedBits(0),
- depthBits(0),
- stencilBits(0),
- pixelBytes(0),
- componentCount(0),
- compressedBlockWidth(0),
- compressedBlockHeight(0),
- format(GL_NONE),
- type(GL_NONE),
- componentType(GL_NONE),
- colorEncoding(GL_NONE),
- compressed(false),
- textureSupport(NeverSupported),
- renderSupport(NeverSupported),
- filterSupport(NeverSupported)
-{
-}
-
-static InternalFormat UnsizedFormat(GLenum format, InternalFormat::SupportCheckFunction textureSupport,
- InternalFormat::SupportCheckFunction renderSupport,
- InternalFormat::SupportCheckFunction filterSupport)
-{
- InternalFormat formatInfo;
- formatInfo.format = format;
- formatInfo.textureSupport = textureSupport;
- formatInfo.renderSupport = renderSupport;
- formatInfo.filterSupport = filterSupport;
- return formatInfo;
-}
-
-static InternalFormat RGBAFormat(GLuint red, GLuint green, GLuint blue, GLuint alpha, GLuint shared,
- GLenum format, GLenum type, GLenum componentType, bool srgb,
- InternalFormat::SupportCheckFunction textureSupport,
- InternalFormat::SupportCheckFunction renderSupport,
- InternalFormat::SupportCheckFunction filterSupport)
-{
- InternalFormat formatInfo;
- formatInfo.redBits = red;
- formatInfo.greenBits = green;
- formatInfo.blueBits = blue;
- formatInfo.alphaBits = alpha;
- formatInfo.sharedBits = shared;
- formatInfo.pixelBytes = (red + green + blue + alpha + shared) / 8;
- formatInfo.componentCount = ((red > 0) ? 1 : 0) + ((green > 0) ? 1 : 0) + ((blue > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0);
- formatInfo.format = format;
- formatInfo.type = type;
- formatInfo.componentType = componentType;
- formatInfo.colorEncoding = (srgb ? GL_SRGB : GL_LINEAR);
- formatInfo.textureSupport = textureSupport;
- formatInfo.renderSupport = renderSupport;
- formatInfo.filterSupport = filterSupport;
- return formatInfo;
-}
-
-static InternalFormat LUMAFormat(GLuint luminance, GLuint alpha, GLenum format, GLenum type, GLenum componentType,
- InternalFormat::SupportCheckFunction textureSupport,
- InternalFormat::SupportCheckFunction renderSupport,
- InternalFormat::SupportCheckFunction filterSupport)
-{
- InternalFormat formatInfo;
- formatInfo.luminanceBits = luminance;
- formatInfo.alphaBits = alpha;
- formatInfo.pixelBytes = (luminance + alpha) / 8;
- formatInfo.componentCount = ((luminance > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0);
- formatInfo.format = format;
- formatInfo.type = type;
- formatInfo.componentType = componentType;
- formatInfo.colorEncoding = GL_LINEAR;
- formatInfo.textureSupport = textureSupport;
- formatInfo.renderSupport = renderSupport;
- formatInfo.filterSupport = filterSupport;
- return formatInfo;
-}
-
-static InternalFormat DepthStencilFormat(GLuint depthBits, GLuint stencilBits, GLuint unusedBits, GLenum format,
- GLenum type, GLenum componentType, InternalFormat::SupportCheckFunction textureSupport,
- InternalFormat::SupportCheckFunction renderSupport,
- InternalFormat::SupportCheckFunction filterSupport)
-{
- InternalFormat formatInfo;
- formatInfo.depthBits = depthBits;
- formatInfo.stencilBits = stencilBits;
- formatInfo.pixelBytes = (depthBits + stencilBits + unusedBits) / 8;
- formatInfo.componentCount = ((depthBits > 0) ? 1 : 0) + ((stencilBits > 0) ? 1 : 0);
- formatInfo.format = format;
- formatInfo.type = type;
- formatInfo.componentType = componentType;
- formatInfo.colorEncoding = GL_LINEAR;
- formatInfo.textureSupport = textureSupport;
- formatInfo.renderSupport = renderSupport;
- formatInfo.filterSupport = filterSupport;
- return formatInfo;
-}
-
-static InternalFormat CompressedFormat(GLuint compressedBlockWidth, GLuint compressedBlockHeight, GLuint compressedBlockSize,
- GLuint componentCount, GLenum format, GLenum type, bool srgb,
- InternalFormat::SupportCheckFunction textureSupport,
- InternalFormat::SupportCheckFunction renderSupport,
- InternalFormat::SupportCheckFunction filterSupport)
-{
- InternalFormat formatInfo;
- formatInfo.compressedBlockWidth = compressedBlockWidth;
- formatInfo.compressedBlockHeight = compressedBlockHeight;
- formatInfo.pixelBytes = compressedBlockSize / 8;
- formatInfo.componentCount = componentCount;
- formatInfo.format = format;
- formatInfo.type = type;
- formatInfo.componentType = GL_UNSIGNED_NORMALIZED;
- formatInfo.colorEncoding = (srgb ? GL_SRGB : GL_LINEAR);
- formatInfo.compressed = true;
- formatInfo.textureSupport = textureSupport;
- formatInfo.renderSupport = renderSupport;
- formatInfo.filterSupport = filterSupport;
- return formatInfo;
-}
-
-typedef std::pair<GLenum, InternalFormat> InternalFormatInfoPair;
-typedef std::map<GLenum, InternalFormat> InternalFormatInfoMap;
-
-static InternalFormatInfoMap BuildInternalFormatInfoMap()
-{
- InternalFormatInfoMap map;
-
- // From ES 3.0.1 spec, table 3.12
- map.insert(InternalFormatInfoPair(GL_NONE, InternalFormat()));
-
- // | Internal format | | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Renderable | Filterable |
- map.insert(InternalFormatInfoPair(GL_R8, RGBAFormat( 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, &Extensions::textureRG>, RequireESOrExt<3, &Extensions::textureRG>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_R8_SNORM, RGBAFormat( 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RG8, RGBAFormat( 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, &Extensions::textureRG>, RequireESOrExt<3, &Extensions::textureRG>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RG8_SNORM, RGBAFormat( 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RGB8, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, &Extensions::rgb8rgba8>, RequireESOrExt<3, &Extensions::rgb8rgba8>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RGB8_SNORM, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RGB565, RGBAFormat( 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, RequireES<2>, RequireES<2>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RGBA4, RGBAFormat( 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, RequireES<2>, RequireES<2>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RGB5_A1, RGBAFormat( 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, RequireES<2>, RequireES<2>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RGBA8, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, &Extensions::rgb8rgba8>, RequireESOrExt<3, &Extensions::rgb8rgba8>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RGBA8_SNORM, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RGB10_A2, RGBAFormat(10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireES<3>, RequireES<3>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RGB10_A2UI, RGBAFormat(10, 10, 10, 2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_SRGB8, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESOrExt<3, &Extensions::sRGB>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_SRGB8_ALPHA8, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESOrExt<3, &Extensions::sRGB>, RequireESOrExt<3, &Extensions::sRGB>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_R11F_G11F_B10F, RGBAFormat(11, 11, 10, 0, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FLOAT, false, RequireES<3>, RequireExt<&Extensions::colorBufferFloat>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RGB9_E5, RGBAFormat( 9, 9, 9, 0, 5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT, false, RequireES<3>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_R8I, RGBAFormat( 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_R8UI, RGBAFormat( 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_R16I, RGBAFormat(16, 0, 0, 0, 0, GL_RED_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_R16UI, RGBAFormat(16, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_R32I, RGBAFormat(32, 0, 0, 0, 0, GL_RED_INTEGER, GL_INT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_R32UI, RGBAFormat(32, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RG8I, RGBAFormat( 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RG8UI, RGBAFormat( 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RG16I, RGBAFormat(16, 16, 0, 0, 0, GL_RG_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RG16UI, RGBAFormat(16, 16, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RG32I, RGBAFormat(32, 32, 0, 0, 0, GL_RG_INTEGER, GL_INT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RG32UI, RGBAFormat(32, 32, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RGB8I, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RGB8UI, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RGB16I, RGBAFormat(16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RGB16UI, RGBAFormat(16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RGB32I, RGBAFormat(32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_INT, GL_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RGB32UI, RGBAFormat(32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RGBA8I, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RGBA8UI, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RGBA16I, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RGBA16UI, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RGBA32I, RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
- map.insert(InternalFormatInfoPair(GL_RGBA32UI, RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
-
- map.insert(InternalFormatInfoPair(GL_BGRA8_EXT, RGBAFormat( 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_BGRA4_ANGLEX, RGBAFormat( 4, 4, 4, 4, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_BGR5_A1_ANGLEX, RGBAFormat( 5, 5, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported)));
-
- // Floating point renderability and filtering is provided by OES_texture_float and OES_texture_half_float
- // | Internal format | | D |S | Format | Type | Comp | SRGB | Texture supported | Renderable | Filterable |
- // | | | | | | | type | | | | |
- map.insert(InternalFormatInfoPair(GL_R16F, RGBAFormat(16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT, GL_FLOAT, false, RequireESOrExtAndExt<3, &Extensions::textureHalfFloat, &Extensions::textureRG>, RequireESOrExtAndExt<3, &Extensions::textureHalfFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureHalfFloatLinear>)));
- map.insert(InternalFormatInfoPair(GL_RG16F, RGBAFormat(16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT, GL_FLOAT, false, RequireESOrExtAndExt<3, &Extensions::textureHalfFloat, &Extensions::textureRG>, RequireESOrExtAndExt<3, &Extensions::textureHalfFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureHalfFloatLinear>)));
- map.insert(InternalFormatInfoPair(GL_RGB16F, RGBAFormat(16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT, GL_FLOAT, false, RequireESOrExt<3, &Extensions::textureHalfFloat>, RequireESOrExt<3, &Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>)));
- map.insert(InternalFormatInfoPair(GL_RGBA16F, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT, GL_FLOAT, false, RequireESOrExt<3, &Extensions::textureHalfFloat>, RequireESOrExt<3, &Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>)));
- map.insert(InternalFormatInfoPair(GL_R32F, RGBAFormat(32, 0, 0, 0, 0, GL_RED, GL_FLOAT, GL_FLOAT, false, RequireESOrExtAndExt<3, &Extensions::textureFloat, &Extensions::textureRG>, RequireESOrExtAndExt<3, &Extensions::textureFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureFloatLinear> )));
- map.insert(InternalFormatInfoPair(GL_RG32F, RGBAFormat(32, 32, 0, 0, 0, GL_RG, GL_FLOAT, GL_FLOAT, false, RequireESOrExtAndExt<3, &Extensions::textureFloat, &Extensions::textureRG>, RequireESOrExtAndExt<3, &Extensions::textureFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureFloatLinear> )));
- map.insert(InternalFormatInfoPair(GL_RGB32F, RGBAFormat(32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, RequireESOrExt<3, &Extensions::textureFloat>, RequireESOrExt<3, &Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear> )));
- map.insert(InternalFormatInfoPair(GL_RGBA32F, RGBAFormat(32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, RequireESOrExt<3, &Extensions::textureFloat>, RequireESOrExt<3, &Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear> )));
-
- // Depth stencil formats
- // | Internal format | | D |S | X | Format | Type | Component type | Supported | Renderable | Filterable |
- map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT16, DepthStencilFormat(16, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, RequireES<2>, RequireES<2>, RequireESOrExt<3, &Extensions::depthTextures>)));
- map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT24, DepthStencilFormat(24, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireES<3>, RequireES<3>, RequireESOrExt<3, &Extensions::depthTextures>)));
- map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32F, DepthStencilFormat(32, 0, 0, GL_DEPTH_COMPONENT, GL_FLOAT, GL_FLOAT, RequireES<3>, RequireES<3>, RequireESOrExt<3, &Extensions::depthTextures>)));
- map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32_OES, DepthStencilFormat(32, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::depthTextures>, RequireExt<&Extensions::depthTextures>, AlwaysSupported )));
- map.insert(InternalFormatInfoPair(GL_DEPTH24_STENCIL8, DepthStencilFormat(24, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_NORMALIZED, RequireESOrExt<3, &Extensions::depthTextures>, RequireESOrExtOrExt<3, &Extensions::depthTextures, &Extensions::packedDepthStencil>, AlwaysSupported )));
- map.insert(InternalFormatInfoPair(GL_DEPTH32F_STENCIL8, DepthStencilFormat(32, 8, 24, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_FLOAT, RequireES<3>, RequireES<3>, AlwaysSupported )));
- map.insert(InternalFormatInfoPair(GL_STENCIL_INDEX8, DepthStencilFormat( 0, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, RequireES<2>, RequireES<2>, NeverSupported )));
-
- // Luminance alpha formats
- // | Internal format | | L | A | Format | Type | Component type | Supported | Renderable | Filterable |
- map.insert(InternalFormatInfoPair(GL_ALPHA8_EXT, LUMAFormat( 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_LUMINANCE8_EXT, LUMAFormat( 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_ALPHA32F_EXT, LUMAFormat( 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_LUMINANCE32F_EXT, LUMAFormat(32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_ALPHA16F_EXT, LUMAFormat( 0, 16, GL_ALPHA, GL_HALF_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_LUMINANCE16F_EXT, LUMAFormat(16, 0, GL_LUMINANCE, GL_HALF_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_LUMINANCE8_ALPHA8_EXT, LUMAFormat( 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA32F_EXT, LUMAFormat(32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA16F_EXT, LUMAFormat(16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, AlwaysSupported)));
-
- // Unsized formats
- // | Internal format | | Format | Supported | Renderable | Filterable |
- map.insert(InternalFormatInfoPair(GL_ALPHA, UnsizedFormat(GL_ALPHA, RequireES<2>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_LUMINANCE, UnsizedFormat(GL_LUMINANCE, RequireES<2>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA, UnsizedFormat(GL_LUMINANCE_ALPHA, RequireES<2>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RED, UnsizedFormat(GL_RED, RequireESOrExt<3, &Extensions::textureRG>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RG, UnsizedFormat(GL_RG, RequireESOrExt<3, &Extensions::textureRG>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RGB, UnsizedFormat(GL_RGB, RequireES<2>, RequireES<2>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RGBA, UnsizedFormat(GL_RGBA, RequireES<2>, RequireES<2>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_RED_INTEGER, UnsizedFormat(GL_RED_INTEGER, RequireES<3>, NeverSupported, NeverSupported )));
- map.insert(InternalFormatInfoPair(GL_RG_INTEGER, UnsizedFormat(GL_RG_INTEGER, RequireES<3>, NeverSupported, NeverSupported )));
- map.insert(InternalFormatInfoPair(GL_RGB_INTEGER, UnsizedFormat(GL_RGB_INTEGER, RequireES<3>, NeverSupported, NeverSupported )));
- map.insert(InternalFormatInfoPair(GL_RGBA_INTEGER, UnsizedFormat(GL_RGBA_INTEGER, RequireES<3>, NeverSupported, NeverSupported )));
- map.insert(InternalFormatInfoPair(GL_BGRA_EXT, UnsizedFormat(GL_BGRA_EXT, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT, UnsizedFormat(GL_DEPTH_COMPONENT, RequireES<2>, RequireES<2>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_DEPTH_STENCIL, UnsizedFormat(GL_DEPTH_STENCIL, RequireESOrExt<3, &Extensions::packedDepthStencil>, RequireESOrExt<3, &Extensions::packedDepthStencil>, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_SRGB_EXT, UnsizedFormat(GL_RGB, RequireESOrExt<3, &Extensions::sRGB>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_SRGB_ALPHA_EXT, UnsizedFormat(GL_RGBA, RequireESOrExt<3, &Extensions::sRGB>, RequireESOrExt<3, &Extensions::sRGB>, AlwaysSupported)));
-
- // Compressed formats, From ES 3.0.1 spec, table 3.16
- // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable |
- map.insert(InternalFormatInfoPair(GL_COMPRESSED_R11_EAC, CompressedFormat(4, 4, 64, 1, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
- map.insert(InternalFormatInfoPair(GL_COMPRESSED_SIGNED_R11_EAC, CompressedFormat(4, 4, 64, 1, GL_COMPRESSED_SIGNED_R11_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
- map.insert(InternalFormatInfoPair(GL_COMPRESSED_RG11_EAC, CompressedFormat(4, 4, 128, 2, GL_COMPRESSED_RG11_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
- map.insert(InternalFormatInfoPair(GL_COMPRESSED_SIGNED_RG11_EAC, CompressedFormat(4, 4, 128, 2, GL_COMPRESSED_SIGNED_RG11_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
- map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB8_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB8_ETC2, GL_UNSIGNED_BYTE, false, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
- map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_SRGB8_ETC2, GL_UNSIGNED_BYTE, true, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
- map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, false, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
- map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, true, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
- map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA8_ETC2_EAC, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
- map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_UNSIGNED_BYTE, true, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
-
- // From GL_EXT_texture_compression_dxt1
- // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable |
- map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT1>, NeverSupported, AlwaysSupported)));
- map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, CompressedFormat(4, 4, 64, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT1>, NeverSupported, AlwaysSupported)));
-
- // From GL_ANGLE_texture_compression_dxt3
- map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT5>, NeverSupported, AlwaysSupported)));
-
- // From GL_ANGLE_texture_compression_dxt5
- map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT5>, NeverSupported, AlwaysSupported)));
-
- return map;
-}
-
-static const InternalFormatInfoMap &GetInternalFormatMap()
-{
- static const InternalFormatInfoMap formatMap = BuildInternalFormatInfoMap();
- return formatMap;
-}
-
-static FormatSet BuildAllSizedInternalFormatSet()
-{
- FormatSet result;
-
- const InternalFormatInfoMap &formats = GetInternalFormatMap();
- for (InternalFormatInfoMap::const_iterator i = formats.begin(); i != formats.end(); i++)
- {
- if (i->second.pixelBytes > 0)
- {
- result.insert(i->first);
- }
- }
-
- return result;
-}
-
-const FormatType &GetFormatTypeInfo(GLenum format, GLenum type)
-{
- static const FormatMap formatMap = BuildFormatMap();
- FormatMap::const_iterator iter = formatMap.find(FormatTypePair(format, type));
- if (iter != formatMap.end())
- {
- return iter->second;
- }
- else
- {
- static const FormatType defaultInfo;
- return defaultInfo;
- }
-}
-
-const Type &GetTypeInfo(GLenum type)
-{
- static const TypeInfoMap infoMap = BuildTypeInfoMap();
- TypeInfoMap::const_iterator iter = infoMap.find(type);
- if (iter != infoMap.end())
- {
- return iter->second;
- }
- else
- {
- static const Type defaultInfo;
- return defaultInfo;
- }
-}
-
-const InternalFormat &GetInternalFormatInfo(GLenum internalFormat)
-{
- const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
- InternalFormatInfoMap::const_iterator iter = formatMap.find(internalFormat);
- if (iter != formatMap.end())
- {
- return iter->second;
- }
- else
- {
- static const InternalFormat defaultInternalFormat;
- return defaultInternalFormat;
- }
-}
-
-GLuint InternalFormat::computeRowPitch(GLenum type, GLsizei width, GLint alignment) const
-{
- ASSERT(alignment > 0 && isPow2(alignment));
- return rx::roundUp(computeBlockSize(type, width, 1), static_cast<GLuint>(alignment));
-}
-
-GLuint InternalFormat::computeDepthPitch(GLenum type, GLsizei width, GLsizei height, GLint alignment) const
-{
- return computeRowPitch(type, width, alignment) * height;
-}
-
-GLuint InternalFormat::computeBlockSize(GLenum type, GLsizei width, GLsizei height) const
-{
- if (compressed)
- {
- GLsizei numBlocksWide = (width + compressedBlockWidth - 1) / compressedBlockWidth;
- GLsizei numBlocksHight = (height + compressedBlockHeight - 1) / compressedBlockHeight;
- return (pixelBytes * numBlocksWide * numBlocksHight);
- }
- else
- {
- const Type &typeInfo = GetTypeInfo(type);
- if (typeInfo.specialInterpretation)
- {
- return typeInfo.bytes * width * height;
- }
- else
- {
- return componentCount * typeInfo.bytes * width * height;
- }
- }
-}
-
-GLenum GetSizedInternalFormat(GLenum internalFormat, GLenum type)
-{
- const InternalFormat& formatInfo = GetInternalFormatInfo(internalFormat);
- return (formatInfo.pixelBytes > 0) ? internalFormat : GetFormatTypeInfo(internalFormat, type).internalFormat;
-}
-
-const FormatSet &GetAllSizedInternalFormats()
-{
- static FormatSet formatSet = BuildAllSizedInternalFormatSet();
- return formatSet;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/formatutils.h b/src/3rdparty/angle/src/libGLESv2/formatutils.h
deleted file mode 100644
index 25106a52e5..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/formatutils.h
+++ /dev/null
@@ -1,106 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// formatutils.h: Queries for GL image formats.
-
-#ifndef LIBGLESV2_FORMATUTILS_H_
-#define LIBGLESV2_FORMATUTILS_H_
-
-#include "libGLESv2/Caps.h"
-#include "libGLESv2/angletypes.h"
-
-#include "angle_gl.h"
-
-#include <cstddef>
-#include <cstdint>
-
-typedef void (*MipGenerationFunction)(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
- const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch,
- uint8_t *destData, size_t destRowPitch, size_t destDepthPitch);
-
-typedef void (*LoadImageFunction)(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-typedef void (*InitializeTextureDataFunction)(size_t width, size_t height, size_t depth,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-typedef void (*ColorReadFunction)(const uint8_t *source, uint8_t *dest);
-typedef void (*ColorWriteFunction)(const uint8_t *source, uint8_t *dest);
-typedef void (*ColorCopyFunction)(const uint8_t *source, uint8_t *dest);
-
-typedef void (*VertexCopyFunction)(const uint8_t *input, size_t stride, size_t count, uint8_t *output);
-
-namespace gl
-{
-
-struct FormatType
-{
- FormatType();
-
- GLenum internalFormat;
- ColorWriteFunction colorWriteFunction;
-};
-const FormatType &GetFormatTypeInfo(GLenum format, GLenum type);
-
-struct Type
-{
- Type();
-
- GLuint bytes;
- bool specialInterpretation;
-};
-const Type &GetTypeInfo(GLenum type);
-
-struct InternalFormat
-{
- InternalFormat();
-
- GLuint redBits;
- GLuint greenBits;
- GLuint blueBits;
-
- GLuint luminanceBits;
-
- GLuint alphaBits;
- GLuint sharedBits;
-
- GLuint depthBits;
- GLuint stencilBits;
-
- GLuint pixelBytes;
-
- GLuint componentCount;
-
- bool compressed;
- GLuint compressedBlockWidth;
- GLuint compressedBlockHeight;
-
- GLenum format;
- GLenum type;
-
- GLenum componentType;
- GLenum colorEncoding;
-
- typedef bool (*SupportCheckFunction)(GLuint, const Extensions &);
- SupportCheckFunction textureSupport;
- SupportCheckFunction renderSupport;
- SupportCheckFunction filterSupport;
-
- GLuint computeRowPitch(GLenum type, GLsizei width, GLint alignment) const;
- GLuint computeDepthPitch(GLenum type, GLsizei width, GLsizei height, GLint alignment) const;
- GLuint computeBlockSize(GLenum type, GLsizei width, GLsizei height) const;
-};
-const InternalFormat &GetInternalFormatInfo(GLenum internalFormat);
-
-GLenum GetSizedInternalFormat(GLenum internalFormat, GLenum type);
-
-typedef std::set<GLenum> FormatSet;
-const FormatSet &GetAllSizedInternalFormats();
-
-}
-
-#endif // LIBGLESV2_FORMATUTILS_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/global_state.cpp b/src/3rdparty/angle/src/libGLESv2/global_state.cpp
new file mode 100644
index 0000000000..686f0bf49b
--- /dev/null
+++ b/src/3rdparty/angle/src/libGLESv2/global_state.cpp
@@ -0,0 +1,235 @@
+//
+// Copyright(c) 2014 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.
+//
+
+// global_state.cpp : Implements functions for querying the thread-local GL and EGL state.
+
+#include "libGLESv2/global_state.h"
+
+#include "libANGLE/Context.h"
+#include "libANGLE/Error.h"
+
+#include "common/debug.h"
+#include "common/platform.h"
+#include "common/tls.h"
+
+namespace
+{
+
+static TLSIndex currentTLS = TLS_INVALID_INDEX;
+
+struct Current
+{
+ EGLint error;
+ EGLenum API;
+ egl::Display *display;
+ egl::Surface *drawSurface;
+ egl::Surface *readSurface;
+ gl::Context *context;
+};
+
+Current *AllocateCurrent()
+{
+ ASSERT(currentTLS != TLS_INVALID_INDEX);
+ if (currentTLS == TLS_INVALID_INDEX)
+ {
+ return NULL;
+ }
+
+ Current *current = new Current();
+ current->error = EGL_SUCCESS;
+ current->API = EGL_OPENGL_ES_API;
+ current->display = reinterpret_cast<egl::Display*>(EGL_NO_DISPLAY);
+ current->drawSurface = reinterpret_cast<egl::Surface*>(EGL_NO_SURFACE);
+ current->readSurface = reinterpret_cast<egl::Surface*>(EGL_NO_SURFACE);
+ current->context = reinterpret_cast<gl::Context*>(EGL_NO_CONTEXT);
+
+ if (!SetTLSValue(currentTLS, current))
+ {
+ ERR("Could not set thread local storage.");
+ return NULL;
+ }
+
+ return current;
+}
+
+void DeallocateCurrent()
+{
+ Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS));
+ SafeDelete(current);
+ SetTLSValue(currentTLS, NULL);
+}
+
+Current *GetCurrentData()
+{
+ // Create a TLS index if one has not been created for this DLL
+ if (currentTLS == TLS_INVALID_INDEX)
+ {
+ currentTLS = CreateTLSIndex();
+ }
+
+ Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS));
+
+ // ANGLE issue 488: when the dll is loaded after thread initialization,
+ // thread local storage (current) might not exist yet.
+ return (current ? current : AllocateCurrent());
+}
+
+#ifdef ANGLE_PLATFORM_WINDOWS
+extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD reason, LPVOID)
+{
+ switch (reason)
+ {
+ case DLL_PROCESS_ATTACH:
+ currentTLS = CreateTLSIndex();
+ if (currentTLS == TLS_INVALID_INDEX)
+ {
+ return FALSE;
+ }
+ AllocateCurrent();
+ break;
+
+ case DLL_THREAD_ATTACH:
+ AllocateCurrent();
+ break;
+
+ case DLL_THREAD_DETACH:
+ DeallocateCurrent();
+ break;
+
+ case DLL_PROCESS_DETACH:
+ DeallocateCurrent();
+ if (currentTLS != TLS_INVALID_INDEX)
+ {
+ DestroyTLSIndex(currentTLS);
+ currentTLS = TLS_INVALID_INDEX;
+ }
+ break;
+ }
+
+ return TRUE;
+}
+#endif
+
+}
+
+namespace gl
+{
+
+Context *GetGlobalContext()
+{
+ Current *current = GetCurrentData();
+
+ return current->context;
+}
+
+Context *GetValidGlobalContext()
+{
+ gl::Context *context = GetGlobalContext();
+ if (context)
+ {
+ if (context->isContextLost())
+ {
+ context->recordError(gl::Error(GL_OUT_OF_MEMORY, "Context has been lost."));
+ return nullptr;
+ }
+ else
+ {
+ return context;
+ }
+ }
+ return nullptr;
+}
+
+}
+
+namespace egl
+{
+
+void SetGlobalError(const Error &error)
+{
+ Current *current = GetCurrentData();
+
+ current->error = error.getCode();
+}
+
+EGLint GetGlobalError()
+{
+ Current *current = GetCurrentData();
+
+ return current->error;
+}
+
+EGLenum GetGlobalAPI()
+{
+ Current *current = GetCurrentData();
+
+ return current->API;
+}
+
+void SetGlobalAPI(EGLenum API)
+{
+ Current *current = GetCurrentData();
+
+ current->API = API;
+}
+
+void SetGlobalDisplay(Display *dpy)
+{
+ Current *current = GetCurrentData();
+
+ current->display = dpy;
+}
+
+Display *GetGlobalDisplay()
+{
+ Current *current = GetCurrentData();
+
+ return current->display;
+}
+
+void SetGlobalDrawSurface(Surface *surface)
+{
+ Current *current = GetCurrentData();
+
+ current->drawSurface = surface;
+}
+
+Surface *GetGlobalDrawSurface()
+{
+ Current *current = GetCurrentData();
+
+ return current->drawSurface;
+}
+
+void SetGlobalReadSurface(Surface *surface)
+{
+ Current *current = GetCurrentData();
+
+ current->readSurface = surface;
+}
+
+Surface *GetGlobalReadSurface()
+{
+ Current *current = GetCurrentData();
+
+ return current->readSurface;
+}
+
+void SetGlobalContext(gl::Context *context)
+{
+ Current *current = GetCurrentData();
+
+ current->context = context;
+}
+
+gl::Context *GetGlobalContext()
+{
+ Current *current = GetCurrentData();
+
+ return current->context;
+}
+
+}
diff --git a/src/3rdparty/angle/src/libGLESv2/global_state.h b/src/3rdparty/angle/src/libGLESv2/global_state.h
new file mode 100644
index 0000000000..db202539cb
--- /dev/null
+++ b/src/3rdparty/angle/src/libGLESv2/global_state.h
@@ -0,0 +1,49 @@
+//
+// Copyright(c) 2014 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.
+//
+
+// global_state.h : Defines functions for querying the thread-local GL and EGL state.
+
+#ifndef LIBGLESV2_GLOBALSTATE_H_
+#define LIBGLESV2_GLOBALSTATE_H_
+
+#include <EGL/egl.h>
+
+namespace gl
+{
+class Context;
+
+Context *GetGlobalContext();
+Context *GetValidGlobalContext();
+
+}
+
+namespace egl
+{
+class Error;
+class Display;
+class Surface;
+
+void SetGlobalError(const Error &error);
+EGLint GetGlobalError();
+
+void SetGlobalAPI(EGLenum API);
+EGLenum GetGlobalAPI();
+
+void SetGlobalDisplay(Display *dpy);
+Display *GetGlobalDisplay();
+
+void SetGlobalDrawSurface(Surface *surface);
+Surface *GetGlobalDrawSurface();
+
+void SetGlobalReadSurface(Surface *surface);
+Surface *GetGlobalReadSurface();
+
+void SetGlobalContext(gl::Context *context);
+gl::Context *GetGlobalContext();
+
+}
+
+#endif // LIBGLESV2_GLOBALSTATE_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/libGLESv2.cpp b/src/3rdparty/angle/src/libGLESv2/libGLESv2.cpp
index 587950a139..e69e04aa60 100644
--- a/src/3rdparty/angle/src/libGLESv2/libGLESv2.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/libGLESv2.cpp
@@ -6,8977 +6,1416 @@
// libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions.
-#undef GL_APICALL
-#define GL_APICALL
-#define GL_GLEXT_PROTOTYPES
-
-#include "common/version.h"
-#include "common/utilities.h"
-
-#include "libGLESv2/main.h"
-#include "libGLESv2/formatutils.h"
-#include "libGLESv2/Buffer.h"
-#include "libGLESv2/Fence.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/Renderbuffer.h"
-#include "libGLESv2/Program.h"
-#include "libGLESv2/ProgramBinary.h"
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/Query.h"
-#include "libGLESv2/Context.h"
-#include "libGLESv2/VertexArray.h"
-#include "libGLESv2/VertexAttribute.h"
-#include "libGLESv2/TransformFeedback.h"
-#include "libGLESv2/FramebufferAttachment.h"
-
-#include "libGLESv2/validationES.h"
-#include "libGLESv2/validationES2.h"
-#include "libGLESv2/validationES3.h"
-#include "libGLESv2/queryconversions.h"
+#include "libGLESv2/entry_points_gles_2_0.h"
+#include "libGLESv2/entry_points_gles_2_0_ext.h"
+#include "libGLESv2/entry_points_gles_3_0.h"
+#include "libGLESv2/entry_points_gles_3_0_ext.h"
+
+#include "common/event_tracer.h"
extern "C"
{
-// OpenGL ES 2.0 functions
-
void GL_APIENTRY glActiveTexture(GLenum texture)
{
- EVENT("(GLenum texture = 0x%X)", texture);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- context->getState().setActiveSampler(texture - GL_TEXTURE0);
- }
+ return gl::ActiveTexture(texture);
}
void GL_APIENTRY glAttachShader(GLuint program, GLuint shader)
{
- EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Program *programObject = context->getProgram(program);
- gl::Shader *shaderObject = context->getShader(shader);
-
- if (!programObject)
- {
- if (context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- if (!shaderObject)
- {
- if (context->getProgram(shader))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- if (!programObject->attachShader(shaderObject))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- }
-}
-
-void GL_APIENTRY glBeginQueryEXT(GLenum target, GLuint id)
-{
- EVENT("(GLenum target = 0x%X, GLuint %d)", target, id);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateBeginQuery(context, target, id))
- {
- return;
- }
-
- gl::Error error = context->beginQuery(target, id);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::AttachShader(program, shader);
}
void GL_APIENTRY glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
{
- EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject)
- {
- if (context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- if (strncmp(name, "gl_", 3) == 0)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- programObject->bindAttributeLocation(index, name);
- }
+ return gl::BindAttribLocation(program, index, name);
}
void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer)
{
- EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!gl::ValidBufferTarget(context, target))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (target)
- {
- case GL_ARRAY_BUFFER:
- context->bindArrayBuffer(buffer);
- return;
- case GL_ELEMENT_ARRAY_BUFFER:
- context->bindElementArrayBuffer(buffer);
- return;
- case GL_COPY_READ_BUFFER:
- context->bindCopyReadBuffer(buffer);
- return;
- case GL_COPY_WRITE_BUFFER:
- context->bindCopyWriteBuffer(buffer);
- return;
- case GL_PIXEL_PACK_BUFFER:
- context->bindPixelPackBuffer(buffer);
- return;
- case GL_PIXEL_UNPACK_BUFFER:
- context->bindPixelUnpackBuffer(buffer);
- return;
- case GL_UNIFORM_BUFFER:
- context->bindGenericUniformBuffer(buffer);
- return;
- case GL_TRANSFORM_FEEDBACK_BUFFER:
- context->bindGenericTransformFeedbackBuffer(buffer);
- return;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::BindBuffer(target, buffer);
}
void GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer)
{
- EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!gl::ValidFramebufferTarget(target))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
- {
- context->bindReadFramebuffer(framebuffer);
- }
-
- if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
- {
- context->bindDrawFramebuffer(framebuffer);
- }
- }
+ return gl::BindFramebuffer(target, framebuffer);
}
void GL_APIENTRY glBindRenderbuffer(GLenum target, GLuint renderbuffer)
{
- EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (target != GL_RENDERBUFFER)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- context->bindRenderbuffer(renderbuffer);
- }
+ return gl::BindRenderbuffer(target, renderbuffer);
}
void GL_APIENTRY glBindTexture(GLenum target, GLuint texture)
{
- EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Texture *textureObject = context->getTexture(texture);
-
- if (textureObject && textureObject->getTarget() != target && texture != 0)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- switch (target)
- {
- case GL_TEXTURE_2D:
- case GL_TEXTURE_CUBE_MAP:
- break;
-
- case GL_TEXTURE_3D:
- case GL_TEXTURE_2D_ARRAY:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- context->bindTexture(target, texture);
- }
+ return gl::BindTexture(target, texture);
}
-void GL_APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+void GL_APIENTRY glBlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
{
- EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
- red, green, blue, alpha);
-
- gl::Context* context = gl::getNonLostContext();
-
- if (context)
- {
- context->getState().setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
- }
+ return gl::BlendColor(red, green, blue, alpha);
}
void GL_APIENTRY glBlendEquation(GLenum mode)
{
- glBlendEquationSeparate(mode, mode);
+ return gl::BlendEquation(mode);
}
void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
{
- EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- switch (modeRGB)
- {
- case GL_FUNC_ADD:
- case GL_FUNC_SUBTRACT:
- case GL_FUNC_REVERSE_SUBTRACT:
- case GL_MIN:
- case GL_MAX:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (modeAlpha)
- {
- case GL_FUNC_ADD:
- case GL_FUNC_SUBTRACT:
- case GL_FUNC_REVERSE_SUBTRACT:
- case GL_MIN:
- case GL_MAX:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- context->getState().setBlendEquation(modeRGB, modeAlpha);
- }
+ return gl::BlendEquationSeparate(modeRGB, modeAlpha);
}
void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
{
- glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
+ return gl::BlendFunc(sfactor, dfactor);
}
void GL_APIENTRY glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
{
- EVENT("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)",
- srcRGB, dstRGB, srcAlpha, dstAlpha);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- switch (srcRGB)
- {
- case GL_ZERO:
- case GL_ONE:
- case GL_SRC_COLOR:
- case GL_ONE_MINUS_SRC_COLOR:
- case GL_DST_COLOR:
- case GL_ONE_MINUS_DST_COLOR:
- case GL_SRC_ALPHA:
- case GL_ONE_MINUS_SRC_ALPHA:
- case GL_DST_ALPHA:
- case GL_ONE_MINUS_DST_ALPHA:
- case GL_CONSTANT_COLOR:
- case GL_ONE_MINUS_CONSTANT_COLOR:
- case GL_CONSTANT_ALPHA:
- case GL_ONE_MINUS_CONSTANT_ALPHA:
- case GL_SRC_ALPHA_SATURATE:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (dstRGB)
- {
- case GL_ZERO:
- case GL_ONE:
- case GL_SRC_COLOR:
- case GL_ONE_MINUS_SRC_COLOR:
- case GL_DST_COLOR:
- case GL_ONE_MINUS_DST_COLOR:
- case GL_SRC_ALPHA:
- case GL_ONE_MINUS_SRC_ALPHA:
- case GL_DST_ALPHA:
- case GL_ONE_MINUS_DST_ALPHA:
- case GL_CONSTANT_COLOR:
- case GL_ONE_MINUS_CONSTANT_COLOR:
- case GL_CONSTANT_ALPHA:
- case GL_ONE_MINUS_CONSTANT_ALPHA:
- break;
-
- case GL_SRC_ALPHA_SATURATE:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (srcAlpha)
- {
- case GL_ZERO:
- case GL_ONE:
- case GL_SRC_COLOR:
- case GL_ONE_MINUS_SRC_COLOR:
- case GL_DST_COLOR:
- case GL_ONE_MINUS_DST_COLOR:
- case GL_SRC_ALPHA:
- case GL_ONE_MINUS_SRC_ALPHA:
- case GL_DST_ALPHA:
- case GL_ONE_MINUS_DST_ALPHA:
- case GL_CONSTANT_COLOR:
- case GL_ONE_MINUS_CONSTANT_COLOR:
- case GL_CONSTANT_ALPHA:
- case GL_ONE_MINUS_CONSTANT_ALPHA:
- case GL_SRC_ALPHA_SATURATE:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (dstAlpha)
- {
- case GL_ZERO:
- case GL_ONE:
- case GL_SRC_COLOR:
- case GL_ONE_MINUS_SRC_COLOR:
- case GL_DST_COLOR:
- case GL_ONE_MINUS_DST_COLOR:
- case GL_SRC_ALPHA:
- case GL_ONE_MINUS_SRC_ALPHA:
- case GL_DST_ALPHA:
- case GL_ONE_MINUS_DST_ALPHA:
- case GL_CONSTANT_COLOR:
- case GL_ONE_MINUS_CONSTANT_COLOR:
- case GL_CONSTANT_ALPHA:
- case GL_ONE_MINUS_CONSTANT_ALPHA:
- break;
-
- case GL_SRC_ALPHA_SATURATE:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
- dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
-
- bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
- dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
-
- if (constantColorUsed && constantAlphaUsed)
- {
- ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR invalid under WebGL");
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- context->getState().setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
- }
+ return gl::BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
}
void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
{
- EVENT("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p, GLenum usage = %d)",
- target, size, data, usage);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (size < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- switch (usage)
- {
- case GL_STREAM_DRAW:
- case GL_STATIC_DRAW:
- case GL_DYNAMIC_DRAW:
- break;
-
- case GL_STREAM_READ:
- case GL_STREAM_COPY:
- case GL_STATIC_READ:
- case GL_STATIC_COPY:
- case GL_DYNAMIC_READ:
- case GL_DYNAMIC_COPY:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (!gl::ValidBufferTarget(context, target))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::Buffer *buffer = context->getState().getTargetBuffer(target);
-
- if (!buffer)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- gl::Error error = buffer->bufferData(data, size, usage);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::BufferData(target, size, data, usage);
}
void GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
{
- EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p)",
- target, offset, size, data);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (size < 0 || offset < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- if (data == NULL)
- {
- return;
- }
-
- if (!gl::ValidBufferTarget(context, target))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::Buffer *buffer = context->getState().getTargetBuffer(target);
-
- if (!buffer)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (buffer->isMapped())
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- // Check for possible overflow of size + offset
- if (!rx::IsUnsignedAdditionSafe<size_t>(size, offset))
- {
- context->recordError(gl::Error(GL_OUT_OF_MEMORY));
- return;
- }
-
- if (size + offset > buffer->getSize())
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::Error error = buffer->bufferSubData(data, size, offset);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::BufferSubData(target, offset, size, data);
}
GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target)
{
- EVENT("(GLenum target = 0x%X)", target);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!gl::ValidFramebufferTarget(target))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return 0;
- }
-
- gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
- ASSERT(framebuffer);
-
- return framebuffer->completeness(context->getData());
- }
-
- return 0;
+ return gl::CheckFramebufferStatus(target);
}
void GL_APIENTRY glClear(GLbitfield mask)
{
- EVENT("(GLbitfield mask = 0x%X)", mask);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
- ASSERT(framebufferObject);
-
- if (framebufferObject->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
- {
- context->recordError(gl::Error(GL_INVALID_FRAMEBUFFER_OPERATION));
- return;
- }
-
- if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::Error error = context->clear(mask);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::Clear(mask);
}
-void GL_APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+void GL_APIENTRY glClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
{
- EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
- red, green, blue, alpha);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- context->getState().setClearColor(red, green, blue, alpha);
- }
+ return gl::ClearColor(red, green, blue, alpha);
}
-void GL_APIENTRY glClearDepthf(GLclampf depth)
+void GL_APIENTRY glClearDepthf(GLfloat depth)
{
- EVENT("(GLclampf depth = %f)", depth);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- context->getState().setClearDepth(depth);
- }
+ return gl::ClearDepthf(depth);
}
void GL_APIENTRY glClearStencil(GLint s)
{
- EVENT("(GLint s = %d)", s);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- context->getState().setClearStencil(s);
- }
+ return gl::ClearStencil(s);
}
void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
{
- EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
- red, green, blue, alpha);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- context->getState().setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
- }
+ return gl::ColorMask(red, green, blue, alpha);
}
void GL_APIENTRY glCompileShader(GLuint shader)
{
- EVENT("(GLuint shader = %d)", shader);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Shader *shaderObject = context->getShader(shader);
-
- if (!shaderObject)
- {
- if (context->getProgram(shader))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- shaderObject->compile(context->getData());
- }
-}
-
-void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
- GLint border, GLsizei imageSize, const GLvoid* data)
-{
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
- "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
- target, level, internalformat, width, height, border, imageSize, data);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3 &&
- !ValidateES2TexImageParameters(context, target, level, internalformat, true, false,
- 0, 0, width, height, border, GL_NONE, GL_NONE, data))
- {
- return;
- }
-
- if (context->getClientVersion() >= 3 &&
- !ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
- 0, 0, 0, width, height, 1, border, GL_NONE, GL_NONE, data))
- {
- return;
- }
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
- if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- switch (target)
- {
- case GL_TEXTURE_2D:
- {
- gl::Texture2D *texture = context->getTexture2D();
- gl::Error error = texture->setCompressedImage(level, internalformat, width, height, imageSize, context->getState().getUnpackState(), data);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- {
- gl::TextureCubeMap *texture = context->getTextureCubeMap();
- gl::Error error = texture->setCompressedImage(target, level, internalformat, width, height, imageSize, context->getState().getUnpackState(), data);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
-}
-
-void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
- GLenum format, GLsizei imageSize, const GLvoid* data)
-{
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
- "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
- "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
- target, level, xoffset, yoffset, width, height, format, imageSize, data);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3 &&
- !ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true,
- xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
- {
- return;
- }
-
- if (context->getClientVersion() >= 3 &&
- !ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
- xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data))
- {
- return;
- }
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
- if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- switch (target)
- {
- case GL_TEXTURE_2D:
- {
- gl::Texture2D *texture = context->getTexture2D();
- gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, context->getState().getUnpackState(), data);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- {
- gl::TextureCubeMap *texture = context->getTextureCubeMap();
- gl::Error error = texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, context->getState().getUnpackState(), data);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::CompileShader(shader);
+}
+
+void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data)
+{
+ return gl::CompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
+}
+
+void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data)
+{
+ return gl::CompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
}
void GL_APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
{
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
- "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
- target, level, internalformat, x, y, width, height, border);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3 &&
- !ValidateES2CopyTexImageParameters(context, target, level, internalformat, false,
- 0, 0, x, y, width, height, border))
- {
- return;
- }
-
- if (context->getClientVersion() >= 3 &&
- !ValidateES3CopyTexImageParameters(context, target, level, internalformat, false,
- 0, 0, 0, x, y, width, height, border))
- {
- return;
- }
-
- gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
-
- switch (target)
- {
- case GL_TEXTURE_2D:
- {
- gl::Texture2D *texture = context->getTexture2D();
- gl::Error error = texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- {
- gl::TextureCubeMap *texture = context->getTextureCubeMap();
- gl::Error error = texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::CopyTexImage2D(target, level, internalformat, x, y, width, height, border);
}
void GL_APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
{
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
- "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
- target, level, xoffset, yoffset, x, y, width, height);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3 &&
- !ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
- xoffset, yoffset, x, y, width, height, 0))
- {
- return;
- }
-
- if (context->getClientVersion() >= 3 &&
- !ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
- xoffset, yoffset, 0, x, y, width, height, 0))
- {
- return;
- }
-
- gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
-
- switch (target)
- {
- case GL_TEXTURE_2D:
- {
- gl::Texture2D *texture = context->getTexture2D();
- gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- {
- gl::TextureCubeMap *texture = context->getTextureCubeMap();
- gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
}
GLuint GL_APIENTRY glCreateProgram(void)
{
- EVENT("()");
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- return context->createProgram();
- }
-
- return 0;
+ return gl::CreateProgram();
}
GLuint GL_APIENTRY glCreateShader(GLenum type)
{
- EVENT("(GLenum type = 0x%X)", type);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- switch (type)
- {
- case GL_FRAGMENT_SHADER:
- case GL_VERTEX_SHADER:
- return context->createShader(type);
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return 0;
- }
- }
-
- return 0;
+ return gl::CreateShader(type);
}
void GL_APIENTRY glCullFace(GLenum mode)
{
- EVENT("(GLenum mode = 0x%X)", mode);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- switch (mode)
- {
- case GL_FRONT:
- case GL_BACK:
- case GL_FRONT_AND_BACK:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- context->getState().setCullMode(mode);
- }
+ return gl::CullFace(mode);
}
void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers)
{
- EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (n < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (int i = 0; i < n; i++)
- {
- context->deleteBuffer(buffers[i]);
- }
- }
-}
-
-void GL_APIENTRY glDeleteFencesNV(GLsizei n, const GLuint* fences)
-{
- EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (n < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (int i = 0; i < n; i++)
- {
- context->deleteFenceNV(fences[i]);
- }
- }
+ return gl::DeleteBuffers(n, buffers);
}
void GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
{
- EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (n < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (int i = 0; i < n; i++)
- {
- if (framebuffers[i] != 0)
- {
- context->deleteFramebuffer(framebuffers[i]);
- }
- }
- }
+ return gl::DeleteFramebuffers(n, framebuffers);
}
void GL_APIENTRY glDeleteProgram(GLuint program)
{
- EVENT("(GLuint program = %d)", program);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (program == 0)
- {
- return;
- }
-
- if (!context->getProgram(program))
- {
- if(context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- context->deleteProgram(program);
- }
-}
-
-void GL_APIENTRY glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
-{
- EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (n < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (int i = 0; i < n; i++)
- {
- context->deleteQuery(ids[i]);
- }
- }
+ return gl::DeleteProgram(program);
}
void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
{
- EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (n < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (int i = 0; i < n; i++)
- {
- context->deleteRenderbuffer(renderbuffers[i]);
- }
- }
+ return gl::DeleteRenderbuffers(n, renderbuffers);
}
void GL_APIENTRY glDeleteShader(GLuint shader)
{
- EVENT("(GLuint shader = %d)", shader);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (shader == 0)
- {
- return;
- }
-
- if (!context->getShader(shader))
- {
- if(context->getProgram(shader))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- context->deleteShader(shader);
- }
+ return gl::DeleteShader(shader);
}
void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures)
{
- EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (n < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (int i = 0; i < n; i++)
- {
- if (textures[i] != 0)
- {
- context->deleteTexture(textures[i]);
- }
- }
- }
+ return gl::DeleteTextures(n, textures);
}
void GL_APIENTRY glDepthFunc(GLenum func)
{
- EVENT("(GLenum func = 0x%X)", func);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- switch (func)
- {
- case GL_NEVER:
- case GL_ALWAYS:
- case GL_LESS:
- case GL_LEQUAL:
- case GL_EQUAL:
- case GL_GREATER:
- case GL_GEQUAL:
- case GL_NOTEQUAL:
- context->getState().setDepthFunc(func);
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::DepthFunc(func);
}
void GL_APIENTRY glDepthMask(GLboolean flag)
{
- EVENT("(GLboolean flag = %u)", flag);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- context->getState().setDepthMask(flag != GL_FALSE);
- }
+ return gl::DepthMask(flag);
}
-void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar)
+void GL_APIENTRY glDepthRangef(GLfloat n, GLfloat f)
{
- EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- context->getState().setDepthRange(zNear, zFar);
- }
+ return gl::DepthRangef(n, f);
}
void GL_APIENTRY glDetachShader(GLuint program, GLuint shader)
{
- EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Program *programObject = context->getProgram(program);
- gl::Shader *shaderObject = context->getShader(shader);
-
- if (!programObject)
- {
- gl::Shader *shaderByProgramHandle;
- shaderByProgramHandle = context->getShader(program);
- if (!shaderByProgramHandle)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- }
-
- if (!shaderObject)
- {
- gl::Program *programByShaderHandle = context->getProgram(shader);
- if (!programByShaderHandle)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- }
-
- if (!programObject->detachShader(shaderObject))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- }
+ return gl::DetachShader(program, shader);
}
void GL_APIENTRY glDisable(GLenum cap)
{
- EVENT("(GLenum cap = 0x%X)", cap);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidCap(context, cap))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- context->getState().setEnableFeature(cap, false);
- }
+ return gl::Disable(cap);
}
void GL_APIENTRY glDisableVertexAttribArray(GLuint index)
{
- EVENT("(GLuint index = %d)", index);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- context->getState().setEnableVertexAttribArray(index, false);
- }
+ return gl::DisableVertexAttribArray(index);
}
void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count)
{
- EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateDrawArrays(context, mode, first, count, 0))
- {
- return;
- }
-
- gl::Error error = context->drawArrays(mode, first, count, 0);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
-}
-
-void GL_APIENTRY glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
-{
- EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateDrawArraysInstancedANGLE(context, mode, first, count, primcount))
- {
- return;
- }
-
- gl::Error error = context->drawArrays(mode, first, count, primcount);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::DrawArrays(mode, first, count);
}
void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
{
- EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p)",
- mode, count, type, indices);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- rx::RangeUI indexRange;
- if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange))
- {
- return;
- }
-
- gl::Error error = context->drawElements(mode, count, type, indices, 0, indexRange);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
-}
-
-void GL_APIENTRY glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
-{
- EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
- mode, count, type, indices, primcount);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- rx::RangeUI indexRange;
- if (!ValidateDrawElementsInstancedANGLE(context, mode, count, type, indices, primcount, &indexRange))
- {
- return;
- }
-
- gl::Error error = context->drawElements(mode, count, type, indices, primcount, indexRange);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::DrawElements(mode, count, type, indices);
}
void GL_APIENTRY glEnable(GLenum cap)
{
- EVENT("(GLenum cap = 0x%X)", cap);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidCap(context, cap))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- context->getState().setEnableFeature(cap, true);
- }
+ return gl::Enable(cap);
}
void GL_APIENTRY glEnableVertexAttribArray(GLuint index)
{
- EVENT("(GLuint index = %d)", index);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- context->getState().setEnableVertexAttribArray(index, true);
- }
-}
-
-void GL_APIENTRY glEndQueryEXT(GLenum target)
-{
- EVENT("GLenum target = 0x%X)", target);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateEndQuery(context, target))
- {
- return;
- }
-
- gl::Error error = context->endQuery(target);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
-}
-
-void GL_APIENTRY glFinishFenceNV(GLuint fence)
-{
- EVENT("(GLuint fence = %d)", fence);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::FenceNV *fenceObject = context->getFenceNV(fence);
-
- if (fenceObject == NULL)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (fenceObject->isFence() != GL_TRUE)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- fenceObject->finishFence();
- }
+ return gl::EnableVertexAttribArray(index);
}
void GL_APIENTRY glFinish(void)
{
- EVENT("()");
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Error error = context->sync(true);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::Finish();
}
void GL_APIENTRY glFlush(void)
{
- EVENT("()");
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Error error = context->sync(false);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::Flush();
}
void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
{
- EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
- "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!gl::ValidFramebufferTarget(target) || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (!gl::ValidateFramebufferRenderbufferParameters(context, target, attachment, renderbuffertarget, renderbuffer))
- {
- return;
- }
-
- gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
- ASSERT(framebuffer);
-
- if (renderbuffer != 0)
- {
- gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
- framebuffer->setRenderbufferAttachment(attachment, renderbufferObject);
- }
- else
- {
- framebuffer->setNULLAttachment(attachment);
- }
- }
+ return gl::FramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
}
void GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
{
- EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
- "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateFramebufferTexture2D(context, target, attachment, textarget, texture, level))
- {
- return;
- }
-
- gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
- ASSERT(framebuffer);
-
- if (texture != 0)
- {
- gl::Texture *textureObj = context->getTexture(texture);
- gl::ImageIndex index(textarget, level, gl::ImageIndex::ENTIRE_LEVEL);
- framebuffer->setTextureAttachment(attachment, textureObj, index);
- }
- else
- {
- framebuffer->setNULLAttachment(attachment);
- }
- }
+ return gl::FramebufferTexture2D(target, attachment, textarget, texture, level);
}
void GL_APIENTRY glFrontFace(GLenum mode)
{
- EVENT("(GLenum mode = 0x%X)", mode);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- switch (mode)
- {
- case GL_CW:
- case GL_CCW:
- context->getState().setFrontFace(mode);
- break;
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::FrontFace(mode);
}
void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers)
{
- EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (n < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (int i = 0; i < n; i++)
- {
- buffers[i] = context->createBuffer();
- }
- }
+ return gl::GenBuffers(n, buffers);
}
void GL_APIENTRY glGenerateMipmap(GLenum target)
{
- EVENT("(GLenum target = 0x%X)", target);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidTextureTarget(context, target))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::Texture *texture = context->getTargetTexture(target);
-
- if (texture == NULL)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- GLenum internalFormat = texture->getBaseLevelInternalFormat();
- const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat);
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
-
- // GenerateMipmap should not generate an INVALID_OPERATION for textures created with
- // unsized formats or that are color renderable and filterable. Since we do not track if
- // the texture was created with sized or unsized format (only sized formats are stored),
- // it is not possible to make sure the the LUMA formats can generate mipmaps (they should
- // be able to) because they aren't color renderable. Simply do a special case for LUMA
- // textures since they're the only texture format that can be created with unsized formats
- // that is not color renderable. New unsized formats are unlikely to be added, since ES2
- // was the last version to use add them.
- bool isLUMA = internalFormat == GL_LUMINANCE8_EXT ||
- internalFormat == GL_LUMINANCE8_ALPHA8_EXT ||
- internalFormat == GL_ALPHA8_EXT;
-
- if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0 || !formatCaps.filterable ||
- (!formatCaps.renderable && !isLUMA) || formatInfo.compressed)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- // GL_EXT_sRGB does not support mipmap generation on sRGB textures
- if (context->getClientVersion() == 2 && formatInfo.colorEncoding == GL_SRGB)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- // Non-power of 2 ES2 check
- if (!context->getExtensions().textureNPOT && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight())))
- {
- ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP));
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- // Cube completeness check
- if (target == GL_TEXTURE_CUBE_MAP)
- {
- gl::TextureCubeMap *textureCube = static_cast<gl::TextureCubeMap *>(texture);
- if (!textureCube->isCubeComplete())
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- }
-
- gl::Error error = texture->generateMipmaps();
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
-}
-
-void GL_APIENTRY glGenFencesNV(GLsizei n, GLuint* fences)
-{
- EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (n < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (int i = 0; i < n; i++)
- {
- fences[i] = context->createFenceNV();
- }
- }
+ return gl::GenerateMipmap(target);
}
void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers)
{
- EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (n < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (int i = 0; i < n; i++)
- {
- framebuffers[i] = context->createFramebuffer();
- }
- }
+ return gl::GenFramebuffers(n, framebuffers);
}
-void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint* ids)
+void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
{
- EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (n < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (GLsizei i = 0; i < n; i++)
- {
- ids[i] = context->createQuery();
- }
- }
+ return gl::GenRenderbuffers(n, renderbuffers);
}
-void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
+void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures)
{
- EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (n < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (int i = 0; i < n; i++)
- {
- renderbuffers[i] = context->createRenderbuffer();
- }
- }
+ return gl::GenTextures(n, textures);
}
-void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures)
+void GL_APIENTRY glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
{
- EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (n < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (int i = 0; i < n; i++)
- {
- textures[i] = context->createTexture();
- }
- }
-}
-
-void GL_APIENTRY glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
-{
- EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
- "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
- program, index, bufsize, length, size, type, name);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (bufsize < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject)
- {
- if (context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- if (index >= (GLuint)programObject->getActiveAttributeCount())
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- programObject->getActiveAttribute(index, bufsize, length, size, type, name);
- }
+ return gl::GetActiveAttrib(program, index, bufsize, length, size, type, name);
}
void GL_APIENTRY glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
{
- EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
- "GLsizei* length = 0x%0.8p, GLint* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
- program, index, bufsize, length, size, type, name);
-
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (bufsize < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject)
- {
- if (context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- if (index >= (GLuint)programObject->getActiveUniformCount())
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- programObject->getActiveUniform(index, bufsize, length, size, type, name);
- }
+ return gl::GetActiveUniform(program, index, bufsize, length, size, type, name);
}
void GL_APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
{
- EVENT("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = 0x%0.8p, GLuint* shaders = 0x%0.8p)",
- program, maxcount, count, shaders);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (maxcount < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject)
- {
- if (context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- return programObject->getAttachedShaders(maxcount, count, shaders);
- }
+ return gl::GetAttachedShaders(program, maxcount, count, shaders);
}
GLint GL_APIENTRY glGetAttribLocation(GLuint program, const GLchar* name)
{
- EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject)
- {
- if (context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return -1;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return -1;
- }
- }
-
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
- if (!programObject->isLinked() || !programBinary)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return -1;
- }
-
- return programBinary->getAttributeLocation(name);
- }
-
- return -1;
+ return gl::GetAttribLocation(program, name);
}
void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params)
{
- EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- GLenum nativeType;
- unsigned int numParams = 0;
- if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
- {
- return;
- }
-
- if (nativeType == GL_BOOL)
- {
- context->getBooleanv(pname, params);
- }
- else
- {
- CastStateValues(context, nativeType, pname, numParams, params);
- }
- }
+ return gl::GetBooleanv(pname, params);
}
void GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
{
- EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!gl::ValidBufferTarget(context, target))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (!gl::ValidBufferParameter(context, pname))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::Buffer *buffer = context->getState().getTargetBuffer(target);
-
- if (!buffer)
- {
- // A null buffer means that "0" is bound to the requested buffer target
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- switch (pname)
- {
- case GL_BUFFER_USAGE:
- *params = static_cast<GLint>(buffer->getUsage());
- break;
- case GL_BUFFER_SIZE:
- *params = gl::clampCast<GLint>(buffer->getSize());
- break;
- case GL_BUFFER_ACCESS_FLAGS:
- *params = buffer->getAccessFlags();
- break;
- case GL_BUFFER_MAPPED:
- *params = static_cast<GLint>(buffer->isMapped());
- break;
- case GL_BUFFER_MAP_OFFSET:
- *params = gl::clampCast<GLint>(buffer->getMapOffset());
- break;
- case GL_BUFFER_MAP_LENGTH:
- *params = gl::clampCast<GLint>(buffer->getMapLength());
- break;
- default: UNREACHABLE(); break;
- }
- }
+ return gl::GetBufferParameteriv(target, pname, params);
}
GLenum GL_APIENTRY glGetError(void)
{
- EVENT("()");
-
- gl::Context *context = gl::getContext();
-
- if (context)
- {
- return context->getError();
- }
-
- return GL_NO_ERROR;
-}
-
-void GL_APIENTRY glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
-{
- EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::FenceNV *fenceObject = context->getFenceNV(fence);
-
- if (fenceObject == NULL)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (fenceObject->isFence() != GL_TRUE)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- switch (pname)
- {
- case GL_FENCE_STATUS_NV:
- {
- // GL_NV_fence spec:
- // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
- // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
- GLboolean status = GL_TRUE;
- if (fenceObject->getStatus() != GL_TRUE)
- {
- gl::Error error = fenceObject->testFence(&status);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- *params = status;
- break;
- }
-
- case GL_FENCE_CONDITION_NV:
- {
- *params = fenceObject->getCondition();
- break;
- }
-
- default:
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
- }
+ return gl::GetError();
}
void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params)
{
- EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- GLenum nativeType;
- unsigned int numParams = 0;
- if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
- {
- return;
- }
-
- if (nativeType == GL_FLOAT)
- {
- context->getFloatv(pname, params);
- }
- else
- {
- CastStateValues(context, nativeType, pname, numParams, params);
- }
- }
+ return gl::GetFloatv(pname, params);
}
void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
{
- EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
- target, attachment, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!gl::ValidFramebufferTarget(target))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- int clientVersion = context->getClientVersion();
-
- switch (pname)
- {
- case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
- case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
- case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
- case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
- break;
-
- case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
- if (clientVersion < 3 && !context->getExtensions().sRGB)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- break;
-
- case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
- case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
- case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
- case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
- case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
- case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
- case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
- case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
- if (clientVersion < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- // Determine if the attachment is a valid enum
- switch (attachment)
- {
- case GL_BACK:
- case GL_FRONT:
- case GL_DEPTH:
- case GL_STENCIL:
- case GL_DEPTH_STENCIL_ATTACHMENT:
- if (clientVersion < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- break;
-
- case GL_DEPTH_ATTACHMENT:
- case GL_STENCIL_ATTACHMENT:
- break;
-
- default:
- if (attachment < GL_COLOR_ATTACHMENT0_EXT ||
- (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- break;
- }
-
- GLuint framebufferHandle = context->getState().getTargetFramebuffer(target)->id();
- gl::Framebuffer *framebuffer = context->getFramebuffer(framebufferHandle);
- ASSERT(framebuffer);
-
- if (framebufferHandle == 0)
- {
- if (clientVersion < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- switch (attachment)
- {
- case GL_BACK:
- case GL_DEPTH:
- case GL_STENCIL:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- }
- else
- {
- if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
- {
- // Valid attachment query
- }
- else
- {
- switch (attachment)
- {
- case GL_DEPTH_ATTACHMENT:
- case GL_STENCIL_ATTACHMENT:
- break;
-
- case GL_DEPTH_STENCIL_ATTACHMENT:
- if (framebuffer->hasValidDepthStencil())
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- }
- }
-
- GLenum attachmentType = GL_NONE;
- GLuint attachmentHandle = 0;
- GLuint attachmentLevel = 0;
- GLuint attachmentLayer = 0;
-
- const gl::FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
-
- if (attachmentObject)
- {
- attachmentType = attachmentObject->type();
- attachmentHandle = attachmentObject->id();
- attachmentLevel = attachmentObject->mipLevel();
- attachmentLayer = attachmentObject->layer();
- }
-
- GLenum attachmentObjectType; // Type category
- if (framebufferHandle == 0)
- {
- attachmentObjectType = GL_FRAMEBUFFER_DEFAULT;
- }
- else if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
- {
- attachmentObjectType = attachmentType;
- }
- else if (gl::ValidTexture2DDestinationTarget(context, attachmentType))
- {
- attachmentObjectType = GL_TEXTURE;
- }
- else
- {
- UNREACHABLE();
- return;
- }
-
- if (attachmentObjectType == GL_NONE)
- {
- // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
- // is NONE, then querying any other pname will generate INVALID_ENUM.
-
- // ES 3.0.2 spec pg 235 states that if the attachment type is none,
- // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
- // INVALID_OPERATION for all other pnames
-
- switch (pname)
- {
- case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
- *params = attachmentObjectType;
- break;
-
- case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
- if (clientVersion < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = 0;
- break;
-
- default:
- if (clientVersion < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- }
- }
- else
- {
- ASSERT(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE ||
- attachmentObjectType == GL_FRAMEBUFFER_DEFAULT);
- ASSERT(attachmentObject != NULL);
-
- switch (pname)
- {
- case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
- *params = attachmentObjectType;
- break;
-
- case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
- if (attachmentObjectType != GL_RENDERBUFFER && attachmentObjectType != GL_TEXTURE)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = attachmentHandle;
- break;
-
- case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
- if (attachmentObjectType != GL_TEXTURE)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = attachmentLevel;
- break;
-
- case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
- if (attachmentObjectType != GL_TEXTURE)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = gl::IsCubemapTextureTarget(attachmentType) ? attachmentType : 0;
- break;
-
- case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
- *params = attachmentObject->getRedSize();
- break;
-
- case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
- *params = attachmentObject->getGreenSize();
- break;
-
- case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
- *params = attachmentObject->getBlueSize();
- break;
-
- case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
- *params = attachmentObject->getAlphaSize();
- break;
-
- case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
- *params = attachmentObject->getDepthSize();
- break;
-
- case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
- *params = attachmentObject->getStencilSize();
- break;
-
- case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
- if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- *params = attachmentObject->getComponentType();
- break;
-
- case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
- *params = attachmentObject->getColorEncoding();
- break;
-
- case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
- if (attachmentObjectType != GL_TEXTURE)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = attachmentLayer;
- break;
-
- default:
- UNREACHABLE();
- break;
- }
- }
- }
-}
-
-GLenum GL_APIENTRY glGetGraphicsResetStatusEXT(void)
-{
- EVENT("()");
-
- gl::Context *context = gl::getContext();
-
- if (context)
- {
- return context->getResetStatus();
- }
-
- return GL_NO_ERROR;
+ return gl::GetFramebufferAttachmentParameteriv(target, attachment, pname, params);
}
void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params)
{
- EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- GLenum nativeType;
- unsigned int numParams = 0;
-
- if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
- {
- return;
- }
-
- if (nativeType == GL_INT)
- {
- context->getIntegerv(pname, params);
- }
- else
- {
- CastStateValues(context, nativeType, pname, numParams, params);
- }
- }
+ return gl::GetIntegerv(pname, params);
}
void GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params)
{
- EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- if (context->getClientVersion() < 3)
- {
- switch (pname)
- {
- case GL_ACTIVE_UNIFORM_BLOCKS:
- case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
- case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
- case GL_TRANSFORM_FEEDBACK_VARYINGS:
- case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
-
- switch (pname)
- {
- case GL_DELETE_STATUS:
- *params = programObject->isFlaggedForDeletion();
- return;
- case GL_LINK_STATUS:
- *params = programObject->isLinked();
- return;
- case GL_VALIDATE_STATUS:
- *params = programObject->isValidated();
- return;
- case GL_INFO_LOG_LENGTH:
- *params = programObject->getInfoLogLength();
- return;
- case GL_ATTACHED_SHADERS:
- *params = programObject->getAttachedShadersCount();
- return;
- case GL_ACTIVE_ATTRIBUTES:
- *params = programObject->getActiveAttributeCount();
- return;
- case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
- *params = programObject->getActiveAttributeMaxLength();
- return;
- case GL_ACTIVE_UNIFORMS:
- *params = programObject->getActiveUniformCount();
- return;
- case GL_ACTIVE_UNIFORM_MAX_LENGTH:
- *params = programObject->getActiveUniformMaxLength();
- return;
- case GL_PROGRAM_BINARY_LENGTH_OES:
- *params = programObject->getProgramBinaryLength();
- return;
- case GL_ACTIVE_UNIFORM_BLOCKS:
- *params = programObject->getActiveUniformBlockCount();
- return;
- case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
- *params = programObject->getActiveUniformBlockMaxLength();
- break;
- case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
- *params = programObject->getTransformFeedbackBufferMode();
- break;
- case GL_TRANSFORM_FEEDBACK_VARYINGS:
- *params = programObject->getTransformFeedbackVaryingCount();
- break;
- case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
- *params = programObject->getTransformFeedbackVaryingMaxLength();
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::GetProgramiv(program, pname, params);
}
void GL_APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
{
- EVENT("(GLuint program = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
- program, bufsize, length, infolog);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (bufsize < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- programObject->getInfoLog(bufsize, length, infolog);
- }
-}
-
-void GL_APIENTRY glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
-{
- EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidQueryType(context, target))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (pname)
- {
- case GL_CURRENT_QUERY_EXT:
- params[0] = context->getState().getActiveQueryId(target);
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
-}
-
-void GL_APIENTRY glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
-{
- EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
-
- if (!queryObject)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (context->getState().getActiveQueryId(queryObject->getType()) == id)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- switch(pname)
- {
- case GL_QUERY_RESULT_EXT:
- {
- gl::Error error = queryObject->getResult(params);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- case GL_QUERY_RESULT_AVAILABLE_EXT:
- {
- gl::Error error = queryObject->isResultAvailable(params);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::GetProgramInfoLog(program, bufsize, length, infolog);
}
void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
{
- EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (target != GL_RENDERBUFFER)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (context->getState().getRenderbufferId() == 0)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getState().getRenderbufferId());
-
- switch (pname)
- {
- case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
- case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
- case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
- case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
- case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
- case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
- case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
- case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
- case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
-
- case GL_RENDERBUFFER_SAMPLES_ANGLE:
- if (!context->getExtensions().framebufferMultisample)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = renderbuffer->getSamples();
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::GetRenderbufferParameteriv(target, pname, params);
}
void GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
{
- EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Shader *shaderObject = context->getShader(shader);
-
- if (!shaderObject)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- switch (pname)
- {
- case GL_SHADER_TYPE:
- *params = shaderObject->getType();
- return;
- case GL_DELETE_STATUS:
- *params = shaderObject->isFlaggedForDeletion();
- return;
- case GL_COMPILE_STATUS:
- *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
- return;
- case GL_INFO_LOG_LENGTH:
- *params = shaderObject->getInfoLogLength();
- return;
- case GL_SHADER_SOURCE_LENGTH:
- *params = shaderObject->getSourceLength();
- return;
- case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
- *params = shaderObject->getTranslatedSourceLength();
- return;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::GetShaderiv(shader, pname, params);
}
void GL_APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
{
- EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
- shader, bufsize, length, infolog);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (bufsize < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::Shader *shaderObject = context->getShader(shader);
-
- if (!shaderObject)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- shaderObject->getInfoLog(bufsize, length, infolog);
- }
+ return gl::GetShaderInfoLog(shader, bufsize, length, infolog);
}
void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
{
- EVENT("(GLenum shadertype = 0x%X, GLenum precisiontype = 0x%X, GLint* range = 0x%0.8p, GLint* precision = 0x%0.8p)",
- shadertype, precisiontype, range, precision);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- switch (shadertype)
- {
- case GL_VERTEX_SHADER:
- case GL_FRAGMENT_SHADER:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (precisiontype)
- {
- case GL_LOW_FLOAT:
- case GL_MEDIUM_FLOAT:
- case GL_HIGH_FLOAT:
- // Assume IEEE 754 precision
- range[0] = 127;
- range[1] = 127;
- *precision = 23;
- break;
-
- case GL_LOW_INT:
- case GL_MEDIUM_INT:
- case GL_HIGH_INT:
- // Some (most) hardware only supports single-precision floating-point numbers,
- // which can accurately represent integers up to +/-16777216
- range[0] = 24;
- range[1] = 24;
- *precision = 0;
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::GetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
}
void GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
{
- EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
- shader, bufsize, length, source);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (bufsize < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::Shader *shaderObject = context->getShader(shader);
-
- if (!shaderObject)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- shaderObject->getSource(bufsize, length, source);
- }
-}
-
-void GL_APIENTRY glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
-{
- EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
- shader, bufsize, length, source);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (bufsize < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::Shader *shaderObject = context->getShader(shader);
-
- if (!shaderObject)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- // Only returns extra info if ANGLE_GENERATE_SHADER_DEBUG_INFO is defined
- shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source);
- }
+ return gl::GetShaderSource(shader, bufsize, length, source);
}
const GLubyte* GL_APIENTRY glGetString(GLenum name)
{
- EVENT("(GLenum name = 0x%X)", name);
-
- gl::Context *context = gl::getNonLostContext();
-
- switch (name)
- {
- case GL_VENDOR:
- return (GLubyte*)"Google Inc.";
-
- case GL_RENDERER:
- return (GLubyte*)((context != NULL) ? context->getRendererString().c_str() : "ANGLE");
-
- case GL_VERSION:
- if (context->getClientVersion() == 2)
- {
- return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")";
- }
- else
- {
- return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")";
- }
-
- case GL_SHADING_LANGUAGE_VERSION:
- if (context->getClientVersion() == 2)
- {
- return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")";
- }
- else
- {
- return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")";
- }
-
- case GL_EXTENSIONS:
- return (GLubyte*)((context != NULL) ? context->getExtensionString().c_str() : "");
-
- default:
- if (context)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- }
- return NULL;
- }
+ return gl::GetString(name);
}
void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
{
- EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", target, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Texture *texture = context->getTargetTexture(target);
-
- if (!texture)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (pname)
- {
- case GL_TEXTURE_MAG_FILTER:
- *params = (GLfloat)texture->getSamplerState().magFilter;
- break;
- case GL_TEXTURE_MIN_FILTER:
- *params = (GLfloat)texture->getSamplerState().minFilter;
- break;
- case GL_TEXTURE_WRAP_S:
- *params = (GLfloat)texture->getSamplerState().wrapS;
- break;
- case GL_TEXTURE_WRAP_T:
- *params = (GLfloat)texture->getSamplerState().wrapT;
- break;
- case GL_TEXTURE_WRAP_R:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = (GLfloat)texture->getSamplerState().wrapR;
- break;
- case GL_TEXTURE_IMMUTABLE_FORMAT:
- // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
- *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
- break;
- case GL_TEXTURE_IMMUTABLE_LEVELS:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = (GLfloat)texture->immutableLevelCount();
- break;
- case GL_TEXTURE_USAGE_ANGLE:
- *params = (GLfloat)texture->getUsage();
- break;
- case GL_TEXTURE_MAX_ANISOTROPY_EXT:
- if (!context->getExtensions().textureFilterAnisotropic)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = (GLfloat)texture->getSamplerState().maxAnisotropy;
- break;
- case GL_TEXTURE_SWIZZLE_R:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = (GLfloat)texture->getSamplerState().swizzleRed;
- break;
- case GL_TEXTURE_SWIZZLE_G:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = (GLfloat)texture->getSamplerState().swizzleGreen;
- break;
- case GL_TEXTURE_SWIZZLE_B:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = (GLfloat)texture->getSamplerState().swizzleBlue;
- break;
- case GL_TEXTURE_SWIZZLE_A:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = (GLfloat)texture->getSamplerState().swizzleAlpha;
- break;
- case GL_TEXTURE_BASE_LEVEL:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = (GLfloat)texture->getSamplerState().baseLevel;
- break;
- case GL_TEXTURE_MAX_LEVEL:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = (GLfloat)texture->getSamplerState().maxLevel;
- break;
- case GL_TEXTURE_MIN_LOD:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = texture->getSamplerState().minLod;
- break;
- case GL_TEXTURE_MAX_LOD:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = texture->getSamplerState().maxLod;
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::GetTexParameterfv(target, pname, params);
}
void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
{
- EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Texture *texture = context->getTargetTexture(target);
-
- if (!texture)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (pname)
- {
- case GL_TEXTURE_MAG_FILTER:
- *params = texture->getSamplerState().magFilter;
- break;
- case GL_TEXTURE_MIN_FILTER:
- *params = texture->getSamplerState().minFilter;
- break;
- case GL_TEXTURE_WRAP_S:
- *params = texture->getSamplerState().wrapS;
- break;
- case GL_TEXTURE_WRAP_T:
- *params = texture->getSamplerState().wrapT;
- break;
- case GL_TEXTURE_WRAP_R:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = texture->getSamplerState().wrapR;
- break;
- case GL_TEXTURE_IMMUTABLE_FORMAT:
- // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
- *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
- break;
- case GL_TEXTURE_IMMUTABLE_LEVELS:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = static_cast<GLint>(texture->immutableLevelCount());
- break;
- case GL_TEXTURE_USAGE_ANGLE:
- *params = texture->getUsage();
- break;
- case GL_TEXTURE_MAX_ANISOTROPY_EXT:
- if (!context->getExtensions().textureFilterAnisotropic)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = (GLint)texture->getSamplerState().maxAnisotropy;
- break;
- case GL_TEXTURE_SWIZZLE_R:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = texture->getSamplerState().swizzleRed;
- break;
- case GL_TEXTURE_SWIZZLE_G:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = texture->getSamplerState().swizzleGreen;
- break;
- case GL_TEXTURE_SWIZZLE_B:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = texture->getSamplerState().swizzleBlue;
- break;
- case GL_TEXTURE_SWIZZLE_A:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = texture->getSamplerState().swizzleAlpha;
- break;
- case GL_TEXTURE_BASE_LEVEL:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = texture->getSamplerState().baseLevel;
- break;
- case GL_TEXTURE_MAX_LEVEL:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = texture->getSamplerState().maxLevel;
- break;
- case GL_TEXTURE_MIN_LOD:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = (GLint)texture->getSamplerState().minLod;
- break;
- case GL_TEXTURE_MAX_LOD:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- *params = (GLint)texture->getSamplerState().maxLod;
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
-}
-
-void GL_APIENTRY glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
-{
- EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
- program, location, bufSize, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateGetnUniformfvEXT(context, program, location, bufSize, params))
- {
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
- ASSERT(programObject);
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
- ASSERT(programBinary);
-
- programBinary->getUniformfv(location, params);
- }
+ return gl::GetTexParameteriv(target, pname, params);
}
void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params)
{
- EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateGetUniformfv(context, program, location, params))
- {
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
- ASSERT(programObject);
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
- ASSERT(programBinary);
-
- programBinary->getUniformfv(location, params);
- }
-}
-
-void GL_APIENTRY glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
-{
- EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
- program, location, bufSize, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateGetnUniformivEXT(context, program, location, bufSize, params))
- {
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
- ASSERT(programObject);
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
- ASSERT(programBinary);
-
- programBinary->getUniformiv(location, params);
- }
+ return gl::GetUniformfv(program, location, params);
}
void GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params)
{
- EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateGetUniformiv(context, program, location, params))
- {
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
- ASSERT(programObject);
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
- ASSERT(programBinary);
-
- programBinary->getUniformiv(location, params);
- }
+ return gl::GetUniformiv(program, location, params);
}
GLint GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* name)
{
- EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (strstr(name, "gl_") == name)
- {
- return -1;
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject)
- {
- if (context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return -1;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return -1;
- }
- }
-
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
- if (!programObject->isLinked() || !programBinary)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return -1;
- }
-
- return programBinary->getUniformLocation(name);
- }
-
- return -1;
+ return gl::GetUniformLocation(program, name);
}
void GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
{
- EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
- if (!gl::ValidateGetVertexAttribParameters(context, pname))
- {
- return;
- }
-
- if (pname == GL_CURRENT_VERTEX_ATTRIB)
- {
- const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
- for (int i = 0; i < 4; ++i)
- {
- params[i] = currentValueData.FloatValues[i];
- }
- }
- else
- {
- *params = gl::QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname);
- }
- }
+ return gl::GetVertexAttribfv(index, pname, params);
}
void GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
{
- EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
-
- if (!gl::ValidateGetVertexAttribParameters(context, pname))
- {
- return;
- }
-
- if (pname == GL_CURRENT_VERTEX_ATTRIB)
- {
- const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
- for (int i = 0; i < 4; ++i)
- {
- float currentValue = currentValueData.FloatValues[i];
- params[i] = gl::iround<GLint>(currentValue);
- }
- }
- else
- {
- *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
- }
- }
+ return gl::GetVertexAttribiv(index, pname, params);
}
void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
{
- EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- *pointer = const_cast<GLvoid*>(context->getState().getVertexAttribPointer(index));
- }
+ return gl::GetVertexAttribPointerv(index, pname, pointer);
}
void GL_APIENTRY glHint(GLenum target, GLenum mode)
{
- EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- switch (mode)
- {
- case GL_FASTEST:
- case GL_NICEST:
- case GL_DONT_CARE:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (target)
- {
- case GL_GENERATE_MIPMAP_HINT:
- context->getState().setGenerateMipmapHint(mode);
- break;
-
- case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
- context->getState().setFragmentShaderDerivativeHint(mode);
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::Hint(target, mode);
}
GLboolean GL_APIENTRY glIsBuffer(GLuint buffer)
{
- EVENT("(GLuint buffer = %d)", buffer);
-
- gl::Context *context = gl::getNonLostContext();
- if (context && buffer)
- {
- gl::Buffer *bufferObject = context->getBuffer(buffer);
-
- if (bufferObject)
- {
- return GL_TRUE;
- }
- }
-
- return GL_FALSE;
+ return gl::IsBuffer(buffer);
}
GLboolean GL_APIENTRY glIsEnabled(GLenum cap)
{
- EVENT("(GLenum cap = 0x%X)", cap);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidCap(context, cap))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return GL_FALSE;
- }
-
- return context->getState().getEnableFeature(cap);
- }
-
- return false;
-}
-
-GLboolean GL_APIENTRY glIsFenceNV(GLuint fence)
-{
- EVENT("(GLuint fence = %d)", fence);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::FenceNV *fenceObject = context->getFenceNV(fence);
-
- if (fenceObject == NULL)
- {
- return GL_FALSE;
- }
-
- return fenceObject->isFence();
- }
-
- return GL_FALSE;
+ return gl::IsEnabled(cap);
}
GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer)
{
- EVENT("(GLuint framebuffer = %d)", framebuffer);
-
- gl::Context *context = gl::getNonLostContext();
- if (context && framebuffer)
- {
- gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
-
- if (framebufferObject)
- {
- return GL_TRUE;
- }
- }
-
- return GL_FALSE;
+ return gl::IsFramebuffer(framebuffer);
}
GLboolean GL_APIENTRY glIsProgram(GLuint program)
{
- EVENT("(GLuint program = %d)", program);
-
- gl::Context *context = gl::getNonLostContext();
- if (context && program)
- {
- gl::Program *programObject = context->getProgram(program);
-
- if (programObject)
- {
- return GL_TRUE;
- }
- }
-
- return GL_FALSE;
-}
-
-GLboolean GL_APIENTRY glIsQueryEXT(GLuint id)
-{
- EVENT("(GLuint id = %d)", id);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
- }
-
- return GL_FALSE;
+ return gl::IsProgram(program);
}
GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer)
{
- EVENT("(GLuint renderbuffer = %d)", renderbuffer);
-
- gl::Context *context = gl::getNonLostContext();
- if (context && renderbuffer)
- {
- gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
-
- if (renderbufferObject)
- {
- return GL_TRUE;
- }
- }
-
- return GL_FALSE;
+ return gl::IsRenderbuffer(renderbuffer);
}
GLboolean GL_APIENTRY glIsShader(GLuint shader)
{
- EVENT("(GLuint shader = %d)", shader);
-
- gl::Context *context = gl::getNonLostContext();
- if (context && shader)
- {
- gl::Shader *shaderObject = context->getShader(shader);
-
- if (shaderObject)
- {
- return GL_TRUE;
- }
- }
-
- return GL_FALSE;
+ return gl::IsShader(shader);
}
GLboolean GL_APIENTRY glIsTexture(GLuint texture)
{
- EVENT("(GLuint texture = %d)", texture);
-
- gl::Context *context = gl::getNonLostContext();
- if (context && texture)
- {
- gl::Texture *textureObject = context->getTexture(texture);
-
- if (textureObject)
- {
- return GL_TRUE;
- }
- }
-
- return GL_FALSE;
+ return gl::IsTexture(texture);
}
void GL_APIENTRY glLineWidth(GLfloat width)
{
- EVENT("(GLfloat width = %f)", width);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (width <= 0.0f)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- context->getState().setLineWidth(width);
- }
+ return gl::LineWidth(width);
}
void GL_APIENTRY glLinkProgram(GLuint program)
{
- EVENT("(GLuint program = %d)", program);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject)
- {
- if (context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- gl::Error error = context->linkProgram(program);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::LinkProgram(program);
}
void GL_APIENTRY glPixelStorei(GLenum pname, GLint param)
{
- EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- switch (pname)
- {
- case GL_UNPACK_ALIGNMENT:
- if (param != 1 && param != 2 && param != 4 && param != 8)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- context->getState().setUnpackAlignment(param);
- break;
-
- case GL_PACK_ALIGNMENT:
- if (param != 1 && param != 2 && param != 4 && param != 8)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- context->getState().setPackAlignment(param);
- break;
-
- case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
- context->getState().setPackReverseRowOrder(param != 0);
- break;
-
- case GL_UNPACK_IMAGE_HEIGHT:
- case GL_UNPACK_SKIP_IMAGES:
- case GL_UNPACK_ROW_LENGTH:
- case GL_UNPACK_SKIP_ROWS:
- case GL_UNPACK_SKIP_PIXELS:
- case GL_PACK_ROW_LENGTH:
- case GL_PACK_SKIP_ROWS:
- case GL_PACK_SKIP_PIXELS:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- UNIMPLEMENTED();
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::PixelStorei(pname, param);
}
void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units)
{
- EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- context->getState().setPolygonOffsetParams(factor, units);
- }
-}
-
-void GL_APIENTRY glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
- GLenum format, GLenum type, GLsizei bufSize,
- GLvoid *data)
-{
- EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
- "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
- x, y, width, height, format, type, bufSize, data);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (width < 0 || height < 0 || bufSize < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
- format, type, &bufSize, data))
- {
- return;
- }
-
- gl::Error error = context->readPixels(x, y, width, height, format, type, &bufSize, data);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
-}
-
-void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
- GLenum format, GLenum type, GLvoid* pixels)
-{
- EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
- "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
- x, y, width, height, format, type, pixels);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (width < 0 || height < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
- format, type, NULL, pixels))
- {
- return;
- }
-
- gl::Error error = context->readPixels(x, y, width, height, format, type, NULL, pixels);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::PolygonOffset(factor, units);
}
-void GL_APIENTRY glReleaseShaderCompiler(void)
+void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
{
- EVENT("()");
-
- gl::Context *context = gl::getNonLostContext();
-
- if (context)
- {
- context->releaseShaderCompiler();
- }
+ return gl::ReadPixels(x, y, width, height, format, type, pixels);
}
-void GL_APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
+void GL_APIENTRY glReleaseShaderCompiler(void)
{
- EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
- target, samples, internalformat, width, height);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
- width, height, true))
- {
- return;
- }
-
- gl::Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
- gl::Error error = renderbuffer->setStorage(width, height, internalformat, samples);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::ReleaseShaderCompiler();
}
void GL_APIENTRY glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
{
- glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
+ return gl::RenderbufferStorage(target, internalformat, width, height);
}
-void GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert)
+void GL_APIENTRY glSampleCoverage(GLfloat value, GLboolean invert)
{
- EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
-
- gl::Context* context = gl::getNonLostContext();
-
- if (context)
- {
- context->getState().setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
- }
-}
-
-void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition)
-{
- EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (condition != GL_ALL_COMPLETED_NV)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::FenceNV *fenceObject = context->getFenceNV(fence);
-
- if (fenceObject == NULL)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- gl::Error error = fenceObject->setFence(condition);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::SampleCoverage(value, invert);
}
void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
{
- EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
-
- gl::Context* context = gl::getNonLostContext();
- if (context)
- {
- if (width < 0 || height < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- context->getState().setScissorParams(x, y, width, height);
- }
+ return gl::Scissor(x, y, width, height);
}
void GL_APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
{
- EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
- "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
- n, shaders, binaryformat, binary, length);
-
- gl::Context* context = gl::getNonLostContext();
- if (context)
- {
- const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats;
- if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) == shaderBinaryFormats.end())
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- // No binary shader formats are supported.
- UNIMPLEMENTED();
- }
+ return gl::ShaderBinary(n, shaders, binaryformat, binary, length);
}
void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
{
- EVENT("(GLuint shader = %d, GLsizei count = %d, const GLchar** string = 0x%0.8p, const GLint* length = 0x%0.8p)",
- shader, count, string, length);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (count < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::Shader *shaderObject = context->getShader(shader);
-
- if (!shaderObject)
- {
- if (context->getProgram(shader))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- shaderObject->setSource(count, string, length);
- }
+ return gl::ShaderSource(shader, count, string, length);
}
void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask)
{
- glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
+ return gl::StencilFunc(func, ref, mask);
}
void GL_APIENTRY glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
{
- EVENT("(GLenum face = 0x%X, GLenum func = 0x%X, GLint ref = %d, GLuint mask = %d)", face, func, ref, mask);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- switch (face)
- {
- case GL_FRONT:
- case GL_BACK:
- case GL_FRONT_AND_BACK:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (func)
- {
- case GL_NEVER:
- case GL_ALWAYS:
- case GL_LESS:
- case GL_LEQUAL:
- case GL_EQUAL:
- case GL_GEQUAL:
- case GL_GREATER:
- case GL_NOTEQUAL:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
- {
- context->getState().setStencilParams(func, ref, mask);
- }
-
- if (face == GL_BACK || face == GL_FRONT_AND_BACK)
- {
- context->getState().setStencilBackParams(func, ref, mask);
- }
- }
+ return gl::StencilFuncSeparate(face, func, ref, mask);
}
void GL_APIENTRY glStencilMask(GLuint mask)
{
- glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
+ return gl::StencilMask(mask);
}
void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask)
{
- EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- switch (face)
- {
- case GL_FRONT:
- case GL_BACK:
- case GL_FRONT_AND_BACK:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
- {
- context->getState().setStencilWritemask(mask);
- }
-
- if (face == GL_BACK || face == GL_FRONT_AND_BACK)
- {
- context->getState().setStencilBackWritemask(mask);
- }
- }
+ return gl::StencilMaskSeparate(face, mask);
}
void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
{
- glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
+ return gl::StencilOp(fail, zfail, zpass);
}
void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
{
- EVENT("(GLenum face = 0x%X, GLenum fail = 0x%X, GLenum zfail = 0x%X, GLenum zpas = 0x%Xs)",
- face, fail, zfail, zpass);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- switch (face)
- {
- case GL_FRONT:
- case GL_BACK:
- case GL_FRONT_AND_BACK:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (fail)
- {
- case GL_ZERO:
- case GL_KEEP:
- case GL_REPLACE:
- case GL_INCR:
- case GL_DECR:
- case GL_INVERT:
- case GL_INCR_WRAP:
- case GL_DECR_WRAP:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (zfail)
- {
- case GL_ZERO:
- case GL_KEEP:
- case GL_REPLACE:
- case GL_INCR:
- case GL_DECR:
- case GL_INVERT:
- case GL_INCR_WRAP:
- case GL_DECR_WRAP:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (zpass)
- {
- case GL_ZERO:
- case GL_KEEP:
- case GL_REPLACE:
- case GL_INCR:
- case GL_DECR:
- case GL_INVERT:
- case GL_INCR_WRAP:
- case GL_DECR_WRAP:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
- {
- context->getState().setStencilOperations(fail, zfail, zpass);
- }
-
- if (face == GL_BACK || face == GL_FRONT_AND_BACK)
- {
- context->getState().setStencilBackOperations(fail, zfail, zpass);
- }
- }
+ return gl::StencilOpSeparate(face, fail, zfail, zpass);
}
-GLboolean GL_APIENTRY glTestFenceNV(GLuint fence)
+void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
{
- EVENT("(GLuint fence = %d)", fence);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::FenceNV *fenceObject = context->getFenceNV(fence);
-
- if (fenceObject == NULL)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return GL_TRUE;
- }
-
- if (fenceObject->isFence() != GL_TRUE)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return GL_TRUE;
- }
-
- GLboolean result;
- gl::Error error = fenceObject->testFence(&result);
- if (error.isError())
- {
- context->recordError(error);
- return GL_TRUE;
- }
-
- return result;
- }
-
- return GL_TRUE;
-}
-
-void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
- GLint border, GLenum format, GLenum type, const GLvoid* pixels)
-{
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
- "GLint border = %d, GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
- target, level, internalformat, width, height, border, format, type, pixels);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3 &&
- !ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
- 0, 0, width, height, border, format, type, pixels))
- {
- return;
- }
-
- if (context->getClientVersion() >= 3 &&
- !ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
- 0, 0, 0, width, height, 1, border, format, type, pixels))
- {
- return;
- }
-
- switch (target)
- {
- case GL_TEXTURE_2D:
- {
- gl::Texture2D *texture = context->getTexture2D();
- gl::Error error = texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- {
- gl::TextureCubeMap *texture = context->getTextureCubeMap();
- gl::Error error = texture->setImage(target, level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- default: UNREACHABLE();
- }
- }
+ return gl::TexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
}
void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param)
{
- EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
- {
- return;
- }
-
- gl::Texture *texture = context->getTargetTexture(target);
-
- if (!texture)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (pname)
- {
- case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = gl::uiround<GLenum>(param); break;
- case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = gl::uiround<GLenum>(param); break;
- case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = gl::uiround<GLenum>(param); break;
- case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = gl::uiround<GLenum>(param); break;
- case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = gl::uiround<GLenum>(param); break;
- case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break;
- case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min(param, context->getExtensions().maxTextureAnisotropy); break;
- case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = gl::uiround<GLenum>(param); break;
- case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = gl::uiround<GLenum>(param); break;
- case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = gl::uiround<GLenum>(param); break;
- case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = gl::uiround<GLenum>(param); break;
- case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = gl::uiround<GLenum>(param); break;
- case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = gl::uiround<GLenum>(param); break;
- case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = gl::iround<GLint>(param); break;
- case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = gl::iround<GLint>(param); break;
- case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = param; break;
- case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = param; break;
- default: UNREACHABLE(); break;
- }
- }
+ return gl::TexParameterf(target, pname, param);
}
void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
{
- glTexParameterf(target, pname, (GLfloat)*params);
+ return gl::TexParameterfv(target, pname, params);
}
void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
{
- EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateTexParamParameters(context, pname, param))
- {
- return;
- }
-
- gl::Texture *texture = context->getTargetTexture(target);
-
- if (!texture)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (pname)
- {
- case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = (GLenum)param; break;
- case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = (GLenum)param; break;
- case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = (GLenum)param; break;
- case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = (GLenum)param; break;
- case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = (GLenum)param; break;
- case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break;
- case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min((float)param, context->getExtensions().maxTextureAnisotropy); break;
- case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = (GLenum)param; break;
- case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = (GLenum)param; break;
- case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = (GLenum)param; break;
- case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = (GLenum)param; break;
- case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = (GLenum)param; break;
- case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = (GLenum)param; break;
- case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = param; break;
- case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = param; break;
- case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = (GLfloat)param; break;
- case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = (GLfloat)param; break;
- default: UNREACHABLE(); break;
- }
- }
+ return gl::TexParameteri(target, pname, param);
}
void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
{
- glTexParameteri(target, pname, *params);
+ return gl::TexParameteriv(target, pname, params);
}
-void GL_APIENTRY glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
+void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels)
{
- EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
- target, levels, internalformat, width, height);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!context->getExtensions().textureStorage)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (context->getClientVersion() < 3 &&
- !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height))
- {
- return;
- }
-
- if (context->getClientVersion() >= 3 &&
- !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
- {
- return;
- }
-
- switch (target)
- {
- case GL_TEXTURE_2D:
- {
- gl::Texture2D *texture2d = context->getTexture2D();
- gl::Error error = texture2d->storage(levels, internalformat, width, height);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- case GL_TEXTURE_CUBE_MAP:
- {
- gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
- gl::Error error = textureCube->storage(levels, internalformat, width);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
-}
-
-void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
- GLenum format, GLenum type, const GLvoid* pixels)
-{
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
- "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
- "const GLvoid* pixels = 0x%0.8p)",
- target, level, xoffset, yoffset, width, height, format, type, pixels);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3 &&
- !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true,
- xoffset, yoffset, width, height, 0, format, type, pixels))
- {
- return;
- }
-
- if (context->getClientVersion() >= 3 &&
- !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
- xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels))
- {
- return;
- }
-
- // Zero sized uploads are valid but no-ops
- if (width == 0 || height == 0)
- {
- return;
- }
-
- switch (target)
- {
- case GL_TEXTURE_2D:
- {
- gl::Texture2D *texture = context->getTexture2D();
- gl::Error error = texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- {
- gl::TextureCubeMap *texture = context->getTextureCubeMap();
- gl::Error error = texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- default:
- UNREACHABLE();
- }
- }
+ return gl::TexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
}
void GL_APIENTRY glUniform1f(GLint location, GLfloat x)
{
- glUniform1fv(location, 1, &x);
+ return gl::Uniform1f(location, x);
}
void GL_APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
{
- EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniform(context, GL_FLOAT, location, count))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniform1fv(location, count, v);
- }
+ return gl::Uniform1fv(location, count, v);
}
void GL_APIENTRY glUniform1i(GLint location, GLint x)
{
- glUniform1iv(location, 1, &x);
+ return gl::Uniform1i(location, x);
}
void GL_APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v)
{
- EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniform(context, GL_INT, location, count))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniform1iv(location, count, v);
- }
+ return gl::Uniform1iv(location, count, v);
}
void GL_APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y)
{
- GLfloat xy[2] = {x, y};
-
- glUniform2fv(location, 1, xy);
+ return gl::Uniform2f(location, x, y);
}
void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
{
- EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniform2fv(location, count, v);
- }
+ return gl::Uniform2fv(location, count, v);
}
void GL_APIENTRY glUniform2i(GLint location, GLint x, GLint y)
{
- GLint xy[2] = {x, y};
-
- glUniform2iv(location, 1, xy);
+ return gl::Uniform2i(location, x, y);
}
void GL_APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v)
{
- EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniform(context, GL_INT_VEC2, location, count))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniform2iv(location, count, v);
- }
+ return gl::Uniform2iv(location, count, v);
}
void GL_APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
{
- GLfloat xyz[3] = {x, y, z};
-
- glUniform3fv(location, 1, xyz);
+ return gl::Uniform3f(location, x, y, z);
}
void GL_APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
{
- EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniform3fv(location, count, v);
- }
+ return gl::Uniform3fv(location, count, v);
}
void GL_APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z)
{
- GLint xyz[3] = {x, y, z};
-
- glUniform3iv(location, 1, xyz);
+ return gl::Uniform3i(location, x, y, z);
}
void GL_APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v)
{
- EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniform(context, GL_INT_VEC3, location, count))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniform3iv(location, count, v);
- }
+ return gl::Uniform3iv(location, count, v);
}
void GL_APIENTRY glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
- GLfloat xyzw[4] = {x, y, z, w};
-
- glUniform4fv(location, 1, xyzw);
+ return gl::Uniform4f(location, x, y, z, w);
}
void GL_APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
{
- EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniform4fv(location, count, v);
- }
+ return gl::Uniform4fv(location, count, v);
}
void GL_APIENTRY glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
{
- GLint xyzw[4] = {x, y, z, w};
-
- glUniform4iv(location, 1, xyzw);
+ return gl::Uniform4i(location, x, y, z, w);
}
void GL_APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v)
{
- EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniform(context, GL_INT_VEC4, location, count))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniform4iv(location, count, v);
- }
+ return gl::Uniform4iv(location, count, v);
}
void GL_APIENTRY glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
- EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniformMatrix2fv(location, count, transpose, value);
- }
+ return gl::UniformMatrix2fv(location, count, transpose, value);
}
void GL_APIENTRY glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
- EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniformMatrix3fv(location, count, transpose, value);
- }
+ return gl::UniformMatrix3fv(location, count, transpose, value);
}
void GL_APIENTRY glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
- EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniformMatrix4fv(location, count, transpose, value);
- }
+ return gl::UniformMatrix4fv(location, count, transpose, value);
}
void GL_APIENTRY glUseProgram(GLuint program)
{
- EVENT("(GLuint program = %d)", program);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject && program != 0)
- {
- if (context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- if (program != 0 && !programObject->isLinked())
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- context->useProgram(program);
- }
+ return gl::UseProgram(program);
}
void GL_APIENTRY glValidateProgram(GLuint program)
{
- EVENT("(GLuint program = %d)", program);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject)
- {
- if (context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- programObject->validate(context->getCaps());
- }
+ return gl::ValidateProgram(program);
}
-void GL_APIENTRY glVertexAttrib1f(GLuint index, GLfloat x)
+void GL_APIENTRY glVertexAttrib1f(GLuint indx, GLfloat x)
{
- EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- GLfloat vals[4] = { x, 0, 0, 1 };
- context->getState().setVertexAttribf(index, vals);
- }
+ return gl::VertexAttrib1f(indx, x);
}
-void GL_APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* values)
+void GL_APIENTRY glVertexAttrib1fv(GLuint indx, const GLfloat* values)
{
- EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- GLfloat vals[4] = { values[0], 0, 0, 1 };
- context->getState().setVertexAttribf(index, vals);
- }
+ return gl::VertexAttrib1fv(indx, values);
}
-void GL_APIENTRY glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
+void GL_APIENTRY glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
{
- EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- GLfloat vals[4] = { x, y, 0, 1 };
- context->getState().setVertexAttribf(index, vals);
- }
+ return gl::VertexAttrib2f(indx, x, y);
}
-void GL_APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* values)
+void GL_APIENTRY glVertexAttrib2fv(GLuint indx, const GLfloat* values)
{
- EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- GLfloat vals[4] = { values[0], values[1], 0, 1 };
- context->getState().setVertexAttribf(index, vals);
- }
+ return gl::VertexAttrib2fv(indx, values);
}
-void GL_APIENTRY glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
+void GL_APIENTRY glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
{
- EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", index, x, y, z);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- GLfloat vals[4] = { x, y, z, 1 };
- context->getState().setVertexAttribf(index, vals);
- }
+ return gl::VertexAttrib3f(indx, x, y, z);
}
-void GL_APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* values)
+void GL_APIENTRY glVertexAttrib3fv(GLuint indx, const GLfloat* values)
{
- EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- GLfloat vals[4] = { values[0], values[1], values[2], 1 };
- context->getState().setVertexAttribf(index, vals);
- }
+ return gl::VertexAttrib3fv(indx, values);
}
-void GL_APIENTRY glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+void GL_APIENTRY glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
- EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f, GLfloat w = %f)", index, x, y, z, w);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- GLfloat vals[4] = { x, y, z, w };
- context->getState().setVertexAttribf(index, vals);
- }
+ return gl::VertexAttrib4f(indx, x, y, z, w);
}
-void GL_APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* values)
+void GL_APIENTRY glVertexAttrib4fv(GLuint indx, const GLfloat* values)
{
- EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- context->getState().setVertexAttribf(index, values);
- }
+ return gl::VertexAttrib4fv(indx, values);
}
-void GL_APIENTRY glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
+void GL_APIENTRY glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
{
- EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- context->setVertexAttribDivisor(index, divisor);
- }
-}
-
-void GL_APIENTRY glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
-{
- EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
- "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
- index, size, type, normalized, stride, ptr);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- if (size < 1 || size > 4)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- switch (type)
- {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_FIXED:
- case GL_FLOAT:
- break;
-
- case GL_HALF_FLOAT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_INT_2_10_10_10_REV:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (stride < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- // [OpenGL ES 3.0.2] Section 2.8 page 24:
- // An INVALID_OPERATION error is generated when a non-zero vertex array object
- // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
- // and the pointer argument is not NULL.
- if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && ptr != NULL)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type,
- normalized == GL_TRUE, false, stride, ptr);
- }
+ return gl::VertexAttribPointer(indx, size, type, normalized, stride, ptr);
}
void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
{
- EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (width < 0 || height < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- context->getState().setViewportParams(x, y, width, height);
- }
+ return gl::Viewport(x, y, width, height);
}
-// OpenGL ES 3.0 functions
-
void GL_APIENTRY glReadBuffer(GLenum mode)
{
- EVENT("(GLenum mode = 0x%X)", mode);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- // glReadBuffer
- UNIMPLEMENTED();
- }
+ return gl::ReadBuffer(mode);
}
void GL_APIENTRY glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
{
- EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
- "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- // glDrawRangeElements
- UNIMPLEMENTED();
- }
+ return gl::DrawRangeElements(mode, start, end, count, type, indices);
}
void GL_APIENTRY glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
{
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
- "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
- "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
- target, level, internalformat, width, height, depth, border, format, type, pixels);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- // validateES3TexImageFormat sets the error code if there is an error
- if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
- 0, 0, 0, width, height, depth, border, format, type, pixels))
- {
- return;
- }
-
- switch(target)
- {
- case GL_TEXTURE_3D:
- {
- gl::Texture3D *texture = context->getTexture3D();
- gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- case GL_TEXTURE_2D_ARRAY:
- {
- gl::Texture2DArray *texture = context->getTexture2DArray();
- gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::TexImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels);
}
void GL_APIENTRY glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
{
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
- "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
- "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
- target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- // validateES3TexImageFormat sets the error code if there is an error
- if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
- xoffset, yoffset, zoffset, width, height, depth, 0,
- format, type, pixels))
- {
- return;
- }
-
- // Zero sized uploads are valid but no-ops
- if (width == 0 || height == 0 || depth == 0)
- {
- return;
- }
-
- switch(target)
- {
- case GL_TEXTURE_3D:
- {
- gl::Texture3D *texture = context->getTexture3D();
- gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- case GL_TEXTURE_2D_ARRAY:
- {
- gl::Texture2DArray *texture = context->getTexture2DArray();
- gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::TexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
}
void GL_APIENTRY glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
{
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
- "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
- target, level, xoffset, yoffset, zoffset, x, y, width, height);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset,
- x, y, width, height, 0))
- {
- return;
- }
-
- gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
- gl::Texture *texture = NULL;
- switch (target)
- {
- case GL_TEXTURE_3D:
- texture = context->getTexture3D();
- break;
-
- case GL_TEXTURE_2D_ARRAY:
- texture = context->getTexture2DArray();
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::CopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height);
}
void GL_APIENTRY glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
{
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
- "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
- "const GLvoid* data = 0x%0.8p)",
- target, level, internalformat, width, height, depth, border, imageSize, data);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
- if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- // validateES3TexImageFormat sets the error code if there is an error
- if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
- 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
- {
- return;
- }
-
- switch(target)
- {
- case GL_TEXTURE_3D:
- {
- gl::Texture3D *texture = context->getTexture3D();
- gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, context->getState().getUnpackState(), data);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- case GL_TEXTURE_2D_ARRAY:
- {
- gl::Texture2DArray *texture = context->getTexture2DArray();
- gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, context->getState().getUnpackState(), data);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::CompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data);
}
void GL_APIENTRY glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
{
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
- "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
- "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
- target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
- if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- if (!data)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- // validateES3TexImageFormat sets the error code if there is an error
- if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
- 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data))
- {
- return;
- }
-
- // Zero sized uploads are valid but no-ops
- if (width == 0 || height == 0)
- {
- return;
- }
-
- switch(target)
- {
- case GL_TEXTURE_3D:
- {
- gl::Texture3D *texture = context->getTexture3D();
- gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
- format, imageSize, context->getState().getUnpackState(), data);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- case GL_TEXTURE_2D_ARRAY:
- {
- gl::Texture2DArray *texture = context->getTexture2DArray();
- gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
- format, imageSize, context->getState().getUnpackState(), data);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::CompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
}
void GL_APIENTRY glGenQueries(GLsizei n, GLuint* ids)
{
- EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (n < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (GLsizei i = 0; i < n; i++)
- {
- ids[i] = context->createQuery();
- }
- }
+ return gl::GenQueries(n, ids);
}
void GL_APIENTRY glDeleteQueries(GLsizei n, const GLuint* ids)
{
- EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (n < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (GLsizei i = 0; i < n; i++)
- {
- context->deleteQuery(ids[i]);
- }
- }
+ return gl::DeleteQueries(n, ids);
}
GLboolean GL_APIENTRY glIsQuery(GLuint id)
{
- EVENT("(GLuint id = %u)", id);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return GL_FALSE;
- }
-
- return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
- }
-
- return GL_FALSE;
+ return gl::IsQuery(id);
}
void GL_APIENTRY glBeginQuery(GLenum target, GLuint id)
{
- EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (!ValidateBeginQuery(context, target, id))
- {
- return;
- }
-
- gl::Error error = context->beginQuery(target, id);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::BeginQuery(target, id);
}
void GL_APIENTRY glEndQuery(GLenum target)
{
- EVENT("(GLenum target = 0x%X)", target);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (!ValidateEndQuery(context, target))
- {
- return;
- }
-
- gl::Error error = context->endQuery(target);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::EndQuery(target);
}
void GL_APIENTRY glGetQueryiv(GLenum target, GLenum pname, GLint* params)
{
- EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (!ValidQueryType(context, target))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (pname)
- {
- case GL_CURRENT_QUERY:
- params[0] = static_cast<GLint>(context->getState().getActiveQueryId(target));
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::GetQueryiv(target, pname, params);
}
void GL_APIENTRY glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
{
- EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
-
- if (!queryObject)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (context->getState().getActiveQueryId(queryObject->getType()) == id)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- switch(pname)
- {
- case GL_QUERY_RESULT_EXT:
- {
- gl::Error error = queryObject->getResult(params);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- case GL_QUERY_RESULT_AVAILABLE_EXT:
- {
- gl::Error error = queryObject->isResultAvailable(params);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::GetQueryObjectuiv(id, pname, params);
}
GLboolean GL_APIENTRY glUnmapBuffer(GLenum target)
{
- EVENT("(GLenum target = 0x%X)", target);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return GL_FALSE;
- }
-
- return glUnmapBufferOES(target);
- }
-
- return GL_FALSE;
+ return gl::UnmapBuffer(target);
}
void GL_APIENTRY glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
{
- EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- glGetBufferPointervOES(target, pname, params);
- }
+ return gl::GetBufferPointerv(target, pname, params);
}
void GL_APIENTRY glDrawBuffers(GLsizei n, const GLenum* bufs)
{
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- glDrawBuffersEXT(n, bufs);
- }
+ return gl::DrawBuffers(n, bufs);
}
void GL_APIENTRY glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
- EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniformMatrix2x3fv(location, count, transpose, value);
- }
+ return gl::UniformMatrix2x3fv(location, count, transpose, value);
}
void GL_APIENTRY glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
- EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniformMatrix3x2fv(location, count, transpose, value);
- }
+ return gl::UniformMatrix3x2fv(location, count, transpose, value);
}
void GL_APIENTRY glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
- EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniformMatrix2x4fv(location, count, transpose, value);
- }
+ return gl::UniformMatrix2x4fv(location, count, transpose, value);
}
void GL_APIENTRY glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
- EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniformMatrix4x2fv(location, count, transpose, value);
- }
+ return gl::UniformMatrix4x2fv(location, count, transpose, value);
}
void GL_APIENTRY glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
- EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniformMatrix3x4fv(location, count, transpose, value);
- }
+ return gl::UniformMatrix3x4fv(location, count, transpose, value);
}
void GL_APIENTRY glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
- EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniformMatrix4x3fv(location, count, transpose, value);
- }
+ return gl::UniformMatrix4x3fv(location, count, transpose, value);
}
void GL_APIENTRY glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
{
- EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
- "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
- srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1, mask, filter,
- false))
- {
- return;
- }
-
- gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
- mask, filter);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
}
void GL_APIENTRY glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
{
- EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
- target, samples, internalformat, width, height);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
- width, height, false))
- {
- return;
- }
-
- gl::Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
- renderbuffer->setStorage(width, height, internalformat, samples);
- }
+ return gl::RenderbufferStorageMultisample(target, samples, internalformat, width, height);
}
void GL_APIENTRY glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
{
- EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
- target, attachment, texture, level, layer);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateFramebufferTextureLayer(context, target, attachment, texture,
- level, layer))
- {
- return;
- }
-
- gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
- ASSERT(framebuffer);
-
- if (texture != 0)
- {
- gl::Texture *textureObject = context->getTexture(texture);
- gl::ImageIndex index(textureObject->getTarget(), level, layer);
- framebuffer->setTextureAttachment(attachment, textureObject, index);
- }
- else
- {
- framebuffer->setNULLAttachment(attachment);
- }
- }
+ return gl::FramebufferTextureLayer(target, attachment, texture, level, layer);
}
GLvoid* GL_APIENTRY glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
{
- EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
- target, offset, length, access);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return NULL;
- }
-
- return glMapBufferRangeEXT(target, offset, length, access);
- }
-
- return NULL;
+ return gl::MapBufferRange(target, offset, length, access);
}
void GL_APIENTRY glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
{
- EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- glFlushMappedBufferRangeEXT(target, offset, length);
- }
+ return gl::FlushMappedBufferRange(target, offset, length);
}
void GL_APIENTRY glBindVertexArray(GLuint array)
{
- EVENT("(GLuint array = %u)", array);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- gl::VertexArray *vao = context->getVertexArray(array);
-
- if (!vao)
- {
- // The default VAO should always exist
- ASSERT(array != 0);
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- context->bindVertexArray(array);
- }
+ return gl::BindVertexArray(array);
}
void GL_APIENTRY glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
{
- EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (n < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
- {
- if (arrays[arrayIndex] != 0)
- {
- context->deleteVertexArray(arrays[arrayIndex]);
- }
- }
- }
+ return gl::DeleteVertexArrays(n, arrays);
}
void GL_APIENTRY glGenVertexArrays(GLsizei n, GLuint* arrays)
{
- EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (n < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
- {
- arrays[arrayIndex] = context->createVertexArray();
- }
- }
+ return gl::GenVertexArrays(n, arrays);
}
GLboolean GL_APIENTRY glIsVertexArray(GLuint array)
{
- EVENT("(GLuint array = %u)", array);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return GL_FALSE;
- }
-
- if (array == 0)
- {
- return GL_FALSE;
- }
-
- gl::VertexArray *vao = context->getVertexArray(array);
-
- return (vao != NULL ? GL_TRUE : GL_FALSE);
- }
-
- return GL_FALSE;
+ return gl::IsVertexArray(array);
}
void GL_APIENTRY glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
{
- EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
- target, index, data);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- const gl::Caps &caps = context->getCaps();
- switch (target)
- {
- case GL_TRANSFORM_FEEDBACK_BUFFER_START:
- case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
- case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
- if (index >= caps.maxTransformFeedbackSeparateAttributes)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- break;
-
- case GL_UNIFORM_BUFFER_START:
- case GL_UNIFORM_BUFFER_SIZE:
- case GL_UNIFORM_BUFFER_BINDING:
- if (index >= caps.maxCombinedUniformBlocks)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (!(context->getIndexedIntegerv(target, index, data)))
- {
- GLenum nativeType;
- unsigned int numParams = 0;
- if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (numParams == 0)
- {
- return; // it is known that pname is valid, but there are no parameters to return
- }
-
- if (nativeType == GL_INT_64_ANGLEX)
- {
- GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min());
- GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max());
- GLint64 *int64Params = new GLint64[numParams];
-
- context->getIndexedInteger64v(target, index, int64Params);
-
- for (unsigned int i = 0; i < numParams; ++i)
- {
- GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue);
- data[i] = static_cast<GLint>(clampedValue);
- }
-
- delete [] int64Params;
- }
- else
- {
- UNREACHABLE();
- }
- }
- }
+ return gl::GetIntegeri_v(target, index, data);
}
void GL_APIENTRY glBeginTransformFeedback(GLenum primitiveMode)
{
- EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- switch (primitiveMode)
- {
- case GL_TRIANGLES:
- case GL_LINES:
- case GL_POINTS:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
- ASSERT(transformFeedback != NULL);
-
- if (transformFeedback->isStarted())
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (transformFeedback->isPaused())
- {
- transformFeedback->resume();
- }
- else
- {
- transformFeedback->start(primitiveMode);
- }
- }
+ return gl::BeginTransformFeedback(primitiveMode);
}
void GL_APIENTRY glEndTransformFeedback(void)
{
- EVENT("(void)");
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
- ASSERT(transformFeedback != NULL);
-
- if (!transformFeedback->isStarted())
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- transformFeedback->stop();
- }
+ return gl::EndTransformFeedback();
}
void GL_APIENTRY glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
{
- EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
- target, index, buffer, offset, size);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- const gl::Caps &caps = context->getCaps();
- switch (target)
- {
- case GL_TRANSFORM_FEEDBACK_BUFFER:
- if (index >= caps.maxTransformFeedbackSeparateAttributes)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- break;
-
- case GL_UNIFORM_BUFFER:
- if (index >= caps.maxUniformBufferBindings)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (buffer != 0 && size <= 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- switch (target)
- {
- case GL_TRANSFORM_FEEDBACK_BUFFER:
-
- // size and offset must be a multiple of 4
- if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
- context->bindGenericTransformFeedbackBuffer(buffer);
- break;
-
- case GL_UNIFORM_BUFFER:
-
- // it is an error to bind an offset not a multiple of the alignment
- if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- context->bindIndexedUniformBuffer(buffer, index, offset, size);
- context->bindGenericUniformBuffer(buffer);
- break;
-
- default:
- UNREACHABLE();
- }
- }
+ return gl::BindBufferRange(target, index, buffer, offset, size);
}
void GL_APIENTRY glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
{
- EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
- target, index, buffer);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- const gl::Caps &caps = context->getCaps();
- switch (target)
- {
- case GL_TRANSFORM_FEEDBACK_BUFFER:
- if (index >= caps.maxTransformFeedbackSeparateAttributes)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- break;
-
- case GL_UNIFORM_BUFFER:
- if (index >= caps.maxUniformBufferBindings)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- switch (target)
- {
- case GL_TRANSFORM_FEEDBACK_BUFFER:
- context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
- context->bindGenericTransformFeedbackBuffer(buffer);
- break;
-
- case GL_UNIFORM_BUFFER:
- context->bindIndexedUniformBuffer(buffer, index, 0, 0);
- context->bindGenericUniformBuffer(buffer);
- break;
-
- default:
- UNREACHABLE();
- }
- }
+ return gl::BindBufferBase(target, index, buffer);
}
void GL_APIENTRY glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
{
- EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
- program, count, varyings, bufferMode);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (count < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- const gl::Caps &caps = context->getCaps();
- switch (bufferMode)
- {
- case GL_INTERLEAVED_ATTRIBS:
- break;
- case GL_SEPARATE_ATTRIBS:
- if (static_cast<GLuint>(count) > caps.maxTransformFeedbackSeparateAttributes)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- break;
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (!gl::ValidProgram(context, program))
- {
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
- ASSERT(programObject);
-
- programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
- }
+ return gl::TransformFeedbackVaryings(program, count, varyings, bufferMode);
}
void GL_APIENTRY glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
{
- EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
- "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
- program, index, bufSize, length, size, type, name);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (bufSize < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- if (!gl::ValidProgram(context, program))
- {
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
- ASSERT(programObject);
-
- if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
- }
+ return gl::GetTransformFeedbackVarying(program, index, bufSize, length, size, type, name);
}
void GL_APIENTRY glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
{
- EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
- index, size, type, stride, pointer);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- if (size < 1 || size > 4)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- switch (type)
- {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_INT_2_10_10_10_REV:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (stride < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- // [OpenGL ES 3.0.2] Section 2.8 page 24:
- // An INVALID_OPERATION error is generated when a non-zero vertex array object
- // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
- // and the pointer argument is not NULL.
- if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true,
- stride, pointer);
- }
+ return gl::VertexAttribIPointer(index, size, type, stride, pointer);
}
void GL_APIENTRY glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
{
- EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
- index, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
-
- if (!gl::ValidateGetVertexAttribParameters(context, pname))
- {
- return;
- }
-
- if (pname == GL_CURRENT_VERTEX_ATTRIB)
- {
- const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
- for (int i = 0; i < 4; ++i)
- {
- params[i] = currentValueData.IntValues[i];
- }
- }
- else
- {
- *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
- }
- }
+ return gl::GetVertexAttribIiv(index, pname, params);
}
void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
{
- EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
- index, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
-
- if (!gl::ValidateGetVertexAttribParameters(context, pname))
- {
- return;
- }
-
- if (pname == GL_CURRENT_VERTEX_ATTRIB)
- {
- const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
- for (int i = 0; i < 4; ++i)
- {
- params[i] = currentValueData.UnsignedIntValues[i];
- }
- }
- else
- {
- *params = gl::QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
- }
- }
+ return gl::GetVertexAttribIuiv(index, pname, params);
}
void GL_APIENTRY glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
{
- EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
- index, x, y, z, w);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- GLint vals[4] = { x, y, z, w };
- context->getState().setVertexAttribi(index, vals);
- }
+ return gl::VertexAttribI4i(index, x, y, z, w);
}
void GL_APIENTRY glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
{
- EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
- index, x, y, z, w);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- GLuint vals[4] = { x, y, z, w };
- context->getState().setVertexAttribu(index, vals);
- }
+ return gl::VertexAttribI4ui(index, x, y, z, w);
}
void GL_APIENTRY glVertexAttribI4iv(GLuint index, const GLint* v)
{
- EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- context->getState().setVertexAttribi(index, v);
- }
+ return gl::VertexAttribI4iv(index, v);
}
void GL_APIENTRY glVertexAttribI4uiv(GLuint index, const GLuint* v)
{
- EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- context->getState().setVertexAttribu(index, v);
- }
+ return gl::VertexAttribI4uiv(index, v);
}
void GL_APIENTRY glGetUniformuiv(GLuint program, GLint location, GLuint* params)
{
- EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
- program, location, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateGetUniformuiv(context, program, location, params))
- {
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
- ASSERT(programObject);
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
- ASSERT(programBinary);
-
- programBinary->getUniformuiv(location, params);
- }
+ return gl::GetUniformuiv(program, location, params);
}
GLint GL_APIENTRY glGetFragDataLocation(GLuint program, const GLchar *name)
{
- EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
- program, name);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return -1;
- }
-
- if (program == 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return -1;
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject || !programObject->isLinked())
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return -1;
- }
-
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
- if (!programBinary)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return -1;
- }
-
- return programBinary->getFragDataLocation(name);
- }
-
- return 0;
+ return gl::GetFragDataLocation(program, name);
}
void GL_APIENTRY glUniform1ui(GLint location, GLuint v0)
{
- glUniform1uiv(location, 1, &v0);
+ return gl::Uniform1ui(location, v0);
}
void GL_APIENTRY glUniform2ui(GLint location, GLuint v0, GLuint v1)
{
- const GLuint xy[] = { v0, v1 };
- glUniform2uiv(location, 1, xy);
+ return gl::Uniform2ui(location, v0, v1);
}
void GL_APIENTRY glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
{
- const GLuint xyz[] = { v0, v1, v2 };
- glUniform3uiv(location, 1, xyz);
+ return gl::Uniform3ui(location, v0, v1, v2);
}
void GL_APIENTRY glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
{
- const GLuint xyzw[] = { v0, v1, v2, v3 };
- glUniform4uiv(location, 1, xyzw);
+ return gl::Uniform4ui(location, v0, v1, v2, v3);
}
void GL_APIENTRY glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
{
- EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
- location, count, value);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniform1uiv(location, count, value);
- }
+ return gl::Uniform1uiv(location, count, value);
}
void GL_APIENTRY glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
{
- EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
- location, count, value);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniform2uiv(location, count, value);
- }
+ return gl::Uniform2uiv(location, count, value);
}
void GL_APIENTRY glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
{
- EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
- location, count, value);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniform3uiv(location, count, value);
- }
+ return gl::Uniform3uiv(location, count, value);
}
void GL_APIENTRY glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
{
- EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
- location, count, value);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC4, location, count))
- {
- return;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- programBinary->setUniform4uiv(location, count, value);
- }
+ return gl::Uniform4uiv(location, count, value);
}
void GL_APIENTRY glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
{
- EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
- buffer, drawbuffer, value);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateClearBuffer(context))
- {
- return;
- }
-
- switch (buffer)
- {
- case GL_COLOR:
- if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- break;
-
- case GL_STENCIL:
- if (drawbuffer != 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::Error error = context->clearBufferiv(buffer, drawbuffer, value);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::ClearBufferiv(buffer, drawbuffer, value);
}
void GL_APIENTRY glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
{
- EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
- buffer, drawbuffer, value);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateClearBuffer(context))
- {
- return;
- }
-
- switch (buffer)
- {
- case GL_COLOR:
- if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::Error error = context->clearBufferuiv(buffer, drawbuffer, value);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::ClearBufferuiv(buffer, drawbuffer, value);
}
void GL_APIENTRY glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
{
- EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
- buffer, drawbuffer, value);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateClearBuffer(context))
- {
- return;
- }
-
- switch (buffer)
- {
- case GL_COLOR:
- if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- break;
-
- case GL_DEPTH:
- if (drawbuffer != 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::Error error = context->clearBufferfv(buffer, drawbuffer, value);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::ClearBufferfv(buffer, drawbuffer, value);
}
void GL_APIENTRY glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
{
- EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
- buffer, drawbuffer, depth, stencil);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateClearBuffer(context))
- {
- return;
- }
-
- switch (buffer)
- {
- case GL_DEPTH_STENCIL:
- if (drawbuffer != 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::Error error = context->clearBufferfi(buffer, drawbuffer, depth, stencil);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::ClearBufferfi(buffer, drawbuffer, depth, stencil);
}
const GLubyte* GL_APIENTRY glGetStringi(GLenum name, GLuint index)
{
- EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return NULL;
- }
-
- if (name != GL_EXTENSIONS)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return NULL;
- }
-
- if (index >= context->getExtensionStringCount())
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return NULL;
- }
-
- return reinterpret_cast<const GLubyte*>(context->getExtensionString(index).c_str());
- }
-
- return NULL;
+ return gl::GetStringi(name, index);
}
void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
{
- EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
- readTarget, writeTarget, readOffset, writeOffset, size);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (!gl::ValidBufferTarget(context, readTarget) || !gl::ValidBufferTarget(context, writeTarget))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::Buffer *readBuffer = context->getState().getTargetBuffer(readTarget);
- gl::Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget);
-
- if (!readBuffer || !writeBuffer)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- // Verify that readBuffer and writeBuffer are not currently mapped
- if (readBuffer->isMapped() || writeBuffer->isMapped())
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (readOffset < 0 || writeOffset < 0 || size < 0 ||
- static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() ||
- static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize())
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- if (readBuffer == writeBuffer && std::abs(readOffset - writeOffset) < size)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- // if size is zero, the copy is a successful no-op
- if (size > 0)
- {
- gl::Error error = writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- }
+ return gl::CopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
}
void GL_APIENTRY glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
{
- EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
- program, uniformCount, uniformNames, uniformIndices);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (uniformCount < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject)
- {
- if (context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
- if (!programObject->isLinked() || !programBinary)
- {
- for (int uniformId = 0; uniformId < uniformCount; uniformId++)
- {
- uniformIndices[uniformId] = GL_INVALID_INDEX;
- }
- }
- else
- {
- for (int uniformId = 0; uniformId < uniformCount; uniformId++)
- {
- uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
- }
- }
- }
+ return gl::GetUniformIndices(program, uniformCount, uniformNames, uniformIndices);
}
void GL_APIENTRY glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
{
- EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
- program, uniformCount, uniformIndices, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (uniformCount < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject)
- {
- if (context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- switch (pname)
- {
- case GL_UNIFORM_TYPE:
- case GL_UNIFORM_SIZE:
- case GL_UNIFORM_NAME_LENGTH:
- case GL_UNIFORM_BLOCK_INDEX:
- case GL_UNIFORM_OFFSET:
- case GL_UNIFORM_ARRAY_STRIDE:
- case GL_UNIFORM_MATRIX_STRIDE:
- case GL_UNIFORM_IS_ROW_MAJOR:
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
-
- if (!programBinary && uniformCount > 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (int uniformId = 0; uniformId < uniformCount; uniformId++)
- {
- const GLuint index = uniformIndices[uniformId];
-
- if (index >= (GLuint)programBinary->getActiveUniformCount())
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- for (int uniformId = 0; uniformId < uniformCount; uniformId++)
- {
- const GLuint index = uniformIndices[uniformId];
- params[uniformId] = programBinary->getActiveUniformi(index, pname);
- }
- }
+ return gl::GetActiveUniformsiv(program, uniformCount, uniformIndices, pname, params);
}
GLuint GL_APIENTRY glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
{
- EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return GL_INVALID_INDEX;
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject)
- {
- if (context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return GL_INVALID_INDEX;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return GL_INVALID_INDEX;
- }
- }
-
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
- if (!programBinary)
- {
- return GL_INVALID_INDEX;
- }
-
- return programBinary->getUniformBlockIndex(uniformBlockName);
- }
-
- return 0;
+ return gl::GetUniformBlockIndex(program, uniformBlockName);
}
void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
{
- EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
- program, uniformBlockIndex, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject)
- {
- if (context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
-
- if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- switch (pname)
- {
- case GL_UNIFORM_BLOCK_BINDING:
- *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
- break;
-
- case GL_UNIFORM_BLOCK_DATA_SIZE:
- case GL_UNIFORM_BLOCK_NAME_LENGTH:
- case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
- case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
- case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
- case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
- programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::GetActiveUniformBlockiv(program, uniformBlockIndex, pname, params);
}
void GL_APIENTRY glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
{
- EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
- program, uniformBlockIndex, bufSize, length, uniformBlockName);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject)
- {
- if (context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
-
- if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
- }
+ return gl::GetActiveUniformBlockName(program, uniformBlockIndex, bufSize, length, uniformBlockName);
}
void GL_APIENTRY glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
{
- EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
- program, uniformBlockIndex, uniformBlockBinding);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (uniformBlockBinding >= context->getCaps().maxUniformBufferBindings)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject)
- {
- if (context->getShader(program))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- else
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- }
-
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
-
- // if never linked, there won't be any uniform blocks
- if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
- }
+ return gl::UniformBlockBinding(program, uniformBlockIndex, uniformBlockBinding);
}
void GL_APIENTRY glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
{
- EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
- mode, first, count, instanceCount);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- // glDrawArraysInstanced
- UNIMPLEMENTED();
- }
+ return gl::DrawArraysInstanced(mode, first, count, instanceCount);
}
void GL_APIENTRY glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
{
- EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
- mode, count, type, indices, instanceCount);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- // glDrawElementsInstanced
- UNIMPLEMENTED();
- }
+ return gl::DrawElementsInstanced(mode, count, type, indices, instanceCount);
}
GLsync GL_APIENTRY glFenceSync(GLenum condition, GLbitfield flags)
{
- EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return 0;
- }
-
- if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return 0;
- }
-
- if (flags != 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return 0;
- }
-
- GLsync fenceSync = context->createFenceSync();
-
- gl::FenceSync *fenceSyncObject = context->getFenceSync(fenceSync);
- gl::Error error = fenceSyncObject->set(condition);
- if (error.isError())
- {
- context->deleteFenceSync(fenceSync);
- context->recordError(error);
- return NULL;
- }
-
- return fenceSync;
- }
-
- return NULL;
+ return gl::FenceSync_(condition, flags);
}
GLboolean GL_APIENTRY glIsSync(GLsync sync)
{
- EVENT("(GLsync sync = 0x%0.8p)", sync);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return GL_FALSE;
- }
-
- return (context->getFenceSync(sync) != NULL);
- }
-
- return GL_FALSE;
+ return gl::IsSync(sync);
}
void GL_APIENTRY glDeleteSync(GLsync sync)
{
- EVENT("(GLsync sync = 0x%0.8p)", sync);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync))
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- context->deleteFenceSync(sync);
- }
+ return gl::DeleteSync(sync);
}
GLenum GL_APIENTRY glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
{
- EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
- sync, flags, timeout);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return GL_WAIT_FAILED;
- }
-
- if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return GL_WAIT_FAILED;
- }
-
- gl::FenceSync *fenceSync = context->getFenceSync(sync);
-
- if (!fenceSync)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return GL_WAIT_FAILED;
- }
-
- GLenum result = GL_WAIT_FAILED;
- gl::Error error = fenceSync->clientWait(flags, timeout, &result);
- if (error.isError())
- {
- context->recordError(error);
- return GL_WAIT_FAILED;
- }
-
- return result;
- }
-
- return GL_FALSE;
+ return gl::ClientWaitSync(sync, flags, timeout);
}
void GL_APIENTRY glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
{
- EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
- sync, flags, timeout);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (flags != 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- if (timeout != GL_TIMEOUT_IGNORED)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::FenceSync *fenceSync = context->getFenceSync(sync);
-
- if (!fenceSync)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::Error error = fenceSync->serverWait(flags, timeout);
- if (error.isError())
- {
- context->recordError(error);
- }
- }
+ return gl::WaitSync(sync, flags, timeout);
}
void GL_APIENTRY glGetInteger64v(GLenum pname, GLint64* params)
{
- EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
- pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- GLenum nativeType;
- unsigned int numParams = 0;
- if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
- {
- return;
- }
-
- if (nativeType == GL_INT_64_ANGLEX)
- {
- context->getInteger64v(pname, params);
- }
- else
- {
- CastStateValues(context, nativeType, pname, numParams, params);
- }
- }
+ return gl::GetInteger64v(pname, params);
}
void GL_APIENTRY glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
{
- EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
- sync, pname, bufSize, length, values);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (bufSize < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- gl::FenceSync *fenceSync = context->getFenceSync(sync);
-
- if (!fenceSync)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- switch (pname)
- {
- case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break;
- case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break;
- case GL_SYNC_FLAGS: values[0] = 0; break;
-
- case GL_SYNC_STATUS:
- {
- gl::Error error = fenceSync->getStatus(values);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- break;
- }
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::GetSynciv(sync, pname, bufSize, length, values);
}
void GL_APIENTRY glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
{
- EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
- target, index, data);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- const gl::Caps &caps = context->getCaps();
- switch (target)
- {
- case GL_TRANSFORM_FEEDBACK_BUFFER_START:
- case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
- case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
- if (index >= caps.maxTransformFeedbackSeparateAttributes)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- break;
-
- case GL_UNIFORM_BUFFER_START:
- case GL_UNIFORM_BUFFER_SIZE:
- case GL_UNIFORM_BUFFER_BINDING:
- if (index >= caps.maxUniformBufferBindings)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (!(context->getIndexedInteger64v(target, index, data)))
- {
- GLenum nativeType;
- unsigned int numParams = 0;
- if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (numParams == 0)
- return; // it is known that pname is valid, but there are no parameters to return
-
- if (nativeType == GL_INT)
- {
- GLint *intParams = new GLint[numParams];
-
- context->getIndexedIntegerv(target, index, intParams);
-
- for (unsigned int i = 0; i < numParams; ++i)
- {
- data[i] = static_cast<GLint64>(intParams[i]);
- }
-
- delete [] intParams;
- }
- else
- {
- UNREACHABLE();
- }
- }
- }
+ return gl::GetInteger64i_v(target, index, data);
}
void GL_APIENTRY glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
{
- EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
- target, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (!gl::ValidBufferTarget(context, target))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (!gl::ValidBufferParameter(context, pname))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::Buffer *buffer = context->getState().getTargetBuffer(target);
-
- if (!buffer)
- {
- // A null buffer means that "0" is bound to the requested buffer target
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- switch (pname)
- {
- case GL_BUFFER_USAGE:
- *params = static_cast<GLint64>(buffer->getUsage());
- break;
- case GL_BUFFER_SIZE:
- *params = buffer->getSize();
- break;
- case GL_BUFFER_ACCESS_FLAGS:
- *params = static_cast<GLint64>(buffer->getAccessFlags());
- break;
- case GL_BUFFER_MAPPED:
- *params = static_cast<GLint64>(buffer->isMapped());
- break;
- case GL_BUFFER_MAP_OFFSET:
- *params = buffer->getMapOffset();
- break;
- case GL_BUFFER_MAP_LENGTH:
- *params = buffer->getMapLength();
- break;
- default: UNREACHABLE(); break;
- }
- }
+ return gl::GetBufferParameteri64v(target, pname, params);
}
void GL_APIENTRY glGenSamplers(GLsizei count, GLuint* samplers)
{
- EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (count < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (int i = 0; i < count; i++)
- {
- samplers[i] = context->createSampler();
- }
- }
+ return gl::GenSamplers(count, samplers);
}
void GL_APIENTRY glDeleteSamplers(GLsizei count, const GLuint* samplers)
{
- EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (count < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- for (int i = 0; i < count; i++)
- {
- context->deleteSampler(samplers[i]);
- }
- }
+ return gl::DeleteSamplers(count, samplers);
}
GLboolean GL_APIENTRY glIsSampler(GLuint sampler)
{
- EVENT("(GLuint sampler = %u)", sampler);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return GL_FALSE;
- }
-
- return context->isSampler(sampler);
- }
-
- return GL_FALSE;
+ return gl::IsSampler(sampler);
}
void GL_APIENTRY glBindSampler(GLuint unit, GLuint sampler)
{
- EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (sampler != 0 && !context->isSampler(sampler))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (unit >= context->getCaps().maxCombinedTextureImageUnits)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- context->bindSampler(unit, sampler);
- }
+ return gl::BindSampler(unit, sampler);
}
void GL_APIENTRY glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
{
- EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (!gl::ValidateSamplerObjectParameter(context, pname))
- {
- return;
- }
-
- if (!gl::ValidateTexParamParameters(context, pname, param))
- {
- return;
- }
-
- if (!context->isSampler(sampler))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- context->samplerParameteri(sampler, pname, param);
- }
+ return gl::SamplerParameteri(sampler, pname, param);
}
void GL_APIENTRY glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
{
- glSamplerParameteri(sampler, pname, *param);
+ return gl::SamplerParameteriv(sampler, pname, param);
}
void GL_APIENTRY glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
{
- EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (!gl::ValidateSamplerObjectParameter(context, pname))
- {
- return;
- }
-
- if (!gl::ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
- {
- return;
- }
-
- if (!context->isSampler(sampler))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- context->samplerParameterf(sampler, pname, param);
- }
+ return gl::SamplerParameterf(sampler, pname, param);
}
void GL_APIENTRY glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
{
- glSamplerParameterf(sampler, pname, *param);
+ return gl::SamplerParameterfv(sampler, pname, param);
}
void GL_APIENTRY glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
{
- EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
+ return gl::GetSamplerParameteriv(sampler, pname, params);
+}
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
+void GL_APIENTRY glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
+{
+ return gl::GetSamplerParameterfv(sampler, pname, params);
+}
- if (!gl::ValidateSamplerObjectParameter(context, pname))
- {
- return;
- }
+void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor)
+{
+ return gl::VertexAttribDivisor(index, divisor);
+}
- if (!context->isSampler(sampler))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
+void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id)
+{
+ return gl::BindTransformFeedback(target, id);
+}
- *params = context->getSamplerParameteri(sampler, pname);
- }
+void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
+{
+ return gl::DeleteTransformFeedbacks(n, ids);
}
-void GL_APIENTRY glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
+void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint* ids)
{
- EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
+ return gl::GenTransformFeedbacks(n, ids);
+}
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
+GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id)
+{
+ return gl::IsTransformFeedback(id);
+}
- if (!gl::ValidateSamplerObjectParameter(context, pname))
- {
- return;
- }
+void GL_APIENTRY glPauseTransformFeedback(void)
+{
+ return gl::PauseTransformFeedback();
+}
- if (!context->isSampler(sampler))
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
+void GL_APIENTRY glResumeTransformFeedback(void)
+{
+ return gl::ResumeTransformFeedback();
+}
- *params = context->getSamplerParameterf(sampler, pname);
- }
+void GL_APIENTRY glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
+{
+ return gl::GetProgramBinary(program, bufSize, length, binaryFormat, binary);
}
-void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor)
+void GL_APIENTRY glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
{
- EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
+ return gl::ProgramBinary(program, binaryFormat, binary, length);
+}
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
+void GL_APIENTRY glProgramParameteri(GLuint program, GLenum pname, GLint value)
+{
+ return gl::ProgramParameteri(program, pname, value);
+}
- if (index >= gl::MAX_VERTEX_ATTRIBS)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
+void GL_APIENTRY glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
+{
+ return gl::InvalidateFramebuffer(target, numAttachments, attachments);
+}
- context->setVertexAttribDivisor(index, divisor);
- }
+void GL_APIENTRY glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ return gl::InvalidateSubFramebuffer(target, numAttachments, attachments, x, y, width, height);
}
-void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id)
+void GL_APIENTRY glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
{
- EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- switch (target)
- {
- case GL_TRANSFORM_FEEDBACK:
- {
- // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
- gl::TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
- if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1)
- if (context->getTransformFeedback(id) == NULL)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- context->bindTransformFeedback(id);
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::TexStorage2D(target, levels, internalformat, width, height);
}
-void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
+void GL_APIENTRY glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
{
- EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
+ return gl::TexStorage3D(target, levels, internalformat, width, height, depth);
+}
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
+void GL_APIENTRY glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
+{
+ return gl::GetInternalformativ(target, internalformat, pname, bufSize, params);
+}
- for (int i = 0; i < n; i++)
- {
- context->deleteTransformFeedback(ids[i]);
- }
- }
+void GL_APIENTRY glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
+{
+ return gl::BlitFramebufferANGLE(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
}
-void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint* ids)
+void GL_APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
{
- EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
+ return gl::RenderbufferStorageMultisampleANGLE(target, samples, internalformat, width, height);
+}
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
+void GL_APIENTRY glDeleteFencesNV(GLsizei n, const GLuint* fences)
+{
+ return gl::DeleteFencesNV(n, fences);
+}
- for (int i = 0; i < n; i++)
- {
- ids[i] = context->createTransformFeedback();
- }
- }
+void GL_APIENTRY glGenFencesNV(GLsizei n, GLuint* fences)
+{
+ return gl::GenFencesNV(n, fences);
}
-GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id)
+GLboolean GL_APIENTRY glIsFenceNV(GLuint fence)
{
- EVENT("(GLuint id = %u)", id);
+ return gl::IsFenceNV(fence);
+}
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return GL_FALSE;
- }
+GLboolean GL_APIENTRY glTestFenceNV(GLuint fence)
+{
+ return gl::TestFenceNV(fence);
+}
- return ((context->getTransformFeedback(id) != NULL) ? GL_TRUE : GL_FALSE);
- }
+void GL_APIENTRY glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
+{
+ return gl::GetFenceivNV(fence, pname, params);
+}
- return GL_FALSE;
+void GL_APIENTRY glFinishFenceNV(GLuint fence)
+{
+ return gl::FinishFenceNV(fence);
}
-void GL_APIENTRY glPauseTransformFeedback(void)
+void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition)
{
- EVENT("(void)");
+ return gl::SetFenceNV(fence, condition);
+}
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
+void GL_APIENTRY glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source)
+{
+ return gl::GetTranslatedShaderSourceANGLE(shader, bufsize, length, source);
+}
- gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
- ASSERT(transformFeedback != NULL);
+void GL_APIENTRY glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
+{
+ return gl::TexStorage2DEXT(target, levels, internalformat, width, height);
+}
- // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86)
- if (!transformFeedback->isStarted() || transformFeedback->isPaused())
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
+GLenum GL_APIENTRY glGetGraphicsResetStatusEXT(void)
+{
+ return gl::GetGraphicsResetStatusEXT();
+}
- transformFeedback->pause();
- }
+void GL_APIENTRY glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data)
+{
+ return gl::ReadnPixelsEXT(x, y, width, height, format, type, bufSize, data);
}
-void GL_APIENTRY glResumeTransformFeedback(void)
+void GL_APIENTRY glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, float *params)
{
- EVENT("(void)");
+ return gl::GetnUniformfvEXT(program, location, bufSize, params);
+}
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
+void GL_APIENTRY glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint *params)
+{
+ return gl::GetnUniformivEXT(program, location, bufSize, params);
+}
- gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
- ASSERT(transformFeedback != NULL);
+void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint *ids)
+{
+ return gl::GenQueriesEXT(n, ids);
+}
- // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86)
- if (!transformFeedback->isStarted() || !transformFeedback->isPaused())
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
+void GL_APIENTRY glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
+{
+ return gl::DeleteQueriesEXT(n, ids);
+}
- transformFeedback->resume();
- }
+GLboolean GL_APIENTRY glIsQueryEXT(GLuint id)
+{
+ return gl::IsQueryEXT(id);
}
-void GL_APIENTRY glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
+void GL_APIENTRY glBeginQueryEXT(GLenum target, GLuint id)
{
- EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
- program, bufSize, length, binaryFormat, binary);
+ return gl::BeginQueryEXT(target, id);
+}
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
+void GL_APIENTRY glEndQueryEXT(GLenum target)
+{
+ return gl::EndQueryEXT(target);
+}
- // glGetProgramBinary
- UNIMPLEMENTED();
- }
+void GL_APIENTRY glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
+{
+ return gl::GetQueryivEXT(target, pname, params);
}
-void GL_APIENTRY glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
+void GL_APIENTRY glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
{
- EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
- program, binaryFormat, binary, length);
+ return gl::GetQueryObjectuivEXT(id, pname, params);
+}
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
+void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
+{
+ return gl::DrawBuffersEXT(n, bufs);
+}
- // glProgramBinary
- UNIMPLEMENTED();
- }
+void GL_APIENTRY glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
+{
+ return gl::DrawArraysInstancedANGLE(mode, first, count, primcount);
}
-void GL_APIENTRY glProgramParameteri(GLuint program, GLenum pname, GLint value)
+void GL_APIENTRY glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount)
{
- EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
- program, pname, value);
+ return gl::DrawElementsInstancedANGLE(mode, count, type, indices, primcount);
+}
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
+void GL_APIENTRY glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
+{
+ return gl::VertexAttribDivisorANGLE(index, divisor);
+}
- // glProgramParameteri
- UNIMPLEMENTED();
- }
+void GL_APIENTRY glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary)
+{
+ return gl::GetProgramBinaryOES(program, bufSize, length, binaryFormat, binary);
}
-void GL_APIENTRY glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
+void GL_APIENTRY glProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length)
{
- EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
- target, numAttachments, attachments);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
- {
- return;
- }
-
- gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
- ASSERT(framebuffer);
-
- if (framebuffer->completeness(context->getData()) == GL_FRAMEBUFFER_COMPLETE)
- {
- gl::Error error = framebuffer->invalidate(context->getCaps(), numAttachments, attachments);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- }
+ return gl::ProgramBinaryOES(program, binaryFormat, binary, length);
}
-void GL_APIENTRY glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
+void* GL_APIENTRY glMapBufferOES(GLenum target, GLenum access)
{
- EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
- "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
- target, numAttachments, attachments, x, y, width, height);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
- {
- return;
- }
-
- gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
- ASSERT(framebuffer);
-
- if (framebuffer->completeness(context->getData()) == GL_FRAMEBUFFER_COMPLETE)
- {
- gl::Error error = framebuffer->invalidateSub(numAttachments, attachments, x, y, width, height);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- }
+ return gl::MapBufferOES(target, access);
}
-void GL_APIENTRY glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
+GLboolean GL_APIENTRY glUnmapBufferOES(GLenum target)
{
- EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
- target, levels, internalformat, width, height);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
- {
- return;
- }
-
- switch (target)
- {
- case GL_TEXTURE_2D:
- {
- gl::Texture2D *texture2d = context->getTexture2D();
- gl::Error error = texture2d->storage(levels, internalformat, width, height);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- case GL_TEXTURE_CUBE_MAP:
- {
- gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
- gl::Error error = textureCube->storage(levels, internalformat, width);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
+ return gl::UnmapBufferOES(target);
}
-void GL_APIENTRY glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
+void GL_APIENTRY glGetBufferPointervOES(GLenum target, GLenum pname, GLvoid **params)
{
- EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
- "GLsizei height = %d, GLsizei depth = %d)",
- target, levels, internalformat, width, height, depth);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
- {
- return;
- }
-
- switch (target)
- {
- case GL_TEXTURE_3D:
- {
- gl::Texture3D *texture3d = context->getTexture3D();
- gl::Error error = texture3d->storage(levels, internalformat, width, height, depth);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- case GL_TEXTURE_2D_ARRAY:
- {
- gl::Texture2DArray *texture2darray = context->getTexture2DArray();
- gl::Error error = texture2darray->storage(levels, internalformat, width, height, depth);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
-
- default:
- UNREACHABLE();
- }
- }
+ return gl::GetBufferPointervOES(target, pname, params);
}
-void GL_APIENTRY glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
+void* GL_APIENTRY glMapBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
{
- EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
- "GLint* params = 0x%0.8p)",
- target, internalformat, pname, bufSize, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
- if (!formatCaps.renderable)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (target != GL_RENDERBUFFER)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (bufSize < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- switch (pname)
- {
- case GL_NUM_SAMPLE_COUNTS:
- if (bufSize != 0)
- {
- *params = formatCaps.sampleCounts.size();
- }
- break;
-
- case GL_SAMPLES:
- std::copy_n(formatCaps.sampleCounts.rbegin(), std::min<size_t>(bufSize, formatCaps.sampleCounts.size()), params);
- break;
-
- default:
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
- }
-}
-
-// Extension functions
-
-void GL_APIENTRY glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
- GLbitfield mask, GLenum filter)
-{
- EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
- "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
- "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
- srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1, mask, filter,
- true))
- {
- return;
- }
-
- gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
- mask, filter);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
-}
-
-void GL_APIENTRY glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
- GLint border, GLenum format, GLenum type, const GLvoid* pixels)
-{
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
- "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
- "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
- target, level, internalformat, width, height, depth, border, format, type, pixels);
-
- UNIMPLEMENTED(); // FIXME
-}
-
-void GL_APIENTRY glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
- GLenum *binaryFormat, void *binary)
-{
- EVENT("(GLenum program = 0x%X, bufSize = %d, length = 0x%0.8p, binaryFormat = 0x%0.8p, binary = 0x%0.8p)",
- program, bufSize, length, binaryFormat, binary);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject || !programObject->isLinked())
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
-
- if (!programBinary)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- gl::Error error = programBinary->save(binaryFormat, binary, bufSize, length);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
-}
-
-void GL_APIENTRY glProgramBinaryOES(GLuint program, GLenum binaryFormat,
- const void *binary, GLint length)
-{
- EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
- program, binaryFormat, binary, length);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- const std::vector<GLenum> &programBinaryFormats = context->getCaps().programBinaryFormats;
- if (std::find(programBinaryFormats.begin(), programBinaryFormats.end(), binaryFormat) == programBinaryFormats.end())
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::Program *programObject = context->getProgram(program);
- if (!programObject)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- gl::Error error = context->setProgramBinary(program, binaryFormat, binary, length);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
+ return gl::MapBufferRangeEXT(target, offset, length, access);
}
-void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
+void GL_APIENTRY glFlushMappedBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length)
{
- EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (n < 0 || static_cast<GLuint>(n) > context->getCaps().maxDrawBuffers)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- ASSERT(context->getState().getDrawFramebuffer());
-
- if (context->getState().getDrawFramebuffer()->id() == 0)
- {
- if (n != 1)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- }
- else
- {
- for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
- {
- const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
- if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
- }
- }
-
- gl::Framebuffer *framebuffer = context->getState().getDrawFramebuffer();
- ASSERT(framebuffer);
-
- for (unsigned int colorAttachment = 0; colorAttachment < static_cast<unsigned int>(n); colorAttachment++)
- {
- framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
- }
-
- for (unsigned int colorAttachment = n; colorAttachment < context->getCaps().maxDrawBuffers; colorAttachment++)
- {
- framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
- }
- }
-}
-
-void GL_APIENTRY glGetBufferPointervOES(GLenum target, GLenum pname, void** params)
-{
- EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!gl::ValidBufferTarget(context, target))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- if (pname != GL_BUFFER_MAP_POINTER)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::Buffer *buffer = context->getState().getTargetBuffer(target);
-
- if (!buffer || !buffer->isMapped())
- {
- *params = NULL;
- }
- else
- {
- *params = buffer->getMapPointer();
- }
- }
-}
-
-void * GL_APIENTRY glMapBufferOES(GLenum target, GLenum access)
-{
- EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!gl::ValidBufferTarget(context, target))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return NULL;
- }
-
- gl::Buffer *buffer = context->getState().getTargetBuffer(target);
-
- if (buffer == NULL)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return NULL;
- }
-
- if (access != GL_WRITE_ONLY_OES)
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return NULL;
- }
-
- if (buffer->isMapped())
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return NULL;
- }
-
- gl::Error error = buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT);
- if (error.isError())
- {
- context->recordError(error);
- return NULL;
- }
-
- return buffer->getMapPointer();
- }
-
- return NULL;
+ return gl::FlushMappedBufferRangeEXT(target, offset, length);
}
-GLboolean GL_APIENTRY glUnmapBufferOES(GLenum target)
+void GL_APIENTRY SetTraceFunctionPointers(GetCategoryEnabledFlagFunc getCategoryEnabledFlag,
+ AddTraceEventFunc addTraceEvent)
{
- EVENT("(GLenum target = 0x%X)", target);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!gl::ValidBufferTarget(context, target))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return GL_FALSE;
- }
-
- gl::Buffer *buffer = context->getState().getTargetBuffer(target);
-
- if (buffer == NULL || !buffer->isMapped())
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return GL_FALSE;
- }
-
- // TODO: detect if we had corruption. if so, throw an error and return false.
-
- gl::Error error = buffer->unmap();
- if (error.isError())
- {
- context->recordError(error);
- return GL_FALSE;
- }
-
- return GL_TRUE;
- }
-
- return GL_FALSE;
-}
-
-void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
-{
- EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
- target, offset, length, access);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (!gl::ValidBufferTarget(context, target))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return NULL;
- }
-
- if (offset < 0 || length < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return NULL;
- }
-
- gl::Buffer *buffer = context->getState().getTargetBuffer(target);
-
- if (buffer == NULL)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return NULL;
- }
-
- // Check for buffer overflow
- size_t offsetSize = static_cast<size_t>(offset);
- size_t lengthSize = static_cast<size_t>(length);
-
- if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
- offsetSize + lengthSize > static_cast<size_t>(buffer->getSize()))
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return NULL;
- }
-
- // Check for invalid bits in the mask
- GLbitfield allAccessBits = GL_MAP_READ_BIT |
- GL_MAP_WRITE_BIT |
- GL_MAP_INVALIDATE_RANGE_BIT |
- GL_MAP_INVALIDATE_BUFFER_BIT |
- GL_MAP_FLUSH_EXPLICIT_BIT |
- GL_MAP_UNSYNCHRONIZED_BIT;
-
- if (access & ~(allAccessBits))
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return NULL;
- }
-
- if (length == 0 || buffer->isMapped())
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return NULL;
- }
-
- // Check for invalid bit combinations
- if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return NULL;
- }
-
- GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT |
- GL_MAP_INVALIDATE_BUFFER_BIT |
- GL_MAP_UNSYNCHRONIZED_BIT;
-
- if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return NULL;
- }
-
- if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return NULL;
- }
-
- gl::Error error = buffer->mapRange(offset, length, access);
- if (error.isError())
- {
- context->recordError(error);
- return NULL;
- }
-
- return buffer->getMapPointer();
- }
-
- return NULL;
-}
-
-void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length)
-{
- EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- if (offset < 0 || length < 0)
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- if (!gl::ValidBufferTarget(context, target))
- {
- context->recordError(gl::Error(GL_INVALID_ENUM));
- return;
- }
-
- gl::Buffer *buffer = context->getState().getTargetBuffer(target);
-
- if (buffer == NULL)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0)
- {
- context->recordError(gl::Error(GL_INVALID_OPERATION));
- return;
- }
-
- // Check for buffer overflow
- size_t offsetSize = static_cast<size_t>(offset);
- size_t lengthSize = static_cast<size_t>(length);
-
- if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
- offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength()))
- {
- context->recordError(gl::Error(GL_INVALID_VALUE));
- return;
- }
-
- // We do not currently support a non-trivial implementation of FlushMappedBufferRange
- }
-}
-
-__eglMustCastToProperFunctionPointerType EGLAPIENTRY glGetProcAddress(const char *procname)
-{
- struct Extension
- {
- const char *name;
- __eglMustCastToProperFunctionPointerType address;
- };
-
- static const Extension glExtensions[] =
- {
- {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
- {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
- {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
- {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
- {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
- {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
- {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
- {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
- {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
- {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
- {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
- {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
- {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
- {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
- {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
- {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
- {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
- {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
- {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
- {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
- {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
- {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
- {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
- {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
- {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
- {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
- {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
- {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
- {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES},
- {"glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES},
- {"glMapBufferOES", (__eglMustCastToProperFunctionPointerType)glMapBufferOES},
- {"glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES},
- {"glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glMapBufferRangeEXT},
- {"glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glFlushMappedBufferRangeEXT}, };
-
- for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
- {
- if (strcmp(procname, glExtensions[ext].name) == 0)
- {
- return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
- }
- }
-
- return NULL;
-}
-
-// Non-public functions used by EGL
-
-bool EGLAPIENTRY glBindTexImage(egl::Surface *surface)
-{
- EVENT("(egl::Surface* surface = 0x%0.8p)",
- surface);
-
- gl::Context *context = gl::getNonLostContext();
- if (context)
- {
- gl::Texture2D *textureObject = context->getTexture2D();
- ASSERT(textureObject != NULL);
-
- if (textureObject->isImmutable())
- {
- return false;
- }
-
- textureObject->bindTexImage(surface);
- }
-
- return true;
+ gl::g_getCategoryEnabledFlag = getCategoryEnabledFlag;
+ gl::g_addTraceEvent = addTraceEvent;
}
}
diff --git a/src/3rdparty/angle/src/libGLESv2/libGLESv2.def b/src/3rdparty/angle/src/libGLESv2/libGLESv2.def
index 33557eb1c9..9c6dc497d0 100644
--- a/src/3rdparty/angle/src/libGLESv2/libGLESv2.def
+++ b/src/3rdparty/angle/src/libGLESv2/libGLESv2.def
@@ -144,7 +144,6 @@ EXPORTS
glViewport @142
; Extensions
- glTexImage3DOES @143
glBlitFramebufferANGLE @149
glRenderbufferStorageMultisampleANGLE @150
glDeleteFencesNV @151
@@ -285,12 +284,5 @@ EXPORTS
glTexStorage3D @282
glGetInternalformativ @283
- ; EGL dependencies
- glCreateContext @144 NONAME
- glDestroyContext @145 NONAME
- glMakeCurrent @146 NONAME
- glGetCurrentContext @147 NONAME
- glGetProcAddress @148 NONAME
- glBindTexImage @158 NONAME
- glCreateRenderer @177 NONAME
- glDestroyRenderer @178 NONAME
+ ; Setting up TRACE macro callbacks
+ SetTraceFunctionPointers @284
diff --git a/src/3rdparty/angle/src/libGLESv2/libGLESv2.rc b/src/3rdparty/angle/src/libGLESv2/libGLESv2.rc
deleted file mode 100644
index 76cd05566e..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/libGLESv2.rc
+++ /dev/null
@@ -1,103 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include <windows.h>
-#include "../common/version.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-#endif //_WIN32
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "#include ""../common/version.h""\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION ANGLE_MAJOR_VERSION,ANGLE_MINOR_VERSION,0,0
- PRODUCTVERSION ANGLE_MAJOR_VERSION,ANGLE_MINOR_VERSION,0,0
- FILEFLAGSMASK 0x17L
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x4L
- FILETYPE 0x2L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "FileDescription", "ANGLE libGLESv2 Dynamic Link Library"
- VALUE "FileVersion", ANGLE_VERSION_STRING
- VALUE "InternalName", "libGLESv2"
- VALUE "LegalCopyright", "Copyright (C) 2011 Google Inc."
- VALUE "OriginalFilename", "libGLESv2.dll"
- VALUE "PrivateBuild", ANGLE_VERSION_STRING
- VALUE "ProductName", "ANGLE libGLESv2 Dynamic Link Library"
- VALUE "ProductVersion", ANGLE_VERSION_STRING
- VALUE "Comments", "Build Date: " ANGLE_COMMIT_DATE
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-#endif // English (U.S.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
diff --git a/src/3rdparty/angle/src/libGLESv2/libGLESv2_mingw32.def b/src/3rdparty/angle/src/libGLESv2/libGLESv2_mingw32.def
index 18ffcf6a0d..e02b85bcf2 100644
--- a/src/3rdparty/angle/src/libGLESv2/libGLESv2_mingw32.def
+++ b/src/3rdparty/angle/src/libGLESv2/libGLESv2_mingw32.def
@@ -144,7 +144,6 @@ EXPORTS
glViewport@16 @142
; Extensions
- glTexImage3DOES@40 @143
glBlitFramebufferANGLE@40 @149
glRenderbufferStorageMultisampleANGLE@20 @150
glDeleteFencesNV@8 @151
@@ -285,12 +284,5 @@ EXPORTS
glTexStorage3D@24 @282
glGetInternalformativ@20 @283
- ; EGL dependencies
- glCreateContext @144 NONAME
- glDestroyContext @145 NONAME
- glMakeCurrent @146 NONAME
- glGetCurrentContext @147 NONAME
- glGetProcAddress@4 @148 NONAME
- glBindTexImage@4 @158 NONAME
- glCreateRenderer @177 NONAME
- glDestroyRenderer @178 NONAME
+ ; Setting up TRACE macro callbacks
+ SetTraceFunctionPointers@8 @284
diff --git a/src/3rdparty/angle/src/libGLESv2/libGLESv2d.def b/src/3rdparty/angle/src/libGLESv2/libGLESv2d.def
index 120371e013..d35309c6ce 100644
--- a/src/3rdparty/angle/src/libGLESv2/libGLESv2d.def
+++ b/src/3rdparty/angle/src/libGLESv2/libGLESv2d.def
@@ -144,7 +144,6 @@ EXPORTS
glViewport @142
; Extensions
- glTexImage3DOES @143
glBlitFramebufferANGLE @149
glRenderbufferStorageMultisampleANGLE @150
glDeleteFencesNV @151
@@ -285,12 +284,5 @@ EXPORTS
glTexStorage3D @282
glGetInternalformativ @283
- ; EGL dependencies
- glCreateContext @144 NONAME
- glDestroyContext @145 NONAME
- glMakeCurrent @146 NONAME
- glGetCurrentContext @147 NONAME
- glGetProcAddress @148 NONAME
- glBindTexImage @158 NONAME
- glCreateRenderer @177 NONAME
- glDestroyRenderer @178 NONAME
+ ; Setting up TRACE macro callbacks
+ SetTraceFunctionPointers @284
diff --git a/src/3rdparty/angle/src/libGLESv2/libGLESv2d_mingw32.def b/src/3rdparty/angle/src/libGLESv2/libGLESv2d_mingw32.def
index 8c1306a703..e2b2c333a1 100644
--- a/src/3rdparty/angle/src/libGLESv2/libGLESv2d_mingw32.def
+++ b/src/3rdparty/angle/src/libGLESv2/libGLESv2d_mingw32.def
@@ -144,7 +144,6 @@ EXPORTS
glViewport@16 @142
; Extensions
- glTexImage3DOES@40 @143
glBlitFramebufferANGLE@40 @149
glRenderbufferStorageMultisampleANGLE@20 @150
glDeleteFencesNV@8 @151
@@ -285,12 +284,5 @@ EXPORTS
glTexStorage3D@24 @282
glGetInternalformativ@20 @283
- ; EGL dependencies
- glCreateContext @144 NONAME
- glDestroyContext @145 NONAME
- glMakeCurrent @146 NONAME
- glGetCurrentContext @147 NONAME
- glGetProcAddress@4 @148 NONAME
- glBindTexImage@4 @158 NONAME
- glCreateRenderer @177 NONAME
- glDestroyRenderer @178 NONAME
+ ; Setting up TRACE macro callbacks
+ SetTraceFunctionPointers@8 @284
diff --git a/src/3rdparty/angle/src/libGLESv2/main.cpp b/src/3rdparty/angle/src/libGLESv2/main.cpp
deleted file mode 100644
index 00f63ae079..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/main.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-//
-// 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.
-//
-
-// main.cpp: DLL entry point and management of thread-local data.
-
-#include "libGLESv2/main.h"
-#include "libGLESv2/Context.h"
-
-#include "common/tls.h"
-
-static TLSIndex currentTLS = TLS_INVALID_INDEX;
-
-namespace gl
-{
-
-// TODO(kbr): figure out how these are going to be managed on
-// non-Windows platforms. These routines would need to be exported
-// from ANGLE and called cooperatively when users create and destroy
-// threads -- or the initialization of the TLS index, and allocation
-// of thread-local data, will have to be done lazily. Will have to use
-// destructor function with pthread_create_key on POSIX platforms to
-// clean up thread-local data.
-
-// Call this exactly once at process startup.
-bool CreateThreadLocalIndex()
-{
- currentTLS = CreateTLSIndex();
- if (currentTLS == TLS_INVALID_INDEX)
- {
- return false;
- }
- return true;
-}
-
-// Call this exactly once at process shutdown.
-void DestroyThreadLocalIndex()
-{
- DestroyTLSIndex(currentTLS);
- currentTLS = TLS_INVALID_INDEX;
-}
-
-// Call this upon thread startup.
-Current *AllocateCurrent()
-{
- ASSERT(currentTLS != TLS_INVALID_INDEX);
- if (currentTLS == TLS_INVALID_INDEX)
- {
- return NULL;
- }
-
- Current *current = new Current();
- current->context = NULL;
- current->display = NULL;
-
- if (!SetTLSValue(currentTLS, current))
- {
- ERR("Could not set thread local storage.");
- return NULL;
- }
-
- return current;
-}
-
-// Call this upon thread shutdown.
-void DeallocateCurrent()
-{
- Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS));
- SafeDelete(current);
- SetTLSValue(currentTLS, NULL);
-}
-
-}
-
-#if defined(ANGLE_PLATFORM_WINDOWS) && !defined(QT_OPENGL_ES_2_ANGLE_STATIC)
-extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
-{
- switch (reason)
- {
- case DLL_PROCESS_ATTACH:
- {
- if (!gl::CreateThreadLocalIndex())
- {
- return FALSE;
- }
-
-#ifdef ANGLE_ENABLE_DEBUG_ANNOTATIONS
- gl::InitializeDebugAnnotations();
-#endif
- }
- // Fall through to initialize index
- case DLL_THREAD_ATTACH:
- {
- gl::AllocateCurrent();
- }
- break;
- case DLL_THREAD_DETACH:
- {
- gl::DeallocateCurrent();
- }
- break;
- case DLL_PROCESS_DETACH:
- {
- gl::DeallocateCurrent();
- gl::DestroyThreadLocalIndex();
-
-#ifdef ANGLE_ENABLE_DEBUG_ANNOTATIONS
- gl::UninitializeDebugAnnotations();
-#endif
- }
- break;
- default:
- break;
- }
-
- return TRUE;
-}
-#endif // ANGLE_PLATFORM_WINDOWS && !QT_OPENGL_ES_2_ANGLE_STATIC
-
-namespace gl
-{
-
-Current *GetCurrentData()
-{
-#ifndef QT_OPENGL_ES_2_ANGLE_STATIC
- Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS));
-
- // ANGLE issue 488: when the dll is loaded after thread initialization,
- // thread local storage (current) might not exist yet.
- return (current ? current : AllocateCurrent());
-#else
- // No precautions for thread safety taken as ANGLE is used single-threaded in Qt.
- static Current current = { 0, 0 };
- return &current;
-#endif
-}
-
-void makeCurrent(Context *context, egl::Display *display, egl::Surface *surface)
-{
- Current *current = GetCurrentData();
-
- current->context = context;
- current->display = display;
-
- if (context && display && surface)
- {
- context->makeCurrent(surface);
- }
-}
-
-Context *getContext()
-{
- Current *current = GetCurrentData();
-
- return current->context;
-}
-
-Context *getNonLostContext()
-{
- Context *context = getContext();
-
- if (context)
- {
- if (context->isContextLost())
- {
- context->recordError(Error(GL_OUT_OF_MEMORY, "Context has been lost."));
- return NULL;
- }
- else
- {
- return context;
- }
- }
- return NULL;
-}
-
-egl::Display *getDisplay()
-{
- Current *current = GetCurrentData();
-
- return current->display;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/main.h b/src/3rdparty/angle/src/libGLESv2/main.h
deleted file mode 100644
index dff02787f5..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/main.h
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-// Copyright (c) 2002-2013 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.
-//
-
-// main.h: Management of thread-local data.
-
-#ifndef LIBGLESV2_MAIN_H_
-#define LIBGLESV2_MAIN_H_
-
-#include "common/debug.h"
-
-#include <GLES2/gl2.h>
-#include <EGL/egl.h>
-
-namespace egl
-{
-class Display;
-class Surface;
-class AttributeMap;
-}
-
-namespace gl
-{
-class Context;
-
-struct Current
-{
- Context *context;
- egl::Display *display;
-};
-
-void makeCurrent(Context *context, egl::Display *display, egl::Surface *surface);
-
-Context *getContext();
-Context *getNonLostContext();
-egl::Display *getDisplay();
-
-}
-
-namespace rx
-{
-class Renderer;
-}
-
-extern "C"
-{
-// Exported functions for use by EGL
-gl::Context *glCreateContext(int clientVersion, const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess);
-void glDestroyContext(gl::Context *context);
-void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *surface);
-gl::Context *glGetCurrentContext();
-rx::Renderer *glCreateRenderer(egl::Display *display, EGLNativeDisplayType nativeDisplay, const egl::AttributeMap &attribMap);
-void glDestroyRenderer(rx::Renderer *renderer);
-
-__eglMustCastToProperFunctionPointerType EGLAPIENTRY glGetProcAddress(const char *procname);
-bool EGLAPIENTRY glBindTexImage(egl::Surface *surface);
-}
-
-#endif // LIBGLESV2_MAIN_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/queryconversions.cpp b/src/3rdparty/angle/src/libGLESv2/queryconversions.cpp
deleted file mode 100644
index 7245902c51..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/queryconversions.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// queryconversions.cpp: Implementation of state query cast conversions
-
-#include "libGLESv2/Context.h"
-#include "common/utilities.h"
-
-namespace gl
-{
-
-// Helper class for converting a GL type to a GLenum:
-// We can't use CastStateValueEnum generally, because of GLboolean + GLubyte overlap.
-// We restrict our use to CastStateValue, where it eliminates duplicate parameters.
-
-template <typename GLType>
-struct CastStateValueEnum { static GLenum mEnumForType; };
-
-template <> GLenum CastStateValueEnum<GLint>::mEnumForType = GL_INT;
-template <> GLenum CastStateValueEnum<GLuint>::mEnumForType = GL_UNSIGNED_INT;
-template <> GLenum CastStateValueEnum<GLboolean>::mEnumForType = GL_BOOL;
-template <> GLenum CastStateValueEnum<GLint64>::mEnumForType = GL_INT_64_ANGLEX;
-template <> GLenum CastStateValueEnum<GLfloat>::mEnumForType = GL_FLOAT;
-
-template <typename QueryT, typename NativeT>
-QueryT CastStateValueToInt(GLenum pname, NativeT value)
-{
- GLenum queryType = CastStateValueEnum<QueryT>::mEnumForType;
- GLenum nativeType = CastStateValueEnum<NativeT>::mEnumForType;
-
- if (nativeType == GL_FLOAT)
- {
- // RGBA color values and DepthRangeF values are converted to integer using Equation 2.4 from Table 4.5
- if (pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE || pname == GL_BLEND_COLOR)
- {
- return static_cast<QueryT>((static_cast<GLfloat>(0xFFFFFFFF) * value - 1.0f) / 2.0f);
- }
- else
- {
- return gl::iround<QueryT>(value);
- }
- }
-
- // Clamp 64-bit int values when casting to int
- if (nativeType == GL_INT_64_ANGLEX && queryType == GL_INT)
- {
- GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<GLint>::min());
- GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<GLint>::max());
- GLint64 clampedValue = std::max(std::min(static_cast<GLint64>(value), maxIntValue), minIntValue);
- return static_cast<QueryT>(clampedValue);
- }
-
- return static_cast<QueryT>(value);
-}
-
-template <typename QueryT, typename NativeT>
-QueryT CastStateValue(GLenum pname, NativeT value)
-{
- GLenum queryType = CastStateValueEnum<QueryT>::mEnumForType;
-
- switch (queryType)
- {
- case GL_INT: return CastStateValueToInt<QueryT, NativeT>(pname, value);
- case GL_INT_64_ANGLEX: return CastStateValueToInt<QueryT, NativeT>(pname, value);
- case GL_FLOAT: return static_cast<QueryT>(value);
- case GL_BOOL: return (value == static_cast<NativeT>(0) ? GL_FALSE : GL_TRUE);
- default: UNREACHABLE(); return 0;
- }
-}
-
-template <typename QueryT>
-void CastStateValues(Context *context, GLenum nativeType, GLenum pname,
- unsigned int numParams, QueryT *outParams)
-{
- if (nativeType == GL_INT)
- {
- GLint *intParams = NULL;
- intParams = new GLint[numParams];
-
- context->getIntegerv(pname, intParams);
-
- for (unsigned int i = 0; i < numParams; ++i)
- {
- outParams[i] = CastStateValue<QueryT>(pname, intParams[i]);
- }
-
- delete [] intParams;
- }
- else if (nativeType == GL_BOOL)
- {
- GLboolean *boolParams = NULL;
- boolParams = new GLboolean[numParams];
-
- context->getBooleanv(pname, boolParams);
-
- for (unsigned int i = 0; i < numParams; ++i)
- {
- outParams[i] = (boolParams[i] == GL_FALSE ? static_cast<QueryT>(0) : static_cast<QueryT>(1));
- }
-
- delete [] boolParams;
- }
- else if (nativeType == GL_FLOAT)
- {
- GLfloat *floatParams = NULL;
- floatParams = new GLfloat[numParams];
-
- context->getFloatv(pname, floatParams);
-
- for (unsigned int i = 0; i < numParams; ++i)
- {
- outParams[i] = CastStateValue<QueryT>(pname, floatParams[i]);
- }
-
- delete [] floatParams;
- }
- else if (nativeType == GL_INT_64_ANGLEX)
- {
- GLint64 *int64Params = NULL;
- int64Params = new GLint64[numParams];
-
- context->getInteger64v(pname, int64Params);
-
- for (unsigned int i = 0; i < numParams; ++i)
- {
- outParams[i] = CastStateValue<QueryT>(pname, int64Params[i]);
- }
-
- delete [] int64Params;
- }
- else UNREACHABLE();
-}
-
-// Explicit template instantiation (how we export template functions in different files)
-// The calls below will make CastStateValues successfully link with the GL state query types
-// The GL state query API types are: bool, int, uint, float, int64
-
-template void CastStateValues<GLboolean>(Context *, GLenum, GLenum, unsigned int, GLboolean *);
-template void CastStateValues<GLint>(Context *, GLenum, GLenum, unsigned int, GLint *);
-template void CastStateValues<GLuint>(Context *, GLenum, GLenum, unsigned int, GLuint *);
-template void CastStateValues<GLfloat>(Context *, GLenum, GLenum, unsigned int, GLfloat *);
-template void CastStateValues<GLint64>(Context *, GLenum, GLenum, unsigned int, GLint64 *);
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/queryconversions.h b/src/3rdparty/angle/src/libGLESv2/queryconversions.h
deleted file mode 100644
index da7047f730..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/queryconversions.h
+++ /dev/null
@@ -1,17 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// queryconversions.h: Declaration of state query cast conversions
-
-namespace gl
-{
-
-// The GL state query API types are: bool, int, uint, float, int64
-template <typename QueryT>
-void CastStateValues(Context *context, GLenum nativeType, GLenum pname,
- unsigned int numParams, QueryT *outParams);
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/BufferImpl.h b/src/3rdparty/angle/src/libGLESv2/renderer/BufferImpl.h
deleted file mode 100644
index c031effabd..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/BufferImpl.h
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// BufferImpl.h: Defines the abstract rx::BufferImpl class.
-
-#ifndef LIBGLESV2_RENDERER_BUFFERIMPL_H_
-#define LIBGLESV2_RENDERER_BUFFERIMPL_H_
-
-#include "common/angleutils.h"
-#include "libGLESv2/Buffer.h"
-
-#include <cstdint>
-
-namespace rx
-{
-
-class BufferImpl
-{
- public:
- virtual ~BufferImpl() { }
-
- virtual gl::Error setData(const void* data, size_t size, GLenum usage) = 0;
- virtual gl::Error setSubData(const void* data, size_t size, size_t offset) = 0;
- virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) = 0;
- virtual gl::Error map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr) = 0;
- virtual gl::Error unmap() = 0;
- virtual void markTransformFeedbackUsage() = 0;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_BUFFERIMPL_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/FenceImpl.h b/src/3rdparty/angle/src/libGLESv2/renderer/FenceImpl.h
deleted file mode 100644
index 1dd46785d9..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/FenceImpl.h
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// FenceImpl.h: Defines the rx::FenceNVImpl and rx::FenceSyncImpl classes.
-
-#ifndef LIBGLESV2_RENDERER_FENCEIMPL_H_
-#define LIBGLESV2_RENDERER_FENCEIMPL_H_
-
-#include "libGLESv2/Error.h"
-
-#include "common/angleutils.h"
-
-#include "angle_gl.h"
-
-namespace rx
-{
-
-class FenceNVImpl
-{
- public:
- FenceNVImpl() { };
- virtual ~FenceNVImpl() { };
-
- virtual gl::Error set() = 0;
- virtual gl::Error test(bool flushCommandBuffer, GLboolean *outFinished) = 0;
- virtual gl::Error finishFence(GLboolean *outFinished) = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FenceNVImpl);
-};
-
-class FenceSyncImpl
-{
- public:
- FenceSyncImpl() { };
- virtual ~FenceSyncImpl() { };
-
- virtual gl::Error set() = 0;
- virtual gl::Error clientWait(GLbitfield flags, GLuint64 timeout, GLenum *outResult) = 0;
- virtual gl::Error serverWait(GLbitfield flags, GLuint64 timeout) = 0;
- virtual gl::Error getStatus(GLint *outResult) = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FenceSyncImpl);
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_FENCEIMPL_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Image.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/Image.cpp
deleted file mode 100644
index 5b9b75f562..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Image.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// 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.
-//
-
-// Image.h: Implements the rx::Image class, an abstract base class for the
-// renderer-specific classes which will define the interface to the underlying
-// surfaces or resources.
-
-#include "libGLESv2/renderer/Image.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/main.h"
-
-namespace rx
-{
-
-Image::Image()
-{
- mWidth = 0;
- mHeight = 0;
- mDepth = 0;
- mInternalFormat = GL_NONE;
- mActualFormat = GL_NONE;
- mTarget = GL_NONE;
- mRenderable = false;
- mDirty = false;
-}
-
-gl::Error Image::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &area, gl::Framebuffer *source)
-{
- gl::FramebufferAttachment *colorbuffer = source->getReadColorbuffer();
- ASSERT(colorbuffer);
-
- RenderTarget *renderTarget = NULL;
- gl::Error error = GetAttachmentRenderTarget(colorbuffer, &renderTarget);
- if (error.isError())
- {
- return error;
- }
-
- ASSERT(renderTarget);
- return copy(xoffset, yoffset, zoffset, area, renderTarget);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Image.h b/src/3rdparty/angle/src/libGLESv2/renderer/Image.h
deleted file mode 100644
index 9071a88c67..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Image.h
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// 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.
-//
-
-// Image.h: Defines the rx::Image class, an abstract base class for the
-// renderer-specific classes which will define the interface to the underlying
-// surfaces or resources.
-
-#ifndef LIBGLESV2_RENDERER_IMAGE_H_
-#define LIBGLESV2_RENDERER_IMAGE_H_
-
-#include "common/debug.h"
-#include "libGLESv2/Error.h"
-
-#include <GLES2/gl2.h>
-
-namespace gl
-{
-class Framebuffer;
-struct Rectangle;
-struct ImageIndex;
-}
-
-namespace rx
-{
-class RendererD3D;
-class RenderTarget;
-class TextureStorage;
-
-class Image
-{
- public:
- Image();
- virtual ~Image() {};
-
- GLsizei getWidth() const { return mWidth; }
- GLsizei getHeight() const { return mHeight; }
- GLsizei getDepth() const { return mDepth; }
- GLenum getInternalFormat() const { return mInternalFormat; }
- GLenum getActualFormat() const { return mActualFormat; }
- GLenum getTarget() const { return mTarget; }
- bool isRenderableFormat() const { return mRenderable; }
-
- void markDirty() {mDirty = true;}
- void markClean() {mDirty = false;}
- virtual bool isDirty() const = 0;
-
- virtual bool redefine(RendererD3D *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease) = 0;
-
- virtual gl::Error loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
- GLint unpackAlignment, GLenum type, const void *input) = 0;
- virtual gl::Error loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
- const void *input) = 0;
-
- gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, gl::Framebuffer *source);
- virtual gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source) = 0;
- virtual gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea,
- const gl::ImageIndex &sourceIndex, TextureStorage *source) = 0;
-
- protected:
- GLsizei mWidth;
- GLsizei mHeight;
- GLsizei mDepth;
- GLenum mInternalFormat;
- GLenum mActualFormat;
- bool mRenderable;
- GLenum mTarget;
-
- bool mDirty;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Image);
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_IMAGE_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/IndexRangeCache.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/IndexRangeCache.cpp
deleted file mode 100644
index d472e1499e..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/IndexRangeCache.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// IndexRangeCache.cpp: Defines the rx::IndexRangeCache class which stores information about
-// ranges of indices.
-
-#include "libGLESv2/renderer/IndexRangeCache.h"
-#include "libGLESv2/formatutils.h"
-
-#include "common/debug.h"
-
-#include <tuple>
-
-namespace rx
-{
-
-template <class IndexType>
-static RangeUI ComputeTypedRange(const IndexType *indices, GLsizei count)
-{
- unsigned int minIndex = indices[0];
- unsigned int maxIndex = indices[0];
-
- for (GLsizei i = 1; i < count; i++)
- {
- if (minIndex > indices[i]) minIndex = indices[i];
- if (maxIndex < indices[i]) maxIndex = indices[i];
- }
-
- return RangeUI(minIndex, maxIndex);
-}
-
-RangeUI IndexRangeCache::ComputeRange(GLenum type, const GLvoid *indices, GLsizei count)
-{
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- return ComputeTypedRange(static_cast<const GLubyte*>(indices), count);
- case GL_UNSIGNED_INT:
- return ComputeTypedRange(static_cast<const GLuint*>(indices), count);
- case GL_UNSIGNED_SHORT:
- return ComputeTypedRange(static_cast<const GLushort*>(indices), count);
- default:
- UNREACHABLE();
- return RangeUI();
- }
-}
-
-void IndexRangeCache::addRange(GLenum type, unsigned int offset, GLsizei count, const RangeUI &range,
- unsigned int streamOffset)
-{
- mIndexRangeCache[IndexRange(type, offset, count)] = IndexBounds(range, streamOffset);
-}
-
-void IndexRangeCache::invalidateRange(unsigned int offset, unsigned int size)
-{
- unsigned int invalidateStart = offset;
- unsigned int invalidateEnd = offset + size;
-
- IndexRangeMap::iterator i = mIndexRangeCache.begin();
- while (i != mIndexRangeCache.end())
- {
- unsigned int rangeStart = i->second.streamOffset;
- unsigned int rangeEnd = i->second.streamOffset + (gl::GetTypeInfo(i->first.type).bytes * i->first.count);
-
- if (invalidateEnd < rangeStart || invalidateStart > rangeEnd)
- {
- ++i;
- }
- else
- {
- i = mIndexRangeCache.erase(i);
- }
- }
-}
-
-bool IndexRangeCache::findRange(GLenum type, unsigned int offset, GLsizei count,
- RangeUI *outRange, unsigned int *outStreamOffset) const
-{
- IndexRangeMap::const_iterator i = mIndexRangeCache.find(IndexRange(type, offset, count));
- if (i != mIndexRangeCache.end())
- {
- if (outRange) *outRange = i->second.range;
- if (outStreamOffset) *outStreamOffset = i->second.streamOffset;
- return true;
- }
- else
- {
- if (outRange) *outRange = RangeUI(0, 0);
- if (outStreamOffset) *outStreamOffset = 0;
- return false;
- }
-}
-
-void IndexRangeCache::clear()
-{
- mIndexRangeCache.clear();
-}
-
-IndexRangeCache::IndexRange::IndexRange()
- : type(GL_NONE), offset(0), count(0)
-{
-}
-
-IndexRangeCache::IndexRange::IndexRange(GLenum typ, intptr_t off, GLsizei c)
- : type(typ), offset(off), count(c)
-{
-}
-
-bool IndexRangeCache::IndexRange::operator<(const IndexRange& rhs) const
-{
- return std::make_tuple(type, offset, count) < std::make_tuple(rhs.type, rhs.offset, rhs.count);
-}
-
-IndexRangeCache::IndexBounds::IndexBounds()
- : range(0, 0),
- streamOffset(0)
-{
-}
-
-IndexRangeCache::IndexBounds::IndexBounds(const RangeUI &rangeIn, unsigned int offset)
- : range(rangeIn), streamOffset(offset)
-{
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/IndexRangeCache.h b/src/3rdparty/angle/src/libGLESv2/renderer/IndexRangeCache.h
deleted file mode 100644
index a7d91e035b..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/IndexRangeCache.h
+++ /dev/null
@@ -1,64 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// IndexRangeCache.h: Defines the rx::IndexRangeCache class which stores information about
-// ranges of indices.
-
-#ifndef LIBGLESV2_RENDERER_INDEXRANGECACHE_H_
-#define LIBGLESV2_RENDERER_INDEXRANGECACHE_H_
-
-#include "common/angleutils.h"
-#include "common/mathutil.h"
-
-#include "angle_gl.h"
-
-#include <map>
-
-namespace rx
-{
-
-class IndexRangeCache
-{
- public:
- void addRange(GLenum type, unsigned int offset, GLsizei count, const RangeUI &range,
- unsigned int streamOffset);
- bool findRange(GLenum type, unsigned int offset, GLsizei count, RangeUI *rangeOut,
- unsigned int *outStreamOffset) const;
-
- void invalidateRange(unsigned int offset, unsigned int size);
- void clear();
-
- static RangeUI ComputeRange(GLenum type, const GLvoid *indices, GLsizei count);
-
- private:
- struct IndexRange
- {
- GLenum type;
- unsigned int offset;
- GLsizei count;
-
- IndexRange();
- IndexRange(GLenum type, intptr_t offset, GLsizei count);
-
- bool operator<(const IndexRange& rhs) const;
- };
-
- struct IndexBounds
- {
- RangeUI range;
- unsigned int streamOffset;
-
- IndexBounds();
- IndexBounds(const RangeUI &range, unsigned int offset);
- };
-
- typedef std::map<IndexRange, IndexBounds> IndexRangeMap;
- IndexRangeMap mIndexRangeCache;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_INDEXRANGECACHE_H
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/ProgramImpl.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/ProgramImpl.cpp
deleted file mode 100644
index f9fcad38a4..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/ProgramImpl.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// ProgramD3D.cpp: Defines the rx::ProgramD3D class which implements rx::ProgramImpl.
-
-#include "libGLESv2/renderer/ProgramImpl.h"
-
-#include "common/utilities.h"
-#include "libGLESv2/main.h"
-
-namespace rx
-{
-
-namespace
-{
-
-unsigned int ParseAndStripArrayIndex(std::string* name)
-{
- unsigned int subscript = GL_INVALID_INDEX;
-
- // Strip any trailing array operator and retrieve the subscript
- size_t open = name->find_last_of('[');
- size_t close = name->find_last_of(']');
- if (open != std::string::npos && close == name->length() - 1)
- {
- subscript = atoi(name->substr(open + 1).c_str());
- name->erase(open);
- }
-
- return subscript;
-}
-
-}
-
-ProgramImpl::~ProgramImpl()
-{
- // Ensure that reset was called by the inherited class during destruction
- ASSERT(mUniformIndex.size() == 0);
-}
-
-gl::LinkedUniform *ProgramImpl::getUniformByLocation(GLint location) const
-{
- ASSERT(location >= 0 && static_cast<size_t>(location) < mUniformIndex.size());
- return mUniforms[mUniformIndex[location].index];
-}
-
-gl::LinkedUniform *ProgramImpl::getUniformByName(const std::string &name) const
-{
- for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); uniformIndex++)
- {
- if (mUniforms[uniformIndex]->name == name)
- {
- return mUniforms[uniformIndex];
- }
- }
-
- return NULL;
-}
-
-gl::UniformBlock *ProgramImpl::getUniformBlockByIndex(GLuint blockIndex) const
-{
- ASSERT(blockIndex < mUniformBlocks.size());
- return mUniformBlocks[blockIndex];
-}
-
-GLint ProgramImpl::getUniformLocation(std::string name)
-{
- unsigned int subscript = ParseAndStripArrayIndex(&name);
-
- unsigned int numUniforms = mUniformIndex.size();
- for (unsigned int location = 0; location < numUniforms; location++)
- {
- if (mUniformIndex[location].name == name)
- {
- const int index = mUniformIndex[location].index;
- const bool isArray = mUniforms[index]->isArray();
-
- if ((isArray && mUniformIndex[location].element == subscript) ||
- (subscript == GL_INVALID_INDEX))
- {
- return location;
- }
- }
- }
-
- return -1;
-}
-
-GLuint ProgramImpl::getUniformIndex(std::string name)
-{
- unsigned int subscript = ParseAndStripArrayIndex(&name);
-
- // The app is not allowed to specify array indices other than 0 for arrays of basic types
- if (subscript != 0 && subscript != GL_INVALID_INDEX)
- {
- return GL_INVALID_INDEX;
- }
-
- unsigned int numUniforms = mUniforms.size();
- for (unsigned int index = 0; index < numUniforms; index++)
- {
- if (mUniforms[index]->name == name)
- {
- if (mUniforms[index]->isArray() || subscript == GL_INVALID_INDEX)
- {
- return index;
- }
- }
- }
-
- return GL_INVALID_INDEX;
-}
-
-GLuint ProgramImpl::getUniformBlockIndex(std::string name) const
-{
- unsigned int subscript = ParseAndStripArrayIndex(&name);
-
- unsigned int numUniformBlocks = mUniformBlocks.size();
- for (unsigned int blockIndex = 0; blockIndex < numUniformBlocks; blockIndex++)
- {
- const gl::UniformBlock &uniformBlock = *mUniformBlocks[blockIndex];
- if (uniformBlock.name == name)
- {
- const bool arrayElementZero = (subscript == GL_INVALID_INDEX && uniformBlock.elementIndex == 0);
- if (subscript == uniformBlock.elementIndex || arrayElementZero)
- {
- return blockIndex;
- }
- }
- }
-
- return GL_INVALID_INDEX;
-}
-
-void ProgramImpl::reset()
-{
- SafeDeleteContainer(mUniforms);
- mUniformIndex.clear();
- SafeDeleteContainer(mUniformBlocks);
- mTransformFeedbackLinkedVaryings.clear();
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/ProgramImpl.h b/src/3rdparty/angle/src/libGLESv2/renderer/ProgramImpl.h
deleted file mode 100644
index 6aaa23cf89..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/ProgramImpl.h
+++ /dev/null
@@ -1,127 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// ProgramImpl.h: Defines the abstract rx::ProgramImpl class.
-
-#ifndef LIBGLESV2_RENDERER_PROGRAMIMPL_H_
-#define LIBGLESV2_RENDERER_PROGRAMIMPL_H_
-
-#include "common/angleutils.h"
-#include "libGLESv2/BinaryStream.h"
-#include "libGLESv2/Constants.h"
-#include "libGLESv2/ProgramBinary.h"
-#include "libGLESv2/Shader.h"
-#include "libGLESv2/renderer/Renderer.h"
-
-#include <map>
-
-namespace rx
-{
-
-class ProgramImpl
-{
- public:
- ProgramImpl() { }
- virtual ~ProgramImpl();
-
- const std::vector<gl::LinkedUniform*> &getUniforms() const { return mUniforms; }
- const std::vector<gl::VariableLocation> &getUniformIndices() const { return mUniformIndex; }
- const std::vector<gl::UniformBlock*> &getUniformBlocks() const { return mUniformBlocks; }
- const std::vector<gl::LinkedVarying> &getTransformFeedbackLinkedVaryings() const { return mTransformFeedbackLinkedVaryings; }
- const sh::Attribute *getShaderAttributes() const { return mShaderAttributes; }
-
- std::vector<gl::LinkedUniform*> &getUniforms() { return mUniforms; }
- std::vector<gl::VariableLocation> &getUniformIndices() { return mUniformIndex; }
- std::vector<gl::UniformBlock*> &getUniformBlocks() { return mUniformBlocks; }
- std::vector<gl::LinkedVarying> &getTransformFeedbackLinkedVaryings() { return mTransformFeedbackLinkedVaryings; }
- sh::Attribute *getShaderAttributes() { return mShaderAttributes; }
-
- gl::LinkedUniform *getUniformByLocation(GLint location) const;
- gl::LinkedUniform *getUniformByName(const std::string &name) const;
- gl::UniformBlock *getUniformBlockByIndex(GLuint blockIndex) const;
-
- GLint getUniformLocation(std::string name);
- GLuint getUniformIndex(std::string name);
- GLuint getUniformBlockIndex(std::string name) const;
-
- virtual bool usesPointSize() const = 0;
- virtual int getShaderVersion() const = 0;
- virtual GLenum getTransformFeedbackBufferMode() const = 0;
-
- virtual GLenum getBinaryFormat() = 0;
- virtual gl::LinkResult load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) = 0;
- virtual gl::Error save(gl::BinaryOutputStream *stream) = 0;
-
- virtual gl::LinkResult link(const gl::Data &data, gl::InfoLog &infoLog,
- gl::Shader *fragmentShader, gl::Shader *vertexShader,
- const std::vector<std::string> &transformFeedbackVaryings,
- GLenum transformFeedbackBufferMode,
- int *registers, std::vector<gl::LinkedVarying> *linkedVaryings,
- std::map<int, gl::VariableLocation> *outputVariables) = 0;
-
- virtual void setUniform1fv(GLint location, GLsizei count, const GLfloat *v) = 0;
- virtual void setUniform2fv(GLint location, GLsizei count, const GLfloat *v) = 0;
- virtual void setUniform3fv(GLint location, GLsizei count, const GLfloat *v) = 0;
- virtual void setUniform4fv(GLint location, GLsizei count, const GLfloat *v) = 0;
- virtual void setUniform1iv(GLint location, GLsizei count, const GLint *v) = 0;
- virtual void setUniform2iv(GLint location, GLsizei count, const GLint *v) = 0;
- virtual void setUniform3iv(GLint location, GLsizei count, const GLint *v) = 0;
- virtual void setUniform4iv(GLint location, GLsizei count, const GLint *v) = 0;
- virtual void setUniform1uiv(GLint location, GLsizei count, const GLuint *v) = 0;
- virtual void setUniform2uiv(GLint location, GLsizei count, const GLuint *v) = 0;
- virtual void setUniform3uiv(GLint location, GLsizei count, const GLuint *v) = 0;
- virtual void setUniform4uiv(GLint location, GLsizei count, const GLuint *v) = 0;
- virtual void setUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
- virtual void setUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
- virtual void setUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
- virtual void setUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
- virtual void setUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
- virtual void setUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
- virtual void setUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
- virtual void setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
- virtual void setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
-
- virtual void getUniformfv(GLint location, GLfloat *params) = 0;
- virtual void getUniformiv(GLint location, GLint *params) = 0;
- virtual void getUniformuiv(GLint location, GLuint *params) = 0;
-
- virtual void reset();
-
- // TODO: The following functions are possibly only applicable to D3D backends. The should be carefully evaluated to
- // determine if they can be removed from this interface.
- virtual GLint getSamplerMapping(gl::SamplerType type, unsigned int samplerIndex, const gl::Caps &caps) const = 0;
- virtual GLenum getSamplerTextureType(gl::SamplerType type, unsigned int samplerIndex) const = 0;
- virtual GLint getUsedSamplerRange(gl::SamplerType type) const = 0;
- virtual void updateSamplerMapping() = 0;
- virtual bool validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps) = 0;
-
- virtual gl::LinkResult compileProgramExecutables(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader,
- int registers) = 0;
-
- virtual bool linkUniforms(gl::InfoLog &infoLog, const gl::Shader &vertexShader, const gl::Shader &fragmentShader,
- const gl::Caps &caps) = 0;
- virtual bool defineUniformBlock(gl::InfoLog &infoLog, const gl::Shader &shader, const sh::InterfaceBlock &interfaceBlock,
- const gl::Caps &caps) = 0;
-
- virtual gl::Error applyUniforms() = 0;
- virtual gl::Error applyUniformBuffers(const std::vector<gl::Buffer*> boundBuffers, const gl::Caps &caps) = 0;
- virtual bool assignUniformBlockRegister(gl::InfoLog &infoLog, gl::UniformBlock *uniformBlock, GLenum shader,
- unsigned int registerIndex, const gl::Caps &caps) = 0;
-
- protected:
- DISALLOW_COPY_AND_ASSIGN(ProgramImpl);
-
- std::vector<gl::LinkedUniform*> mUniforms;
- std::vector<gl::VariableLocation> mUniformIndex;
- std::vector<gl::UniformBlock*> mUniformBlocks;
- std::vector<gl::LinkedVarying> mTransformFeedbackLinkedVaryings;
-
- sh::Attribute mShaderAttributes[gl::MAX_VERTEX_ATTRIBS];
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_PROGRAMIMPL_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/QueryImpl.h b/src/3rdparty/angle/src/libGLESv2/renderer/QueryImpl.h
deleted file mode 100644
index 6b45810a3b..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/QueryImpl.h
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// QueryImpl.h: Defines the abstract rx::QueryImpl class.
-
-#ifndef LIBGLESV2_RENDERER_QUERYIMPL_H_
-#define LIBGLESV2_RENDERER_QUERYIMPL_H_
-
-#include "libGLESv2/Error.h"
-
-#include "common/angleutils.h"
-
-#include <GLES2/gl2.h>
-
-namespace rx
-{
-
-class QueryImpl
-{
- public:
- explicit QueryImpl(GLenum type) { mType = type; }
- virtual ~QueryImpl() { }
-
- virtual gl::Error begin() = 0;
- virtual gl::Error end() = 0;
- virtual gl::Error getResult(GLuint *params) = 0;
- virtual gl::Error isResultAvailable(GLuint *available) = 0;
-
- GLenum getType() const { return mType; }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(QueryImpl);
-
- GLenum mType;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_QUERYIMPL_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget.cpp
deleted file mode 100644
index 857fdc9dae..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// RenderTarget.cpp: Implements serial handling for rx::RenderTarget
-
-#include "libGLESv2/renderer/RenderTarget.h"
-
-namespace rx
-{
-unsigned int RenderTarget::mCurrentSerial = 1;
-
-RenderTarget::RenderTarget()
- : mSerial(issueSerials(1))
-{
-}
-
-RenderTarget::~RenderTarget()
-{
-}
-
-unsigned int RenderTarget::getSerial() const
-{
- return mSerial;
-}
-
-unsigned int RenderTarget::issueSerials(unsigned int count)
-{
- unsigned int firstSerial = mCurrentSerial;
- mCurrentSerial += count;
- return firstSerial;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget.h b/src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget.h
deleted file mode 100644
index 3bdfb0cc98..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/RenderTarget.h
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// RenderTarget.h: Defines an abstract wrapper class to manage IDirect3DSurface9
-// and ID3D11View objects belonging to renderbuffers.
-
-#ifndef LIBGLESV2_RENDERER_RENDERTARGET_H_
-#define LIBGLESV2_RENDERER_RENDERTARGET_H_
-
-#include "common/angleutils.h"
-#include "libGLESv2/angletypes.h"
-
-namespace rx
-{
-class RenderTarget
-{
- public:
- RenderTarget();
- virtual ~RenderTarget();
-
- virtual GLsizei getWidth() const = 0;
- virtual GLsizei getHeight() const = 0;
- virtual GLsizei getDepth() const = 0;
- virtual GLenum getInternalFormat() const = 0;
- virtual GLenum getActualFormat() const = 0;
- virtual GLsizei getSamples() const = 0;
- gl::Extents getExtents() const { return gl::Extents(getWidth(), getHeight(), getDepth()); }
-
- virtual void invalidate(GLint x, GLint y, GLsizei width, GLsizei height) = 0;
-
- virtual unsigned int getSerial() const;
- static unsigned int issueSerials(unsigned int count);
-
- struct Desc {
- GLsizei width;
- GLsizei height;
- GLsizei depth;
- GLenum format;
- };
-
- private:
- DISALLOW_COPY_AND_ASSIGN(RenderTarget);
-
- const unsigned int mSerial;
- static unsigned int mCurrentSerial;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERTARGET_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/RenderbufferImpl.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/RenderbufferImpl.cpp
deleted file mode 100644
index 770ae8e9c6..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/RenderbufferImpl.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// RenderbufferImpl.h: Implements the shared methods of the abstract class gl::RenderbufferImpl
-
-#include "libGLESv2/renderer/RenderbufferImpl.h"
-
-namespace rx
-{
-RenderbufferImpl::RenderbufferImpl()
-{
-}
-
-RenderbufferImpl::~RenderbufferImpl()
-{
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/RenderbufferImpl.h b/src/3rdparty/angle/src/libGLESv2/renderer/RenderbufferImpl.h
deleted file mode 100644
index 52e070f1d3..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/RenderbufferImpl.h
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// RenderbufferImpl.h: Defines the abstract class gl::RenderbufferImpl
-
-#ifndef LIBGLESV2_RENDERER_RENDERBUFFERIMPL_H_
-#define LIBGLESV2_RENDERER_RENDERBUFFERIMPL_H_
-
-#include "angle_gl.h"
-
-#include "libGLESv2/Error.h"
-
-#include "common/angleutils.h"
-
-namespace rx
-{
-
-class RenderbufferImpl
-{
- public:
- RenderbufferImpl();
- virtual ~RenderbufferImpl() = 0;
-
- virtual gl::Error setStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples) = 0;
-
- virtual GLsizei getWidth() const = 0;
- virtual GLsizei getHeight() const = 0;
- virtual GLenum getInternalFormat() const = 0;
- virtual GLenum getActualFormat() const = 0;
- virtual GLsizei getSamples() const = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(RenderbufferImpl);
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_RENDERBUFFERIMPL_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp
deleted file mode 100644
index df3dae1e38..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// Renderer.cpp: Implements EGL dependencies for creating and destroying Renderer instances.
-
-#include "common/utilities.h"
-#include "libEGL/AttributeMap.h"
-#include "libGLESv2/main.h"
-#include "libGLESv2/renderer/Renderer.h"
-
-#include <EGL/eglext.h>
-
-#if defined (ANGLE_ENABLE_D3D9)
-#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
-#endif // ANGLE_ENABLE_D3D9
-
-#if defined (ANGLE_ENABLE_D3D11)
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-#endif // ANGLE_ENABLE_D3D11
-
-#if defined (ANGLE_TEST_CONFIG)
-#define ANGLE_DEFAULT_D3D11 1
-#endif
-
-#if !defined(ANGLE_DEFAULT_D3D11)
-// Enables use of the Direct3D 11 API for a default display, when available
-#define ANGLE_DEFAULT_D3D11 0
-#endif
-
-namespace rx
-{
-
-Renderer::Renderer()
- : mCapsInitialized(false),
- mWorkaroundsInitialized(false)
-{
-}
-
-Renderer::~Renderer()
-{
-}
-
-const gl::Caps &Renderer::getRendererCaps() const
-{
- if (!mCapsInitialized)
- {
- generateCaps(&mCaps, &mTextureCaps, &mExtensions);
- mCapsInitialized = true;
- }
-
- return mCaps;
-}
-
-const gl::TextureCapsMap &Renderer::getRendererTextureCaps() const
-{
- if (!mCapsInitialized)
- {
- generateCaps(&mCaps, &mTextureCaps, &mExtensions);
- mCapsInitialized = true;
- }
-
- return mTextureCaps;
-}
-
-const gl::Extensions &Renderer::getRendererExtensions() const
-{
- if (!mCapsInitialized)
- {
- generateCaps(&mCaps, &mTextureCaps, &mExtensions);
- mCapsInitialized = true;
- }
-
- return mExtensions;
-}
-
-const Workarounds &Renderer::getWorkarounds() const
-{
- if (!mWorkaroundsInitialized)
- {
- mWorkarounds = generateWorkarounds();
- mWorkaroundsInitialized = true;
- }
-
- return mWorkarounds;
-}
-
-typedef Renderer *(*CreateRendererFunction)(egl::Display*, EGLNativeDisplayType, const egl::AttributeMap &);
-
-template <typename RendererType>
-Renderer *CreateRenderer(egl::Display *display, EGLNativeDisplayType nativeDisplay, const egl::AttributeMap &attributes)
-{
- return new RendererType(display, nativeDisplay, attributes);
-}
-
-}
-
-extern "C"
-{
-
-rx::Renderer *glCreateRenderer(egl::Display *display, EGLNativeDisplayType nativeDisplay, const egl::AttributeMap &attribMap)
-{
- std::vector<rx::CreateRendererFunction> rendererCreationFunctions;
-
- EGLint requestedDisplayType = attribMap.get(EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE);
-
-# if defined(ANGLE_ENABLE_D3D11)
- if (nativeDisplay == EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ||
- nativeDisplay == EGL_D3D11_ONLY_DISPLAY_ANGLE ||
- requestedDisplayType == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
- {
- rendererCreationFunctions.push_back(rx::CreateRenderer<rx::Renderer11>);
- }
-# endif
-
-# if defined(ANGLE_ENABLE_D3D9)
- if (nativeDisplay == EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ||
- requestedDisplayType == EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE)
- {
- rendererCreationFunctions.push_back(rx::CreateRenderer<rx::Renderer9>);
- }
-# endif
-
- if (nativeDisplay != EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE &&
- nativeDisplay != EGL_D3D11_ONLY_DISPLAY_ANGLE &&
- requestedDisplayType == EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE)
- {
- // The default display is requested, try the D3D9 and D3D11 renderers, order them using
- // the definition of ANGLE_DEFAULT_D3D11
-# if ANGLE_DEFAULT_D3D11
-# if defined(ANGLE_ENABLE_D3D11)
- rendererCreationFunctions.push_back(rx::CreateRenderer<rx::Renderer11>);
-# endif
-# if defined(ANGLE_ENABLE_D3D9)
- rendererCreationFunctions.push_back(rx::CreateRenderer<rx::Renderer9>);
-# endif
-# else
-# if defined(ANGLE_ENABLE_D3D9)
- rendererCreationFunctions.push_back(rx::CreateRenderer<rx::Renderer9>);
-# endif
-# if defined(ANGLE_ENABLE_D3D11)
- rendererCreationFunctions.push_back(rx::CreateRenderer<rx::Renderer11>);
-# endif
-# endif
- }
-
- for (size_t i = 0; i < rendererCreationFunctions.size(); i++)
- {
- rx::Renderer *renderer = rendererCreationFunctions[i](display, nativeDisplay, attribMap);
- if (renderer->initialize() == EGL_SUCCESS)
- {
- return renderer;
- }
- else
- {
- // Failed to create the renderer, try the next
- SafeDelete(renderer);
- }
- }
-
- return NULL;
-}
-
-void glDestroyRenderer(rx::Renderer *renderer)
-{
- ASSERT(renderer);
- SafeDelete(renderer);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.h b/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.h
deleted file mode 100644
index b85895a938..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.h
+++ /dev/null
@@ -1,193 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// Renderer.h: Defines a back-end specific class that hides the details of the
-// implementation-specific renderer.
-
-#ifndef LIBGLESV2_RENDERER_RENDERER_H_
-#define LIBGLESV2_RENDERER_RENDERER_H_
-
-#include "libGLESv2/Caps.h"
-#include "libGLESv2/Error.h"
-#include "libGLESv2/Uniform.h"
-#include "libGLESv2/angletypes.h"
-#include "libGLESv2/renderer/Workarounds.h"
-#include "common/NativeWindow.h"
-#include "common/mathutil.h"
-
-#include <cstdint>
-
-#include <EGL/egl.h>
-
-#if !defined(ANGLE_COMPILE_OPTIMIZATION_LEVEL)
-// WARNING: D3DCOMPILE_OPTIMIZATION_LEVEL3 may lead to a DX9 shader compiler hang.
-// It should only be used selectively to work around specific bugs.
-#define ANGLE_COMPILE_OPTIMIZATION_LEVEL D3DCOMPILE_OPTIMIZATION_LEVEL1
-#endif
-
-namespace egl
-{
-class Display;
-}
-
-namespace gl
-{
-class Buffer;
-class Framebuffer;
-struct Data;
-}
-
-namespace rx
-{
-class QueryImpl;
-class FenceNVImpl;
-class FenceSyncImpl;
-class BufferImpl;
-class VertexArrayImpl;
-class ShaderImpl;
-class ProgramImpl;
-class TextureImpl;
-class TransformFeedbackImpl;
-class RenderbufferImpl;
-struct TranslatedIndexData;
-struct Workarounds;
-class SwapChain;
-
-struct ConfigDesc
-{
- GLenum renderTargetFormat;
- GLenum depthStencilFormat;
- GLint multiSample;
- bool fastConfig;
- bool es3Capable;
-};
-
-class Renderer
-{
- public:
- Renderer();
- virtual ~Renderer();
-
- virtual EGLint initialize() = 0;
- virtual bool resetDevice() = 0;
-
- virtual int generateConfigs(ConfigDesc **configDescList) = 0;
- virtual void deleteConfigs(ConfigDesc *configDescList) = 0;
-
- virtual gl::Error sync(bool block) = 0;
-
- virtual gl::Error drawArrays(const gl::Data &data, GLenum mode,
- GLint first, GLsizei count, GLsizei instances) = 0;
- virtual gl::Error drawElements(const gl::Data &data, GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices, GLsizei instances,
- const RangeUI &indexRange) = 0;
-
- virtual gl::Error clear(const gl::Data &data, GLbitfield mask) = 0;
- virtual gl::Error clearBufferfv(const gl::Data &data, GLenum buffer, GLint drawbuffer, const GLfloat *values) = 0;
- virtual gl::Error clearBufferuiv(const gl::Data &data, GLenum buffer, GLint drawbuffer, const GLuint *values) = 0;
- virtual gl::Error clearBufferiv(const gl::Data &data, GLenum buffer, GLint drawbuffer, const GLint *values) = 0;
- virtual gl::Error clearBufferfi(const gl::Data &data, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) = 0;
-
- virtual gl::Error readPixels(const gl::Data &data, GLint x, GLint y, GLsizei width, GLsizei height,
- GLenum format, GLenum type, GLsizei *bufSize, void* pixels) = 0;
-
- virtual gl::Error blitFramebuffer(const gl::Data &data,
- GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
- GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
- GLbitfield mask, GLenum filter) = 0;
-
- // TODO(jmadill): caps? and virtual for egl::Display
- virtual bool getShareHandleSupport() const = 0;
- virtual bool getPostSubBufferSupport() const = 0;
-
- // Shader creation
- virtual ShaderImpl *createShader(const gl::Data &data, GLenum type) = 0;
- virtual ProgramImpl *createProgram() = 0;
-
- // Shader operations
- virtual void releaseShaderCompiler() = 0;
-
- // Texture creation
- virtual TextureImpl *createTexture(GLenum target) = 0;
-
- // Renderbuffer creation
- virtual RenderbufferImpl *createRenderbuffer() = 0;
- virtual RenderbufferImpl *createRenderbuffer(SwapChain *swapChain, bool depth) = 0;
-
- // Buffer creation
- virtual BufferImpl *createBuffer() = 0;
-
- // Vertex Array creation
- virtual VertexArrayImpl *createVertexArray() = 0;
-
- // Query and Fence creation
- virtual QueryImpl *createQuery(GLenum type) = 0;
- virtual FenceNVImpl *createFenceNV() = 0;
- virtual FenceSyncImpl *createFenceSync() = 0;
-
- // Transform Feedback creation
- virtual TransformFeedbackImpl *createTransformFeedback() = 0;
-
- // lost device
- //TODO(jmadill): investigate if this stuff is necessary in GL
- virtual void notifyDeviceLost() = 0;
- virtual bool isDeviceLost() = 0;
- virtual bool testDeviceLost(bool notify) = 0;
- virtual bool testDeviceResettable() = 0;
-
- virtual DWORD getAdapterVendor() const = 0;
- virtual std::string getRendererDescription() const = 0;
- virtual GUID getAdapterIdentifier() const = 0;
-
- // Renderer capabilities (virtual because of egl::Display)
- virtual const gl::Caps &getRendererCaps() const;
- const gl::TextureCapsMap &getRendererTextureCaps() const;
- virtual const gl::Extensions &getRendererExtensions() const;
- const Workarounds &getWorkarounds() const;
-
- // TODO(jmadill): needed by egl::Display, probably should be removed
- virtual int getMajorShaderModel() const = 0;
- virtual int getMinSwapInterval() const = 0;
- virtual int getMaxSwapInterval() const = 0;
- virtual bool getLUID(LUID *adapterLuid) const = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Renderer);
-
- virtual void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap* outTextureCaps, gl::Extensions *outExtensions) const = 0;
- virtual Workarounds generateWorkarounds() const = 0;
-
- mutable bool mCapsInitialized;
- mutable gl::Caps mCaps;
- mutable gl::TextureCapsMap mTextureCaps;
- mutable gl::Extensions mExtensions;
-
- mutable bool mWorkaroundsInitialized;
- mutable Workarounds mWorkarounds;
-};
-
-struct dx_VertexConstants
-{
- float depthRange[4];
- float viewAdjust[4];
-};
-
-struct dx_PixelConstants
-{
- float depthRange[4];
- float viewCoords[4];
- float depthFront[4];
-};
-
-enum ShaderType
-{
- SHADER_VERTEX,
- SHADER_PIXEL,
- SHADER_GEOMETRY
-};
-
-}
-#endif // LIBGLESV2_RENDERER_RENDERER_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/ShaderExecutable.h b/src/3rdparty/angle/src/libGLESv2/renderer/ShaderExecutable.h
deleted file mode 100644
index f1a96d74fb..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/ShaderExecutable.h
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// ShaderExecutable.h: Defines a renderer-agnostic class to contain shader
-// executable implementation details.
-
-#ifndef LIBGLESV2_RENDERER_SHADEREXECUTABLE_H_
-#define LIBGLESV2_RENDERER_SHADEREXECUTABLE_H_
-
-#include "common/angleutils.h"
-#include "common/debug.h"
-
-#include <vector>
-#include <cstdint>
-
-namespace rx
-{
-
-class ShaderExecutable
-{
- public:
- ShaderExecutable(const void *function, size_t length)
- : mFunctionBuffer(length)
- {
- memcpy(mFunctionBuffer.data(), function, length);
- }
-
- virtual ~ShaderExecutable() {}
-
- const uint8_t *getFunction() const
- {
- return mFunctionBuffer.data();
- }
-
- size_t getLength() const
- {
- return mFunctionBuffer.size();
- }
-
- const std::string &getDebugInfo() const
- {
- return mDebugInfo;
- }
-
- void appendDebugInfo(const std::string &info)
- {
- mDebugInfo += info;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ShaderExecutable);
-
- std::vector<uint8_t> mFunctionBuffer;
- std::string mDebugInfo;
-};
-
-class UniformStorage
-{
- public:
- UniformStorage(size_t initialSize)
- : mSize(initialSize)
- {
- }
-
- virtual ~UniformStorage() {}
-
- size_t size() const { return mSize; }
-
- private:
- size_t mSize;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_SHADEREXECUTABLE_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/ShaderImpl.h b/src/3rdparty/angle/src/libGLESv2/renderer/ShaderImpl.h
deleted file mode 100644
index cb0d360f0b..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/ShaderImpl.h
+++ /dev/null
@@ -1,55 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// ShaderImpl.h: Defines the abstract rx::ShaderImpl class.
-
-#ifndef LIBGLESV2_RENDERER_SHADERIMPL_H_
-#define LIBGLESV2_RENDERER_SHADERIMPL_H_
-
-#include <vector>
-
-#include "common/angleutils.h"
-#include "libGLESv2/Shader.h"
-
-namespace rx
-{
-
-class ShaderImpl
-{
- public:
- ShaderImpl() { }
- virtual ~ShaderImpl() { }
-
- virtual bool compile(const gl::Data &data, const std::string &source) = 0;
- virtual const std::string &getInfoLog() const = 0;
- virtual const std::string &getTranslatedSource() const = 0;
- virtual std::string getDebugInfo() const = 0;
-
- const std::vector<gl::PackedVarying> &getVaryings() const { return mVaryings; }
- const std::vector<sh::Uniform> &getUniforms() const { return mUniforms; }
- const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return mInterfaceBlocks; }
- const std::vector<sh::Attribute> &getActiveAttributes() const { return mActiveAttributes; }
- const std::vector<sh::Attribute> &getActiveOutputVariables() const { return mActiveOutputVariables; }
-
- std::vector<gl::PackedVarying> &getVaryings() { return mVaryings; }
- std::vector<sh::Uniform> &getUniforms() { return mUniforms; }
- std::vector<sh::InterfaceBlock> &getInterfaceBlocks() { return mInterfaceBlocks; }
- std::vector<sh::Attribute> &getActiveAttributes() { return mActiveAttributes; }
- std::vector<sh::Attribute> &getActiveOutputVariables() { return mActiveOutputVariables; }
-
- protected:
- DISALLOW_COPY_AND_ASSIGN(ShaderImpl);
-
- std::vector<gl::PackedVarying> mVaryings;
- std::vector<sh::Uniform> mUniforms;
- std::vector<sh::InterfaceBlock> mInterfaceBlocks;
- std::vector<sh::Attribute> mActiveAttributes;
- std::vector<sh::Attribute> mActiveOutputVariables;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_SHADERIMPL_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain.h b/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain.h
deleted file mode 100644
index 1417e0bdf6..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain.h
+++ /dev/null
@@ -1,56 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// SwapChain.h: Defines a back-end specific class that hides the details of the
-// implementation-specific swapchain.
-
-#ifndef LIBGLESV2_RENDERER_SWAPCHAIN_H_
-#define LIBGLESV2_RENDERER_SWAPCHAIN_H_
-
-#include "common/angleutils.h"
-#include "common/NativeWindow.h"
-#include "common/platform.h"
-
-#include <GLES2/gl2.h>
-#include <EGL/egl.h>
-
-#if !defined(ANGLE_FORCE_VSYNC_OFF)
-#define ANGLE_FORCE_VSYNC_OFF 0
-#endif
-
-namespace rx
-{
-
-class SwapChain
-{
- public:
- SwapChain(rx::NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat)
- : mNativeWindow(nativeWindow), mShareHandle(shareHandle), mBackBufferFormat(backBufferFormat), mDepthBufferFormat(depthBufferFormat)
- {
- }
-
- virtual ~SwapChain() {};
-
- virtual EGLint resize(EGLint backbufferWidth, EGLint backbufferSize) = 0;
- virtual EGLint reset(EGLint backbufferWidth, EGLint backbufferHeight, EGLint swapInterval) = 0;
- virtual EGLint swapRect(EGLint x, EGLint y, EGLint width, EGLint height) = 0;
- virtual void recreate() = 0;
-
- GLenum GetBackBufferInternalFormat() const { return mBackBufferFormat; }
- GLenum GetDepthBufferInternalFormat() const { return mDepthBufferFormat; }
-
- virtual HANDLE getShareHandle() {return mShareHandle;};
-
- protected:
- rx::NativeWindow mNativeWindow; // Handler for the Window that the surface is created for.
- const GLenum mBackBufferFormat;
- const GLenum mDepthBufferFormat;
-
- HANDLE mShareHandle;
-};
-
-}
-#endif // LIBGLESV2_RENDERER_SWAPCHAIN_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/TextureImpl.h b/src/3rdparty/angle/src/libGLESv2/renderer/TextureImpl.h
deleted file mode 100644
index 3e662557e4..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/TextureImpl.h
+++ /dev/null
@@ -1,64 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// TextureImpl.h: Defines the abstract rx::TextureImpl classes.
-
-#ifndef LIBGLESV2_RENDERER_TEXTUREIMPL_H_
-#define LIBGLESV2_RENDERER_TEXTUREIMPL_H_
-
-#include "common/angleutils.h"
-#include "libGLESv2/Error.h"
-
-#include "angle_gl.h"
-
-#include "libGLESv2/ImageIndex.h"
-
-namespace egl
-{
-class Surface;
-}
-
-namespace gl
-{
-class Framebuffer;
-struct PixelUnpackState;
-struct SamplerState;
-}
-
-namespace rx
-{
-
-class Image;
-
-class TextureImpl
-{
- public:
- virtual ~TextureImpl() {};
-
- // Deprecated in favour of the ImageIndex method
- virtual Image *getImage(int level, int layer) const = 0;
- virtual Image *getImage(const gl::ImageIndex &index) const = 0;
- virtual GLsizei getLayerCount(int level) const = 0;
-
- virtual void setUsage(GLenum usage) = 0;
-
- virtual gl::Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) = 0;
- virtual gl::Error setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels) = 0;
- virtual gl::Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) = 0;
- virtual gl::Error subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels) = 0;
- virtual gl::Error copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) = 0;
- virtual gl::Error copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) = 0;
- virtual gl::Error storage(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) = 0;
-
- virtual gl::Error generateMipmaps() = 0;
-
- virtual void bindTexImage(egl::Surface *surface) = 0;
- virtual void releaseTexImage() = 0;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_TEXTUREIMPL_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/TransformFeedbackImpl.h b/src/3rdparty/angle/src/libGLESv2/renderer/TransformFeedbackImpl.h
deleted file mode 100644
index 8425604d87..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/TransformFeedbackImpl.h
+++ /dev/null
@@ -1,31 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// TransformFeedbackImpl.h: Defines the abstract rx::TransformFeedbackImpl class.
-
-#ifndef LIBGLESV2_RENDERER_TRANSFORMFEEDBACKIMPL_H_
-#define LIBGLESV2_RENDERER_TRANSFORMFEEDBACKIMPL_H_
-
-#include "common/angleutils.h"
-#include "libGLESv2/TransformFeedback.h"
-
-namespace rx
-{
-
-class TransformFeedbackImpl
-{
- public:
- virtual ~TransformFeedbackImpl() { }
-
- virtual void begin(GLenum primitiveMode) = 0;
- virtual void end() = 0;
- virtual void pause() = 0;
- virtual void resume() = 0;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_TRANSFORMFEEDBACKIMPL_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/VertexArrayImpl.h b/src/3rdparty/angle/src/libGLESv2/renderer/VertexArrayImpl.h
deleted file mode 100644
index b013f9cdf4..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/VertexArrayImpl.h
+++ /dev/null
@@ -1,32 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// VertexAttribImpl.h: Defines the abstract rx::VertexAttribImpl class.
-
-#ifndef LIBGLESV2_RENDERER_VERTEXARRAYIMPL_H_
-#define LIBGLESV2_RENDERER_VERTEXARRAYIMPL_H_
-
-#include "common/angleutils.h"
-#include "libGLESv2/Buffer.h"
-#include "libGLESv2/VertexAttribute.h"
-
-namespace rx
-{
-
-class VertexArrayImpl
-{
- public:
- virtual ~VertexArrayImpl() { }
-
- virtual void setElementArrayBuffer(const gl::Buffer *buffer) = 0;
- virtual void setAttribute(size_t idx, const gl::VertexAttribute &attr) = 0;
- virtual void setAttributeDivisor(size_t idx, GLuint divisor) = 0;
- virtual void enableAttribute(size_t idx, bool enabledState) = 0;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_VERTEXARRAYIMPL_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Workarounds.h b/src/3rdparty/angle/src/libGLESv2/renderer/Workarounds.h
deleted file mode 100644
index 20a166fb7a..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Workarounds.h
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// angletypes.h: Workarounds for driver bugs and other issues.
-
-#ifndef LIBGLESV2_RENDERER_WORKAROUNDS_H_
-#define LIBGLESV2_RENDERER_WORKAROUNDS_H_
-
-// TODO(jmadill,zmo,geofflang): make a workarounds library that can operate
-// independent of ANGLE's renderer. Workarounds should also be accessible
-// outside of the Renderer.
-
-namespace rx
-{
-
-enum D3DWorkaroundType
-{
- ANGLE_D3D_WORKAROUND_NONE,
- ANGLE_D3D_WORKAROUND_SKIP_OPTIMIZATION,
- ANGLE_D3D_WORKAROUND_MAX_OPTIMIZATION
-};
-
-struct Workarounds
-{
- Workarounds()
- : mrtPerfWorkaround(false),
- setDataFasterThanImageUpload(false)
- {}
-
- bool mrtPerfWorkaround;
- bool setDataFasterThanImageUpload;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_WORKAROUNDS_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/copyimage.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/copyimage.cpp
deleted file mode 100644
index aabc9f04e9..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/copyimage.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// copyimage.cpp: Defines image copying functions
-
-#include "libGLESv2/renderer/copyimage.h"
-
-namespace rx
-{
-
-void CopyBGRA8ToRGBA8(const uint8_t *source, uint8_t *dest)
-{
- uint32_t argb = *reinterpret_cast<const uint32_t*>(source);
- *reinterpret_cast<uint32_t*>(dest) = (argb & 0xFF00FF00) | // Keep alpha and green
- (argb & 0x00FF0000) >> 16 | // Move red to blue
- (argb & 0x000000FF) << 16; // Move blue to red
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/copyimage.h b/src/3rdparty/angle/src/libGLESv2/renderer/copyimage.h
deleted file mode 100644
index 513eb5cb3d..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/copyimage.h
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// Copyright (c) 2013-2014 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.
-//
-
-// copyimage.h: Defines image copying functions
-
-#ifndef LIBGLESV2_RENDERER_COPYIMAGE_H_
-#define LIBGLESV2_RENDERER_COPYIMAGE_H_
-
-#include "common/mathutil.h"
-#include "libGLESv2/angletypes.h"
-
-#include <cstdint>
-
-namespace rx
-{
-
-template <typename sourceType, typename colorDataType>
-void ReadColor(const uint8_t *source, uint8_t *dest);
-
-template <typename destType, typename colorDataType>
-void WriteColor(const uint8_t *source, uint8_t *dest);
-
-template <typename sourceType, typename destType, typename colorDataType>
-void CopyPixel(const uint8_t *source, uint8_t *dest);
-
-void CopyBGRA8ToRGBA8(const uint8_t *source, uint8_t *dest);
-
-}
-
-#include "copyimage.inl"
-
-#endif // LIBGLESV2_RENDERER_COPYIMAGE_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/copyimage.inl b/src/3rdparty/angle/src/libGLESv2/renderer/copyimage.inl
deleted file mode 100644
index 0498cf7750..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/copyimage.inl
+++ /dev/null
@@ -1,32 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// copyimage.inl: Defines image copying functions
-
-namespace rx
-{
-
-template <typename sourceType, typename colorDataType>
-inline void ReadColor(const uint8_t *source, uint8_t *dest)
-{
- sourceType::readColor(reinterpret_cast<gl::Color<colorDataType>*>(dest), reinterpret_cast<const sourceType*>(source));
-}
-
-template <typename destType, typename colorDataType>
-inline void WriteColor(const uint8_t *source, uint8_t *dest)
-{
- destType::writeColor(reinterpret_cast<destType*>(dest), reinterpret_cast<const gl::Color<colorDataType>*>(source));
-}
-
-template <typename sourceType, typename destType, typename colorDataType>
-inline void CopyPixel(const uint8_t *source, uint8_t *dest)
-{
- colorDataType temp;
- ReadColor<sourceType, colorDataType>(source, &temp);
- WriteColor<destType, colorDataType>(&temp, dest);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/copyvertex.h b/src/3rdparty/angle/src/libGLESv2/renderer/copyvertex.h
deleted file mode 100644
index e0e8af166b..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/copyvertex.h
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// Copyright (c) 2013-2014 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.
-//
-
-// copyvertex.h: Defines vertex buffer copying and conversion functions
-
-#ifndef LIBGLESV2_RENDERER_COPYVERTEX_H_
-#define LIBGLESV2_RENDERER_COPYVERTEX_H_
-
-#include "common/mathutil.h"
-
-namespace rx
-{
-
-// 'widenDefaultValueBits' gives the default value for the alpha channel (4th component)
-// the sentinel value 0 means we do not want to widen the input or add an alpha channel
-template <typename T, size_t componentCount, uint32_t widenDefaultValueBits>
-inline void CopyNativeVertexData(const uint8_t *input, size_t stride, size_t count, uint8_t *output);
-
-template <size_t componentCount>
-inline void Copy32FixedTo32FVertexData(const uint8_t *input, size_t stride, size_t count, uint8_t *output);
-
-template <typename T, size_t componentCount, bool normalized>
-inline void CopyTo32FVertexData(const uint8_t *input, size_t stride, size_t count, uint8_t *output);
-
-template <bool isSigned, bool normalized, bool toFloat>
-inline void CopyXYZ10W2ToXYZW32FVertexData(const uint8_t *input, size_t stride, size_t count, uint8_t *output);
-
-}
-
-#include "copyvertex.inl"
-
-#endif // LIBGLESV2_RENDERER_COPYVERTEX_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/copyvertex.inl b/src/3rdparty/angle/src/libGLESv2/renderer/copyvertex.inl
deleted file mode 100644
index 7eef17b22b..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/copyvertex.inl
+++ /dev/null
@@ -1,288 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-namespace rx
-{
-
-template <typename T, size_t componentCount, uint32_t widenDefaultValueBits>
-inline void CopyNativeVertexData(const uint8_t *input, size_t stride, size_t count, uint8_t *output)
-{
- const size_t attribSize = sizeof(T)* componentCount;
- const T defaultValue = gl::bitCast<T>(widenDefaultValueBits);
- const bool widen = (widenDefaultValueBits != 0);
-
- if (attribSize == stride && !widen)
- {
- memcpy(output, input, count * attribSize);
- }
- else
- {
- size_t outputStride = widen ? 4 : componentCount;
-
- for (size_t i = 0; i < count; i++)
- {
- const T *offsetInput = reinterpret_cast<const T*>(input + (i * stride));
- T *offsetOutput = reinterpret_cast<T*>(output) + i * outputStride;
-
- for (size_t j = 0; j < componentCount; j++)
- {
- offsetOutput[j] = offsetInput[j];
- }
-
- if (widen)
- {
- offsetOutput[3] = defaultValue;
- }
- }
- }
-}
-
-template <size_t componentCount>
-inline void Copy32FixedTo32FVertexData(const uint8_t *input, size_t stride, size_t count, uint8_t *output)
-{
- static const float divisor = 1.0f / (1 << 16);
-
- for (size_t i = 0; i < count; i++)
- {
- const GLfixed* offsetInput = reinterpret_cast<const GLfixed*>(input + (stride * i));
- float* offsetOutput = reinterpret_cast<float*>(output) + i * componentCount;
-
- for (size_t j = 0; j < componentCount; j++)
- {
- offsetOutput[j] = static_cast<float>(offsetInput[j]) * divisor;
- }
- }
-}
-
-template <typename T, size_t componentCount, bool normalized>
-inline void CopyTo32FVertexData(const uint8_t *input, size_t stride, size_t count, uint8_t *output)
-{
- typedef std::numeric_limits<T> NL;
-
- for (size_t i = 0; i < count; i++)
- {
- const T *offsetInput = reinterpret_cast<const T*>(input + (stride * i));
- float *offsetOutput = reinterpret_cast<float*>(output) + i * componentCount;
-
- for (size_t j = 0; j < componentCount; j++)
- {
- if (normalized)
- {
- if (NL::is_signed)
- {
- const float divisor = 1.0f / (2 * static_cast<float>(NL::max()) + 1);
- offsetOutput[j] = (2 * static_cast<float>(offsetInput[j]) + 1) * divisor;
- }
- else
- {
- offsetOutput[j] = static_cast<float>(offsetInput[j]) / NL::max();
- }
- }
- else
- {
- offsetOutput[j] = static_cast<float>(offsetInput[j]);
- }
- }
- }
-}
-
-namespace priv
-{
-
-template <bool isSigned, bool normalized, bool toFloat>
-static inline void CopyPackedRGB(uint32_t data, uint8_t *output)
-{
- const uint32_t rgbSignMask = 0x200; // 1 set at the 9 bit
- const uint32_t negativeMask = 0xFFFFFC00; // All bits from 10 to 31 set to 1
-
- if (toFloat)
- {
- GLfloat *floatOutput = reinterpret_cast<GLfloat*>(output);
- if (isSigned)
- {
- GLfloat finalValue = 0;
- if (data & rgbSignMask)
- {
- int negativeNumber = data | negativeMask;
- finalValue = static_cast<GLfloat>(negativeNumber);
- }
- else
- {
- finalValue = static_cast<GLfloat>(data);
- }
-
- if (normalized)
- {
- const int32_t maxValue = 0x1FF; // 1 set in bits 0 through 8
- const int32_t minValue = 0xFFFFFE01; // Inverse of maxValue
-
- // A 10-bit two's complement number has the possibility of being minValue - 1 but
- // OpenGL's normalization rules dictate that it should be clamped to minValue in this
- // case.
- if (finalValue < minValue)
- {
- finalValue = minValue;
- }
-
- const int32_t halfRange = (maxValue - minValue) >> 1;
- *floatOutput = ((finalValue - minValue) / halfRange) - 1.0f;
- }
- else
- {
- *floatOutput = finalValue;
- }
- }
- else
- {
- if (normalized)
- {
- const uint32_t maxValue = 0x3FF; // 1 set in bits 0 through 9
- *floatOutput = static_cast<GLfloat>(data) / static_cast<GLfloat>(maxValue);
- }
- else
- {
- *floatOutput = static_cast<GLfloat>(data);
- }
- }
- }
- else
- {
- if (isSigned)
- {
- GLshort *intOutput = reinterpret_cast<GLshort*>(output);
-
- if (data & rgbSignMask)
- {
- *intOutput = data | negativeMask;
- }
- else
- {
- *intOutput = data;
- }
- }
- else
- {
- GLushort *uintOutput = reinterpret_cast<GLushort*>(output);
- *uintOutput = data;
- }
- }
-}
-
-template <bool isSigned, bool normalized, bool toFloat>
-inline void CopyPackedAlpha(uint32_t data, uint8_t *output)
-{
- if (toFloat)
- {
- GLfloat *floatOutput = reinterpret_cast<GLfloat*>(output);
- if (isSigned)
- {
- if (normalized)
- {
- switch (data)
- {
- case 0x0: *floatOutput = 0.0f; break;
- case 0x1: *floatOutput = 1.0f; break;
- case 0x2: *floatOutput = -1.0f; break;
- case 0x3: *floatOutput = -1.0f; break;
- default: UNREACHABLE();
- }
- }
- else
- {
- switch (data)
- {
- case 0x0: *floatOutput = 0.0f; break;
- case 0x1: *floatOutput = 1.0f; break;
- case 0x2: *floatOutput = -2.0f; break;
- case 0x3: *floatOutput = -1.0f; break;
- default: UNREACHABLE();
- }
- }
- }
- else
- {
- if (normalized)
- {
- switch (data)
- {
- case 0x0: *floatOutput = 0.0f / 3.0f; break;
- case 0x1: *floatOutput = 1.0f / 3.0f; break;
- case 0x2: *floatOutput = 2.0f / 3.0f; break;
- case 0x3: *floatOutput = 3.0f / 3.0f; break;
- default: UNREACHABLE();
- }
- }
- else
- {
- switch (data)
- {
- case 0x0: *floatOutput = 0.0f; break;
- case 0x1: *floatOutput = 1.0f; break;
- case 0x2: *floatOutput = 2.0f; break;
- case 0x3: *floatOutput = 3.0f; break;
- default: UNREACHABLE();
- }
- }
- }
- }
- else
- {
- if (isSigned)
- {
- GLshort *intOutput = reinterpret_cast<GLshort*>(output);
- switch (data)
- {
- case 0x0: *intOutput = 0; break;
- case 0x1: *intOutput = 1; break;
- case 0x2: *intOutput = -2; break;
- case 0x3: *intOutput = -1; break;
- default: UNREACHABLE();
- }
- }
- else
- {
- GLushort *uintOutput = reinterpret_cast<GLushort*>(output);
- switch (data)
- {
- case 0x0: *uintOutput = 0; break;
- case 0x1: *uintOutput = 1; break;
- case 0x2: *uintOutput = 2; break;
- case 0x3: *uintOutput = 3; break;
- default: UNREACHABLE();
- }
- }
- }
-}
-
-}
-
-template <bool isSigned, bool normalized, bool toFloat>
-inline void CopyXYZ10W2ToXYZW32FVertexData(const uint8_t *input, size_t stride, size_t count, uint8_t *output)
-{
- const size_t outputComponentSize = toFloat ? 4 : 2;
- const size_t componentCount = 4;
-
- const uint32_t rgbMask = 0x3FF; // 1 set in bits 0 through 9
- const size_t redShift = 0; // red is bits 0 through 9
- const size_t greenShift = 10; // green is bits 10 through 19
- const size_t blueShift = 20; // blue is bits 20 through 29
-
- const uint32_t alphaMask = 0x3; // 1 set in bits 0 and 1
- const size_t alphaShift = 30; // Alpha is the 30 and 31 bits
-
- for (size_t i = 0; i < count; i++)
- {
- GLuint packedValue = *reinterpret_cast<const GLuint*>(input + (i * stride));
- uint8_t *offsetOutput = output + (i * outputComponentSize * componentCount);
-
- priv::CopyPackedRGB<isSigned, normalized, toFloat>( (packedValue >> redShift) & rgbMask, offsetOutput + (0 * outputComponentSize));
- priv::CopyPackedRGB<isSigned, normalized, toFloat>( (packedValue >> greenShift) & rgbMask, offsetOutput + (1 * outputComponentSize));
- priv::CopyPackedRGB<isSigned, normalized, toFloat>( (packedValue >> blueShift) & rgbMask, offsetOutput + (2 * outputComponentSize));
- priv::CopyPackedAlpha<isSigned, normalized, toFloat>((packedValue >> alphaShift) & alphaMask, offsetOutput + (3 * outputComponentSize));
- }
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/BufferD3D.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/BufferD3D.cpp
deleted file mode 100644
index dd0d3f52ad..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/BufferD3D.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// BufferD3D.cpp Defines common functionality between the Buffer9 and Buffer11 classes.
-
-#include "libGLESv2/renderer/d3d/BufferD3D.h"
-#include "libGLESv2/renderer/d3d/VertexBuffer.h"
-#include "libGLESv2/renderer/d3d/IndexBuffer.h"
-#include "libGLESv2/main.h"
-
-namespace rx
-{
-
-unsigned int BufferD3D::mNextSerial = 1;
-
-BufferD3D::BufferD3D()
- : BufferImpl(),
- mStaticVertexBuffer(NULL),
- mStaticIndexBuffer(NULL)
-{
- updateSerial();
-}
-
-BufferD3D::~BufferD3D()
-{
- SafeDelete(mStaticVertexBuffer);
- SafeDelete(mStaticIndexBuffer);
-}
-
-BufferD3D *BufferD3D::makeBufferD3D(BufferImpl *buffer)
-{
- ASSERT(HAS_DYNAMIC_TYPE(BufferD3D*, buffer));
- return static_cast<BufferD3D*>(buffer);
-}
-
-BufferD3D *BufferD3D::makeFromBuffer(gl::Buffer *buffer)
-{
- BufferImpl *impl = buffer->getImplementation();
- ASSERT(impl);
- return makeBufferD3D(impl);
-}
-
-void BufferD3D::updateSerial()
-{
- mSerial = mNextSerial++;
-}
-
-void BufferD3D::initializeStaticData()
-{
- if (!mStaticVertexBuffer)
- {
- mStaticVertexBuffer = new StaticVertexBufferInterface(getRenderer());
- }
- if (!mStaticIndexBuffer)
- {
- mStaticIndexBuffer = new StaticIndexBufferInterface(getRenderer());
- }
-}
-
-void BufferD3D::invalidateStaticData()
-{
- if ((mStaticVertexBuffer && mStaticVertexBuffer->getBufferSize() != 0) || (mStaticIndexBuffer && mStaticIndexBuffer->getBufferSize() != 0))
- {
- SafeDelete(mStaticVertexBuffer);
- SafeDelete(mStaticIndexBuffer);
- }
-
- mUnmodifiedDataUse = 0;
-}
-
-// Creates static buffers if sufficient used data has been left unmodified
-void BufferD3D::promoteStaticUsage(int dataSize)
-{
- if (!mStaticVertexBuffer && !mStaticIndexBuffer)
- {
- mUnmodifiedDataUse += dataSize;
-
- if (mUnmodifiedDataUse > 3 * getSize())
- {
- initializeStaticData();
- }
- }
-}
-
-} \ No newline at end of file
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/BufferD3D.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/BufferD3D.h
deleted file mode 100644
index 1a1308c545..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/BufferD3D.h
+++ /dev/null
@@ -1,59 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// BufferImpl.h: Defines the abstract rx::BufferImpl class.
-
-#ifndef LIBGLESV2_RENDERER_BUFFERD3D_H_
-#define LIBGLESV2_RENDERER_BUFFERD3D_H_
-
-#include "libGLESv2/renderer/BufferImpl.h"
-#include "libGLESv2/angletypes.h"
-
-#include <cstdint>
-
-namespace rx
-{
-class RendererD3D;
-class StaticIndexBufferInterface;
-class StaticVertexBufferInterface;
-
-class BufferD3D : public BufferImpl
-{
- public:
- BufferD3D();
- virtual ~BufferD3D();
-
- static BufferD3D *makeBufferD3D(BufferImpl *buffer);
- static BufferD3D *makeFromBuffer(gl::Buffer *buffer);
-
- unsigned int getSerial() const { return mSerial; }
-
- virtual gl::Error getData(const uint8_t **outData) = 0;
- virtual size_t getSize() const = 0;
- virtual bool supportsDirectBinding() const = 0;
- virtual RendererD3D *getRenderer() = 0;
-
- StaticVertexBufferInterface *getStaticVertexBuffer() { return mStaticVertexBuffer; }
- StaticIndexBufferInterface *getStaticIndexBuffer() { return mStaticIndexBuffer; }
-
- void initializeStaticData();
- void invalidateStaticData();
- void promoteStaticUsage(int dataSize);
-
- protected:
- unsigned int mSerial;
- static unsigned int mNextSerial;
-
- void updateSerial();
-
- StaticVertexBufferInterface *mStaticVertexBuffer;
- StaticIndexBufferInterface *mStaticIndexBuffer;
- unsigned int mUnmodifiedDataUse;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_BUFFERIMPLD3D_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/DynamicHLSL.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/DynamicHLSL.cpp
deleted file mode 100644
index 3d5bfe0cbe..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/DynamicHLSL.cpp
+++ /dev/null
@@ -1,1148 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-// DynamicHLSL.cpp: Implementation for link and run-time HLSL generation
-//
-
-#include "libGLESv2/renderer/d3d/DynamicHLSL.h"
-#include "libGLESv2/renderer/d3d/ShaderD3D.h"
-#include "libGLESv2/renderer/d3d/RendererD3D.h"
-#include "libGLESv2/Program.h"
-#include "libGLESv2/ProgramBinary.h"
-#include "libGLESv2/Shader.h"
-#include "libGLESv2/formatutils.h"
-
-#include "common/utilities.h"
-#include "common/blocklayout.h"
-
-// For use with ArrayString, see angleutils.h
-META_ASSERT(GL_INVALID_INDEX == UINT_MAX);
-
-using namespace gl;
-
-namespace rx
-{
-
-namespace
-{
-
-std::string HLSLComponentTypeString(GLenum componentType)
-{
- switch (componentType)
- {
- case GL_UNSIGNED_INT: return "uint";
- case GL_INT: return "int";
- case GL_UNSIGNED_NORMALIZED:
- case GL_SIGNED_NORMALIZED:
- case GL_FLOAT: return "float";
- default: UNREACHABLE(); return "not-component-type";
- }
-}
-
-std::string HLSLComponentTypeString(GLenum componentType, int componentCount)
-{
- return HLSLComponentTypeString(componentType) + (componentCount > 1 ? Str(componentCount) : "");
-}
-
-std::string HLSLMatrixTypeString(GLenum type)
-{
- switch (type)
- {
- case GL_FLOAT_MAT2: return "float2x2";
- case GL_FLOAT_MAT3: return "float3x3";
- case GL_FLOAT_MAT4: return "float4x4";
- case GL_FLOAT_MAT2x3: return "float2x3";
- case GL_FLOAT_MAT3x2: return "float3x2";
- case GL_FLOAT_MAT2x4: return "float2x4";
- case GL_FLOAT_MAT4x2: return "float4x2";
- case GL_FLOAT_MAT3x4: return "float3x4";
- case GL_FLOAT_MAT4x3: return "float4x3";
- default: UNREACHABLE(); return "not-matrix-type";
- }
-}
-
-std::string HLSLTypeString(GLenum type)
-{
- if (gl::IsMatrixType(type))
- {
- return HLSLMatrixTypeString(type);
- }
-
- return HLSLComponentTypeString(gl::VariableComponentType(type), gl::VariableComponentCount(type));
-}
-
-const PixelShaderOutputVariable &GetOutputAtLocation(const std::vector<PixelShaderOutputVariable> &outputVariables,
- unsigned int location)
-{
- for (size_t variableIndex = 0; variableIndex < outputVariables.size(); ++variableIndex)
- {
- if (outputVariables[variableIndex].outputIndex == location)
- {
- return outputVariables[variableIndex];
- }
- }
-
- UNREACHABLE();
- return outputVariables[0];
-}
-
-const std::string VERTEX_ATTRIBUTE_STUB_STRING = "@@ VERTEX ATTRIBUTES @@";
-const std::string PIXEL_OUTPUT_STUB_STRING = "@@ PIXEL OUTPUT @@";
-
-}
-
-DynamicHLSL::DynamicHLSL(RendererD3D *const renderer)
- : mRenderer(renderer)
-{
-}
-
-static bool packVarying(PackedVarying *varying, const int maxVaryingVectors, VaryingPacking packing)
-{
- GLenum transposedType = TransposeMatrixType(varying->type);
-
- // matrices within varying structs are not transposed
- int registers = (varying->isStruct() ? HLSLVariableRegisterCount(*varying) : VariableRowCount(transposedType)) * varying->elementCount();
- int elements = (varying->isStruct() ? 4 : VariableColumnCount(transposedType));
-
- if (elements >= 2 && elements <= 4)
- {
- for (int r = 0; r <= maxVaryingVectors - registers; r++)
- {
- bool available = true;
-
- for (int y = 0; y < registers && available; y++)
- {
- for (int x = 0; x < elements && available; x++)
- {
- if (packing[r + y][x])
- {
- available = false;
- }
- }
- }
-
- if (available)
- {
- varying->registerIndex = r;
- varying->columnIndex = 0;
-
- for (int y = 0; y < registers; y++)
- {
- for (int x = 0; x < elements; x++)
- {
- packing[r + y][x] = &*varying;
- }
- }
-
- return true;
- }
- }
-
- if (elements == 2)
- {
- for (int r = maxVaryingVectors - registers; r >= 0; r--)
- {
- bool available = true;
-
- for (int y = 0; y < registers && available; y++)
- {
- for (int x = 2; x < 4 && available; x++)
- {
- if (packing[r + y][x])
- {
- available = false;
- }
- }
- }
-
- if (available)
- {
- varying->registerIndex = r;
- varying->columnIndex = 2;
-
- for (int y = 0; y < registers; y++)
- {
- for (int x = 2; x < 4; x++)
- {
- packing[r + y][x] = &*varying;
- }
- }
-
- return true;
- }
- }
- }
- }
- else if (elements == 1)
- {
- int space[4] = { 0 };
-
- for (int y = 0; y < maxVaryingVectors; y++)
- {
- for (int x = 0; x < 4; x++)
- {
- space[x] += packing[y][x] ? 0 : 1;
- }
- }
-
- int column = 0;
-
- for (int x = 0; x < 4; x++)
- {
- if (space[x] >= registers && (space[column] < registers || space[x] < space[column]))
- {
- column = x;
- }
- }
-
- if (space[column] >= registers)
- {
- for (int r = 0; r < maxVaryingVectors; r++)
- {
- if (!packing[r][column])
- {
- varying->registerIndex = r;
- varying->columnIndex = column;
-
- for (int y = r; y < r + registers; y++)
- {
- packing[y][column] = &*varying;
- }
-
- break;
- }
- }
-
- return true;
- }
- }
- else UNREACHABLE();
-
- return false;
-}
-
-// Packs varyings into generic varying registers, using the algorithm from [OpenGL ES Shading Language 1.00 rev. 17] appendix A section 7 page 111
-// Returns the number of used varying registers, or -1 if unsuccesful
-int DynamicHLSL::packVaryings(InfoLog &infoLog, VaryingPacking packing, ShaderD3D *fragmentShader,
- ShaderD3D *vertexShader, const std::vector<std::string> &transformFeedbackVaryings)
-{
- // TODO (geofflang): Use context's caps
- const int maxVaryingVectors = mRenderer->getRendererCaps().maxVaryingVectors;
-
- vertexShader->resetVaryingsRegisterAssignment();
- fragmentShader->resetVaryingsRegisterAssignment();
-
- std::set<std::string> packedVaryings;
-
- std::vector<gl::PackedVarying> &fragmentVaryings = fragmentShader->getVaryings();
- std::vector<gl::PackedVarying> &vertexVaryings = vertexShader->getVaryings();
- for (unsigned int varyingIndex = 0; varyingIndex < fragmentVaryings.size(); varyingIndex++)
- {
- PackedVarying *varying = &fragmentVaryings[varyingIndex];
-
- // Do not assign registers to built-in or unreferenced varyings
- if (varying->isBuiltIn() || !varying->staticUse)
- {
- continue;
- }
-
- if (packVarying(varying, maxVaryingVectors, packing))
- {
- packedVaryings.insert(varying->name);
- }
- else
- {
- infoLog.append("Could not pack varying %s", varying->name.c_str());
- return -1;
- }
- }
-
- for (unsigned int feedbackVaryingIndex = 0; feedbackVaryingIndex < transformFeedbackVaryings.size(); feedbackVaryingIndex++)
- {
- const std::string &transformFeedbackVarying = transformFeedbackVaryings[feedbackVaryingIndex];
-
- if (transformFeedbackVarying == "gl_Position" || transformFeedbackVarying == "gl_PointSize")
- {
- // do not pack builtin XFB varyings
- continue;
- }
-
- if (packedVaryings.find(transformFeedbackVarying) == packedVaryings.end())
- {
- bool found = false;
- for (unsigned int varyingIndex = 0; varyingIndex < vertexVaryings.size(); varyingIndex++)
- {
- PackedVarying *varying = &vertexVaryings[varyingIndex];
- if (transformFeedbackVarying == varying->name)
- {
- if (!packVarying(varying, maxVaryingVectors, packing))
- {
- infoLog.append("Could not pack varying %s", varying->name.c_str());
- return -1;
- }
-
- found = true;
- break;
- }
- }
-
- if (!found)
- {
- infoLog.append("Transform feedback varying %s does not exist in the vertex shader.", transformFeedbackVarying.c_str());
- return -1;
- }
- }
- }
-
- // Return the number of used registers
- int registers = 0;
-
- for (int r = 0; r < maxVaryingVectors; r++)
- {
- if (packing[r][0] || packing[r][1] || packing[r][2] || packing[r][3])
- {
- registers++;
- }
- }
-
- return registers;
-}
-
-std::string DynamicHLSL::generateVaryingHLSL(const ShaderD3D *shader) const
-{
- std::string varyingSemantic = getVaryingSemantic(shader->mUsesPointSize);
- std::string varyingHLSL;
-
- const std::vector<gl::PackedVarying> &varyings = shader->getVaryings();
-
- for (unsigned int varyingIndex = 0; varyingIndex < varyings.size(); varyingIndex++)
- {
- const PackedVarying &varying = varyings[varyingIndex];
- if (varying.registerAssigned())
- {
- ASSERT(!varying.isBuiltIn());
- GLenum transposedType = TransposeMatrixType(varying.type);
- int variableRows = (varying.isStruct() ? 1 : VariableRowCount(transposedType));
-
- for (unsigned int elementIndex = 0; elementIndex < varying.elementCount(); elementIndex++)
- {
- for (int row = 0; row < variableRows; row++)
- {
- // TODO: Add checks to ensure D3D interpolation modifiers don't result in too many registers being used.
- // For example, if there are N registers, and we have N vec3 varyings and 1 float varying, then D3D will pack them into N registers.
- // If the float varying has the 'nointerpolation' modifier on it then we would need N + 1 registers, and D3D compilation will fail.
-
- switch (varying.interpolation)
- {
- case sh::INTERPOLATION_SMOOTH: varyingHLSL += " "; break;
- case sh::INTERPOLATION_FLAT: varyingHLSL += " nointerpolation "; break;
- case sh::INTERPOLATION_CENTROID: varyingHLSL += " centroid "; break;
- default: UNREACHABLE();
- }
-
- unsigned int semanticIndex = elementIndex * variableRows + varying.columnIndex * mRenderer->getRendererCaps().maxVaryingVectors + varying.registerIndex + row;
- std::string n = Str(semanticIndex);
-
- std::string typeString;
-
- if (varying.isStruct())
- {
- // matrices within structs are not transposed, so
- // do not use the special struct prefix "rm"
- typeString = decorateVariable(varying.structName);
- }
- else
- {
- GLenum componentType = VariableComponentType(transposedType);
- int columnCount = VariableColumnCount(transposedType);
- typeString = HLSLComponentTypeString(componentType, columnCount);
- }
- varyingHLSL += typeString + " v" + n + " : " + varyingSemantic + n + ";\n";
- }
- }
- }
- }
-
- return varyingHLSL;
-}
-
-std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &sourceShader,
- const VertexFormat inputLayout[],
- const sh::Attribute shaderAttributes[]) const
-{
- std::string structHLSL, initHLSL;
-
- int semanticIndex = 0;
- unsigned int inputIndex = 0;
-
- for (unsigned int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
- {
- const sh::Attribute &shaderAttribute = shaderAttributes[attributeIndex];
- if (!shaderAttribute.name.empty())
- {
- ASSERT(inputIndex < MAX_VERTEX_ATTRIBS);
- const VertexFormat &vertexFormat = inputLayout[inputIndex];
-
- // HLSL code for input structure
- if (IsMatrixType(shaderAttribute.type))
- {
- // Matrix types are always transposed
- structHLSL += " " + HLSLMatrixTypeString(TransposeMatrixType(shaderAttribute.type));
- }
- else
- {
- GLenum componentType = mRenderer->getVertexComponentType(vertexFormat);
- structHLSL += " " + HLSLComponentTypeString(componentType, VariableComponentCount(shaderAttribute.type));
- }
-
- structHLSL += " " + decorateVariable(shaderAttribute.name) + " : TEXCOORD" + Str(semanticIndex) + ";\n";
- semanticIndex += VariableRegisterCount(shaderAttribute.type);
-
- // HLSL code for initialization
- initHLSL += " " + decorateVariable(shaderAttribute.name) + " = ";
-
- // Mismatched vertex attribute to vertex input may result in an undefined
- // data reinterpretation (eg for pure integer->float, float->pure integer)
- // TODO: issue warning with gl debug info extension, when supported
- if (IsMatrixType(shaderAttribute.type) ||
- (mRenderer->getVertexConversionType(vertexFormat) & VERTEX_CONVERT_GPU) != 0)
- {
- initHLSL += generateAttributeConversionHLSL(vertexFormat, shaderAttribute);
- }
- else
- {
- initHLSL += "input." + decorateVariable(shaderAttribute.name);
- }
-
- initHLSL += ";\n";
-
- inputIndex += VariableRowCount(TransposeMatrixType(shaderAttribute.type));
- }
- }
-
- std::string replacementHLSL = "struct VS_INPUT\n"
- "{\n" +
- structHLSL +
- "};\n"
- "\n"
- "void initAttributes(VS_INPUT input)\n"
- "{\n" +
- initHLSL +
- "}\n";
-
- std::string vertexHLSL(sourceShader);
-
- size_t copyInsertionPos = vertexHLSL.find(VERTEX_ATTRIBUTE_STUB_STRING);
- vertexHLSL.replace(copyInsertionPos, VERTEX_ATTRIBUTE_STUB_STRING.length(), replacementHLSL);
-
- return vertexHLSL;
-}
-
-std::string DynamicHLSL::generatePixelShaderForOutputSignature(const std::string &sourceShader, const std::vector<PixelShaderOutputVariable> &outputVariables,
- bool usesFragDepth, const std::vector<GLenum> &outputLayout) const
-{
- const int shaderModel = mRenderer->getMajorShaderModel();
- std::string targetSemantic = (shaderModel >= 4) ? "SV_TARGET" : "COLOR";
- std::string depthSemantic = (shaderModel >= 4) ? "SV_Depth" : "DEPTH";
-
- std::string declarationHLSL;
- std::string copyHLSL;
-
- for (size_t layoutIndex = 0; layoutIndex < outputLayout.size(); ++layoutIndex)
- {
- GLenum binding = outputLayout[layoutIndex];
-
- if (binding != GL_NONE)
- {
- unsigned int location = (binding - GL_COLOR_ATTACHMENT0);
-
- const PixelShaderOutputVariable &outputVariable = GetOutputAtLocation(outputVariables, location);
-
- declarationHLSL += " " + HLSLTypeString(outputVariable.type) + " " + outputVariable.name +
- " : " + targetSemantic + Str(layoutIndex) + ";\n";
-
- copyHLSL += " output." + outputVariable.name + " = " + outputVariable.source + ";\n";
- }
- }
-
- if (usesFragDepth)
- {
- declarationHLSL += " float gl_Depth : " + depthSemantic + ";\n";
- copyHLSL += " output.gl_Depth = gl_Depth; \n";
- }
-
- std::string replacementHLSL = "struct PS_OUTPUT\n"
- "{\n" +
- declarationHLSL +
- "};\n"
- "\n"
- "PS_OUTPUT generateOutput()\n"
- "{\n"
- " PS_OUTPUT output;\n" +
- copyHLSL +
- " return output;\n"
- "}\n";
-
- std::string pixelHLSL(sourceShader);
-
- size_t outputInsertionPos = pixelHLSL.find(PIXEL_OUTPUT_STUB_STRING);
- pixelHLSL.replace(outputInsertionPos, PIXEL_OUTPUT_STUB_STRING.length(), replacementHLSL);
-
- return pixelHLSL;
-}
-
-std::string DynamicHLSL::getVaryingSemantic(bool pointSize) const
-{
- // SM3 reserves the TEXCOORD semantic for point sprite texcoords (gl_PointCoord)
- // In D3D11 we manually compute gl_PointCoord in the GS.
- int shaderModel = mRenderer->getMajorShaderModel();
- return ((pointSize && shaderModel < 4) ? "COLOR" : "TEXCOORD");
-}
-
-struct DynamicHLSL::SemanticInfo
-{
- struct BuiltinInfo
- {
- BuiltinInfo()
- : enabled(false),
- index(0),
- systemValue(false)
- {}
-
- bool enabled;
- std::string semantic;
- unsigned int index;
- bool systemValue;
-
- std::string str() const
- {
- return (systemValue ? semantic : (semantic + Str(index)));
- }
-
- void enableSystem(const std::string &systemValueSemantic)
- {
- enabled = true;
- semantic = systemValueSemantic;
- systemValue = true;
- }
-
- void enable(const std::string &semanticVal, unsigned int indexVal)
- {
- enabled = true;
- semantic = semanticVal;
- index = indexVal;
- }
- };
-
- BuiltinInfo dxPosition;
- BuiltinInfo glPosition;
- BuiltinInfo glFragCoord;
- BuiltinInfo glPointCoord;
- BuiltinInfo glPointSize;
-};
-
-DynamicHLSL::SemanticInfo DynamicHLSL::getSemanticInfo(int startRegisters, bool fragCoord, bool pointCoord,
- bool pointSize, bool pixelShader) const
-{
- SemanticInfo info;
- bool hlsl4 = (mRenderer->getMajorShaderModel() >= 4);
- const std::string &varyingSemantic = getVaryingSemantic(pointSize);
-
- int reservedRegisterIndex = startRegisters;
-
- if (hlsl4)
- {
- info.dxPosition.enableSystem("SV_Position");
- }
- else if (pixelShader)
- {
- info.dxPosition.enableSystem("VPOS");
- }
- else
- {
- info.dxPosition.enableSystem("POSITION");
- }
-
- info.glPosition.enable(varyingSemantic, reservedRegisterIndex++);
-
- if (fragCoord)
- {
- info.glFragCoord.enable(varyingSemantic, reservedRegisterIndex++);
- }
-
- if (pointCoord)
- {
- // SM3 reserves the TEXCOORD semantic for point sprite texcoords (gl_PointCoord)
- // In D3D11 we manually compute gl_PointCoord in the GS.
- if (hlsl4)
- {
- info.glPointCoord.enable(varyingSemantic, reservedRegisterIndex++);
- }
- else
- {
- info.glPointCoord.enable("TEXCOORD", 0);
- }
- }
-
- // Special case: do not include PSIZE semantic in HLSL 3 pixel shaders
- if (pointSize && (!pixelShader || hlsl4))
- {
- info.glPointSize.enableSystem("PSIZE");
- }
-
- return info;
-}
-
-std::string DynamicHLSL::generateVaryingLinkHLSL(const SemanticInfo &info, const std::string &varyingHLSL) const
-{
- std::string linkHLSL = "{\n";
-
- ASSERT(info.dxPosition.enabled && info.glPosition.enabled);
-
- linkHLSL += " float4 dx_Position : " + info.dxPosition.str() + ";\n";
- linkHLSL += " float4 gl_Position : " + info.glPosition.str() + ";\n";
-
- if (info.glFragCoord.enabled)
- {
- linkHLSL += " float4 gl_FragCoord : " + info.glFragCoord.str() + ";\n";
- }
-
- if (info.glPointCoord.enabled)
- {
- linkHLSL += " float2 gl_PointCoord : " + info.glPointCoord.str() + ";\n";
- }
-
- linkHLSL += varyingHLSL;
-
- if (info.glPointSize.enabled)
- {
- linkHLSL += " float gl_PointSize : " + info.glPointSize.str() + ";\n";
- }
-
- linkHLSL += "};\n";
-
- return linkHLSL;
-}
-
-void DynamicHLSL::storeBuiltinLinkedVaryings(const SemanticInfo &info,
- std::vector<LinkedVarying> *linkedVaryings) const
-{
- ASSERT(info.glPosition.enabled);
-
- linkedVaryings->push_back(LinkedVarying("gl_Position", GL_FLOAT_VEC4, 1, info.glPosition.semantic,
- info.glPosition.index, 1));
-
- if (info.glFragCoord.enabled)
- {
- linkedVaryings->push_back(LinkedVarying("gl_FragCoord", GL_FLOAT_VEC4, 1, info.glFragCoord.semantic,
- info.glFragCoord.index, 1));
- }
-
- if (info.glPointSize.enabled)
- {
- linkedVaryings->push_back(LinkedVarying("gl_PointSize", GL_FLOAT, 1, "PSIZE", 0, 1));
- }
-}
-
-void DynamicHLSL::storeUserLinkedVaryings(const ShaderD3D *vertexShader,
- std::vector<LinkedVarying> *linkedVaryings) const
-{
- const std::string &varyingSemantic = getVaryingSemantic(vertexShader->mUsesPointSize);
- const std::vector<PackedVarying> &varyings = vertexShader->getVaryings();
-
- for (unsigned int varyingIndex = 0; varyingIndex < varyings.size(); varyingIndex++)
- {
- const PackedVarying &varying = varyings[varyingIndex];
-
- if (varying.registerAssigned())
- {
- ASSERT(!varying.isBuiltIn());
- GLenum transposedType = TransposeMatrixType(varying.type);
- int variableRows = (varying.isStruct() ? 1 : VariableRowCount(transposedType));
-
- linkedVaryings->push_back(LinkedVarying(varying.name, varying.type, varying.elementCount(),
- varyingSemantic, varying.registerIndex,
- variableRows * varying.elementCount()));
- }
- }
-}
-
-bool DynamicHLSL::generateShaderLinkHLSL(const gl::Data &data, InfoLog &infoLog, int registers,
- const VaryingPacking packing,
- std::string &pixelHLSL, std::string &vertexHLSL,
- ShaderD3D *fragmentShader, ShaderD3D *vertexShader,
- const std::vector<std::string> &transformFeedbackVaryings,
- std::vector<LinkedVarying> *linkedVaryings,
- std::map<int, VariableLocation> *programOutputVars,
- std::vector<PixelShaderOutputVariable> *outPixelShaderKey,
- bool *outUsesFragDepth) const
-{
- if (pixelHLSL.empty() || vertexHLSL.empty())
- {
- return false;
- }
-
- bool usesMRT = fragmentShader->mUsesMultipleRenderTargets;
- bool usesFragColor = fragmentShader->mUsesFragColor;
- bool usesFragData = fragmentShader->mUsesFragData;
- bool usesFragCoord = fragmentShader->mUsesFragCoord;
- bool usesPointCoord = fragmentShader->mUsesPointCoord;
- bool usesPointSize = vertexShader->mUsesPointSize;
-
- if (usesFragColor && usesFragData)
- {
- infoLog.append("Cannot use both gl_FragColor and gl_FragData in the same fragment shader.");
- return false;
- }
-
- // Write the HLSL input/output declarations
- const int shaderModel = mRenderer->getMajorShaderModel();
- const int registersNeeded = registers + (usesFragCoord ? 1 : 0) + (usesPointCoord ? 1 : 0);
-
- // Two cases when writing to gl_FragColor and using ESSL 1.0:
- // - with a 3.0 context, the output color is copied to channel 0
- // - with a 2.0 context, the output color is broadcast to all channels
- const bool broadcast = (fragmentShader->mUsesFragColor && data.clientVersion < 3);
- const unsigned int numRenderTargets = (broadcast || usesMRT ? data.caps->maxDrawBuffers : 1);
-
- int shaderVersion = vertexShader->getShaderVersion();
-
- if (static_cast<GLuint>(registersNeeded) > data.caps->maxVaryingVectors)
- {
- infoLog.append("No varying registers left to support gl_FragCoord/gl_PointCoord");
- return false;
- }
-
- const std::string &varyingHLSL = generateVaryingHLSL(vertexShader);
- const SemanticInfo &vertexSemantics = getSemanticInfo(registers, usesFragCoord,
- false, usesPointSize, false);
-
- storeUserLinkedVaryings(vertexShader, linkedVaryings);
- storeBuiltinLinkedVaryings(vertexSemantics, linkedVaryings);
-
- // Add stub string to be replaced when shader is dynamically defined by its layout
- vertexHLSL += "\n" + VERTEX_ATTRIBUTE_STUB_STRING + "\n"
- "struct VS_OUTPUT\n" + generateVaryingLinkHLSL(vertexSemantics, varyingHLSL) + "\n"
- "VS_OUTPUT main(VS_INPUT input)\n"
- "{\n"
- " initAttributes(input);\n";
-
- if (shaderModel >= 4)
- {
- vertexHLSL += "\n"
- " gl_main();\n"
- "\n"
- " VS_OUTPUT output;\n"
- " output.gl_Position = gl_Position;\n"
- " output.dx_Position.x = gl_Position.x;\n"
- " output.dx_Position.y = -gl_Position.y;\n"
- " output.dx_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n"
- " output.dx_Position.w = gl_Position.w;\n";
- }
- else
- {
- vertexHLSL += "\n"
- " gl_main();\n"
- "\n"
- " VS_OUTPUT output;\n"
- " output.gl_Position = gl_Position;\n"
- " output.dx_Position.x = gl_Position.x * dx_ViewAdjust.z + dx_ViewAdjust.x * gl_Position.w;\n"
- " output.dx_Position.y = -(gl_Position.y * dx_ViewAdjust.w + dx_ViewAdjust.y * gl_Position.w);\n"
- " output.dx_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n"
- " output.dx_Position.w = gl_Position.w;\n";
- }
-
- if (usesPointSize && shaderModel >= 3)
- {
- vertexHLSL += " output.gl_PointSize = gl_PointSize;\n";
- }
-
- if (usesFragCoord)
- {
- vertexHLSL += " output.gl_FragCoord = gl_Position;\n";
- }
-
- const std::vector<PackedVarying> &vertexVaryings = vertexShader->getVaryings();
- for (unsigned int vertVaryingIndex = 0; vertVaryingIndex < vertexVaryings.size(); vertVaryingIndex++)
- {
- const PackedVarying &varying = vertexVaryings[vertVaryingIndex];
- if (varying.registerAssigned())
- {
- for (unsigned int elementIndex = 0; elementIndex < varying.elementCount(); elementIndex++)
- {
- int variableRows = (varying.isStruct() ? 1 : VariableRowCount(TransposeMatrixType(varying.type)));
-
- for (int row = 0; row < variableRows; row++)
- {
- int r = varying.registerIndex + varying.columnIndex * data.caps->maxVaryingVectors + elementIndex * variableRows + row;
- vertexHLSL += " output.v" + Str(r);
-
- vertexHLSL += " = _" + varying.name;
-
- if (varying.isArray())
- {
- vertexHLSL += ArrayString(elementIndex);
- }
-
- if (variableRows > 1)
- {
- vertexHLSL += ArrayString(row);
- }
-
- vertexHLSL += ";\n";
- }
- }
- }
- }
-
- vertexHLSL += "\n"
- " return output;\n"
- "}\n";
-
- const SemanticInfo &pixelSemantics = getSemanticInfo(registers, usesFragCoord, usesPointCoord,
- usesPointSize, true);
-
- pixelHLSL += "struct PS_INPUT\n" + generateVaryingLinkHLSL(pixelSemantics, varyingHLSL) + "\n";
-
- if (shaderVersion < 300)
- {
- for (unsigned int renderTargetIndex = 0; renderTargetIndex < numRenderTargets; renderTargetIndex++)
- {
- PixelShaderOutputVariable outputKeyVariable;
- outputKeyVariable.type = GL_FLOAT_VEC4;
- outputKeyVariable.name = "gl_Color" + Str(renderTargetIndex);
- outputKeyVariable.source = broadcast ? "gl_Color[0]" : "gl_Color[" + Str(renderTargetIndex) + "]";
- outputKeyVariable.outputIndex = renderTargetIndex;
-
- outPixelShaderKey->push_back(outputKeyVariable);
- }
-
- *outUsesFragDepth = fragmentShader->mUsesFragDepth;
- }
- else
- {
- defineOutputVariables(fragmentShader, programOutputVars);
-
- const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getActiveOutputVariables();
- for (auto locationIt = programOutputVars->begin(); locationIt != programOutputVars->end(); locationIt++)
- {
- const VariableLocation &outputLocation = locationIt->second;
- const sh::ShaderVariable &outputVariable = shaderOutputVars[outputLocation.index];
- const std::string &variableName = "out_" + outputLocation.name;
- const std::string &elementString = (outputLocation.element == GL_INVALID_INDEX ? "" : Str(outputLocation.element));
-
- ASSERT(outputVariable.staticUse);
-
- PixelShaderOutputVariable outputKeyVariable;
- outputKeyVariable.type = outputVariable.type;
- outputKeyVariable.name = variableName + elementString;
- outputKeyVariable.source = variableName + ArrayString(outputLocation.element);
- outputKeyVariable.outputIndex = locationIt->first;
-
- outPixelShaderKey->push_back(outputKeyVariable);
- }
-
- *outUsesFragDepth = false;
- }
-
- pixelHLSL += PIXEL_OUTPUT_STUB_STRING + "\n";
-
- if (fragmentShader->mUsesFrontFacing)
- {
- if (shaderModel >= 4)
- {
- pixelHLSL += "PS_OUTPUT main(PS_INPUT input, bool isFrontFace : SV_IsFrontFace)\n"
- "{\n";
- }
- else
- {
- pixelHLSL += "PS_OUTPUT main(PS_INPUT input, float vFace : VFACE)\n"
- "{\n";
- }
- }
- else
- {
- pixelHLSL += "PS_OUTPUT main(PS_INPUT input)\n"
- "{\n";
- }
-
- if (usesFragCoord)
- {
- pixelHLSL += " float rhw = 1.0 / input.gl_FragCoord.w;\n";
-
- if (shaderModel >= 4)
- {
- pixelHLSL += " gl_FragCoord.x = input.dx_Position.x;\n"
- " gl_FragCoord.y = input.dx_Position.y;\n";
- }
- else if (shaderModel >= 3)
- {
- pixelHLSL += " gl_FragCoord.x = input.dx_Position.x + 0.5;\n"
- " gl_FragCoord.y = input.dx_Position.y + 0.5;\n";
- }
- else
- {
- // dx_ViewCoords contains the viewport width/2, height/2, center.x and center.y. See Renderer::setViewport()
- pixelHLSL += " gl_FragCoord.x = (input.gl_FragCoord.x * rhw) * dx_ViewCoords.x + dx_ViewCoords.z;\n"
- " gl_FragCoord.y = (input.gl_FragCoord.y * rhw) * dx_ViewCoords.y + dx_ViewCoords.w;\n";
- }
-
- pixelHLSL += " gl_FragCoord.z = (input.gl_FragCoord.z * rhw) * dx_DepthFront.x + dx_DepthFront.y;\n"
- " gl_FragCoord.w = rhw;\n";
- }
-
- if (usesPointCoord && shaderModel >= 3)
- {
- pixelHLSL += " gl_PointCoord.x = input.gl_PointCoord.x;\n";
- pixelHLSL += " gl_PointCoord.y = 1.0 - input.gl_PointCoord.y;\n";
- }
-
- if (fragmentShader->mUsesFrontFacing)
- {
- if (shaderModel <= 3)
- {
- pixelHLSL += " gl_FrontFacing = (vFace * dx_DepthFront.z >= 0.0);\n";
- }
- else
- {
- pixelHLSL += " gl_FrontFacing = isFrontFace;\n";
- }
- }
-
- const std::vector<PackedVarying> &fragmentVaryings = fragmentShader->getVaryings();
- for (unsigned int varyingIndex = 0; varyingIndex < fragmentVaryings.size(); varyingIndex++)
- {
- const PackedVarying &varying = fragmentVaryings[varyingIndex];
- if (varying.registerAssigned())
- {
- ASSERT(!varying.isBuiltIn());
- for (unsigned int elementIndex = 0; elementIndex < varying.elementCount(); elementIndex++)
- {
- GLenum transposedType = TransposeMatrixType(varying.type);
- int variableRows = (varying.isStruct() ? 1 : VariableRowCount(transposedType));
- for (int row = 0; row < variableRows; row++)
- {
- std::string n = Str(varying.registerIndex + varying.columnIndex * data.caps->maxVaryingVectors + elementIndex * variableRows + row);
- pixelHLSL += " _" + varying.name;
-
- if (varying.isArray())
- {
- pixelHLSL += ArrayString(elementIndex);
- }
-
- if (variableRows > 1)
- {
- pixelHLSL += ArrayString(row);
- }
-
- if (varying.isStruct())
- {
- pixelHLSL += " = input.v" + n + ";\n"; break;
- }
- else
- {
- switch (VariableColumnCount(transposedType))
- {
- case 1: pixelHLSL += " = input.v" + n + ".x;\n"; break;
- case 2: pixelHLSL += " = input.v" + n + ".xy;\n"; break;
- case 3: pixelHLSL += " = input.v" + n + ".xyz;\n"; break;
- case 4: pixelHLSL += " = input.v" + n + ";\n"; break;
- default: UNREACHABLE();
- }
- }
- }
- }
- }
- else
- {
- ASSERT(varying.isBuiltIn() || !varying.staticUse);
- }
- }
-
- pixelHLSL += "\n"
- " gl_main();\n"
- "\n"
- " return generateOutput();\n"
- "}\n";
-
- return true;
-}
-
-void DynamicHLSL::defineOutputVariables(ShaderD3D *fragmentShader, std::map<int, VariableLocation> *programOutputVars) const
-{
- const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getActiveOutputVariables();
-
- for (unsigned int outputVariableIndex = 0; outputVariableIndex < shaderOutputVars.size(); outputVariableIndex++)
- {
- const sh::Attribute &outputVariable = shaderOutputVars[outputVariableIndex];
- const int baseLocation = outputVariable.location == -1 ? 0 : outputVariable.location;
-
- ASSERT(outputVariable.staticUse);
-
- if (outputVariable.arraySize > 0)
- {
- for (unsigned int elementIndex = 0; elementIndex < outputVariable.arraySize; elementIndex++)
- {
- const int location = baseLocation + elementIndex;
- ASSERT(programOutputVars->count(location) == 0);
- (*programOutputVars)[location] = VariableLocation(outputVariable.name, elementIndex, outputVariableIndex);
- }
- }
- else
- {
- ASSERT(programOutputVars->count(baseLocation) == 0);
- (*programOutputVars)[baseLocation] = VariableLocation(outputVariable.name, GL_INVALID_INDEX, outputVariableIndex);
- }
- }
-}
-
-std::string DynamicHLSL::generateGeometryShaderHLSL(int registers, ShaderD3D *fragmentShader, ShaderD3D *vertexShader) const
-{
- // for now we only handle point sprite emulation
- ASSERT(vertexShader->mUsesPointSize && mRenderer->getMajorShaderModel() >= 4);
- return generatePointSpriteHLSL(registers, fragmentShader, vertexShader);
-}
-
-std::string DynamicHLSL::generatePointSpriteHLSL(int registers, ShaderD3D *fragmentShader, ShaderD3D *vertexShader) const
-{
- ASSERT(registers >= 0);
- ASSERT(vertexShader->mUsesPointSize);
- ASSERT(mRenderer->getMajorShaderModel() >= 4);
-
- std::string geomHLSL;
-
- const SemanticInfo &inSemantics = getSemanticInfo(registers, fragmentShader->mUsesFragCoord,
- false, true, false);
- const SemanticInfo &outSemantics = getSemanticInfo(registers, fragmentShader->mUsesFragCoord,
- fragmentShader->mUsesPointCoord, true, false);
-
- std::string varyingHLSL = generateVaryingHLSL(vertexShader);
- std::string inLinkHLSL = generateVaryingLinkHLSL(inSemantics, varyingHLSL);
- std::string outLinkHLSL = generateVaryingLinkHLSL(outSemantics, varyingHLSL);
-
- // TODO(geofflang): use context's caps
- geomHLSL += "uniform float4 dx_ViewCoords : register(c1);\n"
- "\n"
- "struct GS_INPUT\n" + inLinkHLSL + "\n" +
- "struct GS_OUTPUT\n" + outLinkHLSL + "\n" +
- "\n"
- "static float2 pointSpriteCorners[] = \n"
- "{\n"
- " float2( 0.5f, -0.5f),\n"
- " float2( 0.5f, 0.5f),\n"
- " float2(-0.5f, -0.5f),\n"
- " float2(-0.5f, 0.5f)\n"
- "};\n"
- "\n"
- "static float2 pointSpriteTexcoords[] = \n"
- "{\n"
- " float2(1.0f, 1.0f),\n"
- " float2(1.0f, 0.0f),\n"
- " float2(0.0f, 1.0f),\n"
- " float2(0.0f, 0.0f)\n"
- "};\n"
- "\n"
- "static float minPointSize = " + Str(mRenderer->getRendererCaps().minAliasedPointSize) + ".0f;\n"
- "static float maxPointSize = " + Str(mRenderer->getRendererCaps().maxAliasedPointSize) + ".0f;\n"
- "\n"
- "[maxvertexcount(4)]\n"
- "void main(point GS_INPUT input[1], inout TriangleStream<GS_OUTPUT> outStream)\n"
- "{\n"
- " GS_OUTPUT output = (GS_OUTPUT)0;\n"
- " output.gl_Position = input[0].gl_Position;\n"
- " output.gl_PointSize = input[0].gl_PointSize;\n";
-
- for (int r = 0; r < registers; r++)
- {
- geomHLSL += " output.v" + Str(r) + " = input[0].v" + Str(r) + ";\n";
- }
-
- if (fragmentShader->mUsesFragCoord)
- {
- geomHLSL += " output.gl_FragCoord = input[0].gl_FragCoord;\n";
- }
-
- geomHLSL += " \n"
- " float gl_PointSize = clamp(input[0].gl_PointSize, minPointSize, maxPointSize);\n"
- " float4 dx_Position = input[0].dx_Position;\n"
- " float2 viewportScale = float2(1.0f / dx_ViewCoords.x, 1.0f / dx_ViewCoords.y) * dx_Position.w;\n";
-
- for (int corner = 0; corner < 4; corner++)
- {
- geomHLSL += " \n"
- " output.dx_Position = dx_Position + float4(pointSpriteCorners[" + Str(corner) + "] * viewportScale * gl_PointSize, 0.0f, 0.0f);\n";
-
- if (fragmentShader->mUsesPointCoord)
- {
- geomHLSL += " output.gl_PointCoord = pointSpriteTexcoords[" + Str(corner) + "];\n";
- }
-
- geomHLSL += " outStream.Append(output);\n";
- }
-
- geomHLSL += " \n"
- " outStream.RestartStrip();\n"
- "}\n";
-
- return geomHLSL;
-}
-
-// This method needs to match OutputHLSL::decorate
-std::string DynamicHLSL::decorateVariable(const std::string &name)
-{
- if (name.compare(0, 3, "gl_") != 0)
- {
- return "_" + name;
- }
-
- return name;
-}
-
-std::string DynamicHLSL::generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const sh::ShaderVariable &shaderAttrib) const
-{
- std::string attribString = "input." + decorateVariable(shaderAttrib.name);
-
- // Matrix
- if (IsMatrixType(shaderAttrib.type))
- {
- return "transpose(" + attribString + ")";
- }
-
- GLenum shaderComponentType = VariableComponentType(shaderAttrib.type);
- int shaderComponentCount = VariableComponentCount(shaderAttrib.type);
-
- // Perform integer to float conversion (if necessary)
- bool requiresTypeConversion = (shaderComponentType == GL_FLOAT && vertexFormat.mType != GL_FLOAT);
-
- if (requiresTypeConversion)
- {
- // TODO: normalization for 32-bit integer formats
- ASSERT(!vertexFormat.mNormalized && !vertexFormat.mPureInteger);
- return "float" + Str(shaderComponentCount) + "(" + attribString + ")";
- }
-
- // No conversion necessary
- return attribString;
-}
-
-void DynamicHLSL::getInputLayoutSignature(const VertexFormat inputLayout[], GLenum signature[]) const
-{
- for (size_t inputIndex = 0; inputIndex < MAX_VERTEX_ATTRIBS; inputIndex++)
- {
- const VertexFormat &vertexFormat = inputLayout[inputIndex];
-
- if (vertexFormat.mType == GL_NONE)
- {
- signature[inputIndex] = GL_NONE;
- }
- else
- {
- bool gpuConverted = ((mRenderer->getVertexConversionType(vertexFormat) & VERTEX_CONVERT_GPU) != 0);
- signature[inputIndex] = (gpuConverted ? GL_TRUE : GL_FALSE);
- }
- }
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/DynamicHLSL.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/DynamicHLSL.h
deleted file mode 100644
index c46bbf6ce0..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/DynamicHLSL.h
+++ /dev/null
@@ -1,101 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-// DynamicHLSL.h: Interface for link and run-time HLSL generation
-//
-
-#ifndef LIBGLESV2_RENDERER_DYNAMIC_HLSL_H_
-#define LIBGLESV2_RENDERER_DYNAMIC_HLSL_H_
-
-#include "common/angleutils.h"
-#include "libGLESv2/Constants.h"
-
-#include "angle_gl.h"
-
-#include <vector>
-#include <map>
-
-namespace sh
-{
-struct Attribute;
-struct ShaderVariable;
-}
-
-namespace gl
-{
-class InfoLog;
-struct VariableLocation;
-struct LinkedVarying;
-struct VertexAttribute;
-struct VertexFormat;
-struct PackedVarying;
-struct Data;
-}
-
-namespace rx
-{
-class RendererD3D;
-class ShaderD3D;
-
-typedef const gl::PackedVarying *VaryingPacking[gl::IMPLEMENTATION_MAX_VARYING_VECTORS][4];
-
-struct PixelShaderOutputVariable
-{
- GLenum type;
- std::string name;
- std::string source;
- size_t outputIndex;
-};
-
-class DynamicHLSL
-{
- public:
- explicit DynamicHLSL(RendererD3D *const renderer);
-
- int packVaryings(gl::InfoLog &infoLog, VaryingPacking packing, ShaderD3D *fragmentShader,
- ShaderD3D *vertexShader, const std::vector<std::string>& transformFeedbackVaryings);
- std::string generateVertexShaderForInputLayout(const std::string &sourceShader, const gl::VertexFormat inputLayout[],
- const sh::Attribute shaderAttributes[]) const;
- std::string generatePixelShaderForOutputSignature(const std::string &sourceShader, const std::vector<PixelShaderOutputVariable> &outputVariables,
- bool usesFragDepth, const std::vector<GLenum> &outputLayout) const;
- bool generateShaderLinkHLSL(const gl::Data &data, gl::InfoLog &infoLog, int registers,
- const VaryingPacking packing,
- std::string &pixelHLSL, std::string &vertexHLSL,
- ShaderD3D *fragmentShader, ShaderD3D *vertexShader,
- const std::vector<std::string> &transformFeedbackVaryings,
- std::vector<gl::LinkedVarying> *linkedVaryings,
- std::map<int, gl::VariableLocation> *programOutputVars,
- std::vector<PixelShaderOutputVariable> *outPixelShaderKey,
- bool *outUsesFragDepth) const;
-
- std::string generateGeometryShaderHLSL(int registers, ShaderD3D *fragmentShader, ShaderD3D *vertexShader) const;
- void getInputLayoutSignature(const gl::VertexFormat inputLayout[], GLenum signature[]) const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DynamicHLSL);
-
- RendererD3D *const mRenderer;
-
- struct SemanticInfo;
-
- std::string getVaryingSemantic(bool pointSize) const;
- SemanticInfo getSemanticInfo(int startRegisters, bool fragCoord, bool pointCoord, bool pointSize,
- bool pixelShader) const;
- std::string generateVaryingLinkHLSL(const SemanticInfo &info, const std::string &varyingHLSL) const;
- std::string generateVaryingHLSL(const ShaderD3D *shader) const;
- void storeUserLinkedVaryings(const ShaderD3D *vertexShader, std::vector<gl::LinkedVarying> *linkedVaryings) const;
- void storeBuiltinLinkedVaryings(const SemanticInfo &info, std::vector<gl::LinkedVarying> *linkedVaryings) const;
- void defineOutputVariables(ShaderD3D *fragmentShader, std::map<int, gl::VariableLocation> *programOutputVars) const;
- std::string generatePointSpriteHLSL(int registers, ShaderD3D *fragmentShader, ShaderD3D *vertexShader) const;
-
- // Prepend an underscore
- static std::string decorateVariable(const std::string &name);
-
- std::string generateAttributeConversionHLSL(const gl::VertexFormat &vertexFormat, const sh::ShaderVariable &shaderAttrib) const;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_DYNAMIC_HLSL_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/HLSLCompiler.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/HLSLCompiler.cpp
deleted file mode 100644
index 776d92b202..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/HLSLCompiler.cpp
+++ /dev/null
@@ -1,333 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-#include "libGLESv2/renderer/d3d/HLSLCompiler.h"
-#include "libGLESv2/Program.h"
-#include "libGLESv2/main.h"
-
-#include "common/features.h"
-#include "common/utilities.h"
-
-#ifndef QT_D3DCOMPILER_DLL
-#define QT_D3DCOMPILER_DLL D3DCOMPILER_DLL
-#endif
-#ifndef D3DCOMPILE_RESERVED16
-#define D3DCOMPILE_RESERVED16 (1 << 16)
-#endif
-#ifndef D3DCOMPILE_RESERVED17
-#define D3DCOMPILE_RESERVED17 (1 << 17)
-#endif
-
-// Definitions local to the translation unit
-namespace
-{
-
-#ifdef CREATE_COMPILER_FLAG_INFO
- #undef CREATE_COMPILER_FLAG_INFO
-#endif
-
-#define CREATE_COMPILER_FLAG_INFO(flag) { flag, #flag }
-
-struct CompilerFlagInfo
-{
- UINT mFlag;
- const char *mName;
-};
-
-CompilerFlagInfo CompilerFlagInfos[] =
-{
- // NOTE: The data below is copied from d3dcompiler.h
- // If something changes there it should be changed here as well
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_DEBUG), // (1 << 0)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_SKIP_VALIDATION), // (1 << 1)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_SKIP_OPTIMIZATION), // (1 << 2)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_PACK_MATRIX_ROW_MAJOR), // (1 << 3)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR), // (1 << 4)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_PARTIAL_PRECISION), // (1 << 5)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT), // (1 << 6)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT), // (1 << 7)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_NO_PRESHADER), // (1 << 8)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_AVOID_FLOW_CONTROL), // (1 << 9)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_PREFER_FLOW_CONTROL), // (1 << 10)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_ENABLE_STRICTNESS), // (1 << 11)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY), // (1 << 12)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_IEEE_STRICTNESS), // (1 << 13)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_OPTIMIZATION_LEVEL0), // (1 << 14)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_OPTIMIZATION_LEVEL1), // 0
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_OPTIMIZATION_LEVEL2), // ((1 << 14) | (1 << 15))
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_OPTIMIZATION_LEVEL3), // (1 << 15)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_RESERVED16), // (1 << 16)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_RESERVED17), // (1 << 17)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_WARNINGS_ARE_ERRORS) // (1 << 18)
-};
-
-#undef CREATE_COMPILER_FLAG_INFO
-
-bool IsCompilerFlagSet(UINT mask, UINT flag)
-{
- bool isFlagSet = IsMaskFlagSet(mask, flag);
-
- switch(flag)
- {
- case D3DCOMPILE_OPTIMIZATION_LEVEL0:
- return isFlagSet && !IsMaskFlagSet(mask, UINT(D3DCOMPILE_OPTIMIZATION_LEVEL3));
-
- case D3DCOMPILE_OPTIMIZATION_LEVEL1:
- return (mask & D3DCOMPILE_OPTIMIZATION_LEVEL2) == UINT(0);
-
- case D3DCOMPILE_OPTIMIZATION_LEVEL3:
- return isFlagSet && !IsMaskFlagSet(mask, UINT(D3DCOMPILE_OPTIMIZATION_LEVEL0));
-
- default:
- return isFlagSet;
- }
-}
-
-const char *GetCompilerFlagName(UINT mask, size_t flagIx)
-{
- const CompilerFlagInfo &flagInfo = CompilerFlagInfos[flagIx];
- if (IsCompilerFlagSet(mask, flagInfo.mFlag))
- {
- return flagInfo.mName;
- }
-
- return nullptr;
-}
-
-}
-
-namespace rx
-{
-
-CompileConfig::CompileConfig()
- : flags(0),
- name()
-{
-}
-
-CompileConfig::CompileConfig(UINT flags, const std::string &name)
- : flags(flags),
- name(name)
-{
-}
-
-HLSLCompiler::HLSLCompiler()
- : mD3DCompilerModule(NULL),
- mD3DCompileFunc(NULL),
- mD3DDisassembleFunc(NULL)
-{
-}
-
-HLSLCompiler::~HLSLCompiler()
-{
- release();
-}
-
-bool HLSLCompiler::initialize()
-{
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
-#if defined(ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES)
- // Find a D3DCompiler module that had already been loaded based on a predefined list of versions.
- static const char *d3dCompilerNames[] = ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES;
-
- for (size_t i = 0; i < ArraySize(d3dCompilerNames); ++i)
- {
- if (GetModuleHandleExA(0, d3dCompilerNames[i], &mD3DCompilerModule))
- {
- break;
- }
- }
-#endif // ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES
-
- // Load the compiler DLL specified by the environment, or default to QT_D3DCOMPILER_DLL
- const wchar_t *defaultCompiler = _wgetenv(L"QT_D3DCOMPILER_DLL");
- if (!defaultCompiler)
- defaultCompiler = QT_D3DCOMPILER_DLL;
-
- const wchar_t *compilerDlls[] = {
- defaultCompiler,
- L"d3dcompiler_47.dll",
- L"d3dcompiler_46.dll",
- L"d3dcompiler_45.dll",
- L"d3dcompiler_44.dll",
- L"d3dcompiler_43.dll",
- 0
- };
-
- // Load the first available known compiler DLL
- for (int i = 0; compilerDlls[i]; ++i)
- {
- mD3DCompilerModule = LoadLibrary(compilerDlls[i]);
- if (mD3DCompilerModule)
- break;
- }
-
- if (!mD3DCompilerModule)
- {
- // Load the version of the D3DCompiler DLL associated with the Direct3D version ANGLE was built with.
- mD3DCompilerModule = LoadLibrary(D3DCOMPILER_DLL);
- }
-
- if (!mD3DCompilerModule)
- {
- ERR("No D3D compiler module found - aborting!\n");
- return false;
- }
-
- mD3DCompileFunc = reinterpret_cast<pD3DCompile>(GetProcAddress(mD3DCompilerModule, "D3DCompile"));
- ASSERT(mD3DCompileFunc);
-
- mD3DDisassembleFunc = reinterpret_cast<pD3DDisassemble>(GetProcAddress(mD3DCompilerModule, "D3DDisassemble"));
- ASSERT(mD3DDisassembleFunc);
-
-#else
- // D3D Shader compiler is linked already into this module, so the export
- // can be directly assigned.
- mD3DCompilerModule = NULL;
- mD3DCompileFunc = reinterpret_cast<pD3DCompile>(D3DCompile);
- mD3DDisassembleFunc = reinterpret_cast<pD3DDisassemble>(D3DDisassemble);
-#endif
-
- return mD3DCompileFunc != NULL;
-}
-
-void HLSLCompiler::release()
-{
- if (mD3DCompilerModule)
- {
- FreeLibrary(mD3DCompilerModule);
- mD3DCompilerModule = NULL;
- mD3DCompileFunc = NULL;
- mD3DDisassembleFunc = NULL;
- }
-}
-
-gl::Error HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const std::string &hlsl, const std::string &profile,
- const std::vector<CompileConfig> &configs, const D3D_SHADER_MACRO *overrideMacros,
- ID3DBlob **outCompiledBlob, std::string *outDebugInfo) const
-{
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
- ASSERT(mD3DCompilerModule);
-#endif
- ASSERT(mD3DCompileFunc);
-
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
- if (gl::perfActive())
- {
- std::string sourcePath = getTempPath();
- std::string sourceText = FormatString("#line 2 \"%s\"\n\n%s", sourcePath.c_str(), hlsl.c_str());
- writeFile(sourcePath.c_str(), sourceText.c_str(), sourceText.size());
- }
-#endif
-
- const D3D_SHADER_MACRO *macros = overrideMacros ? overrideMacros : NULL;
-
- for (size_t i = 0; i < configs.size(); ++i)
- {
- ID3DBlob *errorMessage = NULL;
- ID3DBlob *binary = NULL;
-
- HRESULT result = mD3DCompileFunc(hlsl.c_str(), hlsl.length(), gl::g_fakepath, macros, NULL, "main", profile.c_str(),
- configs[i].flags, 0, &binary, &errorMessage);
-
- if (errorMessage)
- {
- std::string message = reinterpret_cast<const char*>(errorMessage->GetBufferPointer());
- SafeRelease(errorMessage);
-
- infoLog.appendSanitized(message.c_str());
- TRACE("\n%s", hlsl.c_str());
- TRACE("\n%s", message.c_str());
-
- if (message.find("error X3531:") != std::string::npos) // "can't unroll loops marked with loop attribute"
- {
- macros = NULL; // Disable [loop] and [flatten]
-
- // Retry without changing compiler flags
- i--;
- continue;
- }
- }
-
- if (SUCCEEDED(result))
- {
- *outCompiledBlob = binary;
-
-#if ANGLE_SHADER_DEBUG_INFO == ANGLE_ENABLED
- (*outDebugInfo) += "// COMPILER INPUT HLSL BEGIN\n\n" + hlsl + "\n// COMPILER INPUT HLSL END\n";
- (*outDebugInfo) += "\n\n// ASSEMBLY BEGIN\n\n";
- (*outDebugInfo) += "// Compiler configuration: " + configs[i].name + "\n// Flags:\n";
- for (size_t fIx = 0; fIx < ArraySize(CompilerFlagInfos); ++fIx)
- {
- const char *flagName = GetCompilerFlagName(configs[i].flags, fIx);
- if (flagName != nullptr)
- {
- (*outDebugInfo) += std::string("// ") + flagName + "\n";
- }
- }
-
- (*outDebugInfo) += "// Macros:\n";
- if (macros == nullptr)
- {
- (*outDebugInfo) += "// - : -\n";
- }
- else
- {
- for (const D3D_SHADER_MACRO *mIt = macros; mIt->Name != nullptr; ++mIt)
- {
- (*outDebugInfo) += std::string("// ") + mIt->Name + " : " + mIt->Definition + "\n";
- }
- }
-
- (*outDebugInfo) += "\n" + disassembleBinary(binary) + "\n// ASSEMBLY END\n";
-#endif
-
- return gl::Error(GL_NO_ERROR);
- }
- else
- {
- if (result == E_OUTOFMEMORY)
- {
- *outCompiledBlob = NULL;
- return gl::Error(GL_OUT_OF_MEMORY, "HLSL compiler had an unexpected failure, result: 0x%X.", result);
- }
-
- infoLog.append("Warning: D3D shader compilation failed with %s flags.", configs[i].name.c_str());
-
- if (i + 1 < configs.size())
- {
- infoLog.append(" Retrying with %s.\n", configs[i + 1].name.c_str());
- }
- }
- }
-
- // None of the configurations succeeded in compiling this shader but the compiler is still intact
- *outCompiledBlob = NULL;
- return gl::Error(GL_NO_ERROR);
-}
-
-std::string HLSLCompiler::disassembleBinary(ID3DBlob *shaderBinary) const
-{
- // Retrieve disassembly
- UINT flags = D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS | D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING;
- ID3DBlob *disassembly = NULL;
- pD3DDisassemble disassembleFunc = reinterpret_cast<pD3DDisassemble>(mD3DDisassembleFunc);
- LPCVOID buffer = shaderBinary->GetBufferPointer();
- SIZE_T bufSize = shaderBinary->GetBufferSize();
- HRESULT result = disassembleFunc(buffer, bufSize, flags, "", &disassembly);
-
- std::string asmSrc;
- if (SUCCEEDED(result))
- {
- asmSrc = reinterpret_cast<const char*>(disassembly->GetBufferPointer());
- }
-
- SafeRelease(disassembly);
-
- return asmSrc;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/HLSLCompiler.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/HLSLCompiler.h
deleted file mode 100644
index ff56f8035a..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/HLSLCompiler.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef LIBGLESV2_RENDERER_HLSL_D3DCOMPILER_H_
-#define LIBGLESV2_RENDERER_HLSL_D3DCOMPILER_H_
-
-#include "libGLESv2/Error.h"
-
-#include "common/angleutils.h"
-#include "common/platform.h"
-
-#include <vector>
-#include <string>
-
-namespace gl
-{
-class InfoLog;
-}
-
-namespace rx
-{
-
-struct CompileConfig
-{
- UINT flags;
- std::string name;
-
- CompileConfig();
- CompileConfig(UINT flags, const std::string &name);
-};
-
-class HLSLCompiler
-{
- public:
- HLSLCompiler();
- ~HLSLCompiler();
-
- bool initialize();
- void release();
-
- // Attempt to compile a HLSL shader using the supplied configurations, may output a NULL compiled blob
- // even if no GL errors are returned.
- gl::Error compileToBinary(gl::InfoLog &infoLog, const std::string &hlsl, const std::string &profile,
- const std::vector<CompileConfig> &configs, const D3D_SHADER_MACRO *overrideMacros,
- ID3DBlob **outCompiledBlob, std::string *outDebugInfo) const;
-
- std::string disassembleBinary(ID3DBlob* shaderBinary) const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(HLSLCompiler);
-
- HMODULE mD3DCompilerModule;
- pD3DCompile mD3DCompileFunc;
- pD3DDisassemble mD3DDisassembleFunc;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_HLSL_D3DCOMPILER_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ImageD3D.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ImageD3D.cpp
deleted file mode 100644
index 12b919ab5a..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ImageD3D.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-//
-// 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.
-//
-
-// Image.h: Implements the rx::Image class, an abstract base class for the
-// renderer-specific classes which will define the interface to the underlying
-// surfaces or resources.
-
-#include "libGLESv2/renderer/d3d/ImageD3D.h"
-
-namespace rx
-{
-
-ImageD3D::ImageD3D()
-{
-}
-
-ImageD3D *ImageD3D::makeImageD3D(Image *img)
-{
- ASSERT(HAS_DYNAMIC_TYPE(ImageD3D*, img));
- return static_cast<ImageD3D*>(img);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ImageD3D.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ImageD3D.h
deleted file mode 100644
index 554ca0cee0..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ImageD3D.h
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// 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.
-//
-
-// Image.h: Defines the rx::Image class, an abstract base class for the
-// renderer-specific classes which will define the interface to the underlying
-// surfaces or resources.
-
-#ifndef LIBGLESV2_RENDERER_IMAGED3D_H_
-#define LIBGLESV2_RENDERER_IMAGED3D_H_
-
-#include "common/debug.h"
-#include "libGLESv2/renderer/Image.h"
-
-namespace gl
-{
-class Framebuffer;
-struct ImageIndex;
-struct Box;
-}
-
-namespace rx
-{
-class TextureStorage;
-
-class ImageD3D : public Image
-{
- public:
- ImageD3D();
- virtual ~ImageD3D() {};
-
- static ImageD3D *makeImageD3D(Image *img);
-
- virtual bool isDirty() const = 0;
-
- virtual gl::Error setManagedSurface2D(TextureStorage *storage, int level) { return gl::Error(GL_NO_ERROR); };
- virtual gl::Error setManagedSurfaceCube(TextureStorage *storage, int face, int level) { return gl::Error(GL_NO_ERROR); };
- virtual gl::Error setManagedSurface3D(TextureStorage *storage, int level) { return gl::Error(GL_NO_ERROR); };
- virtual gl::Error setManagedSurface2DArray(TextureStorage *storage, int layer, int level) { return gl::Error(GL_NO_ERROR); };
- virtual gl::Error copyToStorage(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region) = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ImageD3D);
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_IMAGED3D_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/IndexBuffer.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/IndexBuffer.cpp
deleted file mode 100644
index aa614f6cc4..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/IndexBuffer.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-//
-// 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.
-//
-
-// IndexBuffer.cpp: Defines the abstract IndexBuffer class and IndexBufferInterface
-// class with derivations, classes that perform graphics API agnostic index buffer operations.
-
-#include "libGLESv2/renderer/d3d/IndexBuffer.h"
-#include "libGLESv2/renderer/d3d/RendererD3D.h"
-
-namespace rx
-{
-
-unsigned int IndexBuffer::mNextSerial = 1;
-
-IndexBuffer::IndexBuffer()
-{
- updateSerial();
-}
-
-IndexBuffer::~IndexBuffer()
-{
-}
-
-unsigned int IndexBuffer::getSerial() const
-{
- return mSerial;
-}
-
-void IndexBuffer::updateSerial()
-{
- mSerial = mNextSerial++;
-}
-
-
-IndexBufferInterface::IndexBufferInterface(RendererD3D *renderer, bool dynamic) : mRenderer(renderer)
-{
- mIndexBuffer = renderer->createIndexBuffer();
-
- mDynamic = dynamic;
- mWritePosition = 0;
-}
-
-IndexBufferInterface::~IndexBufferInterface()
-{
- if (mIndexBuffer)
- {
- delete mIndexBuffer;
- }
-}
-
-GLenum IndexBufferInterface::getIndexType() const
-{
- return mIndexBuffer->getIndexType();
-}
-
-unsigned int IndexBufferInterface::getBufferSize() const
-{
- return mIndexBuffer->getBufferSize();
-}
-
-unsigned int IndexBufferInterface::getSerial() const
-{
- return mIndexBuffer->getSerial();
-}
-
-gl::Error IndexBufferInterface::mapBuffer(unsigned int size, void** outMappedMemory, unsigned int *streamOffset)
-{
- // Protect against integer overflow
- if (mWritePosition + size < mWritePosition)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Mapping of internal index buffer would cause an integer overflow.");
- }
-
- gl::Error error = mIndexBuffer->mapBuffer(mWritePosition, size, outMappedMemory);
- if (error.isError())
- {
- if (outMappedMemory)
- {
- *outMappedMemory = NULL;
- }
- return error;
- }
-
- if (streamOffset)
- {
- *streamOffset = mWritePosition;
- }
-
- mWritePosition += size;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error IndexBufferInterface::unmapBuffer()
-{
- return mIndexBuffer->unmapBuffer();
-}
-
-IndexBuffer * IndexBufferInterface::getIndexBuffer() const
-{
- return mIndexBuffer;
-}
-
-unsigned int IndexBufferInterface::getWritePosition() const
-{
- return mWritePosition;
-}
-
-void IndexBufferInterface::setWritePosition(unsigned int writePosition)
-{
- mWritePosition = writePosition;
-}
-
-gl::Error IndexBufferInterface::discard()
-{
- return mIndexBuffer->discard();
-}
-
-gl::Error IndexBufferInterface::setBufferSize(unsigned int bufferSize, GLenum indexType)
-{
- if (mIndexBuffer->getBufferSize() == 0)
- {
- return mIndexBuffer->initialize(bufferSize, indexType, mDynamic);
- }
- else
- {
- return mIndexBuffer->setSize(bufferSize, indexType);
- }
-}
-
-StreamingIndexBufferInterface::StreamingIndexBufferInterface(RendererD3D *renderer) : IndexBufferInterface(renderer, true)
-{
-}
-
-StreamingIndexBufferInterface::~StreamingIndexBufferInterface()
-{
-}
-
-gl::Error StreamingIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum indexType)
-{
- unsigned int curBufferSize = getBufferSize();
- unsigned int writePos = getWritePosition();
- if (size > curBufferSize)
- {
- gl::Error error = setBufferSize(std::max(size, 2 * curBufferSize), indexType);
- if (error.isError())
- {
- return error;
- }
- setWritePosition(0);
- }
- else if (writePos + size > curBufferSize || writePos + size < writePos)
- {
- gl::Error error = discard();
- if (error.isError())
- {
- return error;
- }
- setWritePosition(0);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-
-StaticIndexBufferInterface::StaticIndexBufferInterface(RendererD3D *renderer) : IndexBufferInterface(renderer, false)
-{
-}
-
-StaticIndexBufferInterface::~StaticIndexBufferInterface()
-{
-}
-
-gl::Error StaticIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum indexType)
-{
- unsigned int curSize = getBufferSize();
- if (curSize == 0)
- {
- return setBufferSize(size, indexType);
- }
- else if (curSize >= size && indexType == getIndexType())
- {
- return gl::Error(GL_NO_ERROR);
- }
- else
- {
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION, "Internal static index buffers can't be resized");
- }
-}
-
-IndexRangeCache *StaticIndexBufferInterface::getIndexRangeCache()
-{
- return &mIndexRangeCache;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/IndexBuffer.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/IndexBuffer.h
deleted file mode 100644
index a34d30bbf3..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/IndexBuffer.h
+++ /dev/null
@@ -1,112 +0,0 @@
-//
-// 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.
-//
-
-// IndexBuffer.h: Defines the abstract IndexBuffer class and IndexBufferInterface
-// class with derivations, classes that perform graphics API agnostic index buffer operations.
-
-#ifndef LIBGLESV2_RENDERER_INDEXBUFFER_H_
-#define LIBGLESV2_RENDERER_INDEXBUFFER_H_
-
-#include "common/angleutils.h"
-#include "libGLESv2/Error.h"
-#include "libGLESv2/renderer/IndexRangeCache.h"
-
-namespace rx
-{
-class RendererD3D;
-
-class IndexBuffer
-{
- public:
- IndexBuffer();
- virtual ~IndexBuffer();
-
- virtual gl::Error initialize(unsigned int bufferSize, GLenum indexType, bool dynamic) = 0;
-
- virtual gl::Error mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory) = 0;
- virtual gl::Error unmapBuffer() = 0;
-
- virtual gl::Error discard() = 0;
-
- virtual GLenum getIndexType() const = 0;
- virtual unsigned int getBufferSize() const = 0;
- virtual gl::Error setSize(unsigned int bufferSize, GLenum indexType) = 0;
-
- unsigned int getSerial() const;
-
- protected:
- void updateSerial();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(IndexBuffer);
-
- unsigned int mSerial;
- static unsigned int mNextSerial;
-};
-
-class IndexBufferInterface
-{
- public:
- IndexBufferInterface(RendererD3D *renderer, bool dynamic);
- virtual ~IndexBufferInterface();
-
- virtual gl::Error reserveBufferSpace(unsigned int size, GLenum indexType) = 0;
-
- GLenum getIndexType() const;
- unsigned int getBufferSize() const;
-
- unsigned int getSerial() const;
-
- gl::Error mapBuffer(unsigned int size, void** outMappedMemory, unsigned int *streamOffset);
- gl::Error unmapBuffer();
-
- IndexBuffer *getIndexBuffer() const;
-
- protected:
- unsigned int getWritePosition() const;
- void setWritePosition(unsigned int writePosition);
-
- gl::Error discard();
-
- gl::Error setBufferSize(unsigned int bufferSize, GLenum indexType);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(IndexBufferInterface);
-
- RendererD3D *const mRenderer;
-
- IndexBuffer* mIndexBuffer;
-
- unsigned int mWritePosition;
- bool mDynamic;
-};
-
-class StreamingIndexBufferInterface : public IndexBufferInterface
-{
- public:
- StreamingIndexBufferInterface(RendererD3D *renderer);
- ~StreamingIndexBufferInterface();
-
- virtual gl::Error reserveBufferSpace(unsigned int size, GLenum indexType);
-};
-
-class StaticIndexBufferInterface : public IndexBufferInterface
-{
- public:
- explicit StaticIndexBufferInterface(RendererD3D *renderer);
- ~StaticIndexBufferInterface();
-
- virtual gl::Error reserveBufferSpace(unsigned int size, GLenum indexType);
-
- IndexRangeCache *getIndexRangeCache();
-
- private:
- IndexRangeCache mIndexRangeCache;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_INDEXBUFFER_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/IndexDataManager.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/IndexDataManager.cpp
deleted file mode 100644
index eddd9de887..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/IndexDataManager.cpp
+++ /dev/null
@@ -1,271 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// IndexDataManager.cpp: Defines the IndexDataManager, a class that
-// runs the Buffer translation process for index buffers.
-
-#include "libGLESv2/renderer/d3d/IndexDataManager.h"
-#include "libGLESv2/renderer/d3d/BufferD3D.h"
-#include "libGLESv2/renderer/d3d/IndexBuffer.h"
-#include "libGLESv2/renderer/d3d/RendererD3D.h"
-#include "libGLESv2/Buffer.h"
-#include "libGLESv2/main.h"
-#include "libGLESv2/formatutils.h"
-
-namespace rx
-{
-
-static void ConvertIndices(GLenum sourceType, GLenum destinationType, const void *input, GLsizei count, void *output)
-{
- if (sourceType == GL_UNSIGNED_BYTE)
- {
- ASSERT(destinationType == GL_UNSIGNED_SHORT);
- const GLubyte *in = static_cast<const GLubyte*>(input);
- GLushort *out = static_cast<GLushort*>(output);
-
- for (GLsizei i = 0; i < count; i++)
- {
- out[i] = in[i];
- }
- }
- else if (sourceType == GL_UNSIGNED_INT)
- {
- ASSERT(destinationType == GL_UNSIGNED_INT);
- memcpy(output, input, count * sizeof(GLuint));
- }
- else if (sourceType == GL_UNSIGNED_SHORT)
- {
- if (destinationType == GL_UNSIGNED_SHORT)
- {
- memcpy(output, input, count * sizeof(GLushort));
- }
- else if (destinationType == GL_UNSIGNED_INT)
- {
- const GLushort *in = static_cast<const GLushort*>(input);
- GLuint *out = static_cast<GLuint*>(output);
-
- for (GLsizei i = 0; i < count; i++)
- {
- out[i] = in[i];
- }
- }
- else UNREACHABLE();
- }
- else UNREACHABLE();
-}
-
-IndexDataManager::IndexDataManager(RendererD3D *renderer)
- : mRenderer(renderer),
- mStreamingBufferShort(NULL),
- mStreamingBufferInt(NULL)
-{
-}
-
-IndexDataManager::~IndexDataManager()
-{
- SafeDelete(mStreamingBufferShort);
- SafeDelete(mStreamingBufferInt);
-}
-
-gl::Error IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer *buffer, const GLvoid *indices, TranslatedIndexData *translated)
-{
- const gl::Type &typeInfo = gl::GetTypeInfo(type);
-
- GLenum destinationIndexType = (type == GL_UNSIGNED_INT) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT;
-
- unsigned int offset = 0;
- bool alignedOffset = false;
-
- BufferD3D *storage = NULL;
-
- if (buffer != NULL)
- {
- offset = static_cast<unsigned int>(reinterpret_cast<uintptr_t>(indices));
-
- storage = BufferD3D::makeBufferD3D(buffer->getImplementation());
-
- switch (type)
- {
- case GL_UNSIGNED_BYTE: alignedOffset = (offset % sizeof(GLubyte) == 0); break;
- case GL_UNSIGNED_SHORT: alignedOffset = (offset % sizeof(GLushort) == 0); break;
- case GL_UNSIGNED_INT: alignedOffset = (offset % sizeof(GLuint) == 0); break;
- default: UNREACHABLE(); alignedOffset = false;
- }
-
- ASSERT(typeInfo.bytes * static_cast<unsigned int>(count) + offset <= storage->getSize());
-
- const uint8_t *bufferData = NULL;
- gl::Error error = storage->getData(&bufferData);
- if (error.isError())
- {
- return error;
- }
-
- indices = bufferData + offset;
- }
-
- StaticIndexBufferInterface *staticBuffer = storage ? storage->getStaticIndexBuffer() : NULL;
- IndexBufferInterface *indexBuffer = NULL;
- bool directStorage = alignedOffset && storage && storage->supportsDirectBinding() &&
- destinationIndexType == type;
- unsigned int streamOffset = 0;
-
- if (directStorage)
- {
- streamOffset = offset;
-
- if (!buffer->getIndexRangeCache()->findRange(type, offset, count, NULL, NULL))
- {
- buffer->getIndexRangeCache()->addRange(type, offset, count, translated->indexRange, offset);
- }
- }
- else if (staticBuffer && staticBuffer->getBufferSize() != 0 && staticBuffer->getIndexType() == type && alignedOffset)
- {
- indexBuffer = staticBuffer;
-
- if (!staticBuffer->getIndexRangeCache()->findRange(type, offset, count, NULL, &streamOffset))
- {
- streamOffset = (offset / typeInfo.bytes) * gl::GetTypeInfo(destinationIndexType).bytes;
- staticBuffer->getIndexRangeCache()->addRange(type, offset, count, translated->indexRange, streamOffset);
- }
- }
-
- // Avoid D3D11's primitive restart index value
- // see http://msdn.microsoft.com/en-us/library/windows/desktop/bb205124(v=vs.85).aspx
- if (translated->indexRange.end == 0xFFFF && type == GL_UNSIGNED_SHORT && mRenderer->getMajorShaderModel() > 3)
- {
- destinationIndexType = GL_UNSIGNED_INT;
- directStorage = false;
- indexBuffer = NULL;
- }
-
- const gl::Type &destTypeInfo = gl::GetTypeInfo(destinationIndexType);
-
- if (!directStorage && !indexBuffer)
- {
- gl::Error error = getStreamingIndexBuffer(destinationIndexType, &indexBuffer);
- if (error.isError())
- {
- return error;
- }
-
- unsigned int convertCount = count;
-
- if (staticBuffer)
- {
- if (staticBuffer->getBufferSize() == 0 && alignedOffset)
- {
- indexBuffer = staticBuffer;
- convertCount = storage->getSize() / typeInfo.bytes;
- }
- else
- {
- storage->invalidateStaticData();
- staticBuffer = NULL;
- }
- }
-
- ASSERT(indexBuffer);
-
- if (convertCount > std::numeric_limits<unsigned int>::max() / destTypeInfo.bytes)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Reserving %u indices of %u bytes each exceeds the maximum buffer size.",
- convertCount, destTypeInfo.bytes);
- }
-
- unsigned int bufferSizeRequired = convertCount * destTypeInfo.bytes;
- error = indexBuffer->reserveBufferSpace(bufferSizeRequired, type);
- if (error.isError())
- {
- return error;
- }
-
- void* output = NULL;
- error = indexBuffer->mapBuffer(bufferSizeRequired, &output, &streamOffset);
- if (error.isError())
- {
- return error;
- }
-
- const uint8_t *dataPointer = reinterpret_cast<const uint8_t*>(indices);
- if (staticBuffer)
- {
- error = storage->getData(&dataPointer);
- if (error.isError())
- {
- return error;
- }
- }
- ConvertIndices(type, destinationIndexType, dataPointer, convertCount, output);
-
- error = indexBuffer->unmapBuffer();
- if (error.isError())
- {
- return error;
- }
-
- if (staticBuffer)
- {
- streamOffset = (offset / typeInfo.bytes) * destTypeInfo.bytes;
- staticBuffer->getIndexRangeCache()->addRange(type, offset, count, translated->indexRange, streamOffset);
- }
- }
-
- translated->storage = directStorage ? storage : NULL;
- translated->indexBuffer = indexBuffer ? indexBuffer->getIndexBuffer() : NULL;
- translated->serial = directStorage ? storage->getSerial() : indexBuffer->getSerial();
- translated->startIndex = streamOffset / destTypeInfo.bytes;
- translated->startOffset = streamOffset;
- translated->indexType = destinationIndexType;
-
- if (storage)
- {
- storage->promoteStaticUsage(count * typeInfo.bytes);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error IndexDataManager::getStreamingIndexBuffer(GLenum destinationIndexType, IndexBufferInterface **outBuffer)
-{
- ASSERT(outBuffer);
- if (destinationIndexType == GL_UNSIGNED_INT)
- {
- if (!mStreamingBufferInt)
- {
- mStreamingBufferInt = new StreamingIndexBufferInterface(mRenderer);
- gl::Error error = mStreamingBufferInt->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT);
- if (error.isError())
- {
- SafeDelete(mStreamingBufferInt);
- return error;
- }
- }
-
- *outBuffer = mStreamingBufferInt;
- return gl::Error(GL_NO_ERROR);
- }
- else
- {
- ASSERT(destinationIndexType == GL_UNSIGNED_SHORT);
-
- if (!mStreamingBufferShort)
- {
- mStreamingBufferShort = new StreamingIndexBufferInterface(mRenderer);
- gl::Error error = mStreamingBufferShort->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_SHORT);
- if (error.isError())
- {
- SafeDelete(mStreamingBufferShort);
- return error;
- }
- }
-
- *outBuffer = mStreamingBufferShort;
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/IndexDataManager.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/IndexDataManager.h
deleted file mode 100644
index a1aee1588b..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/IndexDataManager.h
+++ /dev/null
@@ -1,71 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// IndexDataManager.h: Defines the IndexDataManager, a class that
-// runs the Buffer translation process for index buffers.
-
-#ifndef LIBGLESV2_INDEXDATAMANAGER_H_
-#define LIBGLESV2_INDEXDATAMANAGER_H_
-
-#include "common/angleutils.h"
-#include "common/mathutil.h"
-#include "libGLESv2/Error.h"
-
-#include <GLES2/gl2.h>
-
-namespace
-{
- enum { INITIAL_INDEX_BUFFER_SIZE = 4096 * sizeof(GLuint) };
-}
-
-namespace gl
-{
-class Buffer;
-}
-
-namespace rx
-{
-class IndexBufferInterface;
-class StaticIndexBufferInterface;
-class StreamingIndexBufferInterface;
-class IndexBuffer;
-class BufferD3D;
-class RendererD3D;
-
-struct TranslatedIndexData
-{
- RangeUI indexRange;
- unsigned int startIndex;
- unsigned int startOffset; // In bytes
-
- IndexBuffer *indexBuffer;
- BufferD3D *storage;
- GLenum indexType;
- unsigned int serial;
-};
-
-class IndexDataManager
-{
- public:
- explicit IndexDataManager(RendererD3D *renderer);
- virtual ~IndexDataManager();
-
- gl::Error prepareIndexData(GLenum type, GLsizei count, gl::Buffer *arrayElementBuffer, const GLvoid *indices, TranslatedIndexData *translated);
-
- private:
- gl::Error getStreamingIndexBuffer(GLenum destinationIndexType, IndexBufferInterface **outBuffer);
-
- DISALLOW_COPY_AND_ASSIGN(IndexDataManager);
-
- RendererD3D *const mRenderer;
-
- StreamingIndexBufferInterface *mStreamingBufferShort;
- StreamingIndexBufferInterface *mStreamingBufferInt;
-};
-
-}
-
-#endif // LIBGLESV2_INDEXDATAMANAGER_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/MemoryBuffer.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/MemoryBuffer.cpp
deleted file mode 100644
index 2b5b09a324..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/MemoryBuffer.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-#include "libGLESv2/renderer/d3d/MemoryBuffer.h"
-#include "common/debug.h"
-
-#include <algorithm>
-#include <cstdlib>
-
-namespace rx
-{
-
-MemoryBuffer::MemoryBuffer()
- : mSize(0),
- mData(NULL)
-{
-}
-
-MemoryBuffer::~MemoryBuffer()
-{
- free(mData);
- mData = NULL;
-}
-
-bool MemoryBuffer::resize(size_t size)
-{
- if (size == 0)
- {
- free(mData);
- mData = NULL;
- mSize = 0;
- }
- else
- {
- uint8_t *newMemory = reinterpret_cast<uint8_t*>(malloc(sizeof(uint8_t) * size));
- if (newMemory == NULL)
- {
- return false;
- }
-
- if (mData)
- {
- // Copy the intersection of the old data and the new data
- std::copy(mData, mData + std::min(mSize, size), newMemory);
- free(mData);
- }
-
- mData = newMemory;
- mSize = size;
- }
-
- return true;
-}
-
-size_t MemoryBuffer::size() const
-{
- return mSize;
-}
-
-const uint8_t *MemoryBuffer::data() const
-{
- return mData;
-}
-
-uint8_t *MemoryBuffer::data()
-{
- ASSERT(mData);
- return mData;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/MemoryBuffer.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/MemoryBuffer.h
deleted file mode 100644
index c65f79fe10..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/MemoryBuffer.h
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-#ifndef LIBGLESV2_RENDERER_D3D_MEMORYBUFFER_H_
-#define LIBGLESV2_RENDERER_D3D_MEMORYBUFFER_H_
-
-#include <cstddef>
-#include <cstdint>
-
-namespace rx
-{
-
-class MemoryBuffer
-{
- public:
- MemoryBuffer();
- ~MemoryBuffer();
-
- bool resize(size_t size);
- size_t size() const;
- bool empty() const { return mSize == 0; }
-
- const uint8_t *data() const;
- uint8_t *data();
-
- private:
- size_t mSize;
- uint8_t *mData;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_D3D_MEMORYBUFFER_H
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ProgramD3D.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ProgramD3D.cpp
deleted file mode 100644
index 75da78110e..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ProgramD3D.cpp
+++ /dev/null
@@ -1,1925 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// ProgramD3D.cpp: Defines the rx::ProgramD3D class which implements rx::ProgramImpl.
-
-#include "libGLESv2/renderer/d3d/ProgramD3D.h"
-
-#include "common/features.h"
-#include "common/utilities.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/FramebufferAttachment.h"
-#include "libGLESv2/Program.h"
-#include "libGLESv2/ProgramBinary.h"
-#include "libGLESv2/main.h"
-#include "libGLESv2/renderer/ShaderExecutable.h"
-#include "libGLESv2/renderer/d3d/DynamicHLSL.h"
-#include "libGLESv2/renderer/d3d/RendererD3D.h"
-#include "libGLESv2/renderer/d3d/ShaderD3D.h"
-
-namespace rx
-{
-
-namespace
-{
-
-GLenum GetTextureType(GLenum samplerType)
-{
- switch (samplerType)
- {
- case GL_SAMPLER_2D:
- case GL_INT_SAMPLER_2D:
- case GL_UNSIGNED_INT_SAMPLER_2D:
- case GL_SAMPLER_2D_SHADOW:
- return GL_TEXTURE_2D;
- case GL_SAMPLER_3D:
- case GL_INT_SAMPLER_3D:
- case GL_UNSIGNED_INT_SAMPLER_3D:
- return GL_TEXTURE_3D;
- case GL_SAMPLER_CUBE:
- case GL_SAMPLER_CUBE_SHADOW:
- return GL_TEXTURE_CUBE_MAP;
- case GL_INT_SAMPLER_CUBE:
- case GL_UNSIGNED_INT_SAMPLER_CUBE:
- return GL_TEXTURE_CUBE_MAP;
- case GL_SAMPLER_2D_ARRAY:
- case GL_INT_SAMPLER_2D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
- case GL_SAMPLER_2D_ARRAY_SHADOW:
- return GL_TEXTURE_2D_ARRAY;
- default: UNREACHABLE();
- }
-
- return GL_TEXTURE_2D;
-}
-
-void GetDefaultInputLayoutFromShader(const std::vector<sh::Attribute> &shaderAttributes, gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS])
-{
- size_t layoutIndex = 0;
- for (size_t attributeIndex = 0; attributeIndex < shaderAttributes.size(); attributeIndex++)
- {
- ASSERT(layoutIndex < gl::MAX_VERTEX_ATTRIBS);
-
- const sh::Attribute &shaderAttr = shaderAttributes[attributeIndex];
-
- if (shaderAttr.type != GL_NONE)
- {
- GLenum transposedType = gl::TransposeMatrixType(shaderAttr.type);
-
- for (size_t rowIndex = 0; static_cast<int>(rowIndex) < gl::VariableRowCount(transposedType); rowIndex++, layoutIndex++)
- {
- gl::VertexFormat *defaultFormat = &inputLayout[layoutIndex];
-
- defaultFormat->mType = gl::VariableComponentType(transposedType);
- defaultFormat->mNormalized = false;
- defaultFormat->mPureInteger = (defaultFormat->mType != GL_FLOAT); // note: inputs can not be bool
- defaultFormat->mComponents = gl::VariableColumnCount(transposedType);
- }
- }
- }
-}
-
-std::vector<GLenum> GetDefaultOutputLayoutFromShader(const std::vector<PixelShaderOutputVariable> &shaderOutputVars)
-{
- std::vector<GLenum> defaultPixelOutput(1);
-
- ASSERT(!shaderOutputVars.empty());
- defaultPixelOutput[0] = GL_COLOR_ATTACHMENT0 + shaderOutputVars[0].outputIndex;
-
- return defaultPixelOutput;
-}
-
-bool IsRowMajorLayout(const sh::InterfaceBlockField &var)
-{
- return var.isRowMajorLayout;
-}
-
-bool IsRowMajorLayout(const sh::ShaderVariable &var)
-{
- return false;
-}
-
-}
-
-ProgramD3D::VertexExecutable::VertexExecutable(const gl::VertexFormat inputLayout[],
- const GLenum signature[],
- ShaderExecutable *shaderExecutable)
- : mShaderExecutable(shaderExecutable)
-{
- for (size_t attributeIndex = 0; attributeIndex < gl::MAX_VERTEX_ATTRIBS; attributeIndex++)
- {
- mInputs[attributeIndex] = inputLayout[attributeIndex];
- mSignature[attributeIndex] = signature[attributeIndex];
- }
-}
-
-ProgramD3D::VertexExecutable::~VertexExecutable()
-{
- SafeDelete(mShaderExecutable);
-}
-
-bool ProgramD3D::VertexExecutable::matchesSignature(const GLenum signature[]) const
-{
- for (size_t attributeIndex = 0; attributeIndex < gl::MAX_VERTEX_ATTRIBS; attributeIndex++)
- {
- if (mSignature[attributeIndex] != signature[attributeIndex])
- {
- return false;
- }
- }
-
- return true;
-}
-
-ProgramD3D::PixelExecutable::PixelExecutable(const std::vector<GLenum> &outputSignature, ShaderExecutable *shaderExecutable)
- : mOutputSignature(outputSignature),
- mShaderExecutable(shaderExecutable)
-{
-}
-
-ProgramD3D::PixelExecutable::~PixelExecutable()
-{
- SafeDelete(mShaderExecutable);
-}
-
-ProgramD3D::Sampler::Sampler() : active(false), logicalTextureUnit(0), textureType(GL_TEXTURE_2D)
-{
-}
-
-ProgramD3D::ProgramD3D(RendererD3D *renderer)
- : ProgramImpl(),
- mRenderer(renderer),
- mDynamicHLSL(NULL),
- mGeometryExecutable(NULL),
- mVertexWorkarounds(ANGLE_D3D_WORKAROUND_NONE),
- mPixelWorkarounds(ANGLE_D3D_WORKAROUND_NONE),
- mUsesPointSize(false),
- mVertexUniformStorage(NULL),
- mFragmentUniformStorage(NULL),
- mUsedVertexSamplerRange(0),
- mUsedPixelSamplerRange(0),
- mDirtySamplerMapping(true),
- mShaderVersion(100)
-{
- mDynamicHLSL = new DynamicHLSL(renderer);
-}
-
-ProgramD3D::~ProgramD3D()
-{
- reset();
- SafeDelete(mDynamicHLSL);
-}
-
-ProgramD3D *ProgramD3D::makeProgramD3D(ProgramImpl *impl)
-{
- ASSERT(HAS_DYNAMIC_TYPE(ProgramD3D*, impl));
- return static_cast<ProgramD3D*>(impl);
-}
-
-const ProgramD3D *ProgramD3D::makeProgramD3D(const ProgramImpl *impl)
-{
- ASSERT(HAS_DYNAMIC_TYPE(const ProgramD3D*, impl));
- return static_cast<const ProgramD3D*>(impl);
-}
-
-bool ProgramD3D::usesPointSpriteEmulation() const
-{
- return mUsesPointSize && mRenderer->getMajorShaderModel() >= 4;
-}
-
-bool ProgramD3D::usesGeometryShader() const
-{
- return usesPointSpriteEmulation();
-}
-
-GLint ProgramD3D::getSamplerMapping(gl::SamplerType type, unsigned int samplerIndex, const gl::Caps &caps) const
-{
- GLint logicalTextureUnit = -1;
-
- switch (type)
- {
- case gl::SAMPLER_PIXEL:
- ASSERT(samplerIndex < caps.maxTextureImageUnits);
- if (samplerIndex < mSamplersPS.size() && mSamplersPS[samplerIndex].active)
- {
- logicalTextureUnit = mSamplersPS[samplerIndex].logicalTextureUnit;
- }
- break;
- case gl::SAMPLER_VERTEX:
- ASSERT(samplerIndex < caps.maxVertexTextureImageUnits);
- if (samplerIndex < mSamplersVS.size() && mSamplersVS[samplerIndex].active)
- {
- logicalTextureUnit = mSamplersVS[samplerIndex].logicalTextureUnit;
- }
- break;
- default: UNREACHABLE();
- }
-
- if (logicalTextureUnit >= 0 && logicalTextureUnit < static_cast<GLint>(caps.maxCombinedTextureImageUnits))
- {
- return logicalTextureUnit;
- }
-
- return -1;
-}
-
-// Returns the texture type for a given Direct3D 9 sampler type and
-// index (0-15 for the pixel shader and 0-3 for the vertex shader).
-GLenum ProgramD3D::getSamplerTextureType(gl::SamplerType type, unsigned int samplerIndex) const
-{
- switch (type)
- {
- case gl::SAMPLER_PIXEL:
- ASSERT(samplerIndex < mSamplersPS.size());
- ASSERT(mSamplersPS[samplerIndex].active);
- return mSamplersPS[samplerIndex].textureType;
- case gl::SAMPLER_VERTEX:
- ASSERT(samplerIndex < mSamplersVS.size());
- ASSERT(mSamplersVS[samplerIndex].active);
- return mSamplersVS[samplerIndex].textureType;
- default: UNREACHABLE();
- }
-
- return GL_TEXTURE_2D;
-}
-
-GLint ProgramD3D::getUsedSamplerRange(gl::SamplerType type) const
-{
- switch (type)
- {
- case gl::SAMPLER_PIXEL:
- return mUsedPixelSamplerRange;
- case gl::SAMPLER_VERTEX:
- return mUsedVertexSamplerRange;
- default:
- UNREACHABLE();
- return 0;
- }
-}
-
-void ProgramD3D::updateSamplerMapping()
-{
- if (!mDirtySamplerMapping)
- {
- return;
- }
-
- mDirtySamplerMapping = false;
-
- // Retrieve sampler uniform values
- for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); uniformIndex++)
- {
- gl::LinkedUniform *targetUniform = mUniforms[uniformIndex];
-
- if (targetUniform->dirty)
- {
- if (gl::IsSampler(targetUniform->type))
- {
- int count = targetUniform->elementCount();
- GLint (*v)[4] = reinterpret_cast<GLint(*)[4]>(targetUniform->data);
-
- if (targetUniform->isReferencedByFragmentShader())
- {
- unsigned int firstIndex = targetUniform->psRegisterIndex;
-
- for (int i = 0; i < count; i++)
- {
- unsigned int samplerIndex = firstIndex + i;
-
- if (samplerIndex < mSamplersPS.size())
- {
- ASSERT(mSamplersPS[samplerIndex].active);
- mSamplersPS[samplerIndex].logicalTextureUnit = v[i][0];
- }
- }
- }
-
- if (targetUniform->isReferencedByVertexShader())
- {
- unsigned int firstIndex = targetUniform->vsRegisterIndex;
-
- for (int i = 0; i < count; i++)
- {
- unsigned int samplerIndex = firstIndex + i;
-
- if (samplerIndex < mSamplersVS.size())
- {
- ASSERT(mSamplersVS[samplerIndex].active);
- mSamplersVS[samplerIndex].logicalTextureUnit = v[i][0];
- }
- }
- }
- }
- }
- }
-}
-
-bool ProgramD3D::validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps)
-{
- // if any two active samplers in a program are of different types, but refer to the same
- // texture image unit, and this is the current program, then ValidateProgram will fail, and
- // DrawArrays and DrawElements will issue the INVALID_OPERATION error.
- updateSamplerMapping();
-
- std::vector<GLenum> textureUnitTypes(caps.maxCombinedTextureImageUnits, GL_NONE);
-
- for (unsigned int i = 0; i < mUsedPixelSamplerRange; ++i)
- {
- if (mSamplersPS[i].active)
- {
- unsigned int unit = mSamplersPS[i].logicalTextureUnit;
-
- if (unit >= textureUnitTypes.size())
- {
- if (infoLog)
- {
- infoLog->append("Sampler uniform (%d) exceeds GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS (%d)", unit, textureUnitTypes.size());
- }
-
- return false;
- }
-
- if (textureUnitTypes[unit] != GL_NONE)
- {
- if (mSamplersPS[i].textureType != textureUnitTypes[unit])
- {
- if (infoLog)
- {
- infoLog->append("Samplers of conflicting types refer to the same texture image unit (%d).", unit);
- }
-
- return false;
- }
- }
- else
- {
- textureUnitTypes[unit] = mSamplersPS[i].textureType;
- }
- }
- }
-
- for (unsigned int i = 0; i < mUsedVertexSamplerRange; ++i)
- {
- if (mSamplersVS[i].active)
- {
- unsigned int unit = mSamplersVS[i].logicalTextureUnit;
-
- if (unit >= textureUnitTypes.size())
- {
- if (infoLog)
- {
- infoLog->append("Sampler uniform (%d) exceeds GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS (%d)", unit, textureUnitTypes.size());
- }
-
- return false;
- }
-
- if (textureUnitTypes[unit] != GL_NONE)
- {
- if (mSamplersVS[i].textureType != textureUnitTypes[unit])
- {
- if (infoLog)
- {
- infoLog->append("Samplers of conflicting types refer to the same texture image unit (%d).", unit);
- }
-
- return false;
- }
- }
- else
- {
- textureUnitTypes[unit] = mSamplersVS[i].textureType;
- }
- }
- }
-
- return true;
-}
-
-gl::LinkResult ProgramD3D::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream)
-{
- stream->readInt(&mShaderVersion);
-
- const unsigned int psSamplerCount = stream->readInt<unsigned int>();
- for (unsigned int i = 0; i < psSamplerCount; ++i)
- {
- Sampler sampler;
- stream->readBool(&sampler.active);
- stream->readInt(&sampler.logicalTextureUnit);
- stream->readInt(&sampler.textureType);
- mSamplersPS.push_back(sampler);
- }
- const unsigned int vsSamplerCount = stream->readInt<unsigned int>();
- for (unsigned int i = 0; i < vsSamplerCount; ++i)
- {
- Sampler sampler;
- stream->readBool(&sampler.active);
- stream->readInt(&sampler.logicalTextureUnit);
- stream->readInt(&sampler.textureType);
- mSamplersVS.push_back(sampler);
- }
-
- stream->readInt(&mUsedVertexSamplerRange);
- stream->readInt(&mUsedPixelSamplerRange);
-
- const unsigned int uniformCount = stream->readInt<unsigned int>();
- if (stream->error())
- {
- infoLog.append("Invalid program binary.");
- return gl::LinkResult(false, gl::Error(GL_NO_ERROR));
- }
-
- mUniforms.resize(uniformCount);
- for (unsigned int uniformIndex = 0; uniformIndex < uniformCount; uniformIndex++)
- {
- GLenum type = stream->readInt<GLenum>();
- GLenum precision = stream->readInt<GLenum>();
- std::string name = stream->readString();
- unsigned int arraySize = stream->readInt<unsigned int>();
- int blockIndex = stream->readInt<int>();
-
- int offset = stream->readInt<int>();
- int arrayStride = stream->readInt<int>();
- int matrixStride = stream->readInt<int>();
- bool isRowMajorMatrix = stream->readBool();
-
- const sh::BlockMemberInfo blockInfo(offset, arrayStride, matrixStride, isRowMajorMatrix);
-
- gl::LinkedUniform *uniform = new gl::LinkedUniform(type, precision, name, arraySize, blockIndex, blockInfo);
-
- stream->readInt(&uniform->psRegisterIndex);
- stream->readInt(&uniform->vsRegisterIndex);
- stream->readInt(&uniform->registerCount);
- stream->readInt(&uniform->registerElement);
-
- mUniforms[uniformIndex] = uniform;
- }
-
- const unsigned int uniformIndexCount = stream->readInt<unsigned int>();
- if (stream->error())
- {
- infoLog.append("Invalid program binary.");
- return gl::LinkResult(false, gl::Error(GL_NO_ERROR));
- }
-
- mUniformIndex.resize(uniformIndexCount);
- for (unsigned int uniformIndexIndex = 0; uniformIndexIndex < uniformIndexCount; uniformIndexIndex++)
- {
- stream->readString(&mUniformIndex[uniformIndexIndex].name);
- stream->readInt(&mUniformIndex[uniformIndexIndex].element);
- stream->readInt(&mUniformIndex[uniformIndexIndex].index);
- }
-
- unsigned int uniformBlockCount = stream->readInt<unsigned int>();
- if (stream->error())
- {
- infoLog.append("Invalid program binary.");
- return gl::LinkResult(false, gl::Error(GL_NO_ERROR));
- }
-
- mUniformBlocks.resize(uniformBlockCount);
- for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < uniformBlockCount; ++uniformBlockIndex)
- {
- std::string name = stream->readString();
- unsigned int elementIndex = stream->readInt<unsigned int>();
- unsigned int dataSize = stream->readInt<unsigned int>();
-
- gl::UniformBlock *uniformBlock = new gl::UniformBlock(name, elementIndex, dataSize);
-
- stream->readInt(&uniformBlock->psRegisterIndex);
- stream->readInt(&uniformBlock->vsRegisterIndex);
-
- unsigned int numMembers = stream->readInt<unsigned int>();
- uniformBlock->memberUniformIndexes.resize(numMembers);
- for (unsigned int blockMemberIndex = 0; blockMemberIndex < numMembers; blockMemberIndex++)
- {
- stream->readInt(&uniformBlock->memberUniformIndexes[blockMemberIndex]);
- }
-
- mUniformBlocks[uniformBlockIndex] = uniformBlock;
- }
-
- stream->readInt(&mTransformFeedbackBufferMode);
- const unsigned int transformFeedbackVaryingCount = stream->readInt<unsigned int>();
- mTransformFeedbackLinkedVaryings.resize(transformFeedbackVaryingCount);
- for (unsigned int varyingIndex = 0; varyingIndex < transformFeedbackVaryingCount; varyingIndex++)
- {
- gl::LinkedVarying &varying = mTransformFeedbackLinkedVaryings[varyingIndex];
-
- stream->readString(&varying.name);
- stream->readInt(&varying.type);
- stream->readInt(&varying.size);
- stream->readString(&varying.semanticName);
- stream->readInt(&varying.semanticIndex);
- stream->readInt(&varying.semanticIndexCount);
- }
-
- stream->readString(&mVertexHLSL);
- stream->readInt(&mVertexWorkarounds);
- stream->readString(&mPixelHLSL);
- stream->readInt(&mPixelWorkarounds);
- stream->readBool(&mUsesFragDepth);
- stream->readBool(&mUsesPointSize);
-
- const size_t pixelShaderKeySize = stream->readInt<unsigned int>();
- mPixelShaderKey.resize(pixelShaderKeySize);
- for (size_t pixelShaderKeyIndex = 0; pixelShaderKeyIndex < pixelShaderKeySize; pixelShaderKeyIndex++)
- {
- stream->readInt(&mPixelShaderKey[pixelShaderKeyIndex].type);
- stream->readString(&mPixelShaderKey[pixelShaderKeyIndex].name);
- stream->readString(&mPixelShaderKey[pixelShaderKeyIndex].source);
- stream->readInt(&mPixelShaderKey[pixelShaderKeyIndex].outputIndex);
- }
-
- const unsigned char* binary = reinterpret_cast<const unsigned char*>(stream->data());
-
- const unsigned int vertexShaderCount = stream->readInt<unsigned int>();
- for (unsigned int vertexShaderIndex = 0; vertexShaderIndex < vertexShaderCount; vertexShaderIndex++)
- {
- gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS];
-
- for (size_t inputIndex = 0; inputIndex < gl::MAX_VERTEX_ATTRIBS; inputIndex++)
- {
- gl::VertexFormat *vertexInput = &inputLayout[inputIndex];
- stream->readInt(&vertexInput->mType);
- stream->readInt(&vertexInput->mNormalized);
- stream->readInt(&vertexInput->mComponents);
- stream->readBool(&vertexInput->mPureInteger);
- }
-
- unsigned int vertexShaderSize = stream->readInt<unsigned int>();
- const unsigned char *vertexShaderFunction = binary + stream->offset();
-
- ShaderExecutable *shaderExecutable = NULL;
- gl::Error error = mRenderer->loadExecutable(vertexShaderFunction, vertexShaderSize,
- SHADER_VERTEX,
- mTransformFeedbackLinkedVaryings,
- (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS),
- &shaderExecutable);
- if (error.isError())
- {
- return gl::LinkResult(false, error);
- }
-
- if (!shaderExecutable)
- {
- infoLog.append("Could not create vertex shader.");
- return gl::LinkResult(false, gl::Error(GL_NO_ERROR));
- }
-
- // generated converted input layout
- GLenum signature[gl::MAX_VERTEX_ATTRIBS];
- getInputLayoutSignature(inputLayout, signature);
-
- // add new binary
- mVertexExecutables.push_back(new VertexExecutable(inputLayout, signature, shaderExecutable));
-
- stream->skip(vertexShaderSize);
- }
-
- const size_t pixelShaderCount = stream->readInt<unsigned int>();
- for (size_t pixelShaderIndex = 0; pixelShaderIndex < pixelShaderCount; pixelShaderIndex++)
- {
- const size_t outputCount = stream->readInt<unsigned int>();
- std::vector<GLenum> outputs(outputCount);
- for (size_t outputIndex = 0; outputIndex < outputCount; outputIndex++)
- {
- stream->readInt(&outputs[outputIndex]);
- }
-
- const size_t pixelShaderSize = stream->readInt<unsigned int>();
- const unsigned char *pixelShaderFunction = binary + stream->offset();
- ShaderExecutable *shaderExecutable = NULL;
- gl::Error error = mRenderer->loadExecutable(pixelShaderFunction, pixelShaderSize, SHADER_PIXEL,
- mTransformFeedbackLinkedVaryings,
- (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS),
- &shaderExecutable);
- if (error.isError())
- {
- return gl::LinkResult(false, error);
- }
-
- if (!shaderExecutable)
- {
- infoLog.append("Could not create pixel shader.");
- return gl::LinkResult(false, gl::Error(GL_NO_ERROR));
- }
-
- // add new binary
- mPixelExecutables.push_back(new PixelExecutable(outputs, shaderExecutable));
-
- stream->skip(pixelShaderSize);
- }
-
- unsigned int geometryShaderSize = stream->readInt<unsigned int>();
-
- if (geometryShaderSize > 0)
- {
- const unsigned char *geometryShaderFunction = binary + stream->offset();
- gl::Error error = mRenderer->loadExecutable(geometryShaderFunction, geometryShaderSize, SHADER_GEOMETRY,
- mTransformFeedbackLinkedVaryings,
- (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS),
- &mGeometryExecutable);
- if (error.isError())
- {
- return gl::LinkResult(false, error);
- }
-
- if (!mGeometryExecutable)
- {
- infoLog.append("Could not create geometry shader.");
- return gl::LinkResult(false, gl::Error(GL_NO_ERROR));
- }
- stream->skip(geometryShaderSize);
- }
-
- GUID binaryIdentifier = {0};
- stream->readBytes(reinterpret_cast<unsigned char*>(&binaryIdentifier), sizeof(GUID));
-
- GUID identifier = mRenderer->getAdapterIdentifier();
- if (memcmp(&identifier, &binaryIdentifier, sizeof(GUID)) != 0)
- {
- infoLog.append("Invalid program binary.");
- return gl::LinkResult(false, gl::Error(GL_NO_ERROR));
- }
-
- initializeUniformStorage();
-
- return gl::LinkResult(true, gl::Error(GL_NO_ERROR));
-}
-
-gl::Error ProgramD3D::save(gl::BinaryOutputStream *stream)
-{
- stream->writeInt(mShaderVersion);
-
- stream->writeInt(mSamplersPS.size());
- for (unsigned int i = 0; i < mSamplersPS.size(); ++i)
- {
- stream->writeInt(mSamplersPS[i].active);
- stream->writeInt(mSamplersPS[i].logicalTextureUnit);
- stream->writeInt(mSamplersPS[i].textureType);
- }
-
- stream->writeInt(mSamplersVS.size());
- for (unsigned int i = 0; i < mSamplersVS.size(); ++i)
- {
- stream->writeInt(mSamplersVS[i].active);
- stream->writeInt(mSamplersVS[i].logicalTextureUnit);
- stream->writeInt(mSamplersVS[i].textureType);
- }
-
- stream->writeInt(mUsedVertexSamplerRange);
- stream->writeInt(mUsedPixelSamplerRange);
-
- stream->writeInt(mUniforms.size());
- for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); ++uniformIndex)
- {
- const gl::LinkedUniform &uniform = *mUniforms[uniformIndex];
-
- stream->writeInt(uniform.type);
- stream->writeInt(uniform.precision);
- stream->writeString(uniform.name);
- stream->writeInt(uniform.arraySize);
- stream->writeInt(uniform.blockIndex);
-
- stream->writeInt(uniform.blockInfo.offset);
- stream->writeInt(uniform.blockInfo.arrayStride);
- stream->writeInt(uniform.blockInfo.matrixStride);
- stream->writeInt(uniform.blockInfo.isRowMajorMatrix);
-
- stream->writeInt(uniform.psRegisterIndex);
- stream->writeInt(uniform.vsRegisterIndex);
- stream->writeInt(uniform.registerCount);
- stream->writeInt(uniform.registerElement);
- }
-
- stream->writeInt(mUniformIndex.size());
- for (size_t i = 0; i < mUniformIndex.size(); ++i)
- {
- stream->writeString(mUniformIndex[i].name);
- stream->writeInt(mUniformIndex[i].element);
- stream->writeInt(mUniformIndex[i].index);
- }
-
- stream->writeInt(mUniformBlocks.size());
- for (size_t uniformBlockIndex = 0; uniformBlockIndex < mUniformBlocks.size(); ++uniformBlockIndex)
- {
- const gl::UniformBlock& uniformBlock = *mUniformBlocks[uniformBlockIndex];
-
- stream->writeString(uniformBlock.name);
- stream->writeInt(uniformBlock.elementIndex);
- stream->writeInt(uniformBlock.dataSize);
-
- stream->writeInt(uniformBlock.memberUniformIndexes.size());
- for (unsigned int blockMemberIndex = 0; blockMemberIndex < uniformBlock.memberUniformIndexes.size(); blockMemberIndex++)
- {
- stream->writeInt(uniformBlock.memberUniformIndexes[blockMemberIndex]);
- }
-
- stream->writeInt(uniformBlock.psRegisterIndex);
- stream->writeInt(uniformBlock.vsRegisterIndex);
- }
-
- stream->writeInt(mTransformFeedbackBufferMode);
- stream->writeInt(mTransformFeedbackLinkedVaryings.size());
- for (size_t i = 0; i < mTransformFeedbackLinkedVaryings.size(); i++)
- {
- const gl::LinkedVarying &varying = mTransformFeedbackLinkedVaryings[i];
-
- stream->writeString(varying.name);
- stream->writeInt(varying.type);
- stream->writeInt(varying.size);
- stream->writeString(varying.semanticName);
- stream->writeInt(varying.semanticIndex);
- stream->writeInt(varying.semanticIndexCount);
- }
-
- stream->writeString(mVertexHLSL);
- stream->writeInt(mVertexWorkarounds);
- stream->writeString(mPixelHLSL);
- stream->writeInt(mPixelWorkarounds);
- stream->writeInt(mUsesFragDepth);
- stream->writeInt(mUsesPointSize);
-
- const std::vector<PixelShaderOutputVariable> &pixelShaderKey = mPixelShaderKey;
- stream->writeInt(pixelShaderKey.size());
- for (size_t pixelShaderKeyIndex = 0; pixelShaderKeyIndex < pixelShaderKey.size(); pixelShaderKeyIndex++)
- {
- const PixelShaderOutputVariable &variable = pixelShaderKey[pixelShaderKeyIndex];
- stream->writeInt(variable.type);
- stream->writeString(variable.name);
- stream->writeString(variable.source);
- stream->writeInt(variable.outputIndex);
- }
-
- stream->writeInt(mVertexExecutables.size());
- for (size_t vertexExecutableIndex = 0; vertexExecutableIndex < mVertexExecutables.size(); vertexExecutableIndex++)
- {
- VertexExecutable *vertexExecutable = mVertexExecutables[vertexExecutableIndex];
-
- for (size_t inputIndex = 0; inputIndex < gl::MAX_VERTEX_ATTRIBS; inputIndex++)
- {
- const gl::VertexFormat &vertexInput = vertexExecutable->inputs()[inputIndex];
- stream->writeInt(vertexInput.mType);
- stream->writeInt(vertexInput.mNormalized);
- stream->writeInt(vertexInput.mComponents);
- stream->writeInt(vertexInput.mPureInteger);
- }
-
- size_t vertexShaderSize = vertexExecutable->shaderExecutable()->getLength();
- stream->writeInt(vertexShaderSize);
-
- const uint8_t *vertexBlob = vertexExecutable->shaderExecutable()->getFunction();
- stream->writeBytes(vertexBlob, vertexShaderSize);
- }
-
- stream->writeInt(mPixelExecutables.size());
- for (size_t pixelExecutableIndex = 0; pixelExecutableIndex < mPixelExecutables.size(); pixelExecutableIndex++)
- {
- PixelExecutable *pixelExecutable = mPixelExecutables[pixelExecutableIndex];
-
- const std::vector<GLenum> outputs = pixelExecutable->outputSignature();
- stream->writeInt(outputs.size());
- for (size_t outputIndex = 0; outputIndex < outputs.size(); outputIndex++)
- {
- stream->writeInt(outputs[outputIndex]);
- }
-
- size_t pixelShaderSize = pixelExecutable->shaderExecutable()->getLength();
- stream->writeInt(pixelShaderSize);
-
- const uint8_t *pixelBlob = pixelExecutable->shaderExecutable()->getFunction();
- stream->writeBytes(pixelBlob, pixelShaderSize);
- }
-
- size_t geometryShaderSize = (mGeometryExecutable != NULL) ? mGeometryExecutable->getLength() : 0;
- stream->writeInt(geometryShaderSize);
-
- if (mGeometryExecutable != NULL && geometryShaderSize > 0)
- {
- const uint8_t *geometryBlob = mGeometryExecutable->getFunction();
- stream->writeBytes(geometryBlob, geometryShaderSize);
- }
-
- GUID binaryIdentifier = mRenderer->getAdapterIdentifier();
- stream->writeBytes(reinterpret_cast<unsigned char*>(&binaryIdentifier), sizeof(GUID));
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error ProgramD3D::getPixelExecutableForFramebuffer(const gl::Framebuffer *fbo, ShaderExecutable **outExecutable)
-{
- std::vector<GLenum> outputs;
-
- const gl::ColorbufferInfo &colorbuffers = fbo->getColorbuffersForRender(mRenderer->getWorkarounds());
-
- for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment)
- {
- const gl::FramebufferAttachment *colorbuffer = colorbuffers[colorAttachment];
-
- if (colorbuffer)
- {
- outputs.push_back(colorbuffer->getBinding() == GL_BACK ? GL_COLOR_ATTACHMENT0 : colorbuffer->getBinding());
- }
- else
- {
- outputs.push_back(GL_NONE);
- }
- }
-
- return getPixelExecutableForOutputLayout(outputs, outExecutable);
-}
-
-gl::Error ProgramD3D::getPixelExecutableForOutputLayout(const std::vector<GLenum> &outputSignature, ShaderExecutable **outExectuable)
-{
- for (size_t executableIndex = 0; executableIndex < mPixelExecutables.size(); executableIndex++)
- {
- if (mPixelExecutables[executableIndex]->matchesSignature(outputSignature))
- {
- *outExectuable = mPixelExecutables[executableIndex]->shaderExecutable();
- return gl::Error(GL_NO_ERROR);
- }
- }
-
- std::string finalPixelHLSL = mDynamicHLSL->generatePixelShaderForOutputSignature(mPixelHLSL, mPixelShaderKey, mUsesFragDepth,
- outputSignature);
-
- // Generate new pixel executable
- gl::InfoLog tempInfoLog;
- ShaderExecutable *pixelExecutable = NULL;
- gl::Error error = mRenderer->compileToExecutable(tempInfoLog, finalPixelHLSL, SHADER_PIXEL,
- mTransformFeedbackLinkedVaryings,
- (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS),
- mPixelWorkarounds, &pixelExecutable);
- if (error.isError())
- {
- return error;
- }
-
- if (!pixelExecutable)
- {
- std::vector<char> tempCharBuffer(tempInfoLog.getLength() + 3);
- tempInfoLog.getLog(tempInfoLog.getLength(), NULL, &tempCharBuffer[0]);
- ERR("Error compiling dynamic pixel executable:\n%s\n", &tempCharBuffer[0]);
- }
- else
- {
- mPixelExecutables.push_back(new PixelExecutable(outputSignature, pixelExecutable));
- }
-
- *outExectuable = pixelExecutable;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error ProgramD3D::getVertexExecutableForInputLayout(const gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS], ShaderExecutable **outExectuable)
-{
- GLenum signature[gl::MAX_VERTEX_ATTRIBS];
- getInputLayoutSignature(inputLayout, signature);
-
- for (size_t executableIndex = 0; executableIndex < mVertexExecutables.size(); executableIndex++)
- {
- if (mVertexExecutables[executableIndex]->matchesSignature(signature))
- {
- *outExectuable = mVertexExecutables[executableIndex]->shaderExecutable();
- return gl::Error(GL_NO_ERROR);
- }
- }
-
- // Generate new dynamic layout with attribute conversions
- std::string finalVertexHLSL = mDynamicHLSL->generateVertexShaderForInputLayout(mVertexHLSL, inputLayout, mShaderAttributes);
-
- // Generate new vertex executable
- gl::InfoLog tempInfoLog;
- ShaderExecutable *vertexExecutable = NULL;
- gl::Error error = mRenderer->compileToExecutable(tempInfoLog, finalVertexHLSL, SHADER_VERTEX,
- mTransformFeedbackLinkedVaryings,
- (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS),
- mVertexWorkarounds, &vertexExecutable);
- if (error.isError())
- {
- return error;
- }
-
- if (!vertexExecutable)
- {
- std::vector<char> tempCharBuffer(tempInfoLog.getLength()+3);
- tempInfoLog.getLog(tempInfoLog.getLength(), NULL, &tempCharBuffer[0]);
- ERR("Error compiling dynamic vertex executable:\n%s\n", &tempCharBuffer[0]);
- }
- else
- {
- mVertexExecutables.push_back(new VertexExecutable(inputLayout, signature, vertexExecutable));
- }
-
- *outExectuable = vertexExecutable;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::LinkResult ProgramD3D::compileProgramExecutables(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader,
- int registers)
-{
- ShaderD3D *vertexShaderD3D = ShaderD3D::makeShaderD3D(vertexShader->getImplementation());
- ShaderD3D *fragmentShaderD3D = ShaderD3D::makeShaderD3D(fragmentShader->getImplementation());
-
- gl::VertexFormat defaultInputLayout[gl::MAX_VERTEX_ATTRIBS];
- GetDefaultInputLayoutFromShader(vertexShader->getActiveAttributes(), defaultInputLayout);
- ShaderExecutable *defaultVertexExecutable = NULL;
- gl::Error error = getVertexExecutableForInputLayout(defaultInputLayout, &defaultVertexExecutable);
- if (error.isError())
- {
- return gl::LinkResult(false, error);
- }
-
- std::vector<GLenum> defaultPixelOutput = GetDefaultOutputLayoutFromShader(getPixelShaderKey());
- ShaderExecutable *defaultPixelExecutable = NULL;
- error = getPixelExecutableForOutputLayout(defaultPixelOutput, &defaultPixelExecutable);
- if (error.isError())
- {
- return gl::LinkResult(false, error);
- }
-
- if (usesGeometryShader())
- {
- std::string geometryHLSL = mDynamicHLSL->generateGeometryShaderHLSL(registers, fragmentShaderD3D, vertexShaderD3D);
-
-
- error = mRenderer->compileToExecutable(infoLog, geometryHLSL, SHADER_GEOMETRY, mTransformFeedbackLinkedVaryings,
- (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS),
- ANGLE_D3D_WORKAROUND_NONE, &mGeometryExecutable);
- if (error.isError())
- {
- return gl::LinkResult(false, error);
- }
- }
-
-#if ANGLE_SHADER_DEBUG_INFO == ANGLE_ENABLED
- if (usesGeometryShader() && mGeometryExecutable)
- {
- // Geometry shaders are currently only used internally, so there is no corresponding shader object at the interface level
- // For now the geometry shader debug info is pre-pended to the vertex shader, this is a bit of a clutch
- vertexShaderD3D->appendDebugInfo("// GEOMETRY SHADER BEGIN\n\n");
- vertexShaderD3D->appendDebugInfo(mGeometryExecutable->getDebugInfo());
- vertexShaderD3D->appendDebugInfo("\nGEOMETRY SHADER END\n\n\n");
- }
-
- if (defaultVertexExecutable)
- {
- vertexShaderD3D->appendDebugInfo(defaultVertexExecutable->getDebugInfo());
- }
-
- if (defaultPixelExecutable)
- {
- fragmentShaderD3D->appendDebugInfo(defaultPixelExecutable->getDebugInfo());
- }
-#endif
-
- bool linkSuccess = (defaultVertexExecutable && defaultPixelExecutable && (!usesGeometryShader() || mGeometryExecutable));
- return gl::LinkResult(linkSuccess, gl::Error(GL_NO_ERROR));
-}
-
-gl::LinkResult ProgramD3D::link(const gl::Data &data, gl::InfoLog &infoLog,
- gl::Shader *fragmentShader, gl::Shader *vertexShader,
- const std::vector<std::string> &transformFeedbackVaryings,
- GLenum transformFeedbackBufferMode,
- int *registers, std::vector<gl::LinkedVarying> *linkedVaryings,
- std::map<int, gl::VariableLocation> *outputVariables)
-{
- ShaderD3D *vertexShaderD3D = ShaderD3D::makeShaderD3D(vertexShader->getImplementation());
- ShaderD3D *fragmentShaderD3D = ShaderD3D::makeShaderD3D(fragmentShader->getImplementation());
-
- mSamplersPS.resize(data.caps->maxTextureImageUnits);
- mSamplersVS.resize(data.caps->maxVertexTextureImageUnits);
-
- mTransformFeedbackBufferMode = transformFeedbackBufferMode;
-
- mPixelHLSL = fragmentShaderD3D->getTranslatedSource();
- mPixelWorkarounds = fragmentShaderD3D->getD3DWorkarounds();
-
- mVertexHLSL = vertexShaderD3D->getTranslatedSource();
- mVertexWorkarounds = vertexShaderD3D->getD3DWorkarounds();
- mShaderVersion = vertexShaderD3D->getShaderVersion();
-
- // Map the varyings to the register file
- VaryingPacking packing = { NULL };
- *registers = mDynamicHLSL->packVaryings(infoLog, packing, fragmentShaderD3D, vertexShaderD3D, transformFeedbackVaryings);
-
- if (*registers < 0)
- {
- return gl::LinkResult(false, gl::Error(GL_NO_ERROR));
- }
-
- if (!gl::ProgramBinary::linkVaryings(infoLog, fragmentShader, vertexShader))
- {
- return gl::LinkResult(false, gl::Error(GL_NO_ERROR));
- }
-
- if (!mDynamicHLSL->generateShaderLinkHLSL(data, infoLog, *registers, packing, mPixelHLSL, mVertexHLSL,
- fragmentShaderD3D, vertexShaderD3D, transformFeedbackVaryings,
- linkedVaryings, outputVariables, &mPixelShaderKey, &mUsesFragDepth))
- {
- return gl::LinkResult(false, gl::Error(GL_NO_ERROR));
- }
-
- mUsesPointSize = vertexShaderD3D->usesPointSize();
-
- return gl::LinkResult(true, gl::Error(GL_NO_ERROR));
-}
-
-void ProgramD3D::getInputLayoutSignature(const gl::VertexFormat inputLayout[], GLenum signature[]) const
-{
- mDynamicHLSL->getInputLayoutSignature(inputLayout, signature);
-}
-
-void ProgramD3D::initializeUniformStorage()
-{
- // Compute total default block size
- unsigned int vertexRegisters = 0;
- unsigned int fragmentRegisters = 0;
- for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); uniformIndex++)
- {
- const gl::LinkedUniform &uniform = *mUniforms[uniformIndex];
-
- if (!gl::IsSampler(uniform.type))
- {
- if (uniform.isReferencedByVertexShader())
- {
- vertexRegisters = std::max(vertexRegisters, uniform.vsRegisterIndex + uniform.registerCount);
- }
- if (uniform.isReferencedByFragmentShader())
- {
- fragmentRegisters = std::max(fragmentRegisters, uniform.psRegisterIndex + uniform.registerCount);
- }
- }
- }
-
- mVertexUniformStorage = mRenderer->createUniformStorage(vertexRegisters * 16u);
- mFragmentUniformStorage = mRenderer->createUniformStorage(fragmentRegisters * 16u);
-}
-
-gl::Error ProgramD3D::applyUniforms()
-{
- updateSamplerMapping();
-
- gl::Error error = mRenderer->applyUniforms(*this, mUniforms);
- if (error.isError())
- {
- return error;
- }
-
- for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); uniformIndex++)
- {
- mUniforms[uniformIndex]->dirty = false;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error ProgramD3D::applyUniformBuffers(const std::vector<gl::Buffer*> boundBuffers, const gl::Caps &caps)
-{
- ASSERT(boundBuffers.size() == mUniformBlocks.size());
-
- const gl::Buffer *vertexUniformBuffers[gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS] = {NULL};
- const gl::Buffer *fragmentUniformBuffers[gl::IMPLEMENTATION_MAX_FRAGMENT_SHADER_UNIFORM_BUFFERS] = {NULL};
-
- const unsigned int reservedBuffersInVS = mRenderer->getReservedVertexUniformBuffers();
- const unsigned int reservedBuffersInFS = mRenderer->getReservedFragmentUniformBuffers();
-
- for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < mUniformBlocks.size(); uniformBlockIndex++)
- {
- gl::UniformBlock *uniformBlock = mUniformBlocks[uniformBlockIndex];
- gl::Buffer *uniformBuffer = boundBuffers[uniformBlockIndex];
-
- ASSERT(uniformBlock && uniformBuffer);
-
- if (uniformBuffer->getSize() < uniformBlock->dataSize)
- {
- // undefined behaviour
- return gl::Error(GL_INVALID_OPERATION, "It is undefined behaviour to use a uniform buffer that is too small.");
- }
-
- // Unnecessary to apply an unreferenced standard or shared UBO
- if (!uniformBlock->isReferencedByVertexShader() && !uniformBlock->isReferencedByFragmentShader())
- {
- continue;
- }
-
- if (uniformBlock->isReferencedByVertexShader())
- {
- unsigned int registerIndex = uniformBlock->vsRegisterIndex - reservedBuffersInVS;
- ASSERT(vertexUniformBuffers[registerIndex] == NULL);
- ASSERT(registerIndex < caps.maxVertexUniformBlocks);
- vertexUniformBuffers[registerIndex] = uniformBuffer;
- }
-
- if (uniformBlock->isReferencedByFragmentShader())
- {
- unsigned int registerIndex = uniformBlock->psRegisterIndex - reservedBuffersInFS;
- ASSERT(fragmentUniformBuffers[registerIndex] == NULL);
- ASSERT(registerIndex < caps.maxFragmentUniformBlocks);
- fragmentUniformBuffers[registerIndex] = uniformBuffer;
- }
- }
-
- return mRenderer->setUniformBuffers(vertexUniformBuffers, fragmentUniformBuffers);
-}
-
-bool ProgramD3D::assignUniformBlockRegister(gl::InfoLog &infoLog, gl::UniformBlock *uniformBlock, GLenum shader,
- unsigned int registerIndex, const gl::Caps &caps)
-{
- if (shader == GL_VERTEX_SHADER)
- {
- uniformBlock->vsRegisterIndex = registerIndex;
- if (registerIndex - mRenderer->getReservedVertexUniformBuffers() >= caps.maxVertexUniformBlocks)
- {
- infoLog.append("Vertex shader uniform block count exceed GL_MAX_VERTEX_UNIFORM_BLOCKS (%u)", caps.maxVertexUniformBlocks);
- return false;
- }
- }
- else if (shader == GL_FRAGMENT_SHADER)
- {
- uniformBlock->psRegisterIndex = registerIndex;
- if (registerIndex - mRenderer->getReservedFragmentUniformBuffers() >= caps.maxFragmentUniformBlocks)
- {
- infoLog.append("Fragment shader uniform block count exceed GL_MAX_FRAGMENT_UNIFORM_BLOCKS (%u)", caps.maxFragmentUniformBlocks);
- return false;
- }
- }
- else UNREACHABLE();
-
- return true;
-}
-
-void ProgramD3D::dirtyAllUniforms()
-{
- unsigned int numUniforms = mUniforms.size();
- for (unsigned int index = 0; index < numUniforms; index++)
- {
- mUniforms[index]->dirty = true;
- }
-}
-
-void ProgramD3D::setUniform1fv(GLint location, GLsizei count, const GLfloat* v)
-{
- setUniform(location, count, v, GL_FLOAT);
-}
-
-void ProgramD3D::setUniform2fv(GLint location, GLsizei count, const GLfloat *v)
-{
- setUniform(location, count, v, GL_FLOAT_VEC2);
-}
-
-void ProgramD3D::setUniform3fv(GLint location, GLsizei count, const GLfloat *v)
-{
- setUniform(location, count, v, GL_FLOAT_VEC3);
-}
-
-void ProgramD3D::setUniform4fv(GLint location, GLsizei count, const GLfloat *v)
-{
- setUniform(location, count, v, GL_FLOAT_VEC4);
-}
-
-void ProgramD3D::setUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
- setUniformMatrixfv<2, 2>(location, count, transpose, value, GL_FLOAT_MAT2);
-}
-
-void ProgramD3D::setUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
- setUniformMatrixfv<3, 3>(location, count, transpose, value, GL_FLOAT_MAT3);
-}
-
-void ProgramD3D::setUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
- setUniformMatrixfv<4, 4>(location, count, transpose, value, GL_FLOAT_MAT4);
-}
-
-void ProgramD3D::setUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
- setUniformMatrixfv<2, 3>(location, count, transpose, value, GL_FLOAT_MAT2x3);
-}
-
-void ProgramD3D::setUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
- setUniformMatrixfv<3, 2>(location, count, transpose, value, GL_FLOAT_MAT3x2);
-}
-
-void ProgramD3D::setUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
- setUniformMatrixfv<2, 4>(location, count, transpose, value, GL_FLOAT_MAT2x4);
-}
-
-void ProgramD3D::setUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
- setUniformMatrixfv<4, 2>(location, count, transpose, value, GL_FLOAT_MAT4x2);
-}
-
-void ProgramD3D::setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
- setUniformMatrixfv<3, 4>(location, count, transpose, value, GL_FLOAT_MAT3x4);
-}
-
-void ProgramD3D::setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
- setUniformMatrixfv<4, 3>(location, count, transpose, value, GL_FLOAT_MAT4x3);
-}
-
-void ProgramD3D::setUniform1iv(GLint location, GLsizei count, const GLint *v)
-{
- setUniform(location, count, v, GL_INT);
-}
-
-void ProgramD3D::setUniform2iv(GLint location, GLsizei count, const GLint *v)
-{
- setUniform(location, count, v, GL_INT_VEC2);
-}
-
-void ProgramD3D::setUniform3iv(GLint location, GLsizei count, const GLint *v)
-{
- setUniform(location, count, v, GL_INT_VEC3);
-}
-
-void ProgramD3D::setUniform4iv(GLint location, GLsizei count, const GLint *v)
-{
- setUniform(location, count, v, GL_INT_VEC4);
-}
-
-void ProgramD3D::setUniform1uiv(GLint location, GLsizei count, const GLuint *v)
-{
- setUniform(location, count, v, GL_UNSIGNED_INT);
-}
-
-void ProgramD3D::setUniform2uiv(GLint location, GLsizei count, const GLuint *v)
-{
- setUniform(location, count, v, GL_UNSIGNED_INT_VEC2);
-}
-
-void ProgramD3D::setUniform3uiv(GLint location, GLsizei count, const GLuint *v)
-{
- setUniform(location, count, v, GL_UNSIGNED_INT_VEC3);
-}
-
-void ProgramD3D::setUniform4uiv(GLint location, GLsizei count, const GLuint *v)
-{
- setUniform(location, count, v, GL_UNSIGNED_INT_VEC4);
-}
-
-void ProgramD3D::getUniformfv(GLint location, GLfloat *params)
-{
- getUniformv(location, params, GL_FLOAT);
-}
-
-void ProgramD3D::getUniformiv(GLint location, GLint *params)
-{
- getUniformv(location, params, GL_INT);
-}
-
-void ProgramD3D::getUniformuiv(GLint location, GLuint *params)
-{
- getUniformv(location, params, GL_UNSIGNED_INT);
-}
-
-bool ProgramD3D::linkUniforms(gl::InfoLog &infoLog, const gl::Shader &vertexShader, const gl::Shader &fragmentShader,
- const gl::Caps &caps)
-{
- const ShaderD3D *vertexShaderD3D = ShaderD3D::makeShaderD3D(vertexShader.getImplementation());
- const ShaderD3D *fragmentShaderD3D = ShaderD3D::makeShaderD3D(fragmentShader.getImplementation());
-
- const std::vector<sh::Uniform> &vertexUniforms = vertexShader.getUniforms();
- const std::vector<sh::Uniform> &fragmentUniforms = fragmentShader.getUniforms();
-
- // Check that uniforms defined in the vertex and fragment shaders are identical
- typedef std::map<std::string, const sh::Uniform*> UniformMap;
- UniformMap linkedUniforms;
-
- for (unsigned int vertexUniformIndex = 0; vertexUniformIndex < vertexUniforms.size(); vertexUniformIndex++)
- {
- const sh::Uniform &vertexUniform = vertexUniforms[vertexUniformIndex];
- linkedUniforms[vertexUniform.name] = &vertexUniform;
- }
-
- for (unsigned int fragmentUniformIndex = 0; fragmentUniformIndex < fragmentUniforms.size(); fragmentUniformIndex++)
- {
- const sh::Uniform &fragmentUniform = fragmentUniforms[fragmentUniformIndex];
- UniformMap::const_iterator entry = linkedUniforms.find(fragmentUniform.name);
- if (entry != linkedUniforms.end())
- {
- const sh::Uniform &vertexUniform = *entry->second;
- const std::string &uniformName = "uniform '" + vertexUniform.name + "'";
- if (!gl::ProgramBinary::linkValidateUniforms(infoLog, uniformName, vertexUniform, fragmentUniform))
- {
- return false;
- }
- }
- }
-
- for (unsigned int uniformIndex = 0; uniformIndex < vertexUniforms.size(); uniformIndex++)
- {
- const sh::Uniform &uniform = vertexUniforms[uniformIndex];
-
- if (uniform.staticUse)
- {
- defineUniformBase(GL_VERTEX_SHADER, uniform, vertexShaderD3D->getUniformRegister(uniform.name));
- }
- }
-
- for (unsigned int uniformIndex = 0; uniformIndex < fragmentUniforms.size(); uniformIndex++)
- {
- const sh::Uniform &uniform = fragmentUniforms[uniformIndex];
-
- if (uniform.staticUse)
- {
- defineUniformBase(GL_FRAGMENT_SHADER, uniform, fragmentShaderD3D->getUniformRegister(uniform.name));
- }
- }
-
- if (!indexUniforms(infoLog, caps))
- {
- return false;
- }
-
- initializeUniformStorage();
-
- // special case for gl_DepthRange, the only built-in uniform (also a struct)
- if (vertexShaderD3D->usesDepthRange() || fragmentShaderD3D->usesDepthRange())
- {
- const sh::BlockMemberInfo &defaultInfo = sh::BlockMemberInfo::getDefaultBlockInfo();
-
- mUniforms.push_back(new gl::LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.near", 0, -1, defaultInfo));
- mUniforms.push_back(new gl::LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.far", 0, -1, defaultInfo));
- mUniforms.push_back(new gl::LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.diff", 0, -1, defaultInfo));
- }
-
- return true;
-}
-
-void ProgramD3D::defineUniformBase(GLenum shader, const sh::Uniform &uniform, unsigned int uniformRegister)
-{
- ShShaderOutput outputType = ShaderD3D::getCompilerOutputType(shader);
- sh::HLSLBlockEncoder encoder(sh::HLSLBlockEncoder::GetStrategyFor(outputType));
- encoder.skipRegisters(uniformRegister);
-
- defineUniform(shader, uniform, uniform.name, &encoder);
-}
-
-void ProgramD3D::defineUniform(GLenum shader, const sh::ShaderVariable &uniform,
- const std::string &fullName, sh::HLSLBlockEncoder *encoder)
-{
- if (uniform.isStruct())
- {
- for (unsigned int elementIndex = 0; elementIndex < uniform.elementCount(); elementIndex++)
- {
- const std::string &elementString = (uniform.isArray() ? ArrayString(elementIndex) : "");
-
- encoder->enterAggregateType();
-
- for (size_t fieldIndex = 0; fieldIndex < uniform.fields.size(); fieldIndex++)
- {
- const sh::ShaderVariable &field = uniform.fields[fieldIndex];
- const std::string &fieldFullName = (fullName + elementString + "." + field.name);
-
- defineUniform(shader, field, fieldFullName, encoder);
- }
-
- encoder->exitAggregateType();
- }
- }
- else // Not a struct
- {
- // Arrays are treated as aggregate types
- if (uniform.isArray())
- {
- encoder->enterAggregateType();
- }
-
- gl::LinkedUniform *linkedUniform = getUniformByName(fullName);
-
- if (!linkedUniform)
- {
- linkedUniform = new gl::LinkedUniform(uniform.type, uniform.precision, fullName, uniform.arraySize,
- -1, sh::BlockMemberInfo::getDefaultBlockInfo());
- ASSERT(linkedUniform);
- linkedUniform->registerElement = encoder->getCurrentElement();
- mUniforms.push_back(linkedUniform);
- }
-
- ASSERT(linkedUniform->registerElement == encoder->getCurrentElement());
-
- if (shader == GL_FRAGMENT_SHADER)
- {
- linkedUniform->psRegisterIndex = encoder->getCurrentRegister();
- }
- else if (shader == GL_VERTEX_SHADER)
- {
- linkedUniform->vsRegisterIndex = encoder->getCurrentRegister();
- }
- else UNREACHABLE();
-
- // Advance the uniform offset, to track registers allocation for structs
- encoder->encodeType(uniform.type, uniform.arraySize, false);
-
- // Arrays are treated as aggregate types
- if (uniform.isArray())
- {
- encoder->exitAggregateType();
- }
- }
-}
-
-template <typename T>
-static inline void SetIfDirty(T *dest, const T& source, bool *dirtyFlag)
-{
- ASSERT(dest != NULL);
- ASSERT(dirtyFlag != NULL);
-
- *dirtyFlag = *dirtyFlag || (memcmp(dest, &source, sizeof(T)) != 0);
- *dest = source;
-}
-
-template <typename T>
-void ProgramD3D::setUniform(GLint location, GLsizei count, const T* v, GLenum targetUniformType)
-{
- const int components = gl::VariableComponentCount(targetUniformType);
- const GLenum targetBoolType = gl::VariableBoolVectorType(targetUniformType);
-
- gl::LinkedUniform *targetUniform = getUniformByLocation(location);
-
- int elementCount = targetUniform->elementCount();
-
- count = std::min(elementCount - (int)mUniformIndex[location].element, count);
-
- if (targetUniform->type == targetUniformType)
- {
- T *target = reinterpret_cast<T*>(targetUniform->data) + mUniformIndex[location].element * 4;
-
- for (int i = 0; i < count; i++)
- {
- T *dest = target + (i * 4);
- const T *source = v + (i * components);
-
- for (int c = 0; c < components; c++)
- {
- SetIfDirty(dest + c, source[c], &targetUniform->dirty);
- }
- for (int c = components; c < 4; c++)
- {
- SetIfDirty(dest + c, T(0), &targetUniform->dirty);
- }
- }
- }
- else if (targetUniform->type == targetBoolType)
- {
- GLint *boolParams = reinterpret_cast<GLint*>(targetUniform->data) + mUniformIndex[location].element * 4;
-
- for (int i = 0; i < count; i++)
- {
- GLint *dest = boolParams + (i * 4);
- const T *source = v + (i * components);
-
- for (int c = 0; c < components; c++)
- {
- SetIfDirty(dest + c, (source[c] == static_cast<T>(0)) ? GL_FALSE : GL_TRUE, &targetUniform->dirty);
- }
- for (int c = components; c < 4; c++)
- {
- SetIfDirty(dest + c, GL_FALSE, &targetUniform->dirty);
- }
- }
- }
- else if (gl::IsSampler(targetUniform->type))
- {
- ASSERT(targetUniformType == GL_INT);
-
- GLint *target = reinterpret_cast<GLint*>(targetUniform->data) + mUniformIndex[location].element * 4;
-
- bool wasDirty = targetUniform->dirty;
-
- for (int i = 0; i < count; i++)
- {
- GLint *dest = target + (i * 4);
- const GLint *source = reinterpret_cast<const GLint*>(v) + (i * components);
-
- SetIfDirty(dest + 0, source[0], &targetUniform->dirty);
- SetIfDirty(dest + 1, 0, &targetUniform->dirty);
- SetIfDirty(dest + 2, 0, &targetUniform->dirty);
- SetIfDirty(dest + 3, 0, &targetUniform->dirty);
- }
-
- if (!wasDirty && targetUniform->dirty)
- {
- mDirtySamplerMapping = true;
- }
- }
- else UNREACHABLE();
-}
-
-template<typename T>
-bool transposeMatrix(T *target, const GLfloat *value, int targetWidth, int targetHeight, int srcWidth, int srcHeight)
-{
- bool dirty = false;
- int copyWidth = std::min(targetHeight, srcWidth);
- int copyHeight = std::min(targetWidth, srcHeight);
-
- for (int x = 0; x < copyWidth; x++)
- {
- for (int y = 0; y < copyHeight; y++)
- {
- SetIfDirty(target + (x * targetWidth + y), static_cast<T>(value[y * srcWidth + x]), &dirty);
- }
- }
- // clear unfilled right side
- for (int y = 0; y < copyWidth; y++)
- {
- for (int x = copyHeight; x < targetWidth; x++)
- {
- SetIfDirty(target + (y * targetWidth + x), static_cast<T>(0), &dirty);
- }
- }
- // clear unfilled bottom.
- for (int y = copyWidth; y < targetHeight; y++)
- {
- for (int x = 0; x < targetWidth; x++)
- {
- SetIfDirty(target + (y * targetWidth + x), static_cast<T>(0), &dirty);
- }
- }
-
- return dirty;
-}
-
-template<typename T>
-bool expandMatrix(T *target, const GLfloat *value, int targetWidth, int targetHeight, int srcWidth, int srcHeight)
-{
- bool dirty = false;
- int copyWidth = std::min(targetWidth, srcWidth);
- int copyHeight = std::min(targetHeight, srcHeight);
-
- for (int y = 0; y < copyHeight; y++)
- {
- for (int x = 0; x < copyWidth; x++)
- {
- SetIfDirty(target + (y * targetWidth + x), static_cast<T>(value[y * srcWidth + x]), &dirty);
- }
- }
- // clear unfilled right side
- for (int y = 0; y < copyHeight; y++)
- {
- for (int x = copyWidth; x < targetWidth; x++)
- {
- SetIfDirty(target + (y * targetWidth + x), static_cast<T>(0), &dirty);
- }
- }
- // clear unfilled bottom.
- for (int y = copyHeight; y < targetHeight; y++)
- {
- for (int x = 0; x < targetWidth; x++)
- {
- SetIfDirty(target + (y * targetWidth + x), static_cast<T>(0), &dirty);
- }
- }
-
- return dirty;
-}
-
-template <int cols, int rows>
-void ProgramD3D::setUniformMatrixfv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value, GLenum targetUniformType)
-{
- gl::LinkedUniform *targetUniform = getUniformByLocation(location);
-
- int elementCount = targetUniform->elementCount();
-
- count = std::min(elementCount - (int)mUniformIndex[location].element, count);
- const unsigned int targetMatrixStride = (4 * rows);
- GLfloat *target = (GLfloat*)(targetUniform->data + mUniformIndex[location].element * sizeof(GLfloat) * targetMatrixStride);
-
- for (int i = 0; i < count; i++)
- {
- // Internally store matrices as transposed versions to accomodate HLSL matrix indexing
- if (transpose == GL_FALSE)
- {
- targetUniform->dirty = transposeMatrix<GLfloat>(target, value, 4, rows, rows, cols) || targetUniform->dirty;
- }
- else
- {
- targetUniform->dirty = expandMatrix<GLfloat>(target, value, 4, rows, cols, rows) || targetUniform->dirty;
- }
- target += targetMatrixStride;
- value += cols * rows;
- }
-}
-
-template <typename T>
-void ProgramD3D::getUniformv(GLint location, T *params, GLenum uniformType)
-{
- gl::LinkedUniform *targetUniform = mUniforms[mUniformIndex[location].index];
-
- if (gl::IsMatrixType(targetUniform->type))
- {
- const int rows = gl::VariableRowCount(targetUniform->type);
- const int cols = gl::VariableColumnCount(targetUniform->type);
- transposeMatrix(params, (GLfloat*)targetUniform->data + mUniformIndex[location].element * 4 * rows, rows, cols, 4, rows);
- }
- else if (uniformType == gl::VariableComponentType(targetUniform->type))
- {
- unsigned int size = gl::VariableComponentCount(targetUniform->type);
- memcpy(params, targetUniform->data + mUniformIndex[location].element * 4 * sizeof(T),
- size * sizeof(T));
- }
- else
- {
- unsigned int size = gl::VariableComponentCount(targetUniform->type);
- switch (gl::VariableComponentType(targetUniform->type))
- {
- case GL_BOOL:
- {
- GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
-
- for (unsigned int i = 0; i < size; i++)
- {
- params[i] = (boolParams[i] == GL_FALSE) ? static_cast<T>(0) : static_cast<T>(1);
- }
- }
- break;
-
- case GL_FLOAT:
- {
- GLfloat *floatParams = (GLfloat*)targetUniform->data + mUniformIndex[location].element * 4;
-
- for (unsigned int i = 0; i < size; i++)
- {
- params[i] = static_cast<T>(floatParams[i]);
- }
- }
- break;
-
- case GL_INT:
- {
- GLint *intParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
-
- for (unsigned int i = 0; i < size; i++)
- {
- params[i] = static_cast<T>(intParams[i]);
- }
- }
- break;
-
- case GL_UNSIGNED_INT:
- {
- GLuint *uintParams = (GLuint*)targetUniform->data + mUniformIndex[location].element * 4;
-
- for (unsigned int i = 0; i < size; i++)
- {
- params[i] = static_cast<T>(uintParams[i]);
- }
- }
- break;
-
- default: UNREACHABLE();
- }
- }
-}
-
-template <typename VarT>
-void ProgramD3D::defineUniformBlockMembers(const std::vector<VarT> &fields, const std::string &prefix, int blockIndex,
- sh::BlockLayoutEncoder *encoder, std::vector<unsigned int> *blockUniformIndexes,
- bool inRowMajorLayout)
-{
- for (unsigned int uniformIndex = 0; uniformIndex < fields.size(); uniformIndex++)
- {
- const VarT &field = fields[uniformIndex];
- const std::string &fieldName = (prefix.empty() ? field.name : prefix + "." + field.name);
-
- if (field.isStruct())
- {
- bool rowMajorLayout = (inRowMajorLayout || IsRowMajorLayout(field));
-
- for (unsigned int arrayElement = 0; arrayElement < field.elementCount(); arrayElement++)
- {
- encoder->enterAggregateType();
-
- const std::string uniformElementName = fieldName + (field.isArray() ? ArrayString(arrayElement) : "");
- defineUniformBlockMembers(field.fields, uniformElementName, blockIndex, encoder, blockUniformIndexes, rowMajorLayout);
-
- encoder->exitAggregateType();
- }
- }
- else
- {
- bool isRowMajorMatrix = (gl::IsMatrixType(field.type) && inRowMajorLayout);
-
- sh::BlockMemberInfo memberInfo = encoder->encodeType(field.type, field.arraySize, isRowMajorMatrix);
-
- gl::LinkedUniform *newUniform = new gl::LinkedUniform(field.type, field.precision, fieldName, field.arraySize,
- blockIndex, memberInfo);
-
- // add to uniform list, but not index, since uniform block uniforms have no location
- blockUniformIndexes->push_back(mUniforms.size());
- mUniforms.push_back(newUniform);
- }
- }
-}
-
-bool ProgramD3D::defineUniformBlock(gl::InfoLog &infoLog, const gl::Shader &shader, const sh::InterfaceBlock &interfaceBlock,
- const gl::Caps &caps)
-{
- const ShaderD3D* shaderD3D = ShaderD3D::makeShaderD3D(shader.getImplementation());
-
- // create uniform block entries if they do not exist
- if (getUniformBlockIndex(interfaceBlock.name) == GL_INVALID_INDEX)
- {
- std::vector<unsigned int> blockUniformIndexes;
- const unsigned int blockIndex = mUniformBlocks.size();
-
- // define member uniforms
- sh::BlockLayoutEncoder *encoder = NULL;
-
- if (interfaceBlock.layout == sh::BLOCKLAYOUT_STANDARD)
- {
- encoder = new sh::Std140BlockEncoder;
- }
- else
- {
- encoder = new sh::HLSLBlockEncoder(sh::HLSLBlockEncoder::ENCODE_PACKED);
- }
- ASSERT(encoder);
-
- defineUniformBlockMembers(interfaceBlock.fields, "", blockIndex, encoder, &blockUniformIndexes, interfaceBlock.isRowMajorLayout);
-
- size_t dataSize = encoder->getBlockSize();
-
- // create all the uniform blocks
- if (interfaceBlock.arraySize > 0)
- {
- for (unsigned int uniformBlockElement = 0; uniformBlockElement < interfaceBlock.arraySize; uniformBlockElement++)
- {
- gl::UniformBlock *newUniformBlock = new gl::UniformBlock(interfaceBlock.name, uniformBlockElement, dataSize);
- newUniformBlock->memberUniformIndexes = blockUniformIndexes;
- mUniformBlocks.push_back(newUniformBlock);
- }
- }
- else
- {
- gl::UniformBlock *newUniformBlock = new gl::UniformBlock(interfaceBlock.name, GL_INVALID_INDEX, dataSize);
- newUniformBlock->memberUniformIndexes = blockUniformIndexes;
- mUniformBlocks.push_back(newUniformBlock);
- }
- }
-
- if (interfaceBlock.staticUse)
- {
- // Assign registers to the uniform blocks
- const GLuint blockIndex = getUniformBlockIndex(interfaceBlock.name);
- const unsigned int elementCount = std::max(1u, interfaceBlock.arraySize);
- ASSERT(blockIndex != GL_INVALID_INDEX);
- ASSERT(blockIndex + elementCount <= mUniformBlocks.size());
-
- unsigned int interfaceBlockRegister = shaderD3D->getInterfaceBlockRegister(interfaceBlock.name);
-
- for (unsigned int uniformBlockElement = 0; uniformBlockElement < elementCount; uniformBlockElement++)
- {
- gl::UniformBlock *uniformBlock = mUniformBlocks[blockIndex + uniformBlockElement];
- ASSERT(uniformBlock->name == interfaceBlock.name);
-
- if (!assignUniformBlockRegister(infoLog, uniformBlock, shader.getType(),
- interfaceBlockRegister + uniformBlockElement, caps))
- {
- return false;
- }
- }
- }
-
- return true;
-}
-
-bool ProgramD3D::assignSamplers(unsigned int startSamplerIndex,
- GLenum samplerType,
- unsigned int samplerCount,
- std::vector<Sampler> &outSamplers,
- GLuint *outUsedRange)
-{
- unsigned int samplerIndex = startSamplerIndex;
-
- do
- {
- if (samplerIndex < outSamplers.size())
- {
- Sampler& sampler = outSamplers[samplerIndex];
- sampler.active = true;
- sampler.textureType = GetTextureType(samplerType);
- sampler.logicalTextureUnit = 0;
- *outUsedRange = std::max(samplerIndex + 1, *outUsedRange);
- }
- else
- {
- return false;
- }
-
- samplerIndex++;
- } while (samplerIndex < startSamplerIndex + samplerCount);
-
- return true;
-}
-
-bool ProgramD3D::indexSamplerUniform(const gl::LinkedUniform &uniform, gl::InfoLog &infoLog, const gl::Caps &caps)
-{
- ASSERT(gl::IsSampler(uniform.type));
- ASSERT(uniform.vsRegisterIndex != GL_INVALID_INDEX || uniform.psRegisterIndex != GL_INVALID_INDEX);
-
- if (uniform.vsRegisterIndex != GL_INVALID_INDEX)
- {
- if (!assignSamplers(uniform.vsRegisterIndex, uniform.type, uniform.arraySize, mSamplersVS,
- &mUsedVertexSamplerRange))
- {
- infoLog.append("Vertex shader sampler count exceeds the maximum vertex texture units (%d).",
- mSamplersVS.size());
- return false;
- }
-
- unsigned int maxVertexVectors = mRenderer->getReservedVertexUniformVectors() + caps.maxVertexUniformVectors;
- if (uniform.vsRegisterIndex + uniform.registerCount > maxVertexVectors)
- {
- infoLog.append("Vertex shader active uniforms exceed GL_MAX_VERTEX_UNIFORM_VECTORS (%u)",
- caps.maxVertexUniformVectors);
- return false;
- }
- }
-
- if (uniform.psRegisterIndex != GL_INVALID_INDEX)
- {
- if (!assignSamplers(uniform.psRegisterIndex, uniform.type, uniform.arraySize, mSamplersPS,
- &mUsedPixelSamplerRange))
- {
- infoLog.append("Pixel shader sampler count exceeds MAX_TEXTURE_IMAGE_UNITS (%d).",
- mSamplersPS.size());
- return false;
- }
-
- unsigned int maxFragmentVectors = mRenderer->getReservedFragmentUniformVectors() + caps.maxFragmentUniformVectors;
- if (uniform.psRegisterIndex + uniform.registerCount > maxFragmentVectors)
- {
- infoLog.append("Fragment shader active uniforms exceed GL_MAX_FRAGMENT_UNIFORM_VECTORS (%u)",
- caps.maxFragmentUniformVectors);
- return false;
- }
- }
-
- return true;
-}
-
-bool ProgramD3D::indexUniforms(gl::InfoLog &infoLog, const gl::Caps &caps)
-{
- for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); uniformIndex++)
- {
- const gl::LinkedUniform &uniform = *mUniforms[uniformIndex];
-
- if (gl::IsSampler(uniform.type))
- {
- if (!indexSamplerUniform(uniform, infoLog, caps))
- {
- return false;
- }
- }
-
- for (unsigned int arrayElementIndex = 0; arrayElementIndex < uniform.elementCount(); arrayElementIndex++)
- {
- mUniformIndex.push_back(gl::VariableLocation(uniform.name, arrayElementIndex, uniformIndex));
- }
- }
-
- return true;
-}
-
-void ProgramD3D::reset()
-{
- ProgramImpl::reset();
-
- SafeDeleteContainer(mVertexExecutables);
- SafeDeleteContainer(mPixelExecutables);
- SafeDelete(mGeometryExecutable);
-
- mTransformFeedbackBufferMode = GL_NONE;
-
- mVertexHLSL.clear();
- mVertexWorkarounds = ANGLE_D3D_WORKAROUND_NONE;
- mShaderVersion = 100;
-
- mPixelHLSL.clear();
- mPixelWorkarounds = ANGLE_D3D_WORKAROUND_NONE;
- mUsesFragDepth = false;
- mPixelShaderKey.clear();
- mUsesPointSize = false;
-
- SafeDelete(mVertexUniformStorage);
- SafeDelete(mFragmentUniformStorage);
-
- mSamplersPS.clear();
- mSamplersVS.clear();
-
- mUsedVertexSamplerRange = 0;
- mUsedPixelSamplerRange = 0;
- mDirtySamplerMapping = true;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ProgramD3D.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ProgramD3D.h
deleted file mode 100644
index 4baab9aa19..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ProgramD3D.h
+++ /dev/null
@@ -1,219 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// ProgramD3D.h: Defines the rx::ProgramD3D class which implements rx::ProgramImpl.
-
-#ifndef LIBGLESV2_RENDERER_PROGRAMD3D_H_
-#define LIBGLESV2_RENDERER_PROGRAMD3D_H_
-
-#include "libGLESv2/renderer/ProgramImpl.h"
-#include "libGLESv2/renderer/Workarounds.h"
-
-#include <string>
-#include <vector>
-
-namespace gl
-{
-struct LinkedUniform;
-struct VariableLocation;
-struct VertexFormat;
-}
-
-namespace rx
-{
-class RendererD3D;
-class UniformStorage;
-
-class ProgramD3D : public ProgramImpl
-{
- public:
- ProgramD3D(RendererD3D *renderer);
- virtual ~ProgramD3D();
-
- static ProgramD3D *makeProgramD3D(ProgramImpl *impl);
- static const ProgramD3D *makeProgramD3D(const ProgramImpl *impl);
-
- const std::vector<PixelShaderOutputVariable> &getPixelShaderKey() { return mPixelShaderKey; }
- int getShaderVersion() const { return mShaderVersion; }
- GLenum getTransformFeedbackBufferMode() const { return mTransformFeedbackBufferMode; }
-
- GLint getSamplerMapping(gl::SamplerType type, unsigned int samplerIndex, const gl::Caps &caps) const;
- GLenum getSamplerTextureType(gl::SamplerType type, unsigned int samplerIndex) const;
- GLint getUsedSamplerRange(gl::SamplerType type) const;
- void updateSamplerMapping();
- bool validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps);
-
- bool usesPointSize() const { return mUsesPointSize; }
- bool usesPointSpriteEmulation() const;
- bool usesGeometryShader() const;
-
- GLenum getBinaryFormat() { return GL_PROGRAM_BINARY_ANGLE; }
- gl::LinkResult load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream);
- gl::Error save(gl::BinaryOutputStream *stream);
-
- gl::Error getPixelExecutableForFramebuffer(const gl::Framebuffer *fbo, ShaderExecutable **outExectuable);
- gl::Error getPixelExecutableForOutputLayout(const std::vector<GLenum> &outputLayout, ShaderExecutable **outExectuable);
- gl::Error getVertexExecutableForInputLayout(const gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS], ShaderExecutable **outExectuable);
- ShaderExecutable *getGeometryExecutable() const { return mGeometryExecutable; }
-
- gl::LinkResult compileProgramExecutables(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader,
- int registers);
-
- gl::LinkResult link(const gl::Data &data, gl::InfoLog &infoLog,
- gl::Shader *fragmentShader, gl::Shader *vertexShader,
- const std::vector<std::string> &transformFeedbackVaryings,
- GLenum transformFeedbackBufferMode,
- int *registers, std::vector<gl::LinkedVarying> *linkedVaryings,
- std::map<int, gl::VariableLocation> *outputVariables);
-
- void getInputLayoutSignature(const gl::VertexFormat inputLayout[], GLenum signature[]) const;
-
- void initializeUniformStorage();
- gl::Error applyUniforms();
- gl::Error applyUniformBuffers(const std::vector<gl::Buffer*> boundBuffers, const gl::Caps &caps);
- bool assignUniformBlockRegister(gl::InfoLog &infoLog, gl::UniformBlock *uniformBlock, GLenum shader,
- unsigned int registerIndex, const gl::Caps &caps);
- void dirtyAllUniforms();
-
- void setUniform1fv(GLint location, GLsizei count, const GLfloat *v);
- void setUniform2fv(GLint location, GLsizei count, const GLfloat *v);
- void setUniform3fv(GLint location, GLsizei count, const GLfloat *v);
- void setUniform4fv(GLint location, GLsizei count, const GLfloat *v);
- void setUniform1iv(GLint location, GLsizei count, const GLint *v);
- void setUniform2iv(GLint location, GLsizei count, const GLint *v);
- void setUniform3iv(GLint location, GLsizei count, const GLint *v);
- void setUniform4iv(GLint location, GLsizei count, const GLint *v);
- void setUniform1uiv(GLint location, GLsizei count, const GLuint *v);
- void setUniform2uiv(GLint location, GLsizei count, const GLuint *v);
- void setUniform3uiv(GLint location, GLsizei count, const GLuint *v);
- void setUniform4uiv(GLint location, GLsizei count, const GLuint *v);
- void setUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- void setUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- void setUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- void setUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- void setUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- void setUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- void setUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- void setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- void setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-
- void getUniformfv(GLint location, GLfloat *params);
- void getUniformiv(GLint location, GLint *params);
- void getUniformuiv(GLint location, GLuint *params);
-
- const UniformStorage &getVertexUniformStorage() const { return *mVertexUniformStorage; }
- const UniformStorage &getFragmentUniformStorage() const { return *mFragmentUniformStorage; }
-
- bool linkUniforms(gl::InfoLog &infoLog, const gl::Shader &vertexShader, const gl::Shader &fragmentShader,
- const gl::Caps &caps);
- bool defineUniformBlock(gl::InfoLog &infoLog, const gl::Shader &shader, const sh::InterfaceBlock &interfaceBlock, const gl::Caps &caps);
-
- void reset();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ProgramD3D);
-
- class VertexExecutable
- {
- public:
- VertexExecutable(const gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS],
- const GLenum signature[gl::MAX_VERTEX_ATTRIBS],
- ShaderExecutable *shaderExecutable);
- ~VertexExecutable();
-
- bool matchesSignature(const GLenum convertedLayout[gl::MAX_VERTEX_ATTRIBS]) const;
-
- const gl::VertexFormat *inputs() const { return mInputs; }
- const GLenum *signature() const { return mSignature; }
- ShaderExecutable *shaderExecutable() const { return mShaderExecutable; }
-
- private:
- gl::VertexFormat mInputs[gl::MAX_VERTEX_ATTRIBS];
- GLenum mSignature[gl::MAX_VERTEX_ATTRIBS];
- ShaderExecutable *mShaderExecutable;
- };
-
- class PixelExecutable
- {
- public:
- PixelExecutable(const std::vector<GLenum> &outputSignature, ShaderExecutable *shaderExecutable);
- ~PixelExecutable();
-
- bool matchesSignature(const std::vector<GLenum> &signature) const { return mOutputSignature == signature; }
-
- const std::vector<GLenum> &outputSignature() const { return mOutputSignature; }
- ShaderExecutable *shaderExecutable() const { return mShaderExecutable; }
-
- private:
- std::vector<GLenum> mOutputSignature;
- ShaderExecutable *mShaderExecutable;
- };
-
- struct Sampler
- {
- Sampler();
-
- bool active;
- GLint logicalTextureUnit;
- GLenum textureType;
- };
-
- void defineUniformBase(GLenum shader, const sh::Uniform &uniform, unsigned int uniformRegister);
- void defineUniform(GLenum shader, const sh::ShaderVariable &uniform, const std::string &fullName,
- sh::HLSLBlockEncoder *encoder);
- bool indexSamplerUniform(const gl::LinkedUniform &uniform, gl::InfoLog &infoLog, const gl::Caps &caps);
- bool indexUniforms(gl::InfoLog &infoLog, const gl::Caps &caps);
- static bool assignSamplers(unsigned int startSamplerIndex, GLenum samplerType, unsigned int samplerCount,
- std::vector<Sampler> &outSamplers, GLuint *outUsedRange);
-
- template <typename T>
- void setUniform(GLint location, GLsizei count, const T* v, GLenum targetUniformType);
-
- template <int cols, int rows>
- void setUniformMatrixfv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value, GLenum targetUniformType);
-
- template <typename T>
- void getUniformv(GLint location, T *params, GLenum uniformType);
-
- template <typename VarT>
- void defineUniformBlockMembers(const std::vector<VarT> &fields, const std::string &prefix, int blockIndex,
- sh::BlockLayoutEncoder *encoder, std::vector<unsigned int> *blockUniformIndexes,
- bool inRowMajorLayout);
-
- RendererD3D *mRenderer;
- DynamicHLSL *mDynamicHLSL;
-
- std::vector<VertexExecutable *> mVertexExecutables;
- std::vector<PixelExecutable *> mPixelExecutables;
- ShaderExecutable *mGeometryExecutable;
-
- std::string mVertexHLSL;
- D3DWorkaroundType mVertexWorkarounds;
-
- std::string mPixelHLSL;
- D3DWorkaroundType mPixelWorkarounds;
- bool mUsesFragDepth;
- std::vector<PixelShaderOutputVariable> mPixelShaderKey;
-
- bool mUsesPointSize;
-
- UniformStorage *mVertexUniformStorage;
- UniformStorage *mFragmentUniformStorage;
-
- GLenum mTransformFeedbackBufferMode;
-
- std::vector<Sampler> mSamplersPS;
- std::vector<Sampler> mSamplersVS;
- GLuint mUsedVertexSamplerRange;
- GLuint mUsedPixelSamplerRange;
- bool mDirtySamplerMapping;
-
- int mShaderVersion;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_PROGRAMD3D_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/RenderbufferD3D.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/RenderbufferD3D.cpp
deleted file mode 100644
index cb4af367a2..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/RenderbufferD3D.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// RenderbufferD3d.cpp: Implements the RenderbufferD3D class, a specialization of RenderbufferImpl
-
-
-#include "libGLESv2/renderer/d3d/RenderbufferD3D.h"
-
-#include "libGLESv2/renderer/d3d/RendererD3D.h"
-#include "libGLESv2/renderer/RenderTarget.h"
-
-namespace rx
-{
-RenderbufferD3D::RenderbufferD3D(RendererD3D *renderer) : mRenderer(renderer)
-{
- mRenderTarget = NULL;
-}
-
-RenderbufferD3D::~RenderbufferD3D()
-{
- SafeDelete(mRenderTarget);
-}
-
-RenderbufferD3D *RenderbufferD3D::makeRenderbufferD3D(RenderbufferImpl *renderbuffer)
-{
- ASSERT(HAS_DYNAMIC_TYPE(RenderbufferD3D*, renderbuffer));
- return static_cast<RenderbufferD3D*>(renderbuffer);
-}
-
-gl::Error RenderbufferD3D::setStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples)
-{
- // If the renderbuffer parameters are queried, the calling function
- // will expect one of the valid renderbuffer formats for use in
- // glRenderbufferStorage, but we should create depth and stencil buffers
- // as DEPTH24_STENCIL8
- GLenum creationFormat = internalformat;
- if (internalformat == GL_DEPTH_COMPONENT16 || internalformat == GL_STENCIL_INDEX8)
- {
- creationFormat = GL_DEPTH24_STENCIL8_OES;
- }
-
- RenderTarget *newRT = NULL;
- gl::Error error = mRenderer->createRenderTarget(width, height, creationFormat, samples, &newRT);
- if (error.isError())
- {
- return error;
- }
-
- SafeDelete(mRenderTarget);
- mRenderTarget = newRT;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error RenderbufferD3D::setStorage(SwapChain *swapChain, bool depth)
-{
- RenderTarget *newRT = NULL;
- gl::Error error = mRenderer->createRenderTarget(swapChain, depth, &newRT);
- if (error.isError())
- {
- return error;
- }
-
- SafeDelete(mRenderTarget);
- mRenderTarget = newRT;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-GLsizei RenderbufferD3D::getWidth() const
-{
- return (mRenderTarget ? mRenderTarget->getWidth() : 0);
-}
-
-GLsizei RenderbufferD3D::getHeight() const
-{
- return (mRenderTarget ? mRenderTarget->getHeight() : 0);
-}
-
-GLenum RenderbufferD3D::getInternalFormat() const
-{
- return (mRenderTarget ? mRenderTarget->getInternalFormat() : GL_RGBA4);
-}
-
-GLenum RenderbufferD3D::getActualFormat() const
-{
- return (mRenderTarget ? mRenderTarget->getActualFormat() : GL_RGBA4);
-}
-
-GLsizei RenderbufferD3D::getSamples() const
-{
- return (mRenderTarget ? mRenderTarget->getSamples() : 0);
-}
-
-RenderTarget *RenderbufferD3D::getRenderTarget()
-{
- return mRenderTarget;
-}
-
-unsigned int RenderbufferD3D::getRenderTargetSerial() const
-{
- return (mRenderTarget ? mRenderTarget->getSerial() : 0);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/RenderbufferD3D.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/RenderbufferD3D.h
deleted file mode 100644
index 9440a449f2..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/RenderbufferD3D.h
+++ /dev/null
@@ -1,51 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// RenderbufferD3d.h: Defines the RenderbufferD3D class which implements RenderbufferImpl.
-
-#ifndef LIBGLESV2_RENDERER_RENDERBUFFERD3D_H_
-#define LIBGLESV2_RENDERER_RENDERBUFFERD3D_H_
-
-#include "angle_gl.h"
-
-#include "common/angleutils.h"
-#include "libGLESv2/renderer/RenderbufferImpl.h"
-
-namespace rx
-{
-class RendererD3D;
-class RenderTarget;
-class SwapChain;
-
-class RenderbufferD3D : public RenderbufferImpl
-{
- public:
- RenderbufferD3D(RendererD3D *renderer);
- virtual ~RenderbufferD3D();
-
- static RenderbufferD3D *makeRenderbufferD3D(RenderbufferImpl *renderbuffer);
-
- virtual gl::Error setStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples) override;
- gl::Error setStorage(SwapChain *swapChain, bool depth);
-
- virtual GLsizei getWidth() const;
- virtual GLsizei getHeight() const;
- virtual GLenum getInternalFormat() const;
- virtual GLenum getActualFormat() const;
- virtual GLsizei getSamples() const;
-
- RenderTarget *getRenderTarget();
- unsigned int getRenderTargetSerial() const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(RenderbufferD3D);
-
- RendererD3D *mRenderer;
- RenderTarget *mRenderTarget;
-};
-}
-
-#endif // LIBGLESV2_RENDERER_RENDERBUFFERD3D_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/RendererD3D.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/RendererD3D.cpp
deleted file mode 100644
index 5cddd8ab5e..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/RendererD3D.cpp
+++ /dev/null
@@ -1,801 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// RendererD3D.cpp: Implementation of the base D3D Renderer.
-
-#include "libGLESv2/renderer/d3d/RendererD3D.h"
-
-#include "libGLESv2/renderer/d3d/IndexDataManager.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/FramebufferAttachment.h"
-#include "libGLESv2/ResourceManager.h"
-#include "libGLESv2/State.h"
-#include "libGLESv2/VertexArray.h"
-#include "libGLESv2/formatutils.h"
-#include "common/utilities.h"
-
-namespace rx
-{
-
-RendererD3D::RendererD3D(egl::Display *display)
- : mDisplay(display)
-{
-}
-
-RendererD3D::~RendererD3D()
-{
- cleanup();
-}
-
-void RendererD3D::cleanup()
-{
- for (gl::TextureMap::iterator i = mIncompleteTextures.begin(); i != mIncompleteTextures.end(); ++i)
- {
- i->second.set(NULL);
- }
- mIncompleteTextures.clear();
-}
-
-// static
-RendererD3D *RendererD3D::makeRendererD3D(Renderer *renderer)
-{
- ASSERT(HAS_DYNAMIC_TYPE(RendererD3D*, renderer));
- return static_cast<RendererD3D*>(renderer);
-}
-
-gl::Error RendererD3D::drawElements(const gl::Data &data,
- GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices, GLsizei instances,
- const RangeUI &indexRange)
-{
- ASSERT(data.state->getCurrentProgramId() != 0);
-
- gl::ProgramBinary *programBinary = data.state->getCurrentProgramBinary();
- programBinary->updateSamplerMapping();
-
- gl::Error error = generateSwizzles(data);
- if (error.isError())
- {
- return error;
- }
-
- if (!applyPrimitiveType(mode, count))
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- error = applyRenderTarget(data, mode, false);
- if (error.isError())
- {
- return error;
- }
-
- error = applyState(data, mode);
- if (error.isError())
- {
- return error;
- }
-
- gl::VertexArray *vao = data.state->getVertexArray();
- TranslatedIndexData indexInfo;
- indexInfo.indexRange = indexRange;
- error = applyIndexBuffer(indices, vao->getElementArrayBuffer(), count, mode, type, &indexInfo);
- if (error.isError())
- {
- return error;
- }
-
- GLsizei vertexCount = indexInfo.indexRange.length() + 1;
- error = applyVertexBuffer(*data.state, indexInfo.indexRange.start, vertexCount, instances);
- if (error.isError())
- {
- return error;
- }
-
- bool transformFeedbackActive = applyTransformFeedbackBuffers(data);
- // Transform feedback is not allowed for DrawElements, this error should have been caught at the API validation
- // layer.
- ASSERT(!transformFeedbackActive);
-
- error = applyShaders(data, transformFeedbackActive);
- if (error.isError())
- {
- return error;
- }
-
- error = applyTextures(data);
- if (error.isError())
- {
- return error;
- }
-
- error = applyUniformBuffers(data);
- if (error.isError())
- {
- return error;
- }
-
- if (!skipDraw(data, mode))
- {
- error = drawElements(mode, count, type, indices, vao->getElementArrayBuffer(), indexInfo, instances);
- if (error.isError())
- {
- return error;
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error RendererD3D::drawArrays(const gl::Data &data,
- GLenum mode, GLint first,
- GLsizei count, GLsizei instances)
-{
- ASSERT(data.state->getCurrentProgramId() != 0);
-
- gl::ProgramBinary *programBinary = data.state->getCurrentProgramBinary();
- programBinary->updateSamplerMapping();
-
- gl::Error error = generateSwizzles(data);
- if (error.isError())
- {
- return error;
- }
-
- if (!applyPrimitiveType(mode, count))
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- error = applyRenderTarget(data, mode, false);
- if (error.isError())
- {
- return error;
- }
-
- error = applyState(data, mode);
- if (error.isError())
- {
- return error;
- }
-
- error = applyVertexBuffer(*data.state, first, count, instances);
- if (error.isError())
- {
- return error;
- }
-
- bool transformFeedbackActive = applyTransformFeedbackBuffers(data);
-
- error = applyShaders(data, transformFeedbackActive);
- if (error.isError())
- {
- return error;
- }
-
- error = applyTextures(data);
- if (error.isError())
- {
- return error;
- }
-
- error = applyUniformBuffers(data);
- if (error.isError())
- {
- return error;
- }
-
- if (!skipDraw(data, mode))
- {
- error = drawArrays(mode, count, instances, transformFeedbackActive);
- if (error.isError())
- {
- return error;
- }
-
- if (transformFeedbackActive)
- {
- markTransformFeedbackUsage(data);
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error RendererD3D::generateSwizzles(const gl::Data &data, gl::SamplerType type)
-{
- gl::ProgramBinary *programBinary = data.state->getCurrentProgramBinary();
-
- size_t samplerRange = programBinary->getUsedSamplerRange(type);
-
- for (size_t i = 0; i < samplerRange; i++)
- {
- GLenum textureType = programBinary->getSamplerTextureType(type, i);
- GLint textureUnit = programBinary->getSamplerMapping(type, i, *data.caps);
- if (textureUnit != -1)
- {
- gl::Texture *texture = data.state->getSamplerTexture(textureUnit, textureType);
- ASSERT(texture);
- if (texture->getSamplerState().swizzleRequired())
- {
- gl::Error error = generateSwizzle(texture);
- if (error.isError())
- {
- return error;
- }
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error RendererD3D::generateSwizzles(const gl::Data &data)
-{
- gl::Error error = generateSwizzles(data, gl::SAMPLER_VERTEX);
- if (error.isError())
- {
- return error;
- }
-
- error = generateSwizzles(data, gl::SAMPLER_PIXEL);
- if (error.isError())
- {
- return error;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-// Applies the render target surface, depth stencil surface, viewport rectangle and
-// scissor rectangle to the renderer
-gl::Error RendererD3D::applyRenderTarget(const gl::Data &data, GLenum drawMode, bool ignoreViewport)
-{
- const gl::Framebuffer *framebufferObject = data.state->getDrawFramebuffer();
- ASSERT(framebufferObject && framebufferObject->completeness(data) == GL_FRAMEBUFFER_COMPLETE);
-
- gl::Error error = applyRenderTarget(framebufferObject);
- if (error.isError())
- {
- return error;
- }
-
- float nearZ, farZ;
- data.state->getDepthRange(&nearZ, &farZ);
- setViewport(data.state->getViewport(), nearZ, farZ, drawMode,
- data.state->getRasterizerState().frontFace, ignoreViewport);
-
- setScissorRectangle(data.state->getScissor(), data.state->isScissorTestEnabled());
-
- return gl::Error(GL_NO_ERROR);
-}
-
-// Applies the fixed-function state (culling, depth test, alpha blending, stenciling, etc) to the Direct3D device
-gl::Error RendererD3D::applyState(const gl::Data &data, GLenum drawMode)
-{
- const gl::Framebuffer *framebufferObject = data.state->getDrawFramebuffer();
- int samples = framebufferObject->getSamples(data);
-
- gl::RasterizerState rasterizer = data.state->getRasterizerState();
- rasterizer.pointDrawMode = (drawMode == GL_POINTS);
- rasterizer.multiSample = (samples != 0);
-
- gl::Error error = setRasterizerState(rasterizer);
- if (error.isError())
- {
- return error;
- }
-
- unsigned int mask = 0;
- if (data.state->isSampleCoverageEnabled())
- {
- GLclampf coverageValue;
- bool coverageInvert = false;
- data.state->getSampleCoverageParams(&coverageValue, &coverageInvert);
- if (coverageValue != 0)
- {
- float threshold = 0.5f;
-
- for (int i = 0; i < samples; ++i)
- {
- mask <<= 1;
-
- if ((i + 1) * coverageValue >= threshold)
- {
- threshold += 1.0f;
- mask |= 1;
- }
- }
- }
-
- if (coverageInvert)
- {
- mask = ~mask;
- }
- }
- else
- {
- mask = 0xFFFFFFFF;
- }
- error = setBlendState(framebufferObject, data.state->getBlendState(), data.state->getBlendColor(), mask);
- if (error.isError())
- {
- return error;
- }
-
- error = setDepthStencilState(data.state->getDepthStencilState(), data.state->getStencilRef(),
- data.state->getStencilBackRef(), rasterizer.frontFace == GL_CCW);
- if (error.isError())
- {
- return error;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-bool RendererD3D::applyTransformFeedbackBuffers(const gl::Data &data)
-{
- gl::TransformFeedback *curTransformFeedback = data.state->getCurrentTransformFeedback();
- if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
- {
- applyTransformFeedbackBuffers(*data.state);
- return true;
- }
- else
- {
- return false;
- }
-}
-
-// Applies the shaders and shader constants to the Direct3D device
-gl::Error RendererD3D::applyShaders(const gl::Data &data, bool transformFeedbackActive)
-{
- gl::ProgramBinary *programBinary = data.state->getCurrentProgramBinary();
-
- gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS];
- gl::VertexFormat::GetInputLayout(inputLayout, programBinary, *data.state);
-
- const gl::Framebuffer *fbo = data.state->getDrawFramebuffer();
-
- gl::Error error = applyShaders(programBinary, inputLayout, fbo, data.state->getRasterizerState().rasterizerDiscard, transformFeedbackActive);
- if (error.isError())
- {
- return error;
- }
-
- return programBinary->applyUniforms();
-}
-
-// For each Direct3D sampler of either the pixel or vertex stage,
-// looks up the corresponding OpenGL texture image unit and texture type,
-// and sets the texture and its addressing/filtering state (or NULL when inactive).
-gl::Error RendererD3D::applyTextures(const gl::Data &data, gl::SamplerType shaderType,
- const FramebufferTextureSerialArray &framebufferSerials, size_t framebufferSerialCount)
-{
- gl::ProgramBinary *programBinary = data.state->getCurrentProgramBinary();
-
- size_t samplerRange = programBinary->getUsedSamplerRange(shaderType);
- for (size_t samplerIndex = 0; samplerIndex < samplerRange; samplerIndex++)
- {
- GLenum textureType = programBinary->getSamplerTextureType(shaderType, samplerIndex);
- GLint textureUnit = programBinary->getSamplerMapping(shaderType, samplerIndex, *data.caps);
- if (textureUnit != -1)
- {
- gl::Texture *texture = data.state->getSamplerTexture(textureUnit, textureType);
- ASSERT(texture);
- gl::SamplerState sampler = texture->getSamplerState();
-
- gl::Sampler *samplerObject = data.state->getSampler(textureUnit);
- if (samplerObject)
- {
- samplerObject->getState(&sampler);
- }
-
- // TODO: std::binary_search may become unavailable using older versions of GCC
- if (texture->isSamplerComplete(sampler, *data.textureCaps, *data.extensions, data.clientVersion) &&
- !std::binary_search(framebufferSerials.begin(), framebufferSerials.begin() + framebufferSerialCount, texture->getTextureSerial()))
- {
- gl::Error error = setSamplerState(shaderType, samplerIndex, texture, sampler);
- if (error.isError())
- {
- return error;
- }
-
- error = setTexture(shaderType, samplerIndex, texture);
- if (error.isError())
- {
- return error;
- }
- }
- else
- {
- // Texture is not sampler complete or it is in use by the framebuffer. Bind the incomplete texture.
- gl::Texture *incompleteTexture = getIncompleteTexture(textureType);
- gl::Error error = setTexture(shaderType, samplerIndex, incompleteTexture);
- if (error.isError())
- {
- return error;
- }
- }
- }
- else
- {
- // No texture bound to this slot even though it is used by the shader, bind a NULL texture
- gl::Error error = setTexture(shaderType, samplerIndex, NULL);
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- // Set all the remaining textures to NULL
- size_t samplerCount = (shaderType == gl::SAMPLER_PIXEL) ? data.caps->maxTextureImageUnits
- : data.caps->maxVertexTextureImageUnits;
- for (size_t samplerIndex = samplerRange; samplerIndex < samplerCount; samplerIndex++)
- {
- gl::Error error = setTexture(shaderType, samplerIndex, NULL);
- if (error.isError())
- {
- return error;
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error RendererD3D::applyTextures(const gl::Data &data)
-{
- FramebufferTextureSerialArray framebufferSerials;
- size_t framebufferSerialCount = getBoundFramebufferTextureSerials(data, &framebufferSerials);
-
- gl::Error error = applyTextures(data, gl::SAMPLER_VERTEX, framebufferSerials, framebufferSerialCount);
- if (error.isError())
- {
- return error;
- }
-
- error = applyTextures(data, gl::SAMPLER_PIXEL, framebufferSerials, framebufferSerialCount);
- if (error.isError())
- {
- return error;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error RendererD3D::applyUniformBuffers(const gl::Data &data)
-{
- gl::Program *programObject = data.resourceManager->getProgram(data.state->getCurrentProgramId());
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
-
- std::vector<gl::Buffer*> boundBuffers;
-
- for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < programBinary->getActiveUniformBlockCount(); uniformBlockIndex++)
- {
- GLuint blockBinding = programObject->getUniformBlockBinding(uniformBlockIndex);
-
- if (data.state->getIndexedUniformBuffer(blockBinding)->id() == 0)
- {
- // undefined behaviour
- return gl::Error(GL_INVALID_OPERATION, "It is undefined behaviour to have a used but unbound uniform buffer.");
- }
- else
- {
- gl::Buffer *uniformBuffer = data.state->getIndexedUniformBuffer(blockBinding);
- ASSERT(uniformBuffer);
- boundBuffers.push_back(uniformBuffer);
- }
- }
-
- return programBinary->applyUniformBuffers(boundBuffers, *data.caps);
-}
-
-bool RendererD3D::skipDraw(const gl::Data &data, GLenum drawMode)
-{
- if (drawMode == GL_POINTS)
- {
- // ProgramBinary assumes non-point rendering if gl_PointSize isn't written,
- // which affects varying interpolation. Since the value of gl_PointSize is
- // undefined when not written, just skip drawing to avoid unexpected results.
- if (!data.state->getCurrentProgramBinary()->usesPointSize())
- {
- // This is stictly speaking not an error, but developers should be
- // notified of risking undefined behavior.
- ERR("Point rendering without writing to gl_PointSize.");
-
- return true;
- }
- }
- else if (gl::IsTriangleMode(drawMode))
- {
- if (data.state->getRasterizerState().cullFace && data.state->getRasterizerState().cullMode == GL_FRONT_AND_BACK)
- {
- return true;
- }
- }
-
- return false;
-}
-
-void RendererD3D::markTransformFeedbackUsage(const gl::Data &data)
-{
- for (size_t i = 0; i < data.caps->maxTransformFeedbackSeparateAttributes; i++)
- {
- gl::Buffer *buffer = data.state->getIndexedTransformFeedbackBuffer(i);
- if (buffer)
- {
- buffer->markTransformFeedbackUsage();
- }
- }
-}
-
-size_t RendererD3D::getBoundFramebufferTextureSerials(const gl::Data &data,
- FramebufferTextureSerialArray *outSerialArray)
-{
- size_t serialCount = 0;
-
- const gl::Framebuffer *drawFramebuffer = data.state->getDrawFramebuffer();
- for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; i++)
- {
- gl::FramebufferAttachment *attachment = drawFramebuffer->getColorbuffer(i);
- if (attachment && attachment->isTexture())
- {
- gl::Texture *texture = attachment->getTexture();
- (*outSerialArray)[serialCount++] = texture->getTextureSerial();
- }
- }
-
- gl::FramebufferAttachment *depthStencilAttachment = drawFramebuffer->getDepthOrStencilbuffer();
- if (depthStencilAttachment && depthStencilAttachment->isTexture())
- {
- gl::Texture *depthStencilTexture = depthStencilAttachment->getTexture();
- (*outSerialArray)[serialCount++] = depthStencilTexture->getTextureSerial();
- }
-
- std::sort(outSerialArray->begin(), outSerialArray->begin() + serialCount);
-
- return serialCount;
-}
-
-gl::Texture *RendererD3D::getIncompleteTexture(GLenum type)
-{
- if (mIncompleteTextures.find(type) == mIncompleteTextures.end())
- {
- const GLubyte color[] = { 0, 0, 0, 255 };
- const gl::PixelUnpackState incompleteUnpackState(1);
-
- gl::Texture* t = NULL;
- switch (type)
- {
- default:
- UNREACHABLE();
- // default falls through to TEXTURE_2D
-
- case GL_TEXTURE_2D:
- {
- gl::Texture2D *incomplete2d = new gl::Texture2D(createTexture(GL_TEXTURE_2D), gl::Texture::INCOMPLETE_TEXTURE_ID);
- incomplete2d->setImage(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
- t = incomplete2d;
- }
- break;
-
- case GL_TEXTURE_CUBE_MAP:
- {
- gl::TextureCubeMap *incompleteCube = new gl::TextureCubeMap(createTexture(GL_TEXTURE_CUBE_MAP), gl::Texture::INCOMPLETE_TEXTURE_ID);
-
- incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
- incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
- incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
- incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
- incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
- incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
-
- t = incompleteCube;
- }
- break;
-
- case GL_TEXTURE_3D:
- {
- gl::Texture3D *incomplete3d = new gl::Texture3D(createTexture(GL_TEXTURE_3D), gl::Texture::INCOMPLETE_TEXTURE_ID);
- incomplete3d->setImage(0, 1, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
-
- t = incomplete3d;
- }
- break;
-
- case GL_TEXTURE_2D_ARRAY:
- {
- gl::Texture2DArray *incomplete2darray = new gl::Texture2DArray(createTexture(GL_TEXTURE_2D_ARRAY), gl::Texture::INCOMPLETE_TEXTURE_ID);
- incomplete2darray->setImage(0, 1, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
-
- t = incomplete2darray;
- }
- break;
- }
-
- mIncompleteTextures[type].set(t);
- }
-
- return mIncompleteTextures[type].get();
-}
-
-gl::Error RendererD3D::clear(const gl::Data &data, GLbitfield mask)
-{
- gl::ClearParameters clearParams = data.state->getClearParameters(mask);
-
- // Clips the clear to the scissor rectangle but not the viewport
- gl::Error error = applyRenderTarget(data, GL_TRIANGLES, true);
- if (error.isError())
- {
- return error;
- }
-
- return clear(clearParams, data.state->getDrawFramebuffer());
-}
-
-gl::Error RendererD3D::clearBufferfv(const gl::Data &data, GLenum buffer, GLint drawbuffer, const GLfloat *values)
-{
- // glClearBufferfv can be called to clear the color buffer or depth buffer
- gl::ClearParameters clearParams = data.state->getClearParameters(0);
-
- if (buffer == GL_COLOR)
- {
- for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++)
- {
- clearParams.clearColor[i] = (drawbuffer == static_cast<int>(i));
- }
- clearParams.colorFClearValue = gl::ColorF(values[0], values[1], values[2], values[3]);
- clearParams.colorClearType = GL_FLOAT;
- }
-
- if (buffer == GL_DEPTH)
- {
- clearParams.clearDepth = true;
- clearParams.depthClearValue = values[0];
- }
-
- // Clips the clear to the scissor rectangle but not the viewport
- gl::Error error = applyRenderTarget(data, GL_TRIANGLES, true);
- if (error.isError())
- {
- return error;
- }
-
- return clear(clearParams, data.state->getDrawFramebuffer());
-}
-
-gl::Error RendererD3D::clearBufferuiv(const gl::Data &data, GLenum buffer, GLint drawbuffer, const GLuint *values)
-{
- // glClearBufferuiv can only be called to clear a color buffer
- gl::ClearParameters clearParams = data.state->getClearParameters(0);
- for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++)
- {
- clearParams.clearColor[i] = (drawbuffer == static_cast<int>(i));
- }
- clearParams.colorUIClearValue = gl::ColorUI(values[0], values[1], values[2], values[3]);
- clearParams.colorClearType = GL_UNSIGNED_INT;
-
- // Clips the clear to the scissor rectangle but not the viewport
- gl::Error error = applyRenderTarget(data, GL_TRIANGLES, true);
- if (error.isError())
- {
- return error;
- }
-
- return clear(clearParams, data.state->getDrawFramebuffer());
-}
-
-gl::Error RendererD3D::clearBufferiv(const gl::Data &data, GLenum buffer, GLint drawbuffer, const GLint *values)
-{
- // glClearBufferiv can be called to clear the color buffer or stencil buffer
- gl::ClearParameters clearParams = data.state->getClearParameters(0);
-
- if (buffer == GL_COLOR)
- {
- for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++)
- {
- clearParams.clearColor[i] = (drawbuffer == static_cast<int>(i));
- }
- clearParams.colorIClearValue = gl::ColorI(values[0], values[1], values[2], values[3]);
- clearParams.colorClearType = GL_INT;
- }
-
- if (buffer == GL_STENCIL)
- {
- clearParams.clearStencil = true;
- clearParams.stencilClearValue = values[1];
- }
-
- // Clips the clear to the scissor rectangle but not the viewport
- gl::Error error = applyRenderTarget(data, GL_TRIANGLES, true);
- if (error.isError())
- {
- return error;
- }
-
- return clear(clearParams, data.state->getDrawFramebuffer());
-}
-
-gl::Error RendererD3D::clearBufferfi(const gl::Data &data, GLenum buffer, GLint drawbuffer,
- GLfloat depth, GLint stencil)
-{
- if (data.state->isRasterizerDiscardEnabled())
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- // glClearBufferfi can only be called to clear a depth stencil buffer
- gl::ClearParameters clearParams = data.state->getClearParameters(0);
- clearParams.clearDepth = true;
- clearParams.depthClearValue = depth;
- clearParams.clearStencil = true;
- clearParams.stencilClearValue = stencil;
-
- // Clips the clear to the scissor rectangle but not the viewport
- gl::Error error = applyRenderTarget(data, GL_TRIANGLES, true);
- if (error.isError())
- {
- return error;
- }
-
- return clear(clearParams, data.state->getDrawFramebuffer());
-}
-
-gl::Error RendererD3D::blitFramebuffer(const gl::Data &data,
- GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
- GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
- GLbitfield mask, GLenum filter)
-{
- const gl::Framebuffer *readFramebuffer = data.state->getReadFramebuffer();
- const gl::Framebuffer *drawFramebuffer = data.state->getDrawFramebuffer();
-
- bool blitRenderTarget = false;
- bool blitDepth = false;
- bool blitStencil = false;
- if ((mask & GL_COLOR_BUFFER_BIT) && readFramebuffer->getReadColorbuffer() && drawFramebuffer->getFirstColorbuffer())
- {
- blitRenderTarget = true;
- }
- if ((mask & GL_STENCIL_BUFFER_BIT) && readFramebuffer->getStencilbuffer() && drawFramebuffer->getStencilbuffer())
- {
- blitStencil = true;
- }
- if ((mask & GL_DEPTH_BUFFER_BIT) && readFramebuffer->getDepthbuffer() && drawFramebuffer->getDepthbuffer())
- {
- blitDepth = true;
- }
-
- gl::Rectangle srcRect(srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0);
- gl::Rectangle dstRect(dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0);
- if (blitRenderTarget || blitDepth || blitStencil)
- {
- const gl::Rectangle *scissor = data.state->isScissorTestEnabled() ? &data.state->getScissor() : NULL;
- gl::Error error = blitRect(readFramebuffer, srcRect, drawFramebuffer, dstRect, scissor,
- blitRenderTarget, blitDepth, blitStencil, filter);
- if (error.isError())
- {
- return error;
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error RendererD3D::readPixels(const gl::Data &data, GLint x, GLint y, GLsizei width, GLsizei height,
- GLenum format, GLenum type, GLsizei *bufSize, void* pixels)
-{
- const gl::Framebuffer *framebuffer = data.state->getReadFramebuffer();
-
- GLenum sizedInternalFormat = gl::GetSizedInternalFormat(format, type);
- const gl::InternalFormat &sizedFormatInfo = gl::GetInternalFormatInfo(sizedInternalFormat);
- GLuint outputPitch = sizedFormatInfo.computeRowPitch(type, width, data.state->getPackAlignment());
-
- return readPixels(framebuffer, x, y, width, height, format, type, outputPitch, data.state->getPackState(),
- reinterpret_cast<uint8_t*>(pixels));
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/RendererD3D.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/RendererD3D.h
deleted file mode 100644
index a2f778763c..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/RendererD3D.h
+++ /dev/null
@@ -1,197 +0,0 @@
-
-// Copyright (c) 2014 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.
-//
-
-// RendererD3D.h: Defines a back-end specific class for the DirectX renderer.
-
-#ifndef LIBGLESV2_RENDERER_RENDERERD3D_H_
-#define LIBGLESV2_RENDERER_RENDERERD3D_H_
-
-#include "libGLESv2/renderer/Renderer.h"
-#include "libGLESv2/Data.h"
-
-//FIXME(jmadill): std::array is currently prohibited by Chromium style guide
-#include <array>
-
-namespace gl
-{
-class InfoLog;
-struct LinkedVarying;
-class Texture;
-}
-
-namespace rx
-{
-class TextureStorage;
-class VertexBuffer;
-class IndexBuffer;
-class ShaderExecutable;
-class SwapChain;
-class RenderTarget;
-class Image;
-class TextureStorage;
-class UniformStorage;
-
-class RendererD3D : public Renderer
-{
- public:
- explicit RendererD3D(egl::Display *display);
- virtual ~RendererD3D();
-
- static RendererD3D *makeRendererD3D(Renderer *renderer);
-
- gl::Error drawArrays(const gl::Data &data,
- GLenum mode, GLint first,
- GLsizei count, GLsizei instances) override;
-
- gl::Error drawElements(const gl::Data &data,
- GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices, GLsizei instances,
- const RangeUI &indexRange) override;
-
- gl::Error clear(const gl::Data &data, GLbitfield mask) override;
- gl::Error clearBufferfv(const gl::Data &data, GLenum buffer, int drawbuffer, const GLfloat *values) override;
- gl::Error clearBufferuiv(const gl::Data &data, GLenum buffer, int drawbuffer, const GLuint *values) override;
- gl::Error clearBufferiv(const gl::Data &data, GLenum buffer, int drawbuffer, const GLint *values) override;
- gl::Error clearBufferfi(const gl::Data &data, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) override;
-
- gl::Error readPixels(const gl::Data &data, GLint x, GLint y, GLsizei width, GLsizei height,
- GLenum format, GLenum type, GLsizei *bufSize, void* pixels) override;
-
- gl::Error blitFramebuffer(const gl::Data &data,
- GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
- GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
- GLbitfield mask, GLenum filter) override;
-
- // Direct3D Specific methods
- virtual SwapChain *createSwapChain(NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat) = 0;
-
- virtual gl::Error generateSwizzle(gl::Texture *texture) = 0;
- virtual gl::Error setSamplerState(gl::SamplerType type, int index, gl::Texture *texture, const gl::SamplerState &sampler) = 0;
- virtual gl::Error setTexture(gl::SamplerType type, int index, gl::Texture *texture) = 0;
-
- virtual gl::Error setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]) = 0;
-
- virtual gl::Error setRasterizerState(const gl::RasterizerState &rasterState) = 0;
- virtual gl::Error setBlendState(const gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor,
- unsigned int sampleMask) = 0;
- virtual gl::Error setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
- int stencilBackRef, bool frontFaceCCW) = 0;
-
- virtual void setScissorRectangle(const gl::Rectangle &scissor, bool enabled) = 0;
- virtual void setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace,
- bool ignoreViewport) = 0;
-
- virtual gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer) = 0;
- virtual gl::Error applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
- bool rasterizerDiscard, bool transformFeedbackActive) = 0;
- virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray) = 0;
- virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount) = 0;
- virtual gl::Error applyVertexBuffer(const gl::State &state, GLint first, GLsizei count, GLsizei instances) = 0;
- virtual gl::Error applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo) = 0;
- virtual void applyTransformFeedbackBuffers(const gl::State& state) = 0;
-
- virtual void markAllStateDirty() = 0;
-
- virtual unsigned int getReservedVertexUniformVectors() const = 0;
- virtual unsigned int getReservedFragmentUniformVectors() const = 0;
- virtual unsigned int getReservedVertexUniformBuffers() const = 0;
- virtual unsigned int getReservedFragmentUniformBuffers() const = 0;
- virtual bool getShareHandleSupport() const = 0;
- virtual bool getPostSubBufferSupport() const = 0;
-
- // Pixel operations
- virtual gl::Error copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level) = 0;
- virtual gl::Error copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level) = 0;
- virtual gl::Error copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level) = 0;
- virtual gl::Error copyImage2DArray(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level) = 0;
-
- virtual gl::Error readPixels(const gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
- GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels) = 0;
-
- // RenderTarget creation
- virtual gl::Error createRenderTarget(SwapChain *swapChain, bool depth, RenderTarget **outRT) = 0;
- virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTarget **outRT) = 0;
-
- // Shader operations
- virtual void releaseShaderCompiler() = 0;
- virtual gl::Error loadExecutable(const void *function, size_t length, ShaderType type,
- const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
- bool separatedOutputBuffers, ShaderExecutable **outExecutable) = 0;
- virtual gl::Error compileToExecutable(gl::InfoLog &infoLog, const std::string &shaderHLSL, ShaderType type,
- const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
- bool separatedOutputBuffers, D3DWorkaroundType workaround,
- ShaderExecutable **outExectuable) = 0;
- virtual UniformStorage *createUniformStorage(size_t storageSize) = 0;
-
- // Image operations
- virtual Image *createImage() = 0;
- virtual gl::Error generateMipmap(Image *dest, Image *source) = 0;
- virtual TextureStorage *createTextureStorage2D(SwapChain *swapChain) = 0;
- virtual TextureStorage *createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels) = 0;
- virtual TextureStorage *createTextureStorageCube(GLenum internalformat, bool renderTarget, int size, int levels) = 0;
- virtual TextureStorage *createTextureStorage3D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels) = 0;
- virtual TextureStorage *createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels) = 0;
-
- // Buffer-to-texture and Texture-to-buffer copies
- virtual bool supportsFastCopyBufferToTexture(GLenum internalFormat) const = 0;
- virtual gl::Error fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
- GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea) = 0;
-
- virtual VertexConversionType getVertexConversionType(const gl::VertexFormat &vertexFormat) const = 0;
- virtual GLenum getVertexComponentType(const gl::VertexFormat &vertexFormat) const = 0;
-
- virtual VertexBuffer *createVertexBuffer() = 0;
- virtual IndexBuffer *createIndexBuffer() = 0;
-
- protected:
- virtual gl::Error drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive) = 0;
- virtual gl::Error drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
- gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo, GLsizei instances) = 0;
- virtual gl::Error clear(const gl::ClearParameters &clearParams, const gl::Framebuffer *frameBuffer) = 0;
- virtual gl::Error blitRect(const gl::Framebuffer *readTarget, const gl::Rectangle &readRect,
- const gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
- const gl::Rectangle *scissor, bool blitRenderTarget,
- bool blitDepth, bool blitStencil, GLenum filter) = 0;
-
- void cleanup();
-
- egl::Display *mDisplay;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(RendererD3D);
-
- //FIXME(jmadill): std::array is currently prohibited by Chromium style guide
- typedef std::array<unsigned int, gl::IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS> FramebufferTextureSerialArray;
-
- gl::Error generateSwizzles(const gl::Data &data, gl::SamplerType type);
- gl::Error generateSwizzles(const gl::Data &data);
-
- gl::Error applyRenderTarget(const gl::Data &data, GLenum drawMode, bool ignoreViewport);
- gl::Error applyState(const gl::Data &data, GLenum drawMode);
- bool applyTransformFeedbackBuffers(const gl::Data &data);
- gl::Error applyShaders(const gl::Data &data, bool transformFeedbackActive);
- gl::Error applyTextures(const gl::Data &data, gl::SamplerType shaderType,
- const FramebufferTextureSerialArray &framebufferSerials, size_t framebufferSerialCount);
- gl::Error applyTextures(const gl::Data &data);
- gl::Error applyUniformBuffers(const gl::Data &data);
-
- bool skipDraw(const gl::Data &data, GLenum drawMode);
- void markTransformFeedbackUsage(const gl::Data &data);
-
- size_t getBoundFramebufferTextureSerials(const gl::Data &data,
- FramebufferTextureSerialArray *outSerialArray);
- gl::Texture *getIncompleteTexture(GLenum type);
-
- gl::TextureMap mIncompleteTextures;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_RENDERERD3D_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ShaderD3D.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ShaderD3D.cpp
deleted file mode 100644
index 8a97579e16..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ShaderD3D.cpp
+++ /dev/null
@@ -1,481 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// ShaderD3D.cpp: Defines the rx::ShaderD3D class which implements rx::ShaderImpl.
-
-#include "libGLESv2/Shader.h"
-#include "libGLESv2/main.h"
-#include "libGLESv2/renderer/d3d/RendererD3D.h"
-#include "libGLESv2/renderer/d3d/ShaderD3D.h"
-
-#include "common/features.h"
-#include "common/utilities.h"
-
-// Definitions local to the translation unit
-namespace
-{
-
-const char *GetShaderTypeString(GLenum type)
-{
- switch (type)
- {
- case GL_VERTEX_SHADER:
- return "VERTEX";
-
- case GL_FRAGMENT_SHADER:
- return "FRAGMENT";
-
- default:
- UNREACHABLE();
- return "";
- }
-}
-
-}
-
-namespace rx
-{
-
-template <typename VarT>
-void FilterInactiveVariables(std::vector<VarT> *variableList)
-{
- ASSERT(variableList);
-
- for (size_t varIndex = 0; varIndex < variableList->size();)
- {
- if (!(*variableList)[varIndex].staticUse)
- {
- variableList->erase(variableList->begin() + varIndex);
- }
- else
- {
- varIndex++;
- }
- }
-}
-
-void *ShaderD3D::mFragmentCompiler = NULL;
-void *ShaderD3D::mVertexCompiler = NULL;
-
-template <typename VarT>
-const std::vector<VarT> *GetShaderVariables(const std::vector<VarT> *variableList)
-{
- ASSERT(variableList);
- return variableList;
-}
-
-ShaderD3D::ShaderD3D(const gl::Data &data, GLenum type, RendererD3D *renderer)
- : mType(type),
- mRenderer(renderer),
- mShaderVersion(100)
-{
- uncompile();
- initializeCompiler(data);
-}
-
-ShaderD3D::~ShaderD3D()
-{
-}
-
-ShaderD3D *ShaderD3D::makeShaderD3D(ShaderImpl *impl)
-{
- ASSERT(HAS_DYNAMIC_TYPE(ShaderD3D*, impl));
- return static_cast<ShaderD3D*>(impl);
-}
-
-const ShaderD3D *ShaderD3D::makeShaderD3D(const ShaderImpl *impl)
-{
- ASSERT(HAS_DYNAMIC_TYPE(const ShaderD3D*, impl));
- return static_cast<const ShaderD3D*>(impl);
-}
-
-std::string ShaderD3D::getDebugInfo() const
-{
- return mDebugInfo + std::string("\n// ") + GetShaderTypeString(mType) + " SHADER END\n";
-}
-
-// Perform a one-time initialization of the shader compiler (or after being destructed by releaseCompiler)
-void ShaderD3D::initializeCompiler(const gl::Data &data)
-{
- if (!mFragmentCompiler)
- {
- bool result = ShInitialize();
-
- if (result)
- {
- ShShaderSpec specVersion = (data.clientVersion >= 3) ? SH_GLES3_SPEC : SH_GLES2_SPEC;
- ShShaderOutput hlslVersion = (mRenderer->getMajorShaderModel() >= 4) ? SH_HLSL11_OUTPUT : SH_HLSL9_OUTPUT;
-
- ShBuiltInResources resources;
- ShInitBuiltInResources(&resources);
-
- const gl::Caps &caps = *data.caps;
- const gl::Extensions &extensions = *data.extensions;
-
- resources.MaxVertexAttribs = caps.maxVertexAttributes;
- resources.MaxVertexUniformVectors = caps.maxVertexUniformVectors;
- resources.MaxVaryingVectors = caps.maxVaryingVectors;
- resources.MaxVertexTextureImageUnits = caps.maxVertexTextureImageUnits;
- resources.MaxCombinedTextureImageUnits = caps.maxCombinedTextureImageUnits;
- resources.MaxTextureImageUnits = caps.maxTextureImageUnits;
- resources.MaxFragmentUniformVectors = caps.maxFragmentUniformVectors;
- resources.MaxDrawBuffers = caps.maxDrawBuffers;
- resources.OES_standard_derivatives = extensions.standardDerivatives;
- resources.EXT_draw_buffers = extensions.drawBuffers;
- resources.EXT_shader_texture_lod = 1;
- // resources.OES_EGL_image_external = mRenderer->getShareHandleSupport() ? 1 : 0; // TODO: commented out until the extension is actually supported.
- resources.FragmentPrecisionHigh = 1; // Shader Model 2+ always supports FP24 (s16e7) which corresponds to highp
- resources.EXT_frag_depth = 1; // Shader Model 2+ always supports explicit depth output
- // GLSL ES 3.0 constants
- resources.MaxVertexOutputVectors = caps.maxVertexOutputComponents / 4;
- resources.MaxFragmentInputVectors = caps.maxFragmentInputComponents / 4;
- resources.MinProgramTexelOffset = caps.minProgramTexelOffset;
- resources.MaxProgramTexelOffset = caps.maxProgramTexelOffset;
-
- mFragmentCompiler = ShConstructCompiler(GL_FRAGMENT_SHADER, specVersion, hlslVersion, &resources);
- mVertexCompiler = ShConstructCompiler(GL_VERTEX_SHADER, specVersion, hlslVersion, &resources);
- }
- }
-}
-
-void ShaderD3D::releaseCompiler()
-{
- ShDestruct(mFragmentCompiler);
- ShDestruct(mVertexCompiler);
-
- mFragmentCompiler = NULL;
- mVertexCompiler = NULL;
-
- ShFinalize();
-}
-
-void ShaderD3D::parseVaryings(void *compiler)
-{
- if (!mHlsl.empty())
- {
- const std::vector<sh::Varying> *varyings = ShGetVaryings(compiler);
- ASSERT(varyings);
-
- for (size_t varyingIndex = 0; varyingIndex < varyings->size(); varyingIndex++)
- {
- mVaryings.push_back(gl::PackedVarying((*varyings)[varyingIndex]));
- }
-
- mUsesMultipleRenderTargets = mHlsl.find("GL_USES_MRT") != std::string::npos;
- mUsesFragColor = mHlsl.find("GL_USES_FRAG_COLOR") != std::string::npos;
- mUsesFragData = mHlsl.find("GL_USES_FRAG_DATA") != std::string::npos;
- mUsesFragCoord = mHlsl.find("GL_USES_FRAG_COORD") != std::string::npos;
- mUsesFrontFacing = mHlsl.find("GL_USES_FRONT_FACING") != std::string::npos;
- mUsesPointSize = mHlsl.find("GL_USES_POINT_SIZE") != std::string::npos;
- mUsesPointCoord = mHlsl.find("GL_USES_POINT_COORD") != std::string::npos;
- mUsesDepthRange = mHlsl.find("GL_USES_DEPTH_RANGE") != std::string::npos;
- mUsesFragDepth = mHlsl.find("GL_USES_FRAG_DEPTH") != std::string::npos;
- mUsesDiscardRewriting = mHlsl.find("ANGLE_USES_DISCARD_REWRITING") != std::string::npos;
- mUsesNestedBreak = mHlsl.find("ANGLE_USES_NESTED_BREAK") != std::string::npos;
- }
-}
-
-void ShaderD3D::resetVaryingsRegisterAssignment()
-{
- for (size_t varyingIndex = 0; varyingIndex < mVaryings.size(); varyingIndex++)
- {
- mVaryings[varyingIndex].resetRegisterAssignment();
- }
-}
-
-// initialize/clean up previous state
-void ShaderD3D::uncompile()
-{
- // set by compileToHLSL
- mHlsl.clear();
- mInfoLog.clear();
-
- mUsesMultipleRenderTargets = false;
- mUsesFragColor = false;
- mUsesFragData = false;
- mUsesFragCoord = false;
- mUsesFrontFacing = false;
- mUsesPointSize = false;
- mUsesPointCoord = false;
- mUsesDepthRange = false;
- mUsesFragDepth = false;
- mShaderVersion = 100;
- mUsesDiscardRewriting = false;
- mUsesNestedBreak = false;
-
- mVaryings.clear();
- mUniforms.clear();
- mInterfaceBlocks.clear();
- mActiveAttributes.clear();
- mActiveOutputVariables.clear();
- mDebugInfo.clear();
-}
-
-void ShaderD3D::compileToHLSL(const gl::Data &data, void *compiler, const std::string &source)
-{
- // ensure the compiler is loaded
- initializeCompiler(data);
-
- int compileOptions = (SH_OBJECT_CODE | SH_VARIABLES);
- std::string sourcePath;
-
-#if !defined (ANGLE_ENABLE_WINDOWS_STORE)
- if (gl::perfActive())
- {
- sourcePath = getTempPath();
- writeFile(sourcePath.c_str(), source.c_str(), source.length());
- compileOptions |= SH_LINE_DIRECTIVES;
- }
-#endif
-
- int result;
- if (sourcePath.empty())
- {
- const char* sourceStrings[] =
- {
- source.c_str(),
- };
-
- result = ShCompile(compiler, sourceStrings, ArraySize(sourceStrings), compileOptions);
- }
- else
- {
- const char* sourceStrings[] =
- {
- sourcePath.c_str(),
- source.c_str(),
- };
-
- result = ShCompile(compiler, sourceStrings, ArraySize(sourceStrings), compileOptions | SH_SOURCE_PATH);
- }
-
- mShaderVersion = ShGetShaderVersion(compiler);
-
- if (mShaderVersion == 300 && data.clientVersion < 3)
- {
- mInfoLog = "GLSL ES 3.00 is not supported by OpenGL ES 2.0 contexts";
- TRACE("\n%s", mInfoLog.c_str());
- }
- else if (result)
- {
- mHlsl = ShGetObjectCode(compiler);
-
-#ifdef _DEBUG
- // Prefix hlsl shader with commented out glsl shader
- // Useful in diagnostics tools like pix which capture the hlsl shaders
- std::ostringstream hlslStream;
- hlslStream << "// GLSL\n";
- hlslStream << "//\n";
-
- size_t curPos = 0;
- while (curPos != std::string::npos)
- {
- size_t nextLine = source.find("\n", curPos);
- size_t len = (nextLine == std::string::npos) ? std::string::npos : (nextLine - curPos + 1);
-
- hlslStream << "// " << source.substr(curPos, len);
-
- curPos = (nextLine == std::string::npos) ? std::string::npos : (nextLine + 1);
- }
- hlslStream << "\n\n";
- hlslStream << mHlsl;
- mHlsl = hlslStream.str();
-#endif
-
- mUniforms = *GetShaderVariables(ShGetUniforms(compiler));
-
- for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); uniformIndex++)
- {
- const sh::Uniform &uniform = mUniforms[uniformIndex];
-
- if (uniform.staticUse)
- {
- unsigned int index = -1;
- bool result = ShGetUniformRegister(compiler, uniform.name, &index);
- UNUSED_ASSERTION_VARIABLE(result);
- ASSERT(result);
-
- mUniformRegisterMap[uniform.name] = index;
- }
- }
-
- mInterfaceBlocks = *GetShaderVariables(ShGetInterfaceBlocks(compiler));
-
- for (size_t blockIndex = 0; blockIndex < mInterfaceBlocks.size(); blockIndex++)
- {
- const sh::InterfaceBlock &interfaceBlock = mInterfaceBlocks[blockIndex];
-
- if (interfaceBlock.staticUse)
- {
- unsigned int index = -1;
- bool result = ShGetInterfaceBlockRegister(compiler, interfaceBlock.name, &index);
- UNUSED_ASSERTION_VARIABLE(result);
- ASSERT(result);
-
- mInterfaceBlockRegisterMap[interfaceBlock.name] = index;
- }
- }
- }
- else
- {
- mInfoLog = ShGetInfoLog(compiler);
-
- TRACE("\n%s", mInfoLog.c_str());
- }
-}
-
-D3DWorkaroundType ShaderD3D::getD3DWorkarounds() const
-{
- if (mUsesDiscardRewriting)
- {
- // ANGLE issue 486:
- // Work-around a D3D9 compiler bug that presents itself when using conditional discard, by disabling optimization
- return ANGLE_D3D_WORKAROUND_SKIP_OPTIMIZATION;
- }
-
- if (mUsesNestedBreak)
- {
- // ANGLE issue 603:
- // Work-around a D3D9 compiler bug that presents itself when using break in a nested loop, by maximizing optimization
- // We want to keep the use of ANGLE_D3D_WORKAROUND_MAX_OPTIMIZATION minimal to prevent hangs, so usesDiscard takes precedence
- return ANGLE_D3D_WORKAROUND_MAX_OPTIMIZATION;
- }
-
- return ANGLE_D3D_WORKAROUND_NONE;
-}
-
-// true if varying x has a higher priority in packing than y
-bool ShaderD3D::compareVarying(const gl::PackedVarying &x, const gl::PackedVarying &y)
-{
- if (x.type == y.type)
- {
- return x.arraySize > y.arraySize;
- }
-
- // Special case for handling structs: we sort these to the end of the list
- if (x.type == GL_STRUCT_ANGLEX)
- {
- return false;
- }
-
- if (y.type == GL_STRUCT_ANGLEX)
- {
- return true;
- }
-
- return gl::VariableSortOrder(x.type) < gl::VariableSortOrder(y.type);
-}
-
-unsigned int ShaderD3D::getUniformRegister(const std::string &uniformName) const
-{
- ASSERT(mUniformRegisterMap.count(uniformName) > 0);
- return mUniformRegisterMap.find(uniformName)->second;
-}
-
-unsigned int ShaderD3D::getInterfaceBlockRegister(const std::string &blockName) const
-{
- ASSERT(mInterfaceBlockRegisterMap.count(blockName) > 0);
- return mInterfaceBlockRegisterMap.find(blockName)->second;
-}
-
-void *ShaderD3D::getCompiler()
-{
- if (mType == GL_VERTEX_SHADER)
- {
- return mVertexCompiler;
- }
- else
- {
- ASSERT(mType == GL_FRAGMENT_SHADER);
- return mFragmentCompiler;
- }
-}
-
-ShShaderOutput ShaderD3D::getCompilerOutputType(GLenum shader)
-{
- void *compiler = NULL;
-
- switch (shader)
- {
- case GL_VERTEX_SHADER: compiler = mVertexCompiler; break;
- case GL_FRAGMENT_SHADER: compiler = mFragmentCompiler; break;
- default: UNREACHABLE(); return SH_HLSL9_OUTPUT;
- }
-
- return ShGetShaderOutputType(compiler);
-}
-
-bool ShaderD3D::compile(const gl::Data &data, const std::string &source)
-{
- uncompile();
-
- void *compiler = getCompiler();
-
- compileToHLSL(data, compiler, source);
-
- if (mType == GL_VERTEX_SHADER)
- {
- parseAttributes(compiler);
- }
-
- parseVaryings(compiler);
-
- if (mType == GL_FRAGMENT_SHADER)
- {
- std::sort(mVaryings.begin(), mVaryings.end(), compareVarying);
-
- const std::string &hlsl = getTranslatedSource();
- if (!hlsl.empty())
- {
- mActiveOutputVariables = *GetShaderVariables(ShGetOutputVariables(compiler));
- FilterInactiveVariables(&mActiveOutputVariables);
- }
- }
-
-#if ANGLE_SHADER_DEBUG_INFO == ANGLE_ENABLED
- mDebugInfo += std::string("// ") + GetShaderTypeString(mType) + " SHADER BEGIN\n";
- mDebugInfo += "\n// GLSL BEGIN\n\n" + source + "\n\n// GLSL END\n\n\n";
- mDebugInfo += "// INITIAL HLSL BEGIN\n\n" + getTranslatedSource() + "\n// INITIAL HLSL END\n\n\n";
- // Successive steps will append more info
-#else
- mDebugInfo += getTranslatedSource();
-#endif
-
- return !getTranslatedSource().empty();
-}
-
-void ShaderD3D::parseAttributes(void *compiler)
-{
- const std::string &hlsl = getTranslatedSource();
- if (!hlsl.empty())
- {
- mActiveAttributes = *GetShaderVariables(ShGetAttributes(compiler));
- FilterInactiveVariables(&mActiveAttributes);
- }
-}
-
-int ShaderD3D::getSemanticIndex(const std::string &attributeName) const
-{
- if (!attributeName.empty())
- {
- int semanticIndex = 0;
- for (size_t attributeIndex = 0; attributeIndex < mActiveAttributes.size(); attributeIndex++)
- {
- const sh::ShaderVariable &attribute = mActiveAttributes[attributeIndex];
-
- if (attribute.name == attributeName)
- {
- return semanticIndex;
- }
-
- semanticIndex += gl::VariableRegisterCount(attribute.type);
- }
- }
-
- return -1;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ShaderD3D.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ShaderD3D.h
deleted file mode 100644
index 3c9aac2c12..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/ShaderD3D.h
+++ /dev/null
@@ -1,98 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// ShaderD3D.h: Defines the rx::ShaderD3D class which implements rx::ShaderImpl.
-
-#ifndef LIBGLESV2_RENDERER_SHADERD3D_H_
-#define LIBGLESV2_RENDERER_SHADERD3D_H_
-
-#include "libGLESv2/renderer/ShaderImpl.h"
-#include "libGLESv2/renderer/Workarounds.h"
-#include "libGLESv2/Shader.h"
-
-#include <map>
-
-namespace rx
-{
-class DynamicHLSL;
-class RendererD3D;
-
-class ShaderD3D : public ShaderImpl
-{
- friend class DynamicHLSL;
-
- public:
- ShaderD3D(const gl::Data &data, GLenum type, RendererD3D *renderer);
- virtual ~ShaderD3D();
-
- static ShaderD3D *makeShaderD3D(ShaderImpl *impl);
- static const ShaderD3D *makeShaderD3D(const ShaderImpl *impl);
-
- // ShaderImpl implementation
- virtual const std::string &getInfoLog() const { return mInfoLog; }
- virtual const std::string &getTranslatedSource() const { return mHlsl; }
- virtual std::string getDebugInfo() const;
-
- // D3D-specific methods
- virtual void uncompile();
- void resetVaryingsRegisterAssignment();
- unsigned int getUniformRegister(const std::string &uniformName) const;
- unsigned int getInterfaceBlockRegister(const std::string &blockName) const;
- int getSemanticIndex(const std::string &attributeName) const;
- void appendDebugInfo(const std::string &info) { mDebugInfo += info; }
-
- D3DWorkaroundType getD3DWorkarounds() const;
- int getShaderVersion() const { return mShaderVersion; }
- bool usesDepthRange() const { return mUsesDepthRange; }
- bool usesPointSize() const { return mUsesPointSize; }
-
- static void releaseCompiler();
- static ShShaderOutput getCompilerOutputType(GLenum shader);
-
- virtual bool compile(const gl::Data &data, const std::string &source);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ShaderD3D);
-
- void compileToHLSL(const gl::Data &data, void *compiler, const std::string &source);
- void parseVaryings(void *compiler);
-
- void initializeCompiler(const gl::Data &data);
- void parseAttributes(void *compiler);
- void *getCompiler();
-
- static bool compareVarying(const gl::PackedVarying &x, const gl::PackedVarying &y);
-
- static void *mFragmentCompiler;
- static void *mVertexCompiler;
-
- GLenum mType;
- RendererD3D *mRenderer;
-
- int mShaderVersion;
-
- bool mUsesMultipleRenderTargets;
- bool mUsesFragColor;
- bool mUsesFragData;
- bool mUsesFragCoord;
- bool mUsesFrontFacing;
- bool mUsesPointSize;
- bool mUsesPointCoord;
- bool mUsesDepthRange;
- bool mUsesFragDepth;
- bool mUsesDiscardRewriting;
- bool mUsesNestedBreak;
-
- std::string mHlsl;
- std::string mInfoLog;
- std::string mDebugInfo;
- std::map<std::string, unsigned int> mUniformRegisterMap;
- std::map<std::string, unsigned int> mInterfaceBlockRegisterMap;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_SHADERD3D_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TextureD3D.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TextureD3D.cpp
deleted file mode 100644
index 4a67701fdf..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TextureD3D.cpp
+++ /dev/null
@@ -1,2813 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// TextureD3D.cpp: Implementations of the Texture interfaces shared betweeen the D3D backends.
-
-#include "libGLESv2/Buffer.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/main.h"
-#include "libGLESv2/formatutils.h"
-#include "libGLESv2/renderer/BufferImpl.h"
-#include "libGLESv2/renderer/RenderTarget.h"
-#include "libGLESv2/renderer/d3d/BufferD3D.h"
-#include "libGLESv2/renderer/d3d/TextureD3D.h"
-#include "libGLESv2/renderer/d3d/TextureStorage.h"
-#include "libGLESv2/renderer/d3d/ImageD3D.h"
-#include "libGLESv2/renderer/d3d/RendererD3D.h"
-
-#include "libEGL/Surface.h"
-
-#include "common/mathutil.h"
-#include "common/utilities.h"
-
-namespace rx
-{
-
-namespace
-{
-
-gl::Error GetUnpackPointer(const gl::PixelUnpackState &unpack, const void *pixels, const uint8_t **pointerOut)
-{
- if (unpack.pixelBuffer.id() != 0)
- {
- // Do a CPU readback here, if we have an unpack buffer bound and the fast GPU path is not supported
- gl::Buffer *pixelBuffer = unpack.pixelBuffer.get();
- ptrdiff_t offset = reinterpret_cast<ptrdiff_t>(pixels);
-
- // TODO: this is the only place outside of renderer that asks for a buffers raw data.
- // This functionality should be moved into renderer and the getData method of BufferImpl removed.
- BufferD3D *bufferD3D = BufferD3D::makeBufferD3D(pixelBuffer->getImplementation());
- ASSERT(bufferD3D);
- const uint8_t *bufferData = NULL;
- gl::Error error = bufferD3D->getData(&bufferData);
- if (error.isError())
- {
- return error;
- }
-
- *pointerOut = bufferData + offset;
- }
- else
- {
- *pointerOut = static_cast<const uint8_t *>(pixels);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-bool IsRenderTargetUsage(GLenum usage)
-{
- return (usage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
-}
-
-}
-
-TextureD3D::TextureD3D(RendererD3D *renderer)
- : mRenderer(renderer),
- mUsage(GL_NONE),
- mDirtyImages(true),
- mImmutable(false),
- mTexStorage(NULL)
-{
-}
-
-TextureD3D::~TextureD3D()
-{
-}
-
-TextureD3D *TextureD3D::makeTextureD3D(TextureImpl *texture)
-{
- ASSERT(HAS_DYNAMIC_TYPE(TextureD3D*, texture));
- return static_cast<TextureD3D*>(texture);
-}
-
-TextureStorage *TextureD3D::getNativeTexture()
-{
- // ensure the underlying texture is created
- initializeStorage(false);
-
- if (mTexStorage)
- {
- updateStorage();
- }
-
- return mTexStorage;
-}
-
-GLint TextureD3D::getBaseLevelWidth() const
-{
- const Image *baseImage = getBaseLevelImage();
- return (baseImage ? baseImage->getWidth() : 0);
-}
-
-GLint TextureD3D::getBaseLevelHeight() const
-{
- const Image *baseImage = getBaseLevelImage();
- return (baseImage ? baseImage->getHeight() : 0);
-}
-
-GLint TextureD3D::getBaseLevelDepth() const
-{
- const Image *baseImage = getBaseLevelImage();
- return (baseImage ? baseImage->getDepth() : 0);
-}
-
-// Note: "base level image" is loosely defined to be any image from the base level,
-// where in the base of 2D array textures and cube maps there are several. Don't use
-// the base level image for anything except querying texture format and size.
-GLenum TextureD3D::getBaseLevelInternalFormat() const
-{
- const Image *baseImage = getBaseLevelImage();
- return (baseImage ? baseImage->getInternalFormat() : GL_NONE);
-}
-
-bool TextureD3D::shouldUseSetData(const Image *image) const
-{
- if (!mRenderer->getWorkarounds().setDataFasterThanImageUpload)
- {
- return false;
- }
-
- gl::InternalFormat internalFormat = gl::GetInternalFormatInfo(image->getInternalFormat());
-
- // We can only handle full updates for depth-stencil textures, so to avoid complications
- // disable them entirely.
- if (internalFormat.depthBits > 0 || internalFormat.stencilBits > 0)
- {
- return false;
- }
-
- // TODO(jmadill): Handle compressed internal formats
- return (mTexStorage && !internalFormat.compressed);
-}
-
-gl::Error TextureD3D::setImage(const gl::PixelUnpackState &unpack, GLenum type, const void *pixels, const gl::ImageIndex &index)
-{
- Image *image = getImage(index);
- ASSERT(image);
-
- // No-op
- if (image->getWidth() == 0 || image->getHeight() == 0 || image->getDepth() == 0)
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- // We no longer need the "GLenum format" parameter to TexImage to determine what data format "pixels" contains.
- // From our image internal format we know how many channels to expect, and "type" gives the format of pixel's components.
- const uint8_t *pixelData = NULL;
- gl::Error error = GetUnpackPointer(unpack, pixels, &pixelData);
- if (error.isError())
- {
- return error;
- }
-
- if (pixelData != NULL)
- {
- gl::Error error(GL_NO_ERROR);
-
- if (shouldUseSetData(image))
- {
- error = mTexStorage->setData(index, image, NULL, type, unpack, pixelData);
- }
- else
- {
- error = image->loadData(0, 0, 0, image->getWidth(), image->getHeight(), image->getDepth(), unpack.alignment, type, pixelData);
- }
-
- if (error.isError())
- {
- return error;
- }
-
- mDirtyImages = true;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels, const gl::ImageIndex &index)
-{
- // CPU readback & copy where direct GPU copy is not supported
- const uint8_t *pixelData = NULL;
- gl::Error error = GetUnpackPointer(unpack, pixels, &pixelData);
- if (error.isError())
- {
- return error;
- }
-
- if (pixelData != NULL)
- {
- Image *image = getImage(index);
- ASSERT(image);
-
- gl::Box region(xoffset, yoffset, zoffset, width, height, depth);
- if (shouldUseSetData(image))
- {
- return mTexStorage->setData(index, image, &region, type, unpack, pixelData);
- }
-
- gl::Error error = image->loadData(xoffset, yoffset, zoffset, width, height, depth, unpack.alignment,
- type, pixelData);
- if (error.isError())
- {
- return error;
- }
-
- error = commitRegion(index, region);
- if (error.isError())
- {
- return error;
- }
-
- mDirtyImages = true;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D::setCompressedImage(const gl::PixelUnpackState &unpack, GLsizei imageSize, const void *pixels, Image *image)
-{
- // We no longer need the "GLenum format" parameter to TexImage to determine what data format "pixels" contains.
- // From our image internal format we know how many channels to expect, and "type" gives the format of pixel's components.
- const uint8_t *pixelData = NULL;
- gl::Error error = GetUnpackPointer(unpack, pixels, &pixelData);
- if (error.isError())
- {
- return error;
- }
-
- if (pixelData != NULL)
- {
- gl::Error error = image->loadCompressedData(0, 0, 0, image->getWidth(), image->getHeight(), image->getDepth(), pixelData);
- if (error.isError())
- {
- return error;
- }
-
- mDirtyImages = true;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D::subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels, Image *image)
-{
- const uint8_t *pixelData = NULL;
- gl::Error error = GetUnpackPointer(unpack, pixels, &pixelData);
- if (error.isError())
- {
- return error;
- }
-
- if (pixelData != NULL)
- {
- gl::Error error = image->loadCompressedData(xoffset, yoffset, zoffset, width, height, depth, pixelData);
- if (error.isError())
- {
- return error;
- }
-
- mDirtyImages = true;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-bool TextureD3D::isFastUnpackable(const gl::PixelUnpackState &unpack, GLenum sizedInternalFormat)
-{
- return unpack.pixelBuffer.id() != 0 && mRenderer->supportsFastCopyBufferToTexture(sizedInternalFormat);
-}
-
-gl::Error TextureD3D::fastUnpackPixels(const gl::PixelUnpackState &unpack, const void *pixels, const gl::Box &destArea,
- GLenum sizedInternalFormat, GLenum type, RenderTarget *destRenderTarget)
-{
- // No-op
- if (destArea.width <= 0 && destArea.height <= 0 && destArea.depth <= 0)
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- // In order to perform the fast copy through the shader, we must have the right format, and be able
- // to create a render target.
- ASSERT(mRenderer->supportsFastCopyBufferToTexture(sizedInternalFormat));
-
- uintptr_t offset = reinterpret_cast<uintptr_t>(pixels);
-
- gl::Error error = mRenderer->fastCopyBufferToTexture(unpack, offset, destRenderTarget, sizedInternalFormat, type, destArea);
- if (error.isError())
- {
- return error;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-GLint TextureD3D::creationLevels(GLsizei width, GLsizei height, GLsizei depth) const
-{
- if ((gl::isPow2(width) && gl::isPow2(height) && gl::isPow2(depth)) || mRenderer->getRendererExtensions().textureNPOT)
- {
- // Maximum number of levels
- return gl::log2(std::max(std::max(width, height), depth)) + 1;
- }
- else
- {
- // OpenGL ES 2.0 without GL_OES_texture_npot does not permit NPOT mipmaps.
- return 1;
- }
-}
-
-int TextureD3D::mipLevels() const
-{
- return gl::log2(std::max(std::max(getBaseLevelWidth(), getBaseLevelHeight()), getBaseLevelDepth())) + 1;
-}
-
-TextureStorage *TextureD3D::getStorage()
-{
- ASSERT(mTexStorage);
- return mTexStorage;
-}
-
-Image *TextureD3D::getBaseLevelImage() const
-{
- return getImage(getImageIndex(0, 0));
-}
-
-gl::Error TextureD3D::generateMipmaps()
-{
- GLint mipCount = mipLevels();
-
- if (mipCount == 1)
- {
- return gl::Error(GL_NO_ERROR); // no-op
- }
-
- // Set up proper mipmap chain in our Image array.
- initMipmapsImages();
-
- // We know that all layers have the same dimension, for the texture to be complete
- GLint layerCount = static_cast<GLint>(getLayerCount(0));
-
- // When making mipmaps with the setData workaround enabled, the texture storage has
- // the image data already. For non-render-target storage, we have to pull it out into
- // an image layer.
- if (mRenderer->getWorkarounds().setDataFasterThanImageUpload && mTexStorage)
- {
- if (!mTexStorage->isRenderTarget())
- {
- // Copy from the storage mip 0 to Image mip 0
- for (GLint layer = 0; layer < layerCount; ++layer)
- {
- gl::ImageIndex srcIndex = getImageIndex(0, layer);
-
- Image *image = getImage(srcIndex);
- gl::Rectangle area(0, 0, image->getWidth(), image->getHeight());
- gl::Error error = image->copy(0, 0, 0, area, srcIndex, mTexStorage);
- if (error.isError())
- {
- return error;
- }
- }
- }
- else
- {
- gl::Error error = updateStorage();
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- bool renderableStorage = (mTexStorage && mTexStorage->isRenderTarget());
-
- for (GLint layer = 0; layer < layerCount; ++layer)
- {
- for (GLint mip = 1; mip < mipCount; ++mip)
- {
- ASSERT(getLayerCount(mip) == layerCount);
-
- gl::ImageIndex sourceIndex = getImageIndex(mip - 1, layer);
- gl::ImageIndex destIndex = getImageIndex(mip, layer);
-
- if (renderableStorage)
- {
- // GPU-side mipmapping
- gl::Error error = mTexStorage->generateMipmap(sourceIndex, destIndex);
- if (error.isError())
- {
- return error;
- }
- }
- else
- {
- // CPU-side mipmapping
- gl::Error error = mRenderer->generateMipmap(getImage(destIndex), getImage(sourceIndex));
- if (error.isError())
- {
- return error;
- }
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-bool TextureD3D::isBaseImageZeroSize() const
-{
- Image *baseImage = getBaseLevelImage();
-
- if (!baseImage || baseImage->getWidth() <= 0)
- {
- return true;
- }
-
- if (!gl::IsCubemapTextureTarget(baseImage->getTarget()) && baseImage->getHeight() <= 0)
- {
- return true;
- }
-
- if (baseImage->getTarget() == GL_TEXTURE_3D && baseImage->getDepth() <= 0)
- {
- return true;
- }
-
- if (baseImage->getTarget() == GL_TEXTURE_2D_ARRAY && getLayerCount(0) <= 0)
- {
- return true;
- }
-
- return false;
-}
-
-gl::Error TextureD3D::ensureRenderTarget()
-{
- gl::Error error = initializeStorage(true);
- if (error.isError())
- {
- return error;
- }
-
- if (!isBaseImageZeroSize())
- {
- ASSERT(mTexStorage);
- if (!mTexStorage->isRenderTarget())
- {
- TextureStorage *newRenderTargetStorage = NULL;
- error = createCompleteStorage(true, &newRenderTargetStorage);
- if (error.isError())
- {
- return error;
- }
-
- error = mTexStorage->copyToStorage(newRenderTargetStorage);
- if (error.isError())
- {
- SafeDelete(newRenderTargetStorage);
- return error;
- }
-
- error = setCompleteTexStorage(newRenderTargetStorage);
- if (error.isError())
- {
- SafeDelete(newRenderTargetStorage);
- return error;
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-bool TextureD3D::canCreateRenderTargetForImage(const gl::ImageIndex &index) const
-{
- Image *image = getImage(index);
- bool levelsComplete = (isImageComplete(index) && isImageComplete(getImageIndex(0, 0)));
- return (image->isRenderableFormat() && levelsComplete);
-}
-
-gl::Error TextureD3D::commitRegion(const gl::ImageIndex &index, const gl::Box &region)
-{
- if (mTexStorage)
- {
- ASSERT(isValidIndex(index));
- Image *image = getImage(index);
- ImageD3D *imageD3D = ImageD3D::makeImageD3D(image);
- gl::Error error = imageD3D->copyToStorage(mTexStorage, index, region);
- if (error.isError())
- {
- return error;
- }
-
- image->markClean();
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-TextureD3D_2D::TextureD3D_2D(RendererD3D *renderer)
- : TextureD3D(renderer)
-{
- for (int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++i)
- {
- mImageArray[i] = ImageD3D::makeImageD3D(renderer->createImage());
- }
-}
-
-TextureD3D_2D::~TextureD3D_2D()
-{
- // Delete the Images before the TextureStorage.
- // Images might be relying on the TextureStorage for some of their data.
- // If TextureStorage is deleted before the Images, then their data will be wastefully copied back from the GPU before we delete the Images.
- for (int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++i)
- {
- delete mImageArray[i];
- }
-
- SafeDelete(mTexStorage);
-}
-
-Image *TextureD3D_2D::getImage(int level, int layer) const
-{
- ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- ASSERT(layer == 0);
- return mImageArray[level];
-}
-
-Image *TextureD3D_2D::getImage(const gl::ImageIndex &index) const
-{
- ASSERT(index.mipIndex < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- ASSERT(!index.hasLayer());
- ASSERT(index.type == GL_TEXTURE_2D);
- return mImageArray[index.mipIndex];
-}
-
-GLsizei TextureD3D_2D::getLayerCount(int level) const
-{
- ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- return 1;
-}
-
-GLsizei TextureD3D_2D::getWidth(GLint level) const
-{
- if (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mImageArray[level]->getWidth();
- else
- return 0;
-}
-
-GLsizei TextureD3D_2D::getHeight(GLint level) const
-{
- if (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mImageArray[level]->getHeight();
- else
- return 0;
-}
-
-GLenum TextureD3D_2D::getInternalFormat(GLint level) const
-{
- if (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mImageArray[level]->getInternalFormat();
- else
- return GL_NONE;
-}
-
-GLenum TextureD3D_2D::getActualFormat(GLint level) const
-{
- if (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mImageArray[level]->getActualFormat();
- else
- return GL_NONE;
-}
-
-bool TextureD3D_2D::isDepth(GLint level) const
-{
- return gl::GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0;
-}
-
-gl::Error TextureD3D_2D::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth,
- GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack,
- const void *pixels)
-{
- ASSERT(target == GL_TEXTURE_2D && depth == 1);
-
- GLenum sizedInternalFormat = gl::GetSizedInternalFormat(internalFormat, type);
-
- bool fastUnpacked = false;
-
- redefineImage(level, sizedInternalFormat, width, height);
-
- gl::ImageIndex index = gl::ImageIndex::Make2D(level);
-
- // Attempt a fast gpu copy of the pixel data to the surface
- if (isFastUnpackable(unpack, sizedInternalFormat) && isLevelComplete(level))
- {
- // Will try to create RT storage if it does not exist
- RenderTarget *destRenderTarget = NULL;
- gl::Error error = getRenderTarget(index, &destRenderTarget);
- if (error.isError())
- {
- return error;
- }
-
- gl::Box destArea(0, 0, 0, getWidth(level), getHeight(level), 1);
-
- error = fastUnpackPixels(unpack, pixels, destArea, sizedInternalFormat, type, destRenderTarget);
- if (error.isError())
- {
- return error;
- }
-
- // Ensure we don't overwrite our newly initialized data
- mImageArray[level]->markClean();
-
- fastUnpacked = true;
- }
-
- if (!fastUnpacked)
- {
- gl::Error error = TextureD3D::setImage(unpack, type, pixels, index);
- if (error.isError())
- {
- return error;
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_2D::setCompressedImage(GLenum target, GLint level, GLenum format,
- GLsizei width, GLsizei height, GLsizei depth,
- GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels)
-{
- ASSERT(target == GL_TEXTURE_2D && depth == 1);
-
- // compressed formats don't have separate sized internal formats-- we can just use the compressed format directly
- redefineImage(level, format, width, height);
-
- return TextureD3D::setCompressedImage(unpack, imageSize, pixels, mImageArray[level]);
-}
-
-gl::Error TextureD3D_2D::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type,
- const gl::PixelUnpackState &unpack, const void *pixels)
-{
- ASSERT(target == GL_TEXTURE_2D && depth == 1 && zoffset == 0);
-
- bool fastUnpacked = false;
-
- gl::ImageIndex index = gl::ImageIndex::Make2D(level);
- gl::Box destArea(xoffset, yoffset, 0, width, height, 1);
- if (isFastUnpackable(unpack, getInternalFormat(level)) && isLevelComplete(level))
- {
- RenderTarget *renderTarget = NULL;
- gl::Error error = getRenderTarget(index, &renderTarget);
- if (error.isError())
- {
- return error;
- }
-
- error = fastUnpackPixels(unpack, pixels, destArea, getInternalFormat(level), type, renderTarget);
- if (error.isError())
- {
- return error;
- }
-
- // Ensure we don't overwrite our newly initialized data
- mImageArray[level]->markClean();
-
- fastUnpacked = true;
- }
-
- if (!fastUnpacked)
- {
- return TextureD3D::subImage(xoffset, yoffset, 0, width, height, 1, format, type,
- unpack, pixels, index);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_2D::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth, GLenum format,
- GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels)
-{
- ASSERT(target == GL_TEXTURE_2D && depth == 1 && zoffset == 0);
-
- gl::Error error = TextureD3D::subImageCompressed(xoffset, yoffset, 0, width, height, 1, format, imageSize, unpack, pixels, mImageArray[level]);
- if (error.isError())
- {
- return error;
- }
-
- gl::ImageIndex index = gl::ImageIndex::Make2D(level);
- gl::Box region(xoffset, yoffset, 0, width, height, 1);
- return commitRegion(index, region);
-}
-
-gl::Error TextureD3D_2D::copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height,
- gl::Framebuffer *source)
-{
- ASSERT(target == GL_TEXTURE_2D);
-
- GLenum sizedInternalFormat = gl::GetSizedInternalFormat(format, GL_UNSIGNED_BYTE);
- redefineImage(level, sizedInternalFormat, width, height);
-
- gl::Rectangle sourceRect(x, y, width, height);
- gl::ImageIndex index = gl::ImageIndex::Make2D(level);
-
- if (!canCreateRenderTargetForImage(index))
- {
- gl::Error error = mImageArray[level]->copy(0, 0, 0, sourceRect, source);
- if (error.isError())
- {
- return error;
- }
-
- mDirtyImages = true;
- }
- else
- {
- gl::Error error = ensureRenderTarget();
- if (error.isError())
- {
- return error;
- }
-
- mImageArray[level]->markClean();
-
- if (width != 0 && height != 0 && isValidLevel(level))
- {
- gl::Error error = mRenderer->copyImage2D(source, sourceRect, format, 0, 0, mTexStorage, level);
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
- GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source)
-{
- ASSERT(target == GL_TEXTURE_2D && zoffset == 0);
-
- // can only make our texture storage to a render target if level 0 is defined (with a width & height) and
- // the current level we're copying to is defined (with appropriate format, width & height)
-
- gl::Rectangle sourceRect(x, y, width, height);
- gl::ImageIndex index = gl::ImageIndex::Make2D(level);
-
- if (!canCreateRenderTargetForImage(index))
- {
- gl::Error error = mImageArray[level]->copy(xoffset, yoffset, 0, sourceRect, source);
- if (error.isError())
- {
- return error;
- }
-
- mDirtyImages = true;
- }
- else
- {
- gl::Error error = ensureRenderTarget();
- if (error.isError())
- {
- return error;
- }
-
- if (isValidLevel(level))
- {
- error = updateStorageLevel(level);
- if (error.isError())
- {
- return error;
- }
-
- error = mRenderer->copyImage2D(source, sourceRect,
- gl::GetInternalFormatInfo(getBaseLevelInternalFormat()).format,
- xoffset, yoffset, mTexStorage, level);
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_2D::storage(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
-{
- ASSERT(target == GL_TEXTURE_2D && depth == 1);
-
- for (int level = 0; level < levels; level++)
- {
- GLsizei levelWidth = std::max(1, width >> level);
- GLsizei levelHeight = std::max(1, height >> level);
- mImageArray[level]->redefine(mRenderer, GL_TEXTURE_2D, internalformat, levelWidth, levelHeight, 1, true);
- }
-
- for (int level = levels; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
- {
- mImageArray[level]->redefine(mRenderer, GL_TEXTURE_2D, GL_NONE, 0, 0, 0, true);
- }
-
- // TODO(geofflang): Verify storage creation had no errors
- bool renderTarget = IsRenderTargetUsage(mUsage);
- TextureStorage *storage = mRenderer->createTextureStorage2D(internalformat, renderTarget, width, height, levels);
-
- gl::Error error = setCompleteTexStorage(storage);
- if (error.isError())
- {
- SafeDelete(storage);
- return error;
- }
-
- mImmutable = true;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void TextureD3D_2D::bindTexImage(egl::Surface *surface)
-{
- GLenum internalformat = surface->getFormat();
-
- mImageArray[0]->redefine(mRenderer, GL_TEXTURE_2D, internalformat, surface->getWidth(), surface->getHeight(), 1, true);
-
- if (mTexStorage)
- {
- SafeDelete(mTexStorage);
- }
-
- mTexStorage = mRenderer->createTextureStorage2D(surface->getSwapChain());
-
- mDirtyImages = true;
-}
-
-void TextureD3D_2D::releaseTexImage()
-{
- if (mTexStorage)
- {
- SafeDelete(mTexStorage);
- }
-
- for (int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
- {
- mImageArray[i]->redefine(mRenderer, GL_TEXTURE_2D, GL_NONE, 0, 0, 0, true);
- }
-}
-
-void TextureD3D_2D::initMipmapsImages()
-{
- // Purge array levels 1 through q and reset them to represent the generated mipmap levels.
- int levelCount = mipLevels();
- for (int level = 1; level < levelCount; level++)
- {
- redefineImage(level, getBaseLevelInternalFormat(),
- std::max(getBaseLevelWidth() >> level, 1),
- std::max(getBaseLevelHeight() >> level, 1));
- }
-}
-
-unsigned int TextureD3D_2D::getRenderTargetSerial(const gl::ImageIndex &index)
-{
- ASSERT(!index.hasLayer());
- return (!ensureRenderTarget().isError() ? mTexStorage->getRenderTargetSerial(index) : 0);
-}
-
-gl::Error TextureD3D_2D::getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT)
-{
- ASSERT(!index.hasLayer());
-
- // ensure the underlying texture is created
- gl::Error error = ensureRenderTarget();
- if (error.isError())
- {
- return error;
- }
-
- error = updateStorageLevel(index.mipIndex);
- if (error.isError())
- {
- return error;
- }
-
- return mTexStorage->getRenderTarget(index, outRT);
-}
-
-bool TextureD3D_2D::isValidLevel(int level) const
-{
- return (mTexStorage ? (level >= 0 && level < mTexStorage->getLevelCount()) : false);
-}
-
-bool TextureD3D_2D::isLevelComplete(int level) const
-{
- if (isImmutable())
- {
- return true;
- }
-
- const Image *baseImage = getBaseLevelImage();
-
- GLsizei width = baseImage->getWidth();
- GLsizei height = baseImage->getHeight();
-
- if (width <= 0 || height <= 0)
- {
- return false;
- }
-
- // The base image level is complete if the width and height are positive
- if (level == 0)
- {
- return true;
- }
-
- ASSERT(level >= 1 && level <= (int)ArraySize(mImageArray) && mImageArray[level] != NULL);
- ImageD3D *image = mImageArray[level];
-
- if (image->getInternalFormat() != baseImage->getInternalFormat())
- {
- return false;
- }
-
- if (image->getWidth() != std::max(1, width >> level))
- {
- return false;
- }
-
- if (image->getHeight() != std::max(1, height >> level))
- {
- return false;
- }
-
- return true;
-}
-
-bool TextureD3D_2D::isImageComplete(const gl::ImageIndex &index) const
-{
- return isLevelComplete(index.mipIndex);
-}
-
-// Constructs a native texture resource from the texture images
-gl::Error TextureD3D_2D::initializeStorage(bool renderTarget)
-{
- // Only initialize the first time this texture is used as a render target or shader resource
- if (mTexStorage)
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- // do not attempt to create storage for nonexistant data
- if (!isLevelComplete(0))
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- bool createRenderTarget = (renderTarget || IsRenderTargetUsage(mUsage));
-
- TextureStorage *storage = NULL;
- gl::Error error = createCompleteStorage(createRenderTarget, &storage);
- if (error.isError())
- {
- return error;
- }
-
- error = setCompleteTexStorage(storage);
- if (error.isError())
- {
- SafeDelete(storage);
- return error;
- }
-
- ASSERT(mTexStorage);
-
- // flush image data to the storage
- error = updateStorage();
- if (error.isError())
- {
- return error;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_2D::createCompleteStorage(bool renderTarget, TextureStorage **outTexStorage) const
-{
- GLsizei width = getBaseLevelWidth();
- GLsizei height = getBaseLevelHeight();
- GLenum internalFormat = getBaseLevelInternalFormat();
-
- ASSERT(width > 0 && height > 0);
-
- // use existing storage level count, when previously specified by TexStorage*D
- GLint levels = (mTexStorage ? mTexStorage->getLevelCount() : creationLevels(width, height, 1));
-
- // TODO(geofflang): Determine if the texture creation succeeded
- *outTexStorage = mRenderer->createTextureStorage2D(internalFormat, renderTarget, width, height, levels);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_2D::setCompleteTexStorage(TextureStorage *newCompleteTexStorage)
-{
- if (newCompleteTexStorage && newCompleteTexStorage->isManaged())
- {
- for (int level = 0; level < newCompleteTexStorage->getLevelCount(); level++)
- {
- gl::Error error = mImageArray[level]->setManagedSurface2D(newCompleteTexStorage, level);
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- SafeDelete(mTexStorage);
- mTexStorage = newCompleteTexStorage;
-
- mDirtyImages = true;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_2D::updateStorage()
-{
- ASSERT(mTexStorage != NULL);
- GLint storageLevels = mTexStorage->getLevelCount();
- for (int level = 0; level < storageLevels; level++)
- {
- if (mImageArray[level]->isDirty() && isLevelComplete(level))
- {
- gl::Error error = updateStorageLevel(level);
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_2D::updateStorageLevel(int level)
-{
- ASSERT(level <= (int)ArraySize(mImageArray) && mImageArray[level] != NULL);
- ASSERT(isLevelComplete(level));
-
- if (mImageArray[level]->isDirty())
- {
- gl::ImageIndex index = gl::ImageIndex::Make2D(level);
- gl::Box region(0, 0, 0, getWidth(level), getHeight(level), 1);
- gl::Error error = commitRegion(index, region);
- if (error.isError())
- {
- return error;
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void TextureD3D_2D::redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height)
-{
- // If there currently is a corresponding storage texture image, it has these parameters
- const int storageWidth = std::max(1, getBaseLevelWidth() >> level);
- const int storageHeight = std::max(1, getBaseLevelHeight() >> level);
- const GLenum storageFormat = getBaseLevelInternalFormat();
-
- mImageArray[level]->redefine(mRenderer, GL_TEXTURE_2D, internalformat, width, height, 1, false);
-
- if (mTexStorage)
- {
- const int storageLevels = mTexStorage->getLevelCount();
-
- if ((level >= storageLevels && storageLevels != 0) ||
- width != storageWidth ||
- height != storageHeight ||
- internalformat != storageFormat) // Discard mismatched storage
- {
- for (int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
- {
- mImageArray[i]->markDirty();
- }
-
- SafeDelete(mTexStorage);
- mDirtyImages = true;
- }
- }
-}
-
-gl::ImageIndexIterator TextureD3D_2D::imageIterator() const
-{
- return gl::ImageIndexIterator::Make2D(0, mTexStorage->getLevelCount());
-}
-
-gl::ImageIndex TextureD3D_2D::getImageIndex(GLint mip, GLint /*layer*/) const
-{
- // "layer" does not apply to 2D Textures.
- return gl::ImageIndex::Make2D(mip);
-}
-
-bool TextureD3D_2D::isValidIndex(const gl::ImageIndex &index) const
-{
- return (mTexStorage && index.type == GL_TEXTURE_2D &&
- index.mipIndex >= 0 && index.mipIndex < mTexStorage->getLevelCount());
-}
-
-TextureD3D_Cube::TextureD3D_Cube(RendererD3D *renderer)
- : TextureD3D(renderer)
-{
- for (int i = 0; i < 6; i++)
- {
- for (int j = 0; j < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++j)
- {
- mImageArray[i][j] = ImageD3D::makeImageD3D(renderer->createImage());
- }
- }
-}
-
-TextureD3D_Cube::~TextureD3D_Cube()
-{
- // Delete the Images before the TextureStorage.
- // Images might be relying on the TextureStorage for some of their data.
- // If TextureStorage is deleted before the Images, then their data will be wastefully copied back from the GPU before we delete the Images.
- for (int i = 0; i < 6; i++)
- {
- for (int j = 0; j < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++j)
- {
- SafeDelete(mImageArray[i][j]);
- }
- }
-
- SafeDelete(mTexStorage);
-}
-
-Image *TextureD3D_Cube::getImage(int level, int layer) const
-{
- ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- ASSERT(layer < 6);
- return mImageArray[layer][level];
-}
-
-Image *TextureD3D_Cube::getImage(const gl::ImageIndex &index) const
-{
- ASSERT(index.mipIndex < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- ASSERT(index.layerIndex < 6);
- return mImageArray[index.layerIndex][index.mipIndex];
-}
-
-GLsizei TextureD3D_Cube::getLayerCount(int level) const
-{
- ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- return 6;
-}
-
-GLenum TextureD3D_Cube::getInternalFormat(GLint level, GLint layer) const
-{
- if (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mImageArray[layer][level]->getInternalFormat();
- else
- return GL_NONE;
-}
-
-bool TextureD3D_Cube::isDepth(GLint level, GLint layer) const
-{
- return gl::GetInternalFormatInfo(getInternalFormat(level, layer)).depthBits > 0;
-}
-
-gl::Error TextureD3D_Cube::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth,
- GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack,
- const void *pixels)
-{
- ASSERT(depth == 1);
-
- GLenum sizedInternalFormat = gl::GetSizedInternalFormat(internalFormat, type);
- gl::ImageIndex index = gl::ImageIndex::MakeCube(target, level);
-
- redefineImage(index.layerIndex, level, sizedInternalFormat, width, height);
-
- return TextureD3D::setImage(unpack, type, pixels, index);
-}
-
-gl::Error TextureD3D_Cube::setCompressedImage(GLenum target, GLint level, GLenum format,
- GLsizei width, GLsizei height, GLsizei depth,
- GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels)
-{
- ASSERT(depth == 1);
-
- // compressed formats don't have separate sized internal formats-- we can just use the compressed format directly
- int faceIndex = gl::TextureCubeMap::targetToLayerIndex(target);
-
- redefineImage(faceIndex, level, format, width, height);
-
- return TextureD3D::setCompressedImage(unpack, imageSize, pixels, mImageArray[faceIndex][level]);
-}
-
-gl::Error TextureD3D_Cube::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type,
- const gl::PixelUnpackState &unpack, const void *pixels)
-{
- ASSERT(depth == 1 && zoffset == 0);
- gl::ImageIndex index = gl::ImageIndex::MakeCube(target, level);
- return TextureD3D::subImage(xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels, index);
-}
-
-gl::Error TextureD3D_Cube::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth, GLenum format,
- GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels)
-{
- ASSERT(depth == 1 && zoffset == 0);
-
- gl::ImageIndex index = gl::ImageIndex::MakeCube(target, level);
-
- gl::Error error = TextureD3D::subImageCompressed(xoffset, yoffset, 0, width, height, 1, format, imageSize, unpack, pixels, mImageArray[index.layerIndex][level]);
- if (error.isError())
- {
- return error;
- }
-
- gl::Box region(xoffset, yoffset, 0, width, height, 1);
- return commitRegion(index, region);
-}
-
-gl::Error TextureD3D_Cube::copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y,
- GLsizei width, GLsizei height, gl::Framebuffer *source)
-{
- int faceIndex = gl::TextureCubeMap::targetToLayerIndex(target);
- GLenum sizedInternalFormat = gl::GetSizedInternalFormat(format, GL_UNSIGNED_BYTE);
-
- redefineImage(faceIndex, level, sizedInternalFormat, width, height);
-
- gl::Rectangle sourceRect(x, y, width, height);
- gl::ImageIndex index = gl::ImageIndex::MakeCube(target, level);
-
- if (!canCreateRenderTargetForImage(index))
- {
- gl::Error error = mImageArray[faceIndex][level]->copy(0, 0, 0, sourceRect, source);
- if (error.isError())
- {
- return error;
- }
-
- mDirtyImages = true;
- }
- else
- {
- gl::Error error = ensureRenderTarget();
- if (error.isError())
- {
- return error;
- }
-
- mImageArray[faceIndex][level]->markClean();
-
- ASSERT(width == height);
-
- if (width > 0 && isValidFaceLevel(faceIndex, level))
- {
- error = mRenderer->copyImageCube(source, sourceRect, format, 0, 0, mTexStorage, target, level);
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_Cube::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
- GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source)
-{
- int faceIndex = gl::TextureCubeMap::targetToLayerIndex(target);
-
- gl::Rectangle sourceRect(x, y, width, height);
- gl::ImageIndex index = gl::ImageIndex::MakeCube(target, level);
-
- if (!canCreateRenderTargetForImage(index))
- {
- gl::Error error =mImageArray[faceIndex][level]->copy(0, 0, 0, sourceRect, source);
- if (error.isError())
- {
- return error;
- }
-
- mDirtyImages = true;
- }
- else
- {
- gl::Error error = ensureRenderTarget();
- if (error.isError())
- {
- return error;
- }
-
- if (isValidFaceLevel(faceIndex, level))
- {
- error = updateStorageFaceLevel(faceIndex, level);
- if (error.isError())
- {
- return error;
- }
-
- error = mRenderer->copyImageCube(source, sourceRect, gl::GetInternalFormatInfo(getBaseLevelInternalFormat()).format,
- xoffset, yoffset, mTexStorage, target, level);
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_Cube::storage(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
-{
- ASSERT(width == height);
- ASSERT(depth == 1);
-
- for (int level = 0; level < levels; level++)
- {
- GLsizei mipSize = std::max(1, width >> level);
- for (int faceIndex = 0; faceIndex < 6; faceIndex++)
- {
- mImageArray[faceIndex][level]->redefine(mRenderer, GL_TEXTURE_CUBE_MAP, internalformat, mipSize, mipSize, 1, true);
- }
- }
-
- for (int level = levels; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
- {
- for (int faceIndex = 0; faceIndex < 6; faceIndex++)
- {
- mImageArray[faceIndex][level]->redefine(mRenderer, GL_TEXTURE_CUBE_MAP, GL_NONE, 0, 0, 0, true);
- }
- }
-
- // TODO(geofflang): Verify storage creation had no errors
- bool renderTarget = IsRenderTargetUsage(mUsage);
- TextureStorage *storage = mRenderer->createTextureStorageCube(internalformat, renderTarget, width, levels);
-
- gl::Error error = setCompleteTexStorage(storage);
- if (error.isError())
- {
- SafeDelete(storage);
- return error;
- }
-
- mImmutable = true;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-// Tests for cube texture completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
-bool TextureD3D_Cube::isCubeComplete() const
-{
- int baseWidth = getBaseLevelWidth();
- int baseHeight = getBaseLevelHeight();
- GLenum baseFormat = getBaseLevelInternalFormat();
-
- if (baseWidth <= 0 || baseWidth != baseHeight)
- {
- return false;
- }
-
- for (int faceIndex = 1; faceIndex < 6; faceIndex++)
- {
- const ImageD3D &faceBaseImage = *mImageArray[faceIndex][0];
-
- if (faceBaseImage.getWidth() != baseWidth ||
- faceBaseImage.getHeight() != baseHeight ||
- faceBaseImage.getInternalFormat() != baseFormat )
- {
- return false;
- }
- }
-
- return true;
-}
-
-void TextureD3D_Cube::bindTexImage(egl::Surface *surface)
-{
- UNREACHABLE();
-}
-
-void TextureD3D_Cube::releaseTexImage()
-{
- UNREACHABLE();
-}
-
-
-void TextureD3D_Cube::initMipmapsImages()
-{
- // Purge array levels 1 through q and reset them to represent the generated mipmap levels.
- int levelCount = mipLevels();
- for (int faceIndex = 0; faceIndex < 6; faceIndex++)
- {
- for (int level = 1; level < levelCount; level++)
- {
- int faceLevelSize = (std::max(mImageArray[faceIndex][0]->getWidth() >> level, 1));
- redefineImage(faceIndex, level, mImageArray[faceIndex][0]->getInternalFormat(), faceLevelSize, faceLevelSize);
- }
- }
-}
-
-unsigned int TextureD3D_Cube::getRenderTargetSerial(const gl::ImageIndex &index)
-{
- return (ensureRenderTarget().isError() ? mTexStorage->getRenderTargetSerial(index) : 0);
-}
-
-gl::Error TextureD3D_Cube::getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT)
-{
- ASSERT(gl::IsCubemapTextureTarget(index.type));
-
- // ensure the underlying texture is created
- gl::Error error = ensureRenderTarget();
- if (error.isError())
- {
- return error;
- }
-
- error = updateStorageFaceLevel(index.layerIndex, index.mipIndex);
- if (error.isError())
- {
- return error;
- }
-
- return mTexStorage->getRenderTarget(index, outRT);
-}
-
-gl::Error TextureD3D_Cube::initializeStorage(bool renderTarget)
-{
- // Only initialize the first time this texture is used as a render target or shader resource
- if (mTexStorage)
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- // do not attempt to create storage for nonexistant data
- if (!isFaceLevelComplete(0, 0))
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- bool createRenderTarget = (renderTarget || IsRenderTargetUsage(mUsage));
-
- TextureStorage *storage = NULL;
- gl::Error error = createCompleteStorage(createRenderTarget, &storage);
- if (error.isError())
- {
- return error;
- }
-
- error = setCompleteTexStorage(storage);
- if (error.isError())
- {
- SafeDelete(storage);
- return error;
- }
-
- ASSERT(mTexStorage);
-
- // flush image data to the storage
- error = updateStorage();
- if (error.isError())
- {
- return error;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_Cube::createCompleteStorage(bool renderTarget, TextureStorage **outTexStorage) const
-{
- GLsizei size = getBaseLevelWidth();
-
- ASSERT(size > 0);
-
- // use existing storage level count, when previously specified by TexStorage*D
- GLint levels = (mTexStorage ? mTexStorage->getLevelCount() : creationLevels(size, size, 1));
-
- // TODO (geofflang): detect if storage creation succeeded
- *outTexStorage = mRenderer->createTextureStorageCube(getBaseLevelInternalFormat(), renderTarget, size, levels);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_Cube::setCompleteTexStorage(TextureStorage *newCompleteTexStorage)
-{
- if (newCompleteTexStorage && newCompleteTexStorage->isManaged())
- {
- for (int faceIndex = 0; faceIndex < 6; faceIndex++)
- {
- for (int level = 0; level < newCompleteTexStorage->getLevelCount(); level++)
- {
- gl::Error error = mImageArray[faceIndex][level]->setManagedSurfaceCube(newCompleteTexStorage, faceIndex, level);
- if (error.isError())
- {
- return error;
- }
- }
- }
- }
-
- SafeDelete(mTexStorage);
- mTexStorage = newCompleteTexStorage;
-
- mDirtyImages = true;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_Cube::updateStorage()
-{
- ASSERT(mTexStorage != NULL);
- GLint storageLevels = mTexStorage->getLevelCount();
- for (int face = 0; face < 6; face++)
- {
- for (int level = 0; level < storageLevels; level++)
- {
- if (mImageArray[face][level]->isDirty() && isFaceLevelComplete(face, level))
- {
- gl::Error error = updateStorageFaceLevel(face, level);
- if (error.isError())
- {
- return error;
- }
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-bool TextureD3D_Cube::isValidFaceLevel(int faceIndex, int level) const
-{
- return (mTexStorage ? (level >= 0 && level < mTexStorage->getLevelCount()) : 0);
-}
-
-bool TextureD3D_Cube::isFaceLevelComplete(int faceIndex, int level) const
-{
- ASSERT(level >= 0 && faceIndex < 6 && level < (int)ArraySize(mImageArray[faceIndex]) && mImageArray[faceIndex][level] != NULL);
-
- if (isImmutable())
- {
- return true;
- }
-
- int baseSize = getBaseLevelWidth();
-
- if (baseSize <= 0)
- {
- return false;
- }
-
- // "isCubeComplete" checks for base level completeness and we must call that
- // to determine if any face at level 0 is complete. We omit that check here
- // to avoid re-checking cube-completeness for every face at level 0.
- if (level == 0)
- {
- return true;
- }
-
- // Check that non-zero levels are consistent with the base level.
- const ImageD3D *faceLevelImage = mImageArray[faceIndex][level];
-
- if (faceLevelImage->getInternalFormat() != getBaseLevelInternalFormat())
- {
- return false;
- }
-
- if (faceLevelImage->getWidth() != std::max(1, baseSize >> level))
- {
- return false;
- }
-
- return true;
-}
-
-bool TextureD3D_Cube::isImageComplete(const gl::ImageIndex &index) const
-{
- return isFaceLevelComplete(index.layerIndex, index.mipIndex);
-}
-
-gl::Error TextureD3D_Cube::updateStorageFaceLevel(int faceIndex, int level)
-{
- ASSERT(level >= 0 && faceIndex < 6 && level < (int)ArraySize(mImageArray[faceIndex]) && mImageArray[faceIndex][level] != NULL);
- ImageD3D *image = mImageArray[faceIndex][level];
-
- if (image->isDirty())
- {
- GLenum faceTarget = gl::TextureCubeMap::layerIndexToTarget(faceIndex);
- gl::ImageIndex index = gl::ImageIndex::MakeCube(faceTarget, level);
- gl::Box region(0, 0, 0, image->getWidth(), image->getHeight(), 1);
- gl::Error error = commitRegion(index, region);
- if (error.isError())
- {
- return error;
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void TextureD3D_Cube::redefineImage(int faceIndex, GLint level, GLenum internalformat, GLsizei width, GLsizei height)
-{
- // If there currently is a corresponding storage texture image, it has these parameters
- const int storageWidth = std::max(1, getBaseLevelWidth() >> level);
- const int storageHeight = std::max(1, getBaseLevelHeight() >> level);
- const GLenum storageFormat = getBaseLevelInternalFormat();
-
- mImageArray[faceIndex][level]->redefine(mRenderer, GL_TEXTURE_CUBE_MAP, internalformat, width, height, 1, false);
-
- if (mTexStorage)
- {
- const int storageLevels = mTexStorage->getLevelCount();
-
- if ((level >= storageLevels && storageLevels != 0) ||
- width != storageWidth ||
- height != storageHeight ||
- internalformat != storageFormat) // Discard mismatched storage
- {
- for (int level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
- {
- for (int faceIndex = 0; faceIndex < 6; faceIndex++)
- {
- mImageArray[faceIndex][level]->markDirty();
- }
- }
-
- SafeDelete(mTexStorage);
-
- mDirtyImages = true;
- }
- }
-}
-
-gl::ImageIndexIterator TextureD3D_Cube::imageIterator() const
-{
- return gl::ImageIndexIterator::MakeCube(0, mTexStorage->getLevelCount());
-}
-
-gl::ImageIndex TextureD3D_Cube::getImageIndex(GLint mip, GLint layer) const
-{
- // The "layer" of the image index corresponds to the cube face
- return gl::ImageIndex::MakeCube(gl::TextureCubeMap::layerIndexToTarget(layer), mip);
-}
-
-bool TextureD3D_Cube::isValidIndex(const gl::ImageIndex &index) const
-{
- return (mTexStorage && gl::IsCubemapTextureTarget(index.type) &&
- index.mipIndex >= 0 && index.mipIndex < mTexStorage->getLevelCount());
-}
-
-TextureD3D_3D::TextureD3D_3D(RendererD3D *renderer)
- : TextureD3D(renderer)
-{
- for (int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++i)
- {
- mImageArray[i] = ImageD3D::makeImageD3D(renderer->createImage());
- }
-}
-
-TextureD3D_3D::~TextureD3D_3D()
-{
- // Delete the Images before the TextureStorage.
- // Images might be relying on the TextureStorage for some of their data.
- // If TextureStorage is deleted before the Images, then their data will be wastefully copied back from the GPU before we delete the Images.
- for (int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++i)
- {
- delete mImageArray[i];
- }
-
- SafeDelete(mTexStorage);
-}
-
-Image *TextureD3D_3D::getImage(int level, int layer) const
-{
- ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- ASSERT(layer == 0);
- return mImageArray[level];
-}
-
-Image *TextureD3D_3D::getImage(const gl::ImageIndex &index) const
-{
- ASSERT(index.mipIndex < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- ASSERT(!index.hasLayer());
- ASSERT(index.type == GL_TEXTURE_3D);
- return mImageArray[index.mipIndex];
-}
-
-GLsizei TextureD3D_3D::getLayerCount(int level) const
-{
- ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- return 1;
-}
-
-GLsizei TextureD3D_3D::getWidth(GLint level) const
-{
- if (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mImageArray[level]->getWidth();
- else
- return 0;
-}
-
-GLsizei TextureD3D_3D::getHeight(GLint level) const
-{
- if (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mImageArray[level]->getHeight();
- else
- return 0;
-}
-
-GLsizei TextureD3D_3D::getDepth(GLint level) const
-{
- if (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mImageArray[level]->getDepth();
- else
- return 0;
-}
-
-GLenum TextureD3D_3D::getInternalFormat(GLint level) const
-{
- if (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- return mImageArray[level]->getInternalFormat();
- else
- return GL_NONE;
-}
-
-bool TextureD3D_3D::isDepth(GLint level) const
-{
- return gl::GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0;
-}
-
-gl::Error TextureD3D_3D::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth,
- GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack,
- const void *pixels)
-{
- ASSERT(target == GL_TEXTURE_3D);
- GLenum sizedInternalFormat = gl::GetSizedInternalFormat(internalFormat, type);
-
- redefineImage(level, sizedInternalFormat, width, height, depth);
-
- bool fastUnpacked = false;
-
- gl::ImageIndex index = gl::ImageIndex::Make3D(level);
-
- // Attempt a fast gpu copy of the pixel data to the surface if the app bound an unpack buffer
- if (isFastUnpackable(unpack, sizedInternalFormat))
- {
- // Will try to create RT storage if it does not exist
- RenderTarget *destRenderTarget = NULL;
- gl::Error error = getRenderTarget(index, &destRenderTarget);
- if (error.isError())
- {
- return error;
- }
-
- gl::Box destArea(0, 0, 0, getWidth(level), getHeight(level), getDepth(level));
-
- error = fastUnpackPixels(unpack, pixels, destArea, sizedInternalFormat, type, destRenderTarget);
- if (error.isError())
- {
- return error;
- }
-
- // Ensure we don't overwrite our newly initialized data
- mImageArray[level]->markClean();
-
- fastUnpacked = true;
- }
-
- if (!fastUnpacked)
- {
- gl::Error error = TextureD3D::setImage(unpack, type, pixels, index);
- if (error.isError())
- {
- return error;
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_3D::setCompressedImage(GLenum target, GLint level, GLenum format,
- GLsizei width, GLsizei height,GLsizei depth,
- GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels)
-{
- ASSERT(target == GL_TEXTURE_3D);
-
- // compressed formats don't have separate sized internal formats-- we can just use the compressed format directly
- redefineImage(level, format, width, height, depth);
-
- return TextureD3D::setCompressedImage(unpack, imageSize, pixels, mImageArray[level]);
-}
-
-gl::Error TextureD3D_3D::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type,
- const gl::PixelUnpackState &unpack, const void *pixels)
-{
- ASSERT(target == GL_TEXTURE_3D);
-
- bool fastUnpacked = false;
-
- gl::ImageIndex index = gl::ImageIndex::Make3D(level);
-
- // Attempt a fast gpu copy of the pixel data to the surface if the app bound an unpack buffer
- if (isFastUnpackable(unpack, getInternalFormat(level)))
- {
- RenderTarget *destRenderTarget = NULL;
- gl::Error error = getRenderTarget(index, &destRenderTarget);
- if (error.isError())
- {
- return error;
- }
-
- gl::Box destArea(xoffset, yoffset, zoffset, width, height, depth);
- error = fastUnpackPixels(unpack, pixels, destArea, getInternalFormat(level), type, destRenderTarget);
- if (error.isError())
- {
- return error;
- }
-
- // Ensure we don't overwrite our newly initialized data
- mImageArray[level]->markClean();
-
- fastUnpacked = true;
- }
-
- if (!fastUnpacked)
- {
- return TextureD3D::subImage(xoffset, yoffset, zoffset, width, height, depth, format, type,
- unpack, pixels, index);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_3D::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth, GLenum format,
- GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels)
-{
- ASSERT(target == GL_TEXTURE_3D);
-
- gl::Error error = TextureD3D::subImageCompressed(xoffset, yoffset, zoffset, width, height, depth,
- format, imageSize, unpack, pixels, mImageArray[level]);
- if (error.isError())
- {
- return error;
- }
-
- gl::ImageIndex index = gl::ImageIndex::Make3D(level);
- gl::Box region(xoffset, yoffset, zoffset, width, height, depth);
- return commitRegion(index, region);
-}
-
-gl::Error TextureD3D_3D::copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y,
- GLsizei width, GLsizei height, gl::Framebuffer *source)
-{
- UNIMPLEMENTED();
- return gl::Error(GL_INVALID_OPERATION, "Copying 3D textures is unimplemented.");
-}
-
-gl::Error TextureD3D_3D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
- GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source)
-{
- ASSERT(target == GL_TEXTURE_3D);
-
- gl::Rectangle sourceRect(x, y, width, height);
- gl::ImageIndex index = gl::ImageIndex::Make3D(level);
-
- if (canCreateRenderTargetForImage(index))
- {
- gl::Error error = mImageArray[level]->copy(xoffset, yoffset, zoffset, sourceRect, source);
- if (error.isError())
- {
- return error;
- }
-
- mDirtyImages = true;
- }
- else
- {
- gl::Error error = ensureRenderTarget();
- if (error.isError())
- {
- return error;
- }
-
- if (isValidLevel(level))
- {
- error = updateStorageLevel(level);
- if (error.isError())
- {
- return error;
- }
-
- error = mRenderer->copyImage3D(source, sourceRect,
- gl::GetInternalFormatInfo(getBaseLevelInternalFormat()).format,
- xoffset, yoffset, zoffset, mTexStorage, level);
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_3D::storage(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
-{
- ASSERT(target == GL_TEXTURE_3D);
-
- for (int level = 0; level < levels; level++)
- {
- GLsizei levelWidth = std::max(1, width >> level);
- GLsizei levelHeight = std::max(1, height >> level);
- GLsizei levelDepth = std::max(1, depth >> level);
- mImageArray[level]->redefine(mRenderer, GL_TEXTURE_3D, internalformat, levelWidth, levelHeight, levelDepth, true);
- }
-
- for (int level = levels; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
- {
- mImageArray[level]->redefine(mRenderer, GL_TEXTURE_3D, GL_NONE, 0, 0, 0, true);
- }
-
- // TODO(geofflang): Verify storage creation had no errors
- bool renderTarget = IsRenderTargetUsage(mUsage);
- TextureStorage *storage = mRenderer->createTextureStorage3D(internalformat, renderTarget, width, height, depth, levels);
-
- gl::Error error = setCompleteTexStorage(storage);
- if (error.isError())
- {
- SafeDelete(storage);
- return error;
- }
-
- mImmutable = true;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void TextureD3D_3D::bindTexImage(egl::Surface *surface)
-{
- UNREACHABLE();
-}
-
-void TextureD3D_3D::releaseTexImage()
-{
- UNREACHABLE();
-}
-
-
-void TextureD3D_3D::initMipmapsImages()
-{
- // Purge array levels 1 through q and reset them to represent the generated mipmap levels.
- int levelCount = mipLevels();
- for (int level = 1; level < levelCount; level++)
- {
- redefineImage(level, getBaseLevelInternalFormat(),
- std::max(getBaseLevelWidth() >> level, 1),
- std::max(getBaseLevelHeight() >> level, 1),
- std::max(getBaseLevelDepth() >> level, 1));
- }
-}
-
-unsigned int TextureD3D_3D::getRenderTargetSerial(const gl::ImageIndex &index)
-{
- return (!ensureRenderTarget().isError() ? mTexStorage->getRenderTargetSerial(index) : 0);
-}
-
-gl::Error TextureD3D_3D::getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT)
-{
- // ensure the underlying texture is created
- gl::Error error = ensureRenderTarget();
- if (error.isError())
- {
- return error;
- }
-
- if (index.hasLayer())
- {
- error = updateStorage();
- if (error.isError())
- {
- return error;
- }
- }
- else
- {
- error = updateStorageLevel(index.mipIndex);
- if (error.isError())
- {
- return error;
- }
- }
-
- return mTexStorage->getRenderTarget(index, outRT);
-}
-
-gl::Error TextureD3D_3D::initializeStorage(bool renderTarget)
-{
- // Only initialize the first time this texture is used as a render target or shader resource
- if (mTexStorage)
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- // do not attempt to create storage for nonexistant data
- if (!isLevelComplete(0))
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- bool createRenderTarget = (renderTarget || mUsage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
-
- TextureStorage *storage = NULL;
- gl::Error error = createCompleteStorage(createRenderTarget, &storage);
- if (error.isError())
- {
- return error;
- }
-
- error = setCompleteTexStorage(storage);
- if (error.isError())
- {
- SafeDelete(storage);
- return error;
- }
-
- ASSERT(mTexStorage);
-
- // flush image data to the storage
- error = updateStorage();
- if (error.isError())
- {
- return error;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_3D::createCompleteStorage(bool renderTarget, TextureStorage **outStorage) const
-{
- GLsizei width = getBaseLevelWidth();
- GLsizei height = getBaseLevelHeight();
- GLsizei depth = getBaseLevelDepth();
- GLenum internalFormat = getBaseLevelInternalFormat();
-
- ASSERT(width > 0 && height > 0 && depth > 0);
-
- // use existing storage level count, when previously specified by TexStorage*D
- GLint levels = (mTexStorage ? mTexStorage->getLevelCount() : creationLevels(width, height, depth));
-
- // TODO: Verify creation of the storage succeeded
- *outStorage = mRenderer->createTextureStorage3D(internalFormat, renderTarget, width, height, depth, levels);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_3D::setCompleteTexStorage(TextureStorage *newCompleteTexStorage)
-{
- SafeDelete(mTexStorage);
- mTexStorage = newCompleteTexStorage;
- mDirtyImages = true;
-
- // We do not support managed 3D storage, as that is D3D9/ES2-only
- ASSERT(!mTexStorage->isManaged());
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_3D::updateStorage()
-{
- ASSERT(mTexStorage != NULL);
- GLint storageLevels = mTexStorage->getLevelCount();
- for (int level = 0; level < storageLevels; level++)
- {
- if (mImageArray[level]->isDirty() && isLevelComplete(level))
- {
- gl::Error error = updateStorageLevel(level);
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-bool TextureD3D_3D::isValidLevel(int level) const
-{
- return (mTexStorage ? (level >= 0 && level < mTexStorage->getLevelCount()) : 0);
-}
-
-bool TextureD3D_3D::isLevelComplete(int level) const
-{
- ASSERT(level >= 0 && level < (int)ArraySize(mImageArray) && mImageArray[level] != NULL);
-
- if (isImmutable())
- {
- return true;
- }
-
- GLsizei width = getBaseLevelWidth();
- GLsizei height = getBaseLevelHeight();
- GLsizei depth = getBaseLevelDepth();
-
- if (width <= 0 || height <= 0 || depth <= 0)
- {
- return false;
- }
-
- if (level == 0)
- {
- return true;
- }
-
- ImageD3D *levelImage = mImageArray[level];
-
- if (levelImage->getInternalFormat() != getBaseLevelInternalFormat())
- {
- return false;
- }
-
- if (levelImage->getWidth() != std::max(1, width >> level))
- {
- return false;
- }
-
- if (levelImage->getHeight() != std::max(1, height >> level))
- {
- return false;
- }
-
- if (levelImage->getDepth() != std::max(1, depth >> level))
- {
- return false;
- }
-
- return true;
-}
-
-bool TextureD3D_3D::isImageComplete(const gl::ImageIndex &index) const
-{
- return isLevelComplete(index.mipIndex);
-}
-
-gl::Error TextureD3D_3D::updateStorageLevel(int level)
-{
- ASSERT(level >= 0 && level < (int)ArraySize(mImageArray) && mImageArray[level] != NULL);
- ASSERT(isLevelComplete(level));
-
- if (mImageArray[level]->isDirty())
- {
- gl::ImageIndex index = gl::ImageIndex::Make3D(level);
- gl::Box region(0, 0, 0, getWidth(level), getHeight(level), getDepth(level));
- gl::Error error = commitRegion(index, region);
- if (error.isError())
- {
- return error;
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void TextureD3D_3D::redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
-{
- // If there currently is a corresponding storage texture image, it has these parameters
- const int storageWidth = std::max(1, getBaseLevelWidth() >> level);
- const int storageHeight = std::max(1, getBaseLevelHeight() >> level);
- const int storageDepth = std::max(1, getBaseLevelDepth() >> level);
- const GLenum storageFormat = getBaseLevelInternalFormat();
-
- mImageArray[level]->redefine(mRenderer, GL_TEXTURE_3D, internalformat, width, height, depth, false);
-
- if (mTexStorage)
- {
- const int storageLevels = mTexStorage->getLevelCount();
-
- if ((level >= storageLevels && storageLevels != 0) ||
- width != storageWidth ||
- height != storageHeight ||
- depth != storageDepth ||
- internalformat != storageFormat) // Discard mismatched storage
- {
- for (int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
- {
- mImageArray[i]->markDirty();
- }
-
- SafeDelete(mTexStorage);
- mDirtyImages = true;
- }
- }
-}
-
-gl::ImageIndexIterator TextureD3D_3D::imageIterator() const
-{
- return gl::ImageIndexIterator::Make3D(0, mTexStorage->getLevelCount(),
- gl::ImageIndex::ENTIRE_LEVEL, gl::ImageIndex::ENTIRE_LEVEL);
-}
-
-gl::ImageIndex TextureD3D_3D::getImageIndex(GLint mip, GLint /*layer*/) const
-{
- // The "layer" here does not apply to 3D images. We use one Image per mip.
- return gl::ImageIndex::Make3D(mip);
-}
-
-bool TextureD3D_3D::isValidIndex(const gl::ImageIndex &index) const
-{
- return (mTexStorage && index.type == GL_TEXTURE_3D &&
- index.mipIndex >= 0 && index.mipIndex < mTexStorage->getLevelCount());
-}
-
-TextureD3D_2DArray::TextureD3D_2DArray(RendererD3D *renderer)
- : TextureD3D(renderer)
-{
- for (int level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++level)
- {
- mLayerCounts[level] = 0;
- mImageArray[level] = NULL;
- }
-}
-
-TextureD3D_2DArray::~TextureD3D_2DArray()
-{
- // Delete the Images before the TextureStorage.
- // Images might be relying on the TextureStorage for some of their data.
- // If TextureStorage is deleted before the Images, then their data will be wastefully copied back from the GPU before we delete the Images.
- deleteImages();
- SafeDelete(mTexStorage);
-}
-
-Image *TextureD3D_2DArray::getImage(int level, int layer) const
-{
- ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- ASSERT(layer < mLayerCounts[level]);
- return mImageArray[level][layer];
-}
-
-Image *TextureD3D_2DArray::getImage(const gl::ImageIndex &index) const
-{
- ASSERT(index.mipIndex < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- ASSERT(index.layerIndex < mLayerCounts[index.mipIndex]);
- ASSERT(index.type == GL_TEXTURE_2D_ARRAY);
- return mImageArray[index.mipIndex][index.layerIndex];
-}
-
-GLsizei TextureD3D_2DArray::getLayerCount(int level) const
-{
- ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- return mLayerCounts[level];
-}
-
-GLsizei TextureD3D_2DArray::getWidth(GLint level) const
-{
- return (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS && mLayerCounts[level] > 0) ? mImageArray[level][0]->getWidth() : 0;
-}
-
-GLsizei TextureD3D_2DArray::getHeight(GLint level) const
-{
- return (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS && mLayerCounts[level] > 0) ? mImageArray[level][0]->getHeight() : 0;
-}
-
-GLenum TextureD3D_2DArray::getInternalFormat(GLint level) const
-{
- return (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS && mLayerCounts[level] > 0) ? mImageArray[level][0]->getInternalFormat() : GL_NONE;
-}
-
-bool TextureD3D_2DArray::isDepth(GLint level) const
-{
- return gl::GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0;
-}
-
-gl::Error TextureD3D_2DArray::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth,
- GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack,
- const void *pixels)
-{
- ASSERT(target == GL_TEXTURE_2D_ARRAY);
-
- GLenum sizedInternalFormat = gl::GetSizedInternalFormat(internalFormat, type);
-
- redefineImage(level, sizedInternalFormat, width, height, depth);
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(sizedInternalFormat);
- GLsizei inputDepthPitch = formatInfo.computeDepthPitch(type, width, height, unpack.alignment);
-
- for (int i = 0; i < depth; i++)
- {
- const void *layerPixels = pixels ? (reinterpret_cast<const unsigned char*>(pixels) + (inputDepthPitch * i)) : NULL;
- gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, i);
- gl::Error error = TextureD3D::setImage(unpack, type, layerPixels, index);
- if (error.isError())
- {
- return error;
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_2DArray::setCompressedImage(GLenum target, GLint level, GLenum format,
- GLsizei width, GLsizei height, GLsizei depth,
- GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels)
-{
- ASSERT(target == GL_TEXTURE_2D_ARRAY);
-
- // compressed formats don't have separate sized internal formats-- we can just use the compressed format directly
- redefineImage(level, format, width, height, depth);
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
- GLsizei inputDepthPitch = formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, width, height, 1);
-
- for (int i = 0; i < depth; i++)
- {
- const void *layerPixels = pixels ? (reinterpret_cast<const unsigned char*>(pixels) + (inputDepthPitch * i)) : NULL;
- gl::Error error = TextureD3D::setCompressedImage(unpack, imageSize, layerPixels, mImageArray[level][i]);
- if (error.isError())
- {
- return error;
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_2DArray::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type,
- const gl::PixelUnpackState &unpack, const void *pixels)
-{
- ASSERT(target == GL_TEXTURE_2D_ARRAY);
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(getInternalFormat(level));
- GLsizei inputDepthPitch = formatInfo.computeDepthPitch(type, width, height, unpack.alignment);
-
- for (int i = 0; i < depth; i++)
- {
- int layer = zoffset + i;
- const void *layerPixels = pixels ? (reinterpret_cast<const unsigned char*>(pixels) + (inputDepthPitch * i)) : NULL;
-
- gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, layer);
- gl::Error error = TextureD3D::subImage(xoffset, yoffset, zoffset, width, height, 1, format, type,
- unpack, layerPixels, index);
- if (error.isError())
- {
- return error;
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_2DArray::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth, GLenum format,
- GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels)
-{
- ASSERT(target == GL_TEXTURE_2D_ARRAY);
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
- GLsizei inputDepthPitch = formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, width, height, 1);
-
- for (int i = 0; i < depth; i++)
- {
- int layer = zoffset + i;
- const void *layerPixels = pixels ? (reinterpret_cast<const unsigned char*>(pixels) + (inputDepthPitch * i)) : NULL;
-
- gl::Error error = TextureD3D::subImageCompressed(xoffset, yoffset, zoffset, width, height, 1, format, imageSize, unpack, layerPixels, mImageArray[level][layer]);
- if (error.isError())
- {
- return error;
- }
-
- gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, layer);
- gl::Box region(xoffset, yoffset, 0, width, height, 1);
- error = commitRegion(index, region);
- if (error.isError())
- {
- return error;
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_2DArray::copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source)
-{
- UNIMPLEMENTED();
- return gl::Error(GL_INVALID_OPERATION, "Copying 2D array textures is unimplemented.");
-}
-
-gl::Error TextureD3D_2DArray::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source)
-{
- ASSERT(target == GL_TEXTURE_2D_ARRAY);
-
- gl::Rectangle sourceRect(x, y, width, height);
- gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, zoffset);
-
- if (canCreateRenderTargetForImage(index))
- {
- gl::Error error = mImageArray[level][zoffset]->copy(xoffset, yoffset, 0, sourceRect, source);
- if (error.isError())
- {
- return error;
- }
-
- mDirtyImages = true;
- }
- else
- {
- gl::Error error = ensureRenderTarget();
- if (error.isError())
- {
- return error;
- }
-
- if (isValidLevel(level))
- {
- error = updateStorageLevel(level);
- if (error.isError())
- {
- return error;
- }
-
- error = mRenderer->copyImage2DArray(source, sourceRect, gl::GetInternalFormatInfo(getInternalFormat(0)).format,
- xoffset, yoffset, zoffset, mTexStorage, level);
- if (error.isError())
- {
- return error;
- }
- }
- }
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_2DArray::storage(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
-{
- ASSERT(target == GL_TEXTURE_2D_ARRAY);
-
- deleteImages();
-
- for (int level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
- {
- GLsizei levelWidth = std::max(1, width >> level);
- GLsizei levelHeight = std::max(1, height >> level);
-
- mLayerCounts[level] = (level < levels ? depth : 0);
-
- if (mLayerCounts[level] > 0)
- {
- // Create new images for this level
- mImageArray[level] = new ImageD3D*[mLayerCounts[level]];
-
- for (int layer = 0; layer < mLayerCounts[level]; layer++)
- {
- mImageArray[level][layer] = ImageD3D::makeImageD3D(mRenderer->createImage());
- mImageArray[level][layer]->redefine(mRenderer, GL_TEXTURE_2D_ARRAY, internalformat, levelWidth,
- levelHeight, 1, true);
- }
- }
- }
-
- // TODO(geofflang): Verify storage creation had no errors
- bool renderTarget = IsRenderTargetUsage(mUsage);
- TextureStorage *storage = mRenderer->createTextureStorage2DArray(internalformat, renderTarget, width, height, depth, levels);
-
- gl::Error error = setCompleteTexStorage(storage);
- if (error.isError())
- {
- SafeDelete(storage);
- return error;
- }
-
- mImmutable = true;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void TextureD3D_2DArray::bindTexImage(egl::Surface *surface)
-{
- UNREACHABLE();
-}
-
-void TextureD3D_2DArray::releaseTexImage()
-{
- UNREACHABLE();
-}
-
-
-void TextureD3D_2DArray::initMipmapsImages()
-{
- int baseWidth = getBaseLevelWidth();
- int baseHeight = getBaseLevelHeight();
- int baseDepth = getBaseLevelDepth();
- GLenum baseFormat = getBaseLevelInternalFormat();
-
- // Purge array levels 1 through q and reset them to represent the generated mipmap levels.
- int levelCount = mipLevels();
- for (int level = 1; level < levelCount; level++)
- {
- redefineImage(level, baseFormat, std::max(baseWidth >> level, 1), std::max(baseHeight >> level, 1), baseDepth);
- }
-}
-
-unsigned int TextureD3D_2DArray::getRenderTargetSerial(const gl::ImageIndex &index)
-{
- return (!ensureRenderTarget().isError() ? mTexStorage->getRenderTargetSerial(index) : 0);
-}
-
-gl::Error TextureD3D_2DArray::getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT)
-{
- // ensure the underlying texture is created
- gl::Error error = ensureRenderTarget();
- if (error.isError())
- {
- return error;
- }
-
- error = updateStorageLevel(index.mipIndex);
- if (error.isError())
- {
- return error;
- }
-
- return mTexStorage->getRenderTarget(index, outRT);
-}
-
-gl::Error TextureD3D_2DArray::initializeStorage(bool renderTarget)
-{
- // Only initialize the first time this texture is used as a render target or shader resource
- if (mTexStorage)
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- // do not attempt to create storage for nonexistant data
- if (!isLevelComplete(0))
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- bool createRenderTarget = (renderTarget || mUsage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
-
- TextureStorage *storage = NULL;
- gl::Error error = createCompleteStorage(createRenderTarget, &storage);
- if (error.isError())
- {
- return error;
- }
-
- error = setCompleteTexStorage(storage);
- if (error.isError())
- {
- SafeDelete(storage);
- return error;
- }
-
- ASSERT(mTexStorage);
-
- // flush image data to the storage
- error = updateStorage();
- if (error.isError())
- {
- return error;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_2DArray::createCompleteStorage(bool renderTarget, TextureStorage **outStorage) const
-{
- GLsizei width = getBaseLevelWidth();
- GLsizei height = getBaseLevelHeight();
- GLsizei depth = getLayerCount(0);
- GLenum internalFormat = getBaseLevelInternalFormat();
-
- ASSERT(width > 0 && height > 0 && depth > 0);
-
- // use existing storage level count, when previously specified by TexStorage*D
- GLint levels = (mTexStorage ? mTexStorage->getLevelCount() : creationLevels(width, height, 1));
-
- // TODO(geofflang): Verify storage creation succeeds
- *outStorage = mRenderer->createTextureStorage2DArray(internalFormat, renderTarget, width, height, depth, levels);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_2DArray::setCompleteTexStorage(TextureStorage *newCompleteTexStorage)
-{
- SafeDelete(mTexStorage);
- mTexStorage = newCompleteTexStorage;
- mDirtyImages = true;
-
- // We do not support managed 2D array storage, as managed storage is ES2/D3D9 only
- ASSERT(!mTexStorage->isManaged());
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureD3D_2DArray::updateStorage()
-{
- ASSERT(mTexStorage != NULL);
- GLint storageLevels = mTexStorage->getLevelCount();
- for (int level = 0; level < storageLevels; level++)
- {
- if (isLevelComplete(level))
- {
- gl::Error error = updateStorageLevel(level);
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-bool TextureD3D_2DArray::isValidLevel(int level) const
-{
- return (mTexStorage ? (level >= 0 && level < mTexStorage->getLevelCount()) : 0);
-}
-
-bool TextureD3D_2DArray::isLevelComplete(int level) const
-{
- ASSERT(level >= 0 && level < (int)ArraySize(mImageArray));
-
- if (isImmutable())
- {
- return true;
- }
-
- GLsizei width = getBaseLevelWidth();
- GLsizei height = getBaseLevelHeight();
- GLsizei layers = getLayerCount(0);
-
- if (width <= 0 || height <= 0 || layers <= 0)
- {
- return false;
- }
-
- if (level == 0)
- {
- return true;
- }
-
- if (getInternalFormat(level) != getInternalFormat(0))
- {
- return false;
- }
-
- if (getWidth(level) != std::max(1, width >> level))
- {
- return false;
- }
-
- if (getHeight(level) != std::max(1, height >> level))
- {
- return false;
- }
-
- if (getLayerCount(level) != layers)
- {
- return false;
- }
-
- return true;
-}
-
-bool TextureD3D_2DArray::isImageComplete(const gl::ImageIndex &index) const
-{
- return isLevelComplete(index.mipIndex);
-}
-
-gl::Error TextureD3D_2DArray::updateStorageLevel(int level)
-{
- ASSERT(level >= 0 && level < (int)ArraySize(mLayerCounts));
- ASSERT(isLevelComplete(level));
-
- for (int layer = 0; layer < mLayerCounts[level]; layer++)
- {
- ASSERT(mImageArray[level] != NULL && mImageArray[level][layer] != NULL);
- if (mImageArray[level][layer]->isDirty())
- {
- gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, layer);
- gl::Box region(0, 0, 0, getWidth(level), getHeight(level), 1);
- gl::Error error = commitRegion(index, region);
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void TextureD3D_2DArray::deleteImages()
-{
- for (int level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++level)
- {
- for (int layer = 0; layer < mLayerCounts[level]; ++layer)
- {
- delete mImageArray[level][layer];
- }
- delete[] mImageArray[level];
- mImageArray[level] = NULL;
- mLayerCounts[level] = 0;
- }
-}
-
-void TextureD3D_2DArray::redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
-{
- // If there currently is a corresponding storage texture image, it has these parameters
- const int storageWidth = std::max(1, getBaseLevelWidth() >> level);
- const int storageHeight = std::max(1, getBaseLevelHeight() >> level);
- const int storageDepth = getLayerCount(0);
- const GLenum storageFormat = getBaseLevelInternalFormat();
-
- for (int layer = 0; layer < mLayerCounts[level]; layer++)
- {
- delete mImageArray[level][layer];
- }
- delete[] mImageArray[level];
- mImageArray[level] = NULL;
- mLayerCounts[level] = depth;
-
- if (depth > 0)
- {
- mImageArray[level] = new ImageD3D*[depth]();
-
- for (int layer = 0; layer < mLayerCounts[level]; layer++)
- {
- mImageArray[level][layer] = ImageD3D::makeImageD3D(mRenderer->createImage());
- mImageArray[level][layer]->redefine(mRenderer, GL_TEXTURE_2D_ARRAY, internalformat, width, height, 1, false);
- }
- }
-
- if (mTexStorage)
- {
- const int storageLevels = mTexStorage->getLevelCount();
-
- if ((level >= storageLevels && storageLevels != 0) ||
- width != storageWidth ||
- height != storageHeight ||
- depth != storageDepth ||
- internalformat != storageFormat) // Discard mismatched storage
- {
- for (int level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
- {
- for (int layer = 0; layer < mLayerCounts[level]; layer++)
- {
- mImageArray[level][layer]->markDirty();
- }
- }
-
- delete mTexStorage;
- mTexStorage = NULL;
- mDirtyImages = true;
- }
- }
-}
-
-gl::ImageIndexIterator TextureD3D_2DArray::imageIterator() const
-{
- return gl::ImageIndexIterator::Make2DArray(0, mTexStorage->getLevelCount(), mLayerCounts);
-}
-
-gl::ImageIndex TextureD3D_2DArray::getImageIndex(GLint mip, GLint layer) const
-{
- return gl::ImageIndex::Make2DArray(mip, layer);
-}
-
-bool TextureD3D_2DArray::isValidIndex(const gl::ImageIndex &index) const
-{
- // Check for having a storage and the right type of index
- if (!mTexStorage || index.type != GL_TEXTURE_2D_ARRAY)
- {
- return false;
- }
-
- // Check the mip index
- if (index.mipIndex < 0 || index.mipIndex >= mTexStorage->getLevelCount())
- {
- return false;
- }
-
- // Check the layer index
- return (!index.hasLayer() || (index.layerIndex >= 0 && index.layerIndex < mLayerCounts[index.mipIndex]));
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TextureD3D.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TextureD3D.h
deleted file mode 100644
index 083a6335b9..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TextureD3D.h
+++ /dev/null
@@ -1,335 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// TextureD3D.h: Implementations of the Texture interfaces shared betweeen the D3D backends.
-
-#ifndef LIBGLESV2_RENDERER_TEXTURED3D_H_
-#define LIBGLESV2_RENDERER_TEXTURED3D_H_
-
-#include "libGLESv2/renderer/TextureImpl.h"
-#include "libGLESv2/angletypes.h"
-#include "libGLESv2/Constants.h"
-
-namespace gl
-{
-class Framebuffer;
-}
-
-namespace rx
-{
-
-class Image;
-class ImageD3D;
-class RendererD3D;
-class RenderTarget;
-class TextureStorage;
-
-class TextureD3D : public TextureImpl
-{
- public:
- TextureD3D(RendererD3D *renderer);
- virtual ~TextureD3D();
-
- static TextureD3D *makeTextureD3D(TextureImpl *texture);
-
- TextureStorage *getNativeTexture();
-
- virtual void setUsage(GLenum usage) { mUsage = usage; }
- bool hasDirtyImages() const { return mDirtyImages; }
- void resetDirty() { mDirtyImages = false; }
-
- GLint getBaseLevelWidth() const;
- GLint getBaseLevelHeight() const;
- GLint getBaseLevelDepth() const;
- GLenum getBaseLevelInternalFormat() const;
-
- bool isImmutable() const { return mImmutable; }
-
- virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT) = 0;
- virtual unsigned int getRenderTargetSerial(const gl::ImageIndex &index) = 0;
-
- // Returns an iterator over all "Images" for this particular Texture.
- virtual gl::ImageIndexIterator imageIterator() const = 0;
-
- // Returns an ImageIndex for a particular "Image". 3D Textures do not have images for
- // slices of their depth texures, so 3D textures ignore the layer parameter.
- virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const = 0;
- virtual bool isValidIndex(const gl::ImageIndex &index) const = 0;
-
- virtual gl::Error generateMipmaps();
- TextureStorage *getStorage();
- Image *getBaseLevelImage() const;
-
- protected:
- gl::Error setImage(const gl::PixelUnpackState &unpack, GLenum type, const void *pixels, const gl::ImageIndex &index);
- gl::Error subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels, const gl::ImageIndex &index);
- gl::Error setCompressedImage(const gl::PixelUnpackState &unpack, GLsizei imageSize, const void *pixels, Image *image);
- gl::Error subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels, Image *image);
- bool isFastUnpackable(const gl::PixelUnpackState &unpack, GLenum sizedInternalFormat);
- gl::Error fastUnpackPixels(const gl::PixelUnpackState &unpack, const void *pixels, const gl::Box &destArea,
- GLenum sizedInternalFormat, GLenum type, RenderTarget *destRenderTarget);
-
- GLint creationLevels(GLsizei width, GLsizei height, GLsizei depth) const;
- int mipLevels() const;
- virtual void initMipmapsImages() = 0;
- bool isBaseImageZeroSize() const;
- virtual bool isImageComplete(const gl::ImageIndex &index) const = 0;
-
- bool canCreateRenderTargetForImage(const gl::ImageIndex &index) const;
- virtual gl::Error ensureRenderTarget();
-
- virtual gl::Error createCompleteStorage(bool renderTarget, TextureStorage **outTexStorage) const = 0;
- virtual gl::Error setCompleteTexStorage(TextureStorage *newCompleteTexStorage) = 0;
- gl::Error commitRegion(const gl::ImageIndex &index, const gl::Box &region);
-
- RendererD3D *mRenderer;
-
- GLenum mUsage;
-
- bool mDirtyImages;
-
- bool mImmutable;
- TextureStorage *mTexStorage;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureD3D);
-
- virtual gl::Error initializeStorage(bool renderTarget) = 0;
-
- virtual gl::Error updateStorage() = 0;
-
- bool shouldUseSetData(const Image *image) const;
-};
-
-class TextureD3D_2D : public TextureD3D
-{
- public:
- TextureD3D_2D(RendererD3D *renderer);
- virtual ~TextureD3D_2D();
-
- virtual Image *getImage(int level, int layer) const;
- virtual Image *getImage(const gl::ImageIndex &index) const;
- virtual GLsizei getLayerCount(int level) const;
-
- GLsizei getWidth(GLint level) const;
- GLsizei getHeight(GLint level) const;
- GLenum getInternalFormat(GLint level) const;
- GLenum getActualFormat(GLint level) const;
- bool isDepth(GLint level) const;
-
- virtual gl::Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
- virtual gl::Error setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels);
- virtual gl::Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
- virtual gl::Error subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels);
- virtual gl::Error copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
- virtual gl::Error copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
- virtual gl::Error storage(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-
- virtual void bindTexImage(egl::Surface *surface);
- virtual void releaseTexImage();
-
- virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT);
- virtual unsigned int getRenderTargetSerial(const gl::ImageIndex &index);
-
- virtual gl::ImageIndexIterator imageIterator() const;
- virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const;
- virtual bool isValidIndex(const gl::ImageIndex &index) const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureD3D_2D);
-
- virtual gl::Error initializeStorage(bool renderTarget);
- virtual gl::Error createCompleteStorage(bool renderTarget, TextureStorage **outTexStorage) const;
- virtual gl::Error setCompleteTexStorage(TextureStorage *newCompleteTexStorage);
-
- virtual gl::Error updateStorage();
- virtual void initMipmapsImages();
-
- bool isValidLevel(int level) const;
- bool isLevelComplete(int level) const;
- virtual bool isImageComplete(const gl::ImageIndex &index) const;
-
- gl::Error updateStorageLevel(int level);
-
- void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height);
-
- ImageD3D *mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-};
-
-class TextureD3D_Cube : public TextureD3D
-{
- public:
- TextureD3D_Cube(RendererD3D *renderer);
- virtual ~TextureD3D_Cube();
-
- virtual Image *getImage(int level, int layer) const;
- virtual Image *getImage(const gl::ImageIndex &index) const;
- virtual GLsizei getLayerCount(int level) const;
-
- virtual bool hasDirtyImages() const { return mDirtyImages; }
- virtual void resetDirty() { mDirtyImages = false; }
- virtual void setUsage(GLenum usage) { mUsage = usage; }
-
- GLenum getInternalFormat(GLint level, GLint layer) const;
- bool isDepth(GLint level, GLint layer) const;
-
- virtual gl::Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
- virtual gl::Error setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels);
- virtual gl::Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
- virtual gl::Error subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels);
- virtual gl::Error copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
- virtual gl::Error copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
- virtual gl::Error storage(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-
- virtual void bindTexImage(egl::Surface *surface);
- virtual void releaseTexImage();
-
- virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT);
- virtual unsigned int getRenderTargetSerial(const gl::ImageIndex &index);
-
- virtual gl::ImageIndexIterator imageIterator() const;
- virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const;
- virtual bool isValidIndex(const gl::ImageIndex &index) const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureD3D_Cube);
-
- virtual gl::Error initializeStorage(bool renderTarget);
- virtual gl::Error createCompleteStorage(bool renderTarget, TextureStorage **outTexStorage) const;
- virtual gl::Error setCompleteTexStorage(TextureStorage *newCompleteTexStorage);
-
- virtual gl::Error updateStorage();
- virtual void initMipmapsImages();
-
- bool isValidFaceLevel(int faceIndex, int level) const;
- bool isFaceLevelComplete(int faceIndex, int level) const;
- bool isCubeComplete() const;
- virtual bool isImageComplete(const gl::ImageIndex &index) const;
- gl::Error updateStorageFaceLevel(int faceIndex, int level);
-
- void redefineImage(int faceIndex, GLint level, GLenum internalformat, GLsizei width, GLsizei height);
-
- ImageD3D *mImageArray[6][gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-};
-
-class TextureD3D_3D : public TextureD3D
-{
- public:
- TextureD3D_3D(RendererD3D *renderer);
- virtual ~TextureD3D_3D();
-
- virtual Image *getImage(int level, int layer) const;
- virtual Image *getImage(const gl::ImageIndex &index) const;
- virtual GLsizei getLayerCount(int level) const;
-
- GLsizei getWidth(GLint level) const;
- GLsizei getHeight(GLint level) const;
- GLsizei getDepth(GLint level) const;
- GLenum getInternalFormat(GLint level) const;
- bool isDepth(GLint level) const;
-
- virtual gl::Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
- virtual gl::Error setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels);
- virtual gl::Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
- virtual gl::Error subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels);
- virtual gl::Error copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
- virtual gl::Error copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
- virtual gl::Error storage(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-
- virtual void bindTexImage(egl::Surface *surface);
- virtual void releaseTexImage();
-
- virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT);
- virtual unsigned int getRenderTargetSerial(const gl::ImageIndex &index);
-
- virtual gl::ImageIndexIterator imageIterator() const;
- virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const;
- virtual bool isValidIndex(const gl::ImageIndex &index) const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureD3D_3D);
-
- virtual gl::Error initializeStorage(bool renderTarget);
- virtual gl::Error createCompleteStorage(bool renderTarget, TextureStorage **outStorage) const;
- virtual gl::Error setCompleteTexStorage(TextureStorage *newCompleteTexStorage);
-
- virtual gl::Error updateStorage();
- virtual void initMipmapsImages();
-
- bool isValidLevel(int level) const;
- bool isLevelComplete(int level) const;
- virtual bool isImageComplete(const gl::ImageIndex &index) const;
- gl::Error updateStorageLevel(int level);
-
- void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-
- ImageD3D *mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-};
-
-class TextureD3D_2DArray : public TextureD3D
-{
- public:
- TextureD3D_2DArray(RendererD3D *renderer);
- virtual ~TextureD3D_2DArray();
-
- virtual Image *getImage(int level, int layer) const;
- virtual Image *getImage(const gl::ImageIndex &index) const;
- virtual GLsizei getLayerCount(int level) const;
-
- GLsizei getWidth(GLint level) const;
- GLsizei getHeight(GLint level) const;
- GLenum getInternalFormat(GLint level) const;
- bool isDepth(GLint level) const;
-
- virtual gl::Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
- virtual gl::Error setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels);
- virtual gl::Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
- virtual gl::Error subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels);
- virtual gl::Error copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
- virtual gl::Error copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
- virtual gl::Error storage(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-
- virtual void bindTexImage(egl::Surface *surface);
- virtual void releaseTexImage();
-
- virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT);
- virtual unsigned int getRenderTargetSerial(const gl::ImageIndex &index);
-
- virtual gl::ImageIndexIterator imageIterator() const;
- virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const;
- virtual bool isValidIndex(const gl::ImageIndex &index) const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureD3D_2DArray);
-
- virtual gl::Error initializeStorage(bool renderTarget);
- virtual gl::Error createCompleteStorage(bool renderTarget, TextureStorage **outStorage) const;
- virtual gl::Error setCompleteTexStorage(TextureStorage *newCompleteTexStorage);
-
- virtual gl::Error updateStorage();
- virtual void initMipmapsImages();
-
- bool isValidLevel(int level) const;
- bool isLevelComplete(int level) const;
- virtual bool isImageComplete(const gl::ImageIndex &index) const;
- gl::Error updateStorageLevel(int level);
-
- void deleteImages();
- void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-
- // Storing images as an array of single depth textures since D3D11 treats each array level of a
- // Texture2D object as a separate subresource. Each layer would have to be looped over
- // to update all the texture layers since they cannot all be updated at once and it makes the most
- // sense for the Image class to not have to worry about layer subresource as well as mip subresources.
- GLsizei mLayerCounts[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
- ImageD3D **mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_TEXTURED3D_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TextureStorage.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TextureStorage.cpp
deleted file mode 100644
index 320b74b8ed..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TextureStorage.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// Copyright (c) 2002-2013 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.
-//
-
-// TextureStorage.cpp: Shared members of abstract rx::TextureStorage class.
-
-#include "libGLESv2/renderer/d3d/TextureStorage.h"
-#include "libGLESv2/renderer/d3d/TextureD3D.h"
-#include "libGLESv2/renderer/RenderTarget.h"
-#include "libGLESv2/renderer/Renderer.h"
-#include "libGLESv2/Renderbuffer.h"
-#include "libGLESv2/Texture.h"
-
-#include "common/debug.h"
-#include "common/mathutil.h"
-
-namespace rx
-{
-
-TextureStorage::TextureStorage()
- : mFirstRenderTargetSerial(0),
- mRenderTargetSerialsLayerStride(0)
-{}
-
-void TextureStorage::initializeSerials(unsigned int rtSerialsToReserve, unsigned int rtSerialsLayerStride)
-{
- mFirstRenderTargetSerial = RenderTarget::issueSerials(rtSerialsToReserve);
- mRenderTargetSerialsLayerStride = rtSerialsLayerStride;
-}
-
-unsigned int TextureStorage::getRenderTargetSerial(const gl::ImageIndex &index) const
-{
- unsigned int layerOffset = (index.hasLayer() ? (static_cast<unsigned int>(index.layerIndex) * mRenderTargetSerialsLayerStride) : 0);
- return mFirstRenderTargetSerial + static_cast<unsigned int>(index.mipIndex) + layerOffset;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TextureStorage.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TextureStorage.h
deleted file mode 100644
index da92be3c74..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TextureStorage.h
+++ /dev/null
@@ -1,66 +0,0 @@
-//
-// Copyright (c) 2002-2013 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.
-//
-
-// TextureStorage.h: Defines the abstract rx::TextureStorage class.
-
-#ifndef LIBGLESV2_RENDERER_TEXTURESTORAGE_H_
-#define LIBGLESV2_RENDERER_TEXTURESTORAGE_H_
-
-#include "libGLESv2/Error.h"
-
-#include "common/debug.h"
-#include "libGLESv2/Error.h"
-
-#include <GLES2/gl2.h>
-#include <cstdint>
-
-namespace gl
-{
-struct ImageIndex;
-struct Box;
-struct PixelUnpackState;
-}
-
-namespace rx
-{
-class SwapChain;
-class RenderTarget;
-class Image;
-
-class TextureStorage
-{
- public:
- TextureStorage();
- virtual ~TextureStorage() {};
-
- virtual int getTopLevel() const = 0;
- virtual bool isRenderTarget() const = 0;
- virtual bool isManaged() const = 0;
- virtual int getLevelCount() const = 0;
-
- virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT) = 0;
- virtual gl::Error generateMipmap(const gl::ImageIndex &sourceIndex, const gl::ImageIndex &destIndex) = 0;
-
- virtual gl::Error copyToStorage(TextureStorage *destStorage) = 0;
- virtual gl::Error setData(const gl::ImageIndex &index, Image *image, const gl::Box *destBox, GLenum type,
- const gl::PixelUnpackState &unpack, const uint8_t *pixelData) = 0;
-
- unsigned int getRenderTargetSerial(const gl::ImageIndex &index) const;
- unsigned int getTextureSerial() const;
-
- protected:
- void initializeSerials(unsigned int rtSerialsToReserve, unsigned int rtSerialsLayerStride);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureStorage);
-
- unsigned int mFirstRenderTargetSerial;
- unsigned int mRenderTargetSerialsLayerStride;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_TEXTURESTORAGE_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TransformFeedbackD3D.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TransformFeedbackD3D.cpp
deleted file mode 100644
index 11596006d0..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TransformFeedbackD3D.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// TransformFeedbackD3D.cpp is a no-op implementation for both the D3D9 and D3D11 renderers.
-
-#include "libGLESv2/renderer/d3d/TransformFeedbackD3D.h"
-
-namespace rx
-{
-
-TransformFeedbackD3D::TransformFeedbackD3D()
-{
-}
-
-TransformFeedbackD3D::~TransformFeedbackD3D()
-{
-}
-
-void TransformFeedbackD3D::begin(GLenum primitiveMode)
-{
-}
-
-void TransformFeedbackD3D::end()
-{
-}
-
-void TransformFeedbackD3D::pause()
-{
-}
-
-void TransformFeedbackD3D::resume()
-{
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TransformFeedbackD3D.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TransformFeedbackD3D.h
deleted file mode 100644
index 7c367aba1d..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/TransformFeedbackD3D.h
+++ /dev/null
@@ -1,32 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// TransformFeedbackD3D.h: Implements the abstract rx::TransformFeedbackImpl class.
-
-#ifndef LIBGLESV2_RENDERER_D3D_TRANSFORMFEEDBACKD3D_H_
-#define LIBGLESV2_RENDERER_D3D_TRANSFORMFEEDBACKD3D_H_
-
-#include "libGLESv2/renderer/TransformFeedbackImpl.h"
-#include "libGLESv2/angletypes.h"
-
-namespace rx
-{
-
-class TransformFeedbackD3D : public TransformFeedbackImpl
-{
- public:
- TransformFeedbackD3D();
- virtual ~TransformFeedbackD3D();
-
- virtual void begin(GLenum primitiveMode);
- virtual void end();
- virtual void pause();
- virtual void resume();
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_D3D_TRANSFORMFEEDBACKD3D_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/VertexBuffer.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/VertexBuffer.cpp
deleted file mode 100644
index 73f0c79e19..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/VertexBuffer.cpp
+++ /dev/null
@@ -1,307 +0,0 @@
-//
-// 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.
-//
-
-// VertexBuffer.cpp: Defines the abstract VertexBuffer class and VertexBufferInterface
-// class with derivations, classes that perform graphics API agnostic vertex buffer operations.
-
-#include "libGLESv2/renderer/d3d/VertexBuffer.h"
-#include "libGLESv2/renderer/d3d/BufferD3D.h"
-#include "libGLESv2/renderer/d3d/RendererD3D.h"
-#include "libGLESv2/VertexAttribute.h"
-
-#include "common/mathutil.h"
-
-namespace rx
-{
-
-unsigned int VertexBuffer::mNextSerial = 1;
-
-VertexBuffer::VertexBuffer()
-{
- updateSerial();
-}
-
-VertexBuffer::~VertexBuffer()
-{
-}
-
-void VertexBuffer::updateSerial()
-{
- mSerial = mNextSerial++;
-}
-
-unsigned int VertexBuffer::getSerial() const
-{
- return mSerial;
-}
-
-VertexBufferInterface::VertexBufferInterface(RendererD3D *renderer, bool dynamic) : mRenderer(renderer)
-{
- mDynamic = dynamic;
- mWritePosition = 0;
- mReservedSpace = 0;
-
- mVertexBuffer = renderer->createVertexBuffer();
-}
-
-VertexBufferInterface::~VertexBufferInterface()
-{
- delete mVertexBuffer;
-}
-
-unsigned int VertexBufferInterface::getSerial() const
-{
- return mVertexBuffer->getSerial();
-}
-
-unsigned int VertexBufferInterface::getBufferSize() const
-{
- return mVertexBuffer->getBufferSize();
-}
-
-gl::Error VertexBufferInterface::setBufferSize(unsigned int size)
-{
- if (mVertexBuffer->getBufferSize() == 0)
- {
- return mVertexBuffer->initialize(size, mDynamic);
- }
- else
- {
- return mVertexBuffer->setBufferSize(size);
- }
-}
-
-unsigned int VertexBufferInterface::getWritePosition() const
-{
- return mWritePosition;
-}
-
-void VertexBufferInterface::setWritePosition(unsigned int writePosition)
-{
- mWritePosition = writePosition;
-}
-
-gl::Error VertexBufferInterface::discard()
-{
- return mVertexBuffer->discard();
-}
-
-gl::Error VertexBufferInterface::storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
- GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset)
-{
- gl::Error error(GL_NO_ERROR);
-
- unsigned int spaceRequired;
- error = mVertexBuffer->getSpaceRequired(attrib, count, instances, &spaceRequired);
- if (error.isError())
- {
- return error;
- }
-
- if (mWritePosition + spaceRequired < mWritePosition)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal error, new vertex buffer write position would overflow.");
- }
-
- error = reserveSpace(mReservedSpace);
- if (error.isError())
- {
- return error;
- }
- mReservedSpace = 0;
-
- error = mVertexBuffer->storeVertexAttributes(attrib, currentValue, start, count, instances, mWritePosition);
- if (error.isError())
- {
- return error;
- }
-
- if (outStreamOffset)
- {
- *outStreamOffset = mWritePosition;
- }
-
- mWritePosition += spaceRequired;
-
- // Align to 16-byte boundary
- mWritePosition = roundUp(mWritePosition, 16u);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error VertexBufferInterface::reserveVertexSpace(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances)
-{
- gl::Error error(GL_NO_ERROR);
-
- unsigned int requiredSpace;
- error = mVertexBuffer->getSpaceRequired(attrib, count, instances, &requiredSpace);
- if (error.isError())
- {
- return error;
- }
-
- // Protect against integer overflow
- if (mReservedSpace + requiredSpace < mReservedSpace)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Unable to reserve %u extra bytes in internal vertex buffer, "
- "it would result in an overflow.", requiredSpace);
- }
-
- mReservedSpace += requiredSpace;
-
- // Align to 16-byte boundary
- mReservedSpace = roundUp(mReservedSpace, 16u);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-VertexBuffer* VertexBufferInterface::getVertexBuffer() const
-{
- return mVertexBuffer;
-}
-
-bool VertexBufferInterface::directStoragePossible(const gl::VertexAttribute &attrib,
- const gl::VertexAttribCurrentValueData &currentValue) const
-{
- gl::Buffer *buffer = attrib.buffer.get();
- BufferD3D *storage = buffer ? BufferD3D::makeBufferD3D(buffer->getImplementation()) : NULL;
-
- if (!storage || !storage->supportsDirectBinding())
- {
- return false;
- }
-
- // Alignment restrictions: In D3D, vertex data must be aligned to
- // the format stride, or to a 4-byte boundary, whichever is smaller.
- // (Undocumented, and experimentally confirmed)
- size_t alignment = 4;
- bool requiresConversion = false;
-
- if (attrib.type != GL_FLOAT)
- {
- gl::VertexFormat vertexFormat(attrib, currentValue.Type);
-
- unsigned int outputElementSize;
- getVertexBuffer()->getSpaceRequired(attrib, 1, 0, &outputElementSize);
- alignment = std::min<size_t>(outputElementSize, 4);
-
- requiresConversion = (mRenderer->getVertexConversionType(vertexFormat) & VERTEX_CONVERT_CPU) != 0;
- }
-
- bool isAligned = (static_cast<size_t>(ComputeVertexAttributeStride(attrib)) % alignment == 0) &&
- (static_cast<size_t>(attrib.offset) % alignment == 0);
-
- return !requiresConversion && isAligned;
-}
-
-StreamingVertexBufferInterface::StreamingVertexBufferInterface(RendererD3D *renderer, std::size_t initialSize) : VertexBufferInterface(renderer, true)
-{
- setBufferSize(initialSize);
-}
-
-StreamingVertexBufferInterface::~StreamingVertexBufferInterface()
-{
-}
-
-gl::Error StreamingVertexBufferInterface::reserveSpace(unsigned int size)
-{
- unsigned int curBufferSize = getBufferSize();
- if (size > curBufferSize)
- {
- gl::Error error = setBufferSize(std::max(size, 3 * curBufferSize / 2));
- if (error.isError())
- {
- return error;
- }
- setWritePosition(0);
- }
- else if (getWritePosition() + size > curBufferSize)
- {
- gl::Error error = discard();
- if (error.isError())
- {
- return error;
- }
- setWritePosition(0);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-StaticVertexBufferInterface::StaticVertexBufferInterface(RendererD3D *renderer) : VertexBufferInterface(renderer, false)
-{
-}
-
-StaticVertexBufferInterface::~StaticVertexBufferInterface()
-{
-}
-
-bool StaticVertexBufferInterface::lookupAttribute(const gl::VertexAttribute &attrib, unsigned int *outStreamOffset)
-{
- for (unsigned int element = 0; element < mCache.size(); element++)
- {
- if (mCache[element].type == attrib.type &&
- mCache[element].size == attrib.size &&
- mCache[element].stride == ComputeVertexAttributeStride(attrib) &&
- mCache[element].normalized == attrib.normalized &&
- mCache[element].pureInteger == attrib.pureInteger)
- {
- size_t offset = (static_cast<size_t>(attrib.offset) % ComputeVertexAttributeStride(attrib));
- if (mCache[element].attributeOffset == offset)
- {
- if (outStreamOffset)
- {
- *outStreamOffset = mCache[element].streamOffset;
- }
- return true;
- }
- }
- }
-
- return false;
-}
-
-gl::Error StaticVertexBufferInterface::reserveSpace(unsigned int size)
-{
- unsigned int curSize = getBufferSize();
- if (curSize == 0)
- {
- return setBufferSize(size);
- }
- else if (curSize >= size)
- {
- return gl::Error(GL_NO_ERROR);
- }
- else
- {
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION, "Internal error, Static vertex buffers can't be resized.");
- }
-}
-
-gl::Error StaticVertexBufferInterface::storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
- GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset)
-{
- unsigned int streamOffset;
- gl::Error error = VertexBufferInterface::storeVertexAttributes(attrib, currentValue, start, count, instances, &streamOffset);
- if (error.isError())
- {
- return error;
- }
-
- size_t attributeOffset = static_cast<size_t>(attrib.offset) % ComputeVertexAttributeStride(attrib);
- VertexElement element = { attrib.type, attrib.size, ComputeVertexAttributeStride(attrib), attrib.normalized, attrib.pureInteger, attributeOffset, streamOffset };
- mCache.push_back(element);
-
- if (outStreamOffset)
- {
- *outStreamOffset = streamOffset;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/VertexBuffer.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/VertexBuffer.h
deleted file mode 100644
index 4b40818f8e..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/VertexBuffer.h
+++ /dev/null
@@ -1,144 +0,0 @@
-//
-// 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.
-//
-
-// VertexBuffer.h: Defines the abstract VertexBuffer class and VertexBufferInterface
-// class with derivations, classes that perform graphics API agnostic vertex buffer operations.
-
-#ifndef LIBGLESV2_RENDERER_VERTEXBUFFER_H_
-#define LIBGLESV2_RENDERER_VERTEXBUFFER_H_
-
-#include "common/angleutils.h"
-#include "libGLESv2/Error.h"
-
-#include <GLES2/gl2.h>
-
-#include <cstddef>
-#include <vector>
-
-namespace gl
-{
-struct VertexAttribute;
-struct VertexAttribCurrentValueData;
-}
-
-namespace rx
-{
-class RendererD3D;
-
-class VertexBuffer
-{
- public:
- VertexBuffer();
- virtual ~VertexBuffer();
-
- virtual gl::Error initialize(unsigned int size, bool dynamicUsage) = 0;
-
- virtual gl::Error storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
- GLint start, GLsizei count, GLsizei instances, unsigned int offset) = 0;
- virtual gl::Error getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances,
- unsigned int *outSpaceRequired) const = 0;
-
- virtual unsigned int getBufferSize() const = 0;
- virtual gl::Error setBufferSize(unsigned int size) = 0;
- virtual gl::Error discard() = 0;
-
- unsigned int getSerial() const;
-
- protected:
- void updateSerial();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(VertexBuffer);
-
- unsigned int mSerial;
- static unsigned int mNextSerial;
-};
-
-class VertexBufferInterface
-{
- public:
- VertexBufferInterface(RendererD3D *renderer, bool dynamic);
- virtual ~VertexBufferInterface();
-
- gl::Error reserveVertexSpace(const gl::VertexAttribute &attribute, GLsizei count, GLsizei instances);
-
- unsigned int getBufferSize() const;
-
- unsigned int getSerial() const;
-
- virtual gl::Error storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
- GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset);
-
- bool directStoragePossible(const gl::VertexAttribute &attrib,
- const gl::VertexAttribCurrentValueData &currentValue) const;
-
- VertexBuffer* getVertexBuffer() const;
-
- protected:
- virtual gl::Error reserveSpace(unsigned int size) = 0;
-
- unsigned int getWritePosition() const;
- void setWritePosition(unsigned int writePosition);
-
- gl::Error discard();
-
- gl::Error setBufferSize(unsigned int size);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(VertexBufferInterface);
-
- RendererD3D *const mRenderer;
-
- VertexBuffer* mVertexBuffer;
-
- unsigned int mWritePosition;
- unsigned int mReservedSpace;
- bool mDynamic;
-};
-
-class StreamingVertexBufferInterface : public VertexBufferInterface
-{
- public:
- StreamingVertexBufferInterface(RendererD3D *renderer, std::size_t initialSize);
- ~StreamingVertexBufferInterface();
-
- protected:
- gl::Error reserveSpace(unsigned int size);
-};
-
-class StaticVertexBufferInterface : public VertexBufferInterface
-{
- public:
- explicit StaticVertexBufferInterface(RendererD3D *renderer);
- ~StaticVertexBufferInterface();
-
- gl::Error storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
- GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset);
-
- bool lookupAttribute(const gl::VertexAttribute &attribute, unsigned int* outStreamFffset);
-
- protected:
- gl::Error reserveSpace(unsigned int size);
-
- private:
- struct VertexElement
- {
- GLenum type;
- GLuint size;
- GLuint stride;
- bool normalized;
- bool pureInteger;
- size_t attributeOffset;
-
- unsigned int streamOffset;
- };
-
- std::vector<VertexElement> mCache;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_VERTEXBUFFER_H_ \ No newline at end of file
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/VertexDataManager.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/VertexDataManager.cpp
deleted file mode 100644
index 8d3df31c8b..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/VertexDataManager.cpp
+++ /dev/null
@@ -1,354 +0,0 @@
-//
-// 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.
-//
-
-// VertexDataManager.h: Defines the VertexDataManager, a class that
-// runs the Buffer translation process.
-
-#include "libGLESv2/renderer/d3d/VertexDataManager.h"
-#include "libGLESv2/renderer/d3d/BufferD3D.h"
-#include "libGLESv2/renderer/d3d/VertexBuffer.h"
-#include "libGLESv2/renderer/Renderer.h"
-#include "libGLESv2/Buffer.h"
-#include "libGLESv2/ProgramBinary.h"
-#include "libGLESv2/VertexAttribute.h"
-#include "libGLESv2/State.h"
-
-namespace
-{
- enum { INITIAL_STREAM_BUFFER_SIZE = 1024*1024 };
- // This has to be at least 4k or else it fails on ATI cards.
- enum { CONSTANT_VERTEX_BUFFER_SIZE = 4096 };
-}
-
-namespace rx
-{
-
-static int ElementsInBuffer(const gl::VertexAttribute &attrib, unsigned int size)
-{
- // Size cannot be larger than a GLsizei
- if (size > static_cast<unsigned int>(std::numeric_limits<int>::max()))
- {
- size = static_cast<unsigned int>(std::numeric_limits<int>::max());
- }
-
- GLsizei stride = ComputeVertexAttributeStride(attrib);
- return (size - attrib.offset % stride + (stride - ComputeVertexAttributeTypeSize(attrib))) / stride;
-}
-
-static int StreamingBufferElementCount(const gl::VertexAttribute &attrib, int vertexDrawCount, int instanceDrawCount)
-{
- // For instanced rendering, we draw "instanceDrawCount" sets of "vertexDrawCount" vertices.
- //
- // A vertex attribute with a positive divisor loads one instanced vertex for every set of
- // non-instanced vertices, and the instanced vertex index advances once every "mDivisor" instances.
- if (instanceDrawCount > 0 && attrib.divisor > 0)
- {
- return instanceDrawCount / attrib.divisor;
- }
-
- return vertexDrawCount;
-}
-
-VertexDataManager::VertexDataManager(RendererD3D *renderer) : mRenderer(renderer)
-{
- for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- mCurrentValue[i].FloatValues[0] = std::numeric_limits<float>::quiet_NaN();
- mCurrentValue[i].FloatValues[1] = std::numeric_limits<float>::quiet_NaN();
- mCurrentValue[i].FloatValues[2] = std::numeric_limits<float>::quiet_NaN();
- mCurrentValue[i].FloatValues[3] = std::numeric_limits<float>::quiet_NaN();
- mCurrentValue[i].Type = GL_FLOAT;
- mCurrentValueBuffer[i] = NULL;
- mCurrentValueOffsets[i] = 0;
- }
-
- mStreamingBuffer = new StreamingVertexBufferInterface(renderer, INITIAL_STREAM_BUFFER_SIZE);
-
- if (!mStreamingBuffer)
- {
- ERR("Failed to allocate the streaming vertex buffer.");
- }
-}
-
-VertexDataManager::~VertexDataManager()
-{
- delete mStreamingBuffer;
-
- for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- delete mCurrentValueBuffer[i];
- }
-}
-
-gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint start, GLsizei count,
- TranslatedAttribute *translated, GLsizei instances)
-{
- if (!mStreamingBuffer)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal streaming vertex buffer is unexpectedly NULL.");
- }
-
- // Invalidate static buffers that don't contain matching attributes
- for (int attributeIndex = 0; attributeIndex < gl::MAX_VERTEX_ATTRIBS; attributeIndex++)
- {
- translated[attributeIndex].active = (state.getCurrentProgramBinary()->getSemanticIndex(attributeIndex) != -1);
- const gl::VertexAttribute &curAttrib = state.getVertexAttribState(attributeIndex);
-
- if (translated[attributeIndex].active && curAttrib.enabled)
- {
- invalidateMatchingStaticData(curAttrib, state.getVertexAttribCurrentValue(attributeIndex));
- }
- }
-
- // Reserve the required space in the buffers
- for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- const gl::VertexAttribute &curAttrib = state.getVertexAttribState(i);
- if (translated[i].active && curAttrib.enabled)
- {
- gl::Error error = reserveSpaceForAttrib(curAttrib, state.getVertexAttribCurrentValue(i), count, instances);
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- // Perform the vertex data translations
- for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- const gl::VertexAttribute &curAttrib = state.getVertexAttribState(i);
- if (translated[i].active)
- {
- if (curAttrib.enabled)
- {
- gl::Error error = storeAttribute(curAttrib, state.getVertexAttribCurrentValue(i),
- &translated[i], start, count, instances);
-
- if (error.isError())
- {
- return error;
- }
- }
- else
- {
- if (!mCurrentValueBuffer[i])
- {
- mCurrentValueBuffer[i] = new StreamingVertexBufferInterface(mRenderer, CONSTANT_VERTEX_BUFFER_SIZE);
- }
-
- gl::Error error = storeCurrentValue(curAttrib, state.getVertexAttribCurrentValue(i), &translated[i],
- &mCurrentValue[i], &mCurrentValueOffsets[i],
- mCurrentValueBuffer[i]);
- if (error.isError())
- {
- return error;
- }
- }
- }
- }
-
- for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- const gl::VertexAttribute &curAttrib = state.getVertexAttribState(i);
- if (translated[i].active && curAttrib.enabled)
- {
- gl::Buffer *buffer = curAttrib.buffer.get();
-
- if (buffer)
- {
- BufferD3D *bufferImpl = BufferD3D::makeBufferD3D(buffer->getImplementation());
- bufferImpl->promoteStaticUsage(count * ComputeVertexAttributeTypeSize(curAttrib));
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void VertexDataManager::invalidateMatchingStaticData(const gl::VertexAttribute &attrib,
- const gl::VertexAttribCurrentValueData &currentValue) const
-{
- gl::Buffer *buffer = attrib.buffer.get();
-
- if (buffer)
- {
- BufferD3D *bufferImpl = BufferD3D::makeBufferD3D(buffer->getImplementation());
- StaticVertexBufferInterface *staticBuffer = bufferImpl->getStaticVertexBuffer();
-
- if (staticBuffer &&
- staticBuffer->getBufferSize() > 0 &&
- !staticBuffer->lookupAttribute(attrib, NULL) &&
- !staticBuffer->directStoragePossible(attrib, currentValue))
- {
- bufferImpl->invalidateStaticData();
- }
- }
-}
-
-gl::Error VertexDataManager::reserveSpaceForAttrib(const gl::VertexAttribute &attrib,
- const gl::VertexAttribCurrentValueData &currentValue,
- GLsizei count,
- GLsizei instances) const
-{
- gl::Buffer *buffer = attrib.buffer.get();
- BufferD3D *bufferImpl = buffer ? BufferD3D::makeBufferD3D(buffer->getImplementation()) : NULL;
- StaticVertexBufferInterface *staticBuffer = bufferImpl ? bufferImpl->getStaticVertexBuffer() : NULL;
- VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast<VertexBufferInterface*>(mStreamingBuffer);
-
- if (!vertexBuffer->directStoragePossible(attrib, currentValue))
- {
- if (staticBuffer)
- {
- if (staticBuffer->getBufferSize() == 0)
- {
- int totalCount = ElementsInBuffer(attrib, bufferImpl->getSize());
- gl::Error error = staticBuffer->reserveVertexSpace(attrib, totalCount, 0);
- if (error.isError())
- {
- return error;
- }
- }
- }
- else
- {
- int totalCount = StreamingBufferElementCount(attrib, count, instances);
- ASSERT(!bufferImpl || ElementsInBuffer(attrib, bufferImpl->getSize()) >= totalCount);
-
- gl::Error error = mStreamingBuffer->reserveVertexSpace(attrib, totalCount, instances);
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error VertexDataManager::storeAttribute(const gl::VertexAttribute &attrib,
- const gl::VertexAttribCurrentValueData &currentValue,
- TranslatedAttribute *translated,
- GLint start,
- GLsizei count,
- GLsizei instances)
-{
- gl::Buffer *buffer = attrib.buffer.get();
- ASSERT(buffer || attrib.pointer);
-
- BufferD3D *storage = buffer ? BufferD3D::makeBufferD3D(buffer->getImplementation()) : NULL;
- StaticVertexBufferInterface *staticBuffer = storage ? storage->getStaticVertexBuffer() : NULL;
- VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast<VertexBufferInterface*>(mStreamingBuffer);
- bool directStorage = vertexBuffer->directStoragePossible(attrib, currentValue);
-
- unsigned int streamOffset = 0;
- unsigned int outputElementSize = 0;
-
- if (directStorage)
- {
- outputElementSize = ComputeVertexAttributeStride(attrib);
- streamOffset = attrib.offset + outputElementSize * start;
- }
- else if (staticBuffer)
- {
- gl::Error error = staticBuffer->getVertexBuffer()->getSpaceRequired(attrib, 1, 0, &outputElementSize);
- if (error.isError())
- {
- return error;
- }
-
- if (!staticBuffer->lookupAttribute(attrib, &streamOffset))
- {
- // Convert the entire buffer
- int totalCount = ElementsInBuffer(attrib, storage->getSize());
- int startIndex = attrib.offset / ComputeVertexAttributeStride(attrib);
-
- gl::Error error = staticBuffer->storeVertexAttributes(attrib, currentValue, -startIndex, totalCount,
- 0, &streamOffset);
- if (error.isError())
- {
- return error;
- }
- }
-
- unsigned int firstElementOffset = (attrib.offset / ComputeVertexAttributeStride(attrib)) * outputElementSize;
- unsigned int startOffset = (instances == 0 || attrib.divisor == 0) ? start * outputElementSize : 0;
- if (streamOffset + firstElementOffset + startOffset < streamOffset)
- {
- return gl::Error(GL_OUT_OF_MEMORY);
- }
-
- streamOffset += firstElementOffset + startOffset;
- }
- else
- {
- int totalCount = StreamingBufferElementCount(attrib, count, instances);
- gl::Error error = mStreamingBuffer->getVertexBuffer()->getSpaceRequired(attrib, 1, 0, &outputElementSize);
- if (error.isError())
- {
- return error;
- }
-
- error = mStreamingBuffer->storeVertexAttributes(attrib, currentValue, start, totalCount, instances, &streamOffset);
- if (error.isError())
- {
- return error;
- }
- }
-
- translated->storage = directStorage ? storage : NULL;
- translated->vertexBuffer = vertexBuffer->getVertexBuffer();
- translated->serial = directStorage ? storage->getSerial() : vertexBuffer->getSerial();
- translated->divisor = attrib.divisor;
-
- translated->attribute = &attrib;
- translated->currentValueType = currentValue.Type;
- translated->stride = outputElementSize;
- translated->offset = streamOffset;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error VertexDataManager::storeCurrentValue(const gl::VertexAttribute &attrib,
- const gl::VertexAttribCurrentValueData &currentValue,
- TranslatedAttribute *translated,
- gl::VertexAttribCurrentValueData *cachedValue,
- size_t *cachedOffset,
- StreamingVertexBufferInterface *buffer)
-{
- if (*cachedValue != currentValue)
- {
- gl::Error error = buffer->reserveVertexSpace(attrib, 1, 0);
- if (error.isError())
- {
- return error;
- }
-
- unsigned int streamOffset;
- error = buffer->storeVertexAttributes(attrib, currentValue, 0, 1, 0, &streamOffset);
- if (error.isError())
- {
- return error;
- }
-
- *cachedValue = currentValue;
- *cachedOffset = streamOffset;
- }
-
- translated->storage = NULL;
- translated->vertexBuffer = buffer->getVertexBuffer();
- translated->serial = buffer->getSerial();
- translated->divisor = 0;
-
- translated->attribute = &attrib;
- translated->currentValueType = currentValue.Type;
- translated->stride = 0;
- translated->offset = *cachedOffset;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/VertexDataManager.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/VertexDataManager.h
deleted file mode 100644
index 64ef653221..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/VertexDataManager.h
+++ /dev/null
@@ -1,96 +0,0 @@
-//
-// 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.
-//
-
-// VertexDataManager.h: Defines the VertexDataManager, a class that
-// runs the Buffer translation process.
-
-#ifndef LIBGLESV2_RENDERER_VERTEXDATAMANAGER_H_
-#define LIBGLESV2_RENDERER_VERTEXDATAMANAGER_H_
-
-#include "libGLESv2/Constants.h"
-#include "libGLESv2/VertexAttribute.h"
-#include "common/angleutils.h"
-
-namespace gl
-{
-class ProgramBinary;
-class State;
-struct VertexAttribute;
-struct VertexAttribCurrentValueData;
-}
-
-namespace rx
-{
-class BufferD3D;
-class StreamingVertexBufferInterface;
-class VertexBuffer;
-class RendererD3D;
-
-struct TranslatedAttribute
-{
- TranslatedAttribute() : active(false), attribute(NULL), currentValueType(GL_NONE),
- offset(0), stride(0), vertexBuffer(NULL), storage(NULL),
- serial(0), divisor(0) {};
- bool active;
-
- const gl::VertexAttribute *attribute;
- GLenum currentValueType;
- unsigned int offset;
- unsigned int stride; // 0 means not to advance the read pointer at all
-
- VertexBuffer *vertexBuffer;
- BufferD3D *storage;
- unsigned int serial;
- unsigned int divisor;
-};
-
-class VertexDataManager
-{
- public:
- VertexDataManager(RendererD3D *renderer);
- virtual ~VertexDataManager();
-
- gl::Error prepareVertexData(const gl::State &state, GLint start, GLsizei count,
- TranslatedAttribute *outAttribs, GLsizei instances);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(VertexDataManager);
-
- gl::Error reserveSpaceForAttrib(const gl::VertexAttribute &attrib,
- const gl::VertexAttribCurrentValueData &currentValue,
- GLsizei count,
- GLsizei instances) const;
-
- void invalidateMatchingStaticData(const gl::VertexAttribute &attrib,
- const gl::VertexAttribCurrentValueData &currentValue) const;
-
- gl::Error storeAttribute(const gl::VertexAttribute &attrib,
- const gl::VertexAttribCurrentValueData &currentValue,
- TranslatedAttribute *translated,
- GLint start,
- GLsizei count,
- GLsizei instances);
-
- gl::Error storeCurrentValue(const gl::VertexAttribute &attrib,
- const gl::VertexAttribCurrentValueData &currentValue,
- TranslatedAttribute *translated,
- gl::VertexAttribCurrentValueData *cachedValue,
- size_t *cachedOffset,
- StreamingVertexBufferInterface *buffer);
-
- RendererD3D *const mRenderer;
-
- StreamingVertexBufferInterface *mStreamingBuffer;
-
- gl::VertexAttribCurrentValueData mCurrentValue[gl::MAX_VERTEX_ATTRIBS];
-
- StreamingVertexBufferInterface *mCurrentValueBuffer[gl::MAX_VERTEX_ATTRIBS];
- std::size_t mCurrentValueOffsets[gl::MAX_VERTEX_ATTRIBS];
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_VERTEXDATAMANAGER_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.cpp
deleted file mode 100644
index 06aea9befe..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.cpp
+++ /dev/null
@@ -1,1047 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// Blit11.cpp: Texture copy utility class.
-
-#include "libGLESv2/renderer/d3d/d3d11/Blit11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/renderer11_utils.h"
-#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h"
-#include "libGLESv2/main.h"
-#include "libGLESv2/formatutils.h"
-
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough2dvs.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughdepth2dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2duips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2dips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb2dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb2duips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb2dips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg2dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg2duips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg2dips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr2dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr2duips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr2dips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughlum2dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughlumalpha2dps.h"
-
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough3dvs.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough3dgs.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba3dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba3duips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba3dips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb3dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb3duips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb3dips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg3dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg3duips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg3dips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr3dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr3duips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr3dips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughlum3dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughlumalpha3dps.h"
-
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlef2dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlei2dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzleui2dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlef3dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlei3dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzleui3dps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlef2darrayps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlei2darrayps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzleui2darrayps.h"
-
-namespace rx
-{
-
-static DXGI_FORMAT GetTextureFormat(ID3D11Resource *resource)
-{
- ID3D11Texture2D *texture = d3d11::DynamicCastComObject<ID3D11Texture2D>(resource);
- if (!texture)
- {
- return DXGI_FORMAT_UNKNOWN;
- }
-
- D3D11_TEXTURE2D_DESC desc;
- texture->GetDesc(&desc);
-
- SafeRelease(texture);
-
- return desc.Format;
-}
-
-static ID3D11Resource *CreateStagingTexture(ID3D11Device *device, ID3D11DeviceContext *context,
- ID3D11Resource *source, unsigned int subresource,
- const gl::Extents &size, unsigned int cpuAccessFlags)
-{
- D3D11_TEXTURE2D_DESC stagingDesc;
- stagingDesc.Width = size.width;
- stagingDesc.Height = size.height;
- stagingDesc.MipLevels = 1;
- stagingDesc.ArraySize = 1;
- stagingDesc.Format = GetTextureFormat(source);
- stagingDesc.SampleDesc.Count = 1;
- stagingDesc.SampleDesc.Quality = 0;
- stagingDesc.Usage = D3D11_USAGE_STAGING;
- stagingDesc.CPUAccessFlags = cpuAccessFlags;
- stagingDesc.MiscFlags = 0;
- stagingDesc.BindFlags = 0;
-
- ID3D11Texture2D *stagingTexture = NULL;
- HRESULT result = device->CreateTexture2D(&stagingDesc, NULL, &stagingTexture);
- if (FAILED(result))
- {
- ERR("Failed to create staging texture for depth stencil blit. HRESULT: 0x%X.", result);
- return NULL;
- }
-
- context->CopySubresourceRegion(stagingTexture, 0, 0, 0, 0, source, subresource, NULL);
-
- return stagingTexture;
-}
-
-inline static void GenerateVertexCoords(const gl::Box &sourceArea, const gl::Extents &sourceSize,
- const gl::Box &destArea, const gl::Extents &destSize,
- float *x1, float *y1, float *x2, float *y2,
- float *u1, float *v1, float *u2, float *v2)
-{
- *x1 = (destArea.x / float(destSize.width)) * 2.0f - 1.0f;
- *y1 = ((destSize.height - destArea.y - destArea.height) / float(destSize.height)) * 2.0f - 1.0f;
- *x2 = ((destArea.x + destArea.width) / float(destSize.width)) * 2.0f - 1.0f;
- *y2 = ((destSize.height - destArea.y) / float(destSize.height)) * 2.0f - 1.0f;
-
- *u1 = sourceArea.x / float(sourceSize.width);
- *v1 = sourceArea.y / float(sourceSize.height);
- *u2 = (sourceArea.x + sourceArea.width) / float(sourceSize.width);
- *v2 = (sourceArea.y + sourceArea.height) / float(sourceSize.height);
-}
-
-static void Write2DVertices(const gl::Box &sourceArea, const gl::Extents &sourceSize,
- const gl::Box &destArea, const gl::Extents &destSize,
- void *outVertices, unsigned int *outStride, unsigned int *outVertexCount,
- D3D11_PRIMITIVE_TOPOLOGY *outTopology)
-{
- float x1, y1, x2, y2, u1, v1, u2, v2;
- GenerateVertexCoords(sourceArea, sourceSize, destArea, destSize, &x1, &y1, &x2, &y2, &u1, &v1, &u2, &v2);
-
- d3d11::PositionTexCoordVertex *vertices = static_cast<d3d11::PositionTexCoordVertex*>(outVertices);
-
- d3d11::SetPositionTexCoordVertex(&vertices[0], x1, y1, u1, v2);
- d3d11::SetPositionTexCoordVertex(&vertices[1], x1, y2, u1, v1);
- d3d11::SetPositionTexCoordVertex(&vertices[2], x2, y1, u2, v2);
- d3d11::SetPositionTexCoordVertex(&vertices[3], x2, y2, u2, v1);
-
- *outStride = sizeof(d3d11::PositionTexCoordVertex);
- *outVertexCount = 4;
- *outTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
-}
-
-static void Write3DVertices(const gl::Box &sourceArea, const gl::Extents &sourceSize,
- const gl::Box &destArea, const gl::Extents &destSize,
- void *outVertices, unsigned int *outStride, unsigned int *outVertexCount,
- D3D11_PRIMITIVE_TOPOLOGY *outTopology)
-{
- ASSERT(sourceSize.depth > 0 && destSize.depth > 0);
-
- float x1, y1, x2, y2, u1, v1, u2, v2;
- GenerateVertexCoords(sourceArea, sourceSize, destArea, destSize, &x1, &y1, &x2, &y2, &u1, &v1, &u2, &v2);
-
- d3d11::PositionLayerTexCoord3DVertex *vertices = static_cast<d3d11::PositionLayerTexCoord3DVertex*>(outVertices);
-
- for (int i = 0; i < destSize.depth; i++)
- {
- float readDepth = (float)i / std::max(destSize.depth - 1, 1);
-
- d3d11::SetPositionLayerTexCoord3DVertex(&vertices[i * 6 + 0], x1, y1, i, u1, v2, readDepth);
- d3d11::SetPositionLayerTexCoord3DVertex(&vertices[i * 6 + 1], x1, y2, i, u1, v1, readDepth);
- d3d11::SetPositionLayerTexCoord3DVertex(&vertices[i * 6 + 2], x2, y1, i, u2, v2, readDepth);
-
- d3d11::SetPositionLayerTexCoord3DVertex(&vertices[i * 6 + 3], x1, y2, i, u1, v1, readDepth);
- d3d11::SetPositionLayerTexCoord3DVertex(&vertices[i * 6 + 4], x2, y2, i, u2, v1, readDepth);
- d3d11::SetPositionLayerTexCoord3DVertex(&vertices[i * 6 + 5], x2, y1, i, u2, v2, readDepth);
- }
-
- *outStride = sizeof(d3d11::PositionLayerTexCoord3DVertex);
- *outVertexCount = destSize.depth * 6;
- *outTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
-}
-
-Blit11::Blit11(Renderer11 *renderer)
- : mRenderer(renderer), mBlitShaderMap(compareBlitParameters), mSwizzleShaderMap(compareSwizzleParameters),
- mVertexBuffer(NULL), mPointSampler(NULL), mLinearSampler(NULL), mScissorEnabledRasterizerState(NULL),
- mScissorDisabledRasterizerState(NULL), mDepthStencilState(NULL),
- mQuad2DIL(NULL), mQuad2DVS(NULL), mDepthPS(NULL),
- mQuad3DIL(NULL), mQuad3DVS(NULL), mQuad3DGS(NULL),
- mSwizzleCB(NULL)
-{
- HRESULT result;
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_BUFFER_DESC vbDesc;
- vbDesc.ByteWidth = std::max(sizeof(d3d11::PositionLayerTexCoord3DVertex), sizeof(d3d11::PositionTexCoordVertex)) *
- 6 * renderer->getRendererCaps().max3DTextureSize;
- vbDesc.Usage = D3D11_USAGE_DYNAMIC;
- vbDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
- vbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
- vbDesc.MiscFlags = 0;
- vbDesc.StructureByteStride = 0;
-
- result = device->CreateBuffer(&vbDesc, NULL, &mVertexBuffer);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mVertexBuffer, "Blit11 vertex buffer");
-
- D3D11_SAMPLER_DESC pointSamplerDesc;
- pointSamplerDesc.Filter = D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR;
- pointSamplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
- pointSamplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
- pointSamplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
- pointSamplerDesc.MipLODBias = 0.0f;
- pointSamplerDesc.MaxAnisotropy = 0;
- pointSamplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
- pointSamplerDesc.BorderColor[0] = 0.0f;
- pointSamplerDesc.BorderColor[1] = 0.0f;
- pointSamplerDesc.BorderColor[2] = 0.0f;
- pointSamplerDesc.BorderColor[3] = 0.0f;
- pointSamplerDesc.MinLOD = 0.0f;
- pointSamplerDesc.MaxLOD = mRenderer->isLevel9() ? D3D11_FLOAT32_MAX : 0.0f;
-
- result = device->CreateSamplerState(&pointSamplerDesc, &mPointSampler);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mPointSampler, "Blit11 point sampler");
-
- D3D11_SAMPLER_DESC linearSamplerDesc;
- linearSamplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
- linearSamplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
- linearSamplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
- linearSamplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
- linearSamplerDesc.MipLODBias = 0.0f;
- linearSamplerDesc.MaxAnisotropy = 0;
- linearSamplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
- linearSamplerDesc.BorderColor[0] = 0.0f;
- linearSamplerDesc.BorderColor[1] = 0.0f;
- linearSamplerDesc.BorderColor[2] = 0.0f;
- linearSamplerDesc.BorderColor[3] = 0.0f;
- linearSamplerDesc.MinLOD = 0.0f;
- linearSamplerDesc.MaxLOD = mRenderer->isLevel9() ? D3D11_FLOAT32_MAX : 0.0f;
-
- result = device->CreateSamplerState(&linearSamplerDesc, &mLinearSampler);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mLinearSampler, "Blit11 linear sampler");
-
- // Use a rasterizer state that will not cull so that inverted quads will not be culled
- D3D11_RASTERIZER_DESC rasterDesc;
- rasterDesc.FillMode = D3D11_FILL_SOLID;
- rasterDesc.CullMode = D3D11_CULL_NONE;
- rasterDesc.FrontCounterClockwise = FALSE;
- rasterDesc.DepthBias = 0;
- rasterDesc.SlopeScaledDepthBias = 0.0f;
- rasterDesc.DepthBiasClamp = 0.0f;
- rasterDesc.DepthClipEnable = TRUE;
- rasterDesc.MultisampleEnable = FALSE;
- rasterDesc.AntialiasedLineEnable = FALSE;
-
- rasterDesc.ScissorEnable = TRUE;
- result = device->CreateRasterizerState(&rasterDesc, &mScissorEnabledRasterizerState);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mScissorEnabledRasterizerState, "Blit11 scissoring rasterizer state");
-
- rasterDesc.ScissorEnable = FALSE;
- result = device->CreateRasterizerState(&rasterDesc, &mScissorDisabledRasterizerState);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mScissorDisabledRasterizerState, "Blit11 no scissoring rasterizer state");
-
- D3D11_DEPTH_STENCIL_DESC depthStencilDesc;
- depthStencilDesc.DepthEnable = true;
- depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
- depthStencilDesc.DepthFunc = D3D11_COMPARISON_ALWAYS;
- depthStencilDesc.StencilEnable = FALSE;
- depthStencilDesc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK;
- depthStencilDesc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK;
- depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
- depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
- depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
- depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
- depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
- depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
- depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
- depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
-
- result = device->CreateDepthStencilState(&depthStencilDesc, &mDepthStencilState);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mDepthStencilState, "Blit11 depth stencil state");
-
- D3D11_INPUT_ELEMENT_DESC quad2DLayout[] =
- {
- { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
- { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 },
- };
-
- result = device->CreateInputLayout(quad2DLayout, ArraySize(quad2DLayout), g_VS_Passthrough2D, ArraySize(g_VS_Passthrough2D), &mQuad2DIL);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mQuad2DIL, "Blit11 2D input layout");
-
- result = device->CreateVertexShader(g_VS_Passthrough2D, ArraySize(g_VS_Passthrough2D), NULL, &mQuad2DVS);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mQuad2DVS, "Blit11 2D vertex shader");
-
- if (!renderer->isLevel9())
- {
- result = device->CreatePixelShader(g_PS_PassthroughDepth2D, ArraySize(g_PS_PassthroughDepth2D), NULL, &mDepthPS);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mDepthPS, "Blit11 2D depth pixel shader");
-
- D3D11_INPUT_ELEMENT_DESC quad3DLayout[] =
- {
- { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
- { "LAYER", 0, DXGI_FORMAT_R32_UINT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 },
- { "TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
- };
-
- result = device->CreateInputLayout(quad3DLayout, ArraySize(quad3DLayout), g_VS_Passthrough3D, ArraySize(g_VS_Passthrough3D), &mQuad3DIL);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mQuad3DIL, "Blit11 3D input layout");
-
- result = device->CreateVertexShader(g_VS_Passthrough3D, ArraySize(g_VS_Passthrough3D), NULL, &mQuad3DVS);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mQuad3DVS, "Blit11 3D vertex shader");
-
- result = device->CreateGeometryShader(g_GS_Passthrough3D, ArraySize(g_GS_Passthrough3D), NULL, &mQuad3DGS);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mQuad3DGS, "Renderer11 copy 3D texture geometry shader");
- }
-
- buildShaderMap();
-
- D3D11_BUFFER_DESC swizzleBufferDesc;
- swizzleBufferDesc.ByteWidth = sizeof(unsigned int) * 4;
- swizzleBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
- swizzleBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
- swizzleBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
- swizzleBufferDesc.MiscFlags = 0;
- swizzleBufferDesc.StructureByteStride = 0;
-
- result = device->CreateBuffer(&swizzleBufferDesc, NULL, &mSwizzleCB);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mSwizzleCB, "Blit11 swizzle constant buffer");
-}
-
-Blit11::~Blit11()
-{
- SafeRelease(mVertexBuffer);
- SafeRelease(mPointSampler);
- SafeRelease(mLinearSampler);
- SafeRelease(mScissorEnabledRasterizerState);
- SafeRelease(mScissorDisabledRasterizerState);
- SafeRelease(mDepthStencilState);
-
- SafeRelease(mQuad2DIL);
- SafeRelease(mQuad2DVS);
- SafeRelease(mDepthPS);
-
- SafeRelease(mQuad3DIL);
- SafeRelease(mQuad3DVS);
- SafeRelease(mQuad3DGS);
-
- SafeRelease(mSwizzleCB);
-
- clearShaderMap();
-}
-
-static inline unsigned int GetSwizzleIndex(GLenum swizzle)
-{
- unsigned int colorIndex = 0;
-
- switch (swizzle)
- {
- case GL_RED: colorIndex = 0; break;
- case GL_GREEN: colorIndex = 1; break;
- case GL_BLUE: colorIndex = 2; break;
- case GL_ALPHA: colorIndex = 3; break;
- case GL_ZERO: colorIndex = 4; break;
- case GL_ONE: colorIndex = 5; break;
- default: UNREACHABLE(); break;
- }
-
- return colorIndex;
-}
-
-gl::Error Blit11::swizzleTexture(ID3D11ShaderResourceView *source, ID3D11RenderTargetView *dest, const gl::Extents &size,
- GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha)
-{
- HRESULT result;
- ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
-
- D3D11_SHADER_RESOURCE_VIEW_DESC sourceSRVDesc;
- source->GetDesc(&sourceSRVDesc);
-
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(sourceSRVDesc.Format);
- const gl::InternalFormat &sourceFormatInfo = gl::GetInternalFormatInfo(dxgiFormatInfo.internalFormat);
-
- GLenum shaderType = GL_NONE;
- switch (sourceFormatInfo.componentType)
- {
- case GL_UNSIGNED_NORMALIZED:
- case GL_SIGNED_NORMALIZED:
- case GL_FLOAT:
- shaderType = GL_FLOAT;
- break;
- case GL_INT:
- shaderType = GL_INT;
- break;
- case GL_UNSIGNED_INT:
- shaderType = GL_UNSIGNED_INT;
- break;
- default:
- UNREACHABLE();
- break;
- }
-
- SwizzleParameters parameters = { 0 };
- parameters.mDestinationType = shaderType;
- parameters.mViewDimension = sourceSRVDesc.ViewDimension;
-
- SwizzleShaderMap::const_iterator i = mSwizzleShaderMap.find(parameters);
- if (i == mSwizzleShaderMap.end())
- {
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION, "Internal error, missing swizzle shader.");
- }
-
- const Shader &shader = i->second;
-
- // Set vertices
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- result = deviceContext->Map(mVertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal vertex buffer for swizzle, HRESULT: 0x%X.", result);
- }
-
- UINT stride = 0;
- UINT startIdx = 0;
- UINT drawCount = 0;
- D3D11_PRIMITIVE_TOPOLOGY topology;
-
- gl::Box area(0, 0, 0, size.width, size.height, size.depth);
- shader.mVertexWriteFunction(area, size, area, size, mappedResource.pData, &stride, &drawCount, &topology);
-
- deviceContext->Unmap(mVertexBuffer, 0);
-
- // Set constant buffer
- result = deviceContext->Map(mSwizzleCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal constant buffer for swizzle, HRESULT: 0x%X.", result);
- }
-
- unsigned int *swizzleIndices = reinterpret_cast<unsigned int*>(mappedResource.pData);
- swizzleIndices[0] = GetSwizzleIndex(swizzleRed);
- swizzleIndices[1] = GetSwizzleIndex(swizzleGreen);
- swizzleIndices[2] = GetSwizzleIndex(swizzleBlue);
- swizzleIndices[3] = GetSwizzleIndex(swizzleAlpha);
-
- deviceContext->Unmap(mSwizzleCB, 0);
-
- // Apply vertex buffer
- deviceContext->IASetVertexBuffers(0, 1, &mVertexBuffer, &stride, &startIdx);
-
- // Apply constant buffer
- deviceContext->PSSetConstantBuffers(0, 1, &mSwizzleCB);
-
- // Apply state
- deviceContext->OMSetBlendState(NULL, NULL, 0xFFFFFFF);
- deviceContext->OMSetDepthStencilState(NULL, 0xFFFFFFFF);
- deviceContext->RSSetState(mScissorDisabledRasterizerState);
-
- // Apply shaders
- deviceContext->IASetInputLayout(shader.mInputLayout);
- deviceContext->IASetPrimitiveTopology(topology);
- deviceContext->VSSetShader(shader.mVertexShader, NULL, 0);
-
- deviceContext->PSSetShader(shader.mPixelShader, NULL, 0);
- deviceContext->GSSetShader(shader.mGeometryShader, NULL, 0);
-
- // Unset the currently bound shader resource to avoid conflicts
- mRenderer->setShaderResource(gl::SAMPLER_PIXEL, 0, NULL);
-
- // Apply render target
- mRenderer->setOneTimeRenderTarget(dest);
-
- // Set the viewport
- D3D11_VIEWPORT viewport;
- viewport.TopLeftX = 0;
- viewport.TopLeftY = 0;
- viewport.Width = size.width;
- viewport.Height = size.height;
- viewport.MinDepth = 0.0f;
- viewport.MaxDepth = 1.0f;
- deviceContext->RSSetViewports(1, &viewport);
-
- // Apply textures
- mRenderer->setShaderResource(gl::SAMPLER_PIXEL, 0, source);
-
- // Apply samplers
- deviceContext->PSSetSamplers(0, 1, &mPointSampler);
-
- // Draw the quad
- deviceContext->Draw(drawCount, 0);
-
- // Unbind textures and render targets and vertex buffer
- mRenderer->setShaderResource(gl::SAMPLER_PIXEL, 0, NULL);
-
- mRenderer->unapplyRenderTargets();
-
- UINT zero = 0;
- ID3D11Buffer *const nullBuffer = NULL;
- deviceContext->IASetVertexBuffers(0, 1, &nullBuffer, &zero, &zero);
-
- mRenderer->markAllStateDirty();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Blit11::copyTexture(ID3D11ShaderResourceView *source, const gl::Box &sourceArea, const gl::Extents &sourceSize,
- ID3D11RenderTargetView *dest, const gl::Box &destArea, const gl::Extents &destSize,
- const gl::Rectangle *scissor, GLenum destFormat, GLenum filter)
-{
- HRESULT result;
- ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
-
- // Determine if the source format is a signed integer format, the destFormat will already
- // be GL_XXXX_INTEGER but it does not tell us if it is signed or unsigned.
- D3D11_SHADER_RESOURCE_VIEW_DESC sourceSRVDesc;
- source->GetDesc(&sourceSRVDesc);
-
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(sourceSRVDesc.Format);
- const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(dxgiFormatInfo.internalFormat);
-
- BlitParameters parameters = { 0 };
- parameters.mDestinationFormat = destFormat;
- parameters.mSignedInteger = (internalFormatInfo.componentType == GL_INT);
- parameters.m3DBlit = sourceArea.depth > 1;
-
- BlitShaderMap::const_iterator i = mBlitShaderMap.find(parameters);
- if (i == mBlitShaderMap.end())
- {
- UNREACHABLE();
- return gl::Error(GL_OUT_OF_MEMORY, "Could not find appropriate shader for internal texture blit.");
- }
-
- const Shader& shader = i->second;
-
- // Set vertices
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- result = deviceContext->Map(mVertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal vertex buffer for texture copy, HRESULT: 0x%X.", result);
- }
-
- UINT stride = 0;
- UINT startIdx = 0;
- UINT drawCount = 0;
- D3D11_PRIMITIVE_TOPOLOGY topology;
-
- shader.mVertexWriteFunction(sourceArea, sourceSize, destArea, destSize, mappedResource.pData,
- &stride, &drawCount, &topology);
-
- deviceContext->Unmap(mVertexBuffer, 0);
-
- // Apply vertex buffer
- deviceContext->IASetVertexBuffers(0, 1, &mVertexBuffer, &stride, &startIdx);
-
- // Apply state
- deviceContext->OMSetBlendState(NULL, NULL, 0xFFFFFFF);
- deviceContext->OMSetDepthStencilState(NULL, 0xFFFFFFFF);
-
- if (scissor)
- {
- D3D11_RECT scissorRect;
- scissorRect.left = scissor->x;
- scissorRect.right = scissor->x + scissor->width;
- scissorRect.top = scissor->y;
- scissorRect.bottom = scissor->y + scissor->height;
-
- deviceContext->RSSetScissorRects(1, &scissorRect);
- deviceContext->RSSetState(mScissorEnabledRasterizerState);
- }
- else
- {
- deviceContext->RSSetState(mScissorDisabledRasterizerState);
- }
-
- // Apply shaders
- deviceContext->IASetInputLayout(shader.mInputLayout);
- deviceContext->IASetPrimitiveTopology(topology);
- deviceContext->VSSetShader(shader.mVertexShader, NULL, 0);
-
- deviceContext->PSSetShader(shader.mPixelShader, NULL, 0);
- deviceContext->GSSetShader(shader.mGeometryShader, NULL, 0);
-
- // Unset the currently bound shader resource to avoid conflicts
- mRenderer->setShaderResource(gl::SAMPLER_PIXEL, 0, NULL);
-
- // Apply render target
- mRenderer->setOneTimeRenderTarget(dest);
-
- // Set the viewport
- D3D11_VIEWPORT viewport;
- viewport.TopLeftX = 0;
- viewport.TopLeftY = 0;
- viewport.Width = destSize.width;
- viewport.Height = destSize.height;
- viewport.MinDepth = 0.0f;
- viewport.MaxDepth = 1.0f;
- deviceContext->RSSetViewports(1, &viewport);
-
- // Apply textures
- mRenderer->setShaderResource(gl::SAMPLER_PIXEL, 0, source);
-
- // Apply samplers
- ID3D11SamplerState *sampler = NULL;
- switch (filter)
- {
- case GL_NEAREST: sampler = mPointSampler; break;
- case GL_LINEAR: sampler = mLinearSampler; break;
-
- default:
- UNREACHABLE();
- return gl::Error(GL_OUT_OF_MEMORY, "Internal error, unknown blit filter mode.");
- }
- deviceContext->PSSetSamplers(0, 1, &sampler);
-
- // Draw the quad
- deviceContext->Draw(drawCount, 0);
-
- // Unbind textures and render targets and vertex buffer
- mRenderer->setShaderResource(gl::SAMPLER_PIXEL, 0, NULL);
-
- mRenderer->unapplyRenderTargets();
-
- UINT zero = 0;
- ID3D11Buffer *const nullBuffer = NULL;
- deviceContext->IASetVertexBuffers(0, 1, &nullBuffer, &zero, &zero);
-
- mRenderer->markAllStateDirty();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Blit11::copyStencil(ID3D11Resource *source, unsigned int sourceSubresource, const gl::Box &sourceArea, const gl::Extents &sourceSize,
- ID3D11Resource *dest, unsigned int destSubresource, const gl::Box &destArea, const gl::Extents &destSize,
- const gl::Rectangle *scissor)
-{
- return copyDepthStencil(source, sourceSubresource, sourceArea, sourceSize,
- dest, destSubresource, destArea, destSize,
- scissor, true);
-}
-
-gl::Error Blit11::copyDepth(ID3D11ShaderResourceView *source, const gl::Box &sourceArea, const gl::Extents &sourceSize,
- ID3D11DepthStencilView *dest, const gl::Box &destArea, const gl::Extents &destSize,
- const gl::Rectangle *scissor)
-{
- HRESULT result;
- ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
-
- // Set vertices
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- result = deviceContext->Map(mVertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal vertex buffer for texture copy, HRESULT: 0x%X.", result);
- }
-
- UINT stride = 0;
- UINT startIdx = 0;
- UINT drawCount = 0;
- D3D11_PRIMITIVE_TOPOLOGY topology;
-
- Write2DVertices(sourceArea, sourceSize, destArea, destSize, mappedResource.pData,
- &stride, &drawCount, &topology);
-
- deviceContext->Unmap(mVertexBuffer, 0);
-
- // Apply vertex buffer
- deviceContext->IASetVertexBuffers(0, 1, &mVertexBuffer, &stride, &startIdx);
-
- // Apply state
- deviceContext->OMSetBlendState(NULL, NULL, 0xFFFFFFF);
- deviceContext->OMSetDepthStencilState(mDepthStencilState, 0xFFFFFFFF);
-
- if (scissor)
- {
- D3D11_RECT scissorRect;
- scissorRect.left = scissor->x;
- scissorRect.right = scissor->x + scissor->width;
- scissorRect.top = scissor->y;
- scissorRect.bottom = scissor->y + scissor->height;
-
- deviceContext->RSSetScissorRects(1, &scissorRect);
- deviceContext->RSSetState(mScissorEnabledRasterizerState);
- }
- else
- {
- deviceContext->RSSetState(mScissorDisabledRasterizerState);
- }
-
- // Apply shaders
- deviceContext->IASetInputLayout(mQuad2DIL);
- deviceContext->IASetPrimitiveTopology(topology);
- deviceContext->VSSetShader(mQuad2DVS, NULL, 0);
-
- deviceContext->PSSetShader(mDepthPS, NULL, 0);
- deviceContext->GSSetShader(NULL, NULL, 0);
-
- // Unset the currently bound shader resource to avoid conflicts
- mRenderer->setShaderResource(gl::SAMPLER_PIXEL, 0, NULL);
-
- // Apply render target
- deviceContext->OMSetRenderTargets(0, NULL, dest);
-
- // Set the viewport
- D3D11_VIEWPORT viewport;
- viewport.TopLeftX = 0;
- viewport.TopLeftY = 0;
- viewport.Width = destSize.width;
- viewport.Height = destSize.height;
- viewport.MinDepth = 0.0f;
- viewport.MaxDepth = 1.0f;
- deviceContext->RSSetViewports(1, &viewport);
-
- // Apply textures
- mRenderer->setShaderResource(gl::SAMPLER_PIXEL, 0, source);
-
- // Apply samplers
- deviceContext->PSSetSamplers(0, 1, &mPointSampler);
-
- // Draw the quad
- deviceContext->Draw(drawCount, 0);
-
- // Unbind textures and render targets and vertex buffer
- mRenderer->setShaderResource(gl::SAMPLER_PIXEL, 0, NULL);
-
- mRenderer->unapplyRenderTargets();
-
- UINT zero = 0;
- ID3D11Buffer *const nullBuffer = NULL;
- deviceContext->IASetVertexBuffers(0, 1, &nullBuffer, &zero, &zero);
-
- mRenderer->markAllStateDirty();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Blit11::copyDepthStencil(ID3D11Resource *source, unsigned int sourceSubresource, const gl::Box &sourceArea, const gl::Extents &sourceSize,
- ID3D11Resource *dest, unsigned int destSubresource, const gl::Box &destArea, const gl::Extents &destSize,
- const gl::Rectangle *scissor)
-{
- return copyDepthStencil(source, sourceSubresource, sourceArea, sourceSize,
- dest, destSubresource, destArea, destSize,
- scissor, false);
-}
-
-gl::Error Blit11::copyDepthStencil(ID3D11Resource *source, unsigned int sourceSubresource, const gl::Box &sourceArea, const gl::Extents &sourceSize,
- ID3D11Resource *dest, unsigned int destSubresource, const gl::Box &destArea, const gl::Extents &destSize,
- const gl::Rectangle *scissor, bool stencilOnly)
-{
- ID3D11Device *device = mRenderer->getDevice();
- ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
-
- ID3D11Resource *sourceStaging = CreateStagingTexture(device, deviceContext, source, sourceSubresource, sourceSize, D3D11_CPU_ACCESS_READ);
- // HACK: Create the destination staging buffer as a read/write texture so ID3D11DevicContext::UpdateSubresource can be called
- // using it's mapped data as a source
- ID3D11Resource *destStaging = CreateStagingTexture(device, deviceContext, dest, destSubresource, destSize, D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE);
-
- if (!sourceStaging || !destStaging)
- {
- SafeRelease(sourceStaging);
- SafeRelease(destStaging);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal staging textures for depth stencil blit.");
- }
-
- DXGI_FORMAT format = GetTextureFormat(source);
- ASSERT(format == GetTextureFormat(dest));
-
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(format);
- unsigned int pixelSize = dxgiFormatInfo.pixelBytes;
- unsigned int copyOffset = 0;
- unsigned int copySize = pixelSize;
- if (stencilOnly)
- {
- copyOffset = dxgiFormatInfo.depthBits / 8;
- copySize = dxgiFormatInfo.stencilBits / 8;
-
- // It would be expensive to have non-byte sized stencil sizes since it would
- // require reading from the destination, currently there aren't any though.
- ASSERT(dxgiFormatInfo.stencilBits % 8 == 0 &&
- dxgiFormatInfo.depthBits % 8 == 0);
- }
-
- D3D11_MAPPED_SUBRESOURCE sourceMapping;
- HRESULT result = deviceContext->Map(sourceStaging, 0, D3D11_MAP_READ, 0, &sourceMapping);
- if (FAILED(result))
- {
- SafeRelease(sourceStaging);
- SafeRelease(destStaging);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal source staging texture for depth stencil blit, HRESULT: 0x%X.", result);
- }
-
- D3D11_MAPPED_SUBRESOURCE destMapping;
- result = deviceContext->Map(destStaging, 0, D3D11_MAP_WRITE, 0, &destMapping);
- if (FAILED(result))
- {
- deviceContext->Unmap(sourceStaging, 0);
- SafeRelease(sourceStaging);
- SafeRelease(destStaging);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal destination staging texture for depth stencil blit, HRESULT: 0x%X.", result);
- }
-
- gl::Rectangle clippedDestArea(destArea.x, destArea.y, destArea.width, destArea.height);
-
- // Clip dest area to the destination size
- gl::ClipRectangle(clippedDestArea, gl::Rectangle(0, 0, destSize.width, destSize.height), &clippedDestArea);
-
- // Clip dest area to the scissor
- if (scissor)
- {
- gl::ClipRectangle(clippedDestArea, *scissor, &clippedDestArea);
- }
-
- // Determine if entire rows can be copied at once instead of each individual pixel, requires that there is
- // no out of bounds lookups required, the entire pixel is copied and no stretching
- bool wholeRowCopy = sourceArea.width == clippedDestArea.width &&
- sourceArea.x >= 0 && sourceArea.x + sourceArea.width <= sourceSize.width &&
- copySize == pixelSize;
-
- for (int y = clippedDestArea.y; y < clippedDestArea.y + clippedDestArea.height; y++)
- {
- float yPerc = static_cast<float>(y - destArea.y) / (destArea.height - 1);
-
- // Interpolate using the original source rectangle to determine which row to sample from while clamping to the edges
- unsigned int readRow = gl::clamp(sourceArea.y + floor(yPerc * (sourceArea.height - 1) + 0.5f), 0, sourceSize.height - 1);
- unsigned int writeRow = y;
-
- if (wholeRowCopy)
- {
- void *sourceRow = reinterpret_cast<char*>(sourceMapping.pData) +
- readRow * sourceMapping.RowPitch +
- sourceArea.x * pixelSize;
-
- void *destRow = reinterpret_cast<char*>(destMapping.pData) +
- writeRow * destMapping.RowPitch +
- destArea.x * pixelSize;
-
- memcpy(destRow, sourceRow, pixelSize * destArea.width);
- }
- else
- {
- for (int x = clippedDestArea.x; x < clippedDestArea.x + clippedDestArea.width; x++)
- {
- float xPerc = static_cast<float>(x - destArea.x) / (destArea.width - 1);
-
- // Interpolate the original source rectangle to determine which column to sample from while clamping to the edges
- unsigned int readColumn = gl::clamp(sourceArea.x + floor(xPerc * (sourceArea.width - 1) + 0.5f), 0, sourceSize.width - 1);
- unsigned int writeColumn = x;
-
- void *sourcePixel = reinterpret_cast<char*>(sourceMapping.pData) +
- readRow * sourceMapping.RowPitch +
- readColumn * pixelSize +
- copyOffset;
-
- void *destPixel = reinterpret_cast<char*>(destMapping.pData) +
- writeRow * destMapping.RowPitch +
- writeColumn * pixelSize +
- copyOffset;
-
- memcpy(destPixel, sourcePixel, copySize);
- }
- }
- }
-
- // HACK: Use ID3D11DevicContext::UpdateSubresource which causes an extra copy compared to ID3D11DevicContext::CopySubresourceRegion
- // according to MSDN.
- deviceContext->UpdateSubresource(dest, destSubresource, NULL, destMapping.pData, destMapping.RowPitch, destMapping.DepthPitch);
-
- deviceContext->Unmap(sourceStaging, 0);
- deviceContext->Unmap(destStaging, 0);
-
- // TODO: Determine why this call to ID3D11DevicContext::CopySubresourceRegion causes a TDR timeout on some
- // systems when called repeatedly.
- // deviceContext->CopySubresourceRegion(dest, destSubresource, 0, 0, 0, destStaging, 0, NULL);
-
- SafeRelease(sourceStaging);
- SafeRelease(destStaging);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-bool Blit11::compareBlitParameters(const Blit11::BlitParameters &a, const Blit11::BlitParameters &b)
-{
- return memcmp(&a, &b, sizeof(Blit11::BlitParameters)) < 0;
-}
-
-bool Blit11::compareSwizzleParameters(const SwizzleParameters &a, const SwizzleParameters &b)
-{
- return memcmp(&a, &b, sizeof(Blit11::SwizzleParameters)) < 0;
-}
-
-void Blit11::add2DBlitShaderToMap(GLenum destFormat, bool signedInteger, ID3D11PixelShader *ps)
-{
- BlitParameters params = { 0 };
- params.mDestinationFormat = destFormat;
- params.mSignedInteger = signedInteger;
- params.m3DBlit = false;
-
- ASSERT(mBlitShaderMap.find(params) == mBlitShaderMap.end());
- ASSERT(ps);
-
- Shader shader;
- shader.mVertexWriteFunction = Write2DVertices;
- shader.mInputLayout = mQuad2DIL;
- shader.mVertexShader = mQuad2DVS;
- shader.mGeometryShader = NULL;
- shader.mPixelShader = ps;
-
- mBlitShaderMap[params] = shader;
-}
-
-void Blit11::add3DBlitShaderToMap(GLenum destFormat, bool signedInteger, ID3D11PixelShader *ps)
-{
- BlitParameters params = { 0 };
- params.mDestinationFormat = destFormat;
- params.mSignedInteger = signedInteger;
- params.m3DBlit = true;
-
- ASSERT(mBlitShaderMap.find(params) == mBlitShaderMap.end());
- ASSERT(ps);
-
- Shader shader;
- shader.mVertexWriteFunction = Write3DVertices;
- shader.mInputLayout = mQuad3DIL;
- shader.mVertexShader = mQuad3DVS;
- shader.mGeometryShader = mQuad3DGS;
- shader.mPixelShader = ps;
-
- mBlitShaderMap[params] = shader;
-}
-
-void Blit11::addSwizzleShaderToMap(GLenum destType, D3D11_SRV_DIMENSION viewDimension, ID3D11PixelShader *ps)
-{
- SwizzleParameters params = { 0 };
- params.mDestinationType = destType;
- params.mViewDimension = viewDimension;
-
- ASSERT(mSwizzleShaderMap.find(params) == mSwizzleShaderMap.end());
- ASSERT(ps);
-
- Shader shader;
- switch (viewDimension)
- {
- case D3D_SRV_DIMENSION_TEXTURE2D:
- shader.mVertexWriteFunction = Write2DVertices;
- shader.mInputLayout = mQuad2DIL;
- shader.mVertexShader = mQuad2DVS;
- shader.mGeometryShader = NULL;
- break;
-
- case D3D_SRV_DIMENSION_TEXTURE3D:
- case D3D_SRV_DIMENSION_TEXTURE2DARRAY:
- case D3D_SRV_DIMENSION_TEXTURECUBE:
- shader.mVertexWriteFunction = Write3DVertices;
- shader.mInputLayout = mQuad3DIL;
- shader.mVertexShader = mQuad3DVS;
- shader.mGeometryShader = mQuad3DGS;
- break;
-
- default:
- UNREACHABLE();
- break;
- }
- shader.mPixelShader = ps;
-
- mSwizzleShaderMap[params] = shader;
-}
-
-void Blit11::buildShaderMap()
-{
- ID3D11Device *device = mRenderer->getDevice();
-
- add2DBlitShaderToMap(GL_RGBA, false, d3d11::CompilePS(device, g_PS_PassthroughRGBA2D, "Blit11 2D RGBA pixel shader" ));
- add2DBlitShaderToMap(GL_BGRA_EXT, false, d3d11::CompilePS(device, g_PS_PassthroughRGBA2D, "Blit11 2D BGRA pixel shader" ));
- add2DBlitShaderToMap(GL_RGB, false, d3d11::CompilePS(device, g_PS_PassthroughRGB2D, "Blit11 2D RGB pixel shader" ));
- add2DBlitShaderToMap(GL_RG, false, d3d11::CompilePS(device, g_PS_PassthroughRG2D, "Blit11 2D RG pixel shader" ));
- add2DBlitShaderToMap(GL_RED, false, d3d11::CompilePS(device, g_PS_PassthroughR2D, "Blit11 2D R pixel shader" ));
- add2DBlitShaderToMap(GL_ALPHA, false, d3d11::CompilePS(device, g_PS_PassthroughRGBA2D, "Blit11 2D alpha pixel shader" ));
- add2DBlitShaderToMap(GL_LUMINANCE, false, d3d11::CompilePS(device, g_PS_PassthroughLum2D, "Blit11 2D lum pixel shader" ));
- add2DBlitShaderToMap(GL_LUMINANCE_ALPHA, false, d3d11::CompilePS(device, g_PS_PassthroughLumAlpha2D, "Blit11 2D luminance alpha pixel shader"));
-
- addSwizzleShaderToMap(GL_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, d3d11::CompilePS(device, g_PS_SwizzleF2D, "Blit11 2D F swizzle pixel shader" ));
-
- if (mRenderer->isLevel9())
- return;
-
- add2DBlitShaderToMap(GL_RGBA_INTEGER, false, d3d11::CompilePS(device, g_PS_PassthroughRGBA2DUI, "Blit11 2D RGBA UI pixel shader" ));
- add2DBlitShaderToMap(GL_RGBA_INTEGER, true, d3d11::CompilePS(device, g_PS_PassthroughRGBA2DI, "Blit11 2D RGBA I pixel shader" ));
- add2DBlitShaderToMap(GL_RGB_INTEGER, false, d3d11::CompilePS(device, g_PS_PassthroughRGB2DUI, "Blit11 2D RGB UI pixel shader" ));
- add2DBlitShaderToMap(GL_RGB_INTEGER, true, d3d11::CompilePS(device, g_PS_PassthroughRGB2DI, "Blit11 2D RGB I pixel shader" ));
- add2DBlitShaderToMap(GL_RG_INTEGER, false, d3d11::CompilePS(device, g_PS_PassthroughRG2DUI, "Blit11 2D RG UI pixel shader" ));
- add2DBlitShaderToMap(GL_RG_INTEGER, true, d3d11::CompilePS(device, g_PS_PassthroughRG2DI, "Blit11 2D RG I pixel shader" ));
- add2DBlitShaderToMap(GL_RED_INTEGER, false, d3d11::CompilePS(device, g_PS_PassthroughR2DUI, "Blit11 2D R UI pixel shader" ));
- add2DBlitShaderToMap(GL_RED_INTEGER, true, d3d11::CompilePS(device, g_PS_PassthroughR2DI, "Blit11 2D R I pixel shader" ));
- add3DBlitShaderToMap(GL_RGBA, false, d3d11::CompilePS(device, g_PS_PassthroughRGBA3D, "Blit11 3D RGBA pixel shader" ));
- add3DBlitShaderToMap(GL_RGBA_INTEGER, false, d3d11::CompilePS(device, g_PS_PassthroughRGBA3DUI, "Blit11 3D UI RGBA pixel shader" ));
- add3DBlitShaderToMap(GL_RGBA_INTEGER, true, d3d11::CompilePS(device, g_PS_PassthroughRGBA3DI, "Blit11 3D I RGBA pixel shader" ));
- add3DBlitShaderToMap(GL_BGRA_EXT, false, d3d11::CompilePS(device, g_PS_PassthroughRGBA3D, "Blit11 3D BGRA pixel shader" ));
- add3DBlitShaderToMap(GL_RGB, false, d3d11::CompilePS(device, g_PS_PassthroughRGB3D, "Blit11 3D RGB pixel shader" ));
- add3DBlitShaderToMap(GL_RGB_INTEGER, false, d3d11::CompilePS(device, g_PS_PassthroughRGB3DUI, "Blit11 3D RGB UI pixel shader" ));
- add3DBlitShaderToMap(GL_RGB_INTEGER, true, d3d11::CompilePS(device, g_PS_PassthroughRGB3DI, "Blit11 3D RGB I pixel shader" ));
- add3DBlitShaderToMap(GL_RG, false, d3d11::CompilePS(device, g_PS_PassthroughRG3D, "Blit11 3D RG pixel shader" ));
- add3DBlitShaderToMap(GL_RG_INTEGER, false, d3d11::CompilePS(device, g_PS_PassthroughRG3DUI, "Blit11 3D RG UI pixel shader" ));
- add3DBlitShaderToMap(GL_RG_INTEGER, true, d3d11::CompilePS(device, g_PS_PassthroughRG3DI, "Blit11 3D RG I pixel shader" ));
- add3DBlitShaderToMap(GL_RED, false, d3d11::CompilePS(device, g_PS_PassthroughR3D, "Blit11 3D R pixel shader" ));
- add3DBlitShaderToMap(GL_RED_INTEGER, false, d3d11::CompilePS(device, g_PS_PassthroughR3DUI, "Blit11 3D R UI pixel shader" ));
- add3DBlitShaderToMap(GL_RED_INTEGER, true, d3d11::CompilePS(device, g_PS_PassthroughR3DI, "Blit11 3D R I pixel shader" ));
- add3DBlitShaderToMap(GL_ALPHA, false, d3d11::CompilePS(device, g_PS_PassthroughRGBA3D, "Blit11 3D alpha pixel shader" ));
- add3DBlitShaderToMap(GL_LUMINANCE, false, d3d11::CompilePS(device, g_PS_PassthroughLum3D, "Blit11 3D luminance pixel shader" ));
- add3DBlitShaderToMap(GL_LUMINANCE_ALPHA, false, d3d11::CompilePS(device, g_PS_PassthroughLumAlpha3D, "Blit11 3D luminance alpha pixel shader"));
-
- addSwizzleShaderToMap(GL_UNSIGNED_INT, D3D_SRV_DIMENSION_TEXTURE2D, d3d11::CompilePS(device, g_PS_SwizzleUI2D, "Blit11 2D UI swizzle pixel shader"));
- addSwizzleShaderToMap(GL_INT, D3D_SRV_DIMENSION_TEXTURE2D, d3d11::CompilePS(device, g_PS_SwizzleI2D, "Blit11 2D I swizzle pixel shader" ));
-
- addSwizzleShaderToMap(GL_FLOAT, D3D_SRV_DIMENSION_TEXTURECUBE, d3d11::CompilePS(device, g_PS_SwizzleF2DArray, "Blit11 2D Cube F swizzle pixel shader" ));
- addSwizzleShaderToMap(GL_UNSIGNED_INT, D3D_SRV_DIMENSION_TEXTURECUBE, d3d11::CompilePS(device, g_PS_SwizzleUI2DArray, "Blit11 2D Cube UI swizzle pixel shader"));
- addSwizzleShaderToMap(GL_INT, D3D_SRV_DIMENSION_TEXTURECUBE, d3d11::CompilePS(device, g_PS_SwizzleI2DArray, "Blit11 2D Cube I swizzle pixel shader" ));
-
- addSwizzleShaderToMap(GL_FLOAT, D3D_SRV_DIMENSION_TEXTURE3D, d3d11::CompilePS(device, g_PS_SwizzleF3D, "Blit11 3D F swizzle pixel shader" ));
- addSwizzleShaderToMap(GL_UNSIGNED_INT, D3D_SRV_DIMENSION_TEXTURE3D, d3d11::CompilePS(device, g_PS_SwizzleUI3D, "Blit11 3D UI swizzle pixel shader"));
- addSwizzleShaderToMap(GL_INT, D3D_SRV_DIMENSION_TEXTURE3D, d3d11::CompilePS(device, g_PS_SwizzleI3D, "Blit11 3D I swizzle pixel shader" ));
-
- addSwizzleShaderToMap(GL_FLOAT, D3D_SRV_DIMENSION_TEXTURE2DARRAY, d3d11::CompilePS(device, g_PS_SwizzleF2DArray, "Blit11 2D Array F swizzle pixel shader" ));
- addSwizzleShaderToMap(GL_UNSIGNED_INT, D3D_SRV_DIMENSION_TEXTURE2DARRAY, d3d11::CompilePS(device, g_PS_SwizzleUI2DArray, "Blit11 2D Array UI swizzle pixel shader"));
- addSwizzleShaderToMap(GL_INT, D3D_SRV_DIMENSION_TEXTURE2DARRAY, d3d11::CompilePS(device, g_PS_SwizzleI2DArray, "Blit11 2D Array I swizzle pixel shader" ));
-}
-
-void Blit11::clearShaderMap()
-{
- for (BlitShaderMap::iterator i = mBlitShaderMap.begin(); i != mBlitShaderMap.end(); ++i)
- {
- Shader &shader = i->second;
- SafeRelease(shader.mPixelShader);
- }
- mBlitShaderMap.clear();
-
- for (SwizzleShaderMap::iterator i = mSwizzleShaderMap.begin(); i != mSwizzleShaderMap.end(); ++i)
- {
- Shader &shader = i->second;
- SafeRelease(shader.mPixelShader);
- }
- mSwizzleShaderMap.clear();
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.h
deleted file mode 100644
index 821fa9d0cc..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.h
+++ /dev/null
@@ -1,123 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// Blit11.cpp: Texture copy utility class.
-
-#ifndef LIBGLESV2_BLIT11_H_
-#define LIBGLESV2_BLIT11_H_
-
-#include "common/angleutils.h"
-#include "libGLESv2/angletypes.h"
-#include "libGLESv2/Error.h"
-
-#include <map>
-
-namespace rx
-{
-class Renderer11;
-
-class Blit11
-{
- public:
- explicit Blit11(Renderer11 *renderer);
- ~Blit11();
-
- gl::Error swizzleTexture(ID3D11ShaderResourceView *source, ID3D11RenderTargetView *dest, const gl::Extents &size,
- GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha);
-
- gl::Error copyTexture(ID3D11ShaderResourceView *source, const gl::Box &sourceArea, const gl::Extents &sourceSize,
- ID3D11RenderTargetView *dest, const gl::Box &destArea, const gl::Extents &destSize,
- const gl::Rectangle *scissor, GLenum destFormat, GLenum filter);
-
- gl::Error copyStencil(ID3D11Resource *source, unsigned int sourceSubresource, const gl::Box &sourceArea, const gl::Extents &sourceSize,
- ID3D11Resource *dest, unsigned int destSubresource, const gl::Box &destArea, const gl::Extents &destSize,
- const gl::Rectangle *scissor);
-
- gl::Error copyDepth(ID3D11ShaderResourceView *source, const gl::Box &sourceArea, const gl::Extents &sourceSize,
- ID3D11DepthStencilView *dest, const gl::Box &destArea, const gl::Extents &destSize,
- const gl::Rectangle *scissor);
-
- gl::Error copyDepthStencil(ID3D11Resource *source, unsigned int sourceSubresource, const gl::Box &sourceArea, const gl::Extents &sourceSize,
- ID3D11Resource *dest, unsigned int destSubresource, const gl::Box &destArea, const gl::Extents &destSize,
- const gl::Rectangle *scissor);
-
- private:
- Renderer11 *mRenderer;
-
- struct BlitParameters
- {
- GLenum mDestinationFormat;
- bool mSignedInteger;
- bool m3DBlit;
- };
-
- gl::Error copyDepthStencil(ID3D11Resource *source, unsigned int sourceSubresource, const gl::Box &sourceArea, const gl::Extents &sourceSize,
- ID3D11Resource *dest, unsigned int destSubresource, const gl::Box &destArea, const gl::Extents &destSize,
- const gl::Rectangle *scissor, bool stencilOnly);
-
- static bool compareBlitParameters(const BlitParameters &a, const BlitParameters &b);
-
- typedef void (*WriteVertexFunction)(const gl::Box &sourceArea, const gl::Extents &sourceSize,
- const gl::Box &destArea, const gl::Extents &destSize,
- void *outVertices, unsigned int *outStride, unsigned int *outVertexCount,
- D3D11_PRIMITIVE_TOPOLOGY *outTopology);
-
- struct Shader
- {
- WriteVertexFunction mVertexWriteFunction;
- ID3D11InputLayout *mInputLayout;
- ID3D11VertexShader *mVertexShader;
- ID3D11GeometryShader *mGeometryShader;
- ID3D11PixelShader *mPixelShader;
- };
-
- typedef bool (*BlitParametersComparisonFunction)(const BlitParameters&, const BlitParameters &);
- typedef std::map<BlitParameters, Shader, BlitParametersComparisonFunction> BlitShaderMap;
- BlitShaderMap mBlitShaderMap;
-
- void add2DBlitShaderToMap(GLenum destFormat, bool signedInteger, ID3D11PixelShader *ps);
- void add3DBlitShaderToMap(GLenum destFormat, bool signedInteger, ID3D11PixelShader *ps);
-
- struct SwizzleParameters
- {
- GLenum mDestinationType;
- D3D11_SRV_DIMENSION mViewDimension;
- };
-
- static bool compareSwizzleParameters(const SwizzleParameters &a, const SwizzleParameters &b);
-
- typedef bool (*SwizzleParametersComparisonFunction)(const SwizzleParameters&, const SwizzleParameters &);
- typedef std::map<SwizzleParameters, Shader, SwizzleParametersComparisonFunction> SwizzleShaderMap;
- SwizzleShaderMap mSwizzleShaderMap;
-
- void addSwizzleShaderToMap(GLenum destType, D3D11_SRV_DIMENSION viewDimension, ID3D11PixelShader *ps);
-
- void buildShaderMap();
- void clearShaderMap();
-
- ID3D11Buffer *mVertexBuffer;
- ID3D11SamplerState *mPointSampler;
- ID3D11SamplerState *mLinearSampler;
- ID3D11RasterizerState *mScissorEnabledRasterizerState;
- ID3D11RasterizerState *mScissorDisabledRasterizerState;
- ID3D11DepthStencilState *mDepthStencilState;
-
- ID3D11InputLayout *mQuad2DIL;
- ID3D11VertexShader *mQuad2DVS;
- ID3D11PixelShader *mDepthPS;
-
- ID3D11InputLayout *mQuad3DIL;
- ID3D11VertexShader *mQuad3DVS;
- ID3D11GeometryShader *mQuad3DGS;
-
- ID3D11Buffer *mSwizzleCB;
-
- DISALLOW_COPY_AND_ASSIGN(Blit11);
-};
-
-}
-
-#endif // LIBGLESV2_BLIT11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.cpp
deleted file mode 100644
index 5aab37938f..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.cpp
+++ /dev/null
@@ -1,983 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// Buffer11.cpp Defines the Buffer11 class.
-
-#include "libGLESv2/renderer/d3d/d3d11/Buffer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h"
-#include "libGLESv2/main.h"
-
-namespace rx
-{
-
-PackPixelsParams::PackPixelsParams()
- : format(GL_NONE),
- type(GL_NONE),
- outputPitch(0),
- packBuffer(NULL),
- offset(0)
-{}
-
-PackPixelsParams::PackPixelsParams(const gl::Rectangle &areaIn, GLenum formatIn, GLenum typeIn, GLuint outputPitchIn,
- const gl::PixelPackState &packIn, ptrdiff_t offsetIn)
- : area(areaIn),
- format(formatIn),
- type(typeIn),
- outputPitch(outputPitchIn),
- packBuffer(packIn.pixelBuffer.get()),
- pack(packIn.alignment, packIn.reverseRowOrder),
- offset(offsetIn)
-{}
-
-namespace gl_d3d11
-{
-
-D3D11_MAP GetD3DMapTypeFromBits(GLbitfield access)
-{
- bool readBit = ((access & GL_MAP_READ_BIT) != 0);
- bool writeBit = ((access & GL_MAP_WRITE_BIT) != 0);
-
- ASSERT(readBit || writeBit);
-
- // Note : we ignore the discard bit, because in D3D11, staging buffers
- // don't accept the map-discard flag (discard only works for DYNAMIC usage)
-
- if (readBit && !writeBit)
- {
- return D3D11_MAP_READ;
- }
- else if (writeBit && !readBit)
- {
- return D3D11_MAP_WRITE;
- }
- else if (writeBit && readBit)
- {
- return D3D11_MAP_READ_WRITE;
- }
- else
- {
- UNREACHABLE();
- return D3D11_MAP_READ;
- }
-}
-
-}
-
-// Each instance of Buffer11::BufferStorage11 is specialized for a class of D3D binding points
-// - vertex/transform feedback buffers
-// - index buffers
-// - pixel unpack buffers
-// - uniform buffers
-class Buffer11::BufferStorage11
-{
- public:
- virtual ~BufferStorage11() {}
-
- DataRevision getDataRevision() const { return mRevision; }
- BufferUsage getUsage() const { return mUsage; }
- size_t getSize() const { return mBufferSize; }
- bool isMappable() const { return (mUsage == BUFFER_USAGE_STAGING || mUsage == BUFFER_USAGE_PIXEL_PACK); }
-
- void setDataRevision(DataRevision rev) { mRevision = rev; }
-
- virtual bool copyFromStorage(BufferStorage11 *source, size_t sourceOffset,
- size_t size, size_t destOffset) = 0;
- virtual gl::Error resize(size_t size, bool preserveData) = 0;
-
- virtual void *map(size_t offset, size_t length, GLbitfield access) = 0;
- virtual void unmap() = 0;
-
- protected:
- BufferStorage11(Renderer11 *renderer, BufferUsage usage);
-
- Renderer11 *mRenderer;
- DataRevision mRevision;
- const BufferUsage mUsage;
- size_t mBufferSize;
-};
-
-// A native buffer storage represents an underlying D3D11 buffer for a particular
-// type of storage.
-class Buffer11::NativeBuffer11 : public Buffer11::BufferStorage11
-{
- public:
- NativeBuffer11(Renderer11 *renderer, BufferUsage usage);
- ~NativeBuffer11();
-
- ID3D11Buffer *getNativeBuffer() const { return mNativeBuffer; }
-
- virtual bool copyFromStorage(BufferStorage11 *source, size_t sourceOffset,
- size_t size, size_t destOffset);
- virtual gl::Error resize(size_t size, bool preserveData);
-
- virtual void *map(size_t offset, size_t length, GLbitfield access);
- virtual void unmap();
-
- gl::Error setData(D3D11_MAP mapMode, const uint8_t *data, size_t size, size_t offset);
-
- private:
- ID3D11Buffer *mNativeBuffer;
-
- static void fillBufferDesc(D3D11_BUFFER_DESC* bufferDesc, Renderer11 *renderer, BufferUsage usage, unsigned int bufferSize);
-};
-
-// Pack storage represents internal storage for pack buffers. We implement pack buffers
-// as CPU memory, tied to a staging texture, for asynchronous texture readback.
-class Buffer11::PackStorage11 : public Buffer11::BufferStorage11
-{
- public:
- PackStorage11(Renderer11 *renderer);
- ~PackStorage11();
-
- virtual bool copyFromStorage(BufferStorage11 *source, size_t sourceOffset,
- size_t size, size_t destOffset);
- virtual gl::Error resize(size_t size, bool preserveData);
-
- virtual void *map(size_t offset, size_t length, GLbitfield access);
- virtual void unmap();
-
- gl::Error packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams &params);
-
- private:
-
- gl::Error flushQueuedPackCommand();
-
- ID3D11Texture2D *mStagingTexture;
- DXGI_FORMAT mTextureFormat;
- gl::Extents mTextureSize;
- MemoryBuffer mMemoryBuffer;
- PackPixelsParams *mQueuedPackCommand;
- PackPixelsParams mPackParams;
- bool mDataModified;
-};
-
-
-Buffer11::Buffer11(Renderer11 *renderer)
- : BufferD3D(),
- mRenderer(renderer),
- mSize(0),
- mMappedStorage(NULL),
- mResolvedDataRevision(0),
- mReadUsageCount(0)
-{}
-
-Buffer11::~Buffer11()
-{
- for (auto it = mBufferStorages.begin(); it != mBufferStorages.end(); it++)
- {
- SafeDelete(it->second);
- }
-}
-
-Buffer11 *Buffer11::makeBuffer11(BufferImpl *buffer)
-{
- ASSERT(HAS_DYNAMIC_TYPE(Buffer11*, buffer));
- return static_cast<Buffer11*>(buffer);
-}
-
-gl::Error Buffer11::setData(const void *data, size_t size, GLenum usage)
-{
- gl::Error error = setSubData(data, size, 0);
- if (error.isError())
- {
- return error;
- }
-
- if (usage == GL_STATIC_DRAW)
- {
- initializeStaticData();
- }
-
- return error;
-}
-
-gl::Error Buffer11::getData(const uint8_t **outData)
-{
- NativeBuffer11 *stagingBuffer = getStagingBuffer();
-
- if (!stagingBuffer)
- {
- // Out-of-memory
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to get internal staging buffer.");
- }
-
- if (stagingBuffer->getDataRevision() > mResolvedDataRevision)
- {
- if (stagingBuffer->getSize() > mResolvedData.size())
- {
- if (!mResolvedData.resize(stagingBuffer->getSize()))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to resize data resolve buffer.");
- }
- }
-
- ID3D11DeviceContext *context = mRenderer->getDeviceContext();
-
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- HRESULT result = context->Map(stagingBuffer->getNativeBuffer(), 0, D3D11_MAP_READ, 0, &mappedResource);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal buffer, result: 0x%X.", result);
- }
-
- memcpy(mResolvedData.data(), mappedResource.pData, stagingBuffer->getSize());
-
- context->Unmap(stagingBuffer->getNativeBuffer(), 0);
-
- mResolvedDataRevision = stagingBuffer->getDataRevision();
- }
-
- mReadUsageCount = 0;
-
- // Only happens if we initialized the buffer with no data (NULL)
- if (mResolvedData.empty())
- {
- if (!mResolvedData.resize(mSize))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to resize data resolve buffer.");
- }
- }
-
- ASSERT(mResolvedData.size() >= mSize);
-
- *outData = mResolvedData.data();
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Buffer11::setSubData(const void *data, size_t size, size_t offset)
-{
- size_t requiredSize = size + offset;
-
- if (data && size > 0)
- {
- NativeBuffer11 *stagingBuffer = getStagingBuffer();
-
- if (!stagingBuffer)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate internal staging buffer.");
- }
-
- // Explicitly resize the staging buffer, preserving data if the new data will not
- // completely fill the buffer
- if (stagingBuffer->getSize() < requiredSize)
- {
- bool preserveData = (offset > 0);
- gl::Error error = stagingBuffer->resize(requiredSize, preserveData);
- if (error.isError())
- {
- return error;
- }
- }
-
- gl::Error error = stagingBuffer->setData(D3D11_MAP_WRITE, reinterpret_cast<const uint8_t *>(data), size, offset);
- if (error.isError())
- {
- return error;
- }
-
- stagingBuffer->setDataRevision(stagingBuffer->getDataRevision() + 1);
- }
-
- mSize = std::max(mSize, requiredSize);
- invalidateStaticData();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Buffer11::copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size)
-{
- Buffer11 *sourceBuffer = makeBuffer11(source);
- ASSERT(sourceBuffer != NULL);
-
- BufferStorage11 *copyDest = getLatestBufferStorage();
- if (!copyDest)
- {
- copyDest = getStagingBuffer();
- }
-
- BufferStorage11 *copySource = sourceBuffer->getLatestBufferStorage();
-
- if (!copySource || !copyDest)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate internal staging buffer.");
- }
-
- // If copying to/from a pixel pack buffer, we must have a staging or
- // pack buffer partner, because other native buffers can't be mapped
- if (copyDest->getUsage() == BUFFER_USAGE_PIXEL_PACK && !copySource->isMappable())
- {
- copySource = sourceBuffer->getStagingBuffer();
- }
- else if (copySource->getUsage() == BUFFER_USAGE_PIXEL_PACK && !copyDest->isMappable())
- {
- copyDest = getStagingBuffer();
- }
-
- // D3D11 does not allow overlapped copies until 11.1, and only if the
- // device supports D3D11_FEATURE_DATA_D3D11_OPTIONS::CopyWithOverlap
- // Get around this via a different source buffer
- if (copySource == copyDest)
- {
- if (copySource->getUsage() == BUFFER_USAGE_STAGING)
- {
- copySource = getBufferStorage(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK);
- }
- else
- {
- copySource = getStagingBuffer();
- }
- }
-
- copyDest->copyFromStorage(copySource, sourceOffset, size, destOffset);
- copyDest->setDataRevision(copyDest->getDataRevision() + 1);
-
- mSize = std::max<size_t>(mSize, destOffset + size);
- invalidateStaticData();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Buffer11::map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr)
-{
- ASSERT(!mMappedStorage);
-
- BufferStorage11 *latestStorage = getLatestBufferStorage();
- if (latestStorage &&
- (latestStorage->getUsage() == BUFFER_USAGE_PIXEL_PACK ||
- latestStorage->getUsage() == BUFFER_USAGE_STAGING))
- {
- // Latest storage is mappable.
- mMappedStorage = latestStorage;
- }
- else
- {
- // Fall back to using the staging buffer if the latest storage does
- // not exist or is not CPU-accessible.
- mMappedStorage = getStagingBuffer();
- }
-
- if (!mMappedStorage)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate mappable internal buffer.");
- }
-
- if ((access & GL_MAP_WRITE_BIT) > 0)
- {
- // Update the data revision immediately, since the data might be changed at any time
- mMappedStorage->setDataRevision(mMappedStorage->getDataRevision() + 1);
- }
-
- void *mappedBuffer = mMappedStorage->map(offset, length, access);
- if (!mappedBuffer)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal buffer.");
- }
-
- *mapPtr = mappedBuffer;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Buffer11::unmap()
-{
- ASSERT(mMappedStorage);
- mMappedStorage->unmap();
- mMappedStorage = NULL;
- return gl::Error(GL_NO_ERROR);
-}
-
-void Buffer11::markTransformFeedbackUsage()
-{
- BufferStorage11 *transformFeedbackStorage = getBufferStorage(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK);
-
- if (transformFeedbackStorage)
- {
- transformFeedbackStorage->setDataRevision(transformFeedbackStorage->getDataRevision() + 1);
- }
-
- invalidateStaticData();
-}
-
-void Buffer11::markBufferUsage()
-{
- mReadUsageCount++;
-
- const unsigned int usageLimit = 5;
-
- if (mReadUsageCount > usageLimit && mResolvedData.size() > 0)
- {
- mResolvedData.resize(0);
- mResolvedDataRevision = 0;
- }
-}
-
-RendererD3D* Buffer11::getRenderer()
-{
- return mRenderer;
-}
-
-ID3D11Buffer *Buffer11::getBuffer(BufferUsage usage)
-{
- markBufferUsage();
-
- BufferStorage11 *bufferStorage = getBufferStorage(usage);
-
- if (!bufferStorage)
- {
- // Storage out-of-memory
- return NULL;
- }
-
- ASSERT(HAS_DYNAMIC_TYPE(NativeBuffer11*, bufferStorage));
-
- return static_cast<NativeBuffer11*>(bufferStorage)->getNativeBuffer();
-}
-
-ID3D11ShaderResourceView *Buffer11::getSRV(DXGI_FORMAT srvFormat)
-{
- BufferStorage11 *storage = getBufferStorage(BUFFER_USAGE_PIXEL_UNPACK);
-
- if (!storage)
- {
- // Storage out-of-memory
- return NULL;
- }
-
- ASSERT(HAS_DYNAMIC_TYPE(NativeBuffer11*, storage));
- ID3D11Buffer *buffer = static_cast<NativeBuffer11*>(storage)->getNativeBuffer();
-
- auto bufferSRVIt = mBufferResourceViews.find(srvFormat);
-
- if (bufferSRVIt != mBufferResourceViews.end())
- {
- if (bufferSRVIt->second.first == buffer)
- {
- return bufferSRVIt->second.second;
- }
- else
- {
- // The underlying buffer has changed since the SRV was created: recreate the SRV.
- SafeRelease(bufferSRVIt->second.second);
- }
- }
-
- ID3D11Device *device = mRenderer->getDevice();
- ID3D11ShaderResourceView *bufferSRV = NULL;
-
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(srvFormat);
-
- D3D11_SHADER_RESOURCE_VIEW_DESC bufferSRVDesc;
- bufferSRVDesc.Buffer.ElementOffset = 0;
- bufferSRVDesc.Buffer.ElementWidth = mSize / dxgiFormatInfo.pixelBytes;
- bufferSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
- bufferSRVDesc.Format = srvFormat;
-
- HRESULT result = device->CreateShaderResourceView(buffer, &bufferSRVDesc, &bufferSRV);
- UNUSED_ASSERTION_VARIABLE(result);
- ASSERT(SUCCEEDED(result));
-
- mBufferResourceViews[srvFormat] = BufferSRVPair(buffer, bufferSRV);
-
- return bufferSRV;
-}
-
-gl::Error Buffer11::packPixels(ID3D11Texture2D *srcTexture, UINT srcSubresource, const PackPixelsParams &params)
-{
- PackStorage11 *packStorage = getPackStorage();
-
- BufferStorage11 *latestStorage = getLatestBufferStorage();
-
- if (packStorage)
- {
- gl::Error error = packStorage->packPixels(srcTexture, srcSubresource, params);
- if (error.isError())
- {
- return error;
- }
- packStorage->setDataRevision(latestStorage ? latestStorage->getDataRevision() + 1 : 1);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-Buffer11::BufferStorage11 *Buffer11::getBufferStorage(BufferUsage usage)
-{
- BufferStorage11 *directBuffer = NULL;
- auto directBufferIt = mBufferStorages.find(usage);
- if (directBufferIt != mBufferStorages.end())
- {
- directBuffer = directBufferIt->second;
- }
-
- if (!directBuffer)
- {
- if (usage == BUFFER_USAGE_PIXEL_PACK)
- {
- directBuffer = new PackStorage11(mRenderer);
- }
- else
- {
- // buffer is not allocated, create it
- directBuffer = new NativeBuffer11(mRenderer, usage);
- }
-
- mBufferStorages.insert(std::make_pair(usage, directBuffer));
- }
-
- // resize buffer
- if (directBuffer->getSize() < mSize)
- {
- if (directBuffer->resize(mSize, true).isError())
- {
- // Out of memory error
- return NULL;
- }
- }
-
- BufferStorage11 *latestBuffer = getLatestBufferStorage();
- if (latestBuffer && latestBuffer->getDataRevision() > directBuffer->getDataRevision())
- {
- // if copying from a pack buffer to a non-staging native buffer, we must first
- // copy through the staging buffer, because other native buffers can't be mapped
- if (latestBuffer->getUsage() == BUFFER_USAGE_PIXEL_PACK && !directBuffer->isMappable())
- {
- NativeBuffer11 *stagingBuffer = getStagingBuffer();
-
- stagingBuffer->copyFromStorage(latestBuffer, 0, latestBuffer->getSize(), 0);
- directBuffer->setDataRevision(latestBuffer->getDataRevision());
-
- latestBuffer = stagingBuffer;
- }
-
- // if copyFromStorage returns true, the D3D buffer has been recreated
- // and we should update our serial
- if (directBuffer->copyFromStorage(latestBuffer, 0, latestBuffer->getSize(), 0))
- {
- updateSerial();
- }
- directBuffer->setDataRevision(latestBuffer->getDataRevision());
- }
-
- return directBuffer;
-}
-
-Buffer11::BufferStorage11 *Buffer11::getLatestBufferStorage() const
-{
- // Even though we iterate over all the direct buffers, it is expected that only
- // 1 or 2 will be present.
- BufferStorage11 *latestStorage = NULL;
- DataRevision latestRevision = 0;
- for (auto it = mBufferStorages.begin(); it != mBufferStorages.end(); it++)
- {
- BufferStorage11 *storage = it->second;
- if (!latestStorage || storage->getDataRevision() > latestRevision)
- {
- latestStorage = storage;
- latestRevision = storage->getDataRevision();
- }
- }
-
- return latestStorage;
-}
-
-Buffer11::NativeBuffer11 *Buffer11::getStagingBuffer()
-{
- BufferStorage11 *stagingStorage = getBufferStorage(BUFFER_USAGE_STAGING);
-
- if (!stagingStorage)
- {
- // Out-of-memory
- return NULL;
- }
-
- ASSERT(HAS_DYNAMIC_TYPE(NativeBuffer11*, stagingStorage));
- return static_cast<NativeBuffer11*>(stagingStorage);
-}
-
-Buffer11::PackStorage11 *Buffer11::getPackStorage()
-{
- BufferStorage11 *packStorage = getBufferStorage(BUFFER_USAGE_PIXEL_PACK);
-
- if (!packStorage)
- {
- // Out-of-memory
- return NULL;
- }
-
- ASSERT(HAS_DYNAMIC_TYPE(PackStorage11*, packStorage));
- return static_cast<PackStorage11*>(packStorage);
-}
-
-bool Buffer11::supportsDirectBinding() const
-{
- // Do not support direct buffers for dynamic data. The streaming buffer
- // offers better performance for data which changes every frame.
- // Check for absence of static buffer interfaces to detect dynamic data.
- return (mStaticVertexBuffer && mStaticIndexBuffer);
-}
-
-Buffer11::BufferStorage11::BufferStorage11(Renderer11 *renderer, BufferUsage usage)
- : mRenderer(renderer),
- mUsage(usage),
- mRevision(0),
- mBufferSize(0)
-{
-}
-
-Buffer11::NativeBuffer11::NativeBuffer11(Renderer11 *renderer, BufferUsage usage)
- : BufferStorage11(renderer, usage),
- mNativeBuffer(NULL)
-{
-}
-
-Buffer11::NativeBuffer11::~NativeBuffer11()
-{
- SafeRelease(mNativeBuffer);
-}
-
-// Returns true if it recreates the direct buffer
-bool Buffer11::NativeBuffer11::copyFromStorage(BufferStorage11 *source, size_t sourceOffset,
- size_t size, size_t destOffset)
-{
- ID3D11DeviceContext *context = mRenderer->getDeviceContext();
-
- size_t requiredSize = sourceOffset + size;
- bool createBuffer = !mNativeBuffer || mBufferSize < requiredSize;
-
- // (Re)initialize D3D buffer if needed
- if (createBuffer)
- {
- bool preserveData = (destOffset > 0);
- resize(source->getSize(), preserveData);
- }
-
- if (source->getUsage() == BUFFER_USAGE_PIXEL_PACK)
- {
- ASSERT(HAS_DYNAMIC_TYPE(PackStorage11*, source));
-
- void *sourcePointer = source->map(sourceOffset, size, GL_MAP_READ_BIT);
-
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- HRESULT hr = context->Map(mNativeBuffer, 0, D3D11_MAP_WRITE, 0, &mappedResource);
- UNUSED_ASSERTION_VARIABLE(hr);
- ASSERT(SUCCEEDED(hr));
-
- unsigned char *destPointer = static_cast<unsigned char *>(mappedResource.pData) + destOffset;
-
- // Offset bounds are validated at the API layer
- ASSERT(sourceOffset + size <= destOffset + mBufferSize);
- memcpy(destPointer, sourcePointer, size);
-
- context->Unmap(mNativeBuffer, 0);
- source->unmap();
- }
- else
- {
- ASSERT(HAS_DYNAMIC_TYPE(NativeBuffer11*, source));
-
- D3D11_BOX srcBox;
- srcBox.left = sourceOffset;
- srcBox.right = sourceOffset + size;
- srcBox.top = 0;
- srcBox.bottom = 1;
- srcBox.front = 0;
- srcBox.back = 1;
-
- ASSERT(HAS_DYNAMIC_TYPE(NativeBuffer11*, source));
- ID3D11Buffer *sourceBuffer = static_cast<NativeBuffer11*>(source)->getNativeBuffer();
-
- context->CopySubresourceRegion(mNativeBuffer, 0, destOffset, 0, 0, sourceBuffer, 0, &srcBox);
- }
-
- return createBuffer;
-}
-
-gl::Error Buffer11::NativeBuffer11::resize(size_t size, bool preserveData)
-{
- ID3D11Device *device = mRenderer->getDevice();
- ID3D11DeviceContext *context = mRenderer->getDeviceContext();
-
- D3D11_BUFFER_DESC bufferDesc;
- fillBufferDesc(&bufferDesc, mRenderer, mUsage, size);
-
- ID3D11Buffer *newBuffer;
- HRESULT result = device->CreateBuffer(&bufferDesc, NULL, &newBuffer);
-
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal buffer, result: 0x%X.", result);
- }
-
- if (mNativeBuffer && preserveData)
- {
- // We don't call resize if the buffer is big enough already.
- ASSERT(mBufferSize <= size);
-
- D3D11_BOX srcBox;
- srcBox.left = 0;
- srcBox.right = mBufferSize;
- srcBox.top = 0;
- srcBox.bottom = 1;
- srcBox.front = 0;
- srcBox.back = 1;
-
- context->CopySubresourceRegion(newBuffer, 0, 0, 0, 0, mNativeBuffer, 0, &srcBox);
- }
-
- // No longer need the old buffer
- SafeRelease(mNativeBuffer);
- mNativeBuffer = newBuffer;
-
- mBufferSize = bufferDesc.ByteWidth;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void Buffer11::NativeBuffer11::fillBufferDesc(D3D11_BUFFER_DESC* bufferDesc, Renderer11 *renderer,
- BufferUsage usage, unsigned int bufferSize)
-{
- bufferDesc->ByteWidth = bufferSize;
- bufferDesc->MiscFlags = 0;
- bufferDesc->StructureByteStride = 0;
-
- switch (usage)
- {
- case BUFFER_USAGE_STAGING:
- bufferDesc->Usage = D3D11_USAGE_STAGING;
- bufferDesc->BindFlags = 0;
- bufferDesc->CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
- break;
-
- case BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK:
- bufferDesc->Usage = D3D11_USAGE_DEFAULT;
- bufferDesc->BindFlags = D3D11_BIND_VERTEX_BUFFER;
- if (!renderer->isLevel9())
- bufferDesc->BindFlags |= D3D11_BIND_STREAM_OUTPUT;
- bufferDesc->CPUAccessFlags = 0;
- break;
-
- case BUFFER_USAGE_INDEX:
- bufferDesc->Usage = D3D11_USAGE_DEFAULT;
- bufferDesc->BindFlags = D3D11_BIND_INDEX_BUFFER;
- bufferDesc->CPUAccessFlags = 0;
- break;
-
- case BUFFER_USAGE_PIXEL_UNPACK:
- bufferDesc->Usage = D3D11_USAGE_DEFAULT;
- bufferDesc->BindFlags = D3D11_BIND_SHADER_RESOURCE;
- bufferDesc->CPUAccessFlags = 0;
- break;
-
- case BUFFER_USAGE_UNIFORM:
- bufferDesc->Usage = D3D11_USAGE_DYNAMIC;
- bufferDesc->BindFlags = D3D11_BIND_CONSTANT_BUFFER;
- bufferDesc->CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
-
- // Constant buffers must be of a limited size, and aligned to 16 byte boundaries
- // For our purposes we ignore any buffer data past the maximum constant buffer size
- bufferDesc->ByteWidth = roundUp(bufferDesc->ByteWidth, 16u);
- bufferDesc->ByteWidth = std::min<UINT>(bufferDesc->ByteWidth, renderer->getRendererCaps().maxUniformBlockSize);
- break;
-
- default:
- UNREACHABLE();
- }
-}
-
-void *Buffer11::NativeBuffer11::map(size_t offset, size_t length, GLbitfield access)
-{
- ASSERT(mUsage == BUFFER_USAGE_STAGING);
-
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- ID3D11DeviceContext *context = mRenderer->getDeviceContext();
- D3D11_MAP d3dMapType = gl_d3d11::GetD3DMapTypeFromBits(access);
- UINT d3dMapFlag = ((access & GL_MAP_UNSYNCHRONIZED_BIT) != 0 ? D3D11_MAP_FLAG_DO_NOT_WAIT : 0);
-
- HRESULT result = context->Map(mNativeBuffer, 0, d3dMapType, d3dMapFlag, &mappedResource);
- UNUSED_ASSERTION_VARIABLE(result);
- ASSERT(SUCCEEDED(result));
-
- return static_cast<GLubyte*>(mappedResource.pData) + offset;
-}
-
-gl::Error Buffer11::NativeBuffer11::setData(D3D11_MAP mapMode, const uint8_t *data, size_t size, size_t offset)
-{
- ID3D11DeviceContext *context = mRenderer->getDeviceContext();
-
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- HRESULT result = context->Map(mNativeBuffer, 0, mapMode, 0, &mappedResource);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal buffer, result: 0x%X.", result);
- }
-
- uint8_t *offsetBufferPointer = reinterpret_cast<uint8_t *>(mappedResource.pData) + offset;
- memcpy(offsetBufferPointer, data, size);
-
- context->Unmap(mNativeBuffer, 0);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void Buffer11::NativeBuffer11::unmap()
-{
- ASSERT(mUsage == BUFFER_USAGE_STAGING);
- ID3D11DeviceContext *context = mRenderer->getDeviceContext();
- context->Unmap(mNativeBuffer, 0);
-}
-
-Buffer11::PackStorage11::PackStorage11(Renderer11 *renderer)
- : BufferStorage11(renderer, BUFFER_USAGE_PIXEL_PACK),
- mStagingTexture(NULL),
- mTextureFormat(DXGI_FORMAT_UNKNOWN),
- mQueuedPackCommand(NULL),
- mDataModified(false)
-{
-}
-
-Buffer11::PackStorage11::~PackStorage11()
-{
- SafeRelease(mStagingTexture);
- SafeDelete(mQueuedPackCommand);
-}
-
-bool Buffer11::PackStorage11::copyFromStorage(BufferStorage11 *source, size_t sourceOffset,
- size_t size, size_t destOffset)
-{
- // We copy through a staging buffer when drawing with a pack buffer,
- // or for other cases where we access the pack buffer
- UNREACHABLE();
- return false;
-}
-
-gl::Error Buffer11::PackStorage11::resize(size_t size, bool preserveData)
-{
- if (size != mBufferSize)
- {
- if (!mMemoryBuffer.resize(size))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to resize internal buffer storage.");
- }
- mBufferSize = size;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void *Buffer11::PackStorage11::map(size_t offset, size_t length, GLbitfield access)
-{
- ASSERT(offset + length <= getSize());
- // TODO: fast path
- // We might be able to optimize out one or more memcpy calls by detecting when
- // and if D3D packs the staging texture memory identically to how we would fill
- // the pack buffer according to the current pack state.
-
- gl::Error error = flushQueuedPackCommand();
- if (error.isError())
- {
- return NULL;
- }
-
- mDataModified = (mDataModified || (access & GL_MAP_WRITE_BIT) != 0);
-
- return mMemoryBuffer.data() + offset;
-}
-
-void Buffer11::PackStorage11::unmap()
-{
- // No-op
-}
-
-gl::Error Buffer11::PackStorage11::packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams &params)
-{
- gl::Error error = flushQueuedPackCommand();
- if (error.isError())
- {
- return error;
- }
-
- mQueuedPackCommand = new PackPixelsParams(params);
-
- D3D11_TEXTURE2D_DESC textureDesc;
- srcTexure->GetDesc(&textureDesc);
-
- if (mStagingTexture != NULL &&
- (mTextureFormat != textureDesc.Format ||
- mTextureSize.width != params.area.width ||
- mTextureSize.height != params.area.height))
- {
- SafeRelease(mStagingTexture);
- mTextureSize.width = 0;
- mTextureSize.height = 0;
- mTextureFormat = DXGI_FORMAT_UNKNOWN;
- }
-
- if (mStagingTexture == NULL)
- {
- ID3D11Device *device = mRenderer->getDevice();
- HRESULT hr;
-
- mTextureSize.width = params.area.width;
- mTextureSize.height = params.area.height;
- mTextureFormat = textureDesc.Format;
-
- D3D11_TEXTURE2D_DESC stagingDesc;
- stagingDesc.Width = params.area.width;
- stagingDesc.Height = params.area.height;
- stagingDesc.MipLevels = 1;
- stagingDesc.ArraySize = 1;
- stagingDesc.Format = mTextureFormat;
- stagingDesc.SampleDesc.Count = 1;
- stagingDesc.SampleDesc.Quality = 0;
- stagingDesc.Usage = D3D11_USAGE_STAGING;
- stagingDesc.BindFlags = 0;
- stagingDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
- stagingDesc.MiscFlags = 0;
-
- hr = device->CreateTexture2D(&stagingDesc, NULL, &mStagingTexture);
- if (FAILED(hr))
- {
- ASSERT(hr == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate internal staging texture.");
- }
- }
-
- // ReadPixels from multisampled FBOs isn't supported in current GL
- ASSERT(textureDesc.SampleDesc.Count <= 1);
-
- ID3D11DeviceContext *immediateContext = mRenderer->getDeviceContext();
- D3D11_BOX srcBox;
- srcBox.left = params.area.x;
- srcBox.right = params.area.x + params.area.width;
- srcBox.top = params.area.y;
- srcBox.bottom = params.area.y + params.area.height;
- srcBox.front = 0;
- srcBox.back = 1;
-
- // Asynchronous copy
- immediateContext->CopySubresourceRegion(mStagingTexture, 0, 0, 0, 0, srcTexure, srcSubresource, &srcBox);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Buffer11::PackStorage11::flushQueuedPackCommand()
-{
- ASSERT(mMemoryBuffer.size() > 0);
-
- if (mQueuedPackCommand)
- {
- gl::Error error = mRenderer->packPixels(mStagingTexture, *mQueuedPackCommand, mMemoryBuffer.data());
- SafeDelete(mQueuedPackCommand);
- if (error.isError())
- {
- return error;
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.h
deleted file mode 100644
index 1c06bbf88a..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.h
+++ /dev/null
@@ -1,105 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// Buffer11.h: Defines the rx::Buffer11 class which implements rx::BufferImpl via rx::BufferD3D.
-
-#ifndef LIBGLESV2_RENDERER_BUFFER11_H_
-#define LIBGLESV2_RENDERER_BUFFER11_H_
-
-#include "libGLESv2/renderer/d3d/BufferD3D.h"
-#include "libGLESv2/renderer/d3d/MemoryBuffer.h"
-#include "libGLESv2/angletypes.h"
-
-namespace rx
-{
-class Renderer11;
-
-enum BufferUsage
-{
- BUFFER_USAGE_STAGING,
- BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK,
- BUFFER_USAGE_INDEX,
- BUFFER_USAGE_PIXEL_UNPACK,
- BUFFER_USAGE_PIXEL_PACK,
- BUFFER_USAGE_UNIFORM,
-};
-
-struct PackPixelsParams
-{
- PackPixelsParams();
- PackPixelsParams(const gl::Rectangle &area, GLenum format, GLenum type, GLuint outputPitch,
- const gl::PixelPackState &pack, ptrdiff_t offset);
-
- gl::Rectangle area;
- GLenum format;
- GLenum type;
- GLuint outputPitch;
- gl::Buffer *packBuffer;
- gl::PixelPackState pack;
- ptrdiff_t offset;
-};
-
-typedef size_t DataRevision;
-
-class Buffer11 : public BufferD3D
-{
- public:
- Buffer11(Renderer11 *renderer);
- virtual ~Buffer11();
-
- static Buffer11 *makeBuffer11(BufferImpl *buffer);
-
- ID3D11Buffer *getBuffer(BufferUsage usage);
- ID3D11ShaderResourceView *getSRV(DXGI_FORMAT srvFormat);
- bool isMapped() const { return mMappedStorage != NULL; }
- gl::Error packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams &params);
-
- // BufferD3D implementation
- virtual size_t getSize() const { return mSize; }
- virtual bool supportsDirectBinding() const;
- RendererD3D *getRenderer() override;
-
- // BufferImpl implementation
- virtual gl::Error setData(const void* data, size_t size, GLenum usage);
- gl::Error getData(const uint8_t **outData) override;
- virtual gl::Error setSubData(const void* data, size_t size, size_t offset);
- virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size);
- virtual gl::Error map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr);
- virtual gl::Error unmap();
- virtual void markTransformFeedbackUsage();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Buffer11);
-
- class BufferStorage11;
- class NativeBuffer11;
- class PackStorage11;
-
- Renderer11 *mRenderer;
- size_t mSize;
-
- BufferStorage11 *mMappedStorage;
-
- std::map<BufferUsage, BufferStorage11*> mBufferStorages;
-
- typedef std::pair<ID3D11Buffer *, ID3D11ShaderResourceView *> BufferSRVPair;
- std::map<DXGI_FORMAT, BufferSRVPair> mBufferResourceViews;
-
- MemoryBuffer mResolvedData;
- DataRevision mResolvedDataRevision;
- unsigned int mReadUsageCount;
-
- void markBufferUsage();
- NativeBuffer11 *getStagingBuffer();
- PackStorage11 *getPackStorage();
-
- BufferStorage11 *getBufferStorage(BufferUsage usage);
- BufferStorage11 *getLatestBufferStorage() const;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_BUFFER11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.cpp
deleted file mode 100644
index 7185a05506..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.cpp
+++ /dev/null
@@ -1,556 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// Clear11.cpp: Framebuffer clear utility class.
-
-#include "libGLESv2/renderer/d3d/d3d11/Clear11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/renderer11_utils.h"
-#include "libGLESv2/renderer/d3d/d3d11/RenderTarget11.h"
-#include "libGLESv2/formatutils.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/FramebufferAttachment.h"
-
-// Precompiled shaders
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearfloatvs.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearfloatps.h"
-
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearuintvs.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearuintps.h"
-
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearsintvs.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearsintps.h"
-
-namespace rx
-{
-
-template <typename T>
-static void ApplyVertices(const gl::Extents &framebufferSize, const gl::Rectangle *scissor, const gl::Color<T> &color, float depth, void *buffer)
-{
- d3d11::PositionDepthColorVertex<T> *vertices = reinterpret_cast<d3d11::PositionDepthColorVertex<T>*>(buffer);
-
- float depthClear = gl::clamp01(depth);
- float left = -1.0f;
- float right = 1.0f;
- float top = -1.0f;
- float bottom = 1.0f;
-
- // Clip the quad coordinates to the scissor if needed
- if (scissor != NULL)
- {
- left = std::max(left, (scissor->x / float(framebufferSize.width)) * 2.0f - 1.0f);
- right = std::min(right, ((scissor->x + scissor->width) / float(framebufferSize.width)) * 2.0f - 1.0f);
- top = std::max(top, ((framebufferSize.height - scissor->y - scissor->height) / float(framebufferSize.height)) * 2.0f - 1.0f);
- bottom = std::min(bottom, ((framebufferSize.height - scissor->y) / float(framebufferSize.height)) * 2.0f - 1.0f);
- }
-
- d3d11::SetPositionDepthColorVertex<T>(vertices + 0, left, bottom, depthClear, color);
- d3d11::SetPositionDepthColorVertex<T>(vertices + 1, left, top, depthClear, color);
- d3d11::SetPositionDepthColorVertex<T>(vertices + 2, right, bottom, depthClear, color);
- d3d11::SetPositionDepthColorVertex<T>(vertices + 3, right, top, depthClear, color);
-}
-
-template <unsigned int vsSize, unsigned int psSize>
-Clear11::ClearShader Clear11::CreateClearShader(ID3D11Device *device, DXGI_FORMAT colorType, const BYTE (&vsByteCode)[vsSize], const BYTE (&psByteCode)[psSize])
-{
- HRESULT result;
-
- ClearShader shader = { 0 };
-
- D3D11_INPUT_ELEMENT_DESC quadLayout[] =
- {
- { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
- { "COLOR", 0, colorType, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
- };
-
- result = device->CreateInputLayout(quadLayout, ArraySize(quadLayout), vsByteCode, vsSize, &shader.inputLayout);
- ASSERT(SUCCEEDED(result));
-
- result = device->CreateVertexShader(vsByteCode, vsSize, NULL, &shader.vertexShader);
- ASSERT(SUCCEEDED(result));
-
- result = device->CreatePixelShader(psByteCode, psSize, NULL, &shader.pixelShader);
- ASSERT(SUCCEEDED(result));
-
- return shader;
-}
-
-Clear11::Clear11(Renderer11 *renderer)
- : mRenderer(renderer), mClearBlendStates(StructLessThan<ClearBlendInfo>), mClearDepthStencilStates(StructLessThan<ClearDepthStencilInfo>),
- mVertexBuffer(NULL), mRasterizerState(NULL)
-{
- HRESULT result;
- ID3D11Device *device = renderer->getDevice();
-
- D3D11_BUFFER_DESC vbDesc;
- vbDesc.ByteWidth = sizeof(d3d11::PositionDepthColorVertex<float>) * 4;
- vbDesc.Usage = D3D11_USAGE_DYNAMIC;
- vbDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
- vbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
- vbDesc.MiscFlags = 0;
- vbDesc.StructureByteStride = 0;
-
- result = device->CreateBuffer(&vbDesc, NULL, &mVertexBuffer);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mVertexBuffer, "Clear11 masked clear vertex buffer");
-
- D3D11_RASTERIZER_DESC rsDesc;
- rsDesc.FillMode = D3D11_FILL_SOLID;
- rsDesc.CullMode = D3D11_CULL_NONE;
- rsDesc.FrontCounterClockwise = FALSE;
- rsDesc.DepthBias = 0;
- rsDesc.DepthBiasClamp = 0.0f;
- rsDesc.SlopeScaledDepthBias = 0.0f;
- rsDesc.DepthClipEnable = renderer->isLevel9();
- rsDesc.ScissorEnable = FALSE;
- rsDesc.MultisampleEnable = FALSE;
- rsDesc.AntialiasedLineEnable = FALSE;
-
- result = device->CreateRasterizerState(&rsDesc, &mRasterizerState);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mRasterizerState, "Clear11 masked clear rasterizer state");
-
- mFloatClearShader = CreateClearShader(device, DXGI_FORMAT_R32G32B32A32_FLOAT, g_VS_ClearFloat, g_PS_ClearFloat);
- if (mRenderer->isLevel9()) {
- memset(&mUintClearShader, 0, sizeof(ClearShader));
- memset(&mIntClearShader, 0, sizeof(ClearShader));
- return;
- }
- mUintClearShader = CreateClearShader(device, DXGI_FORMAT_R32G32B32A32_UINT, g_VS_ClearUint, g_PS_ClearUint );
- mIntClearShader = CreateClearShader(device, DXGI_FORMAT_R32G32B32A32_SINT, g_VS_ClearSint, g_PS_ClearSint );
-}
-
-Clear11::~Clear11()
-{
- for (ClearBlendStateMap::iterator i = mClearBlendStates.begin(); i != mClearBlendStates.end(); i++)
- {
- SafeRelease(i->second);
- }
- mClearBlendStates.clear();
-
- SafeRelease(mFloatClearShader.inputLayout);
- SafeRelease(mFloatClearShader.vertexShader);
- SafeRelease(mFloatClearShader.pixelShader);
-
- SafeRelease(mUintClearShader.inputLayout);
- SafeRelease(mUintClearShader.vertexShader);
- SafeRelease(mUintClearShader.pixelShader);
-
- SafeRelease(mIntClearShader.inputLayout);
- SafeRelease(mIntClearShader.vertexShader);
- SafeRelease(mIntClearShader.pixelShader);
-
- for (ClearDepthStencilStateMap::iterator i = mClearDepthStencilStates.begin(); i != mClearDepthStencilStates.end(); i++)
- {
- SafeRelease(i->second);
- }
- mClearDepthStencilStates.clear();
-
- SafeRelease(mVertexBuffer);
- SafeRelease(mRasterizerState);
-}
-
-gl::Error Clear11::clearFramebuffer(const gl::ClearParameters &clearParams, const gl::Framebuffer *frameBuffer)
-{
- // First determine if a scissored clear is needed, this will always require drawing a quad.
- //
- // Otherwise, iterate over the color buffers which require clearing and determine if they can be
- // cleared with ID3D11DeviceContext::ClearRenderTargetView... This requires:
- // 1) The render target is being cleared to a float value (will be cast to integer when clearing integer
- // render targets as expected but does not work the other way around)
- // 2) The format of the render target has no color channels that are currently masked out.
- // Clear the easy-to-clear buffers on the spot and accumulate the ones that require special work.
- //
- // Also determine if the depth stencil can be cleared with ID3D11DeviceContext::ClearDepthStencilView
- // by checking if the stencil write mask covers the entire stencil.
- //
- // To clear the remaining buffers, quads must be drawn containing an int, uint or float vertex color
- // attribute.
-
- gl::Extents framebufferSize;
- if (frameBuffer->getFirstColorbuffer() != NULL)
- {
- gl::FramebufferAttachment *attachment = frameBuffer->getFirstColorbuffer();
- framebufferSize.width = attachment->getWidth();
- framebufferSize.height = attachment->getHeight();
- framebufferSize.depth = 1;
- }
- else if (frameBuffer->getDepthOrStencilbuffer() != NULL)
- {
- gl::FramebufferAttachment *attachment = frameBuffer->getDepthOrStencilbuffer();
- framebufferSize.width = attachment->getWidth();
- framebufferSize.height = attachment->getHeight();
- framebufferSize.depth = 1;
- }
- else
- {
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
- }
-
- if (clearParams.scissorEnabled && (clearParams.scissor.x >= framebufferSize.width ||
- clearParams.scissor.y >= framebufferSize.height ||
- clearParams.scissor.x + clearParams.scissor.width <= 0 ||
- clearParams.scissor.y + clearParams.scissor.height <= 0))
- {
- // Scissor is enabled and the scissor rectangle is outside the renderbuffer
- return gl::Error(GL_NO_ERROR);
- }
-
- bool needScissoredClear = clearParams.scissorEnabled && (clearParams.scissor.x > 0 || clearParams.scissor.y > 0 ||
- clearParams.scissor.x + clearParams.scissor.width < framebufferSize.width ||
- clearParams.scissor.y + clearParams.scissor.height < framebufferSize.height);
-
- std::vector<MaskedRenderTarget> maskedClearRenderTargets;
- RenderTarget11* maskedClearDepthStencil = NULL;
-
- ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
-
- for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
- {
- if (clearParams.clearColor[colorAttachment] && frameBuffer->isEnabledColorAttachment(colorAttachment))
- {
- gl::FramebufferAttachment *attachment = frameBuffer->getColorbuffer(colorAttachment);
- if (attachment)
- {
- RenderTarget11 *renderTarget = NULL;
- gl::Error error = d3d11::GetAttachmentRenderTarget(attachment, &renderTarget);
- if (error.isError())
- {
- return error;
- }
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(attachment->getInternalFormat());
-
- if (clearParams.colorClearType == GL_FLOAT &&
- !(formatInfo.componentType == GL_FLOAT || formatInfo.componentType == GL_UNSIGNED_NORMALIZED || formatInfo.componentType == GL_SIGNED_NORMALIZED))
- {
- ERR("It is undefined behaviour to clear a render buffer which is not normalized fixed point or floating-"
- "point to floating point values (color attachment %u has internal format 0x%X).", colorAttachment,
- attachment->getInternalFormat());
- }
-
- if ((formatInfo.redBits == 0 || !clearParams.colorMaskRed) &&
- (formatInfo.greenBits == 0 || !clearParams.colorMaskGreen) &&
- (formatInfo.blueBits == 0 || !clearParams.colorMaskBlue) &&
- (formatInfo.alphaBits == 0 || !clearParams.colorMaskAlpha))
- {
- // Every channel either does not exist in the render target or is masked out
- continue;
- }
- else if (needScissoredClear || clearParams.colorClearType != GL_FLOAT ||
- (formatInfo.redBits > 0 && !clearParams.colorMaskRed) ||
- (formatInfo.greenBits > 0 && !clearParams.colorMaskGreen) ||
- (formatInfo.blueBits > 0 && !clearParams.colorMaskBlue) ||
- (formatInfo.alphaBits > 0 && !clearParams.colorMaskAlpha))
- {
- // A scissored or masked clear is required
- MaskedRenderTarget maskAndRt;
- bool clearColor = clearParams.clearColor[colorAttachment];
- maskAndRt.colorMask[0] = (clearColor && clearParams.colorMaskRed);
- maskAndRt.colorMask[1] = (clearColor && clearParams.colorMaskGreen);
- maskAndRt.colorMask[2] = (clearColor && clearParams.colorMaskBlue);
- maskAndRt.colorMask[3] = (clearColor && clearParams.colorMaskAlpha);
- maskAndRt.renderTarget = renderTarget;
- maskedClearRenderTargets.push_back(maskAndRt);
- }
- else
- {
- // ID3D11DeviceContext::ClearRenderTargetView is possible
-
- ID3D11RenderTargetView *framebufferRTV = renderTarget->getRenderTargetView();
- if (!framebufferRTV)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal render target view pointer unexpectedly null.");
- }
-
- const gl::InternalFormat &actualFormatInfo = gl::GetInternalFormatInfo(attachment->getActualFormat());
-
- // Check if the actual format has a channel that the internal format does not and set them to the
- // default values
- const float clearValues[4] =
- {
- ((formatInfo.redBits == 0 && actualFormatInfo.redBits > 0) ? 0.0f : clearParams.colorFClearValue.red),
- ((formatInfo.greenBits == 0 && actualFormatInfo.greenBits > 0) ? 0.0f : clearParams.colorFClearValue.green),
- ((formatInfo.blueBits == 0 && actualFormatInfo.blueBits > 0) ? 0.0f : clearParams.colorFClearValue.blue),
- ((formatInfo.alphaBits == 0 && actualFormatInfo.alphaBits > 0) ? 1.0f : clearParams.colorFClearValue.alpha),
- };
-
- deviceContext->ClearRenderTargetView(framebufferRTV, clearValues);
- }
- }
- }
- }
-
- if (clearParams.clearDepth || clearParams.clearStencil)
- {
- gl::FramebufferAttachment *attachment = frameBuffer->getDepthOrStencilbuffer();
- if (attachment)
- {
- RenderTarget11 *renderTarget = NULL;
- gl::Error error = d3d11::GetAttachmentRenderTarget(attachment, &renderTarget);
- if (error.isError())
- {
- return error;
- }
-
- const gl::InternalFormat &actualFormatInfo = gl::GetInternalFormatInfo(attachment->getActualFormat());
-
- unsigned int stencilUnmasked = frameBuffer->hasStencil() ? (1 << actualFormatInfo.stencilBits) - 1 : 0;
- bool needMaskedStencilClear = clearParams.clearStencil && (clearParams.stencilWriteMask & stencilUnmasked) != stencilUnmasked;
-
- if (needScissoredClear || needMaskedStencilClear)
- {
- maskedClearDepthStencil = renderTarget;
- }
- else
- {
- ID3D11DepthStencilView *framebufferDSV = renderTarget->getDepthStencilView();
- if (!framebufferDSV)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal depth stencil view pointer unexpectedly null.");
- }
-
- UINT clearFlags = (clearParams.clearDepth ? D3D11_CLEAR_DEPTH : 0) |
- (clearParams.clearStencil ? D3D11_CLEAR_STENCIL : 0);
- FLOAT depthClear = gl::clamp01(clearParams.depthClearValue);
- UINT8 stencilClear = clearParams.stencilClearValue & 0xFF;
-
- deviceContext->ClearDepthStencilView(framebufferDSV, clearFlags, depthClear, stencilClear);
- }
- }
- }
-
- if (maskedClearRenderTargets.size() > 0 || maskedClearDepthStencil)
- {
- // To clear the render targets and depth stencil in one pass:
- //
- // Render a quad clipped to the scissor rectangle which draws the clear color and a blend
- // state that will perform the required color masking.
- //
- // The quad's depth is equal to the depth clear value with a depth stencil state that
- // will enable or disable depth test/writes if the depth buffer should be cleared or not.
- //
- // The rasterizer state's stencil is set to always pass or fail based on if the stencil
- // should be cleared or not with a stencil write mask of the stencil clear value.
- //
- // ======================================================================================
- //
- // Luckily, the gl spec (ES 3.0.2 pg 183) states that the results of clearing a render-
- // buffer that is not normalized fixed point or floating point with floating point values
- // are undefined so we can just write floats to them and D3D11 will bit cast them to
- // integers.
- //
- // Also, we don't have to worry about attempting to clear a normalized fixed/floating point
- // buffer with integer values because there is no gl API call which would allow it,
- // glClearBuffer* calls only clear a single renderbuffer at a time which is verified to
- // be a compatible clear type.
-
- // Bind all the render targets which need clearing
- ASSERT(maskedClearRenderTargets.size() <= mRenderer->getRendererCaps().maxDrawBuffers);
- std::vector<ID3D11RenderTargetView*> rtvs(maskedClearRenderTargets.size());
- for (unsigned int i = 0; i < maskedClearRenderTargets.size(); i++)
- {
- RenderTarget11 *renderTarget = maskedClearRenderTargets[i].renderTarget;
- ID3D11RenderTargetView *rtv = renderTarget->getRenderTargetView();
- if (!rtv)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal render target view pointer unexpectedly null.");
- }
-
- rtvs[i] = rtv;
- }
- ID3D11DepthStencilView *dsv = maskedClearDepthStencil ? maskedClearDepthStencil->getDepthStencilView() : NULL;
-
- ID3D11BlendState *blendState = getBlendState(maskedClearRenderTargets);
- const FLOAT blendFactors[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
- const UINT sampleMask = 0xFFFFFFFF;
-
- ID3D11DepthStencilState *dsState = getDepthStencilState(clearParams);
- const UINT stencilClear = clearParams.stencilClearValue & 0xFF;
-
- // Set the vertices
- UINT vertexStride = 0;
- const UINT startIdx = 0;
- const ClearShader* shader = NULL;
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- HRESULT result = deviceContext->Map(mVertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal masked clear vertex buffer, HRESULT: 0x%X.", result);
- }
-
- const gl::Rectangle *scissorPtr = clearParams.scissorEnabled ? &clearParams.scissor : NULL;
- switch (clearParams.colorClearType)
- {
- case GL_FLOAT:
- ApplyVertices(framebufferSize, scissorPtr, clearParams.colorFClearValue, clearParams.depthClearValue, mappedResource.pData);
- vertexStride = sizeof(d3d11::PositionDepthColorVertex<float>);
- shader = &mFloatClearShader;
- break;
-
- case GL_UNSIGNED_INT:
- ApplyVertices(framebufferSize, scissorPtr, clearParams.colorUIClearValue, clearParams.depthClearValue, mappedResource.pData);
- vertexStride = sizeof(d3d11::PositionDepthColorVertex<unsigned int>);
- shader = &mUintClearShader;
- break;
-
- case GL_INT:
- ApplyVertices(framebufferSize, scissorPtr, clearParams.colorIClearValue, clearParams.depthClearValue, mappedResource.pData);
- vertexStride = sizeof(d3d11::PositionDepthColorVertex<int>);
- shader = &mIntClearShader;
- break;
-
- default:
- UNREACHABLE();
- break;
- }
-
- deviceContext->Unmap(mVertexBuffer, 0);
-
- // Set the viewport to be the same size as the framebuffer
- D3D11_VIEWPORT viewport;
- viewport.TopLeftX = 0;
- viewport.TopLeftY = 0;
- viewport.Width = framebufferSize.width;
- viewport.Height = framebufferSize.height;
- viewport.MinDepth = 0;
- viewport.MaxDepth = 1;
- deviceContext->RSSetViewports(1, &viewport);
-
- // Apply state
- deviceContext->OMSetBlendState(blendState, blendFactors, sampleMask);
- deviceContext->OMSetDepthStencilState(dsState, stencilClear);
- deviceContext->RSSetState(mRasterizerState);
-
- // Apply shaders
- deviceContext->IASetInputLayout(shader->inputLayout);
- deviceContext->VSSetShader(shader->vertexShader, NULL, 0);
- deviceContext->PSSetShader(shader->pixelShader, NULL, 0);
- deviceContext->GSSetShader(NULL, NULL, 0);
-
- // Apply vertex buffer
- deviceContext->IASetVertexBuffers(0, 1, &mVertexBuffer, &vertexStride, &startIdx);
- deviceContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
-
- // Apply render targets
- deviceContext->OMSetRenderTargets(rtvs.size(), (rtvs.empty() ? NULL : &rtvs[0]), dsv);
-
- // Draw the clear quad
- deviceContext->Draw(4, 0);
-
- // Clean up
- mRenderer->markAllStateDirty();
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-ID3D11BlendState *Clear11::getBlendState(const std::vector<MaskedRenderTarget>& rts)
-{
- ClearBlendInfo blendKey = { 0 };
- for (unsigned int i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
- {
- if (i < rts.size())
- {
- RenderTarget11 *rt = rts[i].renderTarget;
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(rt->getInternalFormat());
-
- blendKey.maskChannels[i][0] = (rts[i].colorMask[0] && formatInfo.redBits > 0);
- blendKey.maskChannels[i][1] = (rts[i].colorMask[1] && formatInfo.greenBits > 0);
- blendKey.maskChannels[i][2] = (rts[i].colorMask[2] && formatInfo.blueBits > 0);
- blendKey.maskChannels[i][3] = (rts[i].colorMask[3] && formatInfo.alphaBits > 0);
- }
- else
- {
- blendKey.maskChannels[i][0] = false;
- blendKey.maskChannels[i][1] = false;
- blendKey.maskChannels[i][2] = false;
- blendKey.maskChannels[i][3] = false;
- }
- }
-
- ClearBlendStateMap::const_iterator i = mClearBlendStates.find(blendKey);
- if (i != mClearBlendStates.end())
- {
- return i->second;
- }
- else
- {
- D3D11_BLEND_DESC blendDesc = { 0 };
- blendDesc.AlphaToCoverageEnable = FALSE;
- blendDesc.IndependentBlendEnable = (rts.size() > 1) ? TRUE : FALSE;
-
- for (unsigned int i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
- {
- blendDesc.RenderTarget[i].BlendEnable = FALSE;
- blendDesc.RenderTarget[i].RenderTargetWriteMask = gl_d3d11::ConvertColorMask(blendKey.maskChannels[i][0],
- blendKey.maskChannels[i][1],
- blendKey.maskChannels[i][2],
- blendKey.maskChannels[i][3]);
- }
-
- ID3D11Device *device = mRenderer->getDevice();
- ID3D11BlendState* blendState = NULL;
- HRESULT result = device->CreateBlendState(&blendDesc, &blendState);
- if (FAILED(result) || !blendState)
- {
- ERR("Unable to create a ID3D11BlendState, HRESULT: 0x%X.", result);
- return NULL;
- }
-
- mClearBlendStates[blendKey] = blendState;
-
- return blendState;
- }
-}
-
-ID3D11DepthStencilState *Clear11::getDepthStencilState(const gl::ClearParameters &clearParams)
-{
- ClearDepthStencilInfo dsKey = { 0 };
- dsKey.clearDepth = clearParams.clearDepth;
- dsKey.clearStencil = clearParams.clearStencil;
- dsKey.stencilWriteMask = clearParams.stencilWriteMask & 0xFF;
-
- ClearDepthStencilStateMap::const_iterator i = mClearDepthStencilStates.find(dsKey);
- if (i != mClearDepthStencilStates.end())
- {
- return i->second;
- }
- else
- {
- D3D11_DEPTH_STENCIL_DESC dsDesc = { 0 };
- dsDesc.DepthEnable = dsKey.clearDepth ? TRUE : FALSE;
- dsDesc.DepthWriteMask = dsKey.clearDepth ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
- dsDesc.DepthFunc = D3D11_COMPARISON_ALWAYS;
- dsDesc.StencilEnable = dsKey.clearStencil ? TRUE : FALSE;
- dsDesc.StencilReadMask = 0;
- dsDesc.StencilWriteMask = dsKey.stencilWriteMask;
- dsDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_REPLACE;
- dsDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_REPLACE;
- dsDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE;
- dsDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
- dsDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_REPLACE;
- dsDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_REPLACE;
- dsDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE;
- dsDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
-
- ID3D11Device *device = mRenderer->getDevice();
- ID3D11DepthStencilState* dsState = NULL;
- HRESULT result = device->CreateDepthStencilState(&dsDesc, &dsState);
- if (FAILED(result) || !dsState)
- {
- ERR("Unable to create a ID3D11DepthStencilState, HRESULT: 0x%X.", result);
- return NULL;
- }
-
- mClearDepthStencilStates[dsKey] = dsState;
-
- return dsState;
- }
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.h
deleted file mode 100644
index a7e8fea56a..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.h
+++ /dev/null
@@ -1,87 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// Clear11.h: Framebuffer clear utility class.
-
-#ifndef LIBGLESV2_RENDERER_CLEAR11_H_
-#define LIBGLESV2_RENDERER_CLEAR11_H_
-
-#include "libGLESv2/angletypes.h"
-#include "libGLESv2/Error.h"
-
-#include <map>
-#include <vector>
-
-namespace gl
-{
-class Framebuffer;
-}
-
-namespace rx
-{
-class Renderer11;
-class RenderTarget11;
-
-class Clear11
-{
- public:
- explicit Clear11(Renderer11 *renderer);
- ~Clear11();
-
- // Clears the framebuffer with the supplied clear parameters, assumes that the framebuffer is currently applied.
- gl::Error clearFramebuffer(const gl::ClearParameters &clearParams, const gl::Framebuffer *frameBuffer);
-
- private:
- Renderer11 *mRenderer;
-
- struct ClearBlendInfo
- {
- bool maskChannels[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT][4];
- };
- typedef bool (*ClearBlendInfoComparisonFunction)(const ClearBlendInfo&, const ClearBlendInfo &);
- typedef std::map<ClearBlendInfo, ID3D11BlendState*, ClearBlendInfoComparisonFunction> ClearBlendStateMap;
- ClearBlendStateMap mClearBlendStates;
-
- struct MaskedRenderTarget
- {
- bool colorMask[4];
- RenderTarget11 *renderTarget;
- };
-
- ID3D11BlendState *getBlendState(const std::vector<MaskedRenderTarget> &rts);
-
- struct ClearShader
- {
- ID3D11InputLayout *inputLayout;
- ID3D11VertexShader *vertexShader;
- ID3D11PixelShader *pixelShader;
- };
- ClearShader mFloatClearShader;
- ClearShader mUintClearShader;
- ClearShader mIntClearShader;
-
- template <unsigned int vsSize, unsigned int psSize>
- static ClearShader CreateClearShader(ID3D11Device *device, DXGI_FORMAT colorType, const BYTE (&vsByteCode)[vsSize], const BYTE (&psByteCode)[psSize]);
-
- struct ClearDepthStencilInfo
- {
- bool clearDepth;
- bool clearStencil;
- UINT8 stencilWriteMask;
- };
- typedef bool (*ClearDepthStencilInfoComparisonFunction)(const ClearDepthStencilInfo&, const ClearDepthStencilInfo &);
- typedef std::map<ClearDepthStencilInfo, ID3D11DepthStencilState*, ClearDepthStencilInfoComparisonFunction> ClearDepthStencilStateMap;
- ClearDepthStencilStateMap mClearDepthStencilStates;
-
- ID3D11DepthStencilState *getDepthStencilState(const gl::ClearParameters &clearParams);
-
- ID3D11Buffer *mVertexBuffer;
- ID3D11RasterizerState *mRasterizerState;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_CLEAR11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Fence11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Fence11.cpp
deleted file mode 100644
index f44d934056..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Fence11.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// Fence11.cpp: Defines the rx::FenceNV11 and rx::FenceSync11 classes which implement rx::FenceNVImpl and rx::FenceSyncImpl.
-
-#include "libGLESv2/renderer/d3d/d3d11/Fence11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-#include "libGLESv2/main.h"
-
-#include "common/utilities.h"
-
-namespace rx
-{
-
-//
-// Template helpers for set and test operations.
-//
-
-template<class FenceClass>
-gl::Error FenceSetHelper(FenceClass *fence)
-{
- if (!fence->mQuery)
- {
- D3D11_QUERY_DESC queryDesc;
- queryDesc.Query = D3D11_QUERY_EVENT;
- queryDesc.MiscFlags = 0;
-
- HRESULT result = fence->mRenderer->getDevice()->CreateQuery(&queryDesc, &fence->mQuery);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create event query, result: 0x%X.", result);
- }
- }
-
- fence->mRenderer->getDeviceContext()->End(fence->mQuery);
- return gl::Error(GL_NO_ERROR);
-}
-
-template <class FenceClass>
-gl::Error FenceTestHelper(FenceClass *fence, bool flushCommandBuffer, GLboolean *outFinished)
-{
- ASSERT(fence->mQuery);
-
- UINT getDataFlags = (flushCommandBuffer ? 0 : D3D11_ASYNC_GETDATA_DONOTFLUSH);
- HRESULT result = fence->mRenderer->getDeviceContext()->GetData(fence->mQuery, NULL, 0, getDataFlags);
-
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to get query data, result: 0x%X.", result);
- }
- else if (fence->mRenderer->isDeviceLost())
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Device was lost while querying result of an event query.");
- }
-
- ASSERT(result == S_OK || result == S_FALSE);
- *outFinished = ((result == S_OK) ? GL_TRUE : GL_FALSE);
- return gl::Error(GL_NO_ERROR);
-}
-
-//
-// FenceNV11
-//
-
-FenceNV11::FenceNV11(Renderer11 *renderer)
- : FenceNVImpl(),
- mRenderer(renderer),
- mQuery(NULL)
-{
-}
-
-FenceNV11::~FenceNV11()
-{
- SafeRelease(mQuery);
-}
-
-gl::Error FenceNV11::set()
-{
- return FenceSetHelper(this);
-}
-
-gl::Error FenceNV11::test(bool flushCommandBuffer, GLboolean *outFinished)
-{
- return FenceTestHelper(this, flushCommandBuffer, outFinished);
-}
-
-gl::Error FenceNV11::finishFence(GLboolean *outFinished)
-{
- ASSERT(outFinished);
-
- while (*outFinished != GL_TRUE)
- {
- gl::Error error = test(true, outFinished);
- if (error.isError())
- {
- return error;
- }
-
- Sleep(0);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-//
-// FenceSync11
-//
-
-// Important note on accurate timers in Windows:
-//
-// QueryPerformanceCounter has a few major issues, including being 10x as expensive to call
-// as timeGetTime on laptops and "jumping" during certain hardware events.
-//
-// See the comments at the top of the Chromium source file "chromium/src/base/time/time_win.cc"
-// https://code.google.com/p/chromium/codesearch#chromium/src/base/time/time_win.cc
-//
-// We still opt to use QPC. In the present and moving forward, most newer systems will not suffer
-// from buggy implementations.
-
-FenceSync11::FenceSync11(Renderer11 *renderer)
- : FenceSyncImpl(),
- mRenderer(renderer),
- mQuery(NULL)
-{
- LARGE_INTEGER counterFreqency = { 0 };
- BOOL success = QueryPerformanceFrequency(&counterFreqency);
- UNUSED_ASSERTION_VARIABLE(success);
- ASSERT(success);
-
- mCounterFrequency = counterFreqency.QuadPart;
-}
-
-FenceSync11::~FenceSync11()
-{
- SafeRelease(mQuery);
-}
-
-gl::Error FenceSync11::set()
-{
- return FenceSetHelper(this);
-}
-
-gl::Error FenceSync11::clientWait(GLbitfield flags, GLuint64 timeout, GLenum *outResult)
-{
- ASSERT(outResult);
-
- bool flushCommandBuffer = ((flags & GL_SYNC_FLUSH_COMMANDS_BIT) != 0);
-
- GLboolean result = GL_FALSE;
- gl::Error error = FenceTestHelper(this, flushCommandBuffer, &result);
- if (error.isError())
- {
- *outResult = GL_WAIT_FAILED;
- return error;
- }
-
- if (result == GL_TRUE)
- {
- *outResult = GL_ALREADY_SIGNALED;
- return gl::Error(GL_NO_ERROR);
- }
-
- if (timeout == 0)
- {
- *outResult = GL_TIMEOUT_EXPIRED;
- return gl::Error(GL_NO_ERROR);
- }
-
- LARGE_INTEGER currentCounter = { 0 };
- BOOL success = QueryPerformanceCounter(&currentCounter);
- UNUSED_ASSERTION_VARIABLE(success);
- ASSERT(success);
-
- LONGLONG timeoutInSeconds = static_cast<LONGLONG>(timeout) * static_cast<LONGLONG>(1000000ll);
- LONGLONG endCounter = currentCounter.QuadPart + mCounterFrequency * timeoutInSeconds;
-
- while (currentCounter.QuadPart < endCounter && !result)
- {
- Sleep(0);
- BOOL success = QueryPerformanceCounter(&currentCounter);
- UNUSED_ASSERTION_VARIABLE(success);
- ASSERT(success);
-
- error = FenceTestHelper(this, flushCommandBuffer, &result);
- if (error.isError())
- {
- *outResult = GL_WAIT_FAILED;
- return error;
- }
- }
-
- if (currentCounter.QuadPart >= endCounter)
- {
- *outResult = GL_TIMEOUT_EXPIRED;
- }
- else
- {
- *outResult = GL_CONDITION_SATISFIED;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error FenceSync11::serverWait(GLbitfield flags, GLuint64 timeout)
-{
- // Because our API is currently designed to be called from a single thread, we don't need to do
- // extra work for a server-side fence. GPU commands issued after the fence is created will always
- // be processed after the fence is signaled.
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error FenceSync11::getStatus(GLint *outResult)
-{
- GLboolean result = GL_FALSE;
- gl::Error error = FenceTestHelper(this, false, &result);
- if (error.isError())
- {
- // The spec does not specify any way to report errors during the status test (e.g. device lost)
- // so we report the fence is unblocked in case of error or signaled.
- *outResult = GL_SIGNALED;
-
- return error;
- }
-
- *outResult = (result ? GL_SIGNALED : GL_UNSIGNALED);
- return gl::Error(GL_NO_ERROR);
-}
-
-} // namespace rx
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Fence11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Fence11.h
deleted file mode 100644
index 1223a53b90..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Fence11.h
+++ /dev/null
@@ -1,62 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// Fence11.h: Defines the rx::FenceNV11 and rx::FenceSync11 classes which implement rx::FenceNVImpl and rx::FenceSyncImpl.
-
-#ifndef LIBGLESV2_RENDERER_FENCE11_H_
-#define LIBGLESV2_RENDERER_FENCE11_H_
-
-#include "libGLESv2/renderer/FenceImpl.h"
-
-namespace rx
-{
-class Renderer11;
-
-class FenceNV11 : public FenceNVImpl
-{
- public:
- explicit FenceNV11(Renderer11 *renderer);
- virtual ~FenceNV11();
-
- gl::Error set();
- gl::Error test(bool flushCommandBuffer, GLboolean *outFinished);
- gl::Error finishFence(GLboolean *outFinished);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FenceNV11);
-
- template<class T> friend gl::Error FenceSetHelper(T *fence);
- template<class T> friend gl::Error FenceTestHelper(T *fence, bool flushCommandBuffer, GLboolean *outFinished);
-
- Renderer11 *mRenderer;
- ID3D11Query *mQuery;
-};
-
-class FenceSync11 : public FenceSyncImpl
-{
- public:
- explicit FenceSync11(Renderer11 *renderer);
- virtual ~FenceSync11();
-
- gl::Error set();
- gl::Error clientWait(GLbitfield flags, GLuint64 timeout, GLenum *outResult);
- gl::Error serverWait(GLbitfield flags, GLuint64 timeout);
- gl::Error getStatus(GLint *outResult);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FenceSync11);
-
- template<class T> friend gl::Error FenceSetHelper(T *fence);
- template<class T> friend gl::Error FenceTestHelper(T *fence, bool flushCommandBuffer, GLboolean *outFinished);
-
- Renderer11 *mRenderer;
- ID3D11Query *mQuery;
- LONGLONG mCounterFrequency;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_FENCE11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Image11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Image11.cpp
deleted file mode 100644
index e6f3e90683..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Image11.cpp
+++ /dev/null
@@ -1,634 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// Image11.h: Implements the rx::Image11 class, which acts as the interface to
-// the actual underlying resources of a Texture
-
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Image11.h"
-#include "libGLESv2/renderer/d3d/d3d11/RenderTarget11.h"
-#include "libGLESv2/renderer/d3d/d3d11/TextureStorage11.h"
-#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h"
-#include "libGLESv2/renderer/d3d/d3d11/renderer11_utils.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/FramebufferAttachment.h"
-#include "libGLESv2/main.h"
-
-#include "common/utilities.h"
-
-namespace rx
-{
-
-Image11::Image11()
- : mRenderer(NULL),
- mDXGIFormat(DXGI_FORMAT_UNKNOWN),
- mStagingTexture(NULL),
- mStagingSubresource(0),
- mRecoverFromStorage(false),
- mAssociatedStorage(NULL),
- mAssociatedImageIndex(gl::ImageIndex::MakeInvalid()),
- mRecoveredFromStorageCount(0)
-
-{
-}
-
-Image11::~Image11()
-{
- disassociateStorage();
- releaseStagingTexture();
-}
-
-Image11 *Image11::makeImage11(Image *img)
-{
- ASSERT(HAS_DYNAMIC_TYPE(Image11*, img));
- return static_cast<Image11*>(img);
-}
-
-gl::Error Image11::generateMipmap(Image11 *dest, Image11 *src)
-{
- ASSERT(src->getDXGIFormat() == dest->getDXGIFormat());
- ASSERT(src->getWidth() == 1 || src->getWidth() / 2 == dest->getWidth());
- ASSERT(src->getHeight() == 1 || src->getHeight() / 2 == dest->getHeight());
-
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(src->getDXGIFormat());
- ASSERT(dxgiFormatInfo.mipGenerationFunction != NULL);
-
- D3D11_MAPPED_SUBRESOURCE destMapped;
- gl::Error error = dest->map(D3D11_MAP_WRITE, &destMapped);
- if (error.isError())
- {
- return error;
- }
-
- D3D11_MAPPED_SUBRESOURCE srcMapped;
- error = src->map(D3D11_MAP_READ, &srcMapped);
- if (error.isError())
- {
- dest->unmap();
- return error;
- }
-
- const uint8_t *sourceData = reinterpret_cast<const uint8_t*>(srcMapped.pData);
- uint8_t *destData = reinterpret_cast<uint8_t*>(destMapped.pData);
-
- dxgiFormatInfo.mipGenerationFunction(src->getWidth(), src->getHeight(), src->getDepth(),
- sourceData, srcMapped.RowPitch, srcMapped.DepthPitch,
- destData, destMapped.RowPitch, destMapped.DepthPitch);
-
- dest->unmap();
- src->unmap();
-
- dest->markDirty();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-bool Image11::isDirty() const
-{
- // If mDirty is true
- // AND mStagingTexture doesn't exist AND mStagingTexture doesn't need to be recovered from TextureStorage
- // AND the texture doesn't require init data (i.e. a blank new texture will suffice)
- // then isDirty should still return false.
- if (mDirty && !mStagingTexture && !mRecoverFromStorage && !(d3d11::GetTextureFormatInfo(mInternalFormat).dataInitializerFunction != NULL))
- {
- return false;
- }
-
- return mDirty;
-}
-
-gl::Error Image11::copyToStorage(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region)
-{
- TextureStorage11 *storage11 = TextureStorage11::makeTextureStorage11(storage);
-
- // If an app's behavior results in an Image11 copying its data to/from to a TextureStorage multiple times,
- // then we should just keep the staging texture around to prevent the copying from impacting perf.
- // We allow the Image11 to copy its data to/from TextureStorage once.
- // This accounts for an app making a late call to glGenerateMipmap.
- bool attemptToReleaseStagingTexture = (mRecoveredFromStorageCount < 2);
-
- if (attemptToReleaseStagingTexture)
- {
- // If another image is relying on this Storage for its data, then we must let it recover its data before we overwrite it.
- gl::Error error = storage11->releaseAssociatedImage(index, this);
- if (error.isError())
- {
- return error;
- }
- }
-
- ID3D11Resource *stagingTexture = NULL;
- unsigned int stagingSubresourceIndex = 0;
- gl::Error error = getStagingTexture(&stagingTexture, &stagingSubresourceIndex);
- if (error.isError())
- {
- return error;
- }
-
- error = storage11->updateSubresourceLevel(stagingTexture, stagingSubresourceIndex, index, region);
- if (error.isError())
- {
- return error;
- }
-
- // Once the image data has been copied into the Storage, we can release it locally.
- if (attemptToReleaseStagingTexture)
- {
- storage11->associateImage(this, index);
- releaseStagingTexture();
- mRecoverFromStorage = true;
- mAssociatedStorage = storage11;
- mAssociatedImageIndex = index;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-bool Image11::isAssociatedStorageValid(TextureStorage11* textureStorage) const
-{
- return (mAssociatedStorage == textureStorage);
-}
-
-gl::Error Image11::recoverFromAssociatedStorage()
-{
- if (mRecoverFromStorage)
- {
- gl::Error error = createStagingTexture();
- if (error.isError())
- {
- return error;
- }
-
- bool textureStorageCorrect = mAssociatedStorage->isAssociatedImageValid(mAssociatedImageIndex, this);
-
- // This means that the cached TextureStorage has been modified after this Image11 released its copy of its data.
- // This should not have happened. The TextureStorage should have told this Image11 to recover its data before it was overwritten.
- ASSERT(textureStorageCorrect);
-
- if (textureStorageCorrect)
- {
- // CopySubResource from the Storage to the Staging texture
- gl::Box region(0, 0, 0, mWidth, mHeight, mDepth);
- error = mAssociatedStorage->copySubresourceLevel(mStagingTexture, mStagingSubresource, mAssociatedImageIndex, region);
- if (error.isError())
- {
- return error;
- }
-
- mRecoveredFromStorageCount += 1;
- }
-
- // Reset all the recovery parameters, even if the texture storage association is broken.
- disassociateStorage();
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void Image11::disassociateStorage()
-{
- if (mRecoverFromStorage)
- {
- // Make the texturestorage release the Image11 too
- mAssociatedStorage->disassociateImage(mAssociatedImageIndex, this);
-
- mRecoverFromStorage = false;
- mAssociatedStorage = NULL;
- mAssociatedImageIndex = gl::ImageIndex::MakeInvalid();
- }
-}
-
-bool Image11::redefine(RendererD3D *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease)
-{
- if (mWidth != width ||
- mHeight != height ||
- mInternalFormat != internalformat ||
- forceRelease)
- {
- // End the association with the TextureStorage, since that data will be out of date.
- // Also reset mRecoveredFromStorageCount since this Image is getting completely redefined.
- disassociateStorage();
- mRecoveredFromStorageCount = 0;
-
- mRenderer = Renderer11::makeRenderer11(renderer);
-
- mWidth = width;
- mHeight = height;
- mDepth = depth;
- mInternalFormat = internalformat;
- mTarget = target;
-
- // compute the d3d format that will be used
- const d3d11::TextureFormat &formatInfo = d3d11::GetTextureFormatInfo(internalformat);
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(formatInfo.texFormat);
- mDXGIFormat = formatInfo.texFormat;
- mActualFormat = dxgiFormatInfo.internalFormat;
- mRenderable = (formatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN);
-
- releaseStagingTexture();
- mDirty = (formatInfo.dataInitializerFunction != NULL);
-
- return true;
- }
-
- return false;
-}
-
-DXGI_FORMAT Image11::getDXGIFormat() const
-{
- // this should only happen if the image hasn't been redefined first
- // which would be a bug by the caller
- ASSERT(mDXGIFormat != DXGI_FORMAT_UNKNOWN);
-
- return mDXGIFormat;
-}
-
-// Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input
-// into the target pixel rectangle.
-gl::Error Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
- GLint unpackAlignment, GLenum type, const void *input)
-{
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
- GLsizei inputRowPitch = formatInfo.computeRowPitch(type, width, unpackAlignment);
- GLsizei inputDepthPitch = formatInfo.computeDepthPitch(type, width, height, unpackAlignment);
-
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mDXGIFormat);
- GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
-
- const d3d11::TextureFormat &d3dFormatInfo = d3d11::GetTextureFormatInfo(mInternalFormat);
- LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions.at(type);
-
- D3D11_MAPPED_SUBRESOURCE mappedImage;
- gl::Error error = map(D3D11_MAP_WRITE, &mappedImage);
- if (error.isError())
- {
- return error;
- }
-
- uint8_t* offsetMappedData = (reinterpret_cast<uint8_t*>(mappedImage.pData) + (yoffset * mappedImage.RowPitch + xoffset * outputPixelSize + zoffset * mappedImage.DepthPitch));
- loadFunction(width, height, depth,
- reinterpret_cast<const uint8_t*>(input), inputRowPitch, inputDepthPitch,
- offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch);
-
- unmap();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
- const void *input)
-{
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
- GLsizei inputRowPitch = formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, width, 1);
- GLsizei inputDepthPitch = formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, width, height, 1);
-
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mDXGIFormat);
- GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
- GLuint outputBlockWidth = dxgiFormatInfo.blockWidth;
- GLuint outputBlockHeight = dxgiFormatInfo.blockHeight;
-
- ASSERT(xoffset % outputBlockWidth == 0);
- ASSERT(yoffset % outputBlockHeight == 0);
-
- const d3d11::TextureFormat &d3dFormatInfo = d3d11::GetTextureFormatInfo(mInternalFormat);
- LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions.at(GL_UNSIGNED_BYTE);
-
- D3D11_MAPPED_SUBRESOURCE mappedImage;
- gl::Error error = map(D3D11_MAP_WRITE, &mappedImage);
- if (error.isError())
- {
- return error;
- }
-
- uint8_t* offsetMappedData = reinterpret_cast<uint8_t*>(mappedImage.pData) + ((yoffset / outputBlockHeight) * mappedImage.RowPitch +
- (xoffset / outputBlockWidth) * outputPixelSize +
- zoffset * mappedImage.DepthPitch);
-
- loadFunction(width, height, depth,
- reinterpret_cast<const uint8_t*>(input), inputRowPitch, inputDepthPitch,
- offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch);
-
- unmap();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source)
-{
- RenderTarget11 *sourceRenderTarget = RenderTarget11::makeRenderTarget11(source);
- ASSERT(sourceRenderTarget->getTexture());
-
- UINT subresourceIndex = sourceRenderTarget->getSubresourceIndex();
- ID3D11Texture2D *sourceTexture2D = d3d11::DynamicCastComObject<ID3D11Texture2D>(sourceRenderTarget->getTexture());
-
- if (!sourceTexture2D)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to retrieve the ID3D11Texture2D from the source RenderTarget.");
- }
-
- gl::Error error = copy(xoffset, yoffset, zoffset, sourceArea, sourceTexture2D, subresourceIndex);
-
- SafeRelease(sourceTexture2D);
-
- return error;
-}
-
-gl::Error Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, const gl::ImageIndex &sourceIndex, TextureStorage *source)
-{
- TextureStorage11 *sourceStorage11 = TextureStorage11::makeTextureStorage11(source);
-
- UINT subresourceIndex = sourceStorage11->getSubresourceIndex(sourceIndex);
- ID3D11Resource *resource = NULL;
- gl::Error error = sourceStorage11->getResource(&resource);
- if (error.isError())
- {
- return error;
- }
-
- ID3D11Texture2D *sourceTexture2D = d3d11::DynamicCastComObject<ID3D11Texture2D>(resource);
-
- if (!sourceTexture2D)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to retrieve the ID3D11Texture2D from the source TextureStorage.");
- }
-
- error = copy(xoffset, yoffset, zoffset, sourceArea, sourceTexture2D, subresourceIndex);
-
- SafeRelease(sourceTexture2D);
-
- return error;
-}
-
-gl::Error Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, ID3D11Texture2D *source, UINT sourceSubResource)
-{
- D3D11_TEXTURE2D_DESC textureDesc;
- source->GetDesc(&textureDesc);
-
- if (textureDesc.Format == mDXGIFormat)
- {
- // No conversion needed-- use copyback fastpath
- ID3D11Resource *stagingTexture = NULL;
- unsigned int stagingSubresourceIndex = 0;
- gl::Error error = getStagingTexture(&stagingTexture, &stagingSubresourceIndex);
- if (error.isError())
- {
- return error;
- }
-
- ID3D11Device *device = mRenderer->getDevice();
- ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
-
- UINT subresourceAfterResolve = sourceSubResource;
-
- ID3D11Texture2D* srcTex = NULL;
- if (textureDesc.SampleDesc.Count > 1)
- {
- D3D11_TEXTURE2D_DESC resolveDesc;
- resolveDesc.Width = textureDesc.Width;
- resolveDesc.Height = textureDesc.Height;
- resolveDesc.MipLevels = 1;
- resolveDesc.ArraySize = 1;
- resolveDesc.Format = textureDesc.Format;
- resolveDesc.SampleDesc.Count = 1;
- resolveDesc.SampleDesc.Quality = 0;
- resolveDesc.Usage = D3D11_USAGE_DEFAULT;
- resolveDesc.BindFlags = 0;
- resolveDesc.CPUAccessFlags = 0;
- resolveDesc.MiscFlags = 0;
-
- HRESULT result = device->CreateTexture2D(&resolveDesc, NULL, &srcTex);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create resolve texture for Image11::copy, HRESULT: 0x%X.", result);
- }
-
- deviceContext->ResolveSubresource(srcTex, 0, source, sourceSubResource, textureDesc.Format);
- subresourceAfterResolve = 0;
- }
- else
- {
- srcTex = source;
- }
-
- D3D11_BOX srcBox;
- srcBox.left = sourceArea.x;
- srcBox.right = sourceArea.x + sourceArea.width;
- srcBox.top = sourceArea.y;
- srcBox.bottom = sourceArea.y + sourceArea.height;
- srcBox.front = 0;
- srcBox.back = 1;
-
- deviceContext->CopySubresourceRegion(stagingTexture, stagingSubresourceIndex, xoffset, yoffset, zoffset, srcTex, subresourceAfterResolve, &srcBox);
-
- if (textureDesc.SampleDesc.Count > 1)
- {
- SafeRelease(srcTex);
- }
- }
- else
- {
- // This format requires conversion, so we must copy the texture to staging and manually convert via readPixels
- D3D11_MAPPED_SUBRESOURCE mappedImage;
- gl::Error error = map(D3D11_MAP_WRITE, &mappedImage);
- if (error.isError())
- {
- return error;
- }
-
- // determine the offset coordinate into the destination buffer
- GLsizei rowOffset = gl::GetInternalFormatInfo(mActualFormat).pixelBytes * xoffset;
- uint8_t *dataOffset = static_cast<uint8_t*>(mappedImage.pData) + mappedImage.RowPitch * yoffset + rowOffset + zoffset * mappedImage.DepthPitch;
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
-
- error = mRenderer->readTextureData(source, sourceSubResource, sourceArea, formatInfo.format, formatInfo.type, mappedImage.RowPitch, gl::PixelPackState(), dataOffset);
-
- unmap();
-
- if (error.isError())
- {
- return error;
- }
- }
-
- mDirty = true;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Image11::getStagingTexture(ID3D11Resource **outStagingTexture, unsigned int *outSubresourceIndex)
-{
- gl::Error error = createStagingTexture();
- if (error.isError())
- {
- return error;
- }
-
- *outStagingTexture = mStagingTexture;
- *outSubresourceIndex = mStagingSubresource;
- return gl::Error(GL_NO_ERROR);
-}
-
-void Image11::releaseStagingTexture()
-{
- SafeRelease(mStagingTexture);
-}
-
-gl::Error Image11::createStagingTexture()
-{
- if (mStagingTexture)
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- ASSERT(mWidth > 0 && mHeight > 0 && mDepth > 0);
-
- const DXGI_FORMAT dxgiFormat = getDXGIFormat();
-
- ID3D11Device *device = mRenderer->getDevice();
- HRESULT result;
-
- int lodOffset = 1;
- GLsizei width = mWidth;
- GLsizei height = mHeight;
-
- // adjust size if needed for compressed textures
- d3d11::MakeValidSize(false, dxgiFormat, &width, &height, &lodOffset);
-
- if (mTarget == GL_TEXTURE_3D)
- {
- ID3D11Texture3D *newTexture = NULL;
-
- D3D11_TEXTURE3D_DESC desc;
- desc.Width = width;
- desc.Height = height;
- desc.Depth = mDepth;
- desc.MipLevels = lodOffset + 1;
- desc.Format = dxgiFormat;
- desc.Usage = D3D11_USAGE_STAGING;
- desc.BindFlags = 0;
- desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
- desc.MiscFlags = 0;
-
- if (d3d11::GetTextureFormatInfo(mInternalFormat).dataInitializerFunction != NULL)
- {
- std::vector<D3D11_SUBRESOURCE_DATA> initialData;
- std::vector< std::vector<BYTE> > textureData;
- d3d11::GenerateInitialTextureData(mInternalFormat, width, height, mDepth,
- lodOffset + 1, &initialData, &textureData);
-
- result = device->CreateTexture3D(&desc, initialData.data(), &newTexture);
- }
- else
- {
- result = device->CreateTexture3D(&desc, NULL, &newTexture);
- }
-
- if (FAILED(result))
- {
- ASSERT(result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create staging texture, result: 0x%X.", result);
- }
-
- mStagingTexture = newTexture;
- mStagingSubresource = D3D11CalcSubresource(lodOffset, 0, lodOffset + 1);
- }
- else if (mTarget == GL_TEXTURE_2D || mTarget == GL_TEXTURE_2D_ARRAY || mTarget == GL_TEXTURE_CUBE_MAP)
- {
- ID3D11Texture2D *newTexture = NULL;
-
- D3D11_TEXTURE2D_DESC desc;
- desc.Width = width;
- desc.Height = height;
- desc.MipLevels = lodOffset + 1;
- desc.ArraySize = 1;
- desc.Format = dxgiFormat;
- desc.SampleDesc.Count = 1;
- desc.SampleDesc.Quality = 0;
- desc.Usage = D3D11_USAGE_STAGING;
- desc.BindFlags = 0;
- desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
- desc.MiscFlags = 0;
-
- if (d3d11::GetTextureFormatInfo(mInternalFormat).dataInitializerFunction != NULL)
- {
- std::vector<D3D11_SUBRESOURCE_DATA> initialData;
- std::vector< std::vector<BYTE> > textureData;
- d3d11::GenerateInitialTextureData(mInternalFormat, width, height, 1,
- lodOffset + 1, &initialData, &textureData);
-
- result = device->CreateTexture2D(&desc, initialData.data(), &newTexture);
- }
- else
- {
- result = device->CreateTexture2D(&desc, NULL, &newTexture);
- }
-
- if (FAILED(result))
- {
- ASSERT(result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create staging texture, result: 0x%X.", result);
- }
-
- mStagingTexture = newTexture;
- mStagingSubresource = D3D11CalcSubresource(lodOffset, 0, lodOffset + 1);
- }
- else
- {
- UNREACHABLE();
- }
-
- mDirty = false;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Image11::map(D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map)
-{
- // We must recover from the TextureStorage if necessary, even for D3D11_MAP_WRITE.
- gl::Error error = recoverFromAssociatedStorage();
- if (error.isError())
- {
- return error;
- }
-
- ID3D11Resource *stagingTexture = NULL;
- unsigned int subresourceIndex = 0;
- error = getStagingTexture(&stagingTexture, &subresourceIndex);
- if (error.isError())
- {
- return error;
- }
-
- ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
-
- ASSERT(mStagingTexture);
- HRESULT result = deviceContext->Map(stagingTexture, subresourceIndex, mapType, 0, map);
-
- // this can fail if the device is removed (from TDR)
- if (d3d11::isDeviceLostError(result))
- {
- mRenderer->notifyDeviceLost();
- }
- else if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to map staging texture, result: 0x%X.", result);
- }
-
- mDirty = true;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void Image11::unmap()
-{
- if (mStagingTexture)
- {
- ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
- deviceContext->Unmap(mStagingTexture, mStagingSubresource);
- }
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Image11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Image11.h
deleted file mode 100644
index a936e6d7b2..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Image11.h
+++ /dev/null
@@ -1,87 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// Image11.h: Defines the rx::Image11 class, which acts as the interface to
-// the actual underlying resources of a Texture
-
-#ifndef LIBGLESV2_RENDERER_IMAGE11_H_
-#define LIBGLESV2_RENDERER_IMAGE11_H_
-
-#include "libGLESv2/renderer/d3d/ImageD3D.h"
-#include "libGLESv2/ImageIndex.h"
-
-#include "common/debug.h"
-
-namespace gl
-{
-class Framebuffer;
-}
-
-namespace rx
-{
-class Renderer11;
-class TextureStorage11;
-
-class Image11 : public ImageD3D
-{
- public:
- Image11();
- virtual ~Image11();
-
- static Image11 *makeImage11(Image *img);
-
- static gl::Error generateMipmap(Image11 *dest, Image11 *src);
-
- virtual bool isDirty() const;
-
- virtual gl::Error copyToStorage(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region);
-
- bool redefine(RendererD3D *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease) override;
-
- DXGI_FORMAT getDXGIFormat() const;
-
- virtual gl::Error loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
- GLint unpackAlignment, GLenum type, const void *input);
- virtual gl::Error loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
- const void *input);
-
- virtual gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source);
- virtual gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea,
- const gl::ImageIndex &sourceIndex, TextureStorage *source);
-
- gl::Error recoverFromAssociatedStorage();
- bool isAssociatedStorageValid(TextureStorage11* textureStorage) const;
- void disassociateStorage();
-
- protected:
- gl::Error map(D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map);
- void unmap();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Image11);
-
- gl::Error copyToStorageImpl(TextureStorage11 *storage11, const gl::ImageIndex &index, const gl::Box &region);
- gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, ID3D11Texture2D *source, UINT sourceSubResource);
-
- gl::Error getStagingTexture(ID3D11Resource **outStagingTexture, unsigned int *outSubresourceIndex);
- gl::Error createStagingTexture();
- void releaseStagingTexture();
-
- Renderer11 *mRenderer;
-
- DXGI_FORMAT mDXGIFormat;
- ID3D11Resource *mStagingTexture;
- unsigned int mStagingSubresource;
-
- bool mRecoverFromStorage;
- TextureStorage11 *mAssociatedStorage;
- gl::ImageIndex mAssociatedImageIndex;
- unsigned int mRecoveredFromStorageCount;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_IMAGE11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.cpp
deleted file mode 100644
index 9a61182ee9..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// IndexBuffer11.cpp: Defines the D3D11 IndexBuffer implementation.
-
-#include "libGLESv2/renderer/d3d/d3d11/IndexBuffer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-
-namespace rx
-{
-
-IndexBuffer11::IndexBuffer11(Renderer11 *const renderer) : mRenderer(renderer)
-{
- mBuffer = NULL;
- mBufferSize = 0;
- mDynamicUsage = false;
-}
-
-IndexBuffer11::~IndexBuffer11()
-{
- SafeRelease(mBuffer);
-}
-
-gl::Error IndexBuffer11::initialize(unsigned int bufferSize, GLenum indexType, bool dynamic)
-{
- SafeRelease(mBuffer);
-
- updateSerial();
-
- if (bufferSize > 0)
- {
- ID3D11Device* dxDevice = mRenderer->getDevice();
-
- D3D11_BUFFER_DESC bufferDesc;
- bufferDesc.ByteWidth = bufferSize;
- bufferDesc.Usage = D3D11_USAGE_DYNAMIC;
- bufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
- bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
- bufferDesc.MiscFlags = 0;
- bufferDesc.StructureByteStride = 0;
-
- HRESULT result = dxDevice->CreateBuffer(&bufferDesc, NULL, &mBuffer);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate internal index buffer of size, %lu.", bufferSize);
- }
- }
-
- mBufferSize = bufferSize;
- mIndexType = indexType;
- mDynamicUsage = dynamic;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-IndexBuffer11 *IndexBuffer11::makeIndexBuffer11(IndexBuffer *indexBuffer)
-{
- ASSERT(HAS_DYNAMIC_TYPE(IndexBuffer11*, indexBuffer));
- return static_cast<IndexBuffer11*>(indexBuffer);
-}
-
-gl::Error IndexBuffer11::mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory)
-{
- if (!mBuffer)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal index buffer is not initialized.");
- }
-
- // Check for integer overflows and out-out-bounds map requests
- if (offset + size < offset || offset + size > mBufferSize)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Index buffer map range is not inside the buffer.");
- }
-
- ID3D11DeviceContext *dxContext = mRenderer->getDeviceContext();
-
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- HRESULT result = dxContext->Map(mBuffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mappedResource);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal index buffer, HRESULT: 0x%08x.", result);
- }
-
- *outMappedMemory = reinterpret_cast<char*>(mappedResource.pData) + offset;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error IndexBuffer11::unmapBuffer()
-{
- if (!mBuffer)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal index buffer is not initialized.");
- }
-
- ID3D11DeviceContext *dxContext = mRenderer->getDeviceContext();
- dxContext->Unmap(mBuffer, 0);
- return gl::Error(GL_NO_ERROR);
-}
-
-GLenum IndexBuffer11::getIndexType() const
-{
- return mIndexType;
-}
-
-unsigned int IndexBuffer11::getBufferSize() const
-{
- return mBufferSize;
-}
-
-gl::Error IndexBuffer11::setSize(unsigned int bufferSize, GLenum indexType)
-{
- if (bufferSize > mBufferSize || indexType != mIndexType)
- {
- return initialize(bufferSize, indexType, mDynamicUsage);
- }
- else
- {
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-gl::Error IndexBuffer11::discard()
-{
- if (!mBuffer)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal index buffer is not initialized.");
- }
-
- ID3D11DeviceContext *dxContext = mRenderer->getDeviceContext();
-
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- HRESULT result = dxContext->Map(mBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal index buffer, HRESULT: 0x%08x.", result);
- }
-
- dxContext->Unmap(mBuffer, 0);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-DXGI_FORMAT IndexBuffer11::getIndexFormat() const
-{
- switch (mIndexType)
- {
- case GL_UNSIGNED_BYTE: return DXGI_FORMAT_R16_UINT;
- case GL_UNSIGNED_SHORT: return DXGI_FORMAT_R16_UINT;
- case GL_UNSIGNED_INT: return DXGI_FORMAT_R32_UINT;
- default: UNREACHABLE(); return DXGI_FORMAT_UNKNOWN;
- }
-}
-
-ID3D11Buffer *IndexBuffer11::getBuffer() const
-{
- return mBuffer;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.h
deleted file mode 100644
index 3351df5ec1..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.h
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// IndexBuffer11.h: Defines the D3D11 IndexBuffer implementation.
-
-#ifndef LIBGLESV2_RENDERER_INDEXBUFFER11_H_
-#define LIBGLESV2_RENDERER_INDEXBUFFER11_H_
-
-#include "libGLESv2/renderer/d3d/IndexBuffer.h"
-
-namespace rx
-{
-class Renderer11;
-
-class IndexBuffer11 : public IndexBuffer
-{
- public:
- explicit IndexBuffer11(Renderer11 *const renderer);
- virtual ~IndexBuffer11();
-
- virtual gl::Error initialize(unsigned int bufferSize, GLenum indexType, bool dynamic);
-
- static IndexBuffer11 *makeIndexBuffer11(IndexBuffer *indexBuffer);
-
- virtual gl::Error mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory);
- virtual gl::Error unmapBuffer();
-
- virtual GLenum getIndexType() const;
- virtual unsigned int getBufferSize() const;
- virtual gl::Error setSize(unsigned int bufferSize, GLenum indexType);
-
- virtual gl::Error discard();
-
- DXGI_FORMAT getIndexFormat() const;
- ID3D11Buffer *getBuffer() const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(IndexBuffer11);
-
- Renderer11 *const mRenderer;
-
- ID3D11Buffer *mBuffer;
- unsigned int mBufferSize;
- GLenum mIndexType;
- bool mDynamicUsage;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_INDEXBUFFER11_H_ \ No newline at end of file
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/InputLayoutCache.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/InputLayoutCache.cpp
deleted file mode 100644
index ff90a6a69a..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/InputLayoutCache.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// InputLayoutCache.cpp: Defines InputLayoutCache, a class that builds and caches
-// D3D11 input layouts.
-
-#include "libGLESv2/renderer/d3d/d3d11/InputLayoutCache.h"
-#include "libGLESv2/renderer/d3d/d3d11/VertexBuffer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Buffer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.h"
-#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h"
-#include "libGLESv2/renderer/d3d/ProgramD3D.h"
-#include "libGLESv2/renderer/d3d/VertexDataManager.h"
-#include "libGLESv2/ProgramBinary.h"
-#include "libGLESv2/VertexAttribute.h"
-
-#include "third_party/murmurhash/MurmurHash3.h"
-
-namespace rx
-{
-
-static void GetInputLayout(const TranslatedAttribute translatedAttributes[gl::MAX_VERTEX_ATTRIBS],
- gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS])
-{
- for (unsigned int attributeIndex = 0; attributeIndex < gl::MAX_VERTEX_ATTRIBS; attributeIndex++)
- {
- const TranslatedAttribute &translatedAttribute = translatedAttributes[attributeIndex];
-
- if (translatedAttributes[attributeIndex].active)
- {
- inputLayout[attributeIndex] = gl::VertexFormat(*translatedAttribute.attribute,
- translatedAttribute.currentValueType);
- }
- }
-}
-
-const unsigned int InputLayoutCache::kMaxInputLayouts = 1024;
-
-InputLayoutCache::InputLayoutCache() : mInputLayoutMap(kMaxInputLayouts, hashInputLayout, compareInputLayouts)
-{
- mCounter = 0;
- mDevice = NULL;
- mDeviceContext = NULL;
- mCurrentIL = NULL;
- for (unsigned int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- mCurrentBuffers[i] = NULL;
- mCurrentVertexStrides[i] = -1;
- mCurrentVertexOffsets[i] = -1;
- }
-}
-
-InputLayoutCache::~InputLayoutCache()
-{
- clear();
-}
-
-void InputLayoutCache::initialize(ID3D11Device *device, ID3D11DeviceContext *context)
-{
- clear();
- mDevice = device;
- mDeviceContext = context;
-}
-
-void InputLayoutCache::clear()
-{
- for (InputLayoutMap::iterator i = mInputLayoutMap.begin(); i != mInputLayoutMap.end(); i++)
- {
- SafeRelease(i->second.inputLayout);
- }
- mInputLayoutMap.clear();
- markDirty();
-}
-
-void InputLayoutCache::markDirty()
-{
- mCurrentIL = NULL;
- for (unsigned int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- mCurrentBuffers[i] = NULL;
- mCurrentVertexStrides[i] = -1;
- mCurrentVertexOffsets[i] = -1;
- }
-}
-
-gl::Error InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS],
- gl::ProgramBinary *programBinary)
-{
- int sortedSemanticIndices[gl::MAX_VERTEX_ATTRIBS];
- programBinary->sortAttributesByLayout(attributes, sortedSemanticIndices);
-
- if (!mDevice || !mDeviceContext)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal input layout cache is not initialized.");
- }
-
- InputLayoutKey ilKey = { 0 };
-
- static const char* semanticName = "TEXCOORD";
-
- for (unsigned int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- if (attributes[i].active)
- {
- D3D11_INPUT_CLASSIFICATION inputClass = attributes[i].divisor > 0 ? D3D11_INPUT_PER_INSTANCE_DATA : D3D11_INPUT_PER_VERTEX_DATA;
-
- gl::VertexFormat vertexFormat(*attributes[i].attribute, attributes[i].currentValueType);
- const d3d11::VertexFormat &vertexFormatInfo = d3d11::GetVertexFormatInfo(vertexFormat);
-
- // Record the type of the associated vertex shader vector in our key
- // This will prevent mismatched vertex shaders from using the same input layout
- GLint attributeSize;
- programBinary->getActiveAttribute(sortedSemanticIndices[i], 0, NULL, &attributeSize, &ilKey.elements[ilKey.elementCount].glslElementType, NULL);
-
- ilKey.elements[ilKey.elementCount].desc.SemanticName = semanticName;
- ilKey.elements[ilKey.elementCount].desc.SemanticIndex = i;
- ilKey.elements[ilKey.elementCount].desc.Format = vertexFormatInfo.nativeFormat;
- ilKey.elements[ilKey.elementCount].desc.InputSlot = i;
- ilKey.elements[ilKey.elementCount].desc.AlignedByteOffset = 0;
- ilKey.elements[ilKey.elementCount].desc.InputSlotClass = inputClass;
- ilKey.elements[ilKey.elementCount].desc.InstanceDataStepRate = attributes[i].divisor;
- ilKey.elementCount++;
- }
- }
-
- ID3D11InputLayout *inputLayout = NULL;
-
- InputLayoutMap::iterator keyIter = mInputLayoutMap.find(ilKey);
- if (keyIter != mInputLayoutMap.end())
- {
- inputLayout = keyIter->second.inputLayout;
- keyIter->second.lastUsedTime = mCounter++;
- }
- else
- {
- gl::VertexFormat shaderInputLayout[gl::MAX_VERTEX_ATTRIBS];
- GetInputLayout(attributes, shaderInputLayout);
- ProgramD3D *programD3D = ProgramD3D::makeProgramD3D(programBinary->getImplementation());
-
- ShaderExecutable *shader = NULL;
- gl::Error error = programD3D->getVertexExecutableForInputLayout(shaderInputLayout, &shader);
- if (error.isError())
- {
- return error;
- }
-
- ShaderExecutable *shader11 = ShaderExecutable11::makeShaderExecutable11(shader);
-
- D3D11_INPUT_ELEMENT_DESC descs[gl::MAX_VERTEX_ATTRIBS];
- for (unsigned int j = 0; j < ilKey.elementCount; ++j)
- {
- descs[j] = ilKey.elements[j].desc;
- }
-
- HRESULT result = mDevice->CreateInputLayout(descs, ilKey.elementCount, shader11->getFunction(), shader11->getLength(), &inputLayout);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal input layout, HRESULT: 0x%08x", result);
- }
-
- if (mInputLayoutMap.size() >= kMaxInputLayouts)
- {
- TRACE("Overflowed the limit of %u input layouts, removing the least recently used "
- "to make room.", kMaxInputLayouts);
-
- InputLayoutMap::iterator leastRecentlyUsed = mInputLayoutMap.begin();
- for (InputLayoutMap::iterator i = mInputLayoutMap.begin(); i != mInputLayoutMap.end(); i++)
- {
- if (i->second.lastUsedTime < leastRecentlyUsed->second.lastUsedTime)
- {
- leastRecentlyUsed = i;
- }
- }
- SafeRelease(leastRecentlyUsed->second.inputLayout);
- mInputLayoutMap.erase(leastRecentlyUsed);
- }
-
- InputLayoutCounterPair inputCounterPair;
- inputCounterPair.inputLayout = inputLayout;
- inputCounterPair.lastUsedTime = mCounter++;
-
- mInputLayoutMap.insert(std::make_pair(ilKey, inputCounterPair));
- }
-
- if (inputLayout != mCurrentIL)
- {
- mDeviceContext->IASetInputLayout(inputLayout);
- mCurrentIL = inputLayout;
- }
-
- bool dirtyBuffers = false;
- size_t minDiff = gl::MAX_VERTEX_ATTRIBS;
- size_t maxDiff = 0;
- for (unsigned int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- ID3D11Buffer *buffer = NULL;
-
- if (attributes[i].active)
- {
- VertexBuffer11 *vertexBuffer = VertexBuffer11::makeVertexBuffer11(attributes[i].vertexBuffer);
- Buffer11 *bufferStorage = attributes[i].storage ? Buffer11::makeBuffer11(attributes[i].storage) : NULL;
-
- buffer = bufferStorage ? bufferStorage->getBuffer(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK)
- : vertexBuffer->getBuffer();
- }
-
- UINT vertexStride = attributes[i].stride;
- UINT vertexOffset = attributes[i].offset;
-
- if (buffer != mCurrentBuffers[i] || vertexStride != mCurrentVertexStrides[i] ||
- vertexOffset != mCurrentVertexOffsets[i])
- {
- dirtyBuffers = true;
- minDiff = std::min(minDiff, static_cast<size_t>(i));
- maxDiff = std::max(maxDiff, static_cast<size_t>(i));
-
- mCurrentBuffers[i] = buffer;
- mCurrentVertexStrides[i] = vertexStride;
- mCurrentVertexOffsets[i] = vertexOffset;
- }
- }
-
- if (dirtyBuffers)
- {
- ASSERT(minDiff <= maxDiff && maxDiff < gl::MAX_VERTEX_ATTRIBS);
- mDeviceContext->IASetVertexBuffers(minDiff, maxDiff - minDiff + 1, mCurrentBuffers + minDiff,
- mCurrentVertexStrides + minDiff, mCurrentVertexOffsets + minDiff);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-std::size_t InputLayoutCache::hashInputLayout(const InputLayoutKey &inputLayout)
-{
- static const unsigned int seed = 0xDEADBEEF;
-
- std::size_t hash = 0;
- MurmurHash3_x86_32(inputLayout.begin(), inputLayout.end() - inputLayout.begin(), seed, &hash);
- return hash;
-}
-
-bool InputLayoutCache::compareInputLayouts(const InputLayoutKey &a, const InputLayoutKey &b)
-{
- if (a.elementCount != b.elementCount)
- {
- return false;
- }
-
- return std::equal(a.begin(), a.end(), b.begin());
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/InputLayoutCache.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/InputLayoutCache.h
deleted file mode 100644
index cc71ac3f6f..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/InputLayoutCache.h
+++ /dev/null
@@ -1,101 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// InputLayoutCache.h: Defines InputLayoutCache, a class that builds and caches
-// D3D11 input layouts.
-
-#ifndef LIBGLESV2_RENDERER_INPUTLAYOUTCACHE_H_
-#define LIBGLESV2_RENDERER_INPUTLAYOUTCACHE_H_
-
-#include "libGLESv2/Constants.h"
-#include "libGLESv2/Error.h"
-#include "common/angleutils.h"
-
-#include <GLES2/gl2.h>
-
-#include <cstddef>
-#include <unordered_map>
-
-namespace gl
-{
-class ProgramBinary;
-}
-
-namespace rx
-{
-struct TranslatedAttribute;
-
-class InputLayoutCache
-{
- public:
- InputLayoutCache();
- virtual ~InputLayoutCache();
-
- void initialize(ID3D11Device *device, ID3D11DeviceContext *context);
- void clear();
- void markDirty();
-
- gl::Error applyVertexBuffers(TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS],
- gl::ProgramBinary *programBinary);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(InputLayoutCache);
-
- struct InputLayoutElement
- {
- D3D11_INPUT_ELEMENT_DESC desc;
- GLenum glslElementType;
- };
-
- struct InputLayoutKey
- {
- unsigned int elementCount;
- InputLayoutElement elements[gl::MAX_VERTEX_ATTRIBS];
-
- const char *begin() const
- {
- return reinterpret_cast<const char*>(&elementCount);
- }
-
- const char *end() const
- {
- return reinterpret_cast<const char*>(&elements[elementCount]);
- }
- };
-
- struct InputLayoutCounterPair
- {
- ID3D11InputLayout *inputLayout;
- unsigned long long lastUsedTime;
- };
-
- ID3D11InputLayout *mCurrentIL;
- ID3D11Buffer *mCurrentBuffers[gl::MAX_VERTEX_ATTRIBS];
- UINT mCurrentVertexStrides[gl::MAX_VERTEX_ATTRIBS];
- UINT mCurrentVertexOffsets[gl::MAX_VERTEX_ATTRIBS];
-
- static std::size_t hashInputLayout(const InputLayoutKey &inputLayout);
- static bool compareInputLayouts(const InputLayoutKey &a, const InputLayoutKey &b);
-
- typedef std::size_t (*InputLayoutHashFunction)(const InputLayoutKey &);
- typedef bool (*InputLayoutEqualityFunction)(const InputLayoutKey &, const InputLayoutKey &);
- typedef std::unordered_map<InputLayoutKey,
- InputLayoutCounterPair,
- InputLayoutHashFunction,
- InputLayoutEqualityFunction> InputLayoutMap;
- InputLayoutMap mInputLayoutMap;
-
- static const unsigned int kMaxInputLayouts;
-
- unsigned long long mCounter;
-
- ID3D11Device *mDevice;
- ID3D11DeviceContext *mDeviceContext;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_INPUTLAYOUTCACHE_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.cpp
deleted file mode 100644
index 6a3d3475ee..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.cpp
+++ /dev/null
@@ -1,304 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// PixelTransfer11.cpp:
-// Implementation for buffer-to-texture and texture-to-buffer copies.
-// Used to implement pixel transfers from unpack and to pack buffers.
-//
-
-#include "libGLESv2/renderer/d3d/d3d11/PixelTransfer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/renderer11_utils.h"
-#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Buffer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/TextureStorage11.h"
-#include "libGLESv2/renderer/d3d/d3d11/RenderTarget11.h"
-#include "libGLESv2/formatutils.h"
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/Buffer.h"
-#include "libGLESv2/Context.h"
-
-// Precompiled shaders
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexturevs.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexturegs.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture_4fps.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture_4ips.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture_4uips.h"
-
-namespace rx
-{
-
-PixelTransfer11::PixelTransfer11(Renderer11 *renderer)
- : mRenderer(renderer),
- mResourcesLoaded(false),
- mBufferToTextureVS(NULL),
- mBufferToTextureGS(NULL),
- mParamsConstantBuffer(NULL),
- mCopyRasterizerState(NULL),
- mCopyDepthStencilState(NULL)
-{
-}
-
-PixelTransfer11::~PixelTransfer11()
-{
- for (auto shaderMapIt = mBufferToTexturePSMap.begin(); shaderMapIt != mBufferToTexturePSMap.end(); shaderMapIt++)
- {
- SafeRelease(shaderMapIt->second);
- }
-
- mBufferToTexturePSMap.clear();
-
- SafeRelease(mBufferToTextureVS);
- SafeRelease(mBufferToTextureGS);
- SafeRelease(mParamsConstantBuffer);
- SafeRelease(mCopyRasterizerState);
- SafeRelease(mCopyDepthStencilState);
-}
-
-gl::Error PixelTransfer11::loadResources()
-{
- if (mResourcesLoaded)
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- HRESULT result = S_OK;
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_RASTERIZER_DESC rasterDesc;
- rasterDesc.FillMode = D3D11_FILL_SOLID;
- rasterDesc.CullMode = D3D11_CULL_NONE;
- rasterDesc.FrontCounterClockwise = FALSE;
- rasterDesc.DepthBias = 0;
- rasterDesc.SlopeScaledDepthBias = 0.0f;
- rasterDesc.DepthBiasClamp = 0.0f;
- rasterDesc.DepthClipEnable = TRUE;
- rasterDesc.ScissorEnable = FALSE;
- rasterDesc.MultisampleEnable = FALSE;
- rasterDesc.AntialiasedLineEnable = FALSE;
-
- result = device->CreateRasterizerState(&rasterDesc, &mCopyRasterizerState);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal pixel transfer rasterizer state, result: 0x%X.", result);
- }
-
- D3D11_DEPTH_STENCIL_DESC depthStencilDesc;
- depthStencilDesc.DepthEnable = true;
- depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
- depthStencilDesc.DepthFunc = D3D11_COMPARISON_ALWAYS;
- depthStencilDesc.StencilEnable = FALSE;
- depthStencilDesc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK;
- depthStencilDesc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK;
- depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
- depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
- depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
- depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
- depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
- depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
- depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
- depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
-
- result = device->CreateDepthStencilState(&depthStencilDesc, &mCopyDepthStencilState);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal pixel transfer depth stencil state, result: 0x%X.", result);
- }
-
- D3D11_BUFFER_DESC constantBufferDesc = { 0 };
- constantBufferDesc.ByteWidth = roundUp<UINT>(sizeof(CopyShaderParams), 32u);
- constantBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
- constantBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
- constantBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
- constantBufferDesc.MiscFlags = 0;
- constantBufferDesc.StructureByteStride = 0;
-
- result = device->CreateBuffer(&constantBufferDesc, NULL, &mParamsConstantBuffer);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal pixel transfer constant buffer, result: 0x%X.", result);
- }
- d3d11::SetDebugName(mParamsConstantBuffer, "PixelTransfer11 constant buffer");
-
- // init shaders
- mBufferToTextureVS = d3d11::CompileVS(device, g_VS_BufferToTexture, "BufferToTexture VS");
- if (!mBufferToTextureVS)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal buffer to texture vertex shader.");
- }
-
- if (!mRenderer->isLevel9())
- {
- mBufferToTextureGS = d3d11::CompileGS(device, g_GS_BufferToTexture, "BufferToTexture GS");
- if (!mBufferToTextureGS)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal buffer to texture geometry shader.");
- }
- }
-
- gl::Error error = buildShaderMap();
- if (error.isError())
- {
- return error;
- }
-
- StructZero(&mParamsData);
-
- mResourcesLoaded = true;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void PixelTransfer11::setBufferToTextureCopyParams(const gl::Box &destArea, const gl::Extents &destSize, GLenum internalFormat,
- const gl::PixelUnpackState &unpack, unsigned int offset, CopyShaderParams *parametersOut)
-{
- StructZero(parametersOut);
-
- float texelCenterX = 0.5f / static_cast<float>(destSize.width - 1);
- float texelCenterY = 0.5f / static_cast<float>(destSize.height - 1);
-
- unsigned int bytesPerPixel = gl::GetInternalFormatInfo(internalFormat).pixelBytes;
- unsigned int alignmentBytes = static_cast<unsigned int>(unpack.alignment);
- unsigned int alignmentPixels = (alignmentBytes <= bytesPerPixel ? 1 : alignmentBytes / bytesPerPixel);
-
- parametersOut->FirstPixelOffset = offset;
- parametersOut->PixelsPerRow = static_cast<unsigned int>(destArea.width);
- parametersOut->RowStride = roundUp(parametersOut->PixelsPerRow, alignmentPixels);
- parametersOut->RowsPerSlice = static_cast<unsigned int>(destArea.height);
- parametersOut->PositionOffset[0] = texelCenterX + (destArea.x / float(destSize.width)) * 2.0f - 1.0f;
- parametersOut->PositionOffset[1] = texelCenterY + ((destSize.height - destArea.y - 1) / float(destSize.height)) * 2.0f - 1.0f;
- parametersOut->PositionScale[0] = 2.0f / static_cast<float>(destSize.width);
- parametersOut->PositionScale[1] = -2.0f / static_cast<float>(destSize.height);
-}
-
-gl::Error PixelTransfer11::copyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
- GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea)
-{
- gl::Error error = loadResources();
- if (error.isError())
- {
- return error;
- }
-
- gl::Extents destSize = destRenderTarget->getExtents();
-
- ASSERT(destArea.x >= 0 && destArea.x + destArea.width <= destSize.width &&
- destArea.y >= 0 && destArea.y + destArea.height <= destSize.height &&
- destArea.z >= 0 && destArea.z + destArea.depth <= destSize.depth );
-
- const gl::Buffer &sourceBuffer = *unpack.pixelBuffer.get();
-
- ASSERT(mRenderer->supportsFastCopyBufferToTexture(destinationFormat));
-
- ID3D11PixelShader *pixelShader = findBufferToTexturePS(destinationFormat);
- ASSERT(pixelShader);
-
- // The SRV must be in the proper read format, which may be different from the destination format
- // EG: for half float data, we can load full precision floats with implicit conversion
- GLenum unsizedFormat = gl::GetInternalFormatInfo(destinationFormat).format;
- GLenum sourceFormat = gl::GetFormatTypeInfo(unsizedFormat, sourcePixelsType).internalFormat;
-
- const d3d11::TextureFormat &sourceFormatInfo = d3d11::GetTextureFormatInfo(sourceFormat);
- DXGI_FORMAT srvFormat = sourceFormatInfo.srvFormat;
- ASSERT(srvFormat != DXGI_FORMAT_UNKNOWN);
- Buffer11 *bufferStorage11 = Buffer11::makeBuffer11(sourceBuffer.getImplementation());
- ID3D11ShaderResourceView *bufferSRV = bufferStorage11->getSRV(srvFormat);
- ASSERT(bufferSRV != NULL);
-
- ID3D11RenderTargetView *textureRTV = RenderTarget11::makeRenderTarget11(destRenderTarget)->getRenderTargetView();
- ASSERT(textureRTV != NULL);
-
- CopyShaderParams shaderParams;
- setBufferToTextureCopyParams(destArea, destSize, sourceFormat, unpack, offset, &shaderParams);
-
- ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
-
- ID3D11Buffer *nullBuffer = NULL;
- UINT zero = 0;
-
- // Are we doing a 2D or 3D copy?
- ID3D11GeometryShader *geometryShader = ((destSize.depth > 1) ? mBufferToTextureGS : NULL);
-
- deviceContext->VSSetShader(mBufferToTextureVS, NULL, 0);
- deviceContext->GSSetShader(geometryShader, NULL, 0);
- deviceContext->PSSetShader(pixelShader, NULL, 0);
- mRenderer->setShaderResource(gl::SAMPLER_PIXEL, 0, bufferSRV);
- deviceContext->IASetInputLayout(NULL);
- deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
-
- deviceContext->IASetVertexBuffers(0, 1, &nullBuffer, &zero, &zero);
- deviceContext->OMSetBlendState(NULL, NULL, 0xFFFFFFF);
- deviceContext->OMSetDepthStencilState(mCopyDepthStencilState, 0xFFFFFFFF);
- deviceContext->RSSetState(mCopyRasterizerState);
-
- mRenderer->setOneTimeRenderTarget(textureRTV);
-
- if (!StructEquals(mParamsData, shaderParams))
- {
- d3d11::SetBufferData(deviceContext, mParamsConstantBuffer, shaderParams);
- mParamsData = shaderParams;
- }
-
- deviceContext->VSSetConstantBuffers(0, 1, &mParamsConstantBuffer);
-
- // Set the viewport
- D3D11_VIEWPORT viewport;
- viewport.TopLeftX = 0;
- viewport.TopLeftY = 0;
- viewport.Width = destSize.width;
- viewport.Height = destSize.height;
- viewport.MinDepth = 0.0f;
- viewport.MaxDepth = 1.0f;
- deviceContext->RSSetViewports(1, &viewport);
-
- UINT numPixels = (destArea.width * destArea.height * destArea.depth);
- deviceContext->Draw(numPixels, 0);
-
- // Unbind textures and render targets and vertex buffer
- mRenderer->setShaderResource(gl::SAMPLER_PIXEL, 0, NULL);
- deviceContext->VSSetConstantBuffers(0, 1, &nullBuffer);
-
- mRenderer->markAllStateDirty();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error PixelTransfer11::buildShaderMap()
-{
- ID3D11Device *device = mRenderer->getDevice();
-
- mBufferToTexturePSMap[GL_FLOAT] = d3d11::CompilePS(device, g_PS_BufferToTexture_4F, "BufferToTexture RGBA ps");
- mBufferToTexturePSMap[GL_INT] = d3d11::CompilePS(device, g_PS_BufferToTexture_4I, "BufferToTexture RGBA-I ps");
- mBufferToTexturePSMap[GL_UNSIGNED_INT] = d3d11::CompilePS(device, g_PS_BufferToTexture_4UI, "BufferToTexture RGBA-UI ps");
-
- // Check that all the shaders were created successfully
- for (auto shaderMapIt = mBufferToTexturePSMap.begin(); shaderMapIt != mBufferToTexturePSMap.end(); shaderMapIt++)
- {
- if (shaderMapIt->second == NULL)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal buffer to texture pixel shader.");
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-ID3D11PixelShader *PixelTransfer11::findBufferToTexturePS(GLenum internalFormat) const
-{
- GLenum componentType = gl::GetInternalFormatInfo(internalFormat).componentType;
- if (componentType == GL_SIGNED_NORMALIZED || componentType == GL_UNSIGNED_NORMALIZED)
- {
- componentType = GL_FLOAT;
- }
-
- auto shaderMapIt = mBufferToTexturePSMap.find(componentType);
- return (shaderMapIt == mBufferToTexturePSMap.end() ? NULL : shaderMapIt->second);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.h
deleted file mode 100644
index 29552140bb..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.h
+++ /dev/null
@@ -1,88 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// PixelTransfer11.h:
-// Buffer-to-Texture and Texture-to-Buffer data transfers.
-// Used to implement pixel unpack and pixel pack buffers in ES3.
-
-#ifndef LIBGLESV2_PIXELTRANSFER11_H_
-#define LIBGLESV2_PIXELTRANSFER11_H_
-
-#include "libGLESv2/Error.h"
-
-#include "common/platform.h"
-
-#include <GLES2/gl2.h>
-
-#include <map>
-
-namespace gl
-{
-
-class Buffer;
-struct Box;
-struct Extents;
-struct PixelUnpackState;
-
-}
-
-namespace rx
-{
-class Renderer11;
-class RenderTarget;
-
-class PixelTransfer11
-{
- public:
- explicit PixelTransfer11(Renderer11 *renderer);
- ~PixelTransfer11();
-
- // unpack: the source buffer is stored in the unpack state, and buffer strides
- // offset: the start of the data within the unpack buffer
- // destRenderTarget: individual slice/layer of a target texture
- // destinationFormat/sourcePixelsType: determines shaders + shader parameters
- // destArea: the sub-section of destRenderTarget to copy to
- gl::Error copyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
- GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea);
-
- private:
-
- struct CopyShaderParams
- {
- unsigned int FirstPixelOffset;
- unsigned int PixelsPerRow;
- unsigned int RowStride;
- unsigned int RowsPerSlice;
- float PositionOffset[2];
- float PositionScale[2];
- int TexLocationOffset[2];
- int TexLocationScale[2];
- };
-
- static void setBufferToTextureCopyParams(const gl::Box &destArea, const gl::Extents &destSize, GLenum internalFormat,
- const gl::PixelUnpackState &unpack, unsigned int offset, CopyShaderParams *parametersOut);
-
- gl::Error loadResources();
- gl::Error buildShaderMap();
- ID3D11PixelShader *findBufferToTexturePS(GLenum internalFormat) const;
-
- Renderer11 *mRenderer;
-
- bool mResourcesLoaded;
- std::map<GLenum, ID3D11PixelShader *> mBufferToTexturePSMap;
- ID3D11VertexShader *mBufferToTextureVS;
- ID3D11GeometryShader *mBufferToTextureGS;
- ID3D11Buffer *mParamsConstantBuffer;
- CopyShaderParams mParamsData;
-
- ID3D11RasterizerState *mCopyRasterizerState;
- ID3D11DepthStencilState *mCopyDepthStencilState;
-
-};
-
-}
-
-#endif // LIBGLESV2_PIXELTRANSFER11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Query11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Query11.cpp
deleted file mode 100644
index 17ab1f8ab3..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Query11.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// Query11.cpp: Defines the rx::Query11 class which implements rx::QueryImpl.
-
-#include "libGLESv2/renderer/d3d/d3d11/Query11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/renderer11_utils.h"
-#include "libGLESv2/main.h"
-#include "common/utilities.h"
-
-#include <GLES2/gl2ext.h>
-
-namespace rx
-{
-
-Query11::Query11(Renderer11 *renderer, GLenum type)
- : QueryImpl(type),
- mResult(0),
- mQueryFinished(false),
- mRenderer(renderer),
- mQuery(NULL)
-{
-}
-
-Query11::~Query11()
-{
- SafeRelease(mQuery);
-}
-
-gl::Error Query11::begin()
-{
- if (mQuery == NULL)
- {
- D3D11_QUERY_DESC queryDesc;
- queryDesc.Query = gl_d3d11::ConvertQueryType(getType());
- queryDesc.MiscFlags = 0;
-
- HRESULT result = mRenderer->getDevice()->CreateQuery(&queryDesc, &mQuery);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal query creation failed, result: 0x%X.", result);
- }
- }
-
- mRenderer->getDeviceContext()->Begin(mQuery);
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Query11::end()
-{
- ASSERT(mQuery);
- mRenderer->getDeviceContext()->End(mQuery);
-
- mQueryFinished = false;
- mResult = GL_FALSE;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Query11::getResult(GLuint *params)
-{
- while (!mQueryFinished)
- {
- gl::Error error = testQuery();
- if (error.isError())
- {
- return error;
- }
-
- if (!mQueryFinished)
- {
- Sleep(0);
- }
- }
-
- ASSERT(mQueryFinished);
- *params = mResult;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Query11::isResultAvailable(GLuint *available)
-{
- gl::Error error = testQuery();
- if (error.isError())
- {
- return error;
- }
-
- *available = (mQueryFinished ? GL_TRUE : GL_FALSE);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Query11::testQuery()
-{
- if (!mQueryFinished)
- {
- ASSERT(mQuery);
-
- ID3D11DeviceContext *context = mRenderer->getDeviceContext();
- switch (getType())
- {
- case GL_ANY_SAMPLES_PASSED_EXT:
- case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
- {
- UINT64 numPixels = 0;
- HRESULT result = context->GetData(mQuery, &numPixels, sizeof(numPixels), 0);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to get the data of an internal query, result: 0x%X.", result);
- }
-
- if (result == S_OK)
- {
- mQueryFinished = true;
- mResult = (numPixels > 0) ? GL_TRUE : GL_FALSE;
- }
- }
- break;
-
- case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
- {
- D3D11_QUERY_DATA_SO_STATISTICS soStats = { 0 };
- HRESULT result = context->GetData(mQuery, &soStats, sizeof(soStats), 0);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to get the data of an internal query, result: 0x%X.", result);
- }
-
- if (result == S_OK)
- {
- mQueryFinished = true;
- mResult = static_cast<GLuint>(soStats.NumPrimitivesWritten);
- }
- }
- break;
-
- default:
- UNREACHABLE();
- break;
- }
-
- if (!mQueryFinished && mRenderer->testDeviceLost(true))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to test get query result, device is lost.");
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Query11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Query11.h
deleted file mode 100644
index f9ff467873..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Query11.h
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// Query11.h: Defines the rx::Query11 class which implements rx::QueryImpl.
-
-#ifndef LIBGLESV2_RENDERER_QUERY11_H_
-#define LIBGLESV2_RENDERER_QUERY11_H_
-
-#include "libGLESv2/renderer/QueryImpl.h"
-
-namespace rx
-{
-class Renderer11;
-
-class Query11 : public QueryImpl
-{
- public:
- Query11(Renderer11 *renderer, GLenum type);
- virtual ~Query11();
-
- virtual gl::Error begin();
- virtual gl::Error end();
- virtual gl::Error getResult(GLuint *params);
- virtual gl::Error isResultAvailable(GLuint *available);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Query11);
-
- gl::Error testQuery();
-
- GLuint mResult;
-
- bool mQueryFinished;
-
- Renderer11 *mRenderer;
- ID3D11Query *mQuery;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_QUERY11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/RenderStateCache.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/RenderStateCache.cpp
deleted file mode 100644
index ab4f60bd98..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/RenderStateCache.cpp
+++ /dev/null
@@ -1,439 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// RenderStateCache.cpp: Defines rx::RenderStateCache, a cache of Direct3D render
-// state objects.
-
-#include "libGLESv2/renderer/d3d/d3d11/RenderStateCache.h"
-#include "libGLESv2/renderer/d3d/d3d11/renderer11_utils.h"
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/FramebufferAttachment.h"
-
-#include "common/debug.h"
-
-#include "third_party/murmurhash/MurmurHash3.h"
-
-namespace rx
-{
-
-template <typename mapType>
-static void ClearStateMap(mapType &map)
-{
- for (typename mapType::iterator i = map.begin(); i != map.end(); i++)
- {
- SafeRelease(i->second.first);
- }
- map.clear();
-}
-
-// MSDN's documentation of ID3D11Device::CreateBlendState, ID3D11Device::CreateRasterizerState,
-// ID3D11Device::CreateDepthStencilState and ID3D11Device::CreateSamplerState claims the maximum
-// number of unique states of each type an application can create is 4096
-const unsigned int RenderStateCache::kMaxBlendStates = 4096;
-const unsigned int RenderStateCache::kMaxRasterizerStates = 4096;
-const unsigned int RenderStateCache::kMaxDepthStencilStates = 4096;
-const unsigned int RenderStateCache::kMaxSamplerStates = 4096;
-
-RenderStateCache::RenderStateCache(Renderer11 *renderer)
- : mRenderer(renderer),
- mDevice(NULL),
- mCounter(0),
- mBlendStateCache(kMaxBlendStates, hashBlendState, compareBlendStates),
- mRasterizerStateCache(kMaxRasterizerStates, hashRasterizerState, compareRasterizerStates),
- mDepthStencilStateCache(kMaxDepthStencilStates, hashDepthStencilState, compareDepthStencilStates),
- mSamplerStateCache(kMaxSamplerStates, hashSamplerState, compareSamplerStates)
-{
-}
-
-RenderStateCache::~RenderStateCache()
-{
- clear();
-}
-
-void RenderStateCache::initialize(ID3D11Device *device)
-{
- clear();
- mDevice = device;
-}
-
-void RenderStateCache::clear()
-{
- ClearStateMap(mBlendStateCache);
- ClearStateMap(mRasterizerStateCache);
- ClearStateMap(mDepthStencilStateCache);
- ClearStateMap(mSamplerStateCache);
-}
-
-std::size_t RenderStateCache::hashBlendState(const BlendStateKey &blendState)
-{
- static const unsigned int seed = 0xABCDEF98;
-
- std::size_t hash = 0;
- MurmurHash3_x86_32(&blendState, sizeof(gl::BlendState), seed, &hash);
- return hash;
-}
-
-bool RenderStateCache::compareBlendStates(const BlendStateKey &a, const BlendStateKey &b)
-{
- return memcmp(&a, &b, sizeof(BlendStateKey)) == 0;
-}
-
-gl::Error RenderStateCache::getBlendState(const gl::Framebuffer *framebuffer, const gl::BlendState &blendState,
- ID3D11BlendState **outBlendState)
-{
- if (!mDevice)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal error, RenderStateCache is not initialized.");
- }
-
- bool mrt = false;
-
- const gl::ColorbufferInfo &colorbuffers = framebuffer->getColorbuffersForRender(mRenderer->getWorkarounds());
-
- BlendStateKey key = { 0 };
- key.blendState = blendState;
- for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment)
- {
- const gl::FramebufferAttachment *attachment = colorbuffers[colorAttachment];
-
- auto rtChannels = key.rtChannels[colorAttachment];
-
- if (attachment)
- {
- if (colorAttachment > 0)
- {
- mrt = true;
- }
-
- rtChannels[0] = attachment->getRedSize() > 0;
- rtChannels[1] = attachment->getGreenSize() > 0;
- rtChannels[2] = attachment->getBlueSize() > 0;
- rtChannels[3] = attachment->getAlphaSize() > 0;
- }
- }
-
- BlendStateMap::iterator keyIter = mBlendStateCache.find(key);
- if (keyIter != mBlendStateCache.end())
- {
- BlendStateCounterPair &state = keyIter->second;
- state.second = mCounter++;
- *outBlendState = state.first;
- return gl::Error(GL_NO_ERROR);
- }
- else
- {
- if (mBlendStateCache.size() >= kMaxBlendStates)
- {
- TRACE("Overflowed the limit of %u blend states, removing the least recently used "
- "to make room.", kMaxBlendStates);
-
- BlendStateMap::iterator leastRecentlyUsed = mBlendStateCache.begin();
- for (BlendStateMap::iterator i = mBlendStateCache.begin(); i != mBlendStateCache.end(); i++)
- {
- if (i->second.second < leastRecentlyUsed->second.second)
- {
- leastRecentlyUsed = i;
- }
- }
- SafeRelease(leastRecentlyUsed->second.first);
- mBlendStateCache.erase(leastRecentlyUsed);
- }
-
- // Create a new blend state and insert it into the cache
- D3D11_BLEND_DESC blendDesc = { 0 };
- blendDesc.AlphaToCoverageEnable = blendState.sampleAlphaToCoverage;
- blendDesc.IndependentBlendEnable = mrt ? TRUE : FALSE;
-
- for (unsigned int i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
- {
- D3D11_RENDER_TARGET_BLEND_DESC &rtBlend = blendDesc.RenderTarget[i];
-
- rtBlend.BlendEnable = blendState.blend;
- if (blendState.blend)
- {
- rtBlend.SrcBlend = gl_d3d11::ConvertBlendFunc(blendState.sourceBlendRGB, false);
- rtBlend.DestBlend = gl_d3d11::ConvertBlendFunc(blendState.destBlendRGB, false);
- rtBlend.BlendOp = gl_d3d11::ConvertBlendOp(blendState.blendEquationRGB);
-
- rtBlend.SrcBlendAlpha = gl_d3d11::ConvertBlendFunc(blendState.sourceBlendAlpha, true);
- rtBlend.DestBlendAlpha = gl_d3d11::ConvertBlendFunc(blendState.destBlendAlpha, true);
- rtBlend.BlendOpAlpha = gl_d3d11::ConvertBlendOp(blendState.blendEquationAlpha);
- }
-
- rtBlend.RenderTargetWriteMask = gl_d3d11::ConvertColorMask(key.rtChannels[i][0] && blendState.colorMaskRed,
- key.rtChannels[i][1] && blendState.colorMaskGreen,
- key.rtChannels[i][2] && blendState.colorMaskBlue,
- key.rtChannels[i][3] && blendState.colorMaskAlpha);
- }
-
- ID3D11BlendState *dx11BlendState = NULL;
- HRESULT result = mDevice->CreateBlendState(&blendDesc, &dx11BlendState);
- if (FAILED(result) || !dx11BlendState)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Unable to create a ID3D11BlendState, HRESULT: 0x%X.", result);
- }
-
- mBlendStateCache.insert(std::make_pair(key, std::make_pair(dx11BlendState, mCounter++)));
-
- *outBlendState = dx11BlendState;
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-std::size_t RenderStateCache::hashRasterizerState(const RasterizerStateKey &rasterState)
-{
- static const unsigned int seed = 0xABCDEF98;
-
- std::size_t hash = 0;
- MurmurHash3_x86_32(&rasterState, sizeof(RasterizerStateKey), seed, &hash);
- return hash;
-}
-
-bool RenderStateCache::compareRasterizerStates(const RasterizerStateKey &a, const RasterizerStateKey &b)
-{
- return memcmp(&a, &b, sizeof(RasterizerStateKey)) == 0;
-}
-
-gl::Error RenderStateCache::getRasterizerState(const gl::RasterizerState &rasterState, bool scissorEnabled,
- ID3D11RasterizerState **outRasterizerState)
-{
- if (!mDevice)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal error, RenderStateCache is not initialized.");
- }
-
- RasterizerStateKey key = { 0 };
- key.rasterizerState = rasterState;
- key.scissorEnabled = scissorEnabled;
-
- RasterizerStateMap::iterator keyIter = mRasterizerStateCache.find(key);
- if (keyIter != mRasterizerStateCache.end())
- {
- RasterizerStateCounterPair &state = keyIter->second;
- state.second = mCounter++;
- *outRasterizerState = state.first;
- return gl::Error(GL_NO_ERROR);
- }
- else
- {
- if (mRasterizerStateCache.size() >= kMaxRasterizerStates)
- {
- TRACE("Overflowed the limit of %u rasterizer states, removing the least recently used "
- "to make room.", kMaxRasterizerStates);
-
- RasterizerStateMap::iterator leastRecentlyUsed = mRasterizerStateCache.begin();
- for (RasterizerStateMap::iterator i = mRasterizerStateCache.begin(); i != mRasterizerStateCache.end(); i++)
- {
- if (i->second.second < leastRecentlyUsed->second.second)
- {
- leastRecentlyUsed = i;
- }
- }
- SafeRelease(leastRecentlyUsed->second.first);
- mRasterizerStateCache.erase(leastRecentlyUsed);
- }
-
- D3D11_CULL_MODE cullMode = gl_d3d11::ConvertCullMode(rasterState.cullFace, rasterState.cullMode);
-
- // Disable culling if drawing points
- if (rasterState.pointDrawMode)
- {
- cullMode = D3D11_CULL_NONE;
- }
-
- D3D11_RASTERIZER_DESC rasterDesc;
- rasterDesc.FillMode = D3D11_FILL_SOLID;
- rasterDesc.CullMode = cullMode;
- rasterDesc.FrontCounterClockwise = (rasterState.frontFace == GL_CCW) ? FALSE: TRUE;
- rasterDesc.DepthBiasClamp = 0.0f; // MSDN documentation of DepthBiasClamp implies a value of zero will preform no clamping, must be tested though.
- rasterDesc.DepthClipEnable = TRUE;
- rasterDesc.ScissorEnable = scissorEnabled ? TRUE : FALSE;
- rasterDesc.MultisampleEnable = rasterState.multiSample;
- rasterDesc.AntialiasedLineEnable = FALSE;
-
- if (rasterState.polygonOffsetFill)
- {
- rasterDesc.SlopeScaledDepthBias = rasterState.polygonOffsetFactor;
- rasterDesc.DepthBias = (INT)rasterState.polygonOffsetUnits;
- }
- else
- {
- rasterDesc.SlopeScaledDepthBias = 0.0f;
- rasterDesc.DepthBias = 0;
- }
-
- ID3D11RasterizerState *dx11RasterizerState = NULL;
- HRESULT result = mDevice->CreateRasterizerState(&rasterDesc, &dx11RasterizerState);
- if (FAILED(result) || !dx11RasterizerState)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Unable to create a ID3D11RasterizerState, HRESULT: 0x%X.", result);
- }
-
- mRasterizerStateCache.insert(std::make_pair(key, std::make_pair(dx11RasterizerState, mCounter++)));
-
- *outRasterizerState = dx11RasterizerState;
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-std::size_t RenderStateCache::hashDepthStencilState(const gl::DepthStencilState &dsState)
-{
- static const unsigned int seed = 0xABCDEF98;
-
- std::size_t hash = 0;
- MurmurHash3_x86_32(&dsState, sizeof(gl::DepthStencilState), seed, &hash);
- return hash;
-}
-
-bool RenderStateCache::compareDepthStencilStates(const gl::DepthStencilState &a, const gl::DepthStencilState &b)
-{
- return memcmp(&a, &b, sizeof(gl::DepthStencilState)) == 0;
-}
-
-gl::Error RenderStateCache::getDepthStencilState(const gl::DepthStencilState &dsState, ID3D11DepthStencilState **outDSState)
-{
- if (!mDevice)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal error, RenderStateCache is not initialized.");
- }
-
- DepthStencilStateMap::iterator keyIter = mDepthStencilStateCache.find(dsState);
- if (keyIter != mDepthStencilStateCache.end())
- {
- DepthStencilStateCounterPair &state = keyIter->second;
- state.second = mCounter++;
- *outDSState = state.first;
- return gl::Error(GL_NO_ERROR);
- }
- else
- {
- if (mDepthStencilStateCache.size() >= kMaxDepthStencilStates)
- {
- TRACE("Overflowed the limit of %u depth stencil states, removing the least recently used "
- "to make room.", kMaxDepthStencilStates);
-
- DepthStencilStateMap::iterator leastRecentlyUsed = mDepthStencilStateCache.begin();
- for (DepthStencilStateMap::iterator i = mDepthStencilStateCache.begin(); i != mDepthStencilStateCache.end(); i++)
- {
- if (i->second.second < leastRecentlyUsed->second.second)
- {
- leastRecentlyUsed = i;
- }
- }
- SafeRelease(leastRecentlyUsed->second.first);
- mDepthStencilStateCache.erase(leastRecentlyUsed);
- }
-
- D3D11_DEPTH_STENCIL_DESC dsDesc = { 0 };
- dsDesc.DepthEnable = dsState.depthTest ? TRUE : FALSE;
- dsDesc.DepthWriteMask = gl_d3d11::ConvertDepthMask(dsState.depthMask);
- dsDesc.DepthFunc = gl_d3d11::ConvertComparison(dsState.depthFunc);
- dsDesc.StencilEnable = dsState.stencilTest ? TRUE : FALSE;
- dsDesc.StencilReadMask = gl_d3d11::ConvertStencilMask(dsState.stencilMask);
- dsDesc.StencilWriteMask = gl_d3d11::ConvertStencilMask(dsState.stencilWritemask);
- dsDesc.FrontFace.StencilFailOp = gl_d3d11::ConvertStencilOp(dsState.stencilFail);
- dsDesc.FrontFace.StencilDepthFailOp = gl_d3d11::ConvertStencilOp(dsState.stencilPassDepthFail);
- dsDesc.FrontFace.StencilPassOp = gl_d3d11::ConvertStencilOp(dsState.stencilPassDepthPass);
- dsDesc.FrontFace.StencilFunc = gl_d3d11::ConvertComparison(dsState.stencilFunc);
- dsDesc.BackFace.StencilFailOp = gl_d3d11::ConvertStencilOp(dsState.stencilBackFail);
- dsDesc.BackFace.StencilDepthFailOp = gl_d3d11::ConvertStencilOp(dsState.stencilBackPassDepthFail);
- dsDesc.BackFace.StencilPassOp = gl_d3d11::ConvertStencilOp(dsState.stencilBackPassDepthPass);
- dsDesc.BackFace.StencilFunc = gl_d3d11::ConvertComparison(dsState.stencilBackFunc);
-
- ID3D11DepthStencilState *dx11DepthStencilState = NULL;
- HRESULT result = mDevice->CreateDepthStencilState(&dsDesc, &dx11DepthStencilState);
- if (FAILED(result) || !dx11DepthStencilState)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Unable to create a ID3D11DepthStencilState, HRESULT: 0x%X.", result);
- }
-
- mDepthStencilStateCache.insert(std::make_pair(dsState, std::make_pair(dx11DepthStencilState, mCounter++)));
-
- *outDSState = dx11DepthStencilState;
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-std::size_t RenderStateCache::hashSamplerState(const gl::SamplerState &samplerState)
-{
- static const unsigned int seed = 0xABCDEF98;
-
- std::size_t hash = 0;
- MurmurHash3_x86_32(&samplerState, sizeof(gl::SamplerState), seed, &hash);
- return hash;
-}
-
-bool RenderStateCache::compareSamplerStates(const gl::SamplerState &a, const gl::SamplerState &b)
-{
- return memcmp(&a, &b, sizeof(gl::SamplerState)) == 0;
-}
-
-gl::Error RenderStateCache::getSamplerState(const gl::SamplerState &samplerState, ID3D11SamplerState **outSamplerState)
-{
- if (!mDevice)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal error, RenderStateCache is not initialized.");
- }
-
- SamplerStateMap::iterator keyIter = mSamplerStateCache.find(samplerState);
- if (keyIter != mSamplerStateCache.end())
- {
- SamplerStateCounterPair &state = keyIter->second;
- state.second = mCounter++;
- *outSamplerState = state.first;
- return gl::Error(GL_NO_ERROR);
- }
- else
- {
- if (mSamplerStateCache.size() >= kMaxSamplerStates)
- {
- TRACE("Overflowed the limit of %u sampler states, removing the least recently used "
- "to make room.", kMaxSamplerStates);
-
- SamplerStateMap::iterator leastRecentlyUsed = mSamplerStateCache.begin();
- for (SamplerStateMap::iterator i = mSamplerStateCache.begin(); i != mSamplerStateCache.end(); i++)
- {
- if (i->second.second < leastRecentlyUsed->second.second)
- {
- leastRecentlyUsed = i;
- }
- }
- SafeRelease(leastRecentlyUsed->second.first);
- mSamplerStateCache.erase(leastRecentlyUsed);
- }
-
- D3D11_SAMPLER_DESC samplerDesc;
- samplerDesc.Filter = gl_d3d11::ConvertFilter(samplerState.minFilter, samplerState.magFilter,
- samplerState.maxAnisotropy, samplerState.compareMode);
- samplerDesc.AddressU = gl_d3d11::ConvertTextureWrap(samplerState.wrapS);
- samplerDesc.AddressV = gl_d3d11::ConvertTextureWrap(samplerState.wrapT);
- samplerDesc.AddressW = gl_d3d11::ConvertTextureWrap(samplerState.wrapR);
- samplerDesc.MipLODBias = 0;
- samplerDesc.MaxAnisotropy = samplerState.maxAnisotropy;
- samplerDesc.ComparisonFunc = gl_d3d11::ConvertComparison(samplerState.compareFunc);
- samplerDesc.BorderColor[0] = 0.0f;
- samplerDesc.BorderColor[1] = 0.0f;
- samplerDesc.BorderColor[2] = 0.0f;
- samplerDesc.BorderColor[3] = 0.0f;
- samplerDesc.MinLOD = samplerState.minLod;
- samplerDesc.MaxLOD = samplerState.maxLod;
-
- ID3D11SamplerState *dx11SamplerState = NULL;
- HRESULT result = mDevice->CreateSamplerState(&samplerDesc, &dx11SamplerState);
- if (FAILED(result) || !dx11SamplerState)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Unable to create a ID3D11SamplerState, HRESULT: 0x%X.", result);
- }
-
- mSamplerStateCache.insert(std::make_pair(samplerState, std::make_pair(dx11SamplerState, mCounter++)));
-
- *outSamplerState = dx11SamplerState;
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/RenderStateCache.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/RenderStateCache.h
deleted file mode 100644
index dfd1d84265..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/RenderStateCache.h
+++ /dev/null
@@ -1,113 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// RenderStateCache.h: Defines rx::RenderStateCache, a cache of Direct3D render
-// state objects.
-
-#ifndef LIBGLESV2_RENDERER_RENDERSTATECACHE_H_
-#define LIBGLESV2_RENDERER_RENDERSTATECACHE_H_
-
-#include "libGLESv2/angletypes.h"
-#include "libGLESv2/Error.h"
-#include "common/angleutils.h"
-
-#include <unordered_map>
-
-namespace gl
-{
-class Framebuffer;
-}
-
-namespace rx
-{
-class Renderer11;
-
-class RenderStateCache
-{
- public:
- RenderStateCache(Renderer11 *renderer);
- virtual ~RenderStateCache();
-
- void initialize(ID3D11Device *device);
- void clear();
-
- gl::Error getBlendState(const gl::Framebuffer *framebuffer, const gl::BlendState &blendState, ID3D11BlendState **outBlendState);
- gl::Error getRasterizerState(const gl::RasterizerState &rasterState, bool scissorEnabled, ID3D11RasterizerState **outRasterizerState);
- gl::Error getDepthStencilState(const gl::DepthStencilState &dsState, ID3D11DepthStencilState **outDSState);
- gl::Error getSamplerState(const gl::SamplerState &samplerState, ID3D11SamplerState **outSamplerState);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(RenderStateCache);
-
- Renderer11 *mRenderer;
- unsigned long long mCounter;
-
- // Blend state cache
- struct BlendStateKey
- {
- gl::BlendState blendState;
- bool rtChannels[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT][4];
- };
- static std::size_t hashBlendState(const BlendStateKey &blendState);
- static bool compareBlendStates(const BlendStateKey &a, const BlendStateKey &b);
- static const unsigned int kMaxBlendStates;
-
- typedef std::size_t (*BlendStateHashFunction)(const BlendStateKey &);
- typedef bool (*BlendStateEqualityFunction)(const BlendStateKey &, const BlendStateKey &);
- typedef std::pair<ID3D11BlendState*, unsigned long long> BlendStateCounterPair;
- typedef std::unordered_map<BlendStateKey, BlendStateCounterPair, BlendStateHashFunction, BlendStateEqualityFunction> BlendStateMap;
- BlendStateMap mBlendStateCache;
-
- // Rasterizer state cache
- struct RasterizerStateKey
- {
- gl::RasterizerState rasterizerState;
- bool scissorEnabled;
- };
- static std::size_t hashRasterizerState(const RasterizerStateKey &rasterState);
- static bool compareRasterizerStates(const RasterizerStateKey &a, const RasterizerStateKey &b);
- static const unsigned int kMaxRasterizerStates;
-
- typedef std::size_t (*RasterizerStateHashFunction)(const RasterizerStateKey &);
- typedef bool (*RasterizerStateEqualityFunction)(const RasterizerStateKey &, const RasterizerStateKey &);
- typedef std::pair<ID3D11RasterizerState*, unsigned long long> RasterizerStateCounterPair;
- typedef std::unordered_map<RasterizerStateKey, RasterizerStateCounterPair, RasterizerStateHashFunction, RasterizerStateEqualityFunction> RasterizerStateMap;
- RasterizerStateMap mRasterizerStateCache;
-
- // Depth stencil state cache
- static std::size_t hashDepthStencilState(const gl::DepthStencilState &dsState);
- static bool compareDepthStencilStates(const gl::DepthStencilState &a, const gl::DepthStencilState &b);
- static const unsigned int kMaxDepthStencilStates;
-
- typedef std::size_t (*DepthStencilStateHashFunction)(const gl::DepthStencilState &);
- typedef bool (*DepthStencilStateEqualityFunction)(const gl::DepthStencilState &, const gl::DepthStencilState &);
- typedef std::pair<ID3D11DepthStencilState*, unsigned long long> DepthStencilStateCounterPair;
- typedef std::unordered_map<gl::DepthStencilState,
- DepthStencilStateCounterPair,
- DepthStencilStateHashFunction,
- DepthStencilStateEqualityFunction> DepthStencilStateMap;
- DepthStencilStateMap mDepthStencilStateCache;
-
- // Sample state cache
- static std::size_t hashSamplerState(const gl::SamplerState &samplerState);
- static bool compareSamplerStates(const gl::SamplerState &a, const gl::SamplerState &b);
- static const unsigned int kMaxSamplerStates;
-
- typedef std::size_t (*SamplerStateHashFunction)(const gl::SamplerState &);
- typedef bool (*SamplerStateEqualityFunction)(const gl::SamplerState &, const gl::SamplerState &);
- typedef std::pair<ID3D11SamplerState*, unsigned long long> SamplerStateCounterPair;
- typedef std::unordered_map<gl::SamplerState,
- SamplerStateCounterPair,
- SamplerStateHashFunction,
- SamplerStateEqualityFunction> SamplerStateMap;
- SamplerStateMap mSamplerStateCache;
-
- ID3D11Device *mDevice;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_RENDERSTATECACHE_H_ \ No newline at end of file
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/RenderTarget11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/RenderTarget11.cpp
deleted file mode 100644
index aff3453492..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/RenderTarget11.cpp
+++ /dev/null
@@ -1,404 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// RenderTarget11.cpp: Implements a DX11-specific wrapper for ID3D11View pointers
-// retained by Renderbuffers.
-
-#include "libGLESv2/renderer/d3d/d3d11/RenderTarget11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/renderer11_utils.h"
-#include "libGLESv2/renderer/d3d/d3d11/SwapChain11.h"
-#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h"
-#include "libGLESv2/main.h"
-
-namespace rx
-{
-
-static bool getTextureProperties(ID3D11Resource *resource, unsigned int *mipLevels, unsigned int *samples)
-{
- ID3D11Texture1D *texture1D = d3d11::DynamicCastComObject<ID3D11Texture1D>(resource);
- if (texture1D)
- {
- D3D11_TEXTURE1D_DESC texDesc;
- texture1D->GetDesc(&texDesc);
- SafeRelease(texture1D);
-
- *mipLevels = texDesc.MipLevels;
- *samples = 0;
-
- return true;
- }
-
- ID3D11Texture2D *texture2D = d3d11::DynamicCastComObject<ID3D11Texture2D>(resource);
- if (texture2D)
- {
- D3D11_TEXTURE2D_DESC texDesc;
- texture2D->GetDesc(&texDesc);
- SafeRelease(texture2D);
-
- *mipLevels = texDesc.MipLevels;
- *samples = texDesc.SampleDesc.Count > 1 ? texDesc.SampleDesc.Count : 0;
-
- return true;
- }
-
- ID3D11Texture3D *texture3D = d3d11::DynamicCastComObject<ID3D11Texture3D>(resource);
- if (texture3D)
- {
- D3D11_TEXTURE3D_DESC texDesc;
- texture3D->GetDesc(&texDesc);
- SafeRelease(texture3D);
-
- *mipLevels = texDesc.MipLevels;
- *samples = 0;
-
- return true;
- }
-
- return false;
-}
-
-static unsigned int getRTVSubresourceIndex(ID3D11Resource *resource, ID3D11RenderTargetView *view)
-{
- D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- view->GetDesc(&rtvDesc);
-
- unsigned int mipSlice = 0;
- unsigned int arraySlice = 0;
-
- switch (rtvDesc.ViewDimension)
- {
- case D3D11_RTV_DIMENSION_TEXTURE1D:
- mipSlice = rtvDesc.Texture1D.MipSlice;
- arraySlice = 0;
- break;
-
- case D3D11_RTV_DIMENSION_TEXTURE1DARRAY:
- mipSlice = rtvDesc.Texture1DArray.MipSlice;
- arraySlice = rtvDesc.Texture1DArray.FirstArraySlice;
- break;
-
- case D3D11_RTV_DIMENSION_TEXTURE2D:
- mipSlice = rtvDesc.Texture2D.MipSlice;
- arraySlice = 0;
- break;
-
- case D3D11_RTV_DIMENSION_TEXTURE2DARRAY:
- mipSlice = rtvDesc.Texture2DArray.MipSlice;
- arraySlice = rtvDesc.Texture2DArray.FirstArraySlice;
- break;
-
- case D3D11_RTV_DIMENSION_TEXTURE2DMS:
- mipSlice = 0;
- arraySlice = 0;
- break;
-
- case D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY:
- mipSlice = 0;
- arraySlice = rtvDesc.Texture2DMSArray.FirstArraySlice;
- break;
-
- case D3D11_RTV_DIMENSION_TEXTURE3D:
- mipSlice = rtvDesc.Texture3D.MipSlice;
- arraySlice = 0;
- break;
-
- case D3D11_RTV_DIMENSION_UNKNOWN:
- case D3D11_RTV_DIMENSION_BUFFER:
- UNIMPLEMENTED();
- break;
-
- default:
- UNREACHABLE();
- break;
- }
-
- unsigned int mipLevels, samples;
- getTextureProperties(resource, &mipLevels, &samples);
-
- return D3D11CalcSubresource(mipSlice, arraySlice, mipLevels);
-}
-
-static unsigned int getDSVSubresourceIndex(ID3D11Resource *resource, ID3D11DepthStencilView *view)
-{
- D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
- view->GetDesc(&dsvDesc);
-
- unsigned int mipSlice = 0;
- unsigned int arraySlice = 0;
-
- switch (dsvDesc.ViewDimension)
- {
- case D3D11_DSV_DIMENSION_TEXTURE1D:
- mipSlice = dsvDesc.Texture1D.MipSlice;
- arraySlice = 0;
- break;
-
- case D3D11_DSV_DIMENSION_TEXTURE1DARRAY:
- mipSlice = dsvDesc.Texture1DArray.MipSlice;
- arraySlice = dsvDesc.Texture1DArray.FirstArraySlice;
- break;
-
- case D3D11_DSV_DIMENSION_TEXTURE2D:
- mipSlice = dsvDesc.Texture2D.MipSlice;
- arraySlice = 0;
- break;
-
- case D3D11_DSV_DIMENSION_TEXTURE2DARRAY:
- mipSlice = dsvDesc.Texture2DArray.MipSlice;
- arraySlice = dsvDesc.Texture2DArray.FirstArraySlice;
- break;
-
- case D3D11_DSV_DIMENSION_TEXTURE2DMS:
- mipSlice = 0;
- arraySlice = 0;
- break;
-
- case D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY:
- mipSlice = 0;
- arraySlice = dsvDesc.Texture2DMSArray.FirstArraySlice;
- break;
-
- case D3D11_DSV_DIMENSION_UNKNOWN:
- UNIMPLEMENTED();
- break;
-
- default:
- UNREACHABLE();
- break;
- }
-
- unsigned int mipLevels, samples;
- getTextureProperties(resource, &mipLevels, &samples);
-
- return D3D11CalcSubresource(mipSlice, arraySlice, mipLevels);
-}
-
-RenderTarget11 *RenderTarget11::makeRenderTarget11(RenderTarget *target)
-{
- ASSERT(HAS_DYNAMIC_TYPE(RenderTarget11*, target));
- return static_cast<RenderTarget11*>(target);
-}
-
-void RenderTarget11::invalidate(GLint x, GLint y, GLsizei width, GLsizei height)
-{
- // Currently a no-op
-}
-
-TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv, ID3D11Resource *resource, ID3D11ShaderResourceView *srv,
- GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei samples)
- : mWidth(width),
- mHeight(height),
- mDepth(depth),
- mInternalFormat(internalFormat),
- mActualFormat(internalFormat),
- mSamples(samples),
- mSubresourceIndex(0),
- mTexture(resource),
- mRenderTarget(rtv),
- mDepthStencil(NULL),
- mShaderResource(srv)
-{
- if (mTexture)
- {
- mTexture->AddRef();
- }
-
- if (mRenderTarget)
- {
- mRenderTarget->AddRef();
- }
-
- if (mShaderResource)
- {
- mShaderResource->AddRef();
- }
-
- if (mRenderTarget && mTexture)
- {
- mSubresourceIndex = getRTVSubresourceIndex(mTexture, mRenderTarget);
-
- D3D11_RENDER_TARGET_VIEW_DESC desc;
- mRenderTarget->GetDesc(&desc);
-
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(desc.Format);
- mActualFormat = dxgiFormatInfo.internalFormat;
- }
-}
-
-TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv, ID3D11Resource *resource, ID3D11ShaderResourceView *srv,
- GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei samples)
- : mWidth(width),
- mHeight(height),
- mDepth(depth),
- mInternalFormat(internalFormat),
- mActualFormat(internalFormat),
- mSamples(samples),
- mSubresourceIndex(0),
- mTexture(resource),
- mRenderTarget(NULL),
- mDepthStencil(dsv),
- mShaderResource(srv)
-{
- if (mTexture)
- {
- mTexture->AddRef();
- }
-
- if (mDepthStencil)
- {
- mDepthStencil->AddRef();
- }
-
- if (mShaderResource)
- {
- mShaderResource->AddRef();
- }
-
- if (mDepthStencil && mTexture)
- {
- mSubresourceIndex = getDSVSubresourceIndex(mTexture, mDepthStencil);
-
- D3D11_DEPTH_STENCIL_VIEW_DESC desc;
- mDepthStencil->GetDesc(&desc);
-
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(desc.Format);
- mActualFormat = dxgiFormatInfo.internalFormat;
- }
-}
-
-TextureRenderTarget11::~TextureRenderTarget11()
-{
- SafeRelease(mTexture);
- SafeRelease(mRenderTarget);
- SafeRelease(mDepthStencil);
- SafeRelease(mShaderResource);
-}
-
-ID3D11Resource *TextureRenderTarget11::getTexture() const
-{
- return mTexture;
-}
-
-ID3D11RenderTargetView *TextureRenderTarget11::getRenderTargetView() const
-{
- return mRenderTarget;
-}
-
-ID3D11DepthStencilView *TextureRenderTarget11::getDepthStencilView() const
-{
- return mDepthStencil;
-}
-
-ID3D11ShaderResourceView *TextureRenderTarget11::getShaderResourceView() const
-{
- return mShaderResource;
-}
-
-GLsizei TextureRenderTarget11::getWidth() const
-{
- return mWidth;
-}
-
-GLsizei TextureRenderTarget11::getHeight() const
-{
- return mHeight;
-}
-
-GLsizei TextureRenderTarget11::getDepth() const
-{
- return mDepth;
-}
-
-GLenum TextureRenderTarget11::getInternalFormat() const
-{
- return mInternalFormat;
-}
-
-GLenum TextureRenderTarget11::getActualFormat() const
-{
- return mActualFormat;
-}
-
-GLsizei TextureRenderTarget11::getSamples() const
-{
- return mSamples;
-}
-
-unsigned int TextureRenderTarget11::getSubresourceIndex() const
-{
- return mSubresourceIndex;
-}
-
-
-SurfaceRenderTarget11::SurfaceRenderTarget11(SwapChain11 *swapChain, bool depth)
- : mSwapChain(swapChain),
- mDepth(depth)
-{
- ASSERT(mSwapChain);
-}
-
-SurfaceRenderTarget11::~SurfaceRenderTarget11()
-{
-}
-
-GLsizei SurfaceRenderTarget11::getWidth() const
-{
- return mSwapChain->getWidth();
-}
-
-GLsizei SurfaceRenderTarget11::getHeight() const
-{
- return mSwapChain->getHeight();
-}
-
-GLsizei SurfaceRenderTarget11::getDepth() const
-{
- return 1;
-}
-
-GLenum SurfaceRenderTarget11::getInternalFormat() const
-{
- return (mDepth ? mSwapChain->GetDepthBufferInternalFormat() : mSwapChain->GetBackBufferInternalFormat());
-}
-
-GLenum SurfaceRenderTarget11::getActualFormat() const
-{
- return d3d11::GetDXGIFormatInfo(d3d11::GetTextureFormatInfo(getInternalFormat()).texFormat).internalFormat;
-}
-
-GLsizei SurfaceRenderTarget11::getSamples() const
-{
- // Our EGL surfaces do not support multisampling.
- return 0;
-}
-
-ID3D11Resource *SurfaceRenderTarget11::getTexture() const
-{
- return (mDepth ? mSwapChain->getDepthStencilTexture() : mSwapChain->getOffscreenTexture());
-}
-
-ID3D11RenderTargetView *SurfaceRenderTarget11::getRenderTargetView() const
-{
- return (mDepth ? NULL : mSwapChain->getRenderTarget());
-}
-
-ID3D11DepthStencilView *SurfaceRenderTarget11::getDepthStencilView() const
-{
- return (mDepth ? mSwapChain->getDepthStencil() : NULL);
-}
-
-ID3D11ShaderResourceView *SurfaceRenderTarget11::getShaderResourceView() const
-{
- return (mDepth ? mSwapChain->getDepthStencilShaderResource() : mSwapChain->getRenderTargetShaderResource());
-}
-
-unsigned int SurfaceRenderTarget11::getSubresourceIndex() const
-{
- return 0;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/RenderTarget11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/RenderTarget11.h
deleted file mode 100644
index c7babdda3f..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/RenderTarget11.h
+++ /dev/null
@@ -1,110 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// RenderTarget11.h: Defines a DX11-specific wrapper for ID3D11View pointers
-// retained by Renderbuffers.
-
-#ifndef LIBGLESV2_RENDERER_RENDERTARGET11_H_
-#define LIBGLESV2_RENDERER_RENDERTARGET11_H_
-
-#include "libGLESv2/renderer/RenderTarget.h"
-
-namespace rx
-{
-class SwapChain11;
-
-class RenderTarget11 : public RenderTarget
-{
- public:
- RenderTarget11() { }
- virtual ~RenderTarget11() { }
-
- static RenderTarget11 *makeRenderTarget11(RenderTarget *renderTarget);
-
- void invalidate(GLint x, GLint y, GLsizei width, GLsizei height) override;
-
- virtual ID3D11Resource *getTexture() const = 0;
- virtual ID3D11RenderTargetView *getRenderTargetView() const = 0;
- virtual ID3D11DepthStencilView *getDepthStencilView() const = 0;
- virtual ID3D11ShaderResourceView *getShaderResourceView() const = 0;
-
- virtual unsigned int getSubresourceIndex() const = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(RenderTarget11);
-};
-
-class TextureRenderTarget11 : public RenderTarget11
-{
- public:
- // TextureRenderTarget11 takes ownership of any D3D11 resources it is given and will AddRef them
- TextureRenderTarget11(ID3D11RenderTargetView *rtv, ID3D11Resource *resource, ID3D11ShaderResourceView *srv,
- GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei samples);
- TextureRenderTarget11(ID3D11DepthStencilView *dsv, ID3D11Resource *resource, ID3D11ShaderResourceView *srv,
- GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei samples);
- virtual ~TextureRenderTarget11();
-
- GLsizei getWidth() const override;
- GLsizei getHeight() const override;
- GLsizei getDepth() const override;
- GLenum getInternalFormat() const override;
- GLenum getActualFormat() const override;
- GLsizei getSamples() const override;
-
- ID3D11Resource *getTexture() const override;
- ID3D11RenderTargetView *getRenderTargetView() const override;
- ID3D11DepthStencilView *getDepthStencilView() const override;
- ID3D11ShaderResourceView *getShaderResourceView() const override;
-
- unsigned int getSubresourceIndex() const override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureRenderTarget11);
-
- GLsizei mWidth;
- GLsizei mHeight;
- GLsizei mDepth;
- GLenum mInternalFormat;
- GLenum mActualFormat;
- GLsizei mSamples;
-
- unsigned int mSubresourceIndex;
- ID3D11Resource *mTexture;
- ID3D11RenderTargetView *mRenderTarget;
- ID3D11DepthStencilView *mDepthStencil;
- ID3D11ShaderResourceView *mShaderResource;
-};
-
-class SurfaceRenderTarget11 : public RenderTarget11
-{
- public:
- SurfaceRenderTarget11(SwapChain11 *swapChain, bool depth);
- virtual ~SurfaceRenderTarget11();
-
- GLsizei getWidth() const override;
- GLsizei getHeight() const override;
- GLsizei getDepth() const override;
- GLenum getInternalFormat() const override;
- GLenum getActualFormat() const override;
- GLsizei getSamples() const override;
-
- ID3D11Resource *getTexture() const override;
- ID3D11RenderTargetView *getRenderTargetView() const override;
- ID3D11DepthStencilView *getDepthStencilView() const override;
- ID3D11ShaderResourceView *getShaderResourceView() const override;
-
- unsigned int getSubresourceIndex() const override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(SurfaceRenderTarget11);
-
- SwapChain11 *mSwapChain;
- bool mDepth;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_RENDERTARGET11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp
deleted file mode 100644
index 777308e6cc..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp
+++ /dev/null
@@ -1,3422 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// Renderer11.cpp: Implements a back-end specific class for the D3D11 renderer.
-
-#include "libGLESv2/main.h"
-#include "libGLESv2/Buffer.h"
-#include "libGLESv2/FramebufferAttachment.h"
-#include "libGLESv2/ProgramBinary.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/State.h"
-#include "libGLESv2/renderer/d3d/ProgramD3D.h"
-#include "libGLESv2/renderer/d3d/ShaderD3D.h"
-#include "libGLESv2/renderer/d3d/TextureD3D.h"
-#include "libGLESv2/renderer/d3d/TransformFeedbackD3D.h"
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/RenderTarget11.h"
-#include "libGLESv2/renderer/d3d/d3d11/renderer11_utils.h"
-#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h"
-#include "libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.h"
-#include "libGLESv2/renderer/d3d/d3d11/SwapChain11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Image11.h"
-#include "libGLESv2/renderer/d3d/d3d11/VertexBuffer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/IndexBuffer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Buffer11.h"
-#include "libGLESv2/renderer/d3d/VertexDataManager.h"
-#include "libGLESv2/renderer/d3d/IndexDataManager.h"
-#include "libGLESv2/renderer/d3d/d3d11/TextureStorage11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Query11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Fence11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Blit11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Clear11.h"
-#include "libGLESv2/renderer/d3d/d3d11/PixelTransfer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/VertexArray11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Buffer11.h"
-#include "libGLESv2/renderer/d3d/RenderbufferD3D.h"
-
-#include "libEGL/Display.h"
-
-#include "common/utilities.h"
-#include "common/tls.h"
-
-#include <EGL/eglext.h>
-
-#include <sstream>
-
-// Enable ANGLE_SKIP_DXGI_1_2_CHECK if there is not a possibility of using cross-process
-// HWNDs or the Windows 7 Platform Update (KB2670838) is expected to be installed.
-#ifndef ANGLE_SKIP_DXGI_1_2_CHECK
-#define ANGLE_SKIP_DXGI_1_2_CHECK 0
-#endif
-
-#ifdef _DEBUG
-// this flag enables suppressing some spurious warnings that pop up in certain WebGL samples
-// and conformance tests. to enable all warnings, remove this define.
-#define ANGLE_SUPPRESS_D3D11_HAZARD_WARNINGS 1
-#endif
-
-namespace rx
-{
-
-namespace
-{
-static const DXGI_FORMAT RenderTargetFormats[] =
- {
- DXGI_FORMAT_B8G8R8A8_UNORM,
- DXGI_FORMAT_R8G8B8A8_UNORM
- };
-
-static const DXGI_FORMAT DepthStencilFormats[] =
- {
- DXGI_FORMAT_UNKNOWN,
- DXGI_FORMAT_D24_UNORM_S8_UINT,
- DXGI_FORMAT_D16_UNORM
- };
-
-enum
-{
- MAX_TEXTURE_IMAGE_UNITS_VTF_SM4 = 16
-};
-
-// Does *not* increment the resource ref count!!
-ID3D11Resource *GetSRVResource(ID3D11ShaderResourceView *srv)
-{
- ID3D11Resource *resource = NULL;
- ASSERT(srv);
- srv->GetResource(&resource);
- resource->Release();
- return resource;
-}
-
-}
-
-Renderer11::Renderer11(egl::Display *display, EGLNativeDisplayType hDc, const egl::AttributeMap &attributes)
- : RendererD3D(display),
- mDc(hDc),
- mStateCache(this)
-{
- mVertexDataManager = NULL;
- mIndexDataManager = NULL;
-
- mLineLoopIB = NULL;
- mTriangleFanIB = NULL;
-
- mBlit = NULL;
- mPixelTransfer = NULL;
-
- mClear = NULL;
-
- mSyncQuery = NULL;
-
- mD3d11Module = NULL;
- mDxgiModule = NULL;
-
- mDeviceLost = false;
-
- mDevice = NULL;
- mDeviceContext = NULL;
- mDxgiAdapter = NULL;
- mDxgiFactory = NULL;
-
- mDriverConstantBufferVS = NULL;
- mDriverConstantBufferPS = NULL;
-
- mAppliedVertexShader = NULL;
- mAppliedGeometryShader = NULL;
- mCurPointGeometryShader = NULL;
- mAppliedPixelShader = NULL;
-
- EGLint requestedMajorVersion = attributes.get(EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, EGL_DONT_CARE);
- EGLint requestedMinorVersion = attributes.get(EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, EGL_DONT_CARE);
-
- if (requestedMajorVersion == EGL_DONT_CARE || requestedMajorVersion >= 11)
- {
- if (requestedMinorVersion == EGL_DONT_CARE || requestedMinorVersion >= 0)
- {
- mAvailableFeatureLevels.push_back(D3D_FEATURE_LEVEL_11_0);
- }
- }
-
- if (requestedMajorVersion == EGL_DONT_CARE || requestedMajorVersion >= 10)
- {
- if (requestedMinorVersion == EGL_DONT_CARE || requestedMinorVersion >= 1)
- {
- mAvailableFeatureLevels.push_back(D3D_FEATURE_LEVEL_10_1);
- }
- if (requestedMinorVersion == EGL_DONT_CARE || requestedMinorVersion >= 0)
- {
- mAvailableFeatureLevels.push_back(D3D_FEATURE_LEVEL_10_0);
- }
- }
-
-#if !defined(ANGLE_ENABLE_D3D9)
- if (requestedMajorVersion == EGL_DONT_CARE || requestedMajorVersion >= 9)
- {
- if (requestedMinorVersion == EGL_DONT_CARE || requestedMinorVersion >= 3)
- {
- mAvailableFeatureLevels.push_back(D3D_FEATURE_LEVEL_9_3);
- }
- if (requestedMinorVersion == EGL_DONT_CARE || requestedMinorVersion >= 2)
- {
- mAvailableFeatureLevels.push_back(D3D_FEATURE_LEVEL_9_2);
- }
- if (requestedMinorVersion == EGL_DONT_CARE || requestedMinorVersion >= 1)
- {
- mAvailableFeatureLevels.push_back(D3D_FEATURE_LEVEL_9_1);
- }
- }
-#endif
-
- mDriverType = (attributes.get(EGL_PLATFORM_ANGLE_USE_WARP_ANGLE, EGL_FALSE) == EGL_TRUE) ? D3D_DRIVER_TYPE_WARP
- : D3D_DRIVER_TYPE_HARDWARE;
-}
-
-Renderer11::~Renderer11()
-{
- release();
-}
-
-Renderer11 *Renderer11::makeRenderer11(Renderer *renderer)
-{
- ASSERT(HAS_DYNAMIC_TYPE(Renderer11*, renderer));
- return static_cast<Renderer11*>(renderer);
-}
-
-#ifndef __d3d11_1_h__
-#define D3D11_MESSAGE_ID_DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET ((D3D11_MESSAGE_ID)3146081)
-#endif
-
-EGLint Renderer11::initialize()
-{
- if (!mCompiler.initialize())
- {
- return EGL_NOT_INITIALIZED;
- }
-
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
- mDxgiModule = LoadLibrary(TEXT("dxgi.dll"));
- mD3d11Module = LoadLibrary(TEXT("d3d11.dll"));
-
- if (mD3d11Module == NULL || mDxgiModule == NULL)
- {
- ERR("Could not load D3D11 or DXGI library - aborting!\n");
- return EGL_NOT_INITIALIZED;
- }
-
- // create the D3D11 device
- ASSERT(mDevice == NULL);
- PFN_D3D11_CREATE_DEVICE D3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE)GetProcAddress(mD3d11Module, "D3D11CreateDevice");
-
- if (D3D11CreateDevice == NULL)
- {
- ERR("Could not retrieve D3D11CreateDevice address - aborting!\n");
- return EGL_NOT_INITIALIZED;
- }
-#endif
-
- HRESULT result = S_OK;
-#ifdef _DEBUG
- result = D3D11CreateDevice(NULL,
- mDriverType,
- NULL,
- D3D11_CREATE_DEVICE_DEBUG,
- mAvailableFeatureLevels.data(),
- mAvailableFeatureLevels.size(),
- D3D11_SDK_VERSION,
- &mDevice,
- &mFeatureLevel,
- &mDeviceContext);
-
- if (!mDevice || FAILED(result))
- {
- ERR("Failed creating Debug D3D11 device - falling back to release runtime.\n");
- }
-
- if (!mDevice || FAILED(result))
-#endif
- {
- result = D3D11CreateDevice(NULL,
- mDriverType,
- NULL,
- 0,
- mAvailableFeatureLevels.data(),
- mAvailableFeatureLevels.size(),
- D3D11_SDK_VERSION,
- &mDevice,
- &mFeatureLevel,
- &mDeviceContext);
-
- if (!mDevice || FAILED(result))
- {
- ERR("Could not create D3D11 device - aborting!\n");
- return EGL_NOT_INITIALIZED; // Cleanup done by destructor through glDestroyRenderer
- }
- }
-
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
- static wchar_t *qt_d3dcreate_multihreaded_var = _wgetenv(L"QT_D3DCREATE_MULTITHREADED");
- if (qt_d3dcreate_multihreaded_var && wcsstr(qt_d3dcreate_multihreaded_var, L"1"))
- {
- ID3D10Multithread *multithread;
- result = mDevice->QueryInterface(IID_PPV_ARGS(&multithread));
- ASSERT(SUCCEEDED(result));
- result = multithread->SetMultithreadProtected(true);
- ASSERT(SUCCEEDED(result));
- multithread->Release();
- }
-#if !ANGLE_SKIP_DXGI_1_2_CHECK
- // In order to create a swap chain for an HWND owned by another process, DXGI 1.2 is required.
- // The easiest way to check is to query for a IDXGIDevice2.
- bool requireDXGI1_2 = false;
- HWND hwnd = WindowFromDC(mDc);
- if (hwnd)
- {
- DWORD currentProcessId = GetCurrentProcessId();
- DWORD wndProcessId;
- GetWindowThreadProcessId(hwnd, &wndProcessId);
- requireDXGI1_2 = (currentProcessId != wndProcessId);
- }
- else
- {
- requireDXGI1_2 = true;
- }
-
- if (requireDXGI1_2)
- {
- IDXGIDevice2 *dxgiDevice2 = NULL;
- result = mDevice->QueryInterface(__uuidof(IDXGIDevice2), (void**)&dxgiDevice2);
- if (FAILED(result))
- {
- ERR("DXGI 1.2 required to present to HWNDs owned by another process.\n");
- return EGL_NOT_INITIALIZED;
- }
- SafeRelease(dxgiDevice2);
- }
-#endif
-#endif
-
- IDXGIDevice *dxgiDevice = NULL;
- result = mDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice);
-
- if (FAILED(result))
- {
- ERR("Could not query DXGI device - aborting!\n");
- return EGL_NOT_INITIALIZED;
- }
-
- result = dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&mDxgiAdapter);
-
- if (FAILED(result))
- {
- ERR("Could not retrieve DXGI adapter - aborting!\n");
- return EGL_NOT_INITIALIZED;
- }
-
- SafeRelease(dxgiDevice);
-
- mDxgiAdapter->GetDesc(&mAdapterDescription);
- memset(mDescription, 0, sizeof(mDescription));
- wcstombs(mDescription, mAdapterDescription.Description, sizeof(mDescription) - 1);
-
- result = mDxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&mDxgiFactory);
-
- if (!mDxgiFactory || FAILED(result))
- {
- ERR("Could not create DXGI factory - aborting!\n");
- return EGL_NOT_INITIALIZED;
- }
-
- // Disable some spurious D3D11 debug warnings to prevent them from flooding the output log
-#if defined(ANGLE_SUPPRESS_D3D11_HAZARD_WARNINGS) && defined(_DEBUG)
- ID3D11InfoQueue *infoQueue;
- result = mDevice->QueryInterface(IID_ID3D11InfoQueue, (void **)&infoQueue);
-
- if (SUCCEEDED(result))
- {
- D3D11_MESSAGE_ID hideMessages[] =
- {
- D3D11_MESSAGE_ID_DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET
- };
-
- D3D11_INFO_QUEUE_FILTER filter = {0};
- filter.DenyList.NumIDs = ArraySize(hideMessages);
- filter.DenyList.pIDList = hideMessages;
-
- infoQueue->AddStorageFilterEntries(&filter);
- SafeRelease(infoQueue);
- }
-#endif
-
- initializeDevice();
-
- return EGL_SUCCESS;
-}
-
-// do any one-time device initialization
-// NOTE: this is also needed after a device lost/reset
-// to reset the scene status and ensure the default states are reset.
-void Renderer11::initializeDevice()
-{
- mStateCache.initialize(mDevice);
- mInputLayoutCache.initialize(mDevice, mDeviceContext);
-
- ASSERT(!mVertexDataManager && !mIndexDataManager);
- mVertexDataManager = new VertexDataManager(this);
- mIndexDataManager = new IndexDataManager(this);
-
- ASSERT(!mBlit);
- mBlit = new Blit11(this);
-
- ASSERT(!mClear);
- mClear = new Clear11(this);
-
- ASSERT(!mPixelTransfer);
- mPixelTransfer = new PixelTransfer11(this);
-
- const gl::Caps &rendererCaps = getRendererCaps();
-
- mForceSetVertexSamplerStates.resize(rendererCaps.maxVertexTextureImageUnits);
- mCurVertexSamplerStates.resize(rendererCaps.maxVertexTextureImageUnits);
-
- mForceSetPixelSamplerStates.resize(rendererCaps.maxTextureImageUnits);
- mCurPixelSamplerStates.resize(rendererCaps.maxTextureImageUnits);
-
- mCurVertexSRVs.resize(rendererCaps.maxVertexTextureImageUnits);
- mCurPixelSRVs.resize(rendererCaps.maxTextureImageUnits);
-
- markAllStateDirty();
-}
-
-int Renderer11::generateConfigs(ConfigDesc **configDescList)
-{
- unsigned int numRenderFormats = ArraySize(RenderTargetFormats);
- unsigned int numDepthFormats = ArraySize(DepthStencilFormats);
- (*configDescList) = new ConfigDesc[numRenderFormats * numDepthFormats];
- int numConfigs = 0;
-
- for (unsigned int formatIndex = 0; formatIndex < numRenderFormats; formatIndex++)
- {
- const d3d11::DXGIFormat &renderTargetFormatInfo = d3d11::GetDXGIFormatInfo(RenderTargetFormats[formatIndex]);
- const gl::TextureCaps &renderTargetFormatCaps = getRendererTextureCaps().get(renderTargetFormatInfo.internalFormat);
- if (renderTargetFormatCaps.renderable)
- {
- for (unsigned int depthStencilIndex = 0; depthStencilIndex < numDepthFormats; depthStencilIndex++)
- {
- const d3d11::DXGIFormat &depthStencilFormatInfo = d3d11::GetDXGIFormatInfo(DepthStencilFormats[depthStencilIndex]);
- const gl::TextureCaps &depthStencilFormatCaps = getRendererTextureCaps().get(depthStencilFormatInfo.internalFormat);
- if (depthStencilFormatCaps.renderable || DepthStencilFormats[depthStencilIndex] == DXGI_FORMAT_UNKNOWN)
- {
- ConfigDesc newConfig;
- newConfig.renderTargetFormat = renderTargetFormatInfo.internalFormat;
- newConfig.depthStencilFormat = depthStencilFormatInfo.internalFormat;
- newConfig.multiSample = 0; // FIXME: enumerate multi-sampling
- newConfig.fastConfig = true; // Assume all DX11 format conversions to be fast
- newConfig.es3Capable = true;
-
- (*configDescList)[numConfigs++] = newConfig;
- }
- }
- }
- }
-
- return numConfigs;
-}
-
-void Renderer11::deleteConfigs(ConfigDesc *configDescList)
-{
- delete [] (configDescList);
-}
-
-gl::Error Renderer11::sync(bool block)
-{
- if (block)
- {
- HRESULT result;
-
- if (!mSyncQuery)
- {
- D3D11_QUERY_DESC queryDesc;
- queryDesc.Query = D3D11_QUERY_EVENT;
- queryDesc.MiscFlags = 0;
-
- result = mDevice->CreateQuery(&queryDesc, &mSyncQuery);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create event query, result: 0x%X.", result);
- }
- }
-
- mDeviceContext->End(mSyncQuery);
- mDeviceContext->Flush();
-
- do
- {
- result = mDeviceContext->GetData(mSyncQuery, NULL, 0, D3D11_ASYNC_GETDATA_DONOTFLUSH);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to get event query data, result: 0x%X.", result);
- }
-
- // Keep polling, but allow other threads to do something useful first
- Sleep(0);
-
- if (testDeviceLost(true))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Device was lost while waiting for sync.");
- }
- }
- while (result == S_FALSE);
- }
- else
- {
- mDeviceContext->Flush();
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-SwapChain *Renderer11::createSwapChain(NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat)
-{
- return new SwapChain11(this, nativeWindow, shareHandle, backBufferFormat, depthBufferFormat);
-}
-
-gl::Error Renderer11::generateSwizzle(gl::Texture *texture)
-{
- if (texture)
- {
- TextureD3D *textureD3D = TextureD3D::makeTextureD3D(texture->getImplementation());
- ASSERT(textureD3D);
-
- TextureStorage *texStorage = textureD3D->getNativeTexture();
- if (texStorage)
- {
- TextureStorage11 *storage11 = TextureStorage11::makeTextureStorage11(texStorage);
- gl::Error error = storage11->generateSwizzles(texture->getSamplerState().swizzleRed,
- texture->getSamplerState().swizzleGreen,
- texture->getSamplerState().swizzleBlue,
- texture->getSamplerState().swizzleAlpha);
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::setSamplerState(gl::SamplerType type, int index, gl::Texture *texture, const gl::SamplerState &samplerStateParam)
-{
- // Make sure to add the level offset for our tiny compressed texture workaround
- TextureD3D *textureD3D = TextureD3D::makeTextureD3D(texture->getImplementation());
- gl::SamplerState samplerStateInternal = samplerStateParam;
- samplerStateInternal.baseLevel += textureD3D->getNativeTexture()->getTopLevel();
-
- if (type == gl::SAMPLER_PIXEL)
- {
- ASSERT(static_cast<unsigned int>(index) < getRendererCaps().maxTextureImageUnits);
-
- if (mForceSetPixelSamplerStates[index] || memcmp(&samplerStateInternal, &mCurPixelSamplerStates[index], sizeof(gl::SamplerState)) != 0)
- {
- ID3D11SamplerState *dxSamplerState = NULL;
- gl::Error error = mStateCache.getSamplerState(samplerStateInternal, &dxSamplerState);
- if (error.isError())
- {
- return error;
- }
-
- ASSERT(dxSamplerState != NULL);
- mDeviceContext->PSSetSamplers(index, 1, &dxSamplerState);
-
- mCurPixelSamplerStates[index] = samplerStateInternal;
- }
-
- mForceSetPixelSamplerStates[index] = false;
- }
- else if (type == gl::SAMPLER_VERTEX)
- {
- ASSERT(static_cast<unsigned int>(index) < getRendererCaps().maxVertexTextureImageUnits);
-
- if (mForceSetVertexSamplerStates[index] || memcmp(&samplerStateInternal, &mCurVertexSamplerStates[index], sizeof(gl::SamplerState)) != 0)
- {
- ID3D11SamplerState *dxSamplerState = NULL;
- gl::Error error = mStateCache.getSamplerState(samplerStateInternal, &dxSamplerState);
- if (error.isError())
- {
- return error;
- }
-
- ASSERT(dxSamplerState != NULL);
- mDeviceContext->VSSetSamplers(index, 1, &dxSamplerState);
-
- mCurVertexSamplerStates[index] = samplerStateInternal;
- }
-
- mForceSetVertexSamplerStates[index] = false;
- }
- else UNREACHABLE();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *texture)
-{
- ID3D11ShaderResourceView *textureSRV = NULL;
-
- if (texture)
- {
- TextureD3D *textureImpl = TextureD3D::makeTextureD3D(texture->getImplementation());
- TextureStorage *texStorage = textureImpl->getNativeTexture();
- ASSERT(texStorage != NULL);
-
- TextureStorage11 *storage11 = TextureStorage11::makeTextureStorage11(texStorage);
-
- // Make sure to add the level offset for our tiny compressed texture workaround
- gl::SamplerState samplerState = texture->getSamplerState();
- samplerState.baseLevel += storage11->getTopLevel();
-
- gl::Error error = storage11->getSRV(samplerState, &textureSRV);
- if (error.isError())
- {
- return error;
- }
-
- // If we get NULL back from getSRV here, something went wrong in the texture class and we're unexpectedly
- // missing the shader resource view
- ASSERT(textureSRV != NULL);
-
- textureImpl->resetDirty();
- }
-
- ASSERT((type == gl::SAMPLER_PIXEL && static_cast<unsigned int>(index) < getRendererCaps().maxTextureImageUnits) ||
- (type == gl::SAMPLER_VERTEX && static_cast<unsigned int>(index) < getRendererCaps().maxVertexTextureImageUnits));
-
- setShaderResource(type, index, textureSRV);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[])
-{
- for (unsigned int uniformBufferIndex = 0; uniformBufferIndex < gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS; uniformBufferIndex++)
- {
- const gl::Buffer *uniformBuffer = vertexUniformBuffers[uniformBufferIndex];
- if (uniformBuffer)
- {
- Buffer11 *bufferStorage = Buffer11::makeBuffer11(uniformBuffer->getImplementation());
- ID3D11Buffer *constantBuffer = bufferStorage->getBuffer(BUFFER_USAGE_UNIFORM);
-
- if (!constantBuffer)
- {
- return gl::Error(GL_OUT_OF_MEMORY);
- }
-
- if (mCurrentConstantBufferVS[uniformBufferIndex] != bufferStorage->getSerial())
- {
- mDeviceContext->VSSetConstantBuffers(getReservedVertexUniformBuffers() + uniformBufferIndex,
- 1, &constantBuffer);
- mCurrentConstantBufferVS[uniformBufferIndex] = bufferStorage->getSerial();
- }
- }
- }
-
- for (unsigned int uniformBufferIndex = 0; uniformBufferIndex < gl::IMPLEMENTATION_MAX_FRAGMENT_SHADER_UNIFORM_BUFFERS; uniformBufferIndex++)
- {
- const gl::Buffer *uniformBuffer = fragmentUniformBuffers[uniformBufferIndex];
- if (uniformBuffer)
- {
- Buffer11 *bufferStorage = Buffer11::makeBuffer11(uniformBuffer->getImplementation());
- ID3D11Buffer *constantBuffer = bufferStorage->getBuffer(BUFFER_USAGE_UNIFORM);
-
- if (!constantBuffer)
- {
- return gl::Error(GL_OUT_OF_MEMORY);
- }
-
- if (mCurrentConstantBufferPS[uniformBufferIndex] != bufferStorage->getSerial())
- {
- mDeviceContext->PSSetConstantBuffers(getReservedFragmentUniformBuffers() + uniformBufferIndex,
- 1, &constantBuffer);
- mCurrentConstantBufferPS[uniformBufferIndex] = bufferStorage->getSerial();
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::setRasterizerState(const gl::RasterizerState &rasterState)
-{
- if (mForceSetRasterState || memcmp(&rasterState, &mCurRasterState, sizeof(gl::RasterizerState)) != 0)
- {
- ID3D11RasterizerState *dxRasterState = NULL;
- gl::Error error = mStateCache.getRasterizerState(rasterState, mScissorEnabled, &dxRasterState);
- if (error.isError())
- {
- return error;
- }
-
- mDeviceContext->RSSetState(dxRasterState);
-
- mCurRasterState = rasterState;
- }
-
- mForceSetRasterState = false;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::setBlendState(const gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor,
- unsigned int sampleMask)
-{
- if (mForceSetBlendState ||
- memcmp(&blendState, &mCurBlendState, sizeof(gl::BlendState)) != 0 ||
- memcmp(&blendColor, &mCurBlendColor, sizeof(gl::ColorF)) != 0 ||
- sampleMask != mCurSampleMask)
- {
- ID3D11BlendState *dxBlendState = NULL;
- gl::Error error = mStateCache.getBlendState(framebuffer, blendState, &dxBlendState);
- if (error.isError())
- {
- return error;
- }
-
- ASSERT(dxBlendState != NULL);
-
- float blendColors[4] = {0.0f};
- if (blendState.sourceBlendRGB != GL_CONSTANT_ALPHA && blendState.sourceBlendRGB != GL_ONE_MINUS_CONSTANT_ALPHA &&
- blendState.destBlendRGB != GL_CONSTANT_ALPHA && blendState.destBlendRGB != GL_ONE_MINUS_CONSTANT_ALPHA)
- {
- blendColors[0] = blendColor.red;
- blendColors[1] = blendColor.green;
- blendColors[2] = blendColor.blue;
- blendColors[3] = blendColor.alpha;
- }
- else
- {
- blendColors[0] = blendColor.alpha;
- blendColors[1] = blendColor.alpha;
- blendColors[2] = blendColor.alpha;
- blendColors[3] = blendColor.alpha;
- }
-
- mDeviceContext->OMSetBlendState(dxBlendState, blendColors, sampleMask);
-
- mCurBlendState = blendState;
- mCurBlendColor = blendColor;
- mCurSampleMask = sampleMask;
- }
-
- mForceSetBlendState = false;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
- int stencilBackRef, bool frontFaceCCW)
-{
- if (mForceSetDepthStencilState ||
- memcmp(&depthStencilState, &mCurDepthStencilState, sizeof(gl::DepthStencilState)) != 0 ||
- stencilRef != mCurStencilRef || stencilBackRef != mCurStencilBackRef)
- {
- ASSERT(depthStencilState.stencilWritemask == depthStencilState.stencilBackWritemask);
- ASSERT(stencilRef == stencilBackRef);
- ASSERT(depthStencilState.stencilMask == depthStencilState.stencilBackMask);
-
- ID3D11DepthStencilState *dxDepthStencilState = NULL;
- gl::Error error = mStateCache.getDepthStencilState(depthStencilState, &dxDepthStencilState);
- if (error.isError())
- {
- return error;
- }
-
- ASSERT(dxDepthStencilState);
-
- // Max D3D11 stencil reference value is 0xFF, corresponding to the max 8 bits in a stencil buffer
- // GL specifies we should clamp the ref value to the nearest bit depth when doing stencil ops
- META_ASSERT(D3D11_DEFAULT_STENCIL_READ_MASK == 0xFF);
- META_ASSERT(D3D11_DEFAULT_STENCIL_WRITE_MASK == 0xFF);
- UINT dxStencilRef = std::min<UINT>(stencilRef, 0xFFu);
-
- mDeviceContext->OMSetDepthStencilState(dxDepthStencilState, dxStencilRef);
-
- mCurDepthStencilState = depthStencilState;
- mCurStencilRef = stencilRef;
- mCurStencilBackRef = stencilBackRef;
- }
-
- mForceSetDepthStencilState = false;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void Renderer11::setScissorRectangle(const gl::Rectangle &scissor, bool enabled)
-{
- if (mForceSetScissor || memcmp(&scissor, &mCurScissor, sizeof(gl::Rectangle)) != 0 ||
- enabled != mScissorEnabled)
- {
- if (enabled)
- {
- D3D11_RECT rect;
- rect.left = std::max(0, scissor.x);
- rect.top = std::max(0, scissor.y);
- rect.right = scissor.x + std::max(0, scissor.width);
- rect.bottom = scissor.y + std::max(0, scissor.height);
-
- mDeviceContext->RSSetScissorRects(1, &rect);
- }
-
- if (enabled != mScissorEnabled)
- {
- mForceSetRasterState = true;
- }
-
- mCurScissor = scissor;
- mScissorEnabled = enabled;
- }
-
- mForceSetScissor = false;
-}
-
-void Renderer11::setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace,
- bool ignoreViewport)
-{
- gl::Rectangle actualViewport = viewport;
- float actualZNear = gl::clamp01(zNear);
- float actualZFar = gl::clamp01(zFar);
- if (ignoreViewport)
- {
- actualViewport.x = 0;
- actualViewport.y = 0;
- actualViewport.width = mRenderTargetDesc.width;
- actualViewport.height = mRenderTargetDesc.height;
- actualZNear = 0.0f;
- actualZFar = 1.0f;
- }
-
- const gl::Caps& caps = getRendererCaps();
-
- // Clamp width and height first to the gl maximum, then clamp further if we extend past the D3D maximum bounds
- D3D11_VIEWPORT dxViewport;
- dxViewport.TopLeftX = gl::clamp(actualViewport.x, -static_cast<int>(caps.maxViewportWidth), static_cast<int>(caps.maxViewportWidth));
- dxViewport.TopLeftY = gl::clamp(actualViewport.y, -static_cast<int>(caps.maxViewportHeight), static_cast<int>(caps.maxViewportHeight));
- dxViewport.Width = gl::clamp(actualViewport.width, 0, static_cast<int>(caps.maxViewportWidth - dxViewport.TopLeftX));
- dxViewport.Height = gl::clamp(actualViewport.height, 0, static_cast<int>(caps.maxViewportHeight - dxViewport.TopLeftY));
- dxViewport.MinDepth = actualZNear;
- dxViewport.MaxDepth = actualZFar;
-
- bool viewportChanged = mForceSetViewport || memcmp(&actualViewport, &mCurViewport, sizeof(gl::Rectangle)) != 0 ||
- actualZNear != mCurNear || actualZFar != mCurFar;
-
- if (viewportChanged)
- {
- mDeviceContext->RSSetViewports(1, &dxViewport);
-
- mCurViewport = actualViewport;
- mCurNear = actualZNear;
- mCurFar = actualZFar;
-
- mPixelConstants.viewCoords[0] = actualViewport.width * 0.5f;
- mPixelConstants.viewCoords[1] = actualViewport.height * 0.5f;
- mPixelConstants.viewCoords[2] = actualViewport.x + (actualViewport.width * 0.5f);
- mPixelConstants.viewCoords[3] = actualViewport.y + (actualViewport.height * 0.5f);
-
- mPixelConstants.depthFront[0] = (actualZFar - actualZNear) * 0.5f;
- mPixelConstants.depthFront[1] = (actualZNear + actualZFar) * 0.5f;
-
- mVertexConstants.depthRange[0] = actualZNear;
- mVertexConstants.depthRange[1] = actualZFar;
- mVertexConstants.depthRange[2] = actualZFar - actualZNear;
-
- mPixelConstants.depthRange[0] = actualZNear;
- mPixelConstants.depthRange[1] = actualZFar;
- mPixelConstants.depthRange[2] = actualZFar - actualZNear;
- }
-
- mForceSetViewport = false;
-}
-
-bool Renderer11::applyPrimitiveType(GLenum mode, GLsizei count)
-{
- D3D11_PRIMITIVE_TOPOLOGY primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
-
- GLsizei minCount = 0;
-
- switch (mode)
- {
- case GL_POINTS: primitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_POINTLIST; minCount = 1; break;
- case GL_LINES: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_LINELIST; minCount = 2; break;
- case GL_LINE_LOOP: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; minCount = 2; break;
- case GL_LINE_STRIP: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; minCount = 2; break;
- case GL_TRIANGLES: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; minCount = 3; break;
- case GL_TRIANGLE_STRIP: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; minCount = 3; break;
- // emulate fans via rewriting index buffer
- case GL_TRIANGLE_FAN: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; minCount = 3; break;
- default:
- UNREACHABLE();
- return false;
- }
-
- if (primitiveTopology != mCurrentPrimitiveTopology)
- {
- mDeviceContext->IASetPrimitiveTopology(primitiveTopology);
- mCurrentPrimitiveTopology = primitiveTopology;
- }
-
- return count >= minCount;
-}
-
-void Renderer11::unsetSRVsWithResource(gl::SamplerType samplerType, const ID3D11Resource *resource)
-{
- std::vector<ID3D11ShaderResourceView *> &currentSRVs = (samplerType == gl::SAMPLER_VERTEX ? mCurVertexSRVs : mCurPixelSRVs);
-
- for (size_t resourceIndex = 0; resourceIndex < currentSRVs.size(); ++resourceIndex)
- {
- ID3D11ShaderResourceView *srv = currentSRVs[resourceIndex];
-
- if (srv && GetSRVResource(srv) == resource)
- {
- setShaderResource(samplerType, static_cast<UINT>(resourceIndex), NULL);
- }
- }
-}
-
-gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer)
-{
- // Get the color render buffer and serial
- // Also extract the render target dimensions and view
- unsigned int renderTargetWidth = 0;
- unsigned int renderTargetHeight = 0;
- GLenum renderTargetFormat = 0;
- unsigned int renderTargetSerials[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS] = {0};
- ID3D11RenderTargetView* framebufferRTVs[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS] = {NULL};
- bool missingColorRenderTarget = true;
-
- const gl::ColorbufferInfo &colorbuffers = framebuffer->getColorbuffersForRender(getWorkarounds());
-
- for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment)
- {
- gl::FramebufferAttachment *colorbuffer = colorbuffers[colorAttachment];
-
- if (colorbuffer)
- {
- // the draw buffer must be either "none", "back" for the default buffer or the same index as this color (in order)
-
- // check for zero-sized default framebuffer, which is a special case.
- // in this case we do not wish to modify any state and just silently return false.
- // this will not report any gl error but will cause the calling method to return.
- if (colorbuffer->getWidth() == 0 || colorbuffer->getHeight() == 0)
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- renderTargetSerials[colorAttachment] = GetAttachmentSerial(colorbuffer);
-
- // Extract the render target dimensions and view
- RenderTarget11 *renderTarget = NULL;
- gl::Error error = d3d11::GetAttachmentRenderTarget(colorbuffer, &renderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(renderTarget);
-
- framebufferRTVs[colorAttachment] = renderTarget->getRenderTargetView();
- ASSERT(framebufferRTVs[colorAttachment]);
-
- if (missingColorRenderTarget)
- {
- renderTargetWidth = colorbuffer->getWidth();
- renderTargetHeight = colorbuffer->getHeight();
- renderTargetFormat = colorbuffer->getActualFormat();
- missingColorRenderTarget = false;
- }
-
-#if !defined(NDEBUG)
- // Unbind render target SRVs from the shader here to prevent D3D11 warnings.
- ID3D11Resource *renderTargetResource = renderTarget->getTexture();
- unsetSRVsWithResource(gl::SAMPLER_VERTEX, renderTargetResource);
- unsetSRVsWithResource(gl::SAMPLER_PIXEL, renderTargetResource);
-#endif
- }
- }
-
- // Get the depth stencil render buffter and serials
- gl::FramebufferAttachment *depthStencil = framebuffer->getDepthbuffer();
- unsigned int depthbufferSerial = 0;
- unsigned int stencilbufferSerial = 0;
- if (depthStencil)
- {
- depthbufferSerial = GetAttachmentSerial(depthStencil);
- }
- else if (framebuffer->getStencilbuffer())
- {
- depthStencil = framebuffer->getStencilbuffer();
- stencilbufferSerial = GetAttachmentSerial(depthStencil);
- }
-
- ID3D11DepthStencilView* framebufferDSV = NULL;
- if (depthStencil)
- {
- RenderTarget11 *depthStencilRenderTarget = NULL;
- gl::Error error = d3d11::GetAttachmentRenderTarget(depthStencil, &depthStencilRenderTarget);
- if (error.isError())
- {
- SafeRelease(framebufferRTVs);
- return error;
- }
- ASSERT(depthStencilRenderTarget);
-
- framebufferDSV = depthStencilRenderTarget->getDepthStencilView();
- ASSERT(framebufferDSV);
-
- // If there is no render buffer, the width, height and format values come from
- // the depth stencil
- if (missingColorRenderTarget)
- {
- renderTargetWidth = depthStencil->getWidth();
- renderTargetHeight = depthStencil->getHeight();
- renderTargetFormat = depthStencil->getActualFormat();
- }
- }
-
- // Apply the render target and depth stencil
- if (!mRenderTargetDescInitialized || !mDepthStencilInitialized ||
- memcmp(renderTargetSerials, mAppliedRenderTargetSerials, sizeof(renderTargetSerials)) != 0 ||
- depthbufferSerial != mAppliedDepthbufferSerial ||
- stencilbufferSerial != mAppliedStencilbufferSerial)
- {
- mDeviceContext->OMSetRenderTargets(getRendererCaps().maxDrawBuffers, framebufferRTVs, framebufferDSV);
-
- mRenderTargetDesc.width = renderTargetWidth;
- mRenderTargetDesc.height = renderTargetHeight;
- mRenderTargetDesc.format = renderTargetFormat;
- mForceSetViewport = true;
- mForceSetScissor = true;
- mForceSetBlendState = true;
-
- if (!mDepthStencilInitialized)
- {
- mForceSetRasterState = true;
- }
-
- for (unsigned int rtIndex = 0; rtIndex < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; rtIndex++)
- {
- mAppliedRenderTargetSerials[rtIndex] = renderTargetSerials[rtIndex];
- }
- mAppliedDepthbufferSerial = depthbufferSerial;
- mAppliedStencilbufferSerial = stencilbufferSerial;
- mRenderTargetDescInitialized = true;
- mDepthStencilInitialized = true;
- }
-
- invalidateFramebufferSwizzles(framebuffer);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::applyVertexBuffer(const gl::State &state, GLint first, GLsizei count, GLsizei instances)
-{
- TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS];
- gl::Error error = mVertexDataManager->prepareVertexData(state, first, count, attributes, instances);
- if (error.isError())
- {
- return error;
- }
-
- return mInputLayoutCache.applyVertexBuffers(attributes, state.getCurrentProgramBinary());
-}
-
-gl::Error Renderer11::applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo)
-{
- gl::Error error = mIndexDataManager->prepareIndexData(type, count, elementArrayBuffer, indices, indexInfo);
- if (error.isError())
- {
- return error;
- }
-
- ID3D11Buffer *buffer = NULL;
- DXGI_FORMAT bufferFormat = (indexInfo->indexType == GL_UNSIGNED_INT) ? DXGI_FORMAT_R32_UINT : DXGI_FORMAT_R16_UINT;
-
- if (indexInfo->storage)
- {
- Buffer11 *storage = Buffer11::makeBuffer11(indexInfo->storage);
- buffer = storage->getBuffer(BUFFER_USAGE_INDEX);
- }
- else
- {
- IndexBuffer11* indexBuffer = IndexBuffer11::makeIndexBuffer11(indexInfo->indexBuffer);
- buffer = indexBuffer->getBuffer();
- }
-
- if (buffer != mAppliedIB || bufferFormat != mAppliedIBFormat || indexInfo->startOffset != mAppliedIBOffset)
- {
- mDeviceContext->IASetIndexBuffer(buffer, bufferFormat, indexInfo->startOffset);
-
- mAppliedIB = buffer;
- mAppliedIBFormat = bufferFormat;
- mAppliedIBOffset = indexInfo->startOffset;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void Renderer11::applyTransformFeedbackBuffers(const gl::State& state)
-{
- size_t numXFBBindings = state.getTransformFeedbackBufferIndexRange();
- ASSERT(numXFBBindings <= gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS);
-
- bool requiresUpdate = false;
- for (size_t i = 0; i < numXFBBindings; i++)
- {
- gl::Buffer *curXFBBuffer = state.getIndexedTransformFeedbackBuffer(i);
- GLintptr curXFBOffset = state.getIndexedTransformFeedbackBufferOffset(i);
- ID3D11Buffer *d3dBuffer = NULL;
- if (curXFBBuffer)
- {
- Buffer11 *storage = Buffer11::makeBuffer11(curXFBBuffer->getImplementation());
- d3dBuffer = storage->getBuffer(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK);
- }
-
- // TODO: mAppliedTFBuffers and friends should also be kept in a vector.
- if (d3dBuffer != mAppliedTFBuffers[i] || curXFBOffset != mAppliedTFOffsets[i])
- {
- requiresUpdate = true;
- }
- }
-
- if (requiresUpdate)
- {
- for (size_t i = 0; i < numXFBBindings; ++i)
- {
- gl::Buffer *curXFBBuffer = state.getIndexedTransformFeedbackBuffer(i);
- GLintptr curXFBOffset = state.getIndexedTransformFeedbackBufferOffset(i);
-
- if (curXFBBuffer)
- {
- Buffer11 *storage = Buffer11::makeBuffer11(curXFBBuffer->getImplementation());
- ID3D11Buffer *d3dBuffer = storage->getBuffer(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK);
-
- mCurrentD3DOffsets[i] = (mAppliedTFBuffers[i] != d3dBuffer && mAppliedTFOffsets[i] != curXFBOffset) ?
- static_cast<UINT>(curXFBOffset) : -1;
- mAppliedTFBuffers[i] = d3dBuffer;
- }
- else
- {
- mAppliedTFBuffers[i] = NULL;
- mCurrentD3DOffsets[i] = 0;
- }
- mAppliedTFOffsets[i] = curXFBOffset;
- }
-
- mDeviceContext->SOSetTargets(numXFBBindings, mAppliedTFBuffers, mCurrentD3DOffsets);
- }
-}
-
-gl::Error Renderer11::drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive)
-{
- if (mode == GL_POINTS && transformFeedbackActive)
- {
- // Since point sprites are generated with a geometry shader, too many vertices will
- // be written if transform feedback is active. To work around this, draw only the points
- // with the stream out shader and no pixel shader to feed the stream out buffers and then
- // draw again with the point sprite geometry shader to rasterize the point sprites.
-
- mDeviceContext->PSSetShader(NULL, NULL, 0);
-
- if (instances > 0)
- {
- mDeviceContext->DrawInstanced(count, instances, 0, 0);
- }
- else
- {
- mDeviceContext->Draw(count, 0);
- }
-
- mDeviceContext->GSSetShader(mCurPointGeometryShader, NULL, 0);
- mDeviceContext->PSSetShader(mAppliedPixelShader, NULL, 0);
-
- if (instances > 0)
- {
- mDeviceContext->DrawInstanced(count, instances, 0, 0);
- }
- else
- {
- mDeviceContext->Draw(count, 0);
- }
-
- mDeviceContext->GSSetShader(mAppliedGeometryShader, NULL, 0);
-
- return gl::Error(GL_NO_ERROR);
- }
- else if (mode == GL_LINE_LOOP)
- {
- return drawLineLoop(count, GL_NONE, NULL, 0, NULL);
- }
- else if (mode == GL_TRIANGLE_FAN)
- {
- return drawTriangleFan(count, GL_NONE, NULL, 0, NULL, instances);
- }
- else if (instances > 0)
- {
- mDeviceContext->DrawInstanced(count, instances, 0, 0);
- return gl::Error(GL_NO_ERROR);
- }
- else
- {
- mDeviceContext->Draw(count, 0);
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-gl::Error Renderer11::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
- gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo, GLsizei instances)
-{
- int minIndex = static_cast<int>(indexInfo.indexRange.start);
-
- if (mode == GL_LINE_LOOP)
- {
- return drawLineLoop(count, type, indices, minIndex, elementArrayBuffer);
- }
- else if (mode == GL_TRIANGLE_FAN)
- {
- return drawTriangleFan(count, type, indices, minIndex, elementArrayBuffer, instances);
- }
- else if (instances > 0)
- {
- mDeviceContext->DrawIndexedInstanced(count, instances, 0, -minIndex, 0);
- return gl::Error(GL_NO_ERROR);
- }
- else
- {
- mDeviceContext->DrawIndexed(count, 0, -minIndex);
- return gl::Error(GL_NO_ERROR);
- }
-}
-template<typename T>
-static void fillLineLoopIndices(GLenum type, GLsizei count, const GLvoid *indices, T *data)
-{
- switch (type)
- {
- case GL_NONE: // Non-indexed draw
- for (int i = 0; i < count; i++)
- {
- data[i] = i;
- }
- data[count] = 0;
- break;
- case GL_UNSIGNED_BYTE:
- for (int i = 0; i < count; i++)
- {
- data[i] = static_cast<const GLubyte*>(indices)[i];
- }
- data[count] = static_cast<const GLubyte*>(indices)[0];
- break;
- case GL_UNSIGNED_SHORT:
- for (int i = 0; i < count; i++)
- {
- data[i] = static_cast<const GLushort*>(indices)[i];
- }
- data[count] = static_cast<const GLushort*>(indices)[0];
- break;
- case GL_UNSIGNED_INT:
- for (int i = 0; i < count; i++)
- {
- data[i] = static_cast<const GLuint*>(indices)[i];
- }
- data[count] = static_cast<const GLuint*>(indices)[0];
- break;
- default: UNREACHABLE();
- }
-}
-
-template<typename T>
-static void fillTriangleFanIndices(GLenum type, unsigned int numTris, const GLvoid *indices, T *data)
-{
- switch (type)
- {
- case GL_NONE: // Non-indexed draw
- for (unsigned int i = 0; i < numTris; i++)
- {
- data[i*3 + 0] = 0;
- data[i*3 + 1] = i + 1;
- data[i*3 + 2] = i + 2;
- }
- break;
- case GL_UNSIGNED_BYTE:
- for (unsigned int i = 0; i < numTris; i++)
- {
- data[i*3 + 0] = static_cast<const GLubyte*>(indices)[0];
- data[i*3 + 1] = static_cast<const GLubyte*>(indices)[i + 1];
- data[i*3 + 2] = static_cast<const GLubyte*>(indices)[i + 2];
- }
- break;
- case GL_UNSIGNED_SHORT:
- for (unsigned int i = 0; i < numTris; i++)
- {
- data[i*3 + 0] = static_cast<const GLushort*>(indices)[0];
- data[i*3 + 1] = static_cast<const GLushort*>(indices)[i + 1];
- data[i*3 + 2] = static_cast<const GLushort*>(indices)[i + 2];
- }
- break;
- case GL_UNSIGNED_INT:
- for (unsigned int i = 0; i < numTris; i++)
- {
- data[i*3 + 0] = static_cast<const GLuint*>(indices)[0];
- data[i*3 + 1] = static_cast<const GLuint*>(indices)[i + 1];
- data[i*3 + 2] = static_cast<const GLuint*>(indices)[i + 2];
- }
- break;
- default: UNREACHABLE();
- }
-}
-
-gl::Error Renderer11::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer)
-{
- // Get the raw indices for an indexed draw
- if (type != GL_NONE && elementArrayBuffer)
- {
- BufferD3D *storage = BufferD3D::makeFromBuffer(elementArrayBuffer);
- intptr_t offset = reinterpret_cast<intptr_t>(indices);
-
- const uint8_t *bufferData = NULL;
- gl::Error error = storage->getData(&bufferData);
- if (error.isError())
- {
- return error;
- }
-
- indices = bufferData + offset;
- }
-
- // TODO: some level 9 hardware supports 32-bit indices; test and store support instead
- const int indexType = isLevel9() ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
-
- if (!mLineLoopIB)
- {
- mLineLoopIB = new StreamingIndexBufferInterface(this);
- gl::Error error = mLineLoopIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, indexType);
- if (error.isError())
- {
- SafeDelete(mLineLoopIB);
- return error;
- }
- }
-
- // Checked by Renderer11::applyPrimitiveType
- ASSERT(count >= 0);
-
- int indexTypeSize = indexType == GL_UNSIGNED_SHORT ? sizeof(unsigned short) : sizeof(unsigned int);
- if (static_cast<unsigned int>(count) + 1 > (std::numeric_limits<unsigned int>::max() / indexTypeSize))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create a 32-bit looping index buffer for GL_LINE_LOOP, too many indices required.");
- }
-
- const unsigned int spaceNeeded = (static_cast<unsigned int>(count) + 1) * sizeof(unsigned int);
- gl::Error error = mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT);
- if (error.isError())
- {
- return error;
- }
-
- void* mappedMemory = NULL;
- unsigned int offset;
- error = mLineLoopIB->mapBuffer(spaceNeeded, &mappedMemory, &offset);
- if (error.isError())
- {
- return error;
- }
-
- if (indexType == GL_UNSIGNED_SHORT)
- fillLineLoopIndices(type, count, indices, reinterpret_cast<unsigned short*>(mappedMemory));
- else
- fillLineLoopIndices(type, count, indices, reinterpret_cast<unsigned int*>(mappedMemory));
- unsigned int indexBufferOffset = offset;
-
- error = mLineLoopIB->unmapBuffer();
- if (error.isError())
- {
- return error;
- }
-
- IndexBuffer11 *indexBuffer = IndexBuffer11::makeIndexBuffer11(mLineLoopIB->getIndexBuffer());
- ID3D11Buffer *d3dIndexBuffer = indexBuffer->getBuffer();
- DXGI_FORMAT indexFormat = indexBuffer->getIndexFormat();
-
- if (mAppliedIB != d3dIndexBuffer || mAppliedIBFormat != indexFormat || mAppliedIBOffset != indexBufferOffset)
- {
- mDeviceContext->IASetIndexBuffer(d3dIndexBuffer, indexFormat, indexBufferOffset);
- mAppliedIB = d3dIndexBuffer;
- mAppliedIBFormat = indexFormat;
- mAppliedIBOffset = indexBufferOffset;
- }
-
- mDeviceContext->DrawIndexed(count + 1, 0, -minIndex);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances)
-{
- // Get the raw indices for an indexed draw
- if (type != GL_NONE && elementArrayBuffer)
- {
- BufferD3D *storage = BufferD3D::makeFromBuffer(elementArrayBuffer);
- intptr_t offset = reinterpret_cast<intptr_t>(indices);
-
- const uint8_t *bufferData = NULL;
- gl::Error error = storage->getData(&bufferData);
- if (error.isError())
- {
- return error;
- }
-
- indices = bufferData + offset;
- }
-
- const int indexType = isLevel9() ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
-
- if (!mTriangleFanIB)
- {
- mTriangleFanIB = new StreamingIndexBufferInterface(this);
- gl::Error error = mTriangleFanIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, indexType);
- if (error.isError())
- {
- SafeDelete(mTriangleFanIB);
- return error;
- }
- }
-
- // Checked by Renderer11::applyPrimitiveType
- ASSERT(count >= 3);
-
- const unsigned int numTris = count - 2;
-
- int indexTypeSize = indexType == GL_UNSIGNED_SHORT ? sizeof(unsigned short) : sizeof(unsigned int);
- if (numTris > (std::numeric_limits<unsigned int>::max() / (indexTypeSize * 3)))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create a scratch index buffer for GL_TRIANGLE_FAN, too many indices required.");
- }
-
- const unsigned int spaceNeeded = (numTris * 3) * indexTypeSize;
- gl::Error error = mTriangleFanIB->reserveBufferSpace(spaceNeeded, indexType);
- if (error.isError())
- {
- return error;
- }
-
- void* mappedMemory = NULL;
- unsigned int offset;
- error = mTriangleFanIB->mapBuffer(spaceNeeded, &mappedMemory, &offset);
- if (error.isError())
- {
- return error;
- }
-
- if (indexType == GL_UNSIGNED_SHORT)
- fillTriangleFanIndices(type, numTris, indices, reinterpret_cast<unsigned short*>(mappedMemory));
- else
- fillTriangleFanIndices(type, numTris, indices, reinterpret_cast<unsigned int*>(mappedMemory));
-
- unsigned int indexBufferOffset = offset;
-
- error = mTriangleFanIB->unmapBuffer();
- if (error.isError())
- {
- return error;
- }
-
- IndexBuffer11 *indexBuffer = IndexBuffer11::makeIndexBuffer11(mTriangleFanIB->getIndexBuffer());
- ID3D11Buffer *d3dIndexBuffer = indexBuffer->getBuffer();
- DXGI_FORMAT indexFormat = indexBuffer->getIndexFormat();
-
- if (mAppliedIB != d3dIndexBuffer || mAppliedIBFormat != indexFormat || mAppliedIBOffset != indexBufferOffset)
- {
- mDeviceContext->IASetIndexBuffer(d3dIndexBuffer, indexFormat, indexBufferOffset);
- mAppliedIB = d3dIndexBuffer;
- mAppliedIBFormat = indexFormat;
- mAppliedIBOffset = indexBufferOffset;
- }
-
- if (instances > 0)
- {
- mDeviceContext->DrawIndexedInstanced(numTris * 3, instances, 0, -minIndex, 0);
- }
- else
- {
- mDeviceContext->DrawIndexed(numTris * 3, 0, -minIndex);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
- bool rasterizerDiscard, bool transformFeedbackActive)
-{
- ProgramD3D *programD3D = ProgramD3D::makeProgramD3D(programBinary->getImplementation());
-
- ShaderExecutable *vertexExe = NULL;
- gl::Error error = programD3D->getVertexExecutableForInputLayout(inputLayout, &vertexExe);
- if (error.isError())
- {
- return error;
- }
-
- ShaderExecutable *pixelExe = NULL;
- error = programD3D->getPixelExecutableForFramebuffer(framebuffer, &pixelExe);
- if (error.isError())
- {
- return error;
- }
-
- ShaderExecutable *geometryExe = programD3D->getGeometryExecutable();
-
- ID3D11VertexShader *vertexShader = (vertexExe ? ShaderExecutable11::makeShaderExecutable11(vertexExe)->getVertexShader() : NULL);
-
- ID3D11PixelShader *pixelShader = NULL;
- // Skip pixel shader if we're doing rasterizer discard.
- if (!rasterizerDiscard)
- {
- pixelShader = (pixelExe ? ShaderExecutable11::makeShaderExecutable11(pixelExe)->getPixelShader() : NULL);
- }
-
- ID3D11GeometryShader *geometryShader = NULL;
- if (transformFeedbackActive)
- {
- geometryShader = (vertexExe ? ShaderExecutable11::makeShaderExecutable11(vertexExe)->getStreamOutShader() : NULL);
- }
- else if (mCurRasterState.pointDrawMode)
- {
- geometryShader = (geometryExe ? ShaderExecutable11::makeShaderExecutable11(geometryExe)->getGeometryShader() : NULL);
- }
-
- bool dirtyUniforms = false;
-
- if (vertexShader != mAppliedVertexShader)
- {
- mDeviceContext->VSSetShader(vertexShader, NULL, 0);
- mAppliedVertexShader = vertexShader;
- dirtyUniforms = true;
- }
-
- if (geometryShader != mAppliedGeometryShader)
- {
- mDeviceContext->GSSetShader(geometryShader, NULL, 0);
- mAppliedGeometryShader = geometryShader;
- dirtyUniforms = true;
- }
-
- if (geometryExe && mCurRasterState.pointDrawMode)
- {
- mCurPointGeometryShader = ShaderExecutable11::makeShaderExecutable11(geometryExe)->getGeometryShader();
- }
- else
- {
- mCurPointGeometryShader = NULL;
- }
-
- if (pixelShader != mAppliedPixelShader)
- {
- mDeviceContext->PSSetShader(pixelShader, NULL, 0);
- mAppliedPixelShader = pixelShader;
- dirtyUniforms = true;
- }
-
- if (dirtyUniforms)
- {
- programD3D->dirtyAllUniforms();
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray)
-{
- unsigned int totalRegisterCountVS = 0;
- unsigned int totalRegisterCountPS = 0;
-
- bool vertexUniformsDirty = false;
- bool pixelUniformsDirty = false;
-
- for (size_t uniformIndex = 0; uniformIndex < uniformArray.size(); uniformIndex++)
- {
- const gl::LinkedUniform &uniform = *uniformArray[uniformIndex];
-
- if (uniform.isReferencedByVertexShader() && !uniform.isSampler())
- {
- totalRegisterCountVS += uniform.registerCount;
- vertexUniformsDirty = (vertexUniformsDirty || uniform.dirty);
- }
-
- if (uniform.isReferencedByFragmentShader() && !uniform.isSampler())
- {
- totalRegisterCountPS += uniform.registerCount;
- pixelUniformsDirty = (pixelUniformsDirty || uniform.dirty);
- }
- }
-
- const ProgramD3D *programD3D = ProgramD3D::makeProgramD3D(&program);
- const UniformStorage11 *vertexUniformStorage = UniformStorage11::makeUniformStorage11(&programD3D->getVertexUniformStorage());
- const UniformStorage11 *fragmentUniformStorage = UniformStorage11::makeUniformStorage11(&programD3D->getFragmentUniformStorage());
- ASSERT(vertexUniformStorage);
- ASSERT(fragmentUniformStorage);
-
- ID3D11Buffer *vertexConstantBuffer = vertexUniformStorage->getConstantBuffer();
- ID3D11Buffer *pixelConstantBuffer = fragmentUniformStorage->getConstantBuffer();
-
- float (*mapVS)[4] = NULL;
- float (*mapPS)[4] = NULL;
-
- if (totalRegisterCountVS > 0 && vertexUniformsDirty)
- {
- D3D11_MAPPED_SUBRESOURCE map = {0};
- HRESULT result = mDeviceContext->Map(vertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
- UNUSED_ASSERTION_VARIABLE(result);
- ASSERT(SUCCEEDED(result));
- mapVS = (float(*)[4])map.pData;
- }
-
- if (totalRegisterCountPS > 0 && pixelUniformsDirty)
- {
- D3D11_MAPPED_SUBRESOURCE map = {0};
- HRESULT result = mDeviceContext->Map(pixelConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
- UNUSED_ASSERTION_VARIABLE(result);
- ASSERT(SUCCEEDED(result));
- mapPS = (float(*)[4])map.pData;
- }
-
- for (size_t uniformIndex = 0; uniformIndex < uniformArray.size(); uniformIndex++)
- {
- gl::LinkedUniform *uniform = uniformArray[uniformIndex];
-
- if (!uniform->isSampler())
- {
- unsigned int componentCount = (4 - uniform->registerElement);
-
- // we assume that uniforms from structs are arranged in struct order in our uniforms list. otherwise we would
- // overwrite previously written regions of memory.
-
- if (uniform->isReferencedByVertexShader() && mapVS)
- {
- memcpy(&mapVS[uniform->vsRegisterIndex][uniform->registerElement], uniform->data, uniform->registerCount * sizeof(float) * componentCount);
- }
-
- if (uniform->isReferencedByFragmentShader() && mapPS)
- {
- memcpy(&mapPS[uniform->psRegisterIndex][uniform->registerElement], uniform->data, uniform->registerCount * sizeof(float) * componentCount);
- }
- }
- }
-
- if (mapVS)
- {
- mDeviceContext->Unmap(vertexConstantBuffer, 0);
- }
-
- if (mapPS)
- {
- mDeviceContext->Unmap(pixelConstantBuffer, 0);
- }
-
- if (mCurrentVertexConstantBuffer != vertexConstantBuffer)
- {
- mDeviceContext->VSSetConstantBuffers(0, 1, &vertexConstantBuffer);
- mCurrentVertexConstantBuffer = vertexConstantBuffer;
- }
-
- if (mCurrentPixelConstantBuffer != pixelConstantBuffer)
- {
- mDeviceContext->PSSetConstantBuffers(0, 1, &pixelConstantBuffer);
- mCurrentPixelConstantBuffer = pixelConstantBuffer;
- }
-
- // Driver uniforms
- if (!mDriverConstantBufferVS)
- {
- D3D11_BUFFER_DESC constantBufferDescription = {0};
- constantBufferDescription.ByteWidth = sizeof(dx_VertexConstants);
- constantBufferDescription.Usage = D3D11_USAGE_DEFAULT;
- constantBufferDescription.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
- constantBufferDescription.CPUAccessFlags = 0;
- constantBufferDescription.MiscFlags = 0;
- constantBufferDescription.StructureByteStride = 0;
-
- HRESULT result = mDevice->CreateBuffer(&constantBufferDescription, NULL, &mDriverConstantBufferVS);
- UNUSED_ASSERTION_VARIABLE(result);
- ASSERT(SUCCEEDED(result));
-
- mDeviceContext->VSSetConstantBuffers(1, 1, &mDriverConstantBufferVS);
- }
-
- if (!mDriverConstantBufferPS)
- {
- D3D11_BUFFER_DESC constantBufferDescription = {0};
- constantBufferDescription.ByteWidth = sizeof(dx_PixelConstants);
- constantBufferDescription.Usage = D3D11_USAGE_DEFAULT;
- constantBufferDescription.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
- constantBufferDescription.CPUAccessFlags = 0;
- constantBufferDescription.MiscFlags = 0;
- constantBufferDescription.StructureByteStride = 0;
-
- HRESULT result = mDevice->CreateBuffer(&constantBufferDescription, NULL, &mDriverConstantBufferPS);
- UNUSED_ASSERTION_VARIABLE(result);
- ASSERT(SUCCEEDED(result));
-
- mDeviceContext->PSSetConstantBuffers(1, 1, &mDriverConstantBufferPS);
- }
-
- if (memcmp(&mVertexConstants, &mAppliedVertexConstants, sizeof(dx_VertexConstants)) != 0)
- {
- mDeviceContext->UpdateSubresource(mDriverConstantBufferVS, 0, NULL, &mVertexConstants, 16, 0);
- memcpy(&mAppliedVertexConstants, &mVertexConstants, sizeof(dx_VertexConstants));
- }
-
- if (memcmp(&mPixelConstants, &mAppliedPixelConstants, sizeof(dx_PixelConstants)) != 0)
- {
- mDeviceContext->UpdateSubresource(mDriverConstantBufferPS, 0, NULL, &mPixelConstants, 16, 0);
- memcpy(&mAppliedPixelConstants, &mPixelConstants, sizeof(dx_PixelConstants));
- }
-
- // needed for the point sprite geometry shader
- if (mFeatureLevel >= D3D_FEATURE_LEVEL_10_0 && mCurrentGeometryConstantBuffer != mDriverConstantBufferPS)
- {
- mDeviceContext->GSSetConstantBuffers(0, 1, &mDriverConstantBufferPS);
- mCurrentGeometryConstantBuffer = mDriverConstantBufferPS;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::clear(const gl::ClearParameters &clearParams, const gl::Framebuffer *frameBuffer)
-{
- gl::Error error = mClear->clearFramebuffer(clearParams, frameBuffer);
- if (error.isError())
- {
- return error;
- }
-
- invalidateFramebufferSwizzles(frameBuffer);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void Renderer11::markAllStateDirty()
-{
- for (unsigned int rtIndex = 0; rtIndex < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; rtIndex++)
- {
- mAppliedRenderTargetSerials[rtIndex] = 0;
- }
- mAppliedDepthbufferSerial = 0;
- mAppliedStencilbufferSerial = 0;
- mDepthStencilInitialized = false;
- mRenderTargetDescInitialized = false;
-
- ASSERT(mForceSetVertexSamplerStates.size() == mCurVertexSRVs.size());
- for (size_t vsamplerId = 0; vsamplerId < mForceSetVertexSamplerStates.size(); ++vsamplerId)
- {
- mForceSetVertexSamplerStates[vsamplerId] = true;
- }
-
- ASSERT(mForceSetPixelSamplerStates.size() == mCurPixelSRVs.size());
- for (size_t fsamplerId = 0; fsamplerId < mForceSetPixelSamplerStates.size(); ++fsamplerId)
- {
- mForceSetPixelSamplerStates[fsamplerId] = true;
- }
-
- mForceSetBlendState = true;
- mForceSetRasterState = true;
- mForceSetDepthStencilState = true;
- mForceSetScissor = true;
- mForceSetViewport = true;
-
- mAppliedIB = NULL;
- mAppliedIBFormat = DXGI_FORMAT_UNKNOWN;
- mAppliedIBOffset = 0;
-
- mAppliedVertexShader = NULL;
- mAppliedGeometryShader = NULL;
- mCurPointGeometryShader = NULL;
- mAppliedPixelShader = NULL;
-
- for (size_t i = 0; i < gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS; i++)
- {
- mAppliedTFBuffers[i] = NULL;
- mAppliedTFOffsets[i] = 0;
- }
-
- memset(&mAppliedVertexConstants, 0, sizeof(dx_VertexConstants));
- memset(&mAppliedPixelConstants, 0, sizeof(dx_PixelConstants));
-
- mInputLayoutCache.markDirty();
-
- for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS; i++)
- {
- mCurrentConstantBufferVS[i] = -1;
- mCurrentConstantBufferPS[i] = -1;
- }
-
- mCurrentVertexConstantBuffer = NULL;
- mCurrentPixelConstantBuffer = NULL;
- mCurrentGeometryConstantBuffer = NULL;
-
- mCurrentPrimitiveTopology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
-}
-
-void Renderer11::releaseDeviceResources()
-{
- mStateCache.clear();
- mInputLayoutCache.clear();
-
- SafeDelete(mVertexDataManager);
- SafeDelete(mIndexDataManager);
- SafeDelete(mLineLoopIB);
- SafeDelete(mTriangleFanIB);
- SafeDelete(mBlit);
- SafeDelete(mClear);
- SafeDelete(mPixelTransfer);
-
- SafeRelease(mDriverConstantBufferVS);
- SafeRelease(mDriverConstantBufferPS);
- SafeRelease(mSyncQuery);
-}
-
-void Renderer11::notifyDeviceLost()
-{
- mDeviceLost = true;
- mDisplay->notifyDeviceLost();
-}
-
-bool Renderer11::isDeviceLost()
-{
- return mDeviceLost;
-}
-
-// set notify to true to broadcast a message to all contexts of the device loss
-bool Renderer11::testDeviceLost(bool notify)
-{
- bool isLost = false;
-
- // GetRemovedReason is used to test if the device is removed
- HRESULT result = mDevice->GetDeviceRemovedReason();
- isLost = d3d11::isDeviceLostError(result);
-
- if (isLost)
- {
- // Log error if this is a new device lost event
- if (mDeviceLost == false)
- {
- ERR("The D3D11 device was removed: 0x%08X", result);
- }
-
- // ensure we note the device loss --
- // we'll probably get this done again by notifyDeviceLost
- // but best to remember it!
- // Note that we don't want to clear the device loss status here
- // -- this needs to be done by resetDevice
- mDeviceLost = true;
- if (notify)
- {
- notifyDeviceLost();
- }
- }
-
- return isLost;
-}
-
-bool Renderer11::testDeviceResettable()
-{
- // determine if the device is resettable by creating a dummy device
- PFN_D3D11_CREATE_DEVICE D3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE)GetProcAddress(mD3d11Module, "D3D11CreateDevice");
-
- if (D3D11CreateDevice == NULL)
- {
- return false;
- }
-
- ID3D11Device* dummyDevice;
- D3D_FEATURE_LEVEL dummyFeatureLevel;
- ID3D11DeviceContext* dummyContext;
-
- HRESULT result = D3D11CreateDevice(NULL,
- mDriverType,
- NULL,
- #if defined(_DEBUG)
- D3D11_CREATE_DEVICE_DEBUG,
- #else
- 0,
- #endif
- mAvailableFeatureLevels.data(),
- mAvailableFeatureLevels.size(),
- D3D11_SDK_VERSION,
- &dummyDevice,
- &dummyFeatureLevel,
- &dummyContext);
-
- if (!mDevice || FAILED(result))
- {
- return false;
- }
-
- SafeRelease(dummyContext);
- SafeRelease(dummyDevice);
-
- return true;
-}
-
-void Renderer11::release()
-{
- RendererD3D::cleanup();
-
- releaseShaderCompiler();
- releaseDeviceResources();
-
- SafeRelease(mDxgiFactory);
- SafeRelease(mDxgiAdapter);
-
- if (mDeviceContext)
- {
- mDeviceContext->ClearState();
- mDeviceContext->Flush();
- SafeRelease(mDeviceContext);
- }
-
- SafeRelease(mDevice);
-
- if (mD3d11Module)
- {
- FreeLibrary(mD3d11Module);
- mD3d11Module = NULL;
- }
-
- if (mDxgiModule)
- {
- FreeLibrary(mDxgiModule);
- mDxgiModule = NULL;
- }
-
- mCompiler.release();
-}
-
-bool Renderer11::resetDevice()
-{
- // recreate everything
- release();
- EGLint result = initialize();
-
- if (result != EGL_SUCCESS)
- {
- ERR("Could not reinitialize D3D11 device: %08X", result);
- return false;
- }
-
- mDeviceLost = false;
-
- return true;
-}
-
-DWORD Renderer11::getAdapterVendor() const
-{
- return mAdapterDescription.VendorId;
-}
-
-std::string Renderer11::getRendererDescription() const
-{
- std::ostringstream rendererString;
-
- rendererString << mDescription;
- rendererString << " Direct3D11";
-
- rendererString << " vs_" << getMajorShaderModel() << "_" << getMinorShaderModel();
- rendererString << " ps_" << getMajorShaderModel() << "_" << getMinorShaderModel();
-
- return rendererString.str();
-}
-
-GUID Renderer11::getAdapterIdentifier() const
-{
- // Use the adapter LUID as our adapter ID
- // This number is local to a machine is only guaranteed to be unique between restarts
- META_ASSERT(sizeof(LUID) <= sizeof(GUID));
- GUID adapterId = {0};
- memcpy(&adapterId, &mAdapterDescription.AdapterLuid, sizeof(LUID));
- return adapterId;
-}
-
-unsigned int Renderer11::getReservedVertexUniformVectors() const
-{
- return 0; // Driver uniforms are stored in a separate constant buffer
-}
-
-unsigned int Renderer11::getReservedFragmentUniformVectors() const
-{
- return 0; // Driver uniforms are stored in a separate constant buffer
-}
-
-unsigned int Renderer11::getReservedVertexUniformBuffers() const
-{
- // we reserve one buffer for the application uniforms, and one for driver uniforms
- return 2;
-}
-
-unsigned int Renderer11::getReservedFragmentUniformBuffers() const
-{
- // we reserve one buffer for the application uniforms, and one for driver uniforms
- return 2;
-}
-
-bool Renderer11::getShareHandleSupport() const
-{
- // We only currently support share handles with BGRA surfaces, because
- // chrome needs BGRA. Once chrome fixes this, we should always support them.
- // PIX doesn't seem to support using share handles, so disable them.
- return getRendererExtensions().textureFormatBGRA8888 && !gl::perfActive();
-}
-
-bool Renderer11::getPostSubBufferSupport() const
-{
- // D3D11 does not support present with dirty rectangles until D3D11.1 and DXGI 1.2.
- return false;
-}
-
-int Renderer11::getMajorShaderModel() const
-{
- switch (mFeatureLevel)
- {
- case D3D_FEATURE_LEVEL_11_0: return D3D11_SHADER_MAJOR_VERSION; // 5
- case D3D_FEATURE_LEVEL_10_1: return D3D10_1_SHADER_MAJOR_VERSION; // 4
- case D3D_FEATURE_LEVEL_10_0:
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return D3D10_SHADER_MAJOR_VERSION; // 4
- default: UNREACHABLE(); return 0;
- }
-}
-
-int Renderer11::getMinorShaderModel() const
-{
- switch (mFeatureLevel)
- {
- case D3D_FEATURE_LEVEL_11_0: return D3D11_SHADER_MINOR_VERSION; // 0
- case D3D_FEATURE_LEVEL_10_1: return D3D10_1_SHADER_MINOR_VERSION; // 1
- case D3D_FEATURE_LEVEL_10_0:
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return D3D10_SHADER_MINOR_VERSION; // 0
- default: UNREACHABLE(); return 0;
- }
-}
-
-int Renderer11::getMinSwapInterval() const
-{
- return 0;
-}
-
-int Renderer11::getMaxSwapInterval() const
-{
- return 4;
-}
-
-gl::Error Renderer11::copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level)
-{
- gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
- ASSERT(colorbuffer);
-
- RenderTarget11 *sourceRenderTarget = NULL;
- gl::Error error = d3d11::GetAttachmentRenderTarget(colorbuffer, &sourceRenderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(sourceRenderTarget);
-
- ID3D11ShaderResourceView *source = sourceRenderTarget->getShaderResourceView();
- ASSERT(source);
-
- TextureStorage11_2D *storage11 = TextureStorage11_2D::makeTextureStorage11_2D(storage);
- ASSERT(storage11);
-
- gl::ImageIndex index = gl::ImageIndex::Make2D(level);
- RenderTarget *destRenderTarget = NULL;
- error = storage11->getRenderTarget(index, &destRenderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(destRenderTarget);
-
- ID3D11RenderTargetView *dest = RenderTarget11::makeRenderTarget11(destRenderTarget)->getRenderTargetView();
- ASSERT(dest);
-
- gl::Box sourceArea(sourceRect.x, sourceRect.y, 0, sourceRect.width, sourceRect.height, 1);
- gl::Extents sourceSize(sourceRenderTarget->getWidth(), sourceRenderTarget->getHeight(), 1);
-
- gl::Box destArea(xoffset, yoffset, 0, sourceRect.width, sourceRect.height, 1);
- gl::Extents destSize(destRenderTarget->getWidth(), destRenderTarget->getHeight(), 1);
-
- // Use nearest filtering because source and destination are the same size for the direct
- // copy
- mBlit->copyTexture(source, sourceArea, sourceSize, dest, destArea, destSize, NULL, destFormat, GL_NEAREST);
- if (error.isError())
- {
- return error;
- }
-
- storage11->invalidateSwizzleCacheLevel(level);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level)
-{
- gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
- ASSERT(colorbuffer);
-
- RenderTarget11 *sourceRenderTarget = NULL;
- gl::Error error = d3d11::GetAttachmentRenderTarget(colorbuffer, &sourceRenderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(sourceRenderTarget);
-
- ID3D11ShaderResourceView *source = sourceRenderTarget->getShaderResourceView();
- ASSERT(source);
-
- TextureStorage11_Cube *storage11 = TextureStorage11_Cube::makeTextureStorage11_Cube(storage);
- ASSERT(storage11);
-
- gl::ImageIndex index = gl::ImageIndex::MakeCube(target, level);
- RenderTarget *destRenderTarget = NULL;
- error = storage11->getRenderTarget(index, &destRenderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(destRenderTarget);
-
- ID3D11RenderTargetView *dest = RenderTarget11::makeRenderTarget11(destRenderTarget)->getRenderTargetView();
- ASSERT(dest);
-
- gl::Box sourceArea(sourceRect.x, sourceRect.y, 0, sourceRect.width, sourceRect.height, 1);
- gl::Extents sourceSize(sourceRenderTarget->getWidth(), sourceRenderTarget->getHeight(), 1);
-
- gl::Box destArea(xoffset, yoffset, 0, sourceRect.width, sourceRect.height, 1);
- gl::Extents destSize(destRenderTarget->getWidth(), destRenderTarget->getHeight(), 1);
-
- // Use nearest filtering because source and destination are the same size for the direct
- // copy
- error = mBlit->copyTexture(source, sourceArea, sourceSize, dest, destArea, destSize, NULL, destFormat, GL_NEAREST);
- if (error.isError())
- {
- return error;
- }
-
- storage11->invalidateSwizzleCacheLevel(level);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level)
-{
- gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
- ASSERT(colorbuffer);
-
- RenderTarget11 *sourceRenderTarget = NULL;
- gl::Error error = d3d11::GetAttachmentRenderTarget(colorbuffer, &sourceRenderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(sourceRenderTarget);
-
- ID3D11ShaderResourceView *source = sourceRenderTarget->getShaderResourceView();
- ASSERT(source);
-
- TextureStorage11_3D *storage11 = TextureStorage11_3D::makeTextureStorage11_3D(storage);
- ASSERT(storage11);
-
- gl::ImageIndex index = gl::ImageIndex::Make3D(level, zOffset);
- RenderTarget *destRenderTarget = NULL;
- error = storage11->getRenderTarget(index, &destRenderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(destRenderTarget);
-
- ID3D11RenderTargetView *dest = RenderTarget11::makeRenderTarget11(destRenderTarget)->getRenderTargetView();
- ASSERT(dest);
-
- gl::Box sourceArea(sourceRect.x, sourceRect.y, 0, sourceRect.width, sourceRect.height, 1);
- gl::Extents sourceSize(sourceRenderTarget->getWidth(), sourceRenderTarget->getHeight(), 1);
-
- gl::Box destArea(xoffset, yoffset, 0, sourceRect.width, sourceRect.height, 1);
- gl::Extents destSize(destRenderTarget->getWidth(), destRenderTarget->getHeight(), 1);
-
- // Use nearest filtering because source and destination are the same size for the direct
- // copy
- error = mBlit->copyTexture(source, sourceArea, sourceSize, dest, destArea, destSize, NULL, destFormat, GL_NEAREST);
- if (error.isError())
- {
- return error;
- }
-
- storage11->invalidateSwizzleCacheLevel(level);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::copyImage2DArray(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level)
-{
- gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
- ASSERT(colorbuffer);
-
- RenderTarget11 *sourceRenderTarget = NULL;
- gl::Error error = d3d11::GetAttachmentRenderTarget(colorbuffer, &sourceRenderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(sourceRenderTarget);
-
- ID3D11ShaderResourceView *source = sourceRenderTarget->getShaderResourceView();
- ASSERT(source);
-
- TextureStorage11_2DArray *storage11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(storage);
- ASSERT(storage11);
-
- gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, zOffset);
- RenderTarget *destRenderTarget = NULL;
- error = storage11->getRenderTarget(index, &destRenderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(destRenderTarget);
-
- ID3D11RenderTargetView *dest = RenderTarget11::makeRenderTarget11(destRenderTarget)->getRenderTargetView();
- ASSERT(dest);
-
- gl::Box sourceArea(sourceRect.x, sourceRect.y, 0, sourceRect.width, sourceRect.height, 1);
- gl::Extents sourceSize(sourceRenderTarget->getWidth(), sourceRenderTarget->getHeight(), 1);
-
- gl::Box destArea(xoffset, yoffset, 0, sourceRect.width, sourceRect.height, 1);
- gl::Extents destSize(destRenderTarget->getWidth(), destRenderTarget->getHeight(), 1);
-
- // Use nearest filtering because source and destination are the same size for the direct
- // copy
- error = mBlit->copyTexture(source, sourceArea, sourceSize, dest, destArea, destSize, NULL, destFormat, GL_NEAREST);
- if (error.isError())
- {
- return error;
- }
-
- storage11->invalidateSwizzleCacheLevel(level);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void Renderer11::unapplyRenderTargets()
-{
- setOneTimeRenderTarget(NULL);
-}
-
-void Renderer11::setOneTimeRenderTarget(ID3D11RenderTargetView *renderTargetView)
-{
- ID3D11RenderTargetView *rtvArray[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS] = {NULL};
-
- rtvArray[0] = renderTargetView;
-
- mDeviceContext->OMSetRenderTargets(getRendererCaps().maxDrawBuffers, rtvArray, NULL);
-
- // Do not preserve the serial for this one-time-use render target
- for (unsigned int rtIndex = 0; rtIndex < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; rtIndex++)
- {
- mAppliedRenderTargetSerials[rtIndex] = 0;
- }
-}
-
-gl::Error Renderer11::createRenderTarget(SwapChain *swapChain, bool depth, RenderTarget **outRT)
-{
- SwapChain11 *swapChain11 = SwapChain11::makeSwapChain11(swapChain);
- *outRT = new SurfaceRenderTarget11(swapChain11, depth);
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTarget **outRT)
-{
- const d3d11::TextureFormat &formatInfo = d3d11::GetTextureFormatInfo(format);
-
- const gl::TextureCaps &textureCaps = getRendererTextureCaps().get(format);
- GLuint supportedSamples = textureCaps.getNearestSamples(samples);
-
- if (width > 0 && height > 0)
- {
- // Create texture resource
- D3D11_TEXTURE2D_DESC desc;
- desc.Width = width;
- desc.Height = height;
- desc.MipLevels = 1;
- desc.ArraySize = 1;
- desc.Format = formatInfo.texFormat;
- desc.SampleDesc.Count = (supportedSamples == 0) ? 1 : supportedSamples;
- desc.SampleDesc.Quality = 0;
- desc.Usage = D3D11_USAGE_DEFAULT;
- desc.CPUAccessFlags = 0;
- desc.MiscFlags = 0;
-
- // If a rendertarget or depthstencil format exists for this texture format,
- // we'll flag it to allow binding that way. Shader resource views are a little
- // more complicated.
- bool bindRTV = false, bindDSV = false, bindSRV = false;
- bindRTV = (formatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN);
- bindDSV = (formatInfo.dsvFormat != DXGI_FORMAT_UNKNOWN);
- if (formatInfo.srvFormat != DXGI_FORMAT_UNKNOWN)
- {
- // Multisample targets flagged for binding as depth stencil cannot also be
- // flagged for binding as SRV, so make certain not to add the SRV flag for
- // these targets.
- bindSRV = !(formatInfo.dsvFormat != DXGI_FORMAT_UNKNOWN && desc.SampleDesc.Count > 1);
- }
-
- desc.BindFlags = (bindRTV ? D3D11_BIND_RENDER_TARGET : 0) |
- (bindDSV ? D3D11_BIND_DEPTH_STENCIL : 0) |
- (bindSRV ? D3D11_BIND_SHADER_RESOURCE : 0);
-
- // The format must be either an RTV or a DSV
- ASSERT(bindRTV != bindDSV);
-
- ID3D11Texture2D *texture = NULL;
- HRESULT result = mDevice->CreateTexture2D(&desc, NULL, &texture);
- if (FAILED(result))
- {
- ASSERT(result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target texture, result: 0x%X.", result);
- }
-
- ID3D11ShaderResourceView *srv = NULL;
- if (bindSRV)
- {
- D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
- srvDesc.Format = formatInfo.srvFormat;
- srvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_SRV_DIMENSION_TEXTURE2D : D3D11_SRV_DIMENSION_TEXTURE2DMS;
- srvDesc.Texture2D.MostDetailedMip = 0;
- srvDesc.Texture2D.MipLevels = 1;
-
- result = mDevice->CreateShaderResourceView(texture, &srvDesc, &srv);
- if (FAILED(result))
- {
- ASSERT(result == E_OUTOFMEMORY);
- SafeRelease(texture);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target shader resource view, result: 0x%X.", result);
- }
- }
-
- if (bindDSV)
- {
- D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
- dsvDesc.Format = formatInfo.dsvFormat;
- dsvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_DSV_DIMENSION_TEXTURE2D : D3D11_DSV_DIMENSION_TEXTURE2DMS;
- dsvDesc.Texture2D.MipSlice = 0;
- dsvDesc.Flags = 0;
-
- ID3D11DepthStencilView *dsv = NULL;
- result = mDevice->CreateDepthStencilView(texture, &dsvDesc, &dsv);
- if (FAILED(result))
- {
- ASSERT(result == E_OUTOFMEMORY);
- SafeRelease(texture);
- SafeRelease(srv);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target depth stencil view, result: 0x%X.", result);
- }
-
- *outRT = new TextureRenderTarget11(dsv, texture, srv, format, width, height, 1, supportedSamples);
-
- SafeRelease(dsv);
- }
- else if (bindRTV)
- {
- D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- rtvDesc.Format = formatInfo.rtvFormat;
- rtvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_RTV_DIMENSION_TEXTURE2D : D3D11_RTV_DIMENSION_TEXTURE2DMS;
- rtvDesc.Texture2D.MipSlice = 0;
-
- ID3D11RenderTargetView *rtv = NULL;
- result = mDevice->CreateRenderTargetView(texture, &rtvDesc, &rtv);
- if (FAILED(result))
- {
- ASSERT(result == E_OUTOFMEMORY);
- SafeRelease(texture);
- SafeRelease(srv);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target render target view, result: 0x%X.", result);
- }
-
- if (formatInfo.dataInitializerFunction != NULL)
- {
- const float clearValues[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
- mDeviceContext->ClearRenderTargetView(rtv, clearValues);
- }
-
- *outRT = new TextureRenderTarget11(rtv, texture, srv, format, width, height, 1, supportedSamples);
-
- SafeRelease(rtv);
- }
- else
- {
- UNREACHABLE();
- }
-
- SafeRelease(texture);
- SafeRelease(srv);
- }
- else
- {
- *outRT = new TextureRenderTarget11(reinterpret_cast<ID3D11RenderTargetView*>(NULL), NULL, NULL, format, width, height, 1, supportedSamples);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-ShaderImpl *Renderer11::createShader(const gl::Data &data, GLenum type)
-{
- return new ShaderD3D(data, type, this);
-}
-
-ProgramImpl *Renderer11::createProgram()
-{
- return new ProgramD3D(this);
-}
-
-void Renderer11::releaseShaderCompiler()
-{
- ShaderD3D::releaseCompiler();
-}
-
-gl::Error Renderer11::loadExecutable(const void *function, size_t length, ShaderType type,
- const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
- bool separatedOutputBuffers, ShaderExecutable **outExecutable)
-{
- switch (type)
- {
- case SHADER_VERTEX:
- {
- ID3D11VertexShader *vertexShader = NULL;
- ID3D11GeometryShader *streamOutShader = NULL;
-
- HRESULT result = mDevice->CreateVertexShader(function, length, NULL, &vertexShader);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create vertex shader, result: 0x%X.", result);
- }
-
- if (transformFeedbackVaryings.size() > 0)
- {
- std::vector<D3D11_SO_DECLARATION_ENTRY> soDeclaration;
- for (size_t i = 0; i < transformFeedbackVaryings.size(); i++)
- {
- const gl::LinkedVarying &varying = transformFeedbackVaryings[i];
- GLenum transposedType = gl::TransposeMatrixType(varying.type);
-
- for (size_t j = 0; j < varying.semanticIndexCount; j++)
- {
- D3D11_SO_DECLARATION_ENTRY entry = { 0 };
- entry.Stream = 0;
- entry.SemanticName = varying.semanticName.c_str();
- entry.SemanticIndex = varying.semanticIndex + j;
- entry.StartComponent = 0;
- entry.ComponentCount = gl::VariableColumnCount(transposedType);
- entry.OutputSlot = (separatedOutputBuffers ? i : 0);
- soDeclaration.push_back(entry);
- }
- }
-
- result = mDevice->CreateGeometryShaderWithStreamOutput(function, length, soDeclaration.data(), soDeclaration.size(),
- NULL, 0, 0, NULL, &streamOutShader);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create steam output shader, result: 0x%X.", result);
- }
- }
-
- *outExecutable = new ShaderExecutable11(function, length, vertexShader, streamOutShader);
- }
- break;
- case SHADER_PIXEL:
- {
- ID3D11PixelShader *pixelShader = NULL;
-
- HRESULT result = mDevice->CreatePixelShader(function, length, NULL, &pixelShader);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create pixel shader, result: 0x%X.", result);
- }
-
- *outExecutable = new ShaderExecutable11(function, length, pixelShader);
- }
- break;
- case SHADER_GEOMETRY:
- {
- ID3D11GeometryShader *geometryShader = NULL;
-
- HRESULT result = mDevice->CreateGeometryShader(function, length, NULL, &geometryShader);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create geometry shader, result: 0x%X.", result);
- }
-
- *outExecutable = new ShaderExecutable11(function, length, geometryShader);
- }
- break;
- default:
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::compileToExecutable(gl::InfoLog &infoLog, const std::string &shaderHLSL, ShaderType type,
- const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
- bool separatedOutputBuffers, D3DWorkaroundType workaround,
- ShaderExecutable **outExectuable)
-{
- const char *profileType = NULL;
- switch (type)
- {
- case SHADER_VERTEX:
- profileType = "vs";
- break;
- case SHADER_PIXEL:
- profileType = "ps";
- break;
- case SHADER_GEOMETRY:
- profileType = "gs";
- break;
- default:
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
- }
-
- unsigned int profileMajorVersion = 0;
- unsigned int profileMinorVersion = 0;
- const char *profileSuffix = NULL;
- switch (mFeatureLevel)
- {
- case D3D_FEATURE_LEVEL_11_0:
- profileMajorVersion = 5;
- profileMinorVersion = 0;
- break;
- case D3D_FEATURE_LEVEL_10_1:
- profileMajorVersion = 4;
- profileMinorVersion = 1;
- break;
- case D3D_FEATURE_LEVEL_10_0:
- profileMajorVersion = 4;
- profileMinorVersion = 0;
- break;
- case D3D_FEATURE_LEVEL_9_3:
- profileMajorVersion = 4;
- profileMinorVersion = 0;
- profileSuffix = "_level_9_3";
- break;
- case D3D_FEATURE_LEVEL_9_2:
- profileMajorVersion = 4;
- profileMinorVersion = 0;
- profileSuffix = "_level_9_2";
- break;
- case D3D_FEATURE_LEVEL_9_1:
- profileMajorVersion = 4;
- profileMinorVersion = 0;
- profileSuffix = "_level_9_1";
- break;
- break;
- default:
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
- }
-
- std::string profile = FormatString("%s_%u_%u", profileType, profileMajorVersion, profileMinorVersion);
- if (profileSuffix)
- profile += profileSuffix;
-
- UINT flags = D3DCOMPILE_OPTIMIZATION_LEVEL2;
-
- if (gl::perfActive())
- {
-#ifndef NDEBUG
- flags = D3DCOMPILE_SKIP_OPTIMIZATION;
-#endif
-
- flags |= D3DCOMPILE_DEBUG;
- }
-
- // Sometimes D3DCompile will fail with the default compilation flags for complicated shaders when it would otherwise pass with alternative options.
- // Try the default flags first and if compilation fails, try some alternatives.
- std::vector<CompileConfig> configs;
- configs.push_back(CompileConfig(flags, "default" ));
- configs.push_back(CompileConfig(flags | D3DCOMPILE_SKIP_VALIDATION, "skip validation" ));
- configs.push_back(CompileConfig(flags | D3DCOMPILE_SKIP_OPTIMIZATION, "skip optimization"));
-
- D3D_SHADER_MACRO loopMacros[] = { {"ANGLE_ENABLE_LOOP_FLATTEN", "1"}, {0, 0} };
-
- ID3DBlob *binary = NULL;
- std::string debugInfo;
- gl::Error error = mCompiler.compileToBinary(infoLog, shaderHLSL, profile, configs, loopMacros, &binary, &debugInfo);
- if (error.isError())
- {
- return error;
- }
-
- // It's possible that binary is NULL if the compiler failed in all configurations. Set the executable to NULL
- // and return GL_NO_ERROR to signify that there was a link error but the internal state is still OK.
- if (!binary)
- {
- *outExectuable = NULL;
- return gl::Error(GL_NO_ERROR);
- }
-
- error = loadExecutable(binary->GetBufferPointer(), binary->GetBufferSize(), type,
- transformFeedbackVaryings, separatedOutputBuffers, outExectuable);
-
- SafeRelease(binary);
- if (error.isError())
- {
- return error;
- }
-
- if (!debugInfo.empty())
- {
- (*outExectuable)->appendDebugInfo(debugInfo);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-UniformStorage *Renderer11::createUniformStorage(size_t storageSize)
-{
- return new UniformStorage11(this, storageSize);
-}
-
-VertexBuffer *Renderer11::createVertexBuffer()
-{
- return new VertexBuffer11(this);
-}
-
-IndexBuffer *Renderer11::createIndexBuffer()
-{
- return new IndexBuffer11(this);
-}
-
-BufferImpl *Renderer11::createBuffer()
-{
- return new Buffer11(this);
-}
-
-VertexArrayImpl *Renderer11::createVertexArray()
-{
- return new VertexArray11(this);
-}
-
-QueryImpl *Renderer11::createQuery(GLenum type)
-{
- return new Query11(this, type);
-}
-
-FenceNVImpl *Renderer11::createFenceNV()
-{
- return new FenceNV11(this);
-}
-
-FenceSyncImpl *Renderer11::createFenceSync()
-{
- return new FenceSync11(this);
-}
-
-TransformFeedbackImpl* Renderer11::createTransformFeedback()
-{
- return new TransformFeedbackD3D();
-}
-
-bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const
-{
- ASSERT(getRendererExtensions().pixelBufferObject);
-
- const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat);
- const d3d11::TextureFormat &d3d11FormatInfo = d3d11::GetTextureFormatInfo(internalFormat);
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(d3d11FormatInfo.texFormat);
-
- // sRGB formats do not work with D3D11 buffer SRVs
- if (internalFormatInfo.colorEncoding == GL_SRGB)
- {
- return false;
- }
-
- // We cannot support direct copies to non-color-renderable formats
- if (d3d11FormatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN)
- {
- return false;
- }
-
- // We skip all 3-channel formats since sometimes format support is missing
- if (internalFormatInfo.componentCount == 3)
- {
- return false;
- }
-
- // We don't support formats which we can't represent without conversion
- if (dxgiFormatInfo.internalFormat != internalFormat)
- {
- return false;
- }
-
- return true;
-}
-
-gl::Error Renderer11::fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
- GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea)
-{
- ASSERT(supportsFastCopyBufferToTexture(destinationFormat));
- return mPixelTransfer->copyBufferToTexture(unpack, offset, destRenderTarget, destinationFormat, sourcePixelsType, destArea);
-}
-
-gl::Error Renderer11::getRenderTargetResource(gl::FramebufferAttachment *colorbuffer, unsigned int *subresourceIndexOut, ID3D11Texture2D **texture2DOut)
-
-{
- ASSERT(colorbuffer);
-
- RenderTarget11 *renderTarget = NULL;
- gl::Error error = d3d11::GetAttachmentRenderTarget(colorbuffer, &renderTarget);
- if (error.isError())
- {
- return error;
- }
-
- ID3D11Resource *renderTargetResource = renderTarget->getTexture();
- ASSERT(renderTargetResource);
-
- *subresourceIndexOut = renderTarget->getSubresourceIndex();
- *texture2DOut = d3d11::DynamicCastComObject<ID3D11Texture2D>(renderTargetResource);
-
- if (!(*texture2DOut))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to query the ID3D11Texture2D from a RenderTarget");
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::blitRect(const gl::Framebuffer *readTarget, const gl::Rectangle &readRect,
- const gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
- const gl::Rectangle *scissor, bool blitRenderTarget,
- bool blitDepth, bool blitStencil, GLenum filter)
-{
- if (blitRenderTarget)
- {
- gl::FramebufferAttachment *readBuffer = readTarget->getReadColorbuffer();
- ASSERT(readBuffer);
-
- RenderTarget *readRenderTarget = NULL;
- gl::Error error = GetAttachmentRenderTarget(readBuffer, &readRenderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(readRenderTarget);
-
- for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
- {
- if (drawTarget->isEnabledColorAttachment(colorAttachment))
- {
- gl::FramebufferAttachment *drawBuffer = drawTarget->getColorbuffer(colorAttachment);
- ASSERT(drawBuffer);
-
- RenderTarget *drawRenderTarget = NULL;
- error = GetAttachmentRenderTarget(drawBuffer, &drawRenderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(drawRenderTarget);
-
- error = blitRenderbufferRect(readRect, drawRect, readRenderTarget, drawRenderTarget, filter, scissor, blitRenderTarget,
- false, false);
- if (error.isError())
- {
- return error;
- }
- }
- }
- }
-
- if (blitDepth || blitStencil)
- {
- gl::FramebufferAttachment *readBuffer = readTarget->getDepthOrStencilbuffer();
- ASSERT(readBuffer);
-
- RenderTarget *readRenderTarget = NULL;
- gl::Error error = GetAttachmentRenderTarget(readBuffer, &readRenderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(readRenderTarget);
-
- gl::FramebufferAttachment *drawBuffer = drawTarget->getDepthOrStencilbuffer();
- ASSERT(drawBuffer);
-
- RenderTarget *drawRenderTarget = NULL;
- error = GetAttachmentRenderTarget(drawBuffer, &drawRenderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(drawRenderTarget);
-
- error = blitRenderbufferRect(readRect, drawRect, readRenderTarget, drawRenderTarget, filter, scissor, false,
- blitDepth, blitStencil);
- if (error.isError())
- {
- return error;
- }
- }
-
- invalidateFramebufferSwizzles(drawTarget);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::readPixels(const gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
- GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels)
-{
- ID3D11Texture2D *colorBufferTexture = NULL;
- unsigned int subresourceIndex = 0;
-
- gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
- ASSERT(colorbuffer);
-
- gl::Error error = getRenderTargetResource(colorbuffer, &subresourceIndex, &colorBufferTexture);
- if (error.isError())
- {
- return error;
- }
-
- gl::Rectangle area;
- area.x = x;
- area.y = y;
- area.width = width;
- area.height = height;
-
- gl::Buffer *packBuffer = pack.pixelBuffer.get();
- if (packBuffer != NULL)
- {
- Buffer11 *packBufferStorage = Buffer11::makeBuffer11(packBuffer->getImplementation());
- PackPixelsParams packParams(area, format, type, outputPitch, pack, reinterpret_cast<ptrdiff_t>(pixels));
-
- error = packBufferStorage->packPixels(colorBufferTexture, subresourceIndex, packParams);
- if (error.isError())
- {
- SafeRelease(colorBufferTexture);
- return error;
- }
-
- packBuffer->getIndexRangeCache()->clear();
- }
- else
- {
- error = readTextureData(colorBufferTexture, subresourceIndex, area, format, type, outputPitch, pack, pixels);
- if (error.isError())
- {
- SafeRelease(colorBufferTexture);
- return error;
- }
- }
-
- SafeRelease(colorBufferTexture);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-Image *Renderer11::createImage()
-{
- return new Image11();
-}
-
-gl::Error Renderer11::generateMipmap(Image *dest, Image *src)
-{
- Image11 *dest11 = Image11::makeImage11(dest);
- Image11 *src11 = Image11::makeImage11(src);
- return Image11::generateMipmap(dest11, src11);
-}
-
-TextureStorage *Renderer11::createTextureStorage2D(SwapChain *swapChain)
-{
- SwapChain11 *swapChain11 = SwapChain11::makeSwapChain11(swapChain);
- return new TextureStorage11_2D(this, swapChain11);
-}
-
-TextureStorage *Renderer11::createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels)
-{
- return new TextureStorage11_2D(this, internalformat, renderTarget, width, height, levels);
-}
-
-TextureStorage *Renderer11::createTextureStorageCube(GLenum internalformat, bool renderTarget, int size, int levels)
-{
- return new TextureStorage11_Cube(this, internalformat, renderTarget, size, levels);
-}
-
-TextureStorage *Renderer11::createTextureStorage3D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels)
-{
- return new TextureStorage11_3D(this, internalformat, renderTarget, width, height, depth, levels);
-}
-
-TextureStorage *Renderer11::createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels)
-{
- return new TextureStorage11_2DArray(this, internalformat, renderTarget, width, height, depth, levels);
-}
-
-TextureImpl *Renderer11::createTexture(GLenum target)
-{
- switch(target)
- {
- case GL_TEXTURE_2D: return new TextureD3D_2D(this);
- case GL_TEXTURE_CUBE_MAP: return new TextureD3D_Cube(this);
- case GL_TEXTURE_3D: return new TextureD3D_3D(this);
- case GL_TEXTURE_2D_ARRAY: return new TextureD3D_2DArray(this);
- default:
- UNREACHABLE();
- }
-
- return NULL;
-}
-
-RenderbufferImpl *Renderer11::createRenderbuffer()
-{
- RenderbufferD3D *renderbuffer = new RenderbufferD3D(this);
- return renderbuffer;
-}
-
-RenderbufferImpl *Renderer11::createRenderbuffer(SwapChain *swapChain, bool depth)
-{
- RenderbufferD3D *renderbuffer = new RenderbufferD3D(this);
- renderbuffer->setStorage(swapChain, depth);
- return renderbuffer;
-}
-
-gl::Error Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area, GLenum format,
- GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels)
-{
- ASSERT(area.width >= 0);
- ASSERT(area.height >= 0);
-
- D3D11_TEXTURE2D_DESC textureDesc;
- texture->GetDesc(&textureDesc);
-
- // Clamp read region to the defined texture boundaries, preventing out of bounds reads
- // and reads of uninitialized data.
- gl::Rectangle safeArea;
- safeArea.x = gl::clamp(area.x, 0, static_cast<int>(textureDesc.Width));
- safeArea.y = gl::clamp(area.y, 0, static_cast<int>(textureDesc.Height));
- safeArea.width = gl::clamp(area.width + std::min(area.x, 0), 0,
- static_cast<int>(textureDesc.Width) - safeArea.x);
- safeArea.height = gl::clamp(area.height + std::min(area.y, 0), 0,
- static_cast<int>(textureDesc.Height) - safeArea.y);
-
- ASSERT(safeArea.x >= 0 && safeArea.y >= 0);
- ASSERT(safeArea.x + safeArea.width <= static_cast<int>(textureDesc.Width));
- ASSERT(safeArea.y + safeArea.height <= static_cast<int>(textureDesc.Height));
-
- if (safeArea.width == 0 || safeArea.height == 0)
- {
- // no work to do
- return gl::Error(GL_NO_ERROR);
- }
-
- D3D11_TEXTURE2D_DESC stagingDesc;
- stagingDesc.Width = safeArea.width;
- stagingDesc.Height = safeArea.height;
- stagingDesc.MipLevels = 1;
- stagingDesc.ArraySize = 1;
- stagingDesc.Format = textureDesc.Format;
- stagingDesc.SampleDesc.Count = 1;
- stagingDesc.SampleDesc.Quality = 0;
- stagingDesc.Usage = D3D11_USAGE_STAGING;
- stagingDesc.BindFlags = 0;
- stagingDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
- stagingDesc.MiscFlags = 0;
-
- ID3D11Texture2D* stagingTex = NULL;
- HRESULT result = mDevice->CreateTexture2D(&stagingDesc, NULL, &stagingTex);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal staging texture for ReadPixels, HRESULT: 0x%X.", result);
- }
-
- ID3D11Texture2D* srcTex = NULL;
- if (textureDesc.SampleDesc.Count > 1)
- {
- D3D11_TEXTURE2D_DESC resolveDesc;
- resolveDesc.Width = textureDesc.Width;
- resolveDesc.Height = textureDesc.Height;
- resolveDesc.MipLevels = 1;
- resolveDesc.ArraySize = 1;
- resolveDesc.Format = textureDesc.Format;
- resolveDesc.SampleDesc.Count = 1;
- resolveDesc.SampleDesc.Quality = 0;
- resolveDesc.Usage = D3D11_USAGE_DEFAULT;
- resolveDesc.BindFlags = 0;
- resolveDesc.CPUAccessFlags = 0;
- resolveDesc.MiscFlags = 0;
-
- result = mDevice->CreateTexture2D(&resolveDesc, NULL, &srcTex);
- if (FAILED(result))
- {
- SafeRelease(stagingTex);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal resolve texture for ReadPixels, HRESULT: 0x%X.", result);
- }
-
- mDeviceContext->ResolveSubresource(srcTex, 0, texture, subResource, textureDesc.Format);
- subResource = 0;
- }
- else
- {
- srcTex = texture;
- srcTex->AddRef();
- }
-
- D3D11_BOX srcBox;
- srcBox.left = static_cast<UINT>(safeArea.x);
- srcBox.right = static_cast<UINT>(safeArea.x + safeArea.width);
- srcBox.top = static_cast<UINT>(safeArea.y);
- srcBox.bottom = static_cast<UINT>(safeArea.y + safeArea.height);
- srcBox.front = 0;
- srcBox.back = 1;
-
- mDeviceContext->CopySubresourceRegion(stagingTex, 0, 0, 0, 0, srcTex, subResource, &srcBox);
-
- SafeRelease(srcTex);
-
- PackPixelsParams packParams(safeArea, format, type, outputPitch, pack, 0);
- gl::Error error = packPixels(stagingTex, packParams, pixels);
-
- SafeRelease(stagingTex);
-
- return error;
-}
-
-gl::Error Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams &params, uint8_t *pixelsOut)
-{
- D3D11_TEXTURE2D_DESC textureDesc;
- readTexture->GetDesc(&textureDesc);
-
- D3D11_MAPPED_SUBRESOURCE mapping;
- HRESULT hr = mDeviceContext->Map(readTexture, 0, D3D11_MAP_READ, 0, &mapping);
- if (FAILED(hr))
- {
- ASSERT(hr == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal texture for reading, result: 0x%X.", hr);
- }
-
- uint8_t *source;
- int inputPitch;
- if (params.pack.reverseRowOrder)
- {
- source = static_cast<uint8_t*>(mapping.pData) + mapping.RowPitch * (params.area.height - 1);
- inputPitch = -static_cast<int>(mapping.RowPitch);
- }
- else
- {
- source = static_cast<uint8_t*>(mapping.pData);
- inputPitch = static_cast<int>(mapping.RowPitch);
- }
-
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(textureDesc.Format);
- const gl::InternalFormat &sourceFormatInfo = gl::GetInternalFormatInfo(dxgiFormatInfo.internalFormat);
- if (sourceFormatInfo.format == params.format && sourceFormatInfo.type == params.type)
- {
- uint8_t *dest = pixelsOut + params.offset;
- for (int y = 0; y < params.area.height; y++)
- {
- memcpy(dest + y * params.outputPitch, source + y * inputPitch, params.area.width * sourceFormatInfo.pixelBytes);
- }
- }
- else
- {
- const d3d11::DXGIFormat &sourceDXGIFormatInfo = d3d11::GetDXGIFormatInfo(textureDesc.Format);
- ColorCopyFunction fastCopyFunc = sourceDXGIFormatInfo.getFastCopyFunction(params.format, params.type);
-
- const gl::FormatType &destFormatTypeInfo = gl::GetFormatTypeInfo(params.format, params.type);
- const gl::InternalFormat &destFormatInfo = gl::GetInternalFormatInfo(destFormatTypeInfo.internalFormat);
-
- if (fastCopyFunc)
- {
- // Fast copy is possible through some special function
- for (int y = 0; y < params.area.height; y++)
- {
- for (int x = 0; x < params.area.width; x++)
- {
- uint8_t *dest = pixelsOut + params.offset + y * params.outputPitch + x * destFormatInfo.pixelBytes;
- const uint8_t *src = source + y * inputPitch + x * sourceFormatInfo.pixelBytes;
-
- fastCopyFunc(src, dest);
- }
- }
- }
- else
- {
- uint8_t temp[16]; // Maximum size of any Color<T> type used.
- META_ASSERT(sizeof(temp) >= sizeof(gl::ColorF) &&
- sizeof(temp) >= sizeof(gl::ColorUI) &&
- sizeof(temp) >= sizeof(gl::ColorI));
-
- for (int y = 0; y < params.area.height; y++)
- {
- for (int x = 0; x < params.area.width; x++)
- {
- uint8_t *dest = pixelsOut + params.offset + y * params.outputPitch + x * destFormatInfo.pixelBytes;
- const uint8_t *src = source + y * inputPitch + x * sourceFormatInfo.pixelBytes;
-
- // readFunc and writeFunc will be using the same type of color, CopyTexImage
- // will not allow the copy otherwise.
- sourceDXGIFormatInfo.colorReadFunction(src, temp);
- destFormatTypeInfo.colorWriteFunction(temp, dest);
- }
- }
- }
- }
-
- mDeviceContext->Unmap(readTexture, 0);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRect, const gl::Rectangle &drawRect, RenderTarget *readRenderTarget,
- RenderTarget *drawRenderTarget, GLenum filter, const gl::Rectangle *scissor,
- bool colorBlit, bool depthBlit, bool stencilBlit)
-{
- // Since blitRenderbufferRect is called for each render buffer that needs to be blitted,
- // it should never be the case that both color and depth/stencil need to be blitted at
- // at the same time.
- ASSERT(colorBlit != (depthBlit || stencilBlit));
-
- RenderTarget11 *drawRenderTarget11 = RenderTarget11::makeRenderTarget11(drawRenderTarget);
- if (!drawRenderTarget)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to retrieve the internal draw render target from the draw framebuffer.");
- }
-
- ID3D11Resource *drawTexture = drawRenderTarget11->getTexture();
- unsigned int drawSubresource = drawRenderTarget11->getSubresourceIndex();
- ID3D11RenderTargetView *drawRTV = drawRenderTarget11->getRenderTargetView();
- ID3D11DepthStencilView *drawDSV = drawRenderTarget11->getDepthStencilView();
-
- RenderTarget11 *readRenderTarget11 = RenderTarget11::makeRenderTarget11(readRenderTarget);
- if (!readRenderTarget)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to retrieve the internal read render target from the read framebuffer.");
- }
-
- ID3D11Resource *readTexture = NULL;
- ID3D11ShaderResourceView *readSRV = NULL;
- unsigned int readSubresource = 0;
- if (readRenderTarget->getSamples() > 0)
- {
- ID3D11Resource *unresolvedResource = readRenderTarget11->getTexture();
- ID3D11Texture2D *unresolvedTexture = d3d11::DynamicCastComObject<ID3D11Texture2D>(unresolvedResource);
-
- if (unresolvedTexture)
- {
- readTexture = resolveMultisampledTexture(unresolvedTexture, readRenderTarget11->getSubresourceIndex());
- readSubresource = 0;
-
- SafeRelease(unresolvedTexture);
-
- HRESULT hresult = mDevice->CreateShaderResourceView(readTexture, NULL, &readSRV);
- if (FAILED(hresult))
- {
- SafeRelease(readTexture);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create shader resource view to resolve multisampled framebuffer.");
- }
- }
- }
- else
- {
- readTexture = readRenderTarget11->getTexture();
- readTexture->AddRef();
- readSubresource = readRenderTarget11->getSubresourceIndex();
- readSRV = readRenderTarget11->getShaderResourceView();
- readSRV->AddRef();
- }
-
- if (!readTexture || !readSRV)
- {
- SafeRelease(readTexture);
- SafeRelease(readSRV);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to retrieve the internal read render target view from the read render target.");
- }
-
- gl::Extents readSize(readRenderTarget->getWidth(), readRenderTarget->getHeight(), 1);
- gl::Extents drawSize(drawRenderTarget->getWidth(), drawRenderTarget->getHeight(), 1);
-
- bool scissorNeeded = scissor && gl::ClipRectangle(drawRect, *scissor, NULL);
-
- bool wholeBufferCopy = !scissorNeeded &&
- readRect.x == 0 && readRect.width == readSize.width &&
- readRect.y == 0 && readRect.height == readSize.height &&
- drawRect.x == 0 && drawRect.width == drawSize.width &&
- drawRect.y == 0 && drawRect.height == drawSize.height;
-
- bool stretchRequired = readRect.width != drawRect.width || readRect.height != drawRect.height;
-
- bool flipRequired = readRect.width < 0 || readRect.height < 0 || drawRect.width < 0 || drawRect.height < 0;
-
- bool outOfBounds = readRect.x < 0 || readRect.x + readRect.width > readSize.width ||
- readRect.y < 0 || readRect.y + readRect.height > readSize.height ||
- drawRect.x < 0 || drawRect.x + drawRect.width > drawSize.width ||
- drawRect.y < 0 || drawRect.y + drawRect.height > drawSize.height;
-
- const gl::InternalFormat &actualFormatInfo = gl::GetInternalFormatInfo(drawRenderTarget->getActualFormat());
- bool partialDSBlit = (actualFormatInfo.depthBits > 0 && depthBlit) != (actualFormatInfo.stencilBits > 0 && stencilBlit);
-
- gl::Error result(GL_NO_ERROR);
-
- if (readRenderTarget11->getActualFormat() == drawRenderTarget->getActualFormat() &&
- !stretchRequired && !outOfBounds && !flipRequired && !partialDSBlit &&
- (!(depthBlit || stencilBlit) || wholeBufferCopy))
- {
- UINT dstX = drawRect.x;
- UINT dstY = drawRect.y;
-
- D3D11_BOX readBox;
- readBox.left = readRect.x;
- readBox.right = readRect.x + readRect.width;
- readBox.top = readRect.y;
- readBox.bottom = readRect.y + readRect.height;
- readBox.front = 0;
- readBox.back = 1;
-
- if (scissorNeeded)
- {
- // drawRect is guaranteed to have positive width and height because stretchRequired is false.
- ASSERT(drawRect.width >= 0 || drawRect.height >= 0);
-
- if (drawRect.x < scissor->x)
- {
- dstX = scissor->x;
- readBox.left += (scissor->x - drawRect.x);
- }
- if (drawRect.y < scissor->y)
- {
- dstY = scissor->y;
- readBox.top += (scissor->y - drawRect.y);
- }
- if (drawRect.x + drawRect.width > scissor->x + scissor->width)
- {
- readBox.right -= ((drawRect.x + drawRect.width) - (scissor->x + scissor->width));
- }
- if (drawRect.y + drawRect.height > scissor->y + scissor->height)
- {
- readBox.bottom -= ((drawRect.y + drawRect.height) - (scissor->y + scissor->height));
- }
- }
-
- // D3D11 needs depth-stencil CopySubresourceRegions to have a NULL pSrcBox
- // We also require complete framebuffer copies for depth-stencil blit.
- D3D11_BOX *pSrcBox = wholeBufferCopy ? NULL : &readBox;
-
- mDeviceContext->CopySubresourceRegion(drawTexture, drawSubresource, dstX, dstY, 0,
- readTexture, readSubresource, pSrcBox);
- result = gl::Error(GL_NO_ERROR);
- }
- else
- {
- gl::Box readArea(readRect.x, readRect.y, 0, readRect.width, readRect.height, 1);
- gl::Box drawArea(drawRect.x, drawRect.y, 0, drawRect.width, drawRect.height, 1);
-
- if (depthBlit && stencilBlit)
- {
- result = mBlit->copyDepthStencil(readTexture, readSubresource, readArea, readSize,
- drawTexture, drawSubresource, drawArea, drawSize,
- scissor);
- }
- else if (depthBlit)
- {
- result = mBlit->copyDepth(readSRV, readArea, readSize, drawDSV, drawArea, drawSize,
- scissor);
- }
- else if (stencilBlit)
- {
- result = mBlit->copyStencil(readTexture, readSubresource, readArea, readSize,
- drawTexture, drawSubresource, drawArea, drawSize,
- scissor);
- }
- else
- {
- GLenum format = gl::GetInternalFormatInfo(drawRenderTarget->getInternalFormat()).format;
- result = mBlit->copyTexture(readSRV, readArea, readSize, drawRTV, drawArea, drawSize,
- scissor, format, filter);
- }
- }
-
- SafeRelease(readTexture);
- SafeRelease(readSRV);
-
- return result;
-}
-
-ID3D11Texture2D *Renderer11::resolveMultisampledTexture(ID3D11Texture2D *source, unsigned int subresource)
-{
- D3D11_TEXTURE2D_DESC textureDesc;
- source->GetDesc(&textureDesc);
-
- if (textureDesc.SampleDesc.Count > 1)
- {
- D3D11_TEXTURE2D_DESC resolveDesc;
- resolveDesc.Width = textureDesc.Width;
- resolveDesc.Height = textureDesc.Height;
- resolveDesc.MipLevels = 1;
- resolveDesc.ArraySize = 1;
- resolveDesc.Format = textureDesc.Format;
- resolveDesc.SampleDesc.Count = 1;
- resolveDesc.SampleDesc.Quality = 0;
- resolveDesc.Usage = textureDesc.Usage;
- resolveDesc.BindFlags = textureDesc.BindFlags;
- resolveDesc.CPUAccessFlags = 0;
- resolveDesc.MiscFlags = 0;
-
- ID3D11Texture2D *resolveTexture = NULL;
- HRESULT result = mDevice->CreateTexture2D(&resolveDesc, NULL, &resolveTexture);
- if (FAILED(result))
- {
- ERR("Failed to create a multisample resolve texture, HRESULT: 0x%X.", result);
- return NULL;
- }
-
- mDeviceContext->ResolveSubresource(resolveTexture, 0, source, subresource, textureDesc.Format);
- return resolveTexture;
- }
- else
- {
- source->AddRef();
- return source;
- }
-}
-
-void Renderer11::invalidateFBOAttachmentSwizzles(gl::FramebufferAttachment *attachment, int mipLevel)
-{
- ASSERT(attachment->isTexture());
- gl::Texture *texture = attachment->getTexture();
-
- TextureD3D *textureD3D = TextureD3D::makeTextureD3D(texture->getImplementation());
- TextureStorage *texStorage = textureD3D->getNativeTexture();
- if (texStorage)
- {
- TextureStorage11 *texStorage11 = TextureStorage11::makeTextureStorage11(texStorage);
- if (!texStorage11)
- {
- ERR("texture storage pointer unexpectedly null.");
- return;
- }
-
- texStorage11->invalidateSwizzleCacheLevel(mipLevel);
- }
-}
-
-void Renderer11::invalidateFramebufferSwizzles(const gl::Framebuffer *framebuffer)
-{
- for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
- {
- gl::FramebufferAttachment *attachment = framebuffer->getColorbuffer(colorAttachment);
- if (attachment && attachment->isTexture())
- {
- invalidateFBOAttachmentSwizzles(attachment, attachment->mipLevel());
- }
- }
-
- gl::FramebufferAttachment *depthAttachment = framebuffer->getDepthbuffer();
- if (depthAttachment && depthAttachment->isTexture())
- {
- invalidateFBOAttachmentSwizzles(depthAttachment, depthAttachment->mipLevel());
- }
-
- gl::FramebufferAttachment *stencilAttachment = framebuffer->getStencilbuffer();
- if (stencilAttachment && stencilAttachment->isTexture())
- {
- invalidateFBOAttachmentSwizzles(stencilAttachment, stencilAttachment->mipLevel());
- }
-}
-
-bool Renderer11::getLUID(LUID *adapterLuid) const
-{
- adapterLuid->HighPart = 0;
- adapterLuid->LowPart = 0;
-
- if (!mDxgiAdapter)
- {
- return false;
- }
-
- DXGI_ADAPTER_DESC adapterDesc;
- if (FAILED(mDxgiAdapter->GetDesc(&adapterDesc)))
- {
- return false;
- }
-
- *adapterLuid = adapterDesc.AdapterLuid;
- return true;
-}
-
-VertexConversionType Renderer11::getVertexConversionType(const gl::VertexFormat &vertexFormat) const
-{
- return d3d11::GetVertexFormatInfo(vertexFormat).conversionType;
-}
-
-GLenum Renderer11::getVertexComponentType(const gl::VertexFormat &vertexFormat) const
-{
- return d3d11::GetDXGIFormatInfo(d3d11::GetVertexFormatInfo(vertexFormat).nativeFormat).componentType;
-}
-
-void Renderer11::generateCaps(gl::Caps *outCaps, gl::TextureCapsMap *outTextureCaps, gl::Extensions *outExtensions) const
-{
- d3d11_gl::GenerateCaps(mDevice, outCaps, outTextureCaps, outExtensions);
-}
-
-Workarounds Renderer11::generateWorkarounds() const
-{
- return d3d11::GenerateWorkarounds();
-}
-
-void Renderer11::setShaderResource(gl::SamplerType shaderType, UINT resourceSlot, ID3D11ShaderResourceView *srv)
-{
- std::vector<ID3D11ShaderResourceView *> &currentSRVs = (shaderType == gl::SAMPLER_VERTEX ? mCurVertexSRVs : mCurPixelSRVs);
-
- ASSERT(static_cast<size_t>(resourceSlot) < currentSRVs.size());
-
- if (currentSRVs[resourceSlot] != srv)
- {
- if (shaderType == gl::SAMPLER_VERTEX)
- {
- mDeviceContext->VSSetShaderResources(resourceSlot, 1, &srv);
- }
- else
- {
- mDeviceContext->PSSetShaderResources(resourceSlot, 1, &srv);
- }
-
- currentSRVs[resourceSlot] = srv;
- }
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h
deleted file mode 100644
index d44bd2fd30..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h
+++ /dev/null
@@ -1,362 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// Renderer11.h: Defines a back-end specific class for the D3D11 renderer.
-
-#ifndef LIBGLESV2_RENDERER_RENDERER11_H_
-#define LIBGLESV2_RENDERER_RENDERER11_H_
-
-#include "common/angleutils.h"
-#include "libGLESv2/angletypes.h"
-#include "common/mathutil.h"
-
-#include "libGLESv2/renderer/d3d/d3d11/RenderStateCache.h"
-#include "libGLESv2/renderer/d3d/d3d11/InputLayoutCache.h"
-#include "libGLESv2/renderer/d3d/HLSLCompiler.h"
-#include "libGLESv2/renderer/d3d/RendererD3D.h"
-#include "libGLESv2/renderer/RenderTarget.h"
-
-#include "libEGL/AttributeMap.h"
-
-namespace gl
-{
-class FramebufferAttachment;
-}
-
-namespace rx
-{
-
-class VertexDataManager;
-class IndexDataManager;
-class StreamingIndexBufferInterface;
-class Blit11;
-class Clear11;
-class PixelTransfer11;
-class RenderTarget11;
-struct PackPixelsParams;
-
-enum
-{
- MAX_VERTEX_UNIFORM_VECTORS_D3D11 = 1024,
- MAX_FRAGMENT_UNIFORM_VECTORS_D3D11 = 1024
-};
-
-class Renderer11 : public RendererD3D
-{
- public:
- Renderer11(egl::Display *display, EGLNativeDisplayType hDc, const egl::AttributeMap &attributes);
- virtual ~Renderer11();
-
- static Renderer11 *makeRenderer11(Renderer *renderer);
-
- virtual EGLint initialize();
- virtual bool resetDevice();
-
- virtual int generateConfigs(ConfigDesc **configDescList);
- virtual void deleteConfigs(ConfigDesc *configDescList);
-
- virtual gl::Error sync(bool block);
-
- virtual SwapChain *createSwapChain(NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat);
-
- virtual gl::Error generateSwizzle(gl::Texture *texture);
- virtual gl::Error setSamplerState(gl::SamplerType type, int index, gl::Texture *texture, const gl::SamplerState &sampler);
- virtual gl::Error setTexture(gl::SamplerType type, int index, gl::Texture *texture);
-
- virtual gl::Error setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]);
-
- virtual gl::Error setRasterizerState(const gl::RasterizerState &rasterState);
- gl::Error setBlendState(const gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor,
- unsigned int sampleMask) override;
- virtual gl::Error setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
- int stencilBackRef, bool frontFaceCCW);
-
- virtual void setScissorRectangle(const gl::Rectangle &scissor, bool enabled);
- virtual void setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace,
- bool ignoreViewport);
-
- virtual bool applyPrimitiveType(GLenum mode, GLsizei count);
- gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer) override;
- virtual gl::Error applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
- bool rasterizerDiscard, bool transformFeedbackActive);
-
- virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray);
- virtual gl::Error applyVertexBuffer(const gl::State &state, GLint first, GLsizei count, GLsizei instances);
- virtual gl::Error applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo);
- virtual void applyTransformFeedbackBuffers(const gl::State &state);
-
- virtual gl::Error drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive);
- virtual gl::Error drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
- gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo, GLsizei instances);
-
- gl::Error clear(const gl::ClearParameters &clearParams, const gl::Framebuffer *frameBuffer) override;
-
- virtual void markAllStateDirty();
-
- // lost device
- void notifyDeviceLost() override;
- bool isDeviceLost() override;
- bool testDeviceLost(bool notify) override;
- bool testDeviceResettable() override;
-
- DWORD getAdapterVendor() const override;
- std::string getRendererDescription() const override;
- GUID getAdapterIdentifier() const override;
-
- virtual unsigned int getReservedVertexUniformVectors() const;
- virtual unsigned int getReservedFragmentUniformVectors() const;
- virtual unsigned int getReservedVertexUniformBuffers() const;
- virtual unsigned int getReservedFragmentUniformBuffers() const;
- virtual bool getShareHandleSupport() const;
- virtual bool getPostSubBufferSupport() const;
-
- virtual int getMajorShaderModel() const;
- virtual int getMinSwapInterval() const;
- virtual int getMaxSwapInterval() const;
-
- // Pixel operations
- virtual gl::Error copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level);
- virtual gl::Error copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level);
- virtual gl::Error copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level);
- virtual gl::Error copyImage2DArray(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level);
-
- gl::Error blitRect(const gl::Framebuffer *readTarget, const gl::Rectangle &readRect, const gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
- const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter) override;
-
- virtual gl::Error readPixels(const gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
- GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels);
-
- // RenderTarget creation
- virtual gl::Error createRenderTarget(SwapChain *swapChain, bool depth, RenderTarget **outRT);
- virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTarget **outRT);
-
- // Shader creation
- virtual ShaderImpl *createShader(const gl::Data &data, GLenum type);
- virtual ProgramImpl *createProgram();
-
- // Shader operations
- void releaseShaderCompiler() override;
- virtual gl::Error loadExecutable(const void *function, size_t length, ShaderType type,
- const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
- bool separatedOutputBuffers, ShaderExecutable **outExecutable);
- virtual gl::Error compileToExecutable(gl::InfoLog &infoLog, const std::string &shaderHLSL, ShaderType type,
- const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
- bool separatedOutputBuffers, D3DWorkaroundType workaround,
- ShaderExecutable **outExectuable);
- virtual UniformStorage *createUniformStorage(size_t storageSize);
-
- // Image operations
- virtual Image *createImage();
- gl::Error generateMipmap(Image *dest, Image *source) override;
- virtual TextureStorage *createTextureStorage2D(SwapChain *swapChain);
- virtual TextureStorage *createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels);
- virtual TextureStorage *createTextureStorageCube(GLenum internalformat, bool renderTarget, int size, int levels);
- virtual TextureStorage *createTextureStorage3D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels);
- virtual TextureStorage *createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels);
-
- // Texture creation
- virtual TextureImpl *createTexture(GLenum target);
-
- // Renderbuffer creation
- virtual RenderbufferImpl *createRenderbuffer();
- virtual RenderbufferImpl *createRenderbuffer(SwapChain *swapChain, bool depth);
-
- // Buffer creation
- virtual BufferImpl *createBuffer();
- virtual VertexBuffer *createVertexBuffer();
- virtual IndexBuffer *createIndexBuffer();
-
- // Vertex Array creation
- virtual VertexArrayImpl *createVertexArray();
-
- // Query and Fence creation
- virtual QueryImpl *createQuery(GLenum type);
- virtual FenceNVImpl *createFenceNV();
- virtual FenceSyncImpl *createFenceSync();
-
- // Transform Feedback creation
- virtual TransformFeedbackImpl* createTransformFeedback();
-
- // D3D11-renderer specific methods
- ID3D11Device *getDevice() { return mDevice; }
- ID3D11DeviceContext *getDeviceContext() { return mDeviceContext; };
- DXGIFactory *getDxgiFactory() { return mDxgiFactory; };
- bool isLevel9() { return mFeatureLevel <= D3D_FEATURE_LEVEL_9_3; }
-
- Blit11 *getBlitter() { return mBlit; }
-
- // Buffer-to-texture and Texture-to-buffer copies
- virtual bool supportsFastCopyBufferToTexture(GLenum internalFormat) const;
- virtual gl::Error fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
- GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea);
-
- gl::Error getRenderTargetResource(gl::FramebufferAttachment *colorbuffer, unsigned int *subresourceIndexOut, ID3D11Texture2D **texture2DOut);
-
- void unapplyRenderTargets();
- void setOneTimeRenderTarget(ID3D11RenderTargetView *renderTargetView);
- gl::Error packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams &params, uint8_t *pixelsOut);
-
- virtual bool getLUID(LUID *adapterLuid) const;
- virtual VertexConversionType getVertexConversionType(const gl::VertexFormat &vertexFormat) const;
- virtual GLenum getVertexComponentType(const gl::VertexFormat &vertexFormat) const;
-
- gl::Error readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area, GLenum format,
- GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels);
-
- void setShaderResource(gl::SamplerType shaderType, UINT resourceSlot, ID3D11ShaderResourceView *srv);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Renderer11);
-
- void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap *outTextureCaps, gl::Extensions *outExtensions) const override;
- Workarounds generateWorkarounds() const override;
-
- gl::Error drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
- gl::Error drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances);
-
- gl::Error blitRenderbufferRect(const gl::Rectangle &readRect, const gl::Rectangle &drawRect, RenderTarget *readRenderTarget,
- RenderTarget *drawRenderTarget, GLenum filter, const gl::Rectangle *scissor,
- bool colorBlit, bool depthBlit, bool stencilBlit);
- ID3D11Texture2D *resolveMultisampledTexture(ID3D11Texture2D *source, unsigned int subresource);
- void unsetSRVsWithResource(gl::SamplerType shaderType, const ID3D11Resource *resource);
-
- static void invalidateFBOAttachmentSwizzles(gl::FramebufferAttachment *attachment, int mipLevel);
- static void invalidateFramebufferSwizzles(const gl::Framebuffer *framebuffer);
-
- HMODULE mD3d11Module;
- HMODULE mDxgiModule;
- EGLNativeDisplayType mDc;
- std::vector<D3D_FEATURE_LEVEL> mAvailableFeatureLevels;
- D3D_DRIVER_TYPE mDriverType;
-
- HLSLCompiler mCompiler;
-
- bool mDeviceLost;
-
- void initializeDevice();
- void releaseDeviceResources();
- int getMinorShaderModel() const;
- void release();
-
- RenderStateCache mStateCache;
-
- // current render target states
- unsigned int mAppliedRenderTargetSerials[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS];
- unsigned int mAppliedDepthbufferSerial;
- unsigned int mAppliedStencilbufferSerial;
- bool mDepthStencilInitialized;
- bool mRenderTargetDescInitialized;
- RenderTarget::Desc mRenderTargetDesc;
-
- // Currently applied sampler states
- std::vector<bool> mForceSetVertexSamplerStates;
- std::vector<gl::SamplerState> mCurVertexSamplerStates;
-
- std::vector<bool> mForceSetPixelSamplerStates;
- std::vector<gl::SamplerState> mCurPixelSamplerStates;
-
- // Currently applied textures
- std::vector<ID3D11ShaderResourceView*> mCurVertexSRVs;
- std::vector<ID3D11ShaderResourceView*> mCurPixelSRVs;
-
- // Currently applied blend state
- bool mForceSetBlendState;
- gl::BlendState mCurBlendState;
- gl::ColorF mCurBlendColor;
- unsigned int mCurSampleMask;
-
- // Currently applied rasterizer state
- bool mForceSetRasterState;
- gl::RasterizerState mCurRasterState;
-
- // Currently applied depth stencil state
- bool mForceSetDepthStencilState;
- gl::DepthStencilState mCurDepthStencilState;
- int mCurStencilRef;
- int mCurStencilBackRef;
-
- // Currently applied scissor rectangle
- bool mForceSetScissor;
- bool mScissorEnabled;
- gl::Rectangle mCurScissor;
-
- // Currently applied viewport
- bool mForceSetViewport;
- gl::Rectangle mCurViewport;
- float mCurNear;
- float mCurFar;
-
- // Currently applied primitive topology
- D3D11_PRIMITIVE_TOPOLOGY mCurrentPrimitiveTopology;
-
- // Currently applied index buffer
- ID3D11Buffer *mAppliedIB;
- DXGI_FORMAT mAppliedIBFormat;
- unsigned int mAppliedIBOffset;
-
- // Currently applied transform feedback buffers
- ID3D11Buffer *mAppliedTFBuffers[gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS]; // Tracks the current D3D buffers
- // in use for streamout
- GLintptr mAppliedTFOffsets[gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS]; // Tracks the current GL-specified
- // buffer offsets to transform feedback
- // buffers
- UINT mCurrentD3DOffsets[gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS]; // Tracks the D3D buffer offsets,
- // which may differ from GLs, due
- // to different append behavior
-
- // Currently applied shaders
- ID3D11VertexShader *mAppliedVertexShader;
- ID3D11GeometryShader *mAppliedGeometryShader;
- ID3D11GeometryShader *mCurPointGeometryShader;
- ID3D11PixelShader *mAppliedPixelShader;
-
- dx_VertexConstants mVertexConstants;
- dx_VertexConstants mAppliedVertexConstants;
- ID3D11Buffer *mDriverConstantBufferVS;
- ID3D11Buffer *mCurrentVertexConstantBuffer;
- unsigned int mCurrentConstantBufferVS[gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS];
-
- dx_PixelConstants mPixelConstants;
- dx_PixelConstants mAppliedPixelConstants;
- ID3D11Buffer *mDriverConstantBufferPS;
- ID3D11Buffer *mCurrentPixelConstantBuffer;
- unsigned int mCurrentConstantBufferPS[gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS];
-
- ID3D11Buffer *mCurrentGeometryConstantBuffer;
-
- // Vertex, index and input layouts
- VertexDataManager *mVertexDataManager;
- IndexDataManager *mIndexDataManager;
- InputLayoutCache mInputLayoutCache;
-
- StreamingIndexBufferInterface *mLineLoopIB;
- StreamingIndexBufferInterface *mTriangleFanIB;
-
- // Texture copy resources
- Blit11 *mBlit;
- PixelTransfer11 *mPixelTransfer;
-
- // Masked clear resources
- Clear11 *mClear;
-
- // Sync query
- ID3D11Query *mSyncQuery;
-
- ID3D11Device *mDevice;
- D3D_FEATURE_LEVEL mFeatureLevel;
- ID3D11DeviceContext *mDeviceContext;
- IDXGIAdapter *mDxgiAdapter;
- DXGI_ADAPTER_DESC mAdapterDescription;
- char mDescription[128];
- DXGIFactory *mDxgiFactory;
-};
-
-}
-#endif // LIBGLESV2_RENDERER_RENDERER11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.cpp
deleted file mode 100644
index 52f34887fb..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// ShaderExecutable11.cpp: Implements a D3D11-specific class to contain shader
-// executable implementation details.
-
-#include "libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-
-namespace rx
-{
-
-ShaderExecutable11::ShaderExecutable11(const void *function, size_t length, ID3D11PixelShader *executable)
- : ShaderExecutable(function, length)
-{
- mPixelExecutable = executable;
- mVertexExecutable = NULL;
- mGeometryExecutable = NULL;
- mStreamOutExecutable = NULL;
-}
-
-ShaderExecutable11::ShaderExecutable11(const void *function, size_t length, ID3D11VertexShader *executable, ID3D11GeometryShader *streamOut)
- : ShaderExecutable(function, length)
-{
- mVertexExecutable = executable;
- mPixelExecutable = NULL;
- mGeometryExecutable = NULL;
- mStreamOutExecutable = streamOut;
-}
-
-ShaderExecutable11::ShaderExecutable11(const void *function, size_t length, ID3D11GeometryShader *executable)
- : ShaderExecutable(function, length)
-{
- mGeometryExecutable = executable;
- mVertexExecutable = NULL;
- mPixelExecutable = NULL;
- mStreamOutExecutable = NULL;
-}
-
-ShaderExecutable11::~ShaderExecutable11()
-{
- SafeRelease(mVertexExecutable);
- SafeRelease(mPixelExecutable);
- SafeRelease(mGeometryExecutable);
- SafeRelease(mStreamOutExecutable);
-}
-
-ShaderExecutable11 *ShaderExecutable11::makeShaderExecutable11(ShaderExecutable *executable)
-{
- ASSERT(HAS_DYNAMIC_TYPE(ShaderExecutable11*, executable));
- return static_cast<ShaderExecutable11*>(executable);
-}
-
-ID3D11VertexShader *ShaderExecutable11::getVertexShader() const
-{
- return mVertexExecutable;
-}
-
-ID3D11PixelShader *ShaderExecutable11::getPixelShader() const
-{
- return mPixelExecutable;
-}
-
-ID3D11GeometryShader *ShaderExecutable11::getGeometryShader() const
-{
- return mGeometryExecutable;
-}
-
-ID3D11GeometryShader *ShaderExecutable11::getStreamOutShader() const
-{
- return mStreamOutExecutable;
-}
-
-UniformStorage11::UniformStorage11(Renderer11 *renderer, size_t initialSize)
- : UniformStorage(initialSize),
- mConstantBuffer(NULL)
-{
- ID3D11Device *d3d11Device = renderer->getDevice();
-
- if (initialSize > 0)
- {
- D3D11_BUFFER_DESC constantBufferDescription = {0};
- constantBufferDescription.ByteWidth = initialSize;
- constantBufferDescription.Usage = D3D11_USAGE_DYNAMIC;
- constantBufferDescription.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
- constantBufferDescription.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
- constantBufferDescription.MiscFlags = 0;
- constantBufferDescription.StructureByteStride = 0;
-
- HRESULT result = d3d11Device->CreateBuffer(&constantBufferDescription, NULL, &mConstantBuffer);
- UNUSED_ASSERTION_VARIABLE(result);
- ASSERT(SUCCEEDED(result));
- }
-}
-
-UniformStorage11::~UniformStorage11()
-{
- SafeRelease(mConstantBuffer);
-}
-
-const UniformStorage11 *UniformStorage11::makeUniformStorage11(const UniformStorage *uniformStorage)
-{
- ASSERT(HAS_DYNAMIC_TYPE(const UniformStorage11*, uniformStorage));
- return static_cast<const UniformStorage11*>(uniformStorage);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.h
deleted file mode 100644
index 74a1e03915..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.h
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// ShaderExecutable11.h: Defines a D3D11-specific class to contain shader
-// executable implementation details.
-
-#ifndef LIBGLESV2_RENDERER_SHADEREXECUTABLE11_H_
-#define LIBGLESV2_RENDERER_SHADEREXECUTABLE11_H_
-
-#include "libGLESv2/renderer/ShaderExecutable.h"
-
-namespace rx
-{
-class Renderer11;
-class UniformStorage11;
-
-class ShaderExecutable11 : public ShaderExecutable
-{
- public:
- ShaderExecutable11(const void *function, size_t length, ID3D11PixelShader *executable);
- ShaderExecutable11(const void *function, size_t length, ID3D11VertexShader *executable, ID3D11GeometryShader *streamOut);
- ShaderExecutable11(const void *function, size_t length, ID3D11GeometryShader *executable);
-
- virtual ~ShaderExecutable11();
-
- static ShaderExecutable11 *makeShaderExecutable11(ShaderExecutable *executable);
-
- ID3D11PixelShader *getPixelShader() const;
- ID3D11VertexShader *getVertexShader() const;
- ID3D11GeometryShader *getGeometryShader() const;
- ID3D11GeometryShader *getStreamOutShader() const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ShaderExecutable11);
-
- ID3D11PixelShader *mPixelExecutable;
- ID3D11VertexShader *mVertexExecutable;
- ID3D11GeometryShader *mGeometryExecutable;
- ID3D11GeometryShader *mStreamOutExecutable;
-};
-
-class UniformStorage11 : public UniformStorage
-{
- public:
- UniformStorage11(Renderer11 *renderer, size_t initialSize);
- virtual ~UniformStorage11();
-
- static const UniformStorage11 *makeUniformStorage11(const UniformStorage *uniformStorage);
-
- ID3D11Buffer *getConstantBuffer() const { return mConstantBuffer; }
-
- private:
- ID3D11Buffer *mConstantBuffer;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_SHADEREXECUTABLE11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.cpp
deleted file mode 100644
index 52c8a81633..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.cpp
+++ /dev/null
@@ -1,675 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// SwapChain11.cpp: Implements a back-end specific class for the D3D11 swap chain.
-
-#include "libGLESv2/renderer/d3d/d3d11/SwapChain11.h"
-#include "libGLESv2/renderer/d3d/d3d11/renderer11_utils.h"
-#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-
-// Precompiled shaders
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough2dvs.h"
-#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2dps.h"
-
-#include "common/features.h"
-#include "common/NativeWindow.h"
-
-namespace rx
-{
-
-SwapChain11::SwapChain11(Renderer11 *renderer, NativeWindow nativeWindow, HANDLE shareHandle,
- GLenum backBufferFormat, GLenum depthBufferFormat)
- : mRenderer(renderer),
- SwapChain(nativeWindow, shareHandle, backBufferFormat, depthBufferFormat)
-{
- mSwapChain = NULL;
- mBackBufferTexture = NULL;
- mBackBufferRTView = NULL;
- mOffscreenTexture = NULL;
- mOffscreenRTView = NULL;
- mOffscreenSRView = NULL;
- mDepthStencilTexture = NULL;
- mDepthStencilDSView = NULL;
- mDepthStencilSRView = NULL;
- mQuadVB = NULL;
- mPassThroughSampler = NULL;
- mPassThroughIL = NULL;
- mPassThroughVS = NULL;
- mPassThroughPS = NULL;
- mWidth = -1;
- mHeight = -1;
- mRotateL = false;
- mRotateR = false;
- mSwapInterval = 0;
- mAppCreatedShareHandle = mShareHandle != NULL;
- mPassThroughResourcesInit = false;
-}
-
-SwapChain11::~SwapChain11()
-{
- release();
-}
-
-void SwapChain11::release()
-{
- SafeRelease(mSwapChain);
- SafeRelease(mBackBufferTexture);
- SafeRelease(mBackBufferRTView);
- SafeRelease(mOffscreenTexture);
- SafeRelease(mOffscreenRTView);
- SafeRelease(mOffscreenSRView);
- SafeRelease(mDepthStencilTexture);
- SafeRelease(mDepthStencilDSView);
- SafeRelease(mDepthStencilSRView);
- SafeRelease(mQuadVB);
- SafeRelease(mPassThroughSampler);
- SafeRelease(mPassThroughIL);
- SafeRelease(mPassThroughVS);
- SafeRelease(mPassThroughPS);
-
- if (!mAppCreatedShareHandle)
- {
- mShareHandle = NULL;
- }
-}
-
-void SwapChain11::releaseOffscreenTexture()
-{
- SafeRelease(mOffscreenTexture);
- SafeRelease(mOffscreenRTView);
- SafeRelease(mOffscreenSRView);
- SafeRelease(mDepthStencilTexture);
- SafeRelease(mDepthStencilDSView);
- SafeRelease(mDepthStencilSRView);
-}
-
-EGLint SwapChain11::resetOffscreenTexture(int backbufferWidth, int backbufferHeight)
-{
- ID3D11Device *device = mRenderer->getDevice();
-
- ASSERT(device != NULL);
-
- // D3D11 does not allow zero size textures
- ASSERT(backbufferWidth != 0);
- ASSERT(backbufferHeight != 0);
-
- // Preserve the render target content
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
- ID3D11Texture2D *previousOffscreenTexture = mOffscreenTexture;
- if (previousOffscreenTexture)
- {
- previousOffscreenTexture->AddRef();
- }
- const int previousWidth = mWidth;
- const int previousHeight = mHeight;
-#endif
-
- releaseOffscreenTexture();
-
- const d3d11::TextureFormat &backbufferFormatInfo = d3d11::GetTextureFormatInfo(mBackBufferFormat);
-
- // If the app passed in a share handle, open the resource
- // See EGL_ANGLE_d3d_share_handle_client_buffer
- if (mAppCreatedShareHandle)
- {
- ID3D11Resource *tempResource11;
- HRESULT result = device->OpenSharedResource(mShareHandle, __uuidof(ID3D11Resource), (void**)&tempResource11);
-
- if (FAILED(result))
- {
- ERR("Failed to open the swap chain pbuffer share handle: %08lX", result);
- release();
- return EGL_BAD_PARAMETER;
- }
-
- result = tempResource11->QueryInterface(__uuidof(ID3D11Texture2D), (void**)&mOffscreenTexture);
- SafeRelease(tempResource11);
-
- if (FAILED(result))
- {
- ERR("Failed to query texture2d interface in pbuffer share handle: %08lX", result);
- release();
- return EGL_BAD_PARAMETER;
- }
-
- // Validate offscreen texture parameters
- D3D11_TEXTURE2D_DESC offscreenTextureDesc = {0};
- mOffscreenTexture->GetDesc(&offscreenTextureDesc);
-
- if (offscreenTextureDesc.Width != UINT(abs(backbufferWidth)) ||
- offscreenTextureDesc.Height != UINT(abs(backbufferHeight)) ||
- offscreenTextureDesc.Format != backbufferFormatInfo.texFormat ||
- offscreenTextureDesc.MipLevels != 1 ||
- offscreenTextureDesc.ArraySize != 1)
- {
- ERR("Invalid texture parameters in the shared offscreen texture pbuffer");
- release();
- return EGL_BAD_PARAMETER;
- }
- }
- else
- {
- const bool useSharedResource = !mNativeWindow.getNativeWindow() && mRenderer->getShareHandleSupport();
-
- D3D11_TEXTURE2D_DESC offscreenTextureDesc = {0};
- offscreenTextureDesc.Width = abs(backbufferWidth);
- offscreenTextureDesc.Height = abs(backbufferHeight);
- offscreenTextureDesc.Format = backbufferFormatInfo.texFormat;
- offscreenTextureDesc.MipLevels = 1;
- offscreenTextureDesc.ArraySize = 1;
- offscreenTextureDesc.SampleDesc.Count = 1;
- offscreenTextureDesc.SampleDesc.Quality = 0;
- offscreenTextureDesc.Usage = D3D11_USAGE_DEFAULT;
- offscreenTextureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
- offscreenTextureDesc.CPUAccessFlags = 0;
- offscreenTextureDesc.MiscFlags = useSharedResource ? D3D11_RESOURCE_MISC_SHARED : 0;
-
- HRESULT result = device->CreateTexture2D(&offscreenTextureDesc, NULL, &mOffscreenTexture);
-
- if (FAILED(result))
- {
- ERR("Could not create offscreen texture: %08lX", result);
- release();
-
- if (d3d11::isDeviceLostError(result))
- {
- return EGL_CONTEXT_LOST;
- }
- else
- {
- return EGL_BAD_ALLOC;
- }
- }
-
- d3d11::SetDebugName(mOffscreenTexture, "Offscreen back buffer texture");
-
- // EGL_ANGLE_surface_d3d_texture_2d_share_handle requires that we store a share handle for the client
- if (useSharedResource)
- {
- IDXGIResource *offscreenTextureResource = NULL;
- result = mOffscreenTexture->QueryInterface(__uuidof(IDXGIResource), (void**)&offscreenTextureResource);
-
- // Fall back to no share handle on failure
- if (FAILED(result))
- {
- ERR("Could not query offscreen texture resource: %08lX", result);
- }
- else
- {
- result = offscreenTextureResource->GetSharedHandle(&mShareHandle);
- SafeRelease(offscreenTextureResource);
-
- if (FAILED(result))
- {
- mShareHandle = NULL;
- ERR("Could not get offscreen texture shared handle: %08lX", result);
- }
- }
- }
- }
-
-
- D3D11_RENDER_TARGET_VIEW_DESC offscreenRTVDesc;
- offscreenRTVDesc.Format = backbufferFormatInfo.rtvFormat;
- offscreenRTVDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
- offscreenRTVDesc.Texture2D.MipSlice = 0;
-
- HRESULT result = device->CreateRenderTargetView(mOffscreenTexture, &offscreenRTVDesc, &mOffscreenRTView);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mOffscreenRTView, "Offscreen back buffer render target");
-
- D3D11_SHADER_RESOURCE_VIEW_DESC offscreenSRVDesc;
- offscreenSRVDesc.Format = backbufferFormatInfo.srvFormat;
- offscreenSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
- offscreenSRVDesc.Texture2D.MostDetailedMip = 0;
- offscreenSRVDesc.Texture2D.MipLevels = -1;
-
- result = device->CreateShaderResourceView(mOffscreenTexture, &offscreenSRVDesc, &mOffscreenSRView);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mOffscreenSRView, "Offscreen back buffer shader resource");
-
- const d3d11::TextureFormat &depthBufferFormatInfo = d3d11::GetTextureFormatInfo(mDepthBufferFormat);
-
- if (mDepthBufferFormat != GL_NONE)
- {
- D3D11_TEXTURE2D_DESC depthStencilTextureDesc;
- depthStencilTextureDesc.Width = abs(backbufferWidth);
- depthStencilTextureDesc.Height = abs(backbufferHeight);
- depthStencilTextureDesc.Format = depthBufferFormatInfo.texFormat;
- depthStencilTextureDesc.MipLevels = 1;
- depthStencilTextureDesc.ArraySize = 1;
- depthStencilTextureDesc.SampleDesc.Count = 1;
- depthStencilTextureDesc.SampleDesc.Quality = 0;
- depthStencilTextureDesc.Usage = D3D11_USAGE_DEFAULT;
- depthStencilTextureDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
- depthStencilTextureDesc.CPUAccessFlags = 0;
- depthStencilTextureDesc.MiscFlags = 0;
-
- result = device->CreateTexture2D(&depthStencilTextureDesc, NULL, &mDepthStencilTexture);
- if (FAILED(result))
- {
- ERR("Could not create depthstencil surface for new swap chain: 0x%08X", result);
- release();
-
- if (d3d11::isDeviceLostError(result))
- {
- return EGL_CONTEXT_LOST;
- }
- else
- {
- return EGL_BAD_ALLOC;
- }
- }
- d3d11::SetDebugName(mDepthStencilTexture, "Offscreen depth stencil texture");
-
- D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilDesc;
- depthStencilDesc.Format = depthBufferFormatInfo.dsvFormat;
- depthStencilDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
- depthStencilDesc.Flags = 0;
- depthStencilDesc.Texture2D.MipSlice = 0;
-
- result = device->CreateDepthStencilView(mDepthStencilTexture, &depthStencilDesc, &mDepthStencilDSView);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mDepthStencilDSView, "Offscreen depth stencil view");
-
- D3D11_SHADER_RESOURCE_VIEW_DESC depthStencilSRVDesc;
- depthStencilSRVDesc.Format = depthBufferFormatInfo.srvFormat;
- depthStencilSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
- depthStencilSRVDesc.Texture2D.MostDetailedMip = 0;
- depthStencilSRVDesc.Texture2D.MipLevels = -1;
-
- result = device->CreateShaderResourceView(mDepthStencilTexture, &depthStencilSRVDesc, &mDepthStencilSRView);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mDepthStencilSRView, "Offscreen depth stencil shader resource");
- }
-
- mWidth = backbufferWidth;
- mHeight = backbufferHeight;
-
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
- if (previousOffscreenTexture != NULL)
- {
- D3D11_BOX sourceBox = {0};
- sourceBox.left = 0;
- sourceBox.right = std::min(previousWidth, mWidth);
- sourceBox.top = std::max(previousHeight - mHeight, 0);
- sourceBox.bottom = previousHeight;
- sourceBox.front = 0;
- sourceBox.back = 1;
-
- ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
- const int yoffset = std::max(mHeight - previousHeight, 0);
- deviceContext->CopySubresourceRegion(mOffscreenTexture, 0, 0, yoffset, 0, previousOffscreenTexture, 0, &sourceBox);
-
- SafeRelease(previousOffscreenTexture);
-
- if (mSwapChain)
- {
- swapRect(0, 0, mWidth, mHeight);
- }
- }
-#endif
-
- return EGL_SUCCESS;
-}
-
-EGLint SwapChain11::resize(EGLint backbufferWidth, EGLint backbufferHeight)
-{
- ID3D11Device *device = mRenderer->getDevice();
-
- if (device == NULL)
- {
- return EGL_BAD_ACCESS;
- }
-
- // Windows Phone works around the rotation limitation by using negative values for the swap chain size
-#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
- mRotateL = backbufferWidth < 0; // Landscape/InvertedLandscape
- mRotateR = backbufferHeight < 0; // InvertedPortrait/InvertedLandscape
- backbufferWidth = abs(backbufferWidth);
- backbufferHeight = abs(backbufferHeight);
-#endif
-
- // EGL allows creating a surface with 0x0 dimension, however, DXGI does not like 0x0 swapchains
- if (backbufferWidth == 0 || backbufferHeight == 0)
- {
- return EGL_SUCCESS;
- }
-
- // Can only call resize if we have already created our swap buffer and resources
- ASSERT(mSwapChain && mBackBufferTexture && mBackBufferRTView);
-
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE) || (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) // The swap chain is not directly resized on Windows Phone
- SafeRelease(mBackBufferTexture);
- SafeRelease(mBackBufferRTView);
-
- // Resize swap chain
- DXGI_SWAP_CHAIN_DESC desc;
- mSwapChain->GetDesc(&desc);
- const d3d11::TextureFormat &backbufferFormatInfo = d3d11::GetTextureFormatInfo(mBackBufferFormat);
- HRESULT result = mSwapChain->ResizeBuffers(desc.BufferCount, backbufferWidth, backbufferHeight, backbufferFormatInfo.texFormat, 0);
-
- if (FAILED(result))
- {
- ERR("Error resizing swap chain buffers: 0x%08X", result);
- release();
-
- if (d3d11::isDeviceLostError(result))
- {
- return EGL_CONTEXT_LOST;
- }
- else
- {
- return EGL_BAD_ALLOC;
- }
- }
-
- result = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&mBackBufferTexture);
- ASSERT(SUCCEEDED(result));
- if (SUCCEEDED(result))
- {
- d3d11::SetDebugName(mBackBufferTexture, "Back buffer texture");
- }
-
- result = device->CreateRenderTargetView(mBackBufferTexture, NULL, &mBackBufferRTView);
- ASSERT(SUCCEEDED(result));
- if (SUCCEEDED(result))
- {
- d3d11::SetDebugName(mBackBufferRTView, "Back buffer render target");
- }
-#endif
-
- return resetOffscreenTexture(backbufferWidth, backbufferHeight);
-}
-
-EGLint SwapChain11::reset(int backbufferWidth, int backbufferHeight, EGLint swapInterval)
-{
- ID3D11Device *device = mRenderer->getDevice();
-
- if (device == NULL)
- {
- return EGL_BAD_ACCESS;
- }
-
- // Release specific resources to free up memory for the new render target, while the
- // old render target still exists for the purpose of preserving its contents.
- SafeRelease(mSwapChain);
- SafeRelease(mBackBufferTexture);
- SafeRelease(mBackBufferRTView);
-
- mSwapInterval = static_cast<unsigned int>(swapInterval);
- if (mSwapInterval > 4)
- {
- // IDXGISwapChain::Present documentation states that valid sync intervals are in the [0,4] range
- return EGL_BAD_PARAMETER;
- }
-
- // EGL allows creating a surface with 0x0 dimension, however, DXGI does not like 0x0 swapchains
- if (backbufferWidth < 1 || backbufferHeight < 1)
- {
- releaseOffscreenTexture();
- return EGL_SUCCESS;
- }
-
- if (mNativeWindow.getNativeWindow())
- {
- const d3d11::TextureFormat &backbufferFormatInfo = d3d11::GetTextureFormatInfo(mBackBufferFormat);
-
- HRESULT result = mNativeWindow.createSwapChain(device, mRenderer->getDxgiFactory(),
- backbufferFormatInfo.texFormat,
- backbufferWidth, backbufferHeight, &mSwapChain);
-
- if (FAILED(result))
- {
- ERR("Could not create additional swap chains or offscreen surfaces: %08lX", result);
- release();
-
- if (d3d11::isDeviceLostError(result))
- {
- return EGL_CONTEXT_LOST;
- }
- else
- {
- return EGL_BAD_ALLOC;
- }
- }
-
- result = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&mBackBufferTexture);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mBackBufferTexture, "Back buffer texture");
-
- result = device->CreateRenderTargetView(mBackBufferTexture, NULL, &mBackBufferRTView);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mBackBufferRTView, "Back buffer render target");
- }
-
- // If we are resizing the swap chain, we don't wish to recreate all the static resources
- if (!mPassThroughResourcesInit)
- {
- mPassThroughResourcesInit = true;
- initPassThroughResources();
- }
-
- return resetOffscreenTexture(backbufferWidth, backbufferHeight);
-}
-
-void SwapChain11::initPassThroughResources()
-{
- ID3D11Device *device = mRenderer->getDevice();
-
- ASSERT(device != NULL);
-
- // Make sure our resources are all not allocated, when we create
- ASSERT(mQuadVB == NULL && mPassThroughSampler == NULL);
- ASSERT(mPassThroughIL == NULL && mPassThroughVS == NULL && mPassThroughPS == NULL);
-
- D3D11_BUFFER_DESC vbDesc;
- vbDesc.ByteWidth = sizeof(d3d11::PositionTexCoordVertex) * 4;
- vbDesc.Usage = D3D11_USAGE_DYNAMIC;
- vbDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
- vbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
- vbDesc.MiscFlags = 0;
- vbDesc.StructureByteStride = 0;
-
- HRESULT result = device->CreateBuffer(&vbDesc, NULL, &mQuadVB);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mQuadVB, "Swap chain quad vertex buffer");
-
- D3D11_SAMPLER_DESC samplerDesc;
- samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
- samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
- samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
- samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
- samplerDesc.MipLODBias = 0.0f;
- samplerDesc.MaxAnisotropy = 0;
- samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
- samplerDesc.BorderColor[0] = 0.0f;
- samplerDesc.BorderColor[1] = 0.0f;
- samplerDesc.BorderColor[2] = 0.0f;
- samplerDesc.BorderColor[3] = 0.0f;
- samplerDesc.MinLOD = 0;
- samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
-
- result = device->CreateSamplerState(&samplerDesc, &mPassThroughSampler);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mPassThroughSampler, "Swap chain pass through sampler");
-
- D3D11_INPUT_ELEMENT_DESC quadLayout[] =
- {
- { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
- { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 },
- };
-
- result = device->CreateInputLayout(quadLayout, 2, g_VS_Passthrough2D, sizeof(g_VS_Passthrough2D), &mPassThroughIL);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mPassThroughIL, "Swap chain pass through layout");
-
- result = device->CreateVertexShader(g_VS_Passthrough2D, sizeof(g_VS_Passthrough2D), NULL, &mPassThroughVS);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mPassThroughVS, "Swap chain pass through vertex shader");
-
- result = device->CreatePixelShader(g_PS_PassthroughRGBA2D, sizeof(g_PS_PassthroughRGBA2D), NULL, &mPassThroughPS);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mPassThroughPS, "Swap chain pass through pixel shader");
-}
-
-// parameters should be validated/clamped by caller
-EGLint SwapChain11::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
-{
- if (!mSwapChain)
- {
- return EGL_SUCCESS;
- }
-
- ID3D11Device *device = mRenderer->getDevice();
- ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
-
- // Create a quad in homogeneous coordinates
- float x1 = (x / float(mWidth)) * 2.0f - 1.0f;
- float y1 = (y / float(mHeight)) * 2.0f - 1.0f;
- float x2 = ((x + width) / float(mWidth)) * 2.0f - 1.0f;
- float y2 = ((y + height) / float(mHeight)) * 2.0f - 1.0f;
-
- float u1 = x / float(mWidth);
- float v1 = y / float(mHeight);
- float u2 = (x + width) / float(mWidth);
- float v2 = (y + height) / float(mHeight);
-
- const bool rotateL = mRotateL;
- const bool rotateR = mRotateR;
-
- // Set vertices
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- HRESULT result = deviceContext->Map(mQuadVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
- if (FAILED(result))
- {
- return EGL_BAD_ACCESS;
- }
-
- d3d11::PositionTexCoordVertex *vertices = static_cast<d3d11::PositionTexCoordVertex*>(mappedResource.pData);
-
- d3d11::SetPositionTexCoordVertex(&vertices[0], x1, y1, rotateL ? u2 : u1, rotateR ? v2 : v1);
- d3d11::SetPositionTexCoordVertex(&vertices[1], x1, y2, rotateR ? u2 : u1, rotateL ? v1 : v2);
- d3d11::SetPositionTexCoordVertex(&vertices[2], x2, y1, rotateR ? u1 : u2, rotateL ? v2 : v1);
- d3d11::SetPositionTexCoordVertex(&vertices[3], x2, y2, rotateL ? u1 : u2, rotateR ? v1 : v2);
-
- deviceContext->Unmap(mQuadVB, 0);
-
- static UINT stride = sizeof(d3d11::PositionTexCoordVertex);
- static UINT startIdx = 0;
- deviceContext->IASetVertexBuffers(0, 1, &mQuadVB, &stride, &startIdx);
-
- // Apply state
- deviceContext->OMSetDepthStencilState(NULL, 0xFFFFFFFF);
-
- static const float blendFactor[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
- deviceContext->OMSetBlendState(NULL, blendFactor, 0xFFFFFFF);
-
- deviceContext->RSSetState(NULL);
-
- // Apply shaders
- deviceContext->IASetInputLayout(mPassThroughIL);
- deviceContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
- deviceContext->VSSetShader(mPassThroughVS, NULL, 0);
- deviceContext->PSSetShader(mPassThroughPS, NULL, 0);
- deviceContext->GSSetShader(NULL, NULL, 0);
-
- // Apply render targets
- mRenderer->setOneTimeRenderTarget(mBackBufferRTView);
-
- // Set the viewport
- D3D11_VIEWPORT viewport;
- viewport.TopLeftX = 0.0f;
- viewport.TopLeftY = 0.0f;
- const bool invertViewport = (mRotateL || mRotateR) && !(mRotateL && mRotateR);
- viewport.Width = FLOAT(invertViewport ? mHeight : mWidth);
- viewport.Height = FLOAT(invertViewport ? mWidth : mHeight);
- viewport.MinDepth = 0.0f;
- viewport.MaxDepth = 1.0f;
- deviceContext->RSSetViewports(1, &viewport);
-
- // Apply textures
- mRenderer->setShaderResource(gl::SAMPLER_PIXEL, 0, mOffscreenSRView);
- deviceContext->PSSetSamplers(0, 1, &mPassThroughSampler);
-
- // Draw
- deviceContext->Draw(4, 0);
-
-#if ANGLE_VSYNC == ANGLE_DISABLED
- result = mSwapChain->Present(0, 0);
-#else
- result = mSwapChain->Present(mSwapInterval, 0);
-#endif
-
- if (result == DXGI_ERROR_DEVICE_REMOVED)
- {
- HRESULT removedReason = device->GetDeviceRemovedReason();
- UNUSED_TRACE_VARIABLE(removedReason);
- ERR("Present failed: the D3D11 device was removed: 0x%08X", removedReason);
- return EGL_CONTEXT_LOST;
- }
- else if (result == DXGI_ERROR_DEVICE_RESET)
- {
- ERR("Present failed: the D3D11 device was reset from a bad command.");
- return EGL_CONTEXT_LOST;
- }
- else if (FAILED(result))
- {
- ERR("Present failed with error code 0x%08X", result);
- }
-
- // Unbind
- mRenderer->setShaderResource(gl::SAMPLER_PIXEL, 0, NULL);
-
- mRenderer->unapplyRenderTargets();
- mRenderer->markAllStateDirty();
-
- return EGL_SUCCESS;
-}
-
-ID3D11Texture2D *SwapChain11::getOffscreenTexture()
-{
- return mOffscreenTexture;
-}
-
-ID3D11RenderTargetView *SwapChain11::getRenderTarget()
-{
- return mOffscreenRTView;
-}
-
-ID3D11ShaderResourceView *SwapChain11::getRenderTargetShaderResource()
-{
- return mOffscreenSRView;
-}
-
-ID3D11DepthStencilView *SwapChain11::getDepthStencil()
-{
- return mDepthStencilDSView;
-}
-
-ID3D11ShaderResourceView * SwapChain11::getDepthStencilShaderResource()
-{
- return mDepthStencilSRView;
-}
-
-ID3D11Texture2D *SwapChain11::getDepthStencilTexture()
-{
- return mDepthStencilTexture;
-}
-
-SwapChain11 *SwapChain11::makeSwapChain11(SwapChain *swapChain)
-{
- ASSERT(HAS_DYNAMIC_TYPE(SwapChain11*, swapChain));
- return static_cast<SwapChain11*>(swapChain);
-}
-
-void SwapChain11::recreate()
-{
- // possibly should use this method instead of reset
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.h
deleted file mode 100644
index 77509edcd3..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.h
+++ /dev/null
@@ -1,82 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// SwapChain11.h: Defines a back-end specific class for the D3D11 swap chain.
-
-#ifndef LIBGLESV2_RENDERER_SWAPCHAIN11_H_
-#define LIBGLESV2_RENDERER_SWAPCHAIN11_H_
-
-#include "common/angleutils.h"
-#include "libGLESv2/renderer/SwapChain.h"
-
-namespace rx
-{
-class Renderer11;
-
-class SwapChain11 : public SwapChain
-{
- public:
- SwapChain11(Renderer11 *renderer, NativeWindow nativeWindow, HANDLE shareHandle,
- GLenum backBufferFormat, GLenum depthBufferFormat);
- virtual ~SwapChain11();
-
- EGLint resize(EGLint backbufferWidth, EGLint backbufferHeight);
- virtual EGLint reset(EGLint backbufferWidth, EGLint backbufferHeight, EGLint swapInterval);
- virtual EGLint swapRect(EGLint x, EGLint y, EGLint width, EGLint height);
- virtual void recreate();
-
- virtual ID3D11Texture2D *getOffscreenTexture();
- virtual ID3D11RenderTargetView *getRenderTarget();
- virtual ID3D11ShaderResourceView *getRenderTargetShaderResource();
-
- virtual ID3D11Texture2D *getDepthStencilTexture();
- virtual ID3D11DepthStencilView *getDepthStencil();
- virtual ID3D11ShaderResourceView *getDepthStencilShaderResource();
-
- EGLint getWidth() const { return mWidth; }
- EGLint getHeight() const { return mHeight; }
-
- static SwapChain11 *makeSwapChain11(SwapChain *swapChain);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(SwapChain11);
-
- void release();
- void initPassThroughResources();
- void releaseOffscreenTexture();
- EGLint resetOffscreenTexture(int backbufferWidth, int backbufferHeight);
-
- Renderer11 *mRenderer;
- EGLint mHeight;
- EGLint mWidth;
- bool mRotateL;
- bool mRotateR;
- bool mAppCreatedShareHandle;
- unsigned int mSwapInterval;
- bool mPassThroughResourcesInit;
-
- DXGISwapChain *mSwapChain;
-
- ID3D11Texture2D *mBackBufferTexture;
- ID3D11RenderTargetView *mBackBufferRTView;
-
- ID3D11Texture2D *mOffscreenTexture;
- ID3D11RenderTargetView *mOffscreenRTView;
- ID3D11ShaderResourceView *mOffscreenSRView;
-
- ID3D11Texture2D *mDepthStencilTexture;
- ID3D11DepthStencilView *mDepthStencilDSView;
- ID3D11ShaderResourceView *mDepthStencilSRView;
-
- ID3D11Buffer *mQuadVB;
- ID3D11SamplerState *mPassThroughSampler;
- ID3D11InputLayout *mPassThroughIL;
- ID3D11VertexShader *mPassThroughVS;
- ID3D11PixelShader *mPassThroughPS;
-};
-
-}
-#endif // LIBGLESV2_RENDERER_SWAPCHAIN11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.cpp
deleted file mode 100644
index 74af27e8b3..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.cpp
+++ /dev/null
@@ -1,2112 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// TextureStorage11.cpp: Implements the abstract rx::TextureStorage11 class and its concrete derived
-// classes TextureStorage11_2D and TextureStorage11_Cube, which act as the interface to the D3D11 texture.
-
-#include "libGLESv2/renderer/d3d/d3d11/TextureStorage11.h"
-
-#include <tuple>
-
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/RenderTarget11.h"
-#include "libGLESv2/renderer/d3d/d3d11/SwapChain11.h"
-#include "libGLESv2/renderer/d3d/d3d11/renderer11_utils.h"
-#include "libGLESv2/renderer/d3d/d3d11/Blit11.h"
-#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Image11.h"
-#include "libGLESv2/renderer/d3d/MemoryBuffer.h"
-#include "libGLESv2/renderer/d3d/TextureD3D.h"
-#include "libGLESv2/main.h"
-#include "libGLESv2/ImageIndex.h"
-
-#include "common/utilities.h"
-
-namespace rx
-{
-
-TextureStorage11::SwizzleCacheValue::SwizzleCacheValue()
- : swizzleRed(GL_NONE), swizzleGreen(GL_NONE), swizzleBlue(GL_NONE), swizzleAlpha(GL_NONE)
-{
-}
-
-TextureStorage11::SwizzleCacheValue::SwizzleCacheValue(GLenum red, GLenum green, GLenum blue, GLenum alpha)
- : swizzleRed(red), swizzleGreen(green), swizzleBlue(blue), swizzleAlpha(alpha)
-{
-}
-
-bool TextureStorage11::SwizzleCacheValue::operator==(const SwizzleCacheValue &other) const
-{
- return swizzleRed == other.swizzleRed &&
- swizzleGreen == other.swizzleGreen &&
- swizzleBlue == other.swizzleBlue &&
- swizzleAlpha == other.swizzleAlpha;
-}
-
-bool TextureStorage11::SwizzleCacheValue::operator!=(const SwizzleCacheValue &other) const
-{
- return !(*this == other);
-}
-
-TextureStorage11::SRVKey::SRVKey(int baseLevel, int mipLevels, bool swizzle)
- : baseLevel(baseLevel), mipLevels(mipLevels), swizzle(swizzle)
-{
-}
-
-bool TextureStorage11::SRVKey::operator<(const SRVKey &rhs) const
-{
- return std::tie(baseLevel, mipLevels, swizzle) < std::tie(rhs.baseLevel, rhs.mipLevels, rhs.swizzle);
-}
-
-TextureStorage11::TextureStorage11(Renderer11 *renderer, UINT bindFlags)
- : mBindFlags(bindFlags),
- mTopLevel(0),
- mMipLevels(0),
- mInternalFormat(GL_NONE),
- mTextureFormat(DXGI_FORMAT_UNKNOWN),
- mShaderResourceFormat(DXGI_FORMAT_UNKNOWN),
- mRenderTargetFormat(DXGI_FORMAT_UNKNOWN),
- mDepthStencilFormat(DXGI_FORMAT_UNKNOWN),
- mTextureWidth(0),
- mTextureHeight(0),
- mTextureDepth(0)
-{
- mRenderer = Renderer11::makeRenderer11(renderer);
-
- for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
- {
- mLevelSRVs[i] = NULL;
- }
-}
-
-TextureStorage11::~TextureStorage11()
-{
- for (unsigned int level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
- {
- SafeRelease(mLevelSRVs[level]);
- }
-
- for (SRVCache::iterator i = mSrvCache.begin(); i != mSrvCache.end(); i++)
- {
- SafeRelease(i->second);
- }
- mSrvCache.clear();
-}
-
-TextureStorage11 *TextureStorage11::makeTextureStorage11(TextureStorage *storage)
-{
- ASSERT(HAS_DYNAMIC_TYPE(TextureStorage11*, storage));
- return static_cast<TextureStorage11*>(storage);
-}
-
-DWORD TextureStorage11::GetTextureBindFlags(GLenum internalFormat, bool renderTarget)
-{
- UINT bindFlags = 0;
-
- const d3d11::TextureFormat &formatInfo = d3d11::GetTextureFormatInfo(internalFormat);
- if (formatInfo.srvFormat != DXGI_FORMAT_UNKNOWN)
- {
- bindFlags |= D3D11_BIND_SHADER_RESOURCE;
- }
- if (formatInfo.dsvFormat != DXGI_FORMAT_UNKNOWN)
- {
- bindFlags |= D3D11_BIND_DEPTH_STENCIL;
- }
- if (formatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN && renderTarget)
- {
- bindFlags |= D3D11_BIND_RENDER_TARGET;
- }
-
- return bindFlags;
-}
-
-UINT TextureStorage11::getBindFlags() const
-{
- return mBindFlags;
-}
-
-int TextureStorage11::getTopLevel() const
-{
- return mTopLevel;
-}
-
-bool TextureStorage11::isRenderTarget() const
-{
- return (mBindFlags & (D3D11_BIND_RENDER_TARGET | D3D11_BIND_DEPTH_STENCIL)) != 0;
-}
-
-bool TextureStorage11::isManaged() const
-{
- return false;
-}
-
-int TextureStorage11::getLevelCount() const
-{
- return mMipLevels - mTopLevel;
-}
-
-int TextureStorage11::getLevelWidth(int mipLevel) const
-{
- return std::max(static_cast<int>(mTextureWidth) >> mipLevel, 1);
-}
-
-int TextureStorage11::getLevelHeight(int mipLevel) const
-{
- return std::max(static_cast<int>(mTextureHeight) >> mipLevel, 1);
-}
-
-int TextureStorage11::getLevelDepth(int mipLevel) const
-{
- return std::max(static_cast<int>(mTextureDepth) >> mipLevel, 1);
-}
-
-UINT TextureStorage11::getSubresourceIndex(const gl::ImageIndex &index) const
-{
- UINT mipSlice = static_cast<UINT>(index.mipIndex + mTopLevel);
- UINT arraySlice = static_cast<UINT>(index.hasLayer() ? index.layerIndex : 0);
- UINT subresource = D3D11CalcSubresource(mipSlice, arraySlice, mMipLevels);
- ASSERT(subresource != std::numeric_limits<UINT>::max());
- return subresource;
-}
-
-gl::Error TextureStorage11::getSRV(const gl::SamplerState &samplerState, ID3D11ShaderResourceView **outSRV)
-{
- bool swizzleRequired = samplerState.swizzleRequired();
- bool mipmapping = gl::IsMipmapFiltered(samplerState);
- unsigned int mipLevels = mipmapping ? (samplerState.maxLevel - samplerState.baseLevel) : 1;
-
- // Make sure there's 'mipLevels' mipmap levels below the base level (offset by the top level, which corresponds to GL level 0)
- mipLevels = std::min(mipLevels, mMipLevels - mTopLevel - samplerState.baseLevel);
-
- if (swizzleRequired)
- {
- verifySwizzleExists(samplerState.swizzleRed, samplerState.swizzleGreen, samplerState.swizzleBlue, samplerState.swizzleAlpha);
- }
-
- SRVKey key(samplerState.baseLevel, mipLevels, swizzleRequired);
- SRVCache::const_iterator iter = mSrvCache.find(key);
- if (iter != mSrvCache.end())
- {
- *outSRV = iter->second;
- }
- else
- {
- ID3D11Resource *texture = NULL;
- if (swizzleRequired)
- {
- gl::Error error = getSwizzleTexture(&texture);
- if (error.isError())
- {
- return error;
- }
- }
- else
- {
- gl::Error error = getResource(&texture);
- if (error.isError())
- {
- return error;
- }
- }
-
- ID3D11ShaderResourceView *srv = NULL;
- DXGI_FORMAT format = (swizzleRequired ? mSwizzleShaderResourceFormat : mShaderResourceFormat);
- gl::Error error = createSRV(samplerState.baseLevel, mipLevels, format, texture, &srv);
- if (error.isError())
- {
- return error;
- }
-
- mSrvCache.insert(std::make_pair(key, srv));
- *outSRV = srv;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11::getSRVLevel(int mipLevel, ID3D11ShaderResourceView **outSRV)
-{
- ASSERT(mipLevel >= 0 && mipLevel < getLevelCount());
-
- if (!mLevelSRVs[mipLevel])
- {
- ID3D11Resource *resource = NULL;
- gl::Error error = getResource(&resource);
- if (error.isError())
- {
- return error;
- }
-
- error = createSRV(mipLevel, 1, mShaderResourceFormat, resource, &mLevelSRVs[mipLevel]);
- if (error.isError())
- {
- return error;
- }
- }
-
- *outSRV = mLevelSRVs[mipLevel];
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11::generateSwizzles(GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha)
-{
- SwizzleCacheValue swizzleTarget(swizzleRed, swizzleGreen, swizzleBlue, swizzleAlpha);
- for (int level = 0; level < getLevelCount(); level++)
- {
- // Check if the swizzle for this level is out of date
- if (mSwizzleCache[level] != swizzleTarget)
- {
- // Need to re-render the swizzle for this level
- ID3D11ShaderResourceView *sourceSRV = NULL;
- gl::Error error = getSRVLevel(level, &sourceSRV);
- if (error.isError())
- {
- return error;
- }
-
- ID3D11RenderTargetView *destRTV = NULL;
- error = getSwizzleRenderTarget(level, &destRTV);
- if (error.isError())
- {
- return error;
- }
-
- gl::Extents size(getLevelWidth(level), getLevelHeight(level), getLevelDepth(level));
-
- Blit11 *blitter = mRenderer->getBlitter();
-
- error = blitter->swizzleTexture(sourceSRV, destRTV, size, swizzleRed, swizzleGreen, swizzleBlue, swizzleAlpha);
- if (error.isError())
- {
- return error;
- }
-
- mSwizzleCache[level] = swizzleTarget;
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void TextureStorage11::invalidateSwizzleCacheLevel(int mipLevel)
-{
- if (mipLevel >= 0 && static_cast<unsigned int>(mipLevel) < ArraySize(mSwizzleCache))
- {
- // The default constructor of SwizzleCacheValue has GL_NONE for all channels which is not a
- // valid swizzle combination
- mSwizzleCache[mipLevel] = SwizzleCacheValue();
- }
-}
-
-void TextureStorage11::invalidateSwizzleCache()
-{
- for (unsigned int mipLevel = 0; mipLevel < ArraySize(mSwizzleCache); mipLevel++)
- {
- invalidateSwizzleCacheLevel(mipLevel);
- }
-}
-
-gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, unsigned int sourceSubresource,
- const gl::ImageIndex &index, const gl::Box &copyArea)
-{
- ASSERT(srcTexture);
-
- GLint level = index.mipIndex;
-
- invalidateSwizzleCacheLevel(level);
-
- gl::Extents texSize(getLevelWidth(level), getLevelHeight(level), getLevelDepth(level));
-
- bool fullCopy = copyArea.x == 0 &&
- copyArea.y == 0 &&
- copyArea.z == 0 &&
- copyArea.width == texSize.width &&
- copyArea.height == texSize.height &&
- copyArea.depth == texSize.depth;
-
- ID3D11Resource *dstTexture = NULL;
- gl::Error error = getResource(&dstTexture);
- if (error.isError())
- {
- return error;
- }
-
- unsigned int dstSubresource = getSubresourceIndex(index);
-
- ASSERT(dstTexture);
-
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mTextureFormat);
- if (!fullCopy && (dxgiFormatInfo.depthBits > 0 || dxgiFormatInfo.stencilBits > 0))
- {
- // CopySubresourceRegion cannot copy partial depth stencils, use the blitter instead
- Blit11 *blitter = mRenderer->getBlitter();
-
- return blitter->copyDepthStencil(srcTexture, sourceSubresource, copyArea, texSize,
- dstTexture, dstSubresource, copyArea, texSize,
- NULL);
- }
- else
- {
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mTextureFormat);
-
- D3D11_BOX srcBox;
- srcBox.left = copyArea.x;
- srcBox.top = copyArea.y;
- srcBox.right = copyArea.x + roundUp(static_cast<UINT>(copyArea.width), dxgiFormatInfo.blockWidth);
- srcBox.bottom = copyArea.y + roundUp(static_cast<UINT>(copyArea.height), dxgiFormatInfo.blockHeight);
- srcBox.front = copyArea.z;
- srcBox.back = copyArea.z + copyArea.depth;
-
- ID3D11DeviceContext *context = mRenderer->getDeviceContext();
-
- context->CopySubresourceRegion(dstTexture, dstSubresource, copyArea.x, copyArea.y, copyArea.z,
- srcTexture, sourceSubresource, fullCopy ? NULL : &srcBox);
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-gl::Error TextureStorage11::copySubresourceLevel(ID3D11Resource* dstTexture, unsigned int dstSubresource,
- const gl::ImageIndex &index, const gl::Box &region)
-{
- ASSERT(dstTexture);
-
- ID3D11Resource *srcTexture = NULL;
- gl::Error error = getResource(&srcTexture);
- if (error.isError())
- {
- return error;
- }
-
- ASSERT(srcTexture);
-
- unsigned int srcSubresource = getSubresourceIndex(index);
-
- ID3D11DeviceContext *context = mRenderer->getDeviceContext();
- context->CopySubresourceRegion(dstTexture, dstSubresource, region.x, region.y, region.z,
- srcTexture, srcSubresource, NULL);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11::generateMipmap(const gl::ImageIndex &sourceIndex, const gl::ImageIndex &destIndex)
-{
- ASSERT(sourceIndex.layerIndex == destIndex.layerIndex);
-
- invalidateSwizzleCacheLevel(destIndex.mipIndex);
-
- RenderTarget *source = NULL;
- gl::Error error = getRenderTarget(sourceIndex, &source);
- if (error.isError())
- {
- return error;
- }
-
- RenderTarget *dest = NULL;
- error = getRenderTarget(destIndex, &dest);
- if (error.isError())
- {
- return error;
- }
-
- ID3D11ShaderResourceView *sourceSRV = RenderTarget11::makeRenderTarget11(source)->getShaderResourceView();
- ID3D11RenderTargetView *destRTV = RenderTarget11::makeRenderTarget11(dest)->getRenderTargetView();
-
- gl::Box sourceArea(0, 0, 0, source->getWidth(), source->getHeight(), source->getDepth());
- gl::Extents sourceSize(source->getWidth(), source->getHeight(), source->getDepth());
-
- gl::Box destArea(0, 0, 0, dest->getWidth(), dest->getHeight(), dest->getDepth());
- gl::Extents destSize(dest->getWidth(), dest->getHeight(), dest->getDepth());
-
- Blit11 *blitter = mRenderer->getBlitter();
- return blitter->copyTexture(sourceSRV, sourceArea, sourceSize, destRTV, destArea, destSize, NULL,
- gl::GetInternalFormatInfo(source->getInternalFormat()).format, GL_LINEAR);
-}
-
-void TextureStorage11::verifySwizzleExists(GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha)
-{
- SwizzleCacheValue swizzleTarget(swizzleRed, swizzleGreen, swizzleBlue, swizzleAlpha);
- for (unsigned int level = 0; level < mMipLevels; level++)
- {
- ASSERT(mSwizzleCache[level] == swizzleTarget);
- }
-}
-
-gl::Error TextureStorage11::copyToStorage(TextureStorage *destStorage)
-{
- ASSERT(destStorage);
-
- ID3D11Resource *sourceResouce = NULL;
- gl::Error error = getResource(&sourceResouce);
- if (error.isError())
- {
- return error;
- }
-
- TextureStorage11 *dest11 = TextureStorage11::makeTextureStorage11(destStorage);
- ID3D11Resource *destResource = NULL;
- error = dest11->getResource(&destResource);
- if (error.isError())
- {
- return error;
- }
-
- ID3D11DeviceContext *immediateContext = mRenderer->getDeviceContext();
- immediateContext->CopyResource(destResource, sourceResouce);
-
- dest11->invalidateSwizzleCache();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11::setData(const gl::ImageIndex &index, Image *image, const gl::Box *destBox, GLenum type,
- const gl::PixelUnpackState &unpack, const uint8_t *pixelData)
-{
- ID3D11Resource *resource = NULL;
- gl::Error error = getResource(&resource);
- if (error.isError())
- {
- return error;
- }
- ASSERT(resource);
-
- UINT destSubresource = getSubresourceIndex(index);
-
- const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(image->getInternalFormat());
-
- bool fullUpdate = (destBox == NULL || *destBox == gl::Box(0, 0, 0, mTextureWidth, mTextureHeight, mTextureDepth));
- ASSERT(internalFormatInfo.depthBits == 0 || fullUpdate);
-
- // TODO(jmadill): Handle compressed formats
- // Compressed formats have different load syntax, so we'll have to handle them with slightly
- // different logic. Will implemnent this in a follow-up patch, and ensure we do not use SetData
- // with compressed formats in the calling logic.
- ASSERT(!internalFormatInfo.compressed);
-
- int width = destBox ? destBox->width : static_cast<int>(image->getWidth());
- int height = destBox ? destBox->height : static_cast<int>(image->getHeight());
- int depth = destBox ? destBox->depth : static_cast<int>(image->getDepth());
- UINT srcRowPitch = internalFormatInfo.computeRowPitch(type, width, unpack.alignment);
- UINT srcDepthPitch = internalFormatInfo.computeDepthPitch(type, width, height, unpack.alignment);
-
- const d3d11::TextureFormat &d3d11Format = d3d11::GetTextureFormatInfo(image->getInternalFormat());
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(d3d11Format.texFormat);
-
- size_t outputPixelSize = dxgiFormatInfo.pixelBytes;
-
- UINT bufferRowPitch = outputPixelSize * width;
- UINT bufferDepthPitch = bufferRowPitch * height;
-
- MemoryBuffer conversionBuffer;
- if (!conversionBuffer.resize(bufferDepthPitch * depth))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate internal buffer.");
- }
-
- // TODO: fast path
- LoadImageFunction loadFunction = d3d11Format.loadFunctions.at(type);
- loadFunction(width, height, depth,
- pixelData, srcRowPitch, srcDepthPitch,
- conversionBuffer.data(), bufferRowPitch, bufferDepthPitch);
-
- ID3D11DeviceContext *immediateContext = mRenderer->getDeviceContext();
-
- if (!fullUpdate)
- {
- ASSERT(destBox);
-
- D3D11_BOX destD3DBox;
- destD3DBox.left = destBox->x;
- destD3DBox.right = destBox->x + destBox->width;
- destD3DBox.top = destBox->y;
- destD3DBox.bottom = destBox->y + destBox->height;
- destD3DBox.front = 0;
- destD3DBox.back = 1;
-
- immediateContext->UpdateSubresource(resource, destSubresource,
- &destD3DBox, conversionBuffer.data(),
- bufferRowPitch, bufferDepthPitch);
- }
- else
- {
- immediateContext->UpdateSubresource(resource, destSubresource,
- NULL, conversionBuffer.data(),
- bufferRowPitch, bufferDepthPitch);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-TextureStorage11_2D::TextureStorage11_2D(Renderer11 *renderer, SwapChain11 *swapchain)
- : TextureStorage11(renderer, D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE),
- mTexture(swapchain->getOffscreenTexture()),
- mSwizzleTexture(NULL)
-{
- mTexture->AddRef();
-
- for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
- {
- mAssociatedImages[i] = NULL;
- mRenderTarget[i] = NULL;
- mSwizzleRenderTargets[i] = NULL;
- }
-
- D3D11_TEXTURE2D_DESC texDesc;
- mTexture->GetDesc(&texDesc);
- mMipLevels = texDesc.MipLevels;
- mTextureFormat = texDesc.Format;
- mTextureWidth = texDesc.Width;
- mTextureHeight = texDesc.Height;
- mTextureDepth = 1;
-
- mInternalFormat = swapchain->GetBackBufferInternalFormat();
-
- ID3D11ShaderResourceView *srv = swapchain->getRenderTargetShaderResource();
- D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
- srv->GetDesc(&srvDesc);
- mShaderResourceFormat = srvDesc.Format;
-
- ID3D11RenderTargetView* offscreenRTV = swapchain->getRenderTarget();
- D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- offscreenRTV->GetDesc(&rtvDesc);
- mRenderTargetFormat = rtvDesc.Format;
-
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mTextureFormat);
- const d3d11::TextureFormat &formatInfo = d3d11::GetTextureFormatInfo(dxgiFormatInfo.internalFormat);
- mSwizzleTextureFormat = formatInfo.swizzleTexFormat;
- mSwizzleShaderResourceFormat = formatInfo.swizzleSRVFormat;
- mSwizzleRenderTargetFormat = formatInfo.swizzleRTVFormat;
-
- mDepthStencilFormat = DXGI_FORMAT_UNKNOWN;
-
- initializeSerials(1, 1);
-}
-
-TextureStorage11_2D::TextureStorage11_2D(Renderer11 *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels)
- : TextureStorage11(renderer, GetTextureBindFlags(internalformat, renderTarget)),
- mTexture(NULL),
- mSwizzleTexture(NULL)
-{
- for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
- {
- mAssociatedImages[i] = NULL;
- mRenderTarget[i] = NULL;
- mSwizzleRenderTargets[i] = NULL;
- }
-
- mInternalFormat = internalformat;
-
- const d3d11::TextureFormat &formatInfo = d3d11::GetTextureFormatInfo(internalformat);
- mTextureFormat = formatInfo.texFormat;
- mShaderResourceFormat = formatInfo.srvFormat;
- mDepthStencilFormat = formatInfo.dsvFormat;
- mRenderTargetFormat = formatInfo.rtvFormat;
- mSwizzleTextureFormat = formatInfo.swizzleTexFormat;
- mSwizzleShaderResourceFormat = formatInfo.swizzleSRVFormat;
- mSwizzleRenderTargetFormat = formatInfo.swizzleRTVFormat;
-
- d3d11::MakeValidSize(false, mTextureFormat, &width, &height, &mTopLevel);
- mMipLevels = mTopLevel + levels;
- mTextureWidth = width;
- mTextureHeight = height;
- mTextureDepth = 1;
-
- initializeSerials(getLevelCount(), 1);
-}
-
-TextureStorage11_2D::~TextureStorage11_2D()
-{
- for (unsigned i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
- {
- if (mAssociatedImages[i] != NULL)
- {
- bool imageAssociationCorrect = mAssociatedImages[i]->isAssociatedStorageValid(this);
- ASSERT(imageAssociationCorrect);
-
- if (imageAssociationCorrect)
- {
- // We must let the Images recover their data before we delete it from the TextureStorage.
- gl::Error error = mAssociatedImages[i]->recoverFromAssociatedStorage();
- if (error.isError())
- {
- // TODO: Find a way to report this back to the context
- }
- }
- }
- }
-
- SafeRelease(mTexture);
- SafeRelease(mSwizzleTexture);
-
- for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
- {
- SafeDelete(mRenderTarget[i]);
- SafeRelease(mSwizzleRenderTargets[i]);
- }
-}
-
-TextureStorage11_2D *TextureStorage11_2D::makeTextureStorage11_2D(TextureStorage *storage)
-{
- ASSERT(HAS_DYNAMIC_TYPE(TextureStorage11_2D*, storage));
- return static_cast<TextureStorage11_2D*>(storage);
-}
-
-void TextureStorage11_2D::associateImage(Image11* image, const gl::ImageIndex &index)
-{
- GLint level = index.mipIndex;
-
- ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
-
- if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- {
- mAssociatedImages[level] = image;
- }
-}
-
-bool TextureStorage11_2D::isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage)
-{
- GLint level = index.mipIndex;
-
- if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- {
- // This validation check should never return false. It means the Image/TextureStorage association is broken.
- bool retValue = (mAssociatedImages[level] == expectedImage);
- ASSERT(retValue);
- return retValue;
- }
-
- return false;
-}
-
-// disassociateImage allows an Image to end its association with a Storage.
-void TextureStorage11_2D::disassociateImage(const gl::ImageIndex &index, Image11* expectedImage)
-{
- GLint level = index.mipIndex;
-
- ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
-
- if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- {
- ASSERT(mAssociatedImages[level] == expectedImage);
-
- if (mAssociatedImages[level] == expectedImage)
- {
- mAssociatedImages[level] = NULL;
- }
- }
-}
-
-// releaseAssociatedImage prepares the Storage for a new Image association. It lets the old Image recover its data before ending the association.
-gl::Error TextureStorage11_2D::releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage)
-{
- GLint level = index.mipIndex;
-
- ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
-
- if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- {
- // No need to let the old Image recover its data, if it is also the incoming Image.
- if (mAssociatedImages[level] != NULL && mAssociatedImages[level] != incomingImage)
- {
- // Ensure that the Image is still associated with this TextureStorage. This should be true.
- bool imageAssociationCorrect = mAssociatedImages[level]->isAssociatedStorageValid(this);
- ASSERT(imageAssociationCorrect);
-
- if (imageAssociationCorrect)
- {
- // Force the image to recover from storage before its data is overwritten.
- // This will reset mAssociatedImages[level] to NULL too.
- gl::Error error = mAssociatedImages[level]->recoverFromAssociatedStorage();
- if (error.isError())
- {
- return error;
- }
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_2D::getResource(ID3D11Resource **outResource)
-{
- // if the width or height is not positive this should be treated as an incomplete texture
- // we handle that here by skipping the d3d texture creation
- if (mTexture == NULL && mTextureWidth > 0 && mTextureHeight > 0)
- {
- ASSERT(mMipLevels > 0);
-
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_TEXTURE2D_DESC desc;
- desc.Width = mTextureWidth; // Compressed texture size constraints?
- desc.Height = mTextureHeight;
- desc.MipLevels = mRenderer->isLevel9() ? 1 : mMipLevels;
- desc.ArraySize = 1;
- desc.Format = mTextureFormat;
- desc.SampleDesc.Count = 1;
- desc.SampleDesc.Quality = 0;
- desc.Usage = D3D11_USAGE_DEFAULT;
- desc.BindFlags = getBindFlags();
- desc.CPUAccessFlags = 0;
- desc.MiscFlags = 0;
-
- HRESULT result = device->CreateTexture2D(&desc, NULL, &mTexture);
-
- // this can happen from windows TDR
- if (d3d11::isDeviceLostError(result))
- {
- mRenderer->notifyDeviceLost();
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create 2D texture storage, result: 0x%X.", result);
- }
- else if (FAILED(result))
- {
- ASSERT(result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create 2D texture storage, result: 0x%X.", result);
- }
- }
-
- *outResource = mTexture;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT)
-{
- ASSERT(!index.hasLayer());
-
- int level = index.mipIndex;
- ASSERT(level >= 0 && level < getLevelCount());
-
- if (!mRenderTarget[level])
- {
- ID3D11Resource *texture = NULL;
- gl::Error error = getResource(&texture);
- if (error.isError())
- {
- return error;
- }
-
- ID3D11ShaderResourceView *srv = NULL;
- error = getSRVLevel(level, &srv);
- if (error.isError())
- {
- return error;
- }
-
- if (mRenderTargetFormat != DXGI_FORMAT_UNKNOWN)
- {
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- rtvDesc.Format = mRenderTargetFormat;
- rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
- rtvDesc.Texture2D.MipSlice = mTopLevel + level;
-
- ID3D11RenderTargetView *rtv;
- HRESULT result = device->CreateRenderTargetView(texture, &rtvDesc, &rtv);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal render target view for texture storage, result: 0x%X.", result);
- }
-
- mRenderTarget[level] = new TextureRenderTarget11(rtv, texture, srv, mInternalFormat, getLevelWidth(level), getLevelHeight(level), 1, 0);
-
- // RenderTarget will take ownership of these resources
- SafeRelease(rtv);
- }
- else if (mDepthStencilFormat != DXGI_FORMAT_UNKNOWN)
- {
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
- dsvDesc.Format = mDepthStencilFormat;
- dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
- dsvDesc.Texture2D.MipSlice = mTopLevel + level;
- dsvDesc.Flags = 0;
-
- ID3D11DepthStencilView *dsv;
- HRESULT result = device->CreateDepthStencilView(texture, &dsvDesc, &dsv);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY,"Failed to create internal depth stencil view for texture storage, result: 0x%X.", result);
- }
-
- mRenderTarget[level] = new TextureRenderTarget11(dsv, texture, srv, mInternalFormat, getLevelWidth(level), getLevelHeight(level), 1, 0);
-
- // RenderTarget will take ownership of these resources
- SafeRelease(dsv);
- }
- else
- {
- UNREACHABLE();
- }
- }
-
- ASSERT(outRT);
- *outRT = mRenderTarget[level];
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_2D::createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture,
- ID3D11ShaderResourceView **outSRV) const
-{
- ASSERT(outSRV);
-
- D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
- srvDesc.Format = format;
- srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
- srvDesc.Texture2D.MostDetailedMip = mTopLevel + baseLevel;
- srvDesc.Texture2D.MipLevels = mRenderer->isLevel9() ? -1 : mipLevels;
-
- ID3D11Device *device = mRenderer->getDevice();
- HRESULT result = device->CreateShaderResourceView(texture, &srvDesc, outSRV);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal texture storage SRV, result: 0x%X.", result);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_2D::getSwizzleTexture(ID3D11Resource **outTexture)
-{
- ASSERT(outTexture);
-
- if (!mSwizzleTexture)
- {
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_TEXTURE2D_DESC desc;
- desc.Width = mTextureWidth;
- desc.Height = mTextureHeight;
- desc.MipLevels = mMipLevels;
- desc.ArraySize = 1;
- desc.Format = mSwizzleTextureFormat;
- desc.SampleDesc.Count = 1;
- desc.SampleDesc.Quality = 0;
- desc.Usage = D3D11_USAGE_DEFAULT;
- desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
- desc.CPUAccessFlags = 0;
- desc.MiscFlags = 0;
-
- HRESULT result = device->CreateTexture2D(&desc, NULL, &mSwizzleTexture);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal swizzle texture, result: 0x%X.", result);
- }
- }
-
- *outTexture = mSwizzleTexture;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_2D::getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV)
-{
- ASSERT(mipLevel >= 0 && mipLevel < getLevelCount());
- ASSERT(outRTV);
-
- if (!mSwizzleRenderTargets[mipLevel])
- {
- ID3D11Resource *swizzleTexture = NULL;
- gl::Error error = getSwizzleTexture(&swizzleTexture);
- if (error.isError())
- {
- return error;
- }
-
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- rtvDesc.Format = mSwizzleRenderTargetFormat;
- rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
- rtvDesc.Texture2D.MipSlice = mTopLevel + mipLevel;
-
- HRESULT result = device->CreateRenderTargetView(mSwizzleTexture, &rtvDesc, &mSwizzleRenderTargets[mipLevel]);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal swizzle render target view, result: 0x%X.", result);
- }
- }
-
- *outRTV = mSwizzleRenderTargets[mipLevel];
- return gl::Error(GL_NO_ERROR);
-}
-
-TextureStorage11_Cube::TextureStorage11_Cube(Renderer11 *renderer, GLenum internalformat, bool renderTarget, int size, int levels)
- : TextureStorage11(renderer, GetTextureBindFlags(internalformat, renderTarget))
-{
- mTexture = NULL;
- mSwizzleTexture = NULL;
-
- for (unsigned int level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
- {
- mSwizzleRenderTargets[level] = NULL;
- for (unsigned int face = 0; face < CUBE_FACE_COUNT; face++)
- {
- mAssociatedImages[face][level] = NULL;
- mRenderTarget[face][level] = NULL;
- }
- }
-
- mInternalFormat = internalformat;
-
- const d3d11::TextureFormat &formatInfo = d3d11::GetTextureFormatInfo(internalformat);
- mTextureFormat = formatInfo.texFormat;
- mShaderResourceFormat = formatInfo.srvFormat;
- mDepthStencilFormat = formatInfo.dsvFormat;
- mRenderTargetFormat = formatInfo.rtvFormat;
- mSwizzleTextureFormat = formatInfo.swizzleTexFormat;
- mSwizzleShaderResourceFormat = formatInfo.swizzleSRVFormat;
- mSwizzleRenderTargetFormat = formatInfo.swizzleRTVFormat;
-
- // adjust size if needed for compressed textures
- int height = size;
- d3d11::MakeValidSize(false, mTextureFormat, &size, &height, &mTopLevel);
-
- mMipLevels = mTopLevel + levels;
- mTextureWidth = size;
- mTextureHeight = size;
- mTextureDepth = 1;
-
- initializeSerials(getLevelCount() * CUBE_FACE_COUNT, CUBE_FACE_COUNT);
-}
-
-TextureStorage11_Cube::~TextureStorage11_Cube()
-{
- for (unsigned int level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
- {
- for (unsigned int face = 0; face < CUBE_FACE_COUNT; face++)
- {
- if (mAssociatedImages[face][level] != NULL)
- {
- bool imageAssociationCorrect = mAssociatedImages[face][level]->isAssociatedStorageValid(this);
- ASSERT(imageAssociationCorrect);
-
- if (imageAssociationCorrect)
- {
- // We must let the Images recover their data before we delete it from the TextureStorage.
- mAssociatedImages[face][level]->recoverFromAssociatedStorage();
- }
- }
- }
- }
-
- SafeRelease(mTexture);
- SafeRelease(mSwizzleTexture);
-
- for (unsigned int level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
- {
- SafeRelease(mSwizzleRenderTargets[level]);
- for (unsigned int face = 0; face < CUBE_FACE_COUNT; face++)
- {
- SafeDelete(mRenderTarget[face][level]);
- }
- }
-}
-
-TextureStorage11_Cube *TextureStorage11_Cube::makeTextureStorage11_Cube(TextureStorage *storage)
-{
- ASSERT(HAS_DYNAMIC_TYPE(TextureStorage11_Cube*, storage));
- return static_cast<TextureStorage11_Cube*>(storage);
-}
-
-void TextureStorage11_Cube::associateImage(Image11* image, const gl::ImageIndex &index)
-{
- GLint level = index.mipIndex;
- GLint layerTarget = index.layerIndex;
-
- ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- ASSERT(0 <= layerTarget && layerTarget < CUBE_FACE_COUNT);
-
- if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- {
- if (0 <= layerTarget && layerTarget < CUBE_FACE_COUNT)
- {
- mAssociatedImages[layerTarget][level] = image;
- }
- }
-}
-
-bool TextureStorage11_Cube::isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage)
-{
- GLint level = index.mipIndex;
- GLint layerTarget = index.layerIndex;
-
- if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- {
- if (0 <= layerTarget && layerTarget < CUBE_FACE_COUNT)
- {
- // This validation check should never return false. It means the Image/TextureStorage association is broken.
- bool retValue = (mAssociatedImages[layerTarget][level] == expectedImage);
- ASSERT(retValue);
- return retValue;
- }
- }
-
- return false;
-}
-
-// disassociateImage allows an Image to end its association with a Storage.
-void TextureStorage11_Cube::disassociateImage(const gl::ImageIndex &index, Image11* expectedImage)
-{
- GLint level = index.mipIndex;
- GLint layerTarget = index.layerIndex;
-
- ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- ASSERT(0 <= layerTarget && layerTarget < CUBE_FACE_COUNT);
-
- if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- {
- if (0 <= layerTarget && layerTarget < CUBE_FACE_COUNT)
- {
- ASSERT(mAssociatedImages[layerTarget][level] == expectedImage);
-
- if (mAssociatedImages[layerTarget][level] == expectedImage)
- {
- mAssociatedImages[layerTarget][level] = NULL;
- }
- }
- }
-}
-
-// releaseAssociatedImage prepares the Storage for a new Image association. It lets the old Image recover its data before ending the association.
-gl::Error TextureStorage11_Cube::releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage)
-{
- GLint level = index.mipIndex;
- GLint layerTarget = index.layerIndex;
-
- ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- ASSERT(0 <= layerTarget && layerTarget < CUBE_FACE_COUNT);
-
- if ((0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS))
- {
- if (0 <= layerTarget && layerTarget < CUBE_FACE_COUNT)
- {
- // No need to let the old Image recover its data, if it is also the incoming Image.
- if (mAssociatedImages[layerTarget][level] != NULL && mAssociatedImages[layerTarget][level] != incomingImage)
- {
- // Ensure that the Image is still associated with this TextureStorage. This should be true.
- bool imageAssociationCorrect = mAssociatedImages[layerTarget][level]->isAssociatedStorageValid(this);
- ASSERT(imageAssociationCorrect);
-
- if (imageAssociationCorrect)
- {
- // Force the image to recover from storage before its data is overwritten.
- // This will reset mAssociatedImages[level] to NULL too.
- gl::Error error = mAssociatedImages[layerTarget][level]->recoverFromAssociatedStorage();
- if (error.isError())
- {
- return error;
- }
- }
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_Cube::getResource(ID3D11Resource **outResource)
-{
- // if the size is not positive this should be treated as an incomplete texture
- // we handle that here by skipping the d3d texture creation
- if (mTexture == NULL && mTextureWidth > 0 && mTextureHeight > 0)
- {
- ASSERT(mMipLevels > 0);
-
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_TEXTURE2D_DESC desc;
- desc.Width = mTextureWidth;
- desc.Height = mTextureHeight;
- desc.MipLevels = mMipLevels;
- desc.ArraySize = CUBE_FACE_COUNT;
- desc.Format = mTextureFormat;
- desc.SampleDesc.Count = 1;
- desc.SampleDesc.Quality = 0;
- desc.Usage = D3D11_USAGE_DEFAULT;
- desc.BindFlags = getBindFlags();
- desc.CPUAccessFlags = 0;
- desc.MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE;
-
- HRESULT result = device->CreateTexture2D(&desc, NULL, &mTexture);
-
- // this can happen from windows TDR
- if (d3d11::isDeviceLostError(result))
- {
- mRenderer->notifyDeviceLost();
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create cube texture storage, result: 0x%X.", result);
- }
- else if (FAILED(result))
- {
- ASSERT(result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create cube texture storage, result: 0x%X.", result);
- }
- }
-
- *outResource = mTexture;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT)
-{
- int faceIndex = index.layerIndex;
- int level = index.mipIndex;
-
- ASSERT(level >= 0 && level < getLevelCount());
- ASSERT(faceIndex >= 0 && faceIndex < CUBE_FACE_COUNT);
-
- if (!mRenderTarget[faceIndex][level])
- {
- ID3D11Device *device = mRenderer->getDevice();
- HRESULT result;
-
- ID3D11Resource *texture = NULL;
- gl::Error error = getResource(&texture);
- if (error.isError())
- {
- return error;
- }
-
- D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
- srvDesc.Format = mShaderResourceFormat;
- srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY; // Will be used with Texture2D sampler, not TextureCube
- srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + level;
- srvDesc.Texture2DArray.MipLevels = 1;
- srvDesc.Texture2DArray.FirstArraySlice = faceIndex;
- srvDesc.Texture2DArray.ArraySize = 1;
-
- ID3D11ShaderResourceView *srv;
- result = device->CreateShaderResourceView(texture, &srvDesc, &srv);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal shader resource view for texture storage, result: 0x%X.", result);
- }
-
- if (mRenderTargetFormat != DXGI_FORMAT_UNKNOWN)
- {
- D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- rtvDesc.Format = mRenderTargetFormat;
- rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
- rtvDesc.Texture2DArray.MipSlice = mTopLevel + level;
- rtvDesc.Texture2DArray.FirstArraySlice = faceIndex;
- rtvDesc.Texture2DArray.ArraySize = 1;
-
- ID3D11RenderTargetView *rtv;
- result = device->CreateRenderTargetView(texture, &rtvDesc, &rtv);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- SafeRelease(srv);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal render target view for texture storage, result: 0x%X.", result);
- }
-
- mRenderTarget[faceIndex][level] = new TextureRenderTarget11(rtv, texture, srv, mInternalFormat, getLevelWidth(level), getLevelHeight(level), 1, 0);
-
- // RenderTarget will take ownership of these resources
- SafeRelease(rtv);
- SafeRelease(srv);
- }
- else if (mDepthStencilFormat != DXGI_FORMAT_UNKNOWN)
- {
- D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
- dsvDesc.Format = mDepthStencilFormat;
- dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
- dsvDesc.Flags = 0;
- dsvDesc.Texture2DArray.MipSlice = mTopLevel + level;
- dsvDesc.Texture2DArray.FirstArraySlice = faceIndex;
- dsvDesc.Texture2DArray.ArraySize = 1;
-
- ID3D11DepthStencilView *dsv;
- result = device->CreateDepthStencilView(texture, &dsvDesc, &dsv);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- SafeRelease(srv);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal depth stencil view for texture storage, result: 0x%X.", result);
- }
-
- mRenderTarget[faceIndex][level] = new TextureRenderTarget11(dsv, texture, srv, mInternalFormat, getLevelWidth(level), getLevelHeight(level), 1, 0);
-
- // RenderTarget will take ownership of these resources
- SafeRelease(dsv);
- SafeRelease(srv);
- }
- else
- {
- UNREACHABLE();
- }
- }
-
- ASSERT(outRT);
- *outRT = mRenderTarget[faceIndex][level];
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_Cube::createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture,
- ID3D11ShaderResourceView **outSRV) const
-{
- ASSERT(outSRV);
-
- D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
- srvDesc.Format = format;
-
- // Unnormalized integer cube maps are not supported by DX11; we emulate them as an array of six 2D textures
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(format);
- if (dxgiFormatInfo.componentType == GL_INT || dxgiFormatInfo.componentType == GL_UNSIGNED_INT)
- {
- srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
- srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + baseLevel;
- srvDesc.Texture2DArray.MipLevels = 1;
- srvDesc.Texture2DArray.FirstArraySlice = 0;
- srvDesc.Texture2DArray.ArraySize = CUBE_FACE_COUNT;
- }
- else
- {
- srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
- srvDesc.TextureCube.MipLevels = mipLevels;
- srvDesc.TextureCube.MostDetailedMip = mTopLevel + baseLevel;
- }
-
- ID3D11Device *device = mRenderer->getDevice();
- HRESULT result = device->CreateShaderResourceView(texture, &srvDesc, outSRV);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal texture storage SRV, result: 0x%X.", result);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_Cube::getSwizzleTexture(ID3D11Resource **outTexture)
-{
- ASSERT(outTexture);
-
- if (!mSwizzleTexture)
- {
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_TEXTURE2D_DESC desc;
- desc.Width = mTextureWidth;
- desc.Height = mTextureHeight;
- desc.MipLevels = mMipLevels;
- desc.ArraySize = CUBE_FACE_COUNT;
- desc.Format = mSwizzleTextureFormat;
- desc.SampleDesc.Count = 1;
- desc.SampleDesc.Quality = 0;
- desc.Usage = D3D11_USAGE_DEFAULT;
- desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
- desc.CPUAccessFlags = 0;
- desc.MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE;
-
- HRESULT result = device->CreateTexture2D(&desc, NULL, &mSwizzleTexture);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal swizzle texture, result: 0x%X.", result);
- }
- }
-
- *outTexture = mSwizzleTexture;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_Cube::getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV)
-{
- ASSERT(mipLevel >= 0 && mipLevel < getLevelCount());
- ASSERT(outRTV);
-
- if (!mSwizzleRenderTargets[mipLevel])
- {
- ID3D11Resource *swizzleTexture = NULL;
- gl::Error error = getSwizzleTexture(&swizzleTexture);
- if (error.isError())
- {
- return error;
- }
-
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- rtvDesc.Format = mSwizzleRenderTargetFormat;
- rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
- rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel;
- rtvDesc.Texture2DArray.FirstArraySlice = 0;
- rtvDesc.Texture2DArray.ArraySize = CUBE_FACE_COUNT;
-
- HRESULT result = device->CreateRenderTargetView(mSwizzleTexture, &rtvDesc, &mSwizzleRenderTargets[mipLevel]);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal swizzle render target view, result: 0x%X.", result);
- }
- }
-
- *outRTV = mSwizzleRenderTargets[mipLevel];
- return gl::Error(GL_NO_ERROR);
-}
-
-TextureStorage11_3D::TextureStorage11_3D(Renderer11 *renderer, GLenum internalformat, bool renderTarget,
- GLsizei width, GLsizei height, GLsizei depth, int levels)
- : TextureStorage11(renderer, GetTextureBindFlags(internalformat, renderTarget))
-{
- mTexture = NULL;
- mSwizzleTexture = NULL;
-
- for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
- {
- mAssociatedImages[i] = NULL;
- mLevelRenderTargets[i] = NULL;
- mSwizzleRenderTargets[i] = NULL;
- }
-
- mInternalFormat = internalformat;
-
- const d3d11::TextureFormat &formatInfo = d3d11::GetTextureFormatInfo(internalformat);
- mTextureFormat = formatInfo.texFormat;
- mShaderResourceFormat = formatInfo.srvFormat;
- mDepthStencilFormat = formatInfo.dsvFormat;
- mRenderTargetFormat = formatInfo.rtvFormat;
- mSwizzleTextureFormat = formatInfo.swizzleTexFormat;
- mSwizzleShaderResourceFormat = formatInfo.swizzleSRVFormat;
- mSwizzleRenderTargetFormat = formatInfo.swizzleRTVFormat;
-
- // adjust size if needed for compressed textures
- d3d11::MakeValidSize(false, mTextureFormat, &width, &height, &mTopLevel);
-
- mMipLevels = mTopLevel + levels;
- mTextureWidth = width;
- mTextureHeight = height;
- mTextureDepth = depth;
-
- initializeSerials(getLevelCount() * depth, depth);
-}
-
-TextureStorage11_3D::~TextureStorage11_3D()
-{
- for (unsigned i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
- {
- if (mAssociatedImages[i] != NULL)
- {
- bool imageAssociationCorrect = mAssociatedImages[i]->isAssociatedStorageValid(this);
- ASSERT(imageAssociationCorrect);
-
- if (imageAssociationCorrect)
- {
- // We must let the Images recover their data before we delete it from the TextureStorage.
- mAssociatedImages[i]->recoverFromAssociatedStorage();
- }
- }
- }
-
- SafeRelease(mTexture);
- SafeRelease(mSwizzleTexture);
-
- for (RenderTargetMap::iterator i = mLevelLayerRenderTargets.begin(); i != mLevelLayerRenderTargets.end(); i++)
- {
- SafeDelete(i->second);
- }
- mLevelLayerRenderTargets.clear();
-
- for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
- {
- SafeDelete(mLevelRenderTargets[i]);
- SafeRelease(mSwizzleRenderTargets[i]);
- }
-}
-
-TextureStorage11_3D *TextureStorage11_3D::makeTextureStorage11_3D(TextureStorage *storage)
-{
- ASSERT(HAS_DYNAMIC_TYPE(TextureStorage11_3D*, storage));
- return static_cast<TextureStorage11_3D*>(storage);
-}
-
-void TextureStorage11_3D::associateImage(Image11* image, const gl::ImageIndex &index)
-{
- GLint level = index.mipIndex;
-
- ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
-
- if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- {
- mAssociatedImages[level] = image;
- }
-}
-
-bool TextureStorage11_3D::isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage)
-{
- GLint level = index.mipIndex;
-
- if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- {
- // This validation check should never return false. It means the Image/TextureStorage association is broken.
- bool retValue = (mAssociatedImages[level] == expectedImage);
- ASSERT(retValue);
- return retValue;
- }
-
- return false;
-}
-
-// disassociateImage allows an Image to end its association with a Storage.
-void TextureStorage11_3D::disassociateImage(const gl::ImageIndex &index, Image11* expectedImage)
-{
- GLint level = index.mipIndex;
-
- ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
-
- if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- {
- ASSERT(mAssociatedImages[level] == expectedImage);
-
- if (mAssociatedImages[level] == expectedImage)
- {
- mAssociatedImages[level] = NULL;
- }
- }
-}
-
-// releaseAssociatedImage prepares the Storage for a new Image association. It lets the old Image recover its data before ending the association.
-gl::Error TextureStorage11_3D::releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage)
-{
- GLint level = index.mipIndex;
-
- ASSERT((0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS));
-
- if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
- {
- // No need to let the old Image recover its data, if it is also the incoming Image.
- if (mAssociatedImages[level] != NULL && mAssociatedImages[level] != incomingImage)
- {
- // Ensure that the Image is still associated with this TextureStorage. This should be true.
- bool imageAssociationCorrect = mAssociatedImages[level]->isAssociatedStorageValid(this);
- ASSERT(imageAssociationCorrect);
-
- if (imageAssociationCorrect)
- {
- // Force the image to recover from storage before its data is overwritten.
- // This will reset mAssociatedImages[level] to NULL too.
- gl::Error error = mAssociatedImages[level]->recoverFromAssociatedStorage();
- if (error.isError())
- {
- return error;
- }
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_3D::getResource(ID3D11Resource **outResource)
-{
- // If the width, height or depth are not positive this should be treated as an incomplete texture
- // we handle that here by skipping the d3d texture creation
- if (mTexture == NULL && mTextureWidth > 0 && mTextureHeight > 0 && mTextureDepth > 0)
- {
- ASSERT(mMipLevels > 0);
-
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_TEXTURE3D_DESC desc;
- desc.Width = mTextureWidth;
- desc.Height = mTextureHeight;
- desc.Depth = mTextureDepth;
- desc.MipLevels = mMipLevels;
- desc.Format = mTextureFormat;
- desc.Usage = D3D11_USAGE_DEFAULT;
- desc.BindFlags = getBindFlags();
- desc.CPUAccessFlags = 0;
- desc.MiscFlags = 0;
-
- HRESULT result = device->CreateTexture3D(&desc, NULL, &mTexture);
-
- // this can happen from windows TDR
- if (d3d11::isDeviceLostError(result))
- {
- mRenderer->notifyDeviceLost();
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create 3D texture storage, result: 0x%X.", result);
- }
- else if (FAILED(result))
- {
- ASSERT(result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create 3D texture storage, result: 0x%X.", result);
- }
- }
-
- *outResource = mTexture;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_3D::createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture,
- ID3D11ShaderResourceView **outSRV) const
-{
- ASSERT(outSRV);
-
- D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
- srvDesc.Format = format;
- srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
- srvDesc.Texture3D.MostDetailedMip = baseLevel;
- srvDesc.Texture3D.MipLevels = mipLevels;
-
- ID3D11Device *device = mRenderer->getDevice();
- HRESULT result = device->CreateShaderResourceView(texture, &srvDesc, outSRV);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal texture storage SRV, result: 0x%X.", result);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT)
-{
- int mipLevel = index.mipIndex;
- ASSERT(mipLevel >= 0 && mipLevel < getLevelCount());
-
- ASSERT(mRenderTargetFormat != DXGI_FORMAT_UNKNOWN);
-
- if (!index.hasLayer())
- {
- if (!mLevelRenderTargets[mipLevel])
- {
- ID3D11Resource *texture = NULL;
- gl::Error error = getResource(&texture);
- if (error.isError())
- {
- return error;
- }
-
- ID3D11ShaderResourceView *srv = NULL;
- error = getSRVLevel(mipLevel, &srv);
- if (error.isError())
- {
- return error;
- }
-
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- rtvDesc.Format = mRenderTargetFormat;
- rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
- rtvDesc.Texture3D.MipSlice = mTopLevel + mipLevel;
- rtvDesc.Texture3D.FirstWSlice = 0;
- rtvDesc.Texture3D.WSize = -1;
-
- ID3D11RenderTargetView *rtv;
- HRESULT result = device->CreateRenderTargetView(texture, &rtvDesc, &rtv);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- SafeRelease(srv);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal render target view for texture storage, result: 0x%X.", result);
- }
-
- mLevelRenderTargets[mipLevel] = new TextureRenderTarget11(rtv, texture, srv, mInternalFormat, getLevelWidth(mipLevel), getLevelHeight(mipLevel), getLevelDepth(mipLevel), 0);
-
- // RenderTarget will take ownership of these resources
- SafeRelease(rtv);
- }
-
- ASSERT(outRT);
- *outRT = mLevelRenderTargets[mipLevel];
- return gl::Error(GL_NO_ERROR);
- }
- else
- {
- int layer = index.layerIndex;
-
- LevelLayerKey key(mipLevel, layer);
- if (mLevelLayerRenderTargets.find(key) == mLevelLayerRenderTargets.end())
- {
- ID3D11Device *device = mRenderer->getDevice();
- HRESULT result;
-
- ID3D11Resource *texture = NULL;
- gl::Error error = getResource(&texture);
- if (error.isError())
- {
- return error;
- }
-
- // TODO, what kind of SRV is expected here?
- ID3D11ShaderResourceView *srv = NULL;
-
- D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- rtvDesc.Format = mRenderTargetFormat;
- rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
- rtvDesc.Texture3D.MipSlice = mTopLevel + mipLevel;
- rtvDesc.Texture3D.FirstWSlice = layer;
- rtvDesc.Texture3D.WSize = 1;
-
- ID3D11RenderTargetView *rtv;
- result = device->CreateRenderTargetView(texture, &rtvDesc, &rtv);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- SafeRelease(srv); return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal render target view for texture storage, result: 0x%X.", result);
- }
- ASSERT(SUCCEEDED(result));
-
- mLevelLayerRenderTargets[key] = new TextureRenderTarget11(rtv, texture, srv, mInternalFormat, getLevelWidth(mipLevel), getLevelHeight(mipLevel), 1, 0);
-
- // RenderTarget will take ownership of these resources
- SafeRelease(rtv);
- }
-
- ASSERT(outRT);
- *outRT = mLevelLayerRenderTargets[key];
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-gl::Error TextureStorage11_3D::getSwizzleTexture(ID3D11Resource **outTexture)
-{
- ASSERT(outTexture);
-
- if (!mSwizzleTexture)
- {
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_TEXTURE3D_DESC desc;
- desc.Width = mTextureWidth;
- desc.Height = mTextureHeight;
- desc.Depth = mTextureDepth;
- desc.MipLevels = mMipLevels;
- desc.Format = mSwizzleTextureFormat;
- desc.Usage = D3D11_USAGE_DEFAULT;
- desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
- desc.CPUAccessFlags = 0;
- desc.MiscFlags = 0;
-
- HRESULT result = device->CreateTexture3D(&desc, NULL, &mSwizzleTexture);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal swizzle texture, result: 0x%X.", result);
- }
- }
-
- *outTexture = mSwizzleTexture;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_3D::getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV)
-{
- ASSERT(mipLevel >= 0 && mipLevel < getLevelCount());
- ASSERT(outRTV);
-
- if (!mSwizzleRenderTargets[mipLevel])
- {
- ID3D11Resource *swizzleTexture = NULL;
- gl::Error error = getSwizzleTexture(&swizzleTexture);
- if (error.isError())
- {
- return error;
- }
-
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- rtvDesc.Format = mSwizzleRenderTargetFormat;
- rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
- rtvDesc.Texture3D.MipSlice = mTopLevel + mipLevel;
- rtvDesc.Texture3D.FirstWSlice = 0;
- rtvDesc.Texture3D.WSize = -1;
-
- HRESULT result = device->CreateRenderTargetView(mSwizzleTexture, &rtvDesc, &mSwizzleRenderTargets[mipLevel]);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal swizzle render target view, result: 0x%X.", result);
- }
- }
-
- *outRTV = mSwizzleRenderTargets[mipLevel];
- return gl::Error(GL_NO_ERROR);
-}
-
-TextureStorage11_2DArray::TextureStorage11_2DArray(Renderer11 *renderer, GLenum internalformat, bool renderTarget,
- GLsizei width, GLsizei height, GLsizei depth, int levels)
- : TextureStorage11(renderer, GetTextureBindFlags(internalformat, renderTarget))
-{
- mTexture = NULL;
- mSwizzleTexture = NULL;
-
- for (unsigned int level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
- {
- mSwizzleRenderTargets[level] = NULL;
- }
-
- mInternalFormat = internalformat;
-
- const d3d11::TextureFormat &formatInfo = d3d11::GetTextureFormatInfo(internalformat);
- mTextureFormat = formatInfo.texFormat;
- mShaderResourceFormat = formatInfo.srvFormat;
- mDepthStencilFormat = formatInfo.dsvFormat;
- mRenderTargetFormat = formatInfo.rtvFormat;
- mSwizzleTextureFormat = formatInfo.swizzleTexFormat;
- mSwizzleShaderResourceFormat = formatInfo.swizzleSRVFormat;
- mSwizzleRenderTargetFormat = formatInfo.swizzleRTVFormat;
-
- // adjust size if needed for compressed textures
- d3d11::MakeValidSize(false, mTextureFormat, &width, &height, &mTopLevel);
-
- mMipLevels = mTopLevel + levels;
- mTextureWidth = width;
- mTextureHeight = height;
- mTextureDepth = depth;
-
- initializeSerials(getLevelCount() * depth, depth);
-}
-
-TextureStorage11_2DArray::~TextureStorage11_2DArray()
-{
- for (ImageMap::iterator i = mAssociatedImages.begin(); i != mAssociatedImages.end(); i++)
- {
- bool imageAssociationCorrect = i->second->isAssociatedStorageValid(this);
- ASSERT(imageAssociationCorrect);
-
- if (imageAssociationCorrect)
- {
- // We must let the Images recover their data before we delete it from the TextureStorage.
- i->second->recoverFromAssociatedStorage();
- }
- }
- mAssociatedImages.clear();
-
- SafeRelease(mTexture);
- SafeRelease(mSwizzleTexture);
-
- for (unsigned int level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
- {
- SafeRelease(mSwizzleRenderTargets[level]);
- }
-
- for (RenderTargetMap::iterator i = mRenderTargets.begin(); i != mRenderTargets.end(); i++)
- {
- SafeDelete(i->second);
- }
- mRenderTargets.clear();
-}
-
-TextureStorage11_2DArray *TextureStorage11_2DArray::makeTextureStorage11_2DArray(TextureStorage *storage)
-{
- ASSERT(HAS_DYNAMIC_TYPE(TextureStorage11_2DArray*, storage));
- return static_cast<TextureStorage11_2DArray*>(storage);
-}
-
-void TextureStorage11_2DArray::associateImage(Image11* image, const gl::ImageIndex &index)
-{
- GLint level = index.mipIndex;
- GLint layerTarget = index.layerIndex;
-
- ASSERT(0 <= level && level < getLevelCount());
-
- if (0 <= level && level < getLevelCount())
- {
- LevelLayerKey key(level, layerTarget);
- mAssociatedImages[key] = image;
- }
-}
-
-bool TextureStorage11_2DArray::isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage)
-{
- GLint level = index.mipIndex;
- GLint layerTarget = index.layerIndex;
-
- LevelLayerKey key(level, layerTarget);
-
- // This validation check should never return false. It means the Image/TextureStorage association is broken.
- bool retValue = (mAssociatedImages.find(key) != mAssociatedImages.end() && (mAssociatedImages[key] == expectedImage));
- ASSERT(retValue);
- return retValue;
-}
-
-// disassociateImage allows an Image to end its association with a Storage.
-void TextureStorage11_2DArray::disassociateImage(const gl::ImageIndex &index, Image11* expectedImage)
-{
- GLint level = index.mipIndex;
- GLint layerTarget = index.layerIndex;
-
- LevelLayerKey key(level, layerTarget);
-
- bool imageAssociationCorrect = (mAssociatedImages.find(key) != mAssociatedImages.end() && (mAssociatedImages[key] == expectedImage));
- ASSERT(imageAssociationCorrect);
-
- if (imageAssociationCorrect)
- {
- mAssociatedImages[key] = NULL;
- }
-}
-
-// releaseAssociatedImage prepares the Storage for a new Image association. It lets the old Image recover its data before ending the association.
-gl::Error TextureStorage11_2DArray::releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage)
-{
- GLint level = index.mipIndex;
- GLint layerTarget = index.layerIndex;
-
- LevelLayerKey key(level, layerTarget);
-
- ASSERT(mAssociatedImages.find(key) != mAssociatedImages.end());
-
- if (mAssociatedImages.find(key) != mAssociatedImages.end())
- {
- if (mAssociatedImages[key] != NULL && mAssociatedImages[key] != incomingImage)
- {
- // Ensure that the Image is still associated with this TextureStorage. This should be true.
- bool imageAssociationCorrect = mAssociatedImages[key]->isAssociatedStorageValid(this);
- ASSERT(imageAssociationCorrect);
-
- if (imageAssociationCorrect)
- {
- // Force the image to recover from storage before its data is overwritten.
- // This will reset mAssociatedImages[level] to NULL too.
- gl::Error error = mAssociatedImages[key]->recoverFromAssociatedStorage();
- if (error.isError())
- {
- return error;
- }
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_2DArray::getResource(ID3D11Resource **outResource)
-{
- // if the width, height or depth is not positive this should be treated as an incomplete texture
- // we handle that here by skipping the d3d texture creation
- if (mTexture == NULL && mTextureWidth > 0 && mTextureHeight > 0 && mTextureDepth > 0)
- {
- ASSERT(mMipLevels > 0);
-
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_TEXTURE2D_DESC desc;
- desc.Width = mTextureWidth;
- desc.Height = mTextureHeight;
- desc.MipLevels = mMipLevels;
- desc.ArraySize = mTextureDepth;
- desc.Format = mTextureFormat;
- desc.SampleDesc.Count = 1;
- desc.SampleDesc.Quality = 0;
- desc.Usage = D3D11_USAGE_DEFAULT;
- desc.BindFlags = getBindFlags();
- desc.CPUAccessFlags = 0;
- desc.MiscFlags = 0;
-
- HRESULT result = device->CreateTexture2D(&desc, NULL, &mTexture);
-
- // this can happen from windows TDR
- if (d3d11::isDeviceLostError(result))
- {
- mRenderer->notifyDeviceLost();
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create 2D array texture storage, result: 0x%X.", result);
- }
- else if (FAILED(result))
- {
- ASSERT(result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create 2D array texture storage, result: 0x%X.", result);
- }
- }
-
- *outResource = mTexture;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_2DArray::createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture,
- ID3D11ShaderResourceView **outSRV) const
-{
- D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
- srvDesc.Format = format;
- srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
- srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + baseLevel;
- srvDesc.Texture2DArray.MipLevels = mipLevels;
- srvDesc.Texture2DArray.FirstArraySlice = 0;
- srvDesc.Texture2DArray.ArraySize = mTextureDepth;
-
- ID3D11Device *device = mRenderer->getDevice();
- HRESULT result = device->CreateShaderResourceView(texture, &srvDesc, outSRV);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal texture storage SRV, result: 0x%X.", result);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT)
-{
- ASSERT(index.hasLayer());
-
- int mipLevel = index.mipIndex;
- int layer = index.layerIndex;
-
- ASSERT(mipLevel >= 0 && mipLevel < getLevelCount());
-
- LevelLayerKey key(mipLevel, layer);
- if (mRenderTargets.find(key) == mRenderTargets.end())
- {
- ID3D11Device *device = mRenderer->getDevice();
- HRESULT result;
-
- ID3D11Resource *texture = NULL;
- gl::Error error = getResource(&texture);
- if (error.isError())
- {
- return error;
- }
-
- D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
- srvDesc.Format = mShaderResourceFormat;
- srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
- srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + mipLevel;
- srvDesc.Texture2DArray.MipLevels = 1;
- srvDesc.Texture2DArray.FirstArraySlice = layer;
- srvDesc.Texture2DArray.ArraySize = 1;
-
- ID3D11ShaderResourceView *srv;
- result = device->CreateShaderResourceView(texture, &srvDesc, &srv);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal shader resource view for texture storage, result: 0x%X.", result);
- }
-
- if (mRenderTargetFormat != DXGI_FORMAT_UNKNOWN)
- {
- D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- rtvDesc.Format = mRenderTargetFormat;
- rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
- rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel;
- rtvDesc.Texture2DArray.FirstArraySlice = layer;
- rtvDesc.Texture2DArray.ArraySize = 1;
-
- ID3D11RenderTargetView *rtv;
- result = device->CreateRenderTargetView(texture, &rtvDesc, &rtv);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- SafeRelease(srv);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal render target view for texture storage, result: 0x%X.", result);
- }
-
- mRenderTargets[key] = new TextureRenderTarget11(rtv, texture, srv, mInternalFormat, getLevelWidth(mipLevel), getLevelHeight(mipLevel), 1, 0);
-
- // RenderTarget will take ownership of these resources
- SafeRelease(rtv);
- SafeRelease(srv);
- }
- else
- {
- UNREACHABLE();
- }
- }
-
- ASSERT(outRT);
- *outRT = mRenderTargets[key];
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_2DArray::getSwizzleTexture(ID3D11Resource **outTexture)
-{
- if (!mSwizzleTexture)
- {
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_TEXTURE2D_DESC desc;
- desc.Width = mTextureWidth;
- desc.Height = mTextureHeight;
- desc.MipLevels = mMipLevels;
- desc.ArraySize = mTextureDepth;
- desc.Format = mSwizzleTextureFormat;
- desc.SampleDesc.Count = 1;
- desc.SampleDesc.Quality = 0;
- desc.Usage = D3D11_USAGE_DEFAULT;
- desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
- desc.CPUAccessFlags = 0;
- desc.MiscFlags = 0;
-
- HRESULT result = device->CreateTexture2D(&desc, NULL, &mSwizzleTexture);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal swizzle texture, result: 0x%X.", result);
- }
- }
-
- *outTexture = mSwizzleTexture;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage11_2DArray::getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV)
-{
- ASSERT(mipLevel >= 0 && mipLevel < getLevelCount());
- ASSERT(outRTV);
-
- if (!mSwizzleRenderTargets[mipLevel])
- {
- ID3D11Resource *swizzleTexture = NULL;
- gl::Error error = getSwizzleTexture(&swizzleTexture);
- if (error.isError())
- {
- return error;
- }
-
- ID3D11Device *device = mRenderer->getDevice();
-
- D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- rtvDesc.Format = mSwizzleRenderTargetFormat;
- rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
- rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel;
- rtvDesc.Texture2DArray.FirstArraySlice = 0;
- rtvDesc.Texture2DArray.ArraySize = mTextureDepth;
-
- HRESULT result = device->CreateRenderTargetView(mSwizzleTexture, &rtvDesc, &mSwizzleRenderTargets[mipLevel]);
-
- ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal swizzle render target view, result: 0x%X.", result);
- }
- }
-
- *outRTV = mSwizzleRenderTargets[mipLevel];
- return gl::Error(GL_NO_ERROR);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.h
deleted file mode 100644
index 930300a63d..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.h
+++ /dev/null
@@ -1,298 +0,0 @@
-//
-// Copyright (c) 2012-2013 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.
-//
-
-// TextureStorage11.h: Defines the abstract rx::TextureStorage11 class and its concrete derived
-// classes TextureStorage11_2D and TextureStorage11_Cube, which act as the interface to the D3D11 texture.
-
-#ifndef LIBGLESV2_RENDERER_TEXTURESTORAGE11_H_
-#define LIBGLESV2_RENDERER_TEXTURESTORAGE11_H_
-
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/Error.h"
-#include "libGLESv2/renderer/d3d/TextureStorage.h"
-
-#include <map>
-
-namespace gl
-{
-struct ImageIndex;
-}
-
-namespace rx
-{
-class RenderTarget;
-class RenderTarget11;
-class Renderer11;
-class SwapChain11;
-class Image11;
-
-class TextureStorage11 : public TextureStorage
-{
- public:
- virtual ~TextureStorage11();
-
- static TextureStorage11 *makeTextureStorage11(TextureStorage *storage);
-
- static DWORD GetTextureBindFlags(GLenum internalFormat, bool renderTarget);
-
- UINT getBindFlags() const;
-
- virtual gl::Error getResource(ID3D11Resource **outResource) = 0;
- virtual gl::Error getSRV(const gl::SamplerState &samplerState, ID3D11ShaderResourceView **outSRV);
- virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT) = 0;
-
- virtual gl::Error generateMipmap(const gl::ImageIndex &sourceIndex, const gl::ImageIndex &destIndex);
-
- virtual int getTopLevel() const;
- virtual bool isRenderTarget() const;
- virtual bool isManaged() const;
- virtual int getLevelCount() const;
- UINT getSubresourceIndex(const gl::ImageIndex &index) const;
-
- gl::Error generateSwizzles(GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha);
- void invalidateSwizzleCacheLevel(int mipLevel);
- void invalidateSwizzleCache();
-
- gl::Error updateSubresourceLevel(ID3D11Resource *texture, unsigned int sourceSubresource,
- const gl::ImageIndex &index, const gl::Box &copyArea);
-
- gl::Error copySubresourceLevel(ID3D11Resource* dstTexture, unsigned int dstSubresource,
- const gl::ImageIndex &index, const gl::Box &region);
-
- virtual void associateImage(Image11* image, const gl::ImageIndex &index) = 0;
- virtual void disassociateImage(const gl::ImageIndex &index, Image11* expectedImage) = 0;
- virtual bool isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage) = 0;
- virtual gl::Error releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage) = 0;
-
- virtual gl::Error copyToStorage(TextureStorage *destStorage);
- virtual gl::Error setData(const gl::ImageIndex &index, Image *image, const gl::Box *destBox, GLenum type,
- const gl::PixelUnpackState &unpack, const uint8_t *pixelData);
-
- protected:
- TextureStorage11(Renderer11 *renderer, UINT bindFlags);
- int getLevelWidth(int mipLevel) const;
- int getLevelHeight(int mipLevel) const;
- int getLevelDepth(int mipLevel) const;
-
- virtual gl::Error getSwizzleTexture(ID3D11Resource **outTexture) = 0;
- virtual gl::Error getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV) = 0;
- gl::Error getSRVLevel(int mipLevel, ID3D11ShaderResourceView **outSRV);
-
- virtual gl::Error createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture,
- ID3D11ShaderResourceView **outSRV) const = 0;
-
- void verifySwizzleExists(GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha);
-
- Renderer11 *mRenderer;
- int mTopLevel;
- unsigned int mMipLevels;
-
- GLenum mInternalFormat;
- DXGI_FORMAT mTextureFormat;
- DXGI_FORMAT mShaderResourceFormat;
- DXGI_FORMAT mRenderTargetFormat;
- DXGI_FORMAT mDepthStencilFormat;
- DXGI_FORMAT mSwizzleTextureFormat;
- DXGI_FORMAT mSwizzleShaderResourceFormat;
- DXGI_FORMAT mSwizzleRenderTargetFormat;
- unsigned int mTextureWidth;
- unsigned int mTextureHeight;
- unsigned int mTextureDepth;
-
- struct SwizzleCacheValue
- {
- GLenum swizzleRed;
- GLenum swizzleGreen;
- GLenum swizzleBlue;
- GLenum swizzleAlpha;
-
- SwizzleCacheValue();
- SwizzleCacheValue(GLenum red, GLenum green, GLenum blue, GLenum alpha);
-
- bool operator ==(const SwizzleCacheValue &other) const;
- bool operator !=(const SwizzleCacheValue &other) const;
- };
- SwizzleCacheValue mSwizzleCache[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureStorage11);
-
- const UINT mBindFlags;
-
- struct SRVKey
- {
- SRVKey(int baseLevel = 0, int mipLevels = 0, bool swizzle = false);
-
- bool operator<(const SRVKey &rhs) const;
-
- int baseLevel;
- int mipLevels;
- bool swizzle;
- };
- typedef std::map<SRVKey, ID3D11ShaderResourceView *> SRVCache;
-
- SRVCache mSrvCache;
- ID3D11ShaderResourceView *mLevelSRVs[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-};
-
-class TextureStorage11_2D : public TextureStorage11
-{
- public:
- TextureStorage11_2D(Renderer11 *renderer, SwapChain11 *swapchain);
- TextureStorage11_2D(Renderer11 *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels);
- virtual ~TextureStorage11_2D();
-
- static TextureStorage11_2D *makeTextureStorage11_2D(TextureStorage *storage);
-
- virtual gl::Error getResource(ID3D11Resource **outResource);
- virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT);
-
- virtual void associateImage(Image11* image, const gl::ImageIndex &index);
- virtual void disassociateImage(const gl::ImageIndex &index, Image11* expectedImage);
- virtual bool isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage);
- virtual gl::Error releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage);
-
- protected:
- virtual gl::Error getSwizzleTexture(ID3D11Resource **outTexture);
- virtual gl::Error getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureStorage11_2D);
-
- virtual gl::Error createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture,
- ID3D11ShaderResourceView **outSRV) const;
-
- ID3D11Texture2D *mTexture;
- RenderTarget11 *mRenderTarget[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-
- ID3D11Texture2D *mSwizzleTexture;
- ID3D11RenderTargetView *mSwizzleRenderTargets[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-
- Image11 *mAssociatedImages[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-};
-
-class TextureStorage11_Cube : public TextureStorage11
-{
- public:
- TextureStorage11_Cube(Renderer11 *renderer, GLenum internalformat, bool renderTarget, int size, int levels);
- virtual ~TextureStorage11_Cube();
-
- static TextureStorage11_Cube *makeTextureStorage11_Cube(TextureStorage *storage);
-
- virtual gl::Error getResource(ID3D11Resource **outResource);
- virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT);
-
- virtual void associateImage(Image11* image, const gl::ImageIndex &index);
- virtual void disassociateImage(const gl::ImageIndex &index, Image11* expectedImage);
- virtual bool isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage);
- virtual gl::Error releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage);
-
- protected:
- virtual gl::Error getSwizzleTexture(ID3D11Resource **outTexture);
- virtual gl::Error getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureStorage11_Cube);
-
- virtual gl::Error createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture,
- ID3D11ShaderResourceView **outSRV) const;
-
- static const size_t CUBE_FACE_COUNT = 6;
-
- ID3D11Texture2D *mTexture;
- RenderTarget11 *mRenderTarget[CUBE_FACE_COUNT][gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-
- ID3D11Texture2D *mSwizzleTexture;
- ID3D11RenderTargetView *mSwizzleRenderTargets[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-
- Image11 *mAssociatedImages[CUBE_FACE_COUNT][gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-};
-
-class TextureStorage11_3D : public TextureStorage11
-{
- public:
- TextureStorage11_3D(Renderer11 *renderer, GLenum internalformat, bool renderTarget,
- GLsizei width, GLsizei height, GLsizei depth, int levels);
- virtual ~TextureStorage11_3D();
-
- static TextureStorage11_3D *makeTextureStorage11_3D(TextureStorage *storage);
-
- virtual gl::Error getResource(ID3D11Resource **outResource);
-
- // Handles both layer and non-layer RTs
- virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT);
-
- virtual void associateImage(Image11* image, const gl::ImageIndex &index);
- virtual void disassociateImage(const gl::ImageIndex &index, Image11* expectedImage);
- virtual bool isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage);
- virtual gl::Error releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage);
-
- protected:
- virtual gl::Error getSwizzleTexture(ID3D11Resource **outTexture);
- virtual gl::Error getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureStorage11_3D);
-
- virtual gl::Error createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture,
- ID3D11ShaderResourceView **outSRV) const;
-
- typedef std::pair<int, int> LevelLayerKey;
- typedef std::map<LevelLayerKey, RenderTarget11*> RenderTargetMap;
- RenderTargetMap mLevelLayerRenderTargets;
-
- RenderTarget11 *mLevelRenderTargets[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-
- ID3D11Texture3D *mTexture;
- ID3D11Texture3D *mSwizzleTexture;
- ID3D11RenderTargetView *mSwizzleRenderTargets[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-
- Image11 *mAssociatedImages[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-};
-
-class TextureStorage11_2DArray : public TextureStorage11
-{
- public:
- TextureStorage11_2DArray(Renderer11 *renderer, GLenum internalformat, bool renderTarget,
- GLsizei width, GLsizei height, GLsizei depth, int levels);
- virtual ~TextureStorage11_2DArray();
-
- static TextureStorage11_2DArray *makeTextureStorage11_2DArray(TextureStorage *storage);
-
- virtual gl::Error getResource(ID3D11Resource **outResource);
- virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT);
-
- virtual void associateImage(Image11* image, const gl::ImageIndex &index);
- virtual void disassociateImage(const gl::ImageIndex &index, Image11* expectedImage);
- virtual bool isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage);
- virtual gl::Error releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage);
-
- protected:
- virtual gl::Error getSwizzleTexture(ID3D11Resource **outTexture);
- virtual gl::Error getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureStorage11_2DArray);
-
- virtual gl::Error createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture,
- ID3D11ShaderResourceView **outSRV) const;
-
- typedef std::pair<int, int> LevelLayerKey;
- typedef std::map<LevelLayerKey, RenderTarget11*> RenderTargetMap;
- RenderTargetMap mRenderTargets;
-
- ID3D11Texture2D *mTexture;
-
- ID3D11Texture2D *mSwizzleTexture;
- ID3D11RenderTargetView *mSwizzleRenderTargets[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-
- typedef std::map<LevelLayerKey, Image11*> ImageMap;
- ImageMap mAssociatedImages;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_TEXTURESTORAGE11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/VertexArray11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/VertexArray11.h
deleted file mode 100644
index 70bc3bb26f..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/VertexArray11.h
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// VertexArray11.h: Defines the rx::VertexArray11 class which implements rx::VertexArrayImpl.
-
-#ifndef LIBGLESV2_RENDERER_VERTEXARRAY11_H_
-#define LIBGLESV2_RENDERER_VERTEXARRAY11_H_
-
-#include "libGLESv2/renderer/VertexArrayImpl.h"
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-
-namespace rx
-{
-class Renderer11;
-
-class VertexArray11 : public VertexArrayImpl
-{
- public:
- VertexArray11(Renderer11 *renderer)
- : VertexArrayImpl(),
- mRenderer(renderer)
- {
- }
- virtual ~VertexArray11() { }
-
- virtual void setElementArrayBuffer(const gl::Buffer *buffer) { }
- virtual void setAttribute(size_t idx, const gl::VertexAttribute &attr) { }
- virtual void setAttributeDivisor(size_t idx, GLuint divisor) { }
- virtual void enableAttribute(size_t idx, bool enabledState) { }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(VertexArray11);
-
- Renderer11 *mRenderer;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_VERTEXARRAY11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/VertexBuffer11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/VertexBuffer11.cpp
deleted file mode 100644
index a9d6fa2ca4..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/VertexBuffer11.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// VertexBuffer11.cpp: Defines the D3D11 VertexBuffer implementation.
-
-#include "libGLESv2/renderer/d3d/d3d11/VertexBuffer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Buffer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
-#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h"
-#include "libGLESv2/Buffer.h"
-#include "libGLESv2/VertexAttribute.h"
-
-namespace rx
-{
-
-VertexBuffer11::VertexBuffer11(Renderer11 *const renderer) : mRenderer(renderer)
-{
- mBuffer = NULL;
- mBufferSize = 0;
- mDynamicUsage = false;
-}
-
-VertexBuffer11::~VertexBuffer11()
-{
- SafeRelease(mBuffer);
-}
-
-gl::Error VertexBuffer11::initialize(unsigned int size, bool dynamicUsage)
-{
- SafeRelease(mBuffer);
-
- updateSerial();
-
- if (size > 0)
- {
- ID3D11Device* dxDevice = mRenderer->getDevice();
-
- D3D11_BUFFER_DESC bufferDesc;
- bufferDesc.ByteWidth = size;
- bufferDesc.Usage = D3D11_USAGE_DYNAMIC;
- bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
- bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
- bufferDesc.MiscFlags = 0;
- bufferDesc.StructureByteStride = 0;
-
- HRESULT result = dxDevice->CreateBuffer(&bufferDesc, NULL, &mBuffer);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate internal vertex buffer of size, %lu.", size);
- }
- }
-
- mBufferSize = size;
- mDynamicUsage = dynamicUsage;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-VertexBuffer11 *VertexBuffer11::makeVertexBuffer11(VertexBuffer *vetexBuffer)
-{
- ASSERT(HAS_DYNAMIC_TYPE(VertexBuffer11*, vetexBuffer));
- return static_cast<VertexBuffer11*>(vetexBuffer);
-}
-
-gl::Error VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
- GLint start, GLsizei count, GLsizei instances, unsigned int offset)
-{
- if (!mBuffer)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal vertex buffer is not initialized.");
- }
-
- gl::Buffer *buffer = attrib.buffer.get();
- int inputStride = ComputeVertexAttributeStride(attrib);
- ID3D11DeviceContext *dxContext = mRenderer->getDeviceContext();
-
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- HRESULT result = dxContext->Map(mBuffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mappedResource);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal vertex buffer, HRESULT: 0x%08x.", result);
- }
-
- uint8_t *output = reinterpret_cast<uint8_t*>(mappedResource.pData) + offset;
-
- const uint8_t *input = NULL;
- if (attrib.enabled)
- {
- if (buffer)
- {
- BufferD3D *storage = BufferD3D::makeFromBuffer(buffer);
- gl::Error error = storage->getData(&input);
- if (error.isError())
- {
- return error;
- }
- input += static_cast<int>(attrib.offset);
- }
- else
- {
- input = static_cast<const uint8_t*>(attrib.pointer);
- }
- }
- else
- {
- input = reinterpret_cast<const uint8_t*>(currentValue.FloatValues);
- }
-
- if (instances == 0 || attrib.divisor == 0)
- {
- input += inputStride * start;
- }
-
- gl::VertexFormat vertexFormat(attrib, currentValue.Type);
- const d3d11::VertexFormat &vertexFormatInfo = d3d11::GetVertexFormatInfo(vertexFormat);
- ASSERT(vertexFormatInfo.copyFunction != NULL);
- vertexFormatInfo.copyFunction(input, inputStride, count, output);
-
- dxContext->Unmap(mBuffer, 0);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error VertexBuffer11::getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei count,
- GLsizei instances, unsigned int *outSpaceRequired) const
-{
- unsigned int elementCount = 0;
- if (attrib.enabled)
- {
- if (instances == 0 || attrib.divisor == 0)
- {
- elementCount = count;
- }
- else
- {
- // Round up to divisor, if possible
- elementCount = UnsignedCeilDivide(static_cast<unsigned int>(instances), attrib.divisor);
- }
-
- gl::VertexFormat vertexFormat(attrib);
- const d3d11::VertexFormat &vertexFormatInfo = d3d11::GetVertexFormatInfo(vertexFormat);
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(vertexFormatInfo.nativeFormat);
- unsigned int elementSize = dxgiFormatInfo.pixelBytes;
- if (elementSize <= std::numeric_limits<unsigned int>::max() / elementCount)
- {
- if (outSpaceRequired)
- {
- *outSpaceRequired = elementSize * elementCount;
- }
- return gl::Error(GL_NO_ERROR);
- }
- else
- {
- return gl::Error(GL_OUT_OF_MEMORY, "New vertex buffer size would result in an overflow.");
- }
- }
- else
- {
- const unsigned int elementSize = 4;
- if (outSpaceRequired)
- {
- *outSpaceRequired = elementSize * 4;
- }
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-unsigned int VertexBuffer11::getBufferSize() const
-{
- return mBufferSize;
-}
-
-gl::Error VertexBuffer11::setBufferSize(unsigned int size)
-{
- if (size > mBufferSize)
- {
- return initialize(size, mDynamicUsage);
- }
- else
- {
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-gl::Error VertexBuffer11::discard()
-{
- if (!mBuffer)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal vertex buffer is not initialized.");
- }
-
- ID3D11DeviceContext *dxContext = mRenderer->getDeviceContext();
-
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- HRESULT result = dxContext->Map(mBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal buffer for discarding, HRESULT: 0x%08x", result);
- }
-
- dxContext->Unmap(mBuffer, 0);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-ID3D11Buffer *VertexBuffer11::getBuffer() const
-{
- return mBuffer;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/VertexBuffer11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/VertexBuffer11.h
deleted file mode 100644
index a9bbac98fa..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/VertexBuffer11.h
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// VertexBuffer11.h: Defines the D3D11 VertexBuffer implementation.
-
-#ifndef LIBGLESV2_RENDERER_VERTEXBUFFER11_H_
-#define LIBGLESV2_RENDERER_VERTEXBUFFER11_H_
-
-#include "libGLESv2/renderer/d3d/VertexBuffer.h"
-
-namespace rx
-{
-class Renderer11;
-
-class VertexBuffer11 : public VertexBuffer
-{
- public:
- explicit VertexBuffer11(Renderer11 *const renderer);
- virtual ~VertexBuffer11();
-
- virtual gl::Error initialize(unsigned int size, bool dynamicUsage);
-
- static VertexBuffer11 *makeVertexBuffer11(VertexBuffer *vetexBuffer);
-
- virtual gl::Error storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
- GLint start, GLsizei count, GLsizei instances, unsigned int offset);
-
- virtual gl::Error getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances,
- unsigned int *outSpaceRequired) const;
-
- virtual unsigned int getBufferSize() const;
- virtual gl::Error setBufferSize(unsigned int size);
- virtual gl::Error discard();
-
- ID3D11Buffer *getBuffer() const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(VertexBuffer11);
-
- Renderer11 *const mRenderer;
-
- ID3D11Buffer *mBuffer;
- unsigned int mBufferSize;
- bool mDynamicUsage;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_VERTEXBUFFER11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.cpp
deleted file mode 100644
index 90a879e170..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.cpp
+++ /dev/null
@@ -1,1075 +0,0 @@
-//
-// Copyright (c) 2013-2014 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.
-//
-
-// formatutils11.cpp: Queries for GL image formats and their translations to D3D11
-// formats.
-
-#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h"
-#include "libGLESv2/renderer/generatemip.h"
-#include "libGLESv2/renderer/loadimage.h"
-#include "libGLESv2/renderer/copyimage.h"
-#include "libGLESv2/renderer/Renderer.h"
-#include "libGLESv2/renderer/copyvertex.h"
-
-namespace rx
-{
-
-namespace d3d11
-{
-
-typedef std::map<DXGI_FORMAT, GLenum> DXGIToESFormatMap;
-
-inline void AddDXGIToESEntry(DXGIToESFormatMap *map, DXGI_FORMAT key, GLenum value)
-{
- map->insert(std::make_pair(key, value));
-}
-
-static DXGIToESFormatMap BuildDXGIToESFormatMap()
-{
- DXGIToESFormatMap map;
-
- AddDXGIToESEntry(&map, DXGI_FORMAT_UNKNOWN, GL_NONE);
-
- AddDXGIToESEntry(&map, DXGI_FORMAT_A8_UNORM, GL_ALPHA8_EXT);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R8_UNORM, GL_R8);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8_UNORM, GL_RG8);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8B8A8_UNORM, GL_RGBA8);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, GL_SRGB8_ALPHA8);
- AddDXGIToESEntry(&map, DXGI_FORMAT_B8G8R8A8_UNORM, GL_BGRA8_EXT);
-
- AddDXGIToESEntry(&map, DXGI_FORMAT_R8_SNORM, GL_R8_SNORM);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8_SNORM, GL_RG8_SNORM);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8B8A8_SNORM, GL_RGBA8_SNORM);
-
- AddDXGIToESEntry(&map, DXGI_FORMAT_R8_UINT, GL_R8UI);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R16_UINT, GL_R16UI);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R32_UINT, GL_R32UI);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8_UINT, GL_RG8UI);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R16G16_UINT, GL_RG16UI);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32_UINT, GL_RG32UI);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32B32_UINT, GL_RGB32UI);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8B8A8_UINT, GL_RGBA8UI);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R16G16B16A16_UINT, GL_RGBA16UI);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32B32A32_UINT, GL_RGBA32UI);
-
- AddDXGIToESEntry(&map, DXGI_FORMAT_R8_SINT, GL_R8I);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R16_SINT, GL_R16I);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R32_SINT, GL_R32I);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8_SINT, GL_RG8I);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R16G16_SINT, GL_RG16I);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32_SINT, GL_RG32I);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32B32_SINT, GL_RGB32I);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8B8A8_SINT, GL_RGBA8I);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R16G16B16A16_SINT, GL_RGBA16I);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32B32A32_SINT, GL_RGBA32I);
-
- AddDXGIToESEntry(&map, DXGI_FORMAT_R10G10B10A2_UNORM, GL_RGB10_A2);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R10G10B10A2_UINT, GL_RGB10_A2UI);
-
- AddDXGIToESEntry(&map, DXGI_FORMAT_R16_FLOAT, GL_R16F);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R16G16_FLOAT, GL_RG16F);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R16G16B16A16_FLOAT, GL_RGBA16F);
-
- AddDXGIToESEntry(&map, DXGI_FORMAT_R32_FLOAT, GL_R32F);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32_FLOAT, GL_RG32F);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32B32_FLOAT, GL_RGB32F);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32B32A32_FLOAT, GL_RGBA32F);
-
- AddDXGIToESEntry(&map, DXGI_FORMAT_R9G9B9E5_SHAREDEXP, GL_RGB9_E5);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R11G11B10_FLOAT, GL_R11F_G11F_B10F);
-
- AddDXGIToESEntry(&map, DXGI_FORMAT_R16_TYPELESS, GL_DEPTH_COMPONENT16);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R16_UNORM, GL_DEPTH_COMPONENT16);
- AddDXGIToESEntry(&map, DXGI_FORMAT_D16_UNORM, GL_DEPTH_COMPONENT16);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R24G8_TYPELESS, GL_DEPTH24_STENCIL8_OES);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, GL_DEPTH24_STENCIL8_OES);
- AddDXGIToESEntry(&map, DXGI_FORMAT_D24_UNORM_S8_UINT, GL_DEPTH24_STENCIL8_OES);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R32G8X24_TYPELESS, GL_DEPTH32F_STENCIL8);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, GL_DEPTH32F_STENCIL8);
- AddDXGIToESEntry(&map, DXGI_FORMAT_D32_FLOAT_S8X24_UINT, GL_DEPTH32F_STENCIL8);
- AddDXGIToESEntry(&map, DXGI_FORMAT_R32_TYPELESS, GL_DEPTH_COMPONENT32F);
- AddDXGIToESEntry(&map, DXGI_FORMAT_D32_FLOAT, GL_DEPTH_COMPONENT32F);
-
- AddDXGIToESEntry(&map, DXGI_FORMAT_BC1_UNORM, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
- AddDXGIToESEntry(&map, DXGI_FORMAT_BC2_UNORM, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE);
- AddDXGIToESEntry(&map, DXGI_FORMAT_BC3_UNORM, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE);
-
- return map;
-}
-
-struct D3D11FastCopyFormat
-{
- GLenum destFormat;
- GLenum destType;
- ColorCopyFunction copyFunction;
-
- D3D11FastCopyFormat(GLenum destFormat, GLenum destType, ColorCopyFunction copyFunction)
- : destFormat(destFormat), destType(destType), copyFunction(copyFunction)
- { }
-
- bool operator<(const D3D11FastCopyFormat& other) const
- {
- return memcmp(this, &other, sizeof(D3D11FastCopyFormat)) < 0;
- }
-};
-
-typedef std::multimap<DXGI_FORMAT, D3D11FastCopyFormat> D3D11FastCopyMap;
-
-static D3D11FastCopyMap BuildFastCopyMap()
-{
- D3D11FastCopyMap map;
-
- map.insert(std::make_pair(DXGI_FORMAT_B8G8R8A8_UNORM, D3D11FastCopyFormat(GL_RGBA, GL_UNSIGNED_BYTE, CopyBGRA8ToRGBA8)));
-
- return map;
-}
-
-struct DXGIDepthStencilInfo
-{
- unsigned int depthBits;
- unsigned int depthOffset;
- unsigned int stencilBits;
- unsigned int stencilOffset;
-};
-
-typedef std::map<DXGI_FORMAT, DXGIDepthStencilInfo> DepthStencilInfoMap;
-typedef std::pair<DXGI_FORMAT, DXGIDepthStencilInfo> DepthStencilInfoPair;
-
-static inline void InsertDXGIDepthStencilInfo(DepthStencilInfoMap *map, DXGI_FORMAT format, unsigned int depthBits,
- unsigned int depthOffset, unsigned int stencilBits, unsigned int stencilOffset)
-{
- DXGIDepthStencilInfo info;
- info.depthBits = depthBits;
- info.depthOffset = depthOffset;
- info.stencilBits = stencilBits;
- info.stencilOffset = stencilOffset;
-
- map->insert(std::make_pair(format, info));
-}
-
-static DepthStencilInfoMap BuildDepthStencilInfoMap()
-{
- DepthStencilInfoMap map;
-
- InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_R16_TYPELESS, 16, 0, 0, 0);
- InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_R16_UNORM, 16, 0, 0, 0);
- InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_D16_UNORM, 16, 0, 0, 0);
-
- InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_R24G8_TYPELESS, 24, 0, 8, 24);
- InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, 24, 0, 8, 24);
- InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_D24_UNORM_S8_UINT, 24, 0, 8, 24);
-
- InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_R32_TYPELESS, 32, 0, 0, 0);
- InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_R32_FLOAT, 32, 0, 0, 0);
- InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_D32_FLOAT, 32, 0, 0, 0);
-
- InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_R32G8X24_TYPELESS, 32, 0, 8, 32);
- InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, 32, 0, 8, 32);
- InsertDXGIDepthStencilInfo(&map, DXGI_FORMAT_D32_FLOAT_S8X24_UINT, 32, 0, 8, 32);
-
- return map;
-}
-
-typedef std::map<DXGI_FORMAT, DXGIFormat> DXGIFormatInfoMap;
-
-DXGIFormat::DXGIFormat()
- : pixelBytes(0),
- blockWidth(0),
- blockHeight(0),
- depthBits(0),
- depthOffset(0),
- stencilBits(0),
- stencilOffset(0),
- internalFormat(GL_NONE),
- componentType(GL_NONE),
- mipGenerationFunction(NULL),
- colorReadFunction(NULL),
- fastCopyFunctions()
-{
-}
-
-ColorCopyFunction DXGIFormat::getFastCopyFunction(GLenum format, GLenum type) const
-{
- FastCopyFunctionMap::const_iterator iter = fastCopyFunctions.find(std::make_pair(format, type));
- return (iter != fastCopyFunctions.end()) ? iter->second : NULL;
-}
-
-void AddDXGIFormat(DXGIFormatInfoMap *map, DXGI_FORMAT dxgiFormat, GLuint pixelBits, GLuint blockWidth, GLuint blockHeight,
- GLenum componentType, MipGenerationFunction mipFunc, ColorReadFunction readFunc)
-{
- DXGIFormat info;
- info.pixelBytes = pixelBits / 8;
- info.blockWidth = blockWidth;
- info.blockHeight = blockHeight;
-
- static const DepthStencilInfoMap dsInfoMap = BuildDepthStencilInfoMap();
- DepthStencilInfoMap::const_iterator dsInfoIter = dsInfoMap.find(dxgiFormat);
- if (dsInfoIter != dsInfoMap.end())
- {
- info.depthBits = dsInfoIter->second.depthBits;
- info.depthOffset = dsInfoIter->second.depthOffset;
- info.stencilBits = dsInfoIter->second.stencilBits;
- info.stencilOffset = dsInfoIter->second.stencilOffset;
- }
- else
- {
- info.depthBits = 0;
- info.depthOffset = 0;
- info.stencilBits = 0;
- info.stencilOffset = 0;
- }
-
- static const DXGIToESFormatMap dxgiToESMap = BuildDXGIToESFormatMap();
- DXGIToESFormatMap::const_iterator dxgiToESIter = dxgiToESMap.find(dxgiFormat);
- info.internalFormat = (dxgiToESIter != dxgiToESMap.end()) ? dxgiToESIter->second : GL_NONE;
-
- info.componentType = componentType;
-
- info.mipGenerationFunction = mipFunc;
- info.colorReadFunction = readFunc;
-
- static const D3D11FastCopyMap fastCopyMap = BuildFastCopyMap();
- std::pair<D3D11FastCopyMap::const_iterator, D3D11FastCopyMap::const_iterator> fastCopyIter = fastCopyMap.equal_range(dxgiFormat);
- for (D3D11FastCopyMap::const_iterator i = fastCopyIter.first; i != fastCopyIter.second; i++)
- {
- info.fastCopyFunctions.insert(std::make_pair(std::make_pair(i->second.destFormat, i->second.destType), i->second.copyFunction));
- }
-
- map->insert(std::make_pair(dxgiFormat, info));
-}
-
-// A map to determine the pixel size and mipmap generation function of a given DXGI format
-static DXGIFormatInfoMap BuildDXGIFormatInfoMap()
-{
- DXGIFormatInfoMap map;
-
- // | DXGI format |S |W |H |Component Type | Mip generation function | Color read function
- AddDXGIFormat(&map, DXGI_FORMAT_UNKNOWN, 0, 0, 0, GL_NONE, NULL, NULL);
-
- AddDXGIFormat(&map, DXGI_FORMAT_A8_UNORM, 8, 1, 1, GL_UNSIGNED_NORMALIZED, GenerateMip<A8>, ReadColor<A8, GLfloat>);
- AddDXGIFormat(&map, DXGI_FORMAT_R8_UNORM, 8, 1, 1, GL_UNSIGNED_NORMALIZED, GenerateMip<R8>, ReadColor<R8, GLfloat>);
- AddDXGIFormat(&map, DXGI_FORMAT_R8G8_UNORM, 16, 1, 1, GL_UNSIGNED_NORMALIZED, GenerateMip<R8G8>, ReadColor<R8G8, GLfloat>);
- AddDXGIFormat(&map, DXGI_FORMAT_R8G8B8A8_UNORM, 32, 1, 1, GL_UNSIGNED_NORMALIZED, GenerateMip<R8G8B8A8>, ReadColor<R8G8B8A8, GLfloat>);
- AddDXGIFormat(&map, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, 32, 1, 1, GL_UNSIGNED_NORMALIZED, GenerateMip<R8G8B8A8>, ReadColor<R8G8B8A8, GLfloat>);
- AddDXGIFormat(&map, DXGI_FORMAT_B8G8R8A8_UNORM, 32, 1, 1, GL_UNSIGNED_NORMALIZED, GenerateMip<B8G8R8A8>, ReadColor<B8G8R8A8, GLfloat>);
-
- AddDXGIFormat(&map, DXGI_FORMAT_R8_SNORM, 8, 1, 1, GL_SIGNED_NORMALIZED, GenerateMip<R8S>, ReadColor<R8S, GLfloat>);
- AddDXGIFormat(&map, DXGI_FORMAT_R8G8_SNORM, 16, 1, 1, GL_SIGNED_NORMALIZED, GenerateMip<R8G8S>, ReadColor<R8G8S, GLfloat>);
- AddDXGIFormat(&map, DXGI_FORMAT_R8G8B8A8_SNORM, 32, 1, 1, GL_SIGNED_NORMALIZED, GenerateMip<R8G8B8A8S>, ReadColor<R8G8B8A8S, GLfloat>);
-
- AddDXGIFormat(&map, DXGI_FORMAT_R8_UINT, 8, 1, 1, GL_UNSIGNED_INT, GenerateMip<R8>, ReadColor<R8, GLuint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R16_UINT, 16, 1, 1, GL_UNSIGNED_INT, GenerateMip<R16>, ReadColor<R16, GLuint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R32_UINT, 32, 1, 1, GL_UNSIGNED_INT, GenerateMip<R32>, ReadColor<R32, GLuint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R8G8_UINT, 16, 1, 1, GL_UNSIGNED_INT, GenerateMip<R8G8>, ReadColor<R8G8, GLuint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R16G16_UINT, 32, 1, 1, GL_UNSIGNED_INT, GenerateMip<R16G16>, ReadColor<R16G16, GLuint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R32G32_UINT, 64, 1, 1, GL_UNSIGNED_INT, GenerateMip<R32G32>, ReadColor<R32G32, GLuint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32_UINT, 96, 1, 1, GL_UNSIGNED_INT, GenerateMip<R32G32B32>, ReadColor<R32G32B32, GLuint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R8G8B8A8_UINT, 32, 1, 1, GL_UNSIGNED_INT, GenerateMip<R8G8B8A8>, ReadColor<R8G8B8A8, GLuint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R16G16B16A16_UINT, 64, 1, 1, GL_UNSIGNED_INT, GenerateMip<R16G16B16A16>, ReadColor<R16G16B16A16, GLuint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32A32_UINT, 128, 1, 1, GL_UNSIGNED_INT, GenerateMip<R32G32B32A32>, ReadColor<R32G32B32A32, GLuint>);
-
- AddDXGIFormat(&map, DXGI_FORMAT_R8_SINT, 8, 1, 1, GL_INT, GenerateMip<R8S>, ReadColor<R8S, GLint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R16_SINT, 16, 1, 1, GL_INT, GenerateMip<R16S>, ReadColor<R16S, GLint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R32_SINT, 32, 1, 1, GL_INT, GenerateMip<R32S>, ReadColor<R32S, GLint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R8G8_SINT, 16, 1, 1, GL_INT, GenerateMip<R8G8S>, ReadColor<R8G8S, GLint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R16G16_SINT, 32, 1, 1, GL_INT, GenerateMip<R16G16S>, ReadColor<R16G16S, GLint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R32G32_SINT, 64, 1, 1, GL_INT, GenerateMip<R32G32S>, ReadColor<R32G32S, GLint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32_SINT, 96, 1, 1, GL_INT, GenerateMip<R32G32B32S>, ReadColor<R32G32B32S, GLint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R8G8B8A8_SINT, 32, 1, 1, GL_INT, GenerateMip<R8G8B8A8S>, ReadColor<R8G8B8A8S, GLint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R16G16B16A16_SINT, 64, 1, 1, GL_INT, GenerateMip<R16G16B16A16S>, ReadColor<R16G16B16A16S, GLint>);
- AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32A32_SINT, 128, 1, 1, GL_INT, GenerateMip<R32G32B32A32S>, ReadColor<R32G32B32A32S, GLint>);
-
- AddDXGIFormat(&map, DXGI_FORMAT_R10G10B10A2_UNORM, 32, 1, 1, GL_UNSIGNED_NORMALIZED, GenerateMip<R10G10B10A2>, ReadColor<R10G10B10A2, GLfloat>);
- AddDXGIFormat(&map, DXGI_FORMAT_R10G10B10A2_UINT, 32, 1, 1, GL_UNSIGNED_INT, GenerateMip<R10G10B10A2>, ReadColor<R10G10B10A2, GLuint>);
-
- AddDXGIFormat(&map, DXGI_FORMAT_R16_FLOAT, 16, 1, 1, GL_FLOAT, GenerateMip<R16F>, ReadColor<R16F, GLfloat>);
- AddDXGIFormat(&map, DXGI_FORMAT_R16G16_FLOAT, 32, 1, 1, GL_FLOAT, GenerateMip<R16G16F>, ReadColor<R16G16F, GLfloat>);
- AddDXGIFormat(&map, DXGI_FORMAT_R16G16B16A16_FLOAT, 64, 1, 1, GL_FLOAT, GenerateMip<R16G16B16A16F>, ReadColor<R16G16B16A16F, GLfloat>);
-
- AddDXGIFormat(&map, DXGI_FORMAT_R32_FLOAT, 32, 1, 1, GL_FLOAT, GenerateMip<R32F>, ReadColor<R32F, GLfloat>);
- AddDXGIFormat(&map, DXGI_FORMAT_R32G32_FLOAT, 64, 1, 1, GL_FLOAT, GenerateMip<R32G32F>, ReadColor<R32G32F, GLfloat>);
- AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32_FLOAT, 96, 1, 1, GL_FLOAT, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32A32_FLOAT, 128, 1, 1, GL_FLOAT, GenerateMip<R32G32B32A32F>, ReadColor<R32G32B32A32F, GLfloat>);
-
- AddDXGIFormat(&map, DXGI_FORMAT_R9G9B9E5_SHAREDEXP, 32, 1, 1, GL_FLOAT, GenerateMip<R9G9B9E5>, ReadColor<R9G9B9E5, GLfloat>);
- AddDXGIFormat(&map, DXGI_FORMAT_R11G11B10_FLOAT, 32, 1, 1, GL_FLOAT, GenerateMip<R11G11B10F>, ReadColor<R11G11B10F, GLfloat>);
-
- AddDXGIFormat(&map, DXGI_FORMAT_R16_TYPELESS, 16, 1, 1, GL_NONE, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_R16_UNORM, 16, 1, 1, GL_UNSIGNED_NORMALIZED, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_D16_UNORM, 16, 1, 1, GL_UNSIGNED_NORMALIZED, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_R24G8_TYPELESS, 32, 1, 1, GL_NONE, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, 32, 1, 1, GL_NONE, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_D24_UNORM_S8_UINT, 32, 1, 1, GL_UNSIGNED_INT, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_R32G8X24_TYPELESS, 64, 1, 1, GL_NONE, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, 64, 1, 1, GL_NONE, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_D32_FLOAT_S8X24_UINT, 64, 1, 1, GL_UNSIGNED_INT, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_R32_TYPELESS, 32, 1, 1, GL_NONE, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_D32_FLOAT, 32, 1, 1, GL_FLOAT, NULL, NULL);
-
- AddDXGIFormat(&map, DXGI_FORMAT_BC1_UNORM, 64, 4, 4, GL_UNSIGNED_NORMALIZED, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_BC2_UNORM, 128, 4, 4, GL_UNSIGNED_NORMALIZED, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_BC3_UNORM, 128, 4, 4, GL_UNSIGNED_NORMALIZED, NULL, NULL);
-
- // Useful formats for vertex buffers
- AddDXGIFormat(&map, DXGI_FORMAT_R16_UNORM, 16, 1, 1, GL_UNSIGNED_NORMALIZED, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_R16_SNORM, 16, 1, 1, GL_SIGNED_NORMALIZED, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_R16G16_UNORM, 32, 1, 1, GL_UNSIGNED_NORMALIZED, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_R16G16_SNORM, 32, 1, 1, GL_SIGNED_NORMALIZED, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_R16G16B16A16_UNORM, 64, 1, 1, GL_UNSIGNED_NORMALIZED, NULL, NULL);
- AddDXGIFormat(&map, DXGI_FORMAT_R16G16B16A16_SNORM, 64, 1, 1, GL_SIGNED_NORMALIZED, NULL, NULL);
-
- return map;
-}
-
-const DXGIFormat &GetDXGIFormatInfo(DXGI_FORMAT format)
-{
- static const DXGIFormatInfoMap infoMap = BuildDXGIFormatInfoMap();
- DXGIFormatInfoMap::const_iterator iter = infoMap.find(format);
- if (iter != infoMap.end())
- {
- return iter->second;
- }
- else
- {
- static DXGIFormat defaultInfo;
- return defaultInfo;
- }
-}
-
-struct SwizzleSizeType
-{
- size_t maxComponentSize;
- GLenum componentType;
-
- SwizzleSizeType()
- : maxComponentSize(0), componentType(GL_NONE)
- { }
-
- SwizzleSizeType(size_t maxComponentSize, GLenum componentType)
- : maxComponentSize(maxComponentSize), componentType(componentType)
- { }
-
- bool operator<(const SwizzleSizeType& other) const
- {
- return (maxComponentSize != other.maxComponentSize) ? (maxComponentSize < other.maxComponentSize)
- : (componentType < other.componentType);
- }
-};
-
-struct SwizzleFormatInfo
-{
- DXGI_FORMAT mTexFormat;
- DXGI_FORMAT mSRVFormat;
- DXGI_FORMAT mRTVFormat;
-
- SwizzleFormatInfo()
- : mTexFormat(DXGI_FORMAT_UNKNOWN), mSRVFormat(DXGI_FORMAT_UNKNOWN), mRTVFormat(DXGI_FORMAT_UNKNOWN)
- { }
-
- SwizzleFormatInfo(DXGI_FORMAT texFormat, DXGI_FORMAT srvFormat, DXGI_FORMAT rtvFormat)
- : mTexFormat(texFormat), mSRVFormat(srvFormat), mRTVFormat(rtvFormat)
- { }
-};
-
-typedef std::map<SwizzleSizeType, SwizzleFormatInfo> SwizzleInfoMap;
-typedef std::pair<SwizzleSizeType, SwizzleFormatInfo> SwizzleInfoPair;
-
-static SwizzleInfoMap BuildSwizzleInfoMap()
-{
- SwizzleInfoMap map;
-
- map.insert(SwizzleInfoPair(SwizzleSizeType( 8, GL_UNSIGNED_NORMALIZED), SwizzleFormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM )));
- map.insert(SwizzleInfoPair(SwizzleSizeType(16, GL_UNSIGNED_NORMALIZED), SwizzleFormatInfo(DXGI_FORMAT_R16G16B16A16_UNORM, DXGI_FORMAT_R16G16B16A16_UNORM, DXGI_FORMAT_R16G16B16A16_UNORM)));
- map.insert(SwizzleInfoPair(SwizzleSizeType(24, GL_UNSIGNED_NORMALIZED), SwizzleFormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT)));
- map.insert(SwizzleInfoPair(SwizzleSizeType(32, GL_UNSIGNED_NORMALIZED), SwizzleFormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT)));
-
- map.insert(SwizzleInfoPair(SwizzleSizeType( 8, GL_SIGNED_NORMALIZED ), SwizzleFormatInfo(DXGI_FORMAT_R8G8B8A8_SNORM, DXGI_FORMAT_R8G8B8A8_SNORM, DXGI_FORMAT_R8G8B8A8_SNORM )));
-
- map.insert(SwizzleInfoPair(SwizzleSizeType(16, GL_FLOAT ), SwizzleFormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT)));
- map.insert(SwizzleInfoPair(SwizzleSizeType(32, GL_FLOAT ), SwizzleFormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT)));
-
- map.insert(SwizzleInfoPair(SwizzleSizeType( 8, GL_UNSIGNED_INT ), SwizzleFormatInfo(DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R8G8B8A8_UINT )));
- map.insert(SwizzleInfoPair(SwizzleSizeType(16, GL_UNSIGNED_INT ), SwizzleFormatInfo(DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_UINT )));
- map.insert(SwizzleInfoPair(SwizzleSizeType(32, GL_UNSIGNED_INT ), SwizzleFormatInfo(DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_UINT )));
-
- map.insert(SwizzleInfoPair(SwizzleSizeType( 8, GL_INT ), SwizzleFormatInfo(DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_SINT )));
- map.insert(SwizzleInfoPair(SwizzleSizeType(16, GL_INT ), SwizzleFormatInfo(DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_SINT )));
- map.insert(SwizzleInfoPair(SwizzleSizeType(32, GL_INT ), SwizzleFormatInfo(DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_SINT )));
-
- return map;
-}
-
-typedef std::pair<GLint, InitializeTextureDataFunction> InternalFormatInitializerPair;
-typedef std::map<GLint, InitializeTextureDataFunction> InternalFormatInitializerMap;
-
-static InternalFormatInitializerMap BuildInternalFormatInitializerMap()
-{
- InternalFormatInitializerMap map;
-
- map.insert(InternalFormatInitializerPair(GL_RGB8, Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF> ));
- map.insert(InternalFormatInitializerPair(GL_RGB565, Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF> ));
- map.insert(InternalFormatInitializerPair(GL_SRGB8, Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF> ));
- map.insert(InternalFormatInitializerPair(GL_RGB16F, Initialize4ComponentData<GLhalf, 0x0000, 0x0000, 0x0000, gl::Float16One>));
- map.insert(InternalFormatInitializerPair(GL_RGB32F, Initialize4ComponentData<GLfloat, 0x00000000, 0x00000000, 0x00000000, gl::Float32One>));
- map.insert(InternalFormatInitializerPair(GL_RGB8UI, Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0x01> ));
- map.insert(InternalFormatInitializerPair(GL_RGB8I, Initialize4ComponentData<GLbyte, 0x00, 0x00, 0x00, 0x01> ));
- map.insert(InternalFormatInitializerPair(GL_RGB16UI, Initialize4ComponentData<GLushort, 0x0000, 0x0000, 0x0000, 0x0001> ));
- map.insert(InternalFormatInitializerPair(GL_RGB16I, Initialize4ComponentData<GLshort, 0x0000, 0x0000, 0x0000, 0x0001> ));
- map.insert(InternalFormatInitializerPair(GL_RGB32UI, Initialize4ComponentData<GLuint, 0x00000000, 0x00000000, 0x00000000, 0x00000001> ));
- map.insert(InternalFormatInitializerPair(GL_RGB32I, Initialize4ComponentData<GLint, 0x00000000, 0x00000000, 0x00000000, 0x00000001> ));
-
- return map;
-}
-
-// ES3 image loading functions vary based on the internal format and data type given,
-// this map type determines the loading function from the internal format and type supplied
-// to glTex*Image*D and the destination DXGI_FORMAT. Source formats and types are taken from
-// Tables 3.2 and 3.3 of the ES 3 spec.
-typedef std::pair<GLenum, LoadImageFunction> TypeLoadFunctionPair;
-typedef std::map<GLenum, std::vector<TypeLoadFunctionPair> > D3D11LoadFunctionMap;
-
-static void UnimplementedLoadFunction(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- UNIMPLEMENTED();
-}
-
-static void UnreachableLoadFunction(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- UNREACHABLE();
-}
-
-// A helper function to insert data into the D3D11LoadFunctionMap with fewer characters.
-static inline void InsertLoadFunction(D3D11LoadFunctionMap *map, GLenum internalFormat, GLenum type,
- LoadImageFunction loadFunc)
-{
- (*map)[internalFormat].push_back(TypeLoadFunctionPair(type, loadFunc));
-}
-
-D3D11LoadFunctionMap BuildD3D11LoadFunctionMap()
-{
- D3D11LoadFunctionMap map;
-
- // | Internal format | Type | Load function |
- InsertLoadFunction(&map, GL_RGBA8, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 4> );
- InsertLoadFunction(&map, GL_RGB5_A1, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 4> );
- InsertLoadFunction(&map, GL_RGBA4, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 4> );
- InsertLoadFunction(&map, GL_SRGB8_ALPHA8, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 4> );
- InsertLoadFunction(&map, GL_RGBA8_SNORM, GL_BYTE, LoadToNative<GLbyte, 4> );
- InsertLoadFunction(&map, GL_RGBA4, GL_UNSIGNED_SHORT_4_4_4_4, LoadRGBA4ToRGBA8 );
- InsertLoadFunction(&map, GL_RGB10_A2, GL_UNSIGNED_INT_2_10_10_10_REV, LoadToNative<GLuint, 1> );
- InsertLoadFunction(&map, GL_RGB5_A1, GL_UNSIGNED_SHORT_5_5_5_1, LoadRGB5A1ToRGBA8 );
- InsertLoadFunction(&map, GL_RGB5_A1, GL_UNSIGNED_INT_2_10_10_10_REV, LoadRGB10A2ToRGBA8 );
- InsertLoadFunction(&map, GL_RGBA16F, GL_HALF_FLOAT, LoadToNative<GLhalf, 4> );
- InsertLoadFunction(&map, GL_RGBA16F, GL_HALF_FLOAT_OES, LoadToNative<GLhalf, 4> );
- InsertLoadFunction(&map, GL_RGBA32F, GL_FLOAT, LoadToNative<GLfloat, 4> );
- InsertLoadFunction(&map, GL_RGBA16F, GL_FLOAT, Load32FTo16F<4> );
- InsertLoadFunction(&map, GL_RGBA8UI, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 4> );
- InsertLoadFunction(&map, GL_RGBA8I, GL_BYTE, LoadToNative<GLbyte, 4> );
- InsertLoadFunction(&map, GL_RGBA16UI, GL_UNSIGNED_SHORT, LoadToNative<GLushort, 4> );
- InsertLoadFunction(&map, GL_RGBA16I, GL_SHORT, LoadToNative<GLshort, 4> );
- InsertLoadFunction(&map, GL_RGBA32UI, GL_UNSIGNED_INT, LoadToNative<GLuint, 4> );
- InsertLoadFunction(&map, GL_RGBA32I, GL_INT, LoadToNative<GLint, 4> );
- InsertLoadFunction(&map, GL_RGB10_A2UI, GL_UNSIGNED_INT_2_10_10_10_REV, LoadToNative<GLuint, 1> );
- InsertLoadFunction(&map, GL_RGB8, GL_UNSIGNED_BYTE, LoadToNative3To4<GLubyte, 0xFF> );
- InsertLoadFunction(&map, GL_RGB565, GL_UNSIGNED_BYTE, LoadToNative3To4<GLubyte, 0xFF> );
- InsertLoadFunction(&map, GL_SRGB8, GL_UNSIGNED_BYTE, LoadToNative3To4<GLubyte, 0xFF> );
- InsertLoadFunction(&map, GL_RGB8_SNORM, GL_BYTE, LoadToNative3To4<GLbyte, 0x7F> );
- InsertLoadFunction(&map, GL_RGB565, GL_UNSIGNED_SHORT_5_6_5, LoadR5G6B5ToRGBA8 );
- InsertLoadFunction(&map, GL_R11F_G11F_B10F, GL_UNSIGNED_INT_10F_11F_11F_REV, LoadToNative<GLuint, 1> );
- InsertLoadFunction(&map, GL_RGB9_E5, GL_UNSIGNED_INT_5_9_9_9_REV, LoadToNative<GLuint, 1> );
- InsertLoadFunction(&map, GL_RGB16F, GL_HALF_FLOAT, LoadToNative3To4<GLhalf, gl::Float16One>);
- InsertLoadFunction(&map, GL_RGB16F, GL_HALF_FLOAT_OES, LoadToNative3To4<GLhalf, gl::Float16One>);
- InsertLoadFunction(&map, GL_R11F_G11F_B10F, GL_HALF_FLOAT, LoadRGB16FToRG11B10F );
- InsertLoadFunction(&map, GL_R11F_G11F_B10F, GL_HALF_FLOAT_OES, LoadRGB16FToRG11B10F );
- InsertLoadFunction(&map, GL_RGB9_E5, GL_HALF_FLOAT, LoadRGB16FToRGB9E5 );
- InsertLoadFunction(&map, GL_RGB9_E5, GL_HALF_FLOAT_OES, LoadRGB16FToRGB9E5 );
- InsertLoadFunction(&map, GL_RGB32F, GL_FLOAT, LoadToNative3To4<GLfloat, gl::Float32One>);
- InsertLoadFunction(&map, GL_RGB16F, GL_FLOAT, LoadRGB32FToRGBA16F );
- InsertLoadFunction(&map, GL_R11F_G11F_B10F, GL_FLOAT, LoadRGB32FToRG11B10F );
- InsertLoadFunction(&map, GL_RGB9_E5, GL_FLOAT, LoadRGB32FToRGB9E5 );
- InsertLoadFunction(&map, GL_RGB8UI, GL_UNSIGNED_BYTE, LoadToNative3To4<GLubyte, 0x01> );
- InsertLoadFunction(&map, GL_RGB8I, GL_BYTE, LoadToNative3To4<GLbyte, 0x01> );
- InsertLoadFunction(&map, GL_RGB16UI, GL_UNSIGNED_SHORT, LoadToNative3To4<GLushort, 0x0001> );
- InsertLoadFunction(&map, GL_RGB16I, GL_SHORT, LoadToNative3To4<GLshort, 0x0001> );
- InsertLoadFunction(&map, GL_RGB32UI, GL_UNSIGNED_INT, LoadToNative3To4<GLuint, 0x00000001> );
- InsertLoadFunction(&map, GL_RGB32I, GL_INT, LoadToNative3To4<GLint, 0x00000001> );
- InsertLoadFunction(&map, GL_RG8, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 2> );
- InsertLoadFunction(&map, GL_RG8_SNORM, GL_BYTE, LoadToNative<GLbyte, 2> );
- InsertLoadFunction(&map, GL_RG16F, GL_HALF_FLOAT, LoadToNative<GLhalf, 2> );
- InsertLoadFunction(&map, GL_RG16F, GL_HALF_FLOAT_OES, LoadToNative<GLhalf, 2> );
- InsertLoadFunction(&map, GL_RG32F, GL_FLOAT, LoadToNative<GLfloat, 2> );
- InsertLoadFunction(&map, GL_RG16F, GL_FLOAT, Load32FTo16F<2> );
- InsertLoadFunction(&map, GL_RG8UI, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 2> );
- InsertLoadFunction(&map, GL_RG8I, GL_BYTE, LoadToNative<GLbyte, 2> );
- InsertLoadFunction(&map, GL_RG16UI, GL_UNSIGNED_SHORT, LoadToNative<GLushort, 2> );
- InsertLoadFunction(&map, GL_RG16I, GL_SHORT, LoadToNative<GLshort, 2> );
- InsertLoadFunction(&map, GL_RG32UI, GL_UNSIGNED_INT, LoadToNative<GLuint, 2> );
- InsertLoadFunction(&map, GL_RG32I, GL_INT, LoadToNative<GLint, 2> );
- InsertLoadFunction(&map, GL_R8, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 1> );
- InsertLoadFunction(&map, GL_R8_SNORM, GL_BYTE, LoadToNative<GLbyte, 1> );
- InsertLoadFunction(&map, GL_R16F, GL_HALF_FLOAT, LoadToNative<GLhalf, 1> );
- InsertLoadFunction(&map, GL_R16F, GL_HALF_FLOAT_OES, LoadToNative<GLhalf, 1> );
- InsertLoadFunction(&map, GL_R32F, GL_FLOAT, LoadToNative<GLfloat, 1> );
- InsertLoadFunction(&map, GL_R16F, GL_FLOAT, Load32FTo16F<1> );
- InsertLoadFunction(&map, GL_R8UI, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 1> );
- InsertLoadFunction(&map, GL_R8I, GL_BYTE, LoadToNative<GLbyte, 1> );
- InsertLoadFunction(&map, GL_R16UI, GL_UNSIGNED_SHORT, LoadToNative<GLushort, 1> );
- InsertLoadFunction(&map, GL_R16I, GL_SHORT, LoadToNative<GLshort, 1> );
- InsertLoadFunction(&map, GL_R32UI, GL_UNSIGNED_INT, LoadToNative<GLuint, 1> );
- InsertLoadFunction(&map, GL_R32I, GL_INT, LoadToNative<GLint, 1> );
- InsertLoadFunction(&map, GL_DEPTH_COMPONENT16, GL_UNSIGNED_SHORT, LoadToNative<GLushort, 1> );
- InsertLoadFunction(&map, GL_DEPTH_COMPONENT24, GL_UNSIGNED_INT, LoadR32ToR24G8 );
- InsertLoadFunction(&map, GL_DEPTH_COMPONENT16, GL_UNSIGNED_INT, LoadR32ToR16 );
- InsertLoadFunction(&map, GL_DEPTH_COMPONENT32F, GL_FLOAT, LoadToNative<GLfloat, 1> );
- InsertLoadFunction(&map, GL_DEPTH24_STENCIL8, GL_UNSIGNED_INT_24_8, LoadR32ToR24G8 );
- InsertLoadFunction(&map, GL_DEPTH32F_STENCIL8, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, LoadToNative<GLuint, 2> );
-
- // Unsized formats
- // Load functions are unreachable because they are converted to sized internal formats based on
- // the format and type before loading takes place.
- InsertLoadFunction(&map, GL_RGBA, GL_UNSIGNED_BYTE, UnreachableLoadFunction );
- InsertLoadFunction(&map, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, UnreachableLoadFunction );
- InsertLoadFunction(&map, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, UnreachableLoadFunction );
- InsertLoadFunction(&map, GL_RGB, GL_UNSIGNED_BYTE, UnreachableLoadFunction );
- InsertLoadFunction(&map, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, UnreachableLoadFunction );
- InsertLoadFunction(&map, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, UnreachableLoadFunction );
- InsertLoadFunction(&map, GL_LUMINANCE, GL_UNSIGNED_BYTE, UnreachableLoadFunction );
- InsertLoadFunction(&map, GL_ALPHA, GL_UNSIGNED_BYTE, UnreachableLoadFunction );
-
- // From GL_OES_texture_float
- InsertLoadFunction(&map, GL_LUMINANCE_ALPHA, GL_FLOAT, LoadLA32FToRGBA32F );
- InsertLoadFunction(&map, GL_LUMINANCE, GL_FLOAT, LoadL32FToRGBA32F );
- InsertLoadFunction(&map, GL_ALPHA, GL_FLOAT, LoadA32FToRGBA32F );
-
- // From GL_OES_texture_half_float
- InsertLoadFunction(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, LoadLA16FToRGBA16F );
- InsertLoadFunction(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, LoadLA16FToRGBA16F );
- InsertLoadFunction(&map, GL_LUMINANCE, GL_HALF_FLOAT, LoadL16FToRGBA16F );
- InsertLoadFunction(&map, GL_LUMINANCE, GL_HALF_FLOAT_OES, LoadL16FToRGBA16F );
- InsertLoadFunction(&map, GL_ALPHA, GL_HALF_FLOAT, LoadA16FToRGBA16F );
- InsertLoadFunction(&map, GL_ALPHA, GL_HALF_FLOAT_OES, LoadA16FToRGBA16F );
-
- // From GL_EXT_texture_storage
- InsertLoadFunction(&map, GL_ALPHA8_EXT, GL_UNSIGNED_BYTE, LoadA8ToRGBA8 );
- InsertLoadFunction(&map, GL_LUMINANCE8_EXT, GL_UNSIGNED_BYTE, LoadL8ToRGBA8 );
- InsertLoadFunction(&map, GL_LUMINANCE8_ALPHA8_EXT, GL_UNSIGNED_BYTE, LoadLA8ToRGBA8 );
- InsertLoadFunction(&map, GL_ALPHA32F_EXT, GL_FLOAT, LoadA32FToRGBA32F );
- InsertLoadFunction(&map, GL_LUMINANCE32F_EXT, GL_FLOAT, LoadL32FToRGBA32F );
- InsertLoadFunction(&map, GL_LUMINANCE_ALPHA32F_EXT, GL_FLOAT, LoadLA32FToRGBA32F );
- InsertLoadFunction(&map, GL_ALPHA16F_EXT, GL_HALF_FLOAT, LoadA16FToRGBA16F );
- InsertLoadFunction(&map, GL_ALPHA16F_EXT, GL_HALF_FLOAT_OES, LoadA16FToRGBA16F );
- InsertLoadFunction(&map, GL_LUMINANCE16F_EXT, GL_HALF_FLOAT, LoadL16FToRGBA16F );
- InsertLoadFunction(&map, GL_LUMINANCE16F_EXT, GL_HALF_FLOAT_OES, LoadL16FToRGBA16F );
- InsertLoadFunction(&map, GL_LUMINANCE_ALPHA16F_EXT, GL_HALF_FLOAT, LoadLA16FToRGBA16F );
- InsertLoadFunction(&map, GL_LUMINANCE_ALPHA16F_EXT, GL_HALF_FLOAT_OES, LoadLA16FToRGBA16F );
-
- // From GL_ANGLE_depth_texture
- InsertLoadFunction(&map, GL_DEPTH_COMPONENT32_OES, GL_UNSIGNED_INT, LoadR32ToR24G8 );
-
- // From GL_EXT_texture_format_BGRA8888
- InsertLoadFunction(&map, GL_BGRA8_EXT, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 4> );
- InsertLoadFunction(&map, GL_BGRA4_ANGLEX, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, LoadRGBA4ToRGBA8 );
- InsertLoadFunction(&map, GL_BGRA4_ANGLEX, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 4> );
- InsertLoadFunction(&map, GL_BGR5_A1_ANGLEX, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, LoadRGB5A1ToRGBA8 );
- InsertLoadFunction(&map, GL_BGR5_A1_ANGLEX, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 4> );
-
- // Compressed formats
- // From ES 3.0.1 spec, table 3.16
- // | Internal format | Type | Load function |
- InsertLoadFunction(&map, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE, UnimplementedLoadFunction );
- InsertLoadFunction(&map, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE, UnimplementedLoadFunction );
- InsertLoadFunction(&map, GL_COMPRESSED_SIGNED_R11_EAC, GL_UNSIGNED_BYTE, UnimplementedLoadFunction );
- InsertLoadFunction(&map, GL_COMPRESSED_RG11_EAC, GL_UNSIGNED_BYTE, UnimplementedLoadFunction );
- InsertLoadFunction(&map, GL_COMPRESSED_SIGNED_RG11_EAC, GL_UNSIGNED_BYTE, UnimplementedLoadFunction );
- InsertLoadFunction(&map, GL_COMPRESSED_RGB8_ETC2, GL_UNSIGNED_BYTE, UnimplementedLoadFunction );
- InsertLoadFunction(&map, GL_COMPRESSED_SRGB8_ETC2, GL_UNSIGNED_BYTE, UnimplementedLoadFunction );
- InsertLoadFunction(&map, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, UnimplementedLoadFunction );
- InsertLoadFunction(&map, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, UnimplementedLoadFunction );
- InsertLoadFunction(&map, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_UNSIGNED_BYTE, UnimplementedLoadFunction );
- InsertLoadFunction(&map, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_UNSIGNED_BYTE, UnimplementedLoadFunction );
-
- // From GL_EXT_texture_compression_dxt1
- InsertLoadFunction(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, LoadCompressedToNative<4, 4, 8>);
- InsertLoadFunction(&map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, LoadCompressedToNative<4, 4, 8>);
-
- // From GL_ANGLE_texture_compression_dxt3
- InsertLoadFunction(&map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, LoadCompressedToNative<4, 4, 16>);
-
- // From GL_ANGLE_texture_compression_dxt5
- InsertLoadFunction(&map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, LoadCompressedToNative<4, 4, 16>);
-
- return map;
-}
-
-// For sized GL internal formats, there is only one corresponding D3D11 format. This map type allows
-// querying for the DXGI texture formats to use for textures, SRVs, RTVs and DSVs given a GL internal
-// format.
-typedef std::map<GLenum, TextureFormat> D3D11ES3FormatMap;
-
-TextureFormat::TextureFormat()
- : texFormat(DXGI_FORMAT_UNKNOWN),
- srvFormat(DXGI_FORMAT_UNKNOWN),
- rtvFormat(DXGI_FORMAT_UNKNOWN),
- dsvFormat(DXGI_FORMAT_UNKNOWN),
- renderFormat(DXGI_FORMAT_UNKNOWN),
- swizzleTexFormat(DXGI_FORMAT_UNKNOWN),
- swizzleSRVFormat(DXGI_FORMAT_UNKNOWN),
- swizzleRTVFormat(DXGI_FORMAT_UNKNOWN),
- dataInitializerFunction(NULL),
- loadFunctions()
-{
-}
-
-static inline void InsertD3D11FormatInfo(D3D11ES3FormatMap *map, GLenum internalFormat, DXGI_FORMAT texFormat,
- DXGI_FORMAT srvFormat, DXGI_FORMAT rtvFormat, DXGI_FORMAT dsvFormat)
-{
- TextureFormat info;
- info.texFormat = texFormat;
- info.srvFormat = srvFormat;
- info.rtvFormat = rtvFormat;
- info.dsvFormat = dsvFormat;
-
- // Given a GL internal format, the renderFormat is the DSV format if it is depth- or stencil-renderable,
- // the RTV format if it is color-renderable, and the (nonrenderable) texture format otherwise.
- if (dsvFormat != DXGI_FORMAT_UNKNOWN)
- {
- info.renderFormat = dsvFormat;
- }
- else if (rtvFormat != DXGI_FORMAT_UNKNOWN)
- {
- info.renderFormat = rtvFormat;
- }
- else if (texFormat != DXGI_FORMAT_UNKNOWN)
- {
- info.renderFormat = texFormat;
- }
- else
- {
- info.renderFormat = DXGI_FORMAT_UNKNOWN;
- }
-
- // Compute the swizzle formats
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
- if (internalFormat != GL_NONE && formatInfo.pixelBytes > 0)
- {
- if (formatInfo.componentCount != 4 || texFormat == DXGI_FORMAT_UNKNOWN ||
- srvFormat == DXGI_FORMAT_UNKNOWN || rtvFormat == DXGI_FORMAT_UNKNOWN)
- {
- // Get the maximum sized component
- unsigned int maxBits = 1;
- if (formatInfo.compressed)
- {
- unsigned int compressedBitsPerBlock = formatInfo.pixelBytes * 8;
- unsigned int blockSize = formatInfo.compressedBlockWidth * formatInfo.compressedBlockHeight;
- maxBits = std::max(compressedBitsPerBlock / blockSize, maxBits);
- }
- else
- {
- maxBits = std::max(maxBits, formatInfo.alphaBits);
- maxBits = std::max(maxBits, formatInfo.redBits);
- maxBits = std::max(maxBits, formatInfo.greenBits);
- maxBits = std::max(maxBits, formatInfo.blueBits);
- maxBits = std::max(maxBits, formatInfo.luminanceBits);
- maxBits = std::max(maxBits, formatInfo.depthBits);
- }
-
- maxBits = roundUp(maxBits, 8U);
-
- static const SwizzleInfoMap swizzleMap = BuildSwizzleInfoMap();
- SwizzleInfoMap::const_iterator swizzleIter = swizzleMap.find(SwizzleSizeType(maxBits, formatInfo.componentType));
- ASSERT(swizzleIter != swizzleMap.end());
-
- const SwizzleFormatInfo &swizzleInfo = swizzleIter->second;
- info.swizzleTexFormat = swizzleInfo.mTexFormat;
- info.swizzleSRVFormat = swizzleInfo.mSRVFormat;
- info.swizzleRTVFormat = swizzleInfo.mRTVFormat;
- }
- else
- {
- // The original texture format is suitable for swizzle operations
- info.swizzleTexFormat = texFormat;
- info.swizzleSRVFormat = srvFormat;
- info.swizzleRTVFormat = rtvFormat;
- }
- }
- else
- {
- // Not possible to swizzle with this texture format since it is either unsized or GL_NONE
- info.swizzleTexFormat = DXGI_FORMAT_UNKNOWN;
- info.swizzleSRVFormat = DXGI_FORMAT_UNKNOWN;
- info.swizzleRTVFormat = DXGI_FORMAT_UNKNOWN;
- }
-
- // Check if there is an initialization function for this texture format
- static const InternalFormatInitializerMap initializerMap = BuildInternalFormatInitializerMap();
- InternalFormatInitializerMap::const_iterator initializerIter = initializerMap.find(internalFormat);
- info.dataInitializerFunction = (initializerIter != initializerMap.end()) ? initializerIter->second : NULL;
-
- // Gather all the load functions for this internal format
- static const D3D11LoadFunctionMap loadFunctions = BuildD3D11LoadFunctionMap();
- D3D11LoadFunctionMap::const_iterator loadFunctionIter = loadFunctions.find(internalFormat);
- if (loadFunctionIter != loadFunctions.end())
- {
- const std::vector<TypeLoadFunctionPair> &loadFunctionVector = loadFunctionIter->second;
- for (size_t i = 0; i < loadFunctionVector.size(); i++)
- {
- GLenum type = loadFunctionVector[i].first;
- LoadImageFunction function = loadFunctionVector[i].second;
- info.loadFunctions.insert(std::make_pair(type, function));
- }
- }
-
- map->insert(std::make_pair(internalFormat, info));
-}
-
-static D3D11ES3FormatMap BuildD3D11FormatMap()
-{
- D3D11ES3FormatMap map;
-
- // | GL internal format | D3D11 texture format | D3D11 SRV format | D3D11 RTV format | D3D11 DSV format |
- InsertD3D11FormatInfo(&map, GL_NONE, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_R8, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_R8_SNORM, DXGI_FORMAT_R8_SNORM, DXGI_FORMAT_R8_SNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RG8, DXGI_FORMAT_R8G8_UNORM, DXGI_FORMAT_R8G8_UNORM, DXGI_FORMAT_R8G8_UNORM, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RG8_SNORM, DXGI_FORMAT_R8G8_SNORM, DXGI_FORMAT_R8G8_SNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGB8, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGB8_SNORM, DXGI_FORMAT_R8G8B8A8_SNORM, DXGI_FORMAT_R8G8B8A8_SNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGB565, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGBA4, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGB5_A1, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGBA8, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGBA8_SNORM, DXGI_FORMAT_R8G8B8A8_SNORM, DXGI_FORMAT_R8G8B8A8_SNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGB10_A2, DXGI_FORMAT_R10G10B10A2_UNORM, DXGI_FORMAT_R10G10B10A2_UNORM, DXGI_FORMAT_R10G10B10A2_UNORM, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGB10_A2UI, DXGI_FORMAT_R10G10B10A2_UINT, DXGI_FORMAT_R10G10B10A2_UINT, DXGI_FORMAT_R10G10B10A2_UINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_SRGB8, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_SRGB8_ALPHA8, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_R16F, DXGI_FORMAT_R16_FLOAT, DXGI_FORMAT_R16_FLOAT, DXGI_FORMAT_R16_FLOAT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RG16F, DXGI_FORMAT_R16G16_FLOAT, DXGI_FORMAT_R16G16_FLOAT, DXGI_FORMAT_R16G16_FLOAT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGB16F, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGBA16F, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_R32F, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RG32F, DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGB32F, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGBA32F, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_R11F_G11F_B10F, DXGI_FORMAT_R11G11B10_FLOAT, DXGI_FORMAT_R11G11B10_FLOAT, DXGI_FORMAT_R11G11B10_FLOAT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGB9_E5, DXGI_FORMAT_R9G9B9E5_SHAREDEXP, DXGI_FORMAT_R9G9B9E5_SHAREDEXP, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_R8I, DXGI_FORMAT_R8_SINT, DXGI_FORMAT_R8_SINT, DXGI_FORMAT_R8_SINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_R8UI, DXGI_FORMAT_R8_UINT, DXGI_FORMAT_R8_UINT, DXGI_FORMAT_R8_UINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_R16I, DXGI_FORMAT_R16_SINT, DXGI_FORMAT_R16_SINT, DXGI_FORMAT_R16_SINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_R16UI, DXGI_FORMAT_R16_UINT, DXGI_FORMAT_R16_UINT, DXGI_FORMAT_R16_UINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_R32I, DXGI_FORMAT_R32_SINT, DXGI_FORMAT_R32_SINT, DXGI_FORMAT_R32_SINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_R32UI, DXGI_FORMAT_R32_UINT, DXGI_FORMAT_R32_UINT, DXGI_FORMAT_R32_UINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RG8I, DXGI_FORMAT_R8G8_SINT, DXGI_FORMAT_R8G8_SINT, DXGI_FORMAT_R8G8_SINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RG8UI, DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RG16I, DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RG16UI, DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RG32I, DXGI_FORMAT_R32G32_SINT, DXGI_FORMAT_R32G32_SINT, DXGI_FORMAT_R32G32_SINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RG32UI, DXGI_FORMAT_R32G32_UINT, DXGI_FORMAT_R32G32_UINT, DXGI_FORMAT_R32G32_UINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGB8I, DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGB8UI, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGB16I, DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGB16UI, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGB32I, DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGB32UI, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGBA8I, DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGBA8UI, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGBA16I, DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGBA16UI, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGBA32I, DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGBA32UI, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_UNKNOWN);
-
- // Unsized formats, TODO: Are types of float and half float allowed for the unsized types? Would it change the DXGI format?
- InsertD3D11FormatInfo(&map, GL_ALPHA, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_LUMINANCE, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_LUMINANCE_ALPHA, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGB, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_RGBA, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_BGRA_EXT, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN);
-
- // From GL_EXT_texture_storage
- // | GL internal format | D3D11 texture format | D3D11 SRV format | D3D11 RTV format | D3D11 DSV format |
- InsertD3D11FormatInfo(&map, GL_ALPHA8_EXT, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN );
- InsertD3D11FormatInfo(&map, GL_LUMINANCE8_EXT, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN );
- InsertD3D11FormatInfo(&map, GL_ALPHA32F_EXT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN );
- InsertD3D11FormatInfo(&map, GL_LUMINANCE32F_EXT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN );
- InsertD3D11FormatInfo(&map, GL_ALPHA16F_EXT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN );
- InsertD3D11FormatInfo(&map, GL_LUMINANCE16F_EXT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN );
- InsertD3D11FormatInfo(&map, GL_LUMINANCE8_ALPHA8_EXT, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN );
- InsertD3D11FormatInfo(&map, GL_LUMINANCE_ALPHA32F_EXT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN );
- InsertD3D11FormatInfo(&map, GL_LUMINANCE_ALPHA16F_EXT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN );
- InsertD3D11FormatInfo(&map, GL_BGRA8_EXT, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN );
- InsertD3D11FormatInfo(&map, GL_BGRA4_ANGLEX, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN );
- InsertD3D11FormatInfo(&map, GL_BGR5_A1_ANGLEX, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN );
-
- // Depth stencil formats
- InsertD3D11FormatInfo(&map, GL_DEPTH_COMPONENT16, DXGI_FORMAT_R16_TYPELESS, DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D16_UNORM );
- InsertD3D11FormatInfo(&map, GL_DEPTH_COMPONENT24, DXGI_FORMAT_R24G8_TYPELESS, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT );
- InsertD3D11FormatInfo(&map, GL_DEPTH_COMPONENT32F, DXGI_FORMAT_R32_TYPELESS, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D32_FLOAT );
- InsertD3D11FormatInfo(&map, GL_DEPTH24_STENCIL8, DXGI_FORMAT_R24G8_TYPELESS, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT );
- InsertD3D11FormatInfo(&map, GL_DEPTH32F_STENCIL8, DXGI_FORMAT_R32G8X24_TYPELESS, DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D32_FLOAT_S8X24_UINT);
- InsertD3D11FormatInfo(&map, GL_STENCIL_INDEX8, DXGI_FORMAT_R24G8_TYPELESS, DXGI_FORMAT_X24_TYPELESS_G8_UINT, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT );
-
- // From GL_ANGLE_depth_texture
- // Since D3D11 doesn't have a D32_UNORM format, use D24S8 which has comparable precision and matches the ES3 format.
- InsertD3D11FormatInfo(&map, GL_DEPTH_COMPONENT32_OES, DXGI_FORMAT_R24G8_TYPELESS, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT);
-
- // Compressed formats, From ES 3.0.1 spec, table 3.16
- // | GL internal format | D3D11 texture format | D3D11 SRV format | D3D11 RTV format | D3D11 DSV format |
- InsertD3D11FormatInfo(&map, GL_COMPRESSED_R11_EAC, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_COMPRESSED_SIGNED_R11_EAC, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_COMPRESSED_RG11_EAC, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_COMPRESSED_SIGNED_RG11_EAC, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_COMPRESSED_RGB8_ETC2, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_COMPRESSED_SRGB8_ETC2, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_COMPRESSED_RGBA8_ETC2_EAC, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
-
- // From GL_EXT_texture_compression_dxt1
- InsertD3D11FormatInfo(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
- InsertD3D11FormatInfo(&map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
-
- // From GL_ANGLE_texture_compression_dxt3
- InsertD3D11FormatInfo(&map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
-
- // From GL_ANGLE_texture_compression_dxt5
- InsertD3D11FormatInfo(&map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
-
- return map;
-}
-
-const TextureFormat &GetTextureFormatInfo(GLenum internalFormat)
-{
- static const D3D11ES3FormatMap formatMap = BuildD3D11FormatMap();
- D3D11ES3FormatMap::const_iterator iter = formatMap.find(internalFormat);
- if (iter != formatMap.end())
- {
- return iter->second;
- }
- else
- {
- static const TextureFormat defaultInfo;
- return defaultInfo;
- }
-}
-
-typedef std::map<gl::VertexFormat, VertexFormat> D3D11VertexFormatInfoMap;
-typedef std::pair<gl::VertexFormat, VertexFormat> D3D11VertexFormatPair;
-
-VertexFormat::VertexFormat()
- : conversionType(VERTEX_CONVERT_NONE),
- nativeFormat(DXGI_FORMAT_UNKNOWN),
- copyFunction(NULL)
-{
-}
-
-static void AddVertexFormatInfo(D3D11VertexFormatInfoMap *map, GLenum inputType, GLboolean normalized, GLuint componentCount,
- VertexConversionType conversionType, DXGI_FORMAT nativeFormat, VertexCopyFunction copyFunction)
-{
- gl::VertexFormat inputFormat(inputType, normalized, componentCount, false);
-
- VertexFormat info;
- info.conversionType = conversionType;
- info.nativeFormat = nativeFormat;
- info.copyFunction = copyFunction;
-
- map->insert(D3D11VertexFormatPair(inputFormat, info));
-}
-
-static void AddIntegerVertexFormatInfo(D3D11VertexFormatInfoMap *map, GLenum inputType, GLuint componentCount,
- VertexConversionType conversionType, DXGI_FORMAT nativeFormat, VertexCopyFunction copyFunction)
-{
- gl::VertexFormat inputFormat(inputType, GL_FALSE, componentCount, true);
-
- VertexFormat info;
- info.conversionType = conversionType;
- info.nativeFormat = nativeFormat;
- info.copyFunction = copyFunction;
-
- map->insert(D3D11VertexFormatPair(inputFormat, info));
-}
-
-static D3D11VertexFormatInfoMap BuildD3D11VertexFormatInfoMap()
-{
- D3D11VertexFormatInfoMap map;
-
- // TODO: column legend
-
- //
- // Float formats
- //
-
- // GL_BYTE -- un-normalized
- AddVertexFormatInfo(&map, GL_BYTE, GL_FALSE, 1, VERTEX_CONVERT_GPU, DXGI_FORMAT_R8_SINT, &CopyNativeVertexData<GLbyte, 1, 0>);
- AddVertexFormatInfo(&map, GL_BYTE, GL_FALSE, 2, VERTEX_CONVERT_GPU, DXGI_FORMAT_R8G8_SINT, &CopyNativeVertexData<GLbyte, 2, 0>);
- AddVertexFormatInfo(&map, GL_BYTE, GL_FALSE, 3, VERTEX_CONVERT_BOTH, DXGI_FORMAT_R8G8B8A8_SINT, &CopyNativeVertexData<GLbyte, 3, 1>);
- AddVertexFormatInfo(&map, GL_BYTE, GL_FALSE, 4, VERTEX_CONVERT_GPU, DXGI_FORMAT_R8G8B8A8_SINT, &CopyNativeVertexData<GLbyte, 4, 0>);
-
- // GL_BYTE -- normalized
- AddVertexFormatInfo(&map, GL_BYTE, GL_TRUE, 1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_SNORM, &CopyNativeVertexData<GLbyte, 1, 0>);
- AddVertexFormatInfo(&map, GL_BYTE, GL_TRUE, 2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_SNORM, &CopyNativeVertexData<GLbyte, 2, 0>);
- AddVertexFormatInfo(&map, GL_BYTE, GL_TRUE, 3, VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_SNORM, &CopyNativeVertexData<GLbyte, 3, INT8_MAX>);
- AddVertexFormatInfo(&map, GL_BYTE, GL_TRUE, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_SNORM, &CopyNativeVertexData<GLbyte, 4, 0>);
-
- // GL_UNSIGNED_BYTE -- un-normalized
- AddVertexFormatInfo(&map, GL_UNSIGNED_BYTE, GL_FALSE, 1, VERTEX_CONVERT_GPU, DXGI_FORMAT_R8_UINT, &CopyNativeVertexData<GLubyte, 1, 0>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_BYTE, GL_FALSE, 2, VERTEX_CONVERT_GPU, DXGI_FORMAT_R8G8_UINT, &CopyNativeVertexData<GLubyte, 2, 0>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_BYTE, GL_FALSE, 3, VERTEX_CONVERT_BOTH, DXGI_FORMAT_R8G8B8A8_UINT, &CopyNativeVertexData<GLubyte, 3, 1>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_BYTE, GL_FALSE, 4, VERTEX_CONVERT_GPU, DXGI_FORMAT_R8G8B8A8_UINT, &CopyNativeVertexData<GLubyte, 4, 0>);
-
- // GL_UNSIGNED_BYTE -- normalized
- AddVertexFormatInfo(&map, GL_UNSIGNED_BYTE, GL_TRUE, 1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_UNORM, &CopyNativeVertexData<GLubyte, 1, 0>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_BYTE, GL_TRUE, 2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_UNORM, &CopyNativeVertexData<GLubyte, 2, 0>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_BYTE, GL_TRUE, 3, VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_UNORM, &CopyNativeVertexData<GLubyte, 3, UINT8_MAX>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_BYTE, GL_TRUE, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_UNORM, &CopyNativeVertexData<GLubyte, 4, 0>);
-
- // GL_SHORT -- un-normalized
- AddVertexFormatInfo(&map, GL_SHORT, GL_FALSE, 1, VERTEX_CONVERT_GPU, DXGI_FORMAT_R16_SINT, &CopyNativeVertexData<GLshort, 1, 0>);
- AddVertexFormatInfo(&map, GL_SHORT, GL_FALSE, 2, VERTEX_CONVERT_GPU, DXGI_FORMAT_R16G16_SINT, &CopyNativeVertexData<GLshort, 2, 0>);
- AddVertexFormatInfo(&map, GL_SHORT, GL_FALSE, 3, VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16B16A16_SINT, &CopyNativeVertexData<GLshort, 4, 1>);
- AddVertexFormatInfo(&map, GL_SHORT, GL_FALSE, 4, VERTEX_CONVERT_GPU, DXGI_FORMAT_R16G16B16A16_SINT, &CopyNativeVertexData<GLshort, 4, 0>);
-
- // GL_SHORT -- normalized
- AddVertexFormatInfo(&map, GL_SHORT, GL_TRUE, 1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_SNORM, &CopyNativeVertexData<GLshort, 1, 0>);
- AddVertexFormatInfo(&map, GL_SHORT, GL_TRUE, 2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_SNORM, &CopyNativeVertexData<GLshort, 2, 0>);
- AddVertexFormatInfo(&map, GL_SHORT, GL_TRUE, 3, VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SNORM, &CopyNativeVertexData<GLshort, 3, INT16_MAX>);
- AddVertexFormatInfo(&map, GL_SHORT, GL_TRUE, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_SNORM, &CopyNativeVertexData<GLshort, 4, 0>);
-
- // GL_UNSIGNED_SHORT -- un-normalized
- AddVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_FALSE, 1, VERTEX_CONVERT_GPU, DXGI_FORMAT_R16_UINT, &CopyNativeVertexData<GLushort, 1, 0>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_FALSE, 2, VERTEX_CONVERT_GPU, DXGI_FORMAT_R16G16_UINT, &CopyNativeVertexData<GLushort, 2, 0>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_FALSE, 3, VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16B16A16_UINT, &CopyNativeVertexData<GLushort, 3, 1>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_FALSE, 4, VERTEX_CONVERT_GPU, DXGI_FORMAT_R16G16B16A16_UINT, &CopyNativeVertexData<GLushort, 4, 0>);
-
- // GL_UNSIGNED_SHORT -- normalized
- AddVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_TRUE, 1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_UNORM, &CopyNativeVertexData<GLushort, 1, 0>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_TRUE, 2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_UNORM, &CopyNativeVertexData<GLushort, 2, 0>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_TRUE, 3, VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_UNORM, &CopyNativeVertexData<GLushort, 3, UINT16_MAX>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_TRUE, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_UNORM, &CopyNativeVertexData<GLushort, 4, 0>);
-
- // GL_INT -- un-normalized
- AddVertexFormatInfo(&map, GL_INT, GL_FALSE, 1, VERTEX_CONVERT_GPU, DXGI_FORMAT_R32_SINT, &CopyNativeVertexData<GLint, 1, 0>);
- AddVertexFormatInfo(&map, GL_INT, GL_FALSE, 2, VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32_SINT, &CopyNativeVertexData<GLint, 2, 0>);
- AddVertexFormatInfo(&map, GL_INT, GL_FALSE, 3, VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32B32_SINT, &CopyNativeVertexData<GLint, 3, 0>);
- AddVertexFormatInfo(&map, GL_INT, GL_FALSE, 4, VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32B32A32_SINT, &CopyNativeVertexData<GLint, 4, 0>);
-
- // GL_INT -- normalized
- AddVertexFormatInfo(&map, GL_INT, GL_TRUE, 1, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32_FLOAT, &CopyTo32FVertexData<GLint, 1, true>);
- AddVertexFormatInfo(&map, GL_INT, GL_TRUE, 2, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, &CopyTo32FVertexData<GLint, 2, true>);
- AddVertexFormatInfo(&map, GL_INT, GL_TRUE, 3, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT, &CopyTo32FVertexData<GLint, 3, true>);
- AddVertexFormatInfo(&map, GL_INT, GL_TRUE, 4, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, &CopyTo32FVertexData<GLint, 4, true>);
-
- // GL_UNSIGNED_INT -- un-normalized
- AddVertexFormatInfo(&map, GL_UNSIGNED_INT, GL_FALSE, 1, VERTEX_CONVERT_GPU, DXGI_FORMAT_R32_UINT, &CopyNativeVertexData<GLuint, 1, 0>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_INT, GL_FALSE, 2, VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32_UINT, &CopyNativeVertexData<GLuint, 2, 0>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_INT, GL_FALSE, 3, VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32B32_UINT, &CopyNativeVertexData<GLuint, 3, 0>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_INT, GL_FALSE, 4, VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32B32A32_UINT, &CopyNativeVertexData<GLuint, 4, 0>);
-
- // GL_UNSIGNED_INT -- normalized
- AddVertexFormatInfo(&map, GL_UNSIGNED_INT, GL_TRUE, 1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32_FLOAT, &CopyTo32FVertexData<GLuint, 1, true>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_INT, GL_TRUE, 2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32_FLOAT, &CopyTo32FVertexData<GLuint, 2, true>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_INT, GL_TRUE, 3, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT, &CopyTo32FVertexData<GLuint, 3, true>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_INT, GL_TRUE, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32A32_FLOAT, &CopyTo32FVertexData<GLuint, 4, true>);
-
- // GL_FIXED
- AddVertexFormatInfo(&map, GL_FIXED, GL_FALSE, 1, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32_FLOAT, &Copy32FixedTo32FVertexData<1>);
- AddVertexFormatInfo(&map, GL_FIXED, GL_FALSE, 2, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT, &Copy32FixedTo32FVertexData<2>);
- AddVertexFormatInfo(&map, GL_FIXED, GL_FALSE, 3, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT, &Copy32FixedTo32FVertexData<3>);
- AddVertexFormatInfo(&map, GL_FIXED, GL_FALSE, 4, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, &Copy32FixedTo32FVertexData<4>);
-
- // GL_HALF_FLOAT
- AddVertexFormatInfo(&map, GL_HALF_FLOAT, GL_FALSE, 1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_FLOAT, &CopyNativeVertexData<GLhalf, 1, 0>);
- AddVertexFormatInfo(&map, GL_HALF_FLOAT, GL_FALSE, 2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_FLOAT, &CopyNativeVertexData<GLhalf, 2, 0>);
- AddVertexFormatInfo(&map, GL_HALF_FLOAT, GL_FALSE, 3, VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_FLOAT, &CopyNativeVertexData<GLhalf, 3, gl::Float16One>);
- AddVertexFormatInfo(&map, GL_HALF_FLOAT, GL_FALSE, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_FLOAT, &CopyNativeVertexData<GLhalf, 4, 0>);
-
- // GL_FLOAT
- AddVertexFormatInfo(&map, GL_FLOAT, GL_FALSE, 1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32_FLOAT, &CopyNativeVertexData<GLfloat, 1, 0>);
- AddVertexFormatInfo(&map, GL_FLOAT, GL_FALSE, 2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32_FLOAT, &CopyNativeVertexData<GLfloat, 2, 0>);
- AddVertexFormatInfo(&map, GL_FLOAT, GL_FALSE, 3, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32_FLOAT, &CopyNativeVertexData<GLfloat, 3, 0>);
- AddVertexFormatInfo(&map, GL_FLOAT, GL_FALSE, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32A32_FLOAT, &CopyNativeVertexData<GLfloat, 4, 0>);
-
- // GL_INT_2_10_10_10_REV
- AddVertexFormatInfo(&map, GL_INT_2_10_10_10_REV, GL_FALSE, 4, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, &CopyXYZ10W2ToXYZW32FVertexData<true, false, true>);
- AddVertexFormatInfo(&map, GL_INT_2_10_10_10_REV, GL_TRUE, 4, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, &CopyXYZ10W2ToXYZW32FVertexData<true, true, true>);
-
- // GL_UNSIGNED_INT_2_10_10_10_REV
- AddVertexFormatInfo(&map, GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 4, VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT, &CopyXYZ10W2ToXYZW32FVertexData<false, false, true>);
- AddVertexFormatInfo(&map, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R10G10B10A2_UNORM, &CopyNativeVertexData<GLuint, 1, 0>);
-
- //
- // Integer Formats
- //
-
- // GL_BYTE
- AddIntegerVertexFormatInfo(&map, GL_BYTE, 1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_SINT, &CopyNativeVertexData<GLbyte, 1, 0>);
- AddIntegerVertexFormatInfo(&map, GL_BYTE, 2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_SINT, &CopyNativeVertexData<GLbyte, 2, 0>);
- AddIntegerVertexFormatInfo(&map, GL_BYTE, 3, VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_SINT, &CopyNativeVertexData<GLbyte, 3, 1>);
- AddIntegerVertexFormatInfo(&map, GL_BYTE, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_SINT, &CopyNativeVertexData<GLbyte, 4, 0>);
-
- // GL_UNSIGNED_BYTE
- AddIntegerVertexFormatInfo(&map, GL_UNSIGNED_BYTE, 1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_UINT, &CopyNativeVertexData<GLubyte, 1, 0>);
- AddIntegerVertexFormatInfo(&map, GL_UNSIGNED_BYTE, 2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_UINT, &CopyNativeVertexData<GLubyte, 2, 0>);
- AddIntegerVertexFormatInfo(&map, GL_UNSIGNED_BYTE, 3, VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_UINT, &CopyNativeVertexData<GLubyte, 3, 1>);
- AddIntegerVertexFormatInfo(&map, GL_UNSIGNED_BYTE, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_UINT, &CopyNativeVertexData<GLubyte, 4, 0>);
-
- // GL_SHORT
- AddIntegerVertexFormatInfo(&map, GL_SHORT, 1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_SINT, &CopyNativeVertexData<GLshort, 1, 0>);
- AddIntegerVertexFormatInfo(&map, GL_SHORT, 2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_SINT, &CopyNativeVertexData<GLshort, 2, 0>);
- AddIntegerVertexFormatInfo(&map, GL_SHORT, 3, VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SINT, &CopyNativeVertexData<GLshort, 3, 1>);
- AddIntegerVertexFormatInfo(&map, GL_SHORT, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_SINT, &CopyNativeVertexData<GLshort, 4, 0>);
-
- // GL_UNSIGNED_SHORT
- AddIntegerVertexFormatInfo(&map, GL_UNSIGNED_SHORT, 1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_UINT, &CopyNativeVertexData<GLushort, 1, 0>);
- AddIntegerVertexFormatInfo(&map, GL_UNSIGNED_SHORT, 2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_UINT, &CopyNativeVertexData<GLushort, 2, 0>);
- AddIntegerVertexFormatInfo(&map, GL_UNSIGNED_SHORT, 3, VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_UINT, &CopyNativeVertexData<GLushort, 3, 1>);
- AddIntegerVertexFormatInfo(&map, GL_UNSIGNED_SHORT, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_UINT, &CopyNativeVertexData<GLushort, 4, 0>);
-
- // GL_INT
- AddIntegerVertexFormatInfo(&map, GL_INT, 1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32_SINT, &CopyNativeVertexData<GLint, 1, 0>);
- AddIntegerVertexFormatInfo(&map, GL_INT, 2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32_SINT, &CopyNativeVertexData<GLint, 2, 0>);
- AddIntegerVertexFormatInfo(&map, GL_INT, 3, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32_SINT, &CopyNativeVertexData<GLint, 3, 0>);
- AddIntegerVertexFormatInfo(&map, GL_INT, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32A32_SINT, &CopyNativeVertexData<GLint, 4, 0>);
-
- // GL_UNSIGNED_INT
- AddIntegerVertexFormatInfo(&map, GL_UNSIGNED_INT, 1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32_SINT, &CopyNativeVertexData<GLuint, 1, 0>);
- AddIntegerVertexFormatInfo(&map, GL_UNSIGNED_INT, 2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32_SINT, &CopyNativeVertexData<GLuint, 2, 0>);
- AddIntegerVertexFormatInfo(&map, GL_UNSIGNED_INT, 3, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32_SINT, &CopyNativeVertexData<GLuint, 3, 0>);
- AddIntegerVertexFormatInfo(&map, GL_UNSIGNED_INT, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32A32_SINT, &CopyNativeVertexData<GLuint, 4, 0>);
-
- // GL_INT_2_10_10_10_REV
- AddIntegerVertexFormatInfo(&map, GL_INT_2_10_10_10_REV, 4, VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SINT, &CopyXYZ10W2ToXYZW32FVertexData<true, true, false>);
-
- // GL_UNSIGNED_INT_2_10_10_10_REV
- AddIntegerVertexFormatInfo(&map, GL_UNSIGNED_INT_2_10_10_10_REV, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R10G10B10A2_UINT, &CopyNativeVertexData<GLuint, 1, 0>);
-
- return map;
-}
-
-const VertexFormat &GetVertexFormatInfo(const gl::VertexFormat &vertexFormat)
-{
- static const D3D11VertexFormatInfoMap vertexFormatMap = BuildD3D11VertexFormatInfoMap();
-
- D3D11VertexFormatInfoMap::const_iterator iter = vertexFormatMap.find(vertexFormat);
- if (iter != vertexFormatMap.end())
- {
- return iter->second;
- }
- else
- {
- static const VertexFormat defaultInfo;
- return defaultInfo;
- }
-}
-
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.h
deleted file mode 100644
index ea11aaa74c..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.h
+++ /dev/null
@@ -1,84 +0,0 @@
-//
-// Copyright (c) 2013-2014 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.
-//
-
-// formatutils11.h: Queries for GL image formats and their translations to D3D11
-// formats.
-
-#ifndef LIBGLESV2_RENDERER_FORMATUTILS11_H_
-#define LIBGLESV2_RENDERER_FORMATUTILS11_H_
-
-#include "libGLESv2/formatutils.h"
-
-#include <map>
-
-namespace rx
-{
-
-namespace d3d11
-{
-
-typedef std::map<std::pair<GLenum, GLenum>, ColorCopyFunction> FastCopyFunctionMap;
-
-struct DXGIFormat
-{
- DXGIFormat();
-
- GLuint pixelBytes;
- GLuint blockWidth;
- GLuint blockHeight;
-
- GLuint depthBits;
- GLuint depthOffset;
- GLuint stencilBits;
- GLuint stencilOffset;
-
- GLenum internalFormat;
- GLenum componentType;
-
- MipGenerationFunction mipGenerationFunction;
- ColorReadFunction colorReadFunction;
-
- FastCopyFunctionMap fastCopyFunctions;
- ColorCopyFunction getFastCopyFunction(GLenum format, GLenum type) const;
-};
-const DXGIFormat &GetDXGIFormatInfo(DXGI_FORMAT format);
-
-struct TextureFormat
-{
- TextureFormat();
-
- DXGI_FORMAT texFormat;
- DXGI_FORMAT srvFormat;
- DXGI_FORMAT rtvFormat;
- DXGI_FORMAT dsvFormat;
- DXGI_FORMAT renderFormat;
-
- DXGI_FORMAT swizzleTexFormat;
- DXGI_FORMAT swizzleSRVFormat;
- DXGI_FORMAT swizzleRTVFormat;
-
- InitializeTextureDataFunction dataInitializerFunction;
-
- typedef std::map<GLenum, LoadImageFunction> LoadFunctionMap;
- LoadFunctionMap loadFunctions;
-};
-const TextureFormat &GetTextureFormatInfo(GLenum internalFormat);
-
-struct VertexFormat
-{
- VertexFormat();
-
- VertexConversionType conversionType;
- DXGI_FORMAT nativeFormat;
- VertexCopyFunction copyFunction;
-};
-const VertexFormat &GetVertexFormatInfo(const gl::VertexFormat &vertexFormat);
-
-}
-
-}
-
-#endif // LIBGLESV2_RENDERER_FORMATUTILS11_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.cpp
deleted file mode 100644
index 121aa3bbad..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.cpp
+++ /dev/null
@@ -1,1228 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// renderer11_utils.cpp: Conversion functions and other utility routines
-// specific to the D3D11 renderer.
-
-#include "libGLESv2/renderer/d3d/d3d11/renderer11_utils.h"
-#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h"
-#include "libGLESv2/renderer/d3d/d3d11/RenderTarget11.h"
-#include "libGLESv2/renderer/Workarounds.h"
-#include "libGLESv2/ProgramBinary.h"
-#include "libGLESv2/Framebuffer.h"
-
-#include "common/debug.h"
-
-#include <algorithm>
-
-#ifndef D3D_FL9_1_DEFAULT_MAX_ANISOTROPY
-# define D3D_FL9_1_DEFAULT_MAX_ANISOTROPY 2
-#endif
-#ifndef D3D_FL9_1_SIMULTANEOUS_RENDER_TARGET_COUNT
-# define D3D_FL9_1_SIMULTANEOUS_RENDER_TARGET_COUNT 1
-#endif
-#ifndef D3D_FL9_3_SIMULTANEOUS_RENDER_TARGET_COUNT
-# define D3D_FL9_3_SIMULTANEOUS_RENDER_TARGET_COUNT 4
-#endif
-#ifndef D3D_FL9_1_IA_PRIMITIVE_MAX_COUNT
-# define D3D_FL9_1_IA_PRIMITIVE_MAX_COUNT 65535
-#endif
-#ifndef D3D_FL9_2_IA_PRIMITIVE_MAX_COUNT
-# define D3D_FL9_2_IA_PRIMITIVE_MAX_COUNT 1048575
-#endif
-#ifndef D3D_FL9_1_REQ_TEXTURECUBE_DIMENSION
-# define D3D_FL9_1_REQ_TEXTURECUBE_DIMENSION 512
-#endif
-#ifndef D3D_FL9_3_REQ_TEXTURECUBE_DIMENSION
-# define D3D_FL9_3_REQ_TEXTURECUBE_DIMENSION 4096
-#endif
-#ifndef D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION
-# define D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION 2048
-#endif
-#ifndef D3D_FL9_1_REQ_TEXTURE3D_U_V_OR_W_DIMENSION
-# define D3D_FL9_1_REQ_TEXTURE3D_U_V_OR_W_DIMENSION 256
-#endif
-#ifndef D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION
-# define D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION 4096
-#endif
-#ifndef D3D11_REQ_TEXTURECUBE_DIMENSION
-# define D3D11_REQ_TEXTURECUBE_DIMENSION 16384
-#endif
-#ifndef D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION
-# define D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION 2048
-#endif
-#ifndef D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION
-# define D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION 2048
-#endif
-#ifndef D3D11_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP
-# define D3D11_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP 32
-#endif
-#ifndef D3D11_REQ_DRAW_VERTEX_COUNT_2_TO_EXP
-# define D3D11_REQ_DRAW_VERTEX_COUNT_2_TO_EXP 32
-#endif
-#ifndef D3D10_1_STANDARD_VERTEX_ELEMENT_COUNT
-# define D3D10_1_STANDARD_VERTEX_ELEMENT_COUNT 32
-#endif
-#ifndef D3D11_STANDARD_VERTEX_ELEMENT_COUNT
-# define D3D11_STANDARD_VERTEX_ELEMENT_COUNT 32
-#endif
-#ifndef D3D10_1_SO_BUFFER_SLOT_COUNT
-# define D3D10_1_SO_BUFFER_SLOT_COUNT 4
-#endif
-#ifndef D3D11_SO_BUFFER_SLOT_COUNT
-# define D3D11_SO_BUFFER_SLOT_COUNT 4
-#endif
-#ifndef D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
-# define D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT 14
-#endif
-#ifndef D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
-# define D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT 16
-#endif
-#ifndef D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE
-# define D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE -8
-#endif
-#ifndef D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE
-# define D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE 7
-#endif
-#ifndef D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT
-# define D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT 4096
-#endif
-#ifndef D3D11_PS_INPUT_REGISTER_COUNT
-# define D3D11_PS_INPUT_REGISTER_COUNT 32
-#endif
-#ifndef D3D10_1_VS_OUTPUT_REGISTER_COUNT
-# define D3D10_1_VS_OUTPUT_REGISTER_COUNT 32
-#endif
-
-namespace rx
-{
-
-namespace gl_d3d11
-{
-
-D3D11_BLEND ConvertBlendFunc(GLenum glBlend, bool isAlpha)
-{
- D3D11_BLEND d3dBlend = D3D11_BLEND_ZERO;
-
- switch (glBlend)
- {
- case GL_ZERO: d3dBlend = D3D11_BLEND_ZERO; break;
- case GL_ONE: d3dBlend = D3D11_BLEND_ONE; break;
- case GL_SRC_COLOR: d3dBlend = (isAlpha ? D3D11_BLEND_SRC_ALPHA : D3D11_BLEND_SRC_COLOR); break;
- case GL_ONE_MINUS_SRC_COLOR: d3dBlend = (isAlpha ? D3D11_BLEND_INV_SRC_ALPHA : D3D11_BLEND_INV_SRC_COLOR); break;
- case GL_DST_COLOR: d3dBlend = (isAlpha ? D3D11_BLEND_DEST_ALPHA : D3D11_BLEND_DEST_COLOR); break;
- case GL_ONE_MINUS_DST_COLOR: d3dBlend = (isAlpha ? D3D11_BLEND_INV_DEST_ALPHA : D3D11_BLEND_INV_DEST_COLOR); break;
- case GL_SRC_ALPHA: d3dBlend = D3D11_BLEND_SRC_ALPHA; break;
- case GL_ONE_MINUS_SRC_ALPHA: d3dBlend = D3D11_BLEND_INV_SRC_ALPHA; break;
- case GL_DST_ALPHA: d3dBlend = D3D11_BLEND_DEST_ALPHA; break;
- case GL_ONE_MINUS_DST_ALPHA: d3dBlend = D3D11_BLEND_INV_DEST_ALPHA; break;
- case GL_CONSTANT_COLOR: d3dBlend = D3D11_BLEND_BLEND_FACTOR; break;
- case GL_ONE_MINUS_CONSTANT_COLOR: d3dBlend = D3D11_BLEND_INV_BLEND_FACTOR; break;
- case GL_CONSTANT_ALPHA: d3dBlend = D3D11_BLEND_BLEND_FACTOR; break;
- case GL_ONE_MINUS_CONSTANT_ALPHA: d3dBlend = D3D11_BLEND_INV_BLEND_FACTOR; break;
- case GL_SRC_ALPHA_SATURATE: d3dBlend = D3D11_BLEND_SRC_ALPHA_SAT; break;
- default: UNREACHABLE();
- }
-
- return d3dBlend;
-}
-
-D3D11_BLEND_OP ConvertBlendOp(GLenum glBlendOp)
-{
- D3D11_BLEND_OP d3dBlendOp = D3D11_BLEND_OP_ADD;
-
- switch (glBlendOp)
- {
- case GL_FUNC_ADD: d3dBlendOp = D3D11_BLEND_OP_ADD; break;
- case GL_FUNC_SUBTRACT: d3dBlendOp = D3D11_BLEND_OP_SUBTRACT; break;
- case GL_FUNC_REVERSE_SUBTRACT: d3dBlendOp = D3D11_BLEND_OP_REV_SUBTRACT; break;
- case GL_MIN: d3dBlendOp = D3D11_BLEND_OP_MIN; break;
- case GL_MAX: d3dBlendOp = D3D11_BLEND_OP_MAX; break;
- default: UNREACHABLE();
- }
-
- return d3dBlendOp;
-}
-
-UINT8 ConvertColorMask(bool red, bool green, bool blue, bool alpha)
-{
- UINT8 mask = 0;
- if (red)
- {
- mask |= D3D11_COLOR_WRITE_ENABLE_RED;
- }
- if (green)
- {
- mask |= D3D11_COLOR_WRITE_ENABLE_GREEN;
- }
- if (blue)
- {
- mask |= D3D11_COLOR_WRITE_ENABLE_BLUE;
- }
- if (alpha)
- {
- mask |= D3D11_COLOR_WRITE_ENABLE_ALPHA;
- }
- return mask;
-}
-
-D3D11_CULL_MODE ConvertCullMode(bool cullEnabled, GLenum cullMode)
-{
- D3D11_CULL_MODE cull = D3D11_CULL_NONE;
-
- if (cullEnabled)
- {
- switch (cullMode)
- {
- case GL_FRONT: cull = D3D11_CULL_FRONT; break;
- case GL_BACK: cull = D3D11_CULL_BACK; break;
- case GL_FRONT_AND_BACK: cull = D3D11_CULL_NONE; break;
- default: UNREACHABLE();
- }
- }
- else
- {
- cull = D3D11_CULL_NONE;
- }
-
- return cull;
-}
-
-D3D11_COMPARISON_FUNC ConvertComparison(GLenum comparison)
-{
- D3D11_COMPARISON_FUNC d3dComp = D3D11_COMPARISON_NEVER;
- switch (comparison)
- {
- case GL_NEVER: d3dComp = D3D11_COMPARISON_NEVER; break;
- case GL_ALWAYS: d3dComp = D3D11_COMPARISON_ALWAYS; break;
- case GL_LESS: d3dComp = D3D11_COMPARISON_LESS; break;
- case GL_LEQUAL: d3dComp = D3D11_COMPARISON_LESS_EQUAL; break;
- case GL_EQUAL: d3dComp = D3D11_COMPARISON_EQUAL; break;
- case GL_GREATER: d3dComp = D3D11_COMPARISON_GREATER; break;
- case GL_GEQUAL: d3dComp = D3D11_COMPARISON_GREATER_EQUAL; break;
- case GL_NOTEQUAL: d3dComp = D3D11_COMPARISON_NOT_EQUAL; break;
- default: UNREACHABLE();
- }
-
- return d3dComp;
-}
-
-D3D11_DEPTH_WRITE_MASK ConvertDepthMask(bool depthWriteEnabled)
-{
- return depthWriteEnabled ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
-}
-
-UINT8 ConvertStencilMask(GLuint stencilmask)
-{
- return static_cast<UINT8>(stencilmask);
-}
-
-D3D11_STENCIL_OP ConvertStencilOp(GLenum stencilOp)
-{
- D3D11_STENCIL_OP d3dStencilOp = D3D11_STENCIL_OP_KEEP;
-
- switch (stencilOp)
- {
- case GL_ZERO: d3dStencilOp = D3D11_STENCIL_OP_ZERO; break;
- case GL_KEEP: d3dStencilOp = D3D11_STENCIL_OP_KEEP; break;
- case GL_REPLACE: d3dStencilOp = D3D11_STENCIL_OP_REPLACE; break;
- case GL_INCR: d3dStencilOp = D3D11_STENCIL_OP_INCR_SAT; break;
- case GL_DECR: d3dStencilOp = D3D11_STENCIL_OP_DECR_SAT; break;
- case GL_INVERT: d3dStencilOp = D3D11_STENCIL_OP_INVERT; break;
- case GL_INCR_WRAP: d3dStencilOp = D3D11_STENCIL_OP_INCR; break;
- case GL_DECR_WRAP: d3dStencilOp = D3D11_STENCIL_OP_DECR; break;
- default: UNREACHABLE();
- }
-
- return d3dStencilOp;
-}
-
-D3D11_FILTER ConvertFilter(GLenum minFilter, GLenum magFilter, float maxAnisotropy, GLenum comparisonMode)
-{
- bool comparison = comparisonMode != GL_NONE;
-
- if (maxAnisotropy > 1.0f)
- {
- return D3D11_ENCODE_ANISOTROPIC_FILTER(static_cast<D3D11_COMPARISON_FUNC>(comparison));
- }
- else
- {
- D3D11_FILTER_TYPE dxMin = D3D11_FILTER_TYPE_POINT;
- D3D11_FILTER_TYPE dxMip = D3D11_FILTER_TYPE_POINT;
- switch (minFilter)
- {
- case GL_NEAREST: dxMin = D3D11_FILTER_TYPE_POINT; dxMip = D3D11_FILTER_TYPE_POINT; break;
- case GL_LINEAR: dxMin = D3D11_FILTER_TYPE_LINEAR; dxMip = D3D11_FILTER_TYPE_POINT; break;
- case GL_NEAREST_MIPMAP_NEAREST: dxMin = D3D11_FILTER_TYPE_POINT; dxMip = D3D11_FILTER_TYPE_POINT; break;
- case GL_LINEAR_MIPMAP_NEAREST: dxMin = D3D11_FILTER_TYPE_LINEAR; dxMip = D3D11_FILTER_TYPE_POINT; break;
- case GL_NEAREST_MIPMAP_LINEAR: dxMin = D3D11_FILTER_TYPE_POINT; dxMip = D3D11_FILTER_TYPE_LINEAR; break;
- case GL_LINEAR_MIPMAP_LINEAR: dxMin = D3D11_FILTER_TYPE_LINEAR; dxMip = D3D11_FILTER_TYPE_LINEAR; break;
- default: UNREACHABLE();
- }
-
- D3D11_FILTER_TYPE dxMag = D3D11_FILTER_TYPE_POINT;
- switch (magFilter)
- {
- case GL_NEAREST: dxMag = D3D11_FILTER_TYPE_POINT; break;
- case GL_LINEAR: dxMag = D3D11_FILTER_TYPE_LINEAR; break;
- default: UNREACHABLE();
- }
-
- return D3D11_ENCODE_BASIC_FILTER(dxMin, dxMag, dxMip, static_cast<D3D11_COMPARISON_FUNC>(comparison));
- }
-}
-
-D3D11_TEXTURE_ADDRESS_MODE ConvertTextureWrap(GLenum wrap)
-{
- switch (wrap)
- {
- case GL_REPEAT: return D3D11_TEXTURE_ADDRESS_WRAP;
- case GL_CLAMP_TO_EDGE: return D3D11_TEXTURE_ADDRESS_CLAMP;
- case GL_MIRRORED_REPEAT: return D3D11_TEXTURE_ADDRESS_MIRROR;
- default: UNREACHABLE();
- }
-
- return D3D11_TEXTURE_ADDRESS_WRAP;
-}
-
-D3D11_QUERY ConvertQueryType(GLenum queryType)
-{
- switch (queryType)
- {
- case GL_ANY_SAMPLES_PASSED_EXT:
- case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: return D3D11_QUERY_OCCLUSION;
- case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: return D3D11_QUERY_SO_STATISTICS;
- default: UNREACHABLE(); return D3D11_QUERY_EVENT;
- }
-}
-
-}
-
-
-namespace d3d11_gl
-{
-
-static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, ID3D11Device *device)
-{
- gl::TextureCaps textureCaps;
-
- const d3d11::TextureFormat &formatInfo = d3d11::GetTextureFormatInfo(internalFormat);
-
- UINT formatSupport;
- if (SUCCEEDED(device->CheckFormatSupport(formatInfo.texFormat, &formatSupport)))
- {
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
- if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0)
- {
- textureCaps.texturable = ((formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE2D) != 0);
- }
- else
- {
- textureCaps.texturable = ((formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE2D) != 0) &&
- ((formatSupport & D3D11_FORMAT_SUPPORT_TEXTURECUBE) != 0) &&
- ((formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE3D) != 0);
- }
- }
-
- if (SUCCEEDED(device->CheckFormatSupport(formatInfo.renderFormat, &formatSupport)) &&
- ((formatSupport & D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET) != 0))
- {
- for (size_t sampleCount = 1; sampleCount <= D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT; sampleCount++)
- {
- UINT qualityCount = 0;
- if (SUCCEEDED(device->CheckMultisampleQualityLevels(formatInfo.renderFormat, sampleCount, &qualityCount)) &&
- qualityCount > 0)
- {
- textureCaps.sampleCounts.insert(sampleCount);
- }
- }
- }
-
- textureCaps.filterable = SUCCEEDED(device->CheckFormatSupport(formatInfo.srvFormat, &formatSupport)) &&
- ((formatSupport & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE)) != 0;
- textureCaps.renderable = (SUCCEEDED(device->CheckFormatSupport(formatInfo.rtvFormat, &formatSupport)) &&
- ((formatSupport & D3D11_FORMAT_SUPPORT_RENDER_TARGET)) != 0) ||
- (SUCCEEDED(device->CheckFormatSupport(formatInfo.dsvFormat, &formatSupport)) &&
- ((formatSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL) != 0));
-
- return textureCaps;
-}
-
-static bool GetNPOTTextureSupport(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0:
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return true;
-
- // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476876.aspx
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return true; // Provided that mipmaps & wrap modes are not used
-
- default: UNREACHABLE(); return false;
- }
-}
-
-static float GetMaximumAnisotropy(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_MAX_MAXANISOTROPY;
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return D3D10_MAX_MAXANISOTROPY;
-
- // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476876.aspx
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2: return 16;
-
- case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_DEFAULT_MAX_ANISOTROPY;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static bool GetOcclusionQuerySupport(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0:
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return true;
-
- // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476150.aspx ID3D11Device::CreateQuery
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2: return true;
- case D3D_FEATURE_LEVEL_9_1: return false;
-
- default: UNREACHABLE(); return false;
- }
-}
-
-static bool GetEventQuerySupport(D3D_FEATURE_LEVEL featureLevel)
-{
- // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476150.aspx ID3D11Device::CreateQuery
-
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0:
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0:
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return true;
-
- default: UNREACHABLE(); return false;
- }
-}
-
-static bool GetInstancingSupport(D3D_FEATURE_LEVEL featureLevel)
-{
- // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476150.aspx ID3D11Device::CreateInputLayout
-
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0:
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0:
- case D3D_FEATURE_LEVEL_9_3: return true;
-
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return false;
-
- default: UNREACHABLE(); return false;
- }
-}
-
-static bool GetDerivativeInstructionSupport(D3D_FEATURE_LEVEL featureLevel)
-{
- // http://msdn.microsoft.com/en-us/library/windows/desktop/bb509588.aspx states that shader model
- // ps_2_x is required for the ddx (and other derivative functions).
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ff476876.aspx states that feature level
- // 9.3 supports shader model ps_2_x.
-
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0:
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0:
- case D3D_FEATURE_LEVEL_9_3: return true;
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return false;
-
- default: UNREACHABLE(); return false;
- }
-}
-
-static size_t GetMaximumSimultaneousRenderTargets(D3D_FEATURE_LEVEL featureLevel)
-{
- // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476150.aspx ID3D11Device::CreateInputLayout
-
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT;
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT;
-
- case D3D_FEATURE_LEVEL_9_3: return D3D_FL9_3_SIMULTANEOUS_RENDER_TARGET_COUNT;
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_SIMULTANEOUS_RENDER_TARGET_COUNT;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximum2DTextureSize(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION;
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION;
-
- case D3D_FEATURE_LEVEL_9_3: return D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION;
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximumCubeMapTextureSize(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURECUBE_DIMENSION;
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_TEXTURECUBE_DIMENSION;
-
- case D3D_FEATURE_LEVEL_9_3: return D3D_FL9_3_REQ_TEXTURECUBE_DIMENSION;
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_REQ_TEXTURECUBE_DIMENSION;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximum2DTextureArraySize(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION;
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION;
-
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 0;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximum3DTextureSize(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION;
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION;
-
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_REQ_TEXTURE3D_U_V_OR_W_DIMENSION;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximumViewportSize(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_VIEWPORT_BOUNDS_MAX;
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return D3D10_VIEWPORT_BOUNDS_MAX;
-
- // No constants for D3D9 viewport size limits, use the maximum texture sizes
- case D3D_FEATURE_LEVEL_9_3: return D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION;
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximumDrawIndexedIndexCount(D3D_FEATURE_LEVEL featureLevel)
-{
- // D3D11 allows up to 2^32 elements, but we report max signed int for convenience since that's what's
- // returned from glGetInteger
- META_ASSERT(D3D11_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP == 32);
- META_ASSERT(D3D10_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP == 32);
-
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0:
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return std::numeric_limits<GLint>::max();
-
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2: return D3D_FL9_2_IA_PRIMITIVE_MAX_COUNT;
- case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_IA_PRIMITIVE_MAX_COUNT;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximumDrawVertexCount(D3D_FEATURE_LEVEL featureLevel)
-{
- // D3D11 allows up to 2^32 elements, but we report max signed int for convenience since that's what's
- // returned from glGetInteger
- META_ASSERT(D3D11_REQ_DRAW_VERTEX_COUNT_2_TO_EXP == 32);
- META_ASSERT(D3D10_REQ_DRAW_VERTEX_COUNT_2_TO_EXP == 32);
-
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0:
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return std::numeric_limits<GLint>::max();
-
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2: return D3D_FL9_2_IA_PRIMITIVE_MAX_COUNT;
- case D3D_FEATURE_LEVEL_9_1: return D3D_FL9_1_IA_PRIMITIVE_MAX_COUNT;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximumVertexInputSlots(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_STANDARD_VERTEX_ELEMENT_COUNT;
-
- case D3D_FEATURE_LEVEL_10_1: return D3D10_1_STANDARD_VERTEX_ELEMENT_COUNT;
- case D3D_FEATURE_LEVEL_10_0: return D3D10_STANDARD_VERTEX_ELEMENT_COUNT;
-
- // From http://http://msdn.microsoft.com/en-us/library/windows/desktop/ff476876.aspx "Max Input Slots"
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 16;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximumVertexUniformVectors(D3D_FEATURE_LEVEL featureLevel)
-{
- // TODO(geofflang): Remove hard-coded limit once the gl-uniform-arrays test can pass
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return 1024; // D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT;
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return 1024; // D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT;
-
- // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476149.aspx ID3D11DeviceContext::VSSetConstantBuffers
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 255;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetReservedVertexUniformBuffers()
-{
- // Reserve one buffer for the application uniforms, and one for driver uniforms
- return 2;
-}
-
-static size_t GetMaximumVertexUniformBlocks(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - GetReservedVertexUniformBuffers();
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - GetReservedVertexUniformBuffers();
-
- // Uniform blocks not supported in D3D9 feature levels
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 0;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetReservedVertexOutputVectors()
-{
- // We potentially reserve varyings for gl_Position, dx_Position, gl_FragCoord and gl_PointSize
- return 4;
-}
-
-static size_t GetMaximumVertexOutputVectors(D3D_FEATURE_LEVEL featureLevel)
-{
- META_ASSERT(gl::IMPLEMENTATION_MAX_VARYING_VECTORS == D3D11_VS_OUTPUT_REGISTER_COUNT);
-
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_VS_OUTPUT_REGISTER_COUNT - GetReservedVertexOutputVectors();
-
- case D3D_FEATURE_LEVEL_10_1: return D3D10_1_VS_OUTPUT_REGISTER_COUNT - GetReservedVertexOutputVectors();
- case D3D_FEATURE_LEVEL_10_0: return D3D10_VS_OUTPUT_REGISTER_COUNT - GetReservedVertexOutputVectors();
-
- // Use D3D9 SM3 and SM2 limits
- case D3D_FEATURE_LEVEL_9_3: return 10 - GetReservedVertexOutputVectors();
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 8 - GetReservedVertexOutputVectors();
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximumVertexTextureUnits(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT;
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT;
-
- // Vertex textures not supported in D3D9 feature levels according to
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ff476149.aspx
- // ID3D11DeviceContext::VSSetSamplers and ID3D11DeviceContext::VSSetShaderResources
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 0;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximumPixelUniformVectors(D3D_FEATURE_LEVEL featureLevel)
-{
- // TODO(geofflang): Remove hard-coded limit once the gl-uniform-arrays test can pass
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return 1024; // D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT;
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return 1024; // D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT;
-
- // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476149.aspx ID3D11DeviceContext::PSSetConstantBuffers
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 32;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetReservedPixelUniformBuffers()
-{
- // Reserve one buffer for the application uniforms, and one for driver uniforms
- return 2;
-}
-
-static size_t GetMaximumPixelUniformBlocks(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - GetReservedPixelUniformBuffers();
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - GetReservedPixelUniformBuffers();
-
- // Uniform blocks not supported in D3D9 feature levels
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 0;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximumPixelInputVectors(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_PS_INPUT_REGISTER_COUNT - GetReservedVertexOutputVectors();
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return D3D10_PS_INPUT_REGISTER_COUNT - GetReservedVertexOutputVectors();
-
- // Use D3D9 SM3 and SM2 limits
- case D3D_FEATURE_LEVEL_9_3: return 10 - GetReservedVertexOutputVectors();
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 8 - GetReservedVertexOutputVectors();
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximumPixelTextureUnits(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT;
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ff476149.aspx ID3D11DeviceContext::PSSetShaderResources
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 16;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static int GetMinimumTexelOffset(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE;
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return D3D10_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE;
-
- // Sampling functions with offsets are not available below shader model 4.0.
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 0;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static int GetMaximumTexelOffset(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE;
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE;
-
- // Sampling functions with offsets are not available below shader model 4.0.
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 0;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximumConstantBufferSize(D3D_FEATURE_LEVEL featureLevel)
-{
- // Returns a size_t despite the limit being a GLuint64 because size_t is the maximum size of
- // any buffer that could be allocated.
-
- const size_t bytesPerComponent = 4 * sizeof(float);
-
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT * bytesPerComponent;
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT * bytesPerComponent;
-
- // Limits from http://msdn.microsoft.com/en-us/library/windows/desktop/ff476501.aspx remarks section
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 4096 * bytesPerComponent;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximumStreamOutputBuffers(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return D3D11_SO_BUFFER_SLOT_COUNT;
-
- case D3D_FEATURE_LEVEL_10_1: return D3D10_1_SO_BUFFER_SLOT_COUNT;
- case D3D_FEATURE_LEVEL_10_0: return D3D10_SO_BUFFER_SLOT_COUNT;
-
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 0;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximumStreamOutputInterleavedComponents(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0:
-
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return GetMaximumVertexOutputVectors(featureLevel) * 4;
-
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 0;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-static size_t GetMaximumStreamOutputSeparateComponents(D3D_FEATURE_LEVEL featureLevel)
-{
- switch (featureLevel)
- {
-#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
- case D3D_FEATURE_LEVEL_11_1:
-#endif
- case D3D_FEATURE_LEVEL_11_0: return GetMaximumStreamOutputInterleavedComponents(featureLevel) /
- GetMaximumStreamOutputBuffers(featureLevel);
-
-
- // D3D 10 and 10.1 only allow one output per output slot if an output slot other than zero is used.
- case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return 4;
-
- case D3D_FEATURE_LEVEL_9_3:
- case D3D_FEATURE_LEVEL_9_2:
- case D3D_FEATURE_LEVEL_9_1: return 0;
-
- default: UNREACHABLE(); return 0;
- }
-}
-
-void GenerateCaps(ID3D11Device *device, gl::Caps *caps, gl::TextureCapsMap *textureCapsMap, gl::Extensions *extensions)
-{
- GLuint maxSamples = 0;
- const gl::FormatSet &allFormats = gl::GetAllSizedInternalFormats();
- for (gl::FormatSet::const_iterator internalFormat = allFormats.begin(); internalFormat != allFormats.end(); ++internalFormat)
- {
- gl::TextureCaps textureCaps = GenerateTextureFormatCaps(*internalFormat, device);
- textureCapsMap->insert(*internalFormat, textureCaps);
-
- maxSamples = std::max(maxSamples, textureCaps.getMaxSamples());
-
- if (gl::GetInternalFormatInfo(*internalFormat).compressed)
- {
- caps->compressedTextureFormats.push_back(*internalFormat);
- }
- }
-
- D3D_FEATURE_LEVEL featureLevel = device->GetFeatureLevel();
-
- // GL core feature limits
- caps->maxElementIndex = static_cast<GLint64>(std::numeric_limits<unsigned int>::max());
- caps->max3DTextureSize = GetMaximum3DTextureSize(featureLevel);
- caps->max2DTextureSize = GetMaximum2DTextureSize(featureLevel);
- caps->maxCubeMapTextureSize = GetMaximumCubeMapTextureSize(featureLevel);
- caps->maxArrayTextureLayers = GetMaximum2DTextureArraySize(featureLevel);
-
- // Unimplemented, set to minimum required
- caps->maxLODBias = 2.0f;
-
- // No specific limits on render target size, maximum 2D texture size is equivalent
- caps->maxRenderbufferSize = caps->max2DTextureSize;
-
- // Maximum draw buffers and color attachments are the same, max color attachments could eventually be
- // increased to 16
- caps->maxDrawBuffers = GetMaximumSimultaneousRenderTargets(featureLevel);
- caps->maxColorAttachments = GetMaximumSimultaneousRenderTargets(featureLevel);
-
- // D3D11 has the same limit for viewport width and height
- caps->maxViewportWidth = GetMaximumViewportSize(featureLevel);
- caps->maxViewportHeight = caps->maxViewportWidth;
-
- // Choose a reasonable maximum, enforced in the shader.
- caps->minAliasedPointSize = 1.0f;
- caps->maxAliasedPointSize = 1024.0f;
-
- // Wide lines not supported
- caps->minAliasedLineWidth = 1.0f;
- caps->maxAliasedLineWidth = 1.0f;
-
- // Primitive count limits
- caps->maxElementsIndices = GetMaximumDrawIndexedIndexCount(featureLevel);
- caps->maxElementsVertices = GetMaximumDrawVertexCount(featureLevel);
-
- // Program and shader binary formats (no supported shader binary formats)
- caps->programBinaryFormats.push_back(GL_PROGRAM_BINARY_ANGLE);
-
- // We do not wait for server fence objects internally, so report a max timeout of zero.
- caps->maxServerWaitTimeout = 0;
-
- // Vertex shader limits
- caps->maxVertexAttributes = GetMaximumVertexInputSlots(featureLevel);
- caps->maxVertexUniformComponents = GetMaximumVertexUniformVectors(featureLevel) * 4;
- caps->maxVertexUniformVectors = GetMaximumVertexUniformVectors(featureLevel);
- caps->maxVertexUniformBlocks = GetMaximumVertexUniformBlocks(featureLevel);
- caps->maxVertexOutputComponents = GetMaximumVertexOutputVectors(featureLevel) * 4;
- caps->maxVertexTextureImageUnits = GetMaximumVertexTextureUnits(featureLevel);
-
- // Fragment shader limits
- caps->maxFragmentUniformComponents = GetMaximumPixelUniformVectors(featureLevel) * 4;
- caps->maxFragmentUniformVectors = GetMaximumPixelUniformVectors(featureLevel);
- caps->maxFragmentUniformBlocks = GetMaximumPixelUniformBlocks(featureLevel);
- caps->maxFragmentInputComponents = GetMaximumPixelInputVectors(featureLevel) * 4;
- caps->maxTextureImageUnits = GetMaximumPixelTextureUnits(featureLevel);
- caps->minProgramTexelOffset = GetMinimumTexelOffset(featureLevel);
- caps->maxProgramTexelOffset = GetMaximumTexelOffset(featureLevel);
-
- // Aggregate shader limits
- caps->maxUniformBufferBindings = caps->maxVertexUniformBlocks + caps->maxFragmentUniformBlocks;
- caps->maxUniformBlockSize = GetMaximumConstantBufferSize(featureLevel);
-
- // Setting a large alignment forces uniform buffers to bind with zero offset
- caps->uniformBufferOffsetAlignment = static_cast<GLuint>(std::numeric_limits<GLint>::max());
-
- caps->maxCombinedUniformBlocks = caps->maxVertexUniformBlocks + caps->maxFragmentUniformBlocks;
- caps->maxCombinedVertexUniformComponents = (static_cast<GLint64>(caps->maxVertexUniformBlocks) * static_cast<GLint64>(caps->maxUniformBlockSize / 4)) +
- static_cast<GLint64>(caps->maxVertexUniformComponents);
- caps->maxCombinedFragmentUniformComponents = (static_cast<GLint64>(caps->maxFragmentUniformBlocks) * static_cast<GLint64>(caps->maxUniformBlockSize / 4)) +
- static_cast<GLint64>(caps->maxFragmentUniformComponents);
- caps->maxVaryingComponents = GetMaximumVertexOutputVectors(featureLevel) * 4;
- caps->maxVaryingVectors = GetMaximumVertexOutputVectors(featureLevel);
- caps->maxCombinedTextureImageUnits = caps->maxVertexTextureImageUnits + caps->maxTextureImageUnits;
-
- // Transform feedback limits
- caps->maxTransformFeedbackInterleavedComponents = GetMaximumStreamOutputInterleavedComponents(featureLevel);
- caps->maxTransformFeedbackSeparateAttributes = GetMaximumStreamOutputBuffers(featureLevel);
- caps->maxTransformFeedbackSeparateComponents = GetMaximumStreamOutputSeparateComponents(featureLevel);
-
- // GL extension support
- extensions->setTextureExtensionSupport(*textureCapsMap);
- extensions->elementIndexUint = true;
- extensions->packedDepthStencil = true;
- extensions->getProgramBinary = true;
- extensions->rgb8rgba8 = true;
- extensions->readFormatBGRA = true;
- extensions->pixelBufferObject = true;
- extensions->mapBuffer = true;
- extensions->mapBufferRange = true;
- extensions->textureNPOT = GetNPOTTextureSupport(featureLevel);
- extensions->drawBuffers = GetMaximumSimultaneousRenderTargets(featureLevel) > 1;
- extensions->textureStorage = true;
- extensions->textureFilterAnisotropic = true;
- extensions->maxTextureAnisotropy = GetMaximumAnisotropy(featureLevel);
- extensions->occlusionQueryBoolean = GetOcclusionQuerySupport(featureLevel);
- extensions->fence = GetEventQuerySupport(featureLevel);
- extensions->timerQuery = false; // Unimplemented
- extensions->robustness = true;
- extensions->blendMinMax = true;
- extensions->framebufferBlit = true;
- extensions->framebufferMultisample = true;
- extensions->maxSamples = maxSamples;
- extensions->instancedArrays = GetInstancingSupport(featureLevel);
- extensions->packReverseRowOrder = true;
- extensions->standardDerivatives = GetDerivativeInstructionSupport(featureLevel);
- extensions->shaderTextureLOD = true;
- extensions->fragDepth = true;
- extensions->textureUsage = true; // This could be false since it has no effect in D3D11
- extensions->translatedShaderSource = true;
-}
-
-}
-
-namespace d3d11
-{
-
-void MakeValidSize(bool isImage, DXGI_FORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset)
-{
- const DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(format);
-
- int upsampleCount = 0;
- // Don't expand the size of full textures that are at least (blockWidth x blockHeight) already.
- if (isImage || *requestWidth < static_cast<GLsizei>(dxgiFormatInfo.blockWidth) ||
- *requestHeight < static_cast<GLsizei>(dxgiFormatInfo.blockHeight))
- {
- while (*requestWidth % dxgiFormatInfo.blockWidth != 0 || *requestHeight % dxgiFormatInfo.blockHeight != 0)
- {
- *requestWidth <<= 1;
- *requestHeight <<= 1;
- upsampleCount++;
- }
- }
- *levelOffset = upsampleCount;
-}
-
-void GenerateInitialTextureData(GLint internalFormat, GLuint width, GLuint height, GLuint depth,
- GLuint mipLevels, std::vector<D3D11_SUBRESOURCE_DATA> *outSubresourceData,
- std::vector< std::vector<BYTE> > *outData)
-{
- const d3d11::TextureFormat &d3dFormatInfo = d3d11::GetTextureFormatInfo(internalFormat);
- ASSERT(d3dFormatInfo.dataInitializerFunction != NULL);
-
- const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(d3dFormatInfo.texFormat);
-
- outSubresourceData->resize(mipLevels);
- outData->resize(mipLevels);
-
- for (unsigned int i = 0; i < mipLevels; i++)
- {
- unsigned int mipWidth = std::max(width >> i, 1U);
- unsigned int mipHeight = std::max(height >> i, 1U);
- unsigned int mipDepth = std::max(depth >> i, 1U);
-
- unsigned int rowWidth = dxgiFormatInfo.pixelBytes * mipWidth;
- unsigned int imageSize = rowWidth * height;
-
- outData->at(i).resize(rowWidth * mipHeight * mipDepth);
- d3dFormatInfo.dataInitializerFunction(mipWidth, mipHeight, mipDepth, outData->at(i).data(), rowWidth, imageSize);
-
- outSubresourceData->at(i).pSysMem = outData->at(i).data();
- outSubresourceData->at(i).SysMemPitch = rowWidth;
- outSubresourceData->at(i).SysMemSlicePitch = imageSize;
- }
-}
-
-void SetPositionTexCoordVertex(PositionTexCoordVertex* vertex, float x, float y, float u, float v)
-{
- vertex->x = x;
- vertex->y = y;
- vertex->u = u;
- vertex->v = v;
-}
-
-void SetPositionLayerTexCoord3DVertex(PositionLayerTexCoord3DVertex* vertex, float x, float y,
- unsigned int layer, float u, float v, float s)
-{
- vertex->x = x;
- vertex->y = y;
- vertex->l = layer;
- vertex->u = u;
- vertex->v = v;
- vertex->s = s;
-}
-
-HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name)
-{
-#if defined(_DEBUG) && !defined(__MINGW32__)
- return resource->SetPrivateData(WKPDID_D3DDebugObjectName, strlen(name), name);
-#else
- return S_OK;
-#endif
-}
-
-gl::Error GetAttachmentRenderTarget(gl::FramebufferAttachment *attachment, RenderTarget11 **outRT)
-{
- RenderTarget *renderTarget = NULL;
- gl::Error error = rx::GetAttachmentRenderTarget(attachment, &renderTarget);
- if (error.isError())
- {
- return error;
- }
- *outRT = RenderTarget11::makeRenderTarget11(renderTarget);
- return gl::Error(GL_NO_ERROR);
-}
-
-Workarounds GenerateWorkarounds()
-{
- Workarounds workarounds;
- workarounds.mrtPerfWorkaround = true;
- workarounds.setDataFasterThanImageUpload = true;
- return workarounds;
-}
-
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.h
deleted file mode 100644
index 9df9c95763..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.h
+++ /dev/null
@@ -1,189 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// renderer11_utils.h: Conversion functions and other utility routines
-// specific to the D3D11 renderer.
-
-#ifndef LIBGLESV2_RENDERER_RENDERER11_UTILS_H
-#define LIBGLESV2_RENDERER_RENDERER11_UTILS_H
-
-#include "libGLESv2/angletypes.h"
-#include "libGLESv2/Caps.h"
-#include "libGLESv2/Error.h"
-
-#include <vector>
-
-namespace gl
-{
-class FramebufferAttachment;
-}
-
-namespace rx
-{
-class RenderTarget11;
-struct Workarounds;
-
-namespace gl_d3d11
-{
-
-D3D11_BLEND ConvertBlendFunc(GLenum glBlend, bool isAlpha);
-D3D11_BLEND_OP ConvertBlendOp(GLenum glBlendOp);
-UINT8 ConvertColorMask(bool maskRed, bool maskGreen, bool maskBlue, bool maskAlpha);
-
-D3D11_CULL_MODE ConvertCullMode(bool cullEnabled, GLenum cullMode);
-
-D3D11_COMPARISON_FUNC ConvertComparison(GLenum comparison);
-D3D11_DEPTH_WRITE_MASK ConvertDepthMask(bool depthWriteEnabled);
-UINT8 ConvertStencilMask(GLuint stencilmask);
-D3D11_STENCIL_OP ConvertStencilOp(GLenum stencilOp);
-
-D3D11_FILTER ConvertFilter(GLenum minFilter, GLenum magFilter, float maxAnisotropy, GLenum comparisonMode);
-D3D11_TEXTURE_ADDRESS_MODE ConvertTextureWrap(GLenum wrap);
-
-D3D11_QUERY ConvertQueryType(GLenum queryType);
-
-}
-
-namespace d3d11_gl
-{
-
-void GenerateCaps(ID3D11Device *device, gl::Caps *caps, gl::TextureCapsMap *textureCapsMap, gl::Extensions *extensions);
-
-}
-
-namespace d3d11
-{
-
-void MakeValidSize(bool isImage, DXGI_FORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset);
-
-void GenerateInitialTextureData(GLint internalFormat, GLuint width, GLuint height, GLuint depth,
- GLuint mipLevels, std::vector<D3D11_SUBRESOURCE_DATA> *outSubresourceData,
- std::vector< std::vector<BYTE> > *outData);
-
-struct PositionTexCoordVertex
-{
- float x, y;
- float u, v;
-};
-void SetPositionTexCoordVertex(PositionTexCoordVertex* vertex, float x, float y, float u, float v);
-
-struct PositionLayerTexCoord3DVertex
-{
- float x, y;
- unsigned int l;
- float u, v, s;
-};
-void SetPositionLayerTexCoord3DVertex(PositionLayerTexCoord3DVertex* vertex, float x, float y,
- unsigned int layer, float u, float v, float s);
-
-template <typename T>
-struct PositionDepthColorVertex
-{
- float x, y, z;
- T r, g, b, a;
-};
-
-template <typename T>
-void SetPositionDepthColorVertex(PositionDepthColorVertex<T>* vertex, float x, float y, float z,
- const gl::Color<T> &color)
-{
- vertex->x = x;
- vertex->y = y;
- vertex->z = z;
- vertex->r = color.red;
- vertex->g = color.green;
- vertex->b = color.blue;
- vertex->a = color.alpha;
-}
-
-HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name);
-
-template <typename outType>
-outType* DynamicCastComObject(IUnknown* object)
-{
- outType *outObject = NULL;
- HRESULT result = object->QueryInterface(__uuidof(outType), reinterpret_cast<void**>(&outObject));
- if (SUCCEEDED(result))
- {
- return outObject;
- }
- else
- {
- SafeRelease(outObject);
- return NULL;
- }
-}
-
-inline bool isDeviceLostError(HRESULT errorCode)
-{
- switch (errorCode)
- {
- case DXGI_ERROR_DEVICE_HUNG:
- case DXGI_ERROR_DEVICE_REMOVED:
- case DXGI_ERROR_DEVICE_RESET:
- case DXGI_ERROR_DRIVER_INTERNAL_ERROR:
- case DXGI_ERROR_NOT_CURRENTLY_AVAILABLE:
- return true;
- default:
- return false;
- }
-}
-
-template <unsigned int N>
-inline ID3D11VertexShader *CompileVS(ID3D11Device *device, const BYTE (&byteCode)[N], const char *name)
-{
- ID3D11VertexShader *vs = NULL;
- HRESULT result = device->CreateVertexShader(byteCode, N, NULL, &vs);
- UNUSED_ASSERTION_VARIABLE(result);
- ASSERT(SUCCEEDED(result));
- SetDebugName(vs, name);
- return vs;
-}
-
-template <unsigned int N>
-inline ID3D11GeometryShader *CompileGS(ID3D11Device *device, const BYTE (&byteCode)[N], const char *name)
-{
- ID3D11GeometryShader *gs = NULL;
- HRESULT result = device->CreateGeometryShader(byteCode, N, NULL, &gs);
- UNUSED_ASSERTION_VARIABLE(result);
- ASSERT(SUCCEEDED(result));
- SetDebugName(gs, name);
- return gs;
-}
-
-template <unsigned int N>
-inline ID3D11PixelShader *CompilePS(ID3D11Device *device, const BYTE (&byteCode)[N], const char *name)
-{
- ID3D11PixelShader *ps = NULL;
- HRESULT result = device->CreatePixelShader(byteCode, N, NULL, &ps);
- UNUSED_ASSERTION_VARIABLE(result);
- ASSERT(SUCCEEDED(result));
- SetDebugName(ps, name);
- return ps;
-}
-
-// Copy data to small D3D11 buffers, such as for small constant buffers, which use one struct to
-// represent an entire buffer.
-template <class T>
-inline void SetBufferData(ID3D11DeviceContext *context, ID3D11Buffer *constantBuffer, const T &value)
-{
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- context->Map(constantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
-
- memcpy(mappedResource.pData, &value, sizeof(T));
-
- context->Unmap(constantBuffer, 0);
-}
-
-gl::Error GetAttachmentRenderTarget(gl::FramebufferAttachment *attachment, RenderTarget11 **outRT);
-
-Workarounds GenerateWorkarounds();
-
-}
-
-}
-
-#endif // LIBGLESV2_RENDERER_RENDERER11_UTILS_H
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/BufferToTexture11.hlsl b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/BufferToTexture11.hlsl
deleted file mode 100644
index 20e6623a30..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/BufferToTexture11.hlsl
+++ /dev/null
@@ -1,76 +0,0 @@
-Buffer<float4> Buffer4F : register(t0);
-Buffer<int4> Buffer4I : register(t0);
-Buffer<uint4> Buffer4UI : register(t0);
-
-struct VS_OUTPUT
-{
- float4 position : SV_Position;
- uint index : TEXCOORD0;
- uint slice : LAYER;
-};
-
-struct GS_OUTPUT
-{
- float4 position : SV_Position;
- uint index : TEXCOORD0;
- uint slice : SV_RenderTargetArrayIndex;
-};
-
-cbuffer BufferCopyParams : register(b0)
-{
- uint FirstPixelOffset;
- uint PixelsPerRow;
- uint RowStride;
- uint RowsPerSlice;
- float2 PositionOffset;
- float2 PositionScale;
- int2 TexLocationOffset;
- int2 TexLocationScale;
-}
-
-void ComputePositionAndIndex(uint vertexID, out VS_OUTPUT outVertex)
-{
- uint PixelsPerSlice = PixelsPerRow * RowsPerSlice;
- uint SliceStride = RowStride * RowsPerSlice;
-
- uint slice = vertexID / PixelsPerSlice;
- uint sliceOffset = slice * PixelsPerSlice;
- uint row = (vertexID - sliceOffset) / PixelsPerRow;
- uint col = vertexID - sliceOffset - (row * PixelsPerRow);
-
- float2 coords = float2(float(col), float(row));
-
- outVertex.position = float4(PositionOffset + PositionScale * coords, 0.0f, 1.0f);
- outVertex.index = FirstPixelOffset + slice * SliceStride + row * RowStride + col;
- outVertex.slice = slice;
-}
-
-void VS_BufferToTexture(in uint vertexID : SV_VertexID, out VS_OUTPUT outVertex)
-{
- ComputePositionAndIndex(vertexID, outVertex);
-}
-
-[maxvertexcount(1)]
-void GS_BufferToTexture(point VS_OUTPUT inVertex[1], inout PointStream<GS_OUTPUT> outStream)
-{
- GS_OUTPUT outVertex;
- outVertex.position = inVertex[0].position;
- outVertex.index = inVertex[0].index;
- outVertex.slice = inVertex[0].slice;
- outStream.Append(outVertex);
-}
-
-float4 PS_BufferToTexture_4F(in float4 inPosition : SV_Position, in uint inIndex : TEXCOORD0) : SV_Target
-{
- return Buffer4F.Load(inIndex);
-}
-
-int4 PS_BufferToTexture_4I(in float4 inPosition : SV_Position, in uint inIndex : TEXCOORD0) : SV_Target
-{
- return Buffer4I.Load(inIndex);
-}
-
-uint4 PS_BufferToTexture_4UI(in float4 inPosition : SV_Position, in uint inIndex : TEXCOORD0) : SV_Target
-{
- return Buffer4UI.Load(inIndex);
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Clear11.hlsl b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Clear11.hlsl
deleted file mode 100644
index b4cf38076e..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Clear11.hlsl
+++ /dev/null
@@ -1,106 +0,0 @@
-// Assume we are in SM4+, which has 8 color outputs
-
-void VS_ClearFloat( in float3 inPosition : POSITION, in float4 inColor : COLOR,
- out float4 outPosition : SV_POSITION, out float4 outColor : COLOR)
-{
- outPosition = float4(inPosition, 1.0f);
- outColor = inColor;
-}
-
-struct PS_OutputFloat
-{
- float4 color0 : SV_TARGET0;
- float4 color1 : SV_TARGET1;
- float4 color2 : SV_TARGET2;
- float4 color3 : SV_TARGET3;
-#if SM4
- float4 color4 : SV_TARGET4;
- float4 color5 : SV_TARGET5;
- float4 color6 : SV_TARGET6;
- float4 color7 : SV_TARGET7;
-#endif
-};
-
-PS_OutputFloat PS_ClearFloat(in float4 inPosition : SV_POSITION, in float4 inColor : COLOR)
-{
- PS_OutputFloat outColor;
- outColor.color0 = inColor;
- outColor.color1 = inColor;
- outColor.color2 = inColor;
- outColor.color3 = inColor;
-#if SM4
- outColor.color4 = inColor;
- outColor.color5 = inColor;
- outColor.color6 = inColor;
- outColor.color7 = inColor;
-#endif
- return outColor;
-}
-
-
-void VS_ClearUint( in float3 inPosition : POSITION, in uint4 inColor : COLOR,
- out float4 outPosition : SV_POSITION, out uint4 outColor : COLOR)
-{
- outPosition = float4(inPosition, 1.0f);
- outColor = inColor;
-}
-
-struct PS_OutputUint
-{
- uint4 color0 : SV_TARGET0;
- uint4 color1 : SV_TARGET1;
- uint4 color2 : SV_TARGET2;
- uint4 color3 : SV_TARGET3;
- uint4 color4 : SV_TARGET4;
- uint4 color5 : SV_TARGET5;
- uint4 color6 : SV_TARGET6;
- uint4 color7 : SV_TARGET7;
-};
-
-PS_OutputUint PS_ClearUint(in float4 inPosition : SV_POSITION, in uint4 inColor : COLOR)
-{
- PS_OutputUint outColor;
- outColor.color0 = inColor;
- outColor.color1 = inColor;
- outColor.color2 = inColor;
- outColor.color3 = inColor;
- outColor.color4 = inColor;
- outColor.color5 = inColor;
- outColor.color6 = inColor;
- outColor.color7 = inColor;
- return outColor;
-}
-
-
-void VS_ClearSint( in float3 inPosition : POSITION, in int4 inColor : COLOR,
- out float4 outPosition : SV_POSITION, out int4 outColor : COLOR)
-{
- outPosition = float4(inPosition, 1.0f);
- outColor = inColor;
-}
-
-struct PS_OutputSint
-{
- int4 color0 : SV_TARGET0;
- int4 color1 : SV_TARGET1;
- int4 color2 : SV_TARGET2;
- int4 color3 : SV_TARGET3;
- int4 color4 : SV_TARGET4;
- int4 color5 : SV_TARGET5;
- int4 color6 : SV_TARGET6;
- int4 color7 : SV_TARGET7;
-};
-
-PS_OutputSint PS_ClearSint(in float4 inPosition : SV_POSITION, in int4 inColor : COLOR)
-{
- PS_OutputSint outColor;
- outColor.color0 = inColor;
- outColor.color1 = inColor;
- outColor.color2 = inColor;
- outColor.color3 = inColor;
- outColor.color4 = inColor;
- outColor.color5 = inColor;
- outColor.color6 = inColor;
- outColor.color7 = inColor;
- return outColor;
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Passthrough2D11.hlsl b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Passthrough2D11.hlsl
deleted file mode 100644
index 8671c39fb7..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Passthrough2D11.hlsl
+++ /dev/null
@@ -1,111 +0,0 @@
-Texture2D<float4> TextureF : register(t0);
-Texture2D<uint4> TextureUI : register(t0);
-Texture2D<int4> TextureI : register(t0);
-
-SamplerState Sampler : register(s0);
-
-void VS_Passthrough2D( in float2 inPosition : POSITION, in float2 inTexCoord : TEXCOORD0,
- out float4 outPosition : SV_POSITION, out float2 outTexCoord : TEXCOORD0)
-{
- outPosition = float4(inPosition, 0.0f, 1.0f);
- outTexCoord = inTexCoord;
-}
-
-float PS_PassthroughDepth2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_DEPTH
-{
- return TextureF.Sample(Sampler, inTexCoord).r;
-}
-
-float4 PS_PassthroughRGBA2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- return TextureF.Sample(Sampler, inTexCoord).rgba;
-}
-
-uint4 PS_PassthroughRGBA2DUI(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- uint2 size;
- TextureUI.GetDimensions(size.x, size.y);
-
- return TextureUI.Load(int3(size * inTexCoord, 0)).rgba;
-}
-
-int4 PS_PassthroughRGBA2DI(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- uint2 size;
- TextureI.GetDimensions(size.x, size.y);
-
- return TextureI.Load(int3(size * inTexCoord, 0)).rgba;
-}
-
-float4 PS_PassthroughRGB2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- return float4(TextureF.Sample(Sampler, inTexCoord).rgb, 1.0f);
-}
-
-uint4 PS_PassthroughRGB2DUI(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- uint2 size;
- TextureUI.GetDimensions(size.x, size.y);
-
- return uint4(TextureUI.Load(int3(size * inTexCoord, 0)).rgb, 0);
-}
-
-int4 PS_PassthroughRGB2DI(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- uint2 size;
- TextureI.GetDimensions(size.x, size.y);
-
- return int4(TextureI.Load(int3(size * inTexCoord, 0)).rgb, 0);
-}
-
-float4 PS_PassthroughRG2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- return float4(TextureF.Sample(Sampler, inTexCoord).rg, 0.0f, 1.0f);
-}
-
-uint4 PS_PassthroughRG2DUI(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- uint2 size;
- TextureUI.GetDimensions(size.x, size.y);
-
- return uint4(TextureUI.Load(int3(size * inTexCoord, 0)).rg, 0, 0);
-}
-
-int4 PS_PassthroughRG2DI(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- uint2 size;
- TextureI.GetDimensions(size.x, size.y);
-
- return int4(TextureI.Load(int3(size * inTexCoord, 0)).rg, 0, 0);
-}
-
-float4 PS_PassthroughR2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- return float4(TextureF.Sample(Sampler, inTexCoord).r, 0.0f, 0.0f, 1.0f);
-}
-
-uint4 PS_PassthroughR2DUI(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- uint2 size;
- TextureUI.GetDimensions(size.x, size.y);
-
- return uint4(TextureUI.Load(int3(size * inTexCoord, 0)).r, 0, 0, 0);
-}
-
-int4 PS_PassthroughR2DI(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- uint2 size;
- TextureI.GetDimensions(size.x, size.y);
-
- return int4(TextureI.Load(int3(size * inTexCoord, 0)).r, 0, 0, 0);
-}
-
-float4 PS_PassthroughLum2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- return float4(TextureF.Sample(Sampler, inTexCoord).rrr, 1.0f);
-}
-
-float4 PS_PassthroughLumAlpha2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- return TextureF.Sample(Sampler, inTexCoord).rrra;
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Passthrough3D11.hlsl b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Passthrough3D11.hlsl
deleted file mode 100644
index c23c9032ec..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Passthrough3D11.hlsl
+++ /dev/null
@@ -1,146 +0,0 @@
-Texture3D<float4> TextureF : register(t0);
-Texture3D<uint4> TextureUI : register(t0);
-Texture3D<int4> TextureI : register(t0);
-
-SamplerState Sampler : register(s0);
-
-struct VS_INPUT
-{
- float2 Position : POSITION;
- uint Layer : LAYER;
- float3 TexCoord : TEXCOORD;
-};
-
-struct VS_OUTPUT
-{
- float4 Position : SV_POSITION;
- uint Layer : LAYER;
- float3 TexCoord : TEXCOORD;
-};
-
-struct GS_OUTPUT
-{
- float4 Position : SV_POSITION;
- uint Layer : SV_RENDERTARGETARRAYINDEX;
- float3 TexCoord : TEXCOORD;
-};
-
-VS_OUTPUT VS_Passthrough3D(VS_INPUT input)
-{
- VS_OUTPUT output;
-
- output.Position = float4(input.Position, 0.0f, 1.0f);
- output.Layer = input.Layer;
- output.TexCoord = input.TexCoord;
-
- return output;
-}
-
-[maxvertexcount(3)]
-void GS_Passthrough3D(triangle VS_OUTPUT input[3], inout TriangleStream<GS_OUTPUT> outputStream)
-{
- GS_OUTPUT output;
-
- for (int i = 0; i < 3; i++)
- {
- output.Position = input[i].Position;
- output.Layer = input[i].Layer;
- output.TexCoord = input[i].TexCoord;
-
- outputStream.Append(output);
- }
-}
-
-float4 PS_PassthroughRGBA3D(GS_OUTPUT input) : SV_TARGET0
-{
- return TextureF.Sample(Sampler, input.TexCoord).rgba;
-}
-
-uint4 PS_PassthroughRGBA3DUI(GS_OUTPUT input) : SV_TARGET0
-{
- uint3 size;
- TextureUI.GetDimensions(size.x, size.y, size.z);
-
- return TextureUI.Load(int4(size * input.TexCoord, 0)).rgba;
-}
-
-int4 PS_PassthroughRGBA3DI(GS_OUTPUT input) : SV_TARGET0
-{
- uint3 size;
- TextureI.GetDimensions(size.x, size.y, size.z);
-
- return TextureI.Load(int4(size * input.TexCoord, 0)).rgba;
-}
-
-float4 PS_PassthroughRGB3D(GS_OUTPUT input) : SV_TARGET0
-{
- return float4(TextureF.Sample(Sampler, input.TexCoord).rgb, 1.0f);
-}
-
-uint4 PS_PassthroughRGB3DUI(GS_OUTPUT input) : SV_TARGET0
-{
- uint3 size;
- TextureUI.GetDimensions(size.x, size.y, size.z);
-
- return uint4(TextureUI.Load(int4(size * input.TexCoord, 0)).rgb, 0);
-}
-
-int4 PS_PassthroughRGB3DI(GS_OUTPUT input) : SV_TARGET0
-{
- uint3 size;
- TextureI.GetDimensions(size.x, size.y, size.z);
-
- return int4(TextureI.Load(int4(size * input.TexCoord, 0)).rgb, 0);
-}
-
-float4 PS_PassthroughRG3D(GS_OUTPUT input) : SV_TARGET0
-{
- return float4(TextureF.Sample(Sampler, input.TexCoord).rg, 0.0f, 1.0f);
-}
-
-uint4 PS_PassthroughRG3DUI(GS_OUTPUT input) : SV_TARGET0
-{
- uint3 size;
- TextureUI.GetDimensions(size.x, size.y, size.z);
-
- return uint4(TextureUI.Load(int4(size * input.TexCoord, 0)).rg, 0, 0);
-}
-
-int4 PS_PassthroughRG3DI(GS_OUTPUT input) : SV_TARGET0
-{
- uint3 size;
- TextureI.GetDimensions(size.x, size.y, size.z);
-
- return int4(TextureI.Load(int4(size * input.TexCoord, 0)).rg, 0, 0);
-}
-
-float4 PS_PassthroughR3D(GS_OUTPUT input) : SV_TARGET0
-{
- return float4(TextureF.Sample(Sampler, input.TexCoord).r, 0.0f, 0.0f, 1.0f);
-}
-
-uint4 PS_PassthroughR3DUI(GS_OUTPUT input) : SV_TARGET0
-{
- uint3 size;
- TextureUI.GetDimensions(size.x, size.y, size.z);
-
- return uint4(TextureUI.Load(int4(size * input.TexCoord, 0)).r, 0, 0, 0);
-}
-
-int4 PS_PassthroughR3DI(GS_OUTPUT input) : SV_TARGET0
-{
- uint3 size;
- TextureI.GetDimensions(size.x, size.y, size.z);
-
- return int4(TextureI.Load(int4(size * input.TexCoord, 0)).r, 0, 0, 0);
-}
-
-float4 PS_PassthroughLum3D(GS_OUTPUT input) : SV_TARGET0
-{
- return float4(TextureF.Sample(Sampler, input.TexCoord).rrr, 1.0f);
-}
-
-float4 PS_PassthroughLumAlpha3D(GS_OUTPUT input) : SV_TARGET0
-{
- return TextureF.Sample(Sampler, input.TexCoord).rrra;
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Swizzle11.hlsl b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Swizzle11.hlsl
deleted file mode 100644
index 505e222137..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Swizzle11.hlsl
+++ /dev/null
@@ -1,99 +0,0 @@
-Texture2D<float4> TextureF2D : register(t0);
-Texture2D<uint4> TextureUI2D : register(t0);
-Texture2D<int4> TextureI2D : register(t0);
-
-Texture3D<float4> TextureF3D : register(t0);
-Texture3D<uint4> TextureUI3D : register(t0);
-Texture3D<int4> TextureI3D : register(t0);
-
-Texture2DArray<float4> TextureF2DArray : register(t0);
-Texture2DArray<uint4> TextureUI2DArray : register(t0);
-Texture2DArray<int4> TextureI2DArray : register(t0);
-
-SamplerState Sampler : register(s0);
-
-cbuffer SwizzleProperties : register(b0)
-{
- uint4 SwizzleIndices : packoffset(c0);
-}
-
-float4 SwizzleLookup(in float4 sample)
-{
- float lookup[6] = { sample[0], sample[1], sample[2], sample[3], 0.0f, 1.0f };
- return float4(lookup[SwizzleIndices[0]], lookup[SwizzleIndices[1]], lookup[SwizzleIndices[2]], lookup[SwizzleIndices[3]]);
-}
-
-int4 SwizzleLookup(in int4 sample)
-{
- int lookup[6] = { sample[0], sample[1], sample[2], sample[3], 0.0f, 1.0f };
- return int4(lookup[SwizzleIndices[0]], lookup[SwizzleIndices[1]], lookup[SwizzleIndices[2]], lookup[SwizzleIndices[3]]);
-}
-
-uint4 SwizzleLookup(in uint4 sample)
-{
- uint lookup[6] = { sample[0], sample[1], sample[2], sample[3], 0.0f, 1.0f };
- return uint4(lookup[SwizzleIndices[0]], lookup[SwizzleIndices[1]], lookup[SwizzleIndices[2]], lookup[SwizzleIndices[3]]);
-}
-
-float4 PS_SwizzleF2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- return SwizzleLookup(TextureF2D.Sample(Sampler, inTexCoord));
-}
-
-int4 PS_SwizzleI2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- uint2 size;
- TextureI2D.GetDimensions(size.x, size.y);
-
- return SwizzleLookup(TextureI2D.Load(int3(size * inTexCoord, 0)));
-}
-
-uint4 PS_SwizzleUI2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- uint2 size;
- TextureUI2D.GetDimensions(size.x, size.y);
-
- return SwizzleLookup(TextureUI2D.Load(int3(size * inTexCoord, 0)));
-}
-
-float4 PS_SwizzleF3D(in float4 inPosition : SV_POSITION, in uint inLayer : SV_RENDERTARGETARRAYINDEX, in float3 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- return SwizzleLookup(TextureF3D.Sample(Sampler, inTexCoord));
-}
-
-int4 PS_SwizzleI3D(in float4 inPosition : SV_POSITION, in uint inLayer : SV_RENDERTARGETARRAYINDEX, in float3 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- uint3 size;
- TextureI3D.GetDimensions(size.x, size.y, size.z);
-
- return SwizzleLookup(TextureI3D.Load(int4(size * inTexCoord, 0)));
-}
-
-uint4 PS_SwizzleUI3D(in float4 inPosition : SV_POSITION, in uint inLayer : SV_RENDERTARGETARRAYINDEX, in float3 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- uint3 size;
- TextureUI3D.GetDimensions(size.x, size.y, size.z);
-
- return SwizzleLookup(TextureUI3D.Load(int4(size * inTexCoord, 0)));
-}
-
-float4 PS_SwizzleF2DArray(in float4 inPosition : SV_POSITION, in uint inLayer : SV_RENDERTARGETARRAYINDEX, in float3 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- return SwizzleLookup(TextureF2DArray.Sample(Sampler, float3(inTexCoord.xy, inLayer)));
-}
-
-int4 PS_SwizzleI2DArray(in float4 inPosition : SV_POSITION, in uint inLayer : SV_RENDERTARGETARRAYINDEX, in float3 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- uint3 size;
- TextureI2DArray.GetDimensions(size.x, size.y, size.z);
-
- return SwizzleLookup(TextureI2DArray.Load(int4(size.xy * inTexCoord.xy, inLayer, 0)));
-}
-
-uint4 PS_SwizzleUI2DArray(in float4 inPosition : SV_POSITION, in uint inLayer : SV_RENDERTARGETARRAYINDEX, in float3 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
- uint3 size;
- TextureUI2DArray.GetDimensions(size.x, size.y, size.z);
-
- return SwizzleLookup(TextureUI2DArray.Load(int4(size.xy * inTexCoord.xy, inLayer, 0)));
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Blit9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Blit9.cpp
deleted file mode 100644
index 2ca7a9cf8a..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Blit9.cpp
+++ /dev/null
@@ -1,679 +0,0 @@
-//
-// Copyright (c) 2002-2010 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.
-//
-
-// Blit9.cpp: Surface copy utility class.
-
-#include "libGLESv2/renderer/d3d/d3d9/Blit9.h"
-#include "libGLESv2/renderer/d3d/d3d9/renderer9_utils.h"
-#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h"
-#include "libGLESv2/renderer/d3d/d3d9/TextureStorage9.h"
-#include "libGLESv2/renderer/d3d/d3d9/RenderTarget9.h"
-#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/FramebufferAttachment.h"
-#include "libGLESv2/main.h"
-
-namespace
-{
-// Precompiled shaders
-#include "libGLESv2/renderer/d3d/d3d9/shaders/compiled/standardvs.h"
-#include "libGLESv2/renderer/d3d/d3d9/shaders/compiled/flipyvs.h"
-#include "libGLESv2/renderer/d3d/d3d9/shaders/compiled/passthroughps.h"
-#include "libGLESv2/renderer/d3d/d3d9/shaders/compiled/luminanceps.h"
-#include "libGLESv2/renderer/d3d/d3d9/shaders/compiled/componentmaskps.h"
-
-const BYTE* const g_shaderCode[] =
-{
- g_vs20_VS_standard,
- g_vs20_VS_flipy,
- g_ps20_PS_passthrough,
- g_ps20_PS_luminance,
- g_ps20_PS_componentmask
-};
-
-const size_t g_shaderSize[] =
-{
- sizeof(g_vs20_VS_standard),
- sizeof(g_vs20_VS_flipy),
- sizeof(g_ps20_PS_passthrough),
- sizeof(g_ps20_PS_luminance),
- sizeof(g_ps20_PS_componentmask)
-};
-}
-
-namespace rx
-{
-
-Blit9::Blit9(Renderer9 *renderer)
- : mRenderer(renderer),
- mGeometryLoaded(false),
- mQuadVertexBuffer(NULL),
- mQuadVertexDeclaration(NULL),
- mSavedStateBlock(NULL),
- mSavedRenderTarget(NULL),
- mSavedDepthStencil(NULL)
-{
- memset(mCompiledShaders, 0, sizeof(mCompiledShaders));
-}
-
-Blit9::~Blit9()
-{
- SafeRelease(mSavedStateBlock);
- SafeRelease(mQuadVertexBuffer);
- SafeRelease(mQuadVertexDeclaration);
-
- for (int i = 0; i < SHADER_COUNT; i++)
- {
- SafeRelease(mCompiledShaders[i]);
- }
-}
-
-gl::Error Blit9::initialize()
-{
- if (mGeometryLoaded)
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- static const float quad[] =
- {
- -1, -1,
- -1, 1,
- 1, -1,
- 1, 1
- };
-
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- HRESULT result = device->CreateVertexBuffer(sizeof(quad), D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &mQuadVertexBuffer, NULL);
-
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal blit vertex shader, result: 0x%X.", result);
- }
-
- void *lockPtr = NULL;
- result = mQuadVertexBuffer->Lock(0, 0, &lockPtr, 0);
-
- if (FAILED(result) || lockPtr == NULL)
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- SafeRelease(mQuadVertexBuffer);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock internal blit vertex shader, result: 0x%X.", result);
- }
-
- memcpy(lockPtr, quad, sizeof(quad));
- mQuadVertexBuffer->Unlock();
-
- static const D3DVERTEXELEMENT9 elements[] =
- {
- { 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
- D3DDECL_END()
- };
-
- result = device->CreateVertexDeclaration(elements, &mQuadVertexDeclaration);
-
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- SafeRelease(mQuadVertexBuffer);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock internal blit vertex declaration, result: 0x%X.", result);
- }
-
- mGeometryLoaded = true;
- return gl::Error(GL_NO_ERROR);
-}
-
-template <class D3DShaderType>
-gl::Error Blit9::setShader(ShaderId source, const char *profile,
- gl::Error (Renderer9::*createShader)(const DWORD *, size_t length, D3DShaderType **outShader),
- HRESULT (WINAPI IDirect3DDevice9::*setShader)(D3DShaderType*))
-{
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- D3DShaderType *shader;
-
- if (mCompiledShaders[source] != NULL)
- {
- shader = static_cast<D3DShaderType*>(mCompiledShaders[source]);
- }
- else
- {
- const BYTE* shaderCode = g_shaderCode[source];
- size_t shaderSize = g_shaderSize[source];
-
- gl::Error error = (mRenderer->*createShader)(reinterpret_cast<const DWORD*>(shaderCode), shaderSize, &shader);
- if (error.isError())
- {
- return error;
- }
-
- mCompiledShaders[source] = shader;
- }
-
- HRESULT hr = (device->*setShader)(shader);
- if (FAILED(hr))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to set shader for blit operation, result: 0x%X.", hr);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Blit9::setVertexShader(ShaderId shader)
-{
- return setShader<IDirect3DVertexShader9>(shader, "vs_2_0", &Renderer9::createVertexShader, &IDirect3DDevice9::SetVertexShader);
-}
-
-gl::Error Blit9::setPixelShader(ShaderId shader)
-{
- return setShader<IDirect3DPixelShader9>(shader, "ps_2_0", &Renderer9::createPixelShader, &IDirect3DDevice9::SetPixelShader);
-}
-
-RECT Blit9::getSurfaceRect(IDirect3DSurface9 *surface) const
-{
- D3DSURFACE_DESC desc;
- surface->GetDesc(&desc);
-
- RECT rect;
- rect.left = 0;
- rect.top = 0;
- rect.right = desc.Width;
- rect.bottom = desc.Height;
-
- return rect;
-}
-
-gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
-{
- gl::Error error = initialize();
- if (error.isError())
- {
- return error;
- }
-
- IDirect3DTexture9 *texture = NULL;
- error = copySurfaceToTexture(source, getSurfaceRect(source), &texture);
- if (error.isError())
- {
- return error;
- }
-
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- saveState();
-
- device->SetTexture(0, texture);
- device->SetRenderTarget(0, dest);
-
- setVertexShader(SHADER_VS_STANDARD);
- setPixelShader(SHADER_PS_PASSTHROUGH);
-
- setCommonBlitState();
- device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
-
- setViewport(getSurfaceRect(dest), 0, 0);
-
- render();
-
- SafeRelease(texture);
-
- restoreState();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Blit9::copy2D(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level)
-{
- gl::Error error = initialize();
- if (error.isError())
- {
- return error;
- }
-
- gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(0);
- ASSERT(colorbuffer);
-
- RenderTarget9 *renderTarget9 = NULL;
- error = d3d9::GetAttachmentRenderTarget(colorbuffer, &renderTarget9);
- if (error.isError())
- {
- return error;
- }
- ASSERT(renderTarget9);
-
- IDirect3DSurface9 *source = renderTarget9->getSurface();
- ASSERT(source);
-
- IDirect3DSurface9 *destSurface = NULL;
- TextureStorage9_2D *storage9 = TextureStorage9_2D::makeTextureStorage9_2D(storage);
- error = storage9->getSurfaceLevel(level, true, &destSurface);
- if (error.isError())
- {
- return error;
- }
- ASSERT(destSurface);
-
- gl::Error result = copy(source, sourceRect, destFormat, xoffset, yoffset, destSurface);
-
- SafeRelease(destSurface);
- SafeRelease(source);
-
- return result;
-}
-
-gl::Error Blit9::copyCube(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level)
-{
- gl::Error error = initialize();
- if (error.isError())
- {
- return error;
- }
-
- gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(0);
- ASSERT(colorbuffer);
-
- RenderTarget9 *renderTarget9 = NULL;
- error = d3d9::GetAttachmentRenderTarget(colorbuffer, &renderTarget9);
- if (error.isError())
- {
- return error;
- }
- ASSERT(renderTarget9);
-
- IDirect3DSurface9 *source = renderTarget9->getSurface();
- ASSERT(source);
-
- IDirect3DSurface9 *destSurface = NULL;
- TextureStorage9_Cube *storage9 = TextureStorage9_Cube::makeTextureStorage9_Cube(storage);
- error = storage9->getCubeMapSurface(target, level, true, &destSurface);
- if (error.isError())
- {
- return error;
- }
- ASSERT(destSurface);
-
- gl::Error result = copy(source, sourceRect, destFormat, xoffset, yoffset, destSurface);
-
- SafeRelease(destSurface);
- SafeRelease(source);
-
- return result;
-}
-
-gl::Error Blit9::copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, IDirect3DSurface9 *dest)
-{
- ASSERT(source != NULL && dest != NULL);
-
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- D3DSURFACE_DESC sourceDesc;
- D3DSURFACE_DESC destDesc;
- source->GetDesc(&sourceDesc);
- dest->GetDesc(&destDesc);
-
- if (sourceDesc.Format == destDesc.Format && destDesc.Usage & D3DUSAGE_RENDERTARGET &&
- d3d9_gl::IsFormatChannelEquivalent(destDesc.Format, destFormat)) // Can use StretchRect
- {
- RECT destRect = {xoffset, yoffset, xoffset + (sourceRect.right - sourceRect.left), yoffset + (sourceRect.bottom - sourceRect.top)};
- HRESULT result = device->StretchRect(source, &sourceRect, dest, &destRect, D3DTEXF_POINT);
-
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to blit between textures, StretchRect result: 0x%X.", result);
- }
-
- return gl::Error(GL_NO_ERROR);
- }
- else
- {
- return formatConvert(source, sourceRect, destFormat, xoffset, yoffset, dest);
- }
-}
-
-gl::Error Blit9::formatConvert(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, IDirect3DSurface9 *dest)
-{
- gl::Error error = initialize();
- if (error.isError())
- {
- return error;
- }
-
- IDirect3DTexture9 *texture = NULL;
- error = copySurfaceToTexture(source, sourceRect, &texture);
- if (error.isError())
- {
- return error;
- }
-
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- saveState();
-
- device->SetTexture(0, texture);
- device->SetRenderTarget(0, dest);
-
- setViewport(sourceRect, xoffset, yoffset);
-
- setCommonBlitState();
-
- error = setFormatConvertShaders(destFormat);
- if (!error.isError())
- {
- render();
- }
-
- SafeRelease(texture);
-
- restoreState();
-
- return error;
-}
-
-gl::Error Blit9::setFormatConvertShaders(GLenum destFormat)
-{
- gl::Error error = setVertexShader(SHADER_VS_STANDARD);
- if (error.isError())
- {
- return error;
- }
-
- switch (destFormat)
- {
- default: UNREACHABLE();
- case GL_RGBA:
- case GL_BGRA_EXT:
- case GL_RGB:
- case GL_RG_EXT:
- case GL_RED_EXT:
- case GL_ALPHA:
- error = setPixelShader(SHADER_PS_COMPONENTMASK);
- break;
-
- case GL_LUMINANCE:
- case GL_LUMINANCE_ALPHA:
- error = setPixelShader(SHADER_PS_LUMINANCE);
- break;
- }
-
- if (error.isError())
- {
- return error;
- }
-
- enum { X = 0, Y = 1, Z = 2, W = 3 };
-
- // The meaning of this constant depends on the shader that was selected.
- // See the shader assembly code above for details.
- // Allocate one array for both registers and split it into two float4's.
- float psConst[8] = { 0 };
- float *multConst = &psConst[0];
- float *addConst = &psConst[4];
-
- switch (destFormat)
- {
- default: UNREACHABLE();
- case GL_RGBA:
- case GL_BGRA_EXT:
- multConst[X] = 1;
- multConst[Y] = 1;
- multConst[Z] = 1;
- multConst[W] = 1;
- addConst[X] = 0;
- addConst[Y] = 0;
- addConst[Z] = 0;
- addConst[W] = 0;
- break;
-
- case GL_RGB:
- multConst[X] = 1;
- multConst[Y] = 1;
- multConst[Z] = 1;
- multConst[W] = 0;
- addConst[X] = 0;
- addConst[Y] = 0;
- addConst[Z] = 0;
- addConst[W] = 1;
- break;
-
- case GL_RG_EXT:
- multConst[X] = 1;
- multConst[Y] = 1;
- multConst[Z] = 0;
- multConst[W] = 0;
- addConst[X] = 0;
- addConst[Y] = 0;
- addConst[Z] = 0;
- addConst[W] = 1;
- break;
-
- case GL_RED_EXT:
- multConst[X] = 1;
- multConst[Y] = 0;
- multConst[Z] = 0;
- multConst[W] = 0;
- addConst[X] = 0;
- addConst[Y] = 0;
- addConst[Z] = 0;
- addConst[W] = 1;
- break;
-
- case GL_ALPHA:
- multConst[X] = 0;
- multConst[Y] = 0;
- multConst[Z] = 0;
- multConst[W] = 1;
- addConst[X] = 0;
- addConst[Y] = 0;
- addConst[Z] = 0;
- addConst[W] = 0;
- break;
-
- case GL_LUMINANCE:
- multConst[X] = 1;
- multConst[Y] = 0;
- multConst[Z] = 0;
- multConst[W] = 0;
- addConst[X] = 0;
- addConst[Y] = 0;
- addConst[Z] = 0;
- addConst[W] = 1;
- break;
-
- case GL_LUMINANCE_ALPHA:
- multConst[X] = 1;
- multConst[Y] = 0;
- multConst[Z] = 0;
- multConst[W] = 1;
- addConst[X] = 0;
- addConst[Y] = 0;
- addConst[Z] = 0;
- addConst[W] = 0;
- break;
- }
-
- mRenderer->getDevice()->SetPixelShaderConstantF(0, psConst, 2);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Blit9::copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &sourceRect, IDirect3DTexture9 **outTexture)
-{
- ASSERT(surface);
-
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- D3DSURFACE_DESC sourceDesc;
- surface->GetDesc(&sourceDesc);
-
- // Copy the render target into a texture
- IDirect3DTexture9 *texture;
- HRESULT result = device->CreateTexture(sourceRect.right - sourceRect.left, sourceRect.bottom - sourceRect.top, 1, D3DUSAGE_RENDERTARGET, sourceDesc.Format, D3DPOOL_DEFAULT, &texture, NULL);
-
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate internal texture for blit, result: 0x%X.", result);
- }
-
- IDirect3DSurface9 *textureSurface;
- result = texture->GetSurfaceLevel(0, &textureSurface);
-
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- SafeRelease(texture);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to query surface of internal blit texture, result: 0x%X.", result);
- }
-
- mRenderer->endScene();
- result = device->StretchRect(surface, &sourceRect, textureSurface, NULL, D3DTEXF_NONE);
-
- SafeRelease(textureSurface);
-
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- SafeRelease(texture);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to copy between internal blit textures, result: 0x%X.", result);
- }
-
- *outTexture = texture;
- return gl::Error(GL_NO_ERROR);
-}
-
-void Blit9::setViewport(const RECT &sourceRect, GLint xoffset, GLint yoffset)
-{
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- D3DVIEWPORT9 vp;
- vp.X = xoffset;
- vp.Y = yoffset;
- vp.Width = sourceRect.right - sourceRect.left;
- vp.Height = sourceRect.bottom - sourceRect.top;
- vp.MinZ = 0.0f;
- vp.MaxZ = 1.0f;
- device->SetViewport(&vp);
-
- float halfPixelAdjust[4] = { -1.0f/vp.Width, 1.0f/vp.Height, 0, 0 };
- device->SetVertexShaderConstantF(0, halfPixelAdjust, 1);
-}
-
-void Blit9::setCommonBlitState()
-{
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- device->SetDepthStencilSurface(NULL);
-
- device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
- device->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
- device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
- device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
- device->SetRenderState(D3DRS_SRGBWRITEENABLE, FALSE);
- device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
-
- device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
- device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
- device->SetSamplerState(0, D3DSAMP_SRGBTEXTURE, FALSE);
- device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
- device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
-
- RECT scissorRect = {0}; // Scissoring is disabled for flipping, but we need this to capture and restore the old rectangle
- device->SetScissorRect(&scissorRect);
-
- for(int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- device->SetStreamSourceFreq(i, 1);
- }
-}
-
-void Blit9::render()
-{
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- HRESULT hr = device->SetStreamSource(0, mQuadVertexBuffer, 0, 2 * sizeof(float));
- hr = device->SetVertexDeclaration(mQuadVertexDeclaration);
-
- mRenderer->startScene();
- hr = device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
-}
-
-void Blit9::saveState()
-{
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- HRESULT hr;
-
- device->GetDepthStencilSurface(&mSavedDepthStencil);
- device->GetRenderTarget(0, &mSavedRenderTarget);
-
- if (mSavedStateBlock == NULL)
- {
- hr = device->BeginStateBlock();
- ASSERT(SUCCEEDED(hr) || hr == D3DERR_OUTOFVIDEOMEMORY || hr == E_OUTOFMEMORY);
-
- setCommonBlitState();
-
- static const float dummyConst[8] = { 0 };
-
- device->SetVertexShader(NULL);
- device->SetVertexShaderConstantF(0, dummyConst, 2);
- device->SetPixelShader(NULL);
- device->SetPixelShaderConstantF(0, dummyConst, 2);
-
- D3DVIEWPORT9 dummyVp;
- dummyVp.X = 0;
- dummyVp.Y = 0;
- dummyVp.Width = 1;
- dummyVp.Height = 1;
- dummyVp.MinZ = 0;
- dummyVp.MaxZ = 1;
-
- device->SetViewport(&dummyVp);
-
- device->SetTexture(0, NULL);
-
- device->SetStreamSource(0, mQuadVertexBuffer, 0, 0);
-
- device->SetVertexDeclaration(mQuadVertexDeclaration);
-
- hr = device->EndStateBlock(&mSavedStateBlock);
- ASSERT(SUCCEEDED(hr) || hr == D3DERR_OUTOFVIDEOMEMORY || hr == E_OUTOFMEMORY);
- }
-
- ASSERT(mSavedStateBlock != NULL);
-
- if (mSavedStateBlock != NULL)
- {
- hr = mSavedStateBlock->Capture();
- ASSERT(SUCCEEDED(hr));
- }
-}
-
-void Blit9::restoreState()
-{
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- device->SetDepthStencilSurface(mSavedDepthStencil);
- SafeRelease(mSavedDepthStencil);
-
- device->SetRenderTarget(0, mSavedRenderTarget);
- SafeRelease(mSavedRenderTarget);
-
- ASSERT(mSavedStateBlock != NULL);
-
- if (mSavedStateBlock != NULL)
- {
- mSavedStateBlock->Apply();
- }
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Blit9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Blit9.h
deleted file mode 100644
index 5c7a76ce05..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Blit9.h
+++ /dev/null
@@ -1,97 +0,0 @@
-//
-// Copyright (c) 2002-2010 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.
-//
-
-// Blit9.cpp: Surface copy utility class.
-
-#ifndef LIBGLESV2_BLIT9_H_
-#define LIBGLESV2_BLIT9_H_
-
-#include "common/angleutils.h"
-#include "libGLESv2/Error.h"
-
-#include <GLES2/gl2.h>
-
-namespace gl
-{
-class Framebuffer;
-}
-
-namespace rx
-{
-class Renderer9;
-class TextureStorage;
-
-class Blit9
-{
- public:
- explicit Blit9(Renderer9 *renderer);
- ~Blit9();
-
- gl::Error initialize();
-
- // Copy from source surface to dest surface.
- // sourceRect, xoffset, yoffset are in D3D coordinates (0,0 in upper-left)
- gl::Error copy2D(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level);
- gl::Error copyCube(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level);
-
- // Copy from source surface to dest surface.
- // sourceRect, xoffset, yoffset are in D3D coordinates (0,0 in upper-left)
- // source is interpreted as RGBA and destFormat specifies the desired result format. For example, if destFormat = GL_RGB, the alpha channel will be forced to 0.
- gl::Error formatConvert(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, IDirect3DSurface9 *dest);
-
- // 2x2 box filter sample from source to dest.
- // Requires that source is RGB(A) and dest has the same format as source.
- gl::Error boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest);
-
- private:
- Renderer9 *mRenderer;
-
- bool mGeometryLoaded;
- IDirect3DVertexBuffer9 *mQuadVertexBuffer;
- IDirect3DVertexDeclaration9 *mQuadVertexDeclaration;
-
- gl::Error setFormatConvertShaders(GLenum destFormat);
-
- gl::Error copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, IDirect3DSurface9 *dest);
- gl::Error copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &sourceRect, IDirect3DTexture9 **outTexture);
- void setViewport(const RECT &sourceRect, GLint xoffset, GLint yoffset);
- void setCommonBlitState();
- RECT getSurfaceRect(IDirect3DSurface9 *surface) const;
-
- // This enum is used to index mCompiledShaders and mShaderSource.
- enum ShaderId
- {
- SHADER_VS_STANDARD,
- SHADER_VS_FLIPY,
- SHADER_PS_PASSTHROUGH,
- SHADER_PS_LUMINANCE,
- SHADER_PS_COMPONENTMASK,
- SHADER_COUNT
- };
-
- // This actually contains IDirect3DVertexShader9 or IDirect3DPixelShader9 casted to IUnknown.
- IUnknown *mCompiledShaders[SHADER_COUNT];
-
- template <class D3DShaderType>
- gl::Error setShader(ShaderId source, const char *profile,
- gl::Error (Renderer9::*createShader)(const DWORD *, size_t length, D3DShaderType **outShader),
- HRESULT (WINAPI IDirect3DDevice9::*setShader)(D3DShaderType*));
-
- gl::Error setVertexShader(ShaderId shader);
- gl::Error setPixelShader(ShaderId shader);
- void render();
-
- void saveState();
- void restoreState();
- IDirect3DStateBlock9 *mSavedStateBlock;
- IDirect3DSurface9 *mSavedRenderTarget;
- IDirect3DSurface9 *mSavedDepthStencil;
-
- DISALLOW_COPY_AND_ASSIGN(Blit9);
-};
-}
-
-#endif // LIBGLESV2_BLIT9_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Buffer9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Buffer9.cpp
deleted file mode 100644
index 430fe81e50..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Buffer9.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// Buffer9.cpp Defines the Buffer9 class.
-
-#include "libGLESv2/renderer/d3d/d3d9/Buffer9.h"
-#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
-#include "libGLESv2/main.h"
-
-namespace rx
-{
-
-Buffer9::Buffer9(Renderer9 *renderer)
- : BufferD3D(),
- mRenderer(renderer),
- mSize(0)
-{}
-
-Buffer9::~Buffer9()
-{
- mSize = 0;
-}
-
-Buffer9 *Buffer9::makeBuffer9(BufferImpl *buffer)
-{
- ASSERT(HAS_DYNAMIC_TYPE(Buffer9*, buffer));
- return static_cast<Buffer9*>(buffer);
-}
-
-gl::Error Buffer9::setData(const void* data, size_t size, GLenum usage)
-{
- if (size > mMemory.size())
- {
- if (!mMemory.resize(size))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to resize internal buffer.");
- }
- }
-
- mSize = size;
- if (data && size > 0)
- {
- memcpy(mMemory.data(), data, size);
- }
-
- invalidateStaticData();
-
- if (usage == GL_STATIC_DRAW)
- {
- initializeStaticData();
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Buffer9::getData(const uint8_t **outData)
-{
- *outData = mMemory.data();
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Buffer9::setSubData(const void* data, size_t size, size_t offset)
-{
- if (offset + size > mMemory.size())
- {
- if (!mMemory.resize(offset + size))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to resize internal buffer.");
- }
- }
-
- mSize = std::max(mSize, offset + size);
- if (data && size > 0)
- {
- memcpy(mMemory.data() + offset, data, size);
- }
-
- invalidateStaticData();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Buffer9::copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size)
-{
- // Note: this method is currently unreachable
- Buffer9* sourceBuffer = makeBuffer9(source);
- ASSERT(sourceBuffer);
-
- memcpy(mMemory.data() + destOffset, sourceBuffer->mMemory.data() + sourceOffset, size);
-
- invalidateStaticData();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-// We do not support buffer mapping in D3D9
-gl::Error Buffer9::map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr)
-{
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
-}
-
-gl::Error Buffer9::unmap()
-{
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
-}
-
-void Buffer9::markTransformFeedbackUsage()
-{
- UNREACHABLE();
-}
-
-RendererD3D *Buffer9::getRenderer()
-{
- return mRenderer;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Buffer9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Buffer9.h
deleted file mode 100644
index c80b009738..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Buffer9.h
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// Buffer9.h: Defines the rx::Buffer9 class which implements rx::BufferImpl via rx::BufferD3D.
-
-#ifndef LIBGLESV2_RENDERER_BUFFER9_H_
-#define LIBGLESV2_RENDERER_BUFFER9_H_
-
-#include "libGLESv2/renderer/d3d/BufferD3D.h"
-#include "libGLESv2/renderer/d3d/MemoryBuffer.h"
-#include "libGLESv2/angletypes.h"
-
-namespace rx
-{
-class Renderer9;
-
-class Buffer9 : public BufferD3D
-{
- public:
- Buffer9(Renderer9 *renderer);
- virtual ~Buffer9();
-
- static Buffer9 *makeBuffer9(BufferImpl *buffer);
-
- // BufferD3D implementation
- virtual size_t getSize() const { return mSize; }
- virtual bool supportsDirectBinding() const { return false; }
- RendererD3D *getRenderer() override;
-
- // BufferImpl implementation
- virtual gl::Error setData(const void* data, size_t size, GLenum usage);
- gl::Error getData(const uint8_t **outData) override;
- virtual gl::Error setSubData(const void* data, size_t size, size_t offset);
- virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size);
- virtual gl::Error map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr);
- virtual gl::Error unmap();
- virtual void markTransformFeedbackUsage();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Buffer9);
-
- Renderer9 *mRenderer;
- MemoryBuffer mMemory;
- size_t mSize;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_BUFFER9_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Fence9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Fence9.cpp
deleted file mode 100644
index 66263fe110..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Fence9.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// Fence9.cpp: Defines the rx::FenceNV9 class.
-
-#include "libGLESv2/renderer/d3d/d3d9/Fence9.h"
-#include "libGLESv2/renderer/d3d/d3d9/renderer9_utils.h"
-#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
-#include "libGLESv2/main.h"
-
-namespace rx
-{
-
-FenceNV9::FenceNV9(Renderer9 *renderer)
- : FenceNVImpl(),
- mRenderer(renderer),
- mQuery(NULL)
-{
-}
-
-FenceNV9::~FenceNV9()
-{
- SafeRelease(mQuery);
-}
-
-gl::Error FenceNV9::set()
-{
- if (!mQuery)
- {
- gl::Error error = mRenderer->allocateEventQuery(&mQuery);
- if (error.isError())
- {
- return error;
- }
- }
-
- HRESULT result = mQuery->Issue(D3DISSUE_END);
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- SafeRelease(mQuery);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to end event query, result: 0x%X.", result);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error FenceNV9::test(bool flushCommandBuffer, GLboolean *outFinished)
-{
- ASSERT(mQuery);
-
- DWORD getDataFlags = (flushCommandBuffer ? D3DGETDATA_FLUSH : 0);
- HRESULT result = mQuery->GetData(NULL, 0, getDataFlags);
-
- if (d3d9::isDeviceLostError(result))
- {
- mRenderer->notifyDeviceLost();
- return gl::Error(GL_OUT_OF_MEMORY, "Device was lost while querying result of an event query.");
- }
- else if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to get query data, result: 0x%X.", result);
- }
-
- ASSERT(result == S_OK || result == S_FALSE);
- *outFinished = ((result == S_OK) ? GL_TRUE : GL_FALSE);
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error FenceNV9::finishFence(GLboolean *outFinished)
-{
- ASSERT(outFinished);
-
- while (*outFinished != GL_TRUE)
- {
- gl::Error error = test(true, outFinished);
- if (error.isError())
- {
- return error;
- }
-
- Sleep(0);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Fence9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Fence9.h
deleted file mode 100644
index d7873d5264..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Fence9.h
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// Fence9.h: Defines the rx::FenceNV9 class which implements rx::FenceNVImpl.
-
-#ifndef LIBGLESV2_RENDERER_FENCE9_H_
-#define LIBGLESV2_RENDERER_FENCE9_H_
-
-#include "libGLESv2/renderer/FenceImpl.h"
-
-namespace rx
-{
-class Renderer9;
-
-class FenceNV9 : public FenceNVImpl
-{
- public:
- explicit FenceNV9(Renderer9 *renderer);
- virtual ~FenceNV9();
-
- gl::Error set();
- gl::Error test(bool flushCommandBuffer, GLboolean *outFinished);
- gl::Error finishFence(GLboolean *outFinished);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FenceNV9);
-
- Renderer9 *mRenderer;
- IDirect3DQuery9 *mQuery;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_FENCE9_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Image9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Image9.cpp
deleted file mode 100644
index 2a06d12942..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Image9.cpp
+++ /dev/null
@@ -1,792 +0,0 @@
-//
-// 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.
-//
-
-// Image9.cpp: Implements the rx::Image9 class, which acts as the interface to
-// the actual underlying surfaces of a Texture.
-
-#include "libGLESv2/renderer/d3d/d3d9/Image9.h"
-#include "libGLESv2/renderer/d3d/d3d9/renderer9_utils.h"
-#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h"
-#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
-#include "libGLESv2/renderer/d3d/d3d9/RenderTarget9.h"
-#include "libGLESv2/renderer/d3d/d3d9/TextureStorage9.h"
-#include "libGLESv2/main.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/FramebufferAttachment.h"
-#include "libGLESv2/Renderbuffer.h"
-#include "common/utilities.h"
-
-namespace rx
-{
-
-Image9::Image9()
-{
- mSurface = NULL;
- mRenderer = NULL;
-
- mD3DPool = D3DPOOL_SYSTEMMEM;
- mD3DFormat = D3DFMT_UNKNOWN;
-}
-
-Image9::~Image9()
-{
- SafeRelease(mSurface);
-}
-
-gl::Error Image9::generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 *sourceSurface)
-{
- D3DSURFACE_DESC destDesc;
- HRESULT result = destSurface->GetDesc(&destDesc);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to query the source surface description for mipmap generation, result: 0x%X.", result);
- }
-
- D3DSURFACE_DESC sourceDesc;
- result = sourceSurface->GetDesc(&sourceDesc);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to query the destination surface description for mipmap generation, result: 0x%X.", result);
- }
-
- ASSERT(sourceDesc.Format == destDesc.Format);
- ASSERT(sourceDesc.Width == 1 || sourceDesc.Width / 2 == destDesc.Width);
- ASSERT(sourceDesc.Height == 1 || sourceDesc.Height / 2 == destDesc.Height);
-
- const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(sourceDesc.Format);
- ASSERT(d3dFormatInfo.mipGenerationFunction != NULL);
-
- D3DLOCKED_RECT sourceLocked = {0};
- result = sourceSurface->LockRect(&sourceLocked, NULL, D3DLOCK_READONLY);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock the source surface for mipmap generation, result: 0x%X.", result);
- }
-
- D3DLOCKED_RECT destLocked = {0};
- result = destSurface->LockRect(&destLocked, NULL, 0);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- sourceSurface->UnlockRect();
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock the destination surface for mipmap generation, result: 0x%X.", result);
- }
-
- const uint8_t *sourceData = reinterpret_cast<const uint8_t*>(sourceLocked.pBits);
- uint8_t *destData = reinterpret_cast<uint8_t*>(destLocked.pBits);
-
- ASSERT(sourceData && destData);
-
- d3dFormatInfo.mipGenerationFunction(sourceDesc.Width, sourceDesc.Height, 1, sourceData, sourceLocked.Pitch, 0,
- destData, destLocked.Pitch, 0);
-
- destSurface->UnlockRect();
- sourceSurface->UnlockRect();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-Image9 *Image9::makeImage9(Image *img)
-{
- ASSERT(HAS_DYNAMIC_TYPE(Image9*, img));
- return static_cast<Image9*>(img);
-}
-
-gl::Error Image9::generateMipmap(Image9 *dest, Image9 *source)
-{
- IDirect3DSurface9 *sourceSurface = NULL;
- gl::Error error = source->getSurface(&sourceSurface);
- if (error.isError())
- {
- return error;
- }
-
- IDirect3DSurface9 *destSurface = NULL;
- error = dest->getSurface(&destSurface);
- if (error.isError())
- {
- return error;
- }
-
- error = generateMip(destSurface, sourceSurface);
- if (error.isError())
- {
- return error;
- }
-
- dest->markDirty();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Image9::copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface9 *source)
-{
- D3DLOCKED_RECT sourceLock = {0};
- D3DLOCKED_RECT destLock = {0};
-
- HRESULT result;
-
- result = source->LockRect(&sourceLock, NULL, 0);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock source surface for copy, result: 0x%X.", result);
- }
-
- result = dest->LockRect(&destLock, NULL, 0);
- if (FAILED(result))
- {
- source->UnlockRect();
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock source surface for copy, result: 0x%X.", result);
- }
-
- ASSERT(sourceLock.pBits && destLock.pBits);
-
- D3DSURFACE_DESC desc;
- source->GetDesc(&desc);
-
- const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(desc.Format);
- unsigned int rows = desc.Height / d3dFormatInfo.blockHeight;
-
- unsigned int bytes = d3d9::ComputeBlockSize(desc.Format, desc.Width, d3dFormatInfo.blockHeight);
- ASSERT(bytes <= static_cast<unsigned int>(sourceLock.Pitch) &&
- bytes <= static_cast<unsigned int>(destLock.Pitch));
-
- for(unsigned int i = 0; i < rows; i++)
- {
- memcpy((char*)destLock.pBits + destLock.Pitch * i, (char*)sourceLock.pBits + sourceLock.Pitch * i, bytes);
- }
-
- source->UnlockRect();
- dest->UnlockRect();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-bool Image9::redefine(RendererD3D *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease)
-{
- // 3D textures are not supported by the D3D9 backend.
- ASSERT(depth <= 1);
-
- // Only 2D and cube texture are supported by the D3D9 backend.
- ASSERT(target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP);
-
- if (mWidth != width ||
- mHeight != height ||
- mDepth != depth ||
- mInternalFormat != internalformat ||
- forceRelease)
- {
- mRenderer = Renderer9::makeRenderer9(renderer);
-
- mWidth = width;
- mHeight = height;
- mDepth = depth;
- mInternalFormat = internalformat;
-
- // compute the d3d format that will be used
- const d3d9::TextureFormat &d3d9FormatInfo = d3d9::GetTextureFormatInfo(internalformat);
- const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(d3d9FormatInfo.texFormat);
- mD3DFormat = d3d9FormatInfo.texFormat;
- mActualFormat = d3dFormatInfo.internalFormat;
- mRenderable = (d3d9FormatInfo.renderFormat != D3DFMT_UNKNOWN);
-
- SafeRelease(mSurface);
- mDirty = (d3d9FormatInfo.dataInitializerFunction != NULL);
-
- return true;
- }
-
- return false;
-}
-
-gl::Error Image9::createSurface()
-{
- if (mSurface)
- {
- return gl::Error(GL_NO_ERROR);
- }
-
- IDirect3DTexture9 *newTexture = NULL;
- IDirect3DSurface9 *newSurface = NULL;
- const D3DPOOL poolToUse = D3DPOOL_SYSTEMMEM;
- const D3DFORMAT d3dFormat = getD3DFormat();
-
- if (mWidth != 0 && mHeight != 0)
- {
- int levelToFetch = 0;
- GLsizei requestWidth = mWidth;
- GLsizei requestHeight = mHeight;
- d3d9::MakeValidSize(true, d3dFormat, &requestWidth, &requestHeight, &levelToFetch);
-
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- HRESULT result = device->CreateTexture(requestWidth, requestHeight, levelToFetch + 1, 0, d3dFormat,
- poolToUse, &newTexture, NULL);
-
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create image surface, result: 0x%X.", result);
- }
-
- newTexture->GetSurfaceLevel(levelToFetch, &newSurface);
- SafeRelease(newTexture);
-
- const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat);
- if (d3dFormatInfo.dataInitializerFunction != NULL)
- {
- RECT entireRect;
- entireRect.left = 0;
- entireRect.right = mWidth;
- entireRect.top = 0;
- entireRect.bottom = mHeight;
-
- D3DLOCKED_RECT lockedRect;
- result = newSurface->LockRect(&lockedRect, &entireRect, 0);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock image surface, result: 0x%X.", result);
- }
-
- d3dFormatInfo.dataInitializerFunction(mWidth, mHeight, 1, reinterpret_cast<uint8_t*>(lockedRect.pBits),
- lockedRect.Pitch, 0);
-
- result = newSurface->UnlockRect();
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to unlock image surface, result: 0x%X.", result);
- }
- }
- }
-
- mSurface = newSurface;
- mDirty = false;
- mD3DPool = poolToUse;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Image9::lock(D3DLOCKED_RECT *lockedRect, const RECT &rect)
-{
- gl::Error error = createSurface();
- if (error.isError())
- {
- return error;
- }
-
- if (mSurface)
- {
- HRESULT result = mSurface->LockRect(lockedRect, &rect, 0);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock image surface, result: 0x%X.", result);
- }
-
- mDirty = true;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void Image9::unlock()
-{
- if (mSurface)
- {
- HRESULT result = mSurface->UnlockRect();
- UNUSED_ASSERTION_VARIABLE(result);
- ASSERT(SUCCEEDED(result));
- }
-}
-
-D3DFORMAT Image9::getD3DFormat() const
-{
- // this should only happen if the image hasn't been redefined first
- // which would be a bug by the caller
- ASSERT(mD3DFormat != D3DFMT_UNKNOWN);
-
- return mD3DFormat;
-}
-
-bool Image9::isDirty() const
-{
- // Make sure to that this image is marked as dirty even if the staging texture hasn't been created yet
- // if initialization is required before use.
- return (mSurface || d3d9::GetTextureFormatInfo(mInternalFormat).dataInitializerFunction != NULL) && mDirty;
-}
-
-gl::Error Image9::getSurface(IDirect3DSurface9 **outSurface)
-{
- gl::Error error = createSurface();
- if (error.isError())
- {
- return error;
- }
-
- *outSurface = mSurface;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Image9::setManagedSurface2D(TextureStorage *storage, int level)
-{
- IDirect3DSurface9 *surface = NULL;
- TextureStorage9_2D *storage9 = TextureStorage9_2D::makeTextureStorage9_2D(storage);
- gl::Error error = storage9->getSurfaceLevel(level, false, &surface);
- if (error.isError())
- {
- return error;
- }
- return setManagedSurface(surface);
-}
-
-gl::Error Image9::setManagedSurfaceCube(TextureStorage *storage, int face, int level)
-{
- IDirect3DSurface9 *surface = NULL;
- TextureStorage9_Cube *storage9 = TextureStorage9_Cube::makeTextureStorage9_Cube(storage);
- gl::Error error = storage9->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level, false, &surface);
- if (error.isError())
- {
- return error;
- }
- return setManagedSurface(surface);
-}
-
-gl::Error Image9::setManagedSurface(IDirect3DSurface9 *surface)
-{
- D3DSURFACE_DESC desc;
- surface->GetDesc(&desc);
- ASSERT(desc.Pool == D3DPOOL_MANAGED);
-
- if ((GLsizei)desc.Width == mWidth && (GLsizei)desc.Height == mHeight)
- {
- if (mSurface)
- {
- gl::Error error = copyLockableSurfaces(surface, mSurface);
- SafeRelease(mSurface);
- if (error.isError())
- {
- return error;
- }
- }
-
- mSurface = surface;
- mD3DPool = desc.Pool;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Image9::copyToStorage(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region)
-{
- gl::Error error = createSurface();
- if (error.isError())
- {
- return error;
- }
-
- IDirect3DSurface9 *destSurface = NULL;
-
- if (index.type == GL_TEXTURE_2D)
- {
- TextureStorage9_2D *storage9 = TextureStorage9_2D::makeTextureStorage9_2D(storage);
- gl::Error error = storage9->getSurfaceLevel(index.mipIndex, true, &destSurface);
- if (error.isError())
- {
- return error;
- }
- }
- else
- {
- ASSERT(gl::IsCubemapTextureTarget(index.type));
- TextureStorage9_Cube *storage9 = TextureStorage9_Cube::makeTextureStorage9_Cube(storage);
- gl::Error error = storage9->getCubeMapSurface(index.type, index.mipIndex, true, &destSurface);
- if (error.isError())
- {
- return error;
- }
- }
-
- error = copyToSurface(destSurface, region.x, region.y, region.width, region.height);
- SafeRelease(destSurface);
- return error;
-}
-
-gl::Error Image9::copyToSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
-{
- ASSERT(width > 0 && height > 0);
- ASSERT(destSurface);
-
- IDirect3DSurface9 *sourceSurface = NULL;
- gl::Error error = getSurface(&sourceSurface);
- if (error.isError())
- {
- return error;
- }
-
- ASSERT(sourceSurface && sourceSurface != destSurface);
-
- RECT rect;
- rect.left = xoffset;
- rect.top = yoffset;
- rect.right = xoffset + width;
- rect.bottom = yoffset + height;
-
- POINT point = {rect.left, rect.top};
-
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- if (mD3DPool == D3DPOOL_MANAGED)
- {
- D3DSURFACE_DESC desc;
- sourceSurface->GetDesc(&desc);
-
- IDirect3DSurface9 *surf = 0;
- HRESULT result = device->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surf, NULL);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal CreateOffscreenPlainSurface call failed, result: 0x%X.", result);
- }
-
- copyLockableSurfaces(surf, sourceSurface);
- result = device->UpdateSurface(surf, &rect, destSurface, &point);
- SafeRelease(surf);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal UpdateSurface call failed, result: 0x%X.", result);
- }
- }
- else
- {
- // UpdateSurface: source must be SYSTEMMEM, dest must be DEFAULT pools
- HRESULT result = device->UpdateSurface(sourceSurface, &rect, destSurface, &point);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal UpdateSurface call failed, result: 0x%X.", result);
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-// Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input
-// into the target pixel rectangle.
-gl::Error Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
- GLint unpackAlignment, GLenum type, const void *input)
-{
- // 3D textures are not supported by the D3D9 backend.
- ASSERT(zoffset == 0 && depth == 1);
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
- GLsizei inputRowPitch = formatInfo.computeRowPitch(type, width, unpackAlignment);
-
- const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat);
- ASSERT(d3dFormatInfo.loadFunction != NULL);
-
- RECT lockRect =
- {
- xoffset, yoffset,
- xoffset + width, yoffset + height
- };
-
- D3DLOCKED_RECT locked;
- gl::Error error = lock(&locked, lockRect);
- if (error.isError())
- {
- return error;
- }
-
- d3dFormatInfo.loadFunction(width, height, depth,
- reinterpret_cast<const uint8_t*>(input), inputRowPitch, 0,
- reinterpret_cast<uint8_t*>(locked.pBits), locked.Pitch, 0);
-
- unlock();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
- const void *input)
-{
- // 3D textures are not supported by the D3D9 backend.
- ASSERT(zoffset == 0 && depth == 1);
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
- GLsizei inputRowPitch = formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, width, 1);
- GLsizei inputDepthPitch = formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, width, height, 1);
-
- const d3d9::TextureFormat &d3d9FormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat);
-
- ASSERT(xoffset % d3d9::GetD3DFormatInfo(d3d9FormatInfo.texFormat).blockWidth == 0);
- ASSERT(yoffset % d3d9::GetD3DFormatInfo(d3d9FormatInfo.texFormat).blockHeight == 0);
-
- ASSERT(d3d9FormatInfo.loadFunction != NULL);
-
- RECT lockRect =
- {
- xoffset, yoffset,
- xoffset + width, yoffset + height
- };
-
- D3DLOCKED_RECT locked;
- gl::Error error = lock(&locked, lockRect);
- if (error.isError())
- {
- return error;
- }
-
- d3d9FormatInfo.loadFunction(width, height, depth,
- reinterpret_cast<const uint8_t*>(input), inputRowPitch, inputDepthPitch,
- reinterpret_cast<uint8_t*>(locked.pBits), locked.Pitch, 0);
-
- unlock();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-// This implements glCopyTex[Sub]Image2D for non-renderable internal texture formats and incomplete textures
-gl::Error Image9::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source)
-{
- ASSERT(source);
-
- // ES3.0 only behaviour to copy into a 3d texture
- ASSERT(zoffset == 0);
-
- RenderTarget9 *renderTarget = RenderTarget9::makeRenderTarget9(source);
-
- IDirect3DSurface9 *surface = renderTarget->getSurface();
- ASSERT(surface);
-
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- IDirect3DSurface9 *renderTargetData = NULL;
- D3DSURFACE_DESC description;
- surface->GetDesc(&description);
-
- HRESULT result = device->CreateOffscreenPlainSurface(description.Width, description.Height, description.Format, D3DPOOL_SYSTEMMEM, &renderTargetData, NULL);
-
- if (FAILED(result))
- {
- SafeRelease(surface);
- return gl::Error(GL_OUT_OF_MEMORY, "Could not create matching destination surface, result: 0x%X.", result);
- }
-
- result = device->GetRenderTargetData(surface, renderTargetData);
-
- if (FAILED(result))
- {
- SafeRelease(renderTargetData);
- SafeRelease(surface);
- return gl::Error(GL_OUT_OF_MEMORY, "GetRenderTargetData unexpectedly failed, result: 0x%X.", result);
- }
-
- int width = sourceArea.width;
- int height = sourceArea.height;
-
- RECT sourceRect = { sourceArea.x, sourceArea.y, sourceArea.x + width, sourceArea.y + height };
- RECT destRect = { xoffset, yoffset, xoffset + width, yoffset + height };
-
- D3DLOCKED_RECT sourceLock = {0};
- result = renderTargetData->LockRect(&sourceLock, &sourceRect, 0);
-
- if (FAILED(result))
- {
- SafeRelease(renderTargetData);
- SafeRelease(surface);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock the source surface (rectangle might be invalid), result: 0x%X.", result);
- }
-
- D3DLOCKED_RECT destLock = {0};
- gl::Error error = lock(&destLock, destRect);
- if (error.isError())
- {
- renderTargetData->UnlockRect();
- SafeRelease(renderTargetData);
- SafeRelease(surface);
- return error;
- }
-
- ASSERT(destLock.pBits && sourceLock.pBits);
-
- unsigned char *sourcePixels = (unsigned char*)sourceLock.pBits;
- unsigned char *destPixels = (unsigned char*)destLock.pBits;
-
- switch (description.Format)
- {
- case D3DFMT_X8R8G8B8:
- case D3DFMT_A8R8G8B8:
- switch (getD3DFormat())
- {
- case D3DFMT_X8R8G8B8:
- case D3DFMT_A8R8G8B8:
- for (int y = 0; y < height; y++)
- {
- memcpy(destPixels, sourcePixels, 4 * width);
- sourcePixels += sourceLock.Pitch;
- destPixels += destLock.Pitch;
- }
- break;
- case D3DFMT_L8:
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
- destPixels[x] = sourcePixels[x * 4 + 2];
- }
- sourcePixels += sourceLock.Pitch;
- destPixels += destLock.Pitch;
- }
- break;
- case D3DFMT_A8L8:
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
- destPixels[x * 2 + 0] = sourcePixels[x * 4 + 2];
- destPixels[x * 2 + 1] = sourcePixels[x * 4 + 3];
- }
- sourcePixels += sourceLock.Pitch;
- destPixels += destLock.Pitch;
- }
- break;
- default:
- UNREACHABLE();
- }
- break;
- case D3DFMT_R5G6B5:
- switch (getD3DFormat())
- {
- case D3DFMT_X8R8G8B8:
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
- unsigned short rgb = ((unsigned short*)sourcePixels)[x];
- unsigned char red = (rgb & 0xF800) >> 8;
- unsigned char green = (rgb & 0x07E0) >> 3;
- unsigned char blue = (rgb & 0x001F) << 3;
- destPixels[x + 0] = blue | (blue >> 5);
- destPixels[x + 1] = green | (green >> 6);
- destPixels[x + 2] = red | (red >> 5);
- destPixels[x + 3] = 0xFF;
- }
- sourcePixels += sourceLock.Pitch;
- destPixels += destLock.Pitch;
- }
- break;
- case D3DFMT_L8:
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
- unsigned char red = sourcePixels[x * 2 + 1] & 0xF8;
- destPixels[x] = red | (red >> 5);
- }
- sourcePixels += sourceLock.Pitch;
- destPixels += destLock.Pitch;
- }
- break;
- default:
- UNREACHABLE();
- }
- break;
- case D3DFMT_A1R5G5B5:
- switch (getD3DFormat())
- {
- case D3DFMT_X8R8G8B8:
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
- unsigned short argb = ((unsigned short*)sourcePixels)[x];
- unsigned char red = (argb & 0x7C00) >> 7;
- unsigned char green = (argb & 0x03E0) >> 2;
- unsigned char blue = (argb & 0x001F) << 3;
- destPixels[x + 0] = blue | (blue >> 5);
- destPixels[x + 1] = green | (green >> 5);
- destPixels[x + 2] = red | (red >> 5);
- destPixels[x + 3] = 0xFF;
- }
- sourcePixels += sourceLock.Pitch;
- destPixels += destLock.Pitch;
- }
- break;
- case D3DFMT_A8R8G8B8:
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
- unsigned short argb = ((unsigned short*)sourcePixels)[x];
- unsigned char red = (argb & 0x7C00) >> 7;
- unsigned char green = (argb & 0x03E0) >> 2;
- unsigned char blue = (argb & 0x001F) << 3;
- unsigned char alpha = (signed short)argb >> 15;
- destPixels[x + 0] = blue | (blue >> 5);
- destPixels[x + 1] = green | (green >> 5);
- destPixels[x + 2] = red | (red >> 5);
- destPixels[x + 3] = alpha;
- }
- sourcePixels += sourceLock.Pitch;
- destPixels += destLock.Pitch;
- }
- break;
- case D3DFMT_L8:
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
- unsigned char red = sourcePixels[x * 2 + 1] & 0x7C;
- destPixels[x] = (red << 1) | (red >> 4);
- }
- sourcePixels += sourceLock.Pitch;
- destPixels += destLock.Pitch;
- }
- break;
- case D3DFMT_A8L8:
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
- unsigned char red = sourcePixels[x * 2 + 1] & 0x7C;
- destPixels[x * 2 + 0] = (red << 1) | (red >> 4);
- destPixels[x * 2 + 1] = (signed char)sourcePixels[x * 2 + 1] >> 7;
- }
- sourcePixels += sourceLock.Pitch;
- destPixels += destLock.Pitch;
- }
- break;
- default:
- UNREACHABLE();
- }
- break;
- default:
- UNREACHABLE();
- }
-
- unlock();
- renderTargetData->UnlockRect();
-
- SafeRelease(renderTargetData);
- SafeRelease(surface);
-
- mDirty = true;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Image9::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &area, const gl::ImageIndex &srcIndex, TextureStorage *srcStorage)
-{
- // Currently unreachable, due to only being used in a D3D11-only workaround
- UNIMPLEMENTED();
- return gl::Error(GL_INVALID_OPERATION);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Image9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Image9.h
deleted file mode 100644
index 8cc2258859..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Image9.h
+++ /dev/null
@@ -1,77 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// Image9.h: Defines the rx::Image9 class, which acts as the interface to
-// the actual underlying surfaces of a Texture.
-
-#ifndef LIBGLESV2_RENDERER_IMAGE9_H_
-#define LIBGLESV2_RENDERER_IMAGE9_H_
-
-#include "libGLESv2/renderer/d3d/ImageD3D.h"
-#include "common/debug.h"
-
-namespace gl
-{
-class Framebuffer;
-}
-
-namespace rx
-{
-class Renderer9;
-
-class Image9 : public ImageD3D
-{
- public:
- Image9();
- ~Image9();
-
- static Image9 *makeImage9(Image *img);
-
- static gl::Error generateMipmap(Image9 *dest, Image9 *source);
- static gl::Error generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 *sourceSurface);
- static gl::Error copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface9 *source);
-
- bool redefine(RendererD3D *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease) override;
-
- D3DFORMAT getD3DFormat() const;
-
- virtual bool isDirty() const;
-
- virtual gl::Error setManagedSurface2D(TextureStorage *storage, int level);
- virtual gl::Error setManagedSurfaceCube(TextureStorage *storage, int face, int level);
- virtual gl::Error copyToStorage(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region);
-
- virtual gl::Error loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
- GLint unpackAlignment, GLenum type, const void *input);
- virtual gl::Error loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
- const void *input);
-
- virtual gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source);
- virtual gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea,
- const gl::ImageIndex &sourceIndex, TextureStorage *source);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Image9);
-
- gl::Error getSurface(IDirect3DSurface9 **outSurface);
-
- gl::Error createSurface();
- gl::Error setManagedSurface(IDirect3DSurface9 *surface);
- gl::Error copyToSurface(IDirect3DSurface9 *dest, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
-
- gl::Error lock(D3DLOCKED_RECT *lockedRect, const RECT &rect);
- void unlock();
-
- Renderer9 *mRenderer;
-
- D3DPOOL mD3DPool; // can only be D3DPOOL_SYSTEMMEM or D3DPOOL_MANAGED since it needs to be lockable.
- D3DFORMAT mD3DFormat;
-
- IDirect3DSurface9 *mSurface;
-};
-}
-
-#endif // LIBGLESV2_RENDERER_IMAGE9_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.cpp
deleted file mode 100644
index 1c51b9e985..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// Indexffer9.cpp: Defines the D3D9 IndexBuffer implementation.
-
-#include "libGLESv2/renderer/d3d/d3d9/IndexBuffer9.h"
-#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
-
-namespace rx
-{
-
-IndexBuffer9::IndexBuffer9(Renderer9 *const renderer) : mRenderer(renderer)
-{
- mIndexBuffer = NULL;
- mBufferSize = 0;
- mIndexType = 0;
- mDynamic = false;
-}
-
-IndexBuffer9::~IndexBuffer9()
-{
- SafeRelease(mIndexBuffer);
-}
-
-gl::Error IndexBuffer9::initialize(unsigned int bufferSize, GLenum indexType, bool dynamic)
-{
- SafeRelease(mIndexBuffer);
-
- updateSerial();
-
- if (bufferSize > 0)
- {
- D3DFORMAT format = D3DFMT_UNKNOWN;
- if (indexType == GL_UNSIGNED_SHORT || indexType == GL_UNSIGNED_BYTE)
- {
- format = D3DFMT_INDEX16;
- }
- else if (indexType == GL_UNSIGNED_INT)
- {
- ASSERT(mRenderer->getRendererExtensions().elementIndexUint);
- format = D3DFMT_INDEX32;
- }
- else UNREACHABLE();
-
- DWORD usageFlags = D3DUSAGE_WRITEONLY;
- if (dynamic)
- {
- usageFlags |= D3DUSAGE_DYNAMIC;
- }
-
- HRESULT result = mRenderer->createIndexBuffer(bufferSize, usageFlags, format, &mIndexBuffer);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate internal index buffer of size, %lu.", bufferSize);
- }
- }
-
- mBufferSize = bufferSize;
- mIndexType = indexType;
- mDynamic = dynamic;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-IndexBuffer9 *IndexBuffer9::makeIndexBuffer9(IndexBuffer *indexBuffer)
-{
- ASSERT(HAS_DYNAMIC_TYPE(IndexBuffer9*, indexBuffer));
- return static_cast<IndexBuffer9*>(indexBuffer);
-}
-
-gl::Error IndexBuffer9::mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory)
-{
- if (!mIndexBuffer)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal index buffer is not initialized.");
- }
-
- DWORD lockFlags = mDynamic ? D3DLOCK_NOOVERWRITE : 0;
-
- void *mapPtr = NULL;
- HRESULT result = mIndexBuffer->Lock(offset, size, &mapPtr, lockFlags);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock internal index buffer, HRESULT: 0x%08x.", result);
- }
-
- *outMappedMemory = mapPtr;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error IndexBuffer9::unmapBuffer()
-{
- if (!mIndexBuffer)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal index buffer is not initialized.");
- }
-
- HRESULT result = mIndexBuffer->Unlock();
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to unlock internal index buffer, HRESULT: 0x%08x.", result);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-GLenum IndexBuffer9::getIndexType() const
-{
- return mIndexType;
-}
-
-unsigned int IndexBuffer9::getBufferSize() const
-{
- return mBufferSize;
-}
-
-gl::Error IndexBuffer9::setSize(unsigned int bufferSize, GLenum indexType)
-{
- if (bufferSize > mBufferSize || indexType != mIndexType)
- {
- return initialize(bufferSize, indexType, mDynamic);
- }
- else
- {
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-gl::Error IndexBuffer9::discard()
-{
- if (!mIndexBuffer)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal index buffer is not initialized.");
- }
-
- void *dummy;
- HRESULT result;
-
- result = mIndexBuffer->Lock(0, 1, &dummy, D3DLOCK_DISCARD);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock internal index buffer, HRESULT: 0x%08x.", result);
- }
-
- result = mIndexBuffer->Unlock();
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to unlock internal index buffer, HRESULT: 0x%08x.", result);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-D3DFORMAT IndexBuffer9::getIndexFormat() const
-{
- switch (mIndexType)
- {
- case GL_UNSIGNED_BYTE: return D3DFMT_INDEX16;
- case GL_UNSIGNED_SHORT: return D3DFMT_INDEX16;
- case GL_UNSIGNED_INT: return D3DFMT_INDEX32;
- default: UNREACHABLE(); return D3DFMT_UNKNOWN;
- }
-}
-
-IDirect3DIndexBuffer9 * IndexBuffer9::getBuffer() const
-{
- return mIndexBuffer;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.h
deleted file mode 100644
index 2375fcf4b0..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.h
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// 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.
-//
-
-// Indexffer9.h: Defines the D3D9 IndexBuffer implementation.
-
-#ifndef LIBGLESV2_RENDERER_INDEXBUFFER9_H_
-#define LIBGLESV2_RENDERER_INDEXBUFFER9_H_
-
-#include "libGLESv2/renderer/d3d/IndexBuffer.h"
-
-namespace rx
-{
-class Renderer9;
-
-class IndexBuffer9 : public IndexBuffer
-{
- public:
- explicit IndexBuffer9(Renderer9 *const renderer);
- virtual ~IndexBuffer9();
-
- virtual gl::Error initialize(unsigned int bufferSize, GLenum indexType, bool dynamic);
-
- static IndexBuffer9 *makeIndexBuffer9(IndexBuffer *indexBuffer);
-
- virtual gl::Error mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory);
- virtual gl::Error unmapBuffer();
-
- virtual GLenum getIndexType() const;
- virtual unsigned int getBufferSize() const;
- virtual gl::Error setSize(unsigned int bufferSize, GLenum indexType);
-
- virtual gl::Error discard();
-
- D3DFORMAT getIndexFormat() const;
- IDirect3DIndexBuffer9 *getBuffer() const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(IndexBuffer9);
-
- Renderer9 *const mRenderer;
-
- IDirect3DIndexBuffer9 *mIndexBuffer;
- unsigned int mBufferSize;
- GLenum mIndexType;
- bool mDynamic;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_INDEXBUFFER9_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Query9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Query9.cpp
deleted file mode 100644
index a3cab578be..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Query9.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// Query9.cpp: Defines the rx::Query9 class which implements rx::QueryImpl.
-
-#include "libGLESv2/renderer/d3d/d3d9/Query9.h"
-#include "libGLESv2/renderer/d3d/d3d9/renderer9_utils.h"
-#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
-#include "libGLESv2/main.h"
-
-#include <GLES2/gl2ext.h>
-
-namespace rx
-{
-Query9::Query9(Renderer9 *renderer, GLenum type)
- : QueryImpl(type),
- mResult(GL_FALSE),
- mQueryFinished(false),
- mRenderer(renderer),
- mQuery(NULL)
-{
-}
-
-Query9::~Query9()
-{
- SafeRelease(mQuery);
-}
-
-gl::Error Query9::begin()
-{
- if (mQuery == NULL)
- {
- HRESULT result = mRenderer->getDevice()->CreateQuery(D3DQUERYTYPE_OCCLUSION, &mQuery);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal query creation failed, result: 0x%X.", result);
- }
- }
-
- HRESULT result = mQuery->Issue(D3DISSUE_BEGIN);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to begin internal query, result: 0x%X.", result);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Query9::end()
-{
- ASSERT(mQuery);
-
- HRESULT result = mQuery->Issue(D3DISSUE_END);
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to end internal query, result: 0x%X.", result);
- }
-
- mQueryFinished = false;
- mResult = GL_FALSE;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Query9::getResult(GLuint *params)
-{
- while (!mQueryFinished)
- {
- gl::Error error = testQuery();
- if (error.isError())
- {
- return error;
- }
-
- if (!mQueryFinished)
- {
- Sleep(0);
- }
- }
-
- ASSERT(mQueryFinished);
- *params = mResult;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Query9::isResultAvailable(GLuint *available)
-{
- gl::Error error = testQuery();
- if (error.isError())
- {
- return error;
- }
-
- *available = (mQueryFinished ? GL_TRUE : GL_FALSE);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Query9::testQuery()
-{
- if (!mQueryFinished)
- {
- ASSERT(mQuery);
-
- DWORD numPixels = 0;
-
- HRESULT hres = mQuery->GetData(&numPixels, sizeof(DWORD), D3DGETDATA_FLUSH);
- if (hres == S_OK)
- {
- mQueryFinished = true;
-
- switch (getType())
- {
- case GL_ANY_SAMPLES_PASSED_EXT:
- case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
- mResult = (numPixels > 0) ? GL_TRUE : GL_FALSE;
- break;
-
- default:
- UNREACHABLE();
- break;
- }
- }
- else if (d3d9::isDeviceLostError(hres))
- {
- mRenderer->notifyDeviceLost();
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to test get query result, device is lost.");
- }
- else if (mRenderer->testDeviceLost(true))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to test get query result, device is lost.");
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Query9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Query9.h
deleted file mode 100644
index 36851c6c6c..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Query9.h
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// Query9.h: Defines the rx::Query9 class which implements rx::QueryImpl.
-
-#ifndef LIBGLESV2_RENDERER_QUERY9_H_
-#define LIBGLESV2_RENDERER_QUERY9_H_
-
-#include "libGLESv2/renderer/QueryImpl.h"
-
-namespace rx
-{
-class Renderer9;
-
-class Query9 : public QueryImpl
-{
- public:
- Query9(Renderer9 *renderer, GLenum type);
- virtual ~Query9();
-
- virtual gl::Error begin();
- virtual gl::Error end();
- virtual gl::Error getResult(GLuint *params);
- virtual gl::Error isResultAvailable(GLuint *available);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Query9);
-
- gl::Error testQuery();
-
- GLuint mResult;
- bool mQueryFinished;
-
- Renderer9 *mRenderer;
- IDirect3DQuery9 *mQuery;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_QUERY9_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.cpp
deleted file mode 100644
index 53d1f752fa..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// RenderTarget9.cpp: Implements a D3D9-specific wrapper for IDirect3DSurface9
-// pointers retained by renderbuffers.
-
-#include "libGLESv2/renderer/d3d/d3d9/RenderTarget9.h"
-#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
-#include "libGLESv2/renderer/d3d/d3d9/renderer9_utils.h"
-#include "libGLESv2/renderer/d3d/d3d9/SwapChain9.h"
-#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h"
-#include "libGLESv2/main.h"
-
-namespace rx
-{
-
-RenderTarget9 *RenderTarget9::makeRenderTarget9(RenderTarget *target)
-{
- ASSERT(HAS_DYNAMIC_TYPE(RenderTarget9*, target));
- return static_cast<RenderTarget9*>(target);
-}
-
-void RenderTarget9::invalidate(GLint x, GLint y, GLsizei width, GLsizei height)
-{
- // Currently a no-op
-}
-
-// TODO: AddRef the incoming surface to take ownership instead of expecting that its ref is being given.
-TextureRenderTarget9::TextureRenderTarget9(IDirect3DSurface9 *surface, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth,
- GLsizei samples)
- : mWidth(width),
- mHeight(height),
- mDepth(depth),
- mInternalFormat(internalFormat),
- mActualFormat(internalFormat),
- mSamples(samples),
- mRenderTarget(surface)
-{
- ASSERT(mDepth == 1);
-
- if (mRenderTarget)
- {
- D3DSURFACE_DESC description;
- mRenderTarget->GetDesc(&description);
-
- const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(description.Format);
- mActualFormat = d3dFormatInfo.internalFormat;
- }
-}
-
-TextureRenderTarget9::~TextureRenderTarget9()
-{
- SafeRelease(mRenderTarget);
-}
-
-GLsizei TextureRenderTarget9::getWidth() const
-{
- return mWidth;
-}
-
-GLsizei TextureRenderTarget9::getHeight() const
-{
- return mHeight;
-}
-
-GLsizei TextureRenderTarget9::getDepth() const
-{
- return mDepth;
-}
-
-GLenum TextureRenderTarget9::getInternalFormat() const
-{
- return mInternalFormat;
-}
-
-GLenum TextureRenderTarget9::getActualFormat() const
-{
- return mActualFormat;
-}
-
-GLsizei TextureRenderTarget9::getSamples() const
-{
- return mSamples;
-}
-
-IDirect3DSurface9 *TextureRenderTarget9::getSurface()
-{
- // Caller is responsible for releasing the returned surface reference.
- // TODO: remove the AddRef to match RenderTarget11
- if (mRenderTarget)
- {
- mRenderTarget->AddRef();
- }
-
- return mRenderTarget;
-}
-
-
-SurfaceRenderTarget9::SurfaceRenderTarget9(SwapChain9 *swapChain, bool depth)
- : mSwapChain(swapChain),
- mDepth(depth)
-{
-}
-
-SurfaceRenderTarget9::~SurfaceRenderTarget9()
-{
-}
-
-GLsizei SurfaceRenderTarget9::getWidth() const
-{
- return mSwapChain->getWidth();
-}
-
-GLsizei SurfaceRenderTarget9::getHeight() const
-{
- return mSwapChain->getHeight();
-}
-
-GLsizei SurfaceRenderTarget9::getDepth() const
-{
- return 1;
-}
-
-GLenum SurfaceRenderTarget9::getInternalFormat() const
-{
- return (mDepth ? mSwapChain->GetDepthBufferInternalFormat() : mSwapChain->GetBackBufferInternalFormat());
-}
-
-GLenum SurfaceRenderTarget9::getActualFormat() const
-{
- return d3d9::GetD3DFormatInfo(d3d9::GetTextureFormatInfo(getInternalFormat()).texFormat).internalFormat;
-}
-
-GLsizei SurfaceRenderTarget9::getSamples() const
-{
- // Our EGL surfaces do not support multisampling.
- return 0;
-}
-
-IDirect3DSurface9 *SurfaceRenderTarget9::getSurface()
-{
- return (mDepth ? mSwapChain->getDepthStencil() : mSwapChain->getRenderTarget());
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.h
deleted file mode 100644
index 4585697f4c..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.h
+++ /dev/null
@@ -1,89 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// RenderTarget9.h: Defines a D3D9-specific wrapper for IDirect3DSurface9 pointers
-// retained by Renderbuffers.
-
-#ifndef LIBGLESV2_RENDERER_RENDERTARGET9_H_
-#define LIBGLESV2_RENDERER_RENDERTARGET9_H_
-
-#include "libGLESv2/renderer/RenderTarget.h"
-
-namespace rx
-{
-class Renderer9;
-class SwapChain9;
-
-class RenderTarget9 : public RenderTarget
-{
- public:
- RenderTarget9() { }
- virtual ~RenderTarget9() { }
-
- static RenderTarget9 *makeRenderTarget9(RenderTarget *renderTarget);
-
- void invalidate(GLint x, GLint y, GLsizei width, GLsizei height) override;
-
- virtual IDirect3DSurface9 *getSurface() = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(RenderTarget9);
-};
-
-class TextureRenderTarget9 : public RenderTarget9
-{
- public:
- TextureRenderTarget9(IDirect3DSurface9 *surface, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth,
- GLsizei samples);
- virtual ~TextureRenderTarget9();
-
- GLsizei getWidth() const override;
- GLsizei getHeight() const override;
- GLsizei getDepth() const override;
- GLenum getInternalFormat() const override;
- GLenum getActualFormat() const override;
- GLsizei getSamples() const override;
-
- IDirect3DSurface9 *getSurface() override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureRenderTarget9);
-
- GLsizei mWidth;
- GLsizei mHeight;
- GLsizei mDepth;
- GLenum mInternalFormat;
- GLenum mActualFormat;
- GLsizei mSamples;
-
- IDirect3DSurface9 *mRenderTarget;
-};
-
-class SurfaceRenderTarget9 : public RenderTarget9
-{
- public:
- SurfaceRenderTarget9(SwapChain9 *swapChain, bool depth);
- virtual ~SurfaceRenderTarget9();
-
- GLsizei getWidth() const override;
- GLsizei getHeight() const override;
- GLsizei getDepth() const override;
- GLenum getInternalFormat() const override;
- GLenum getActualFormat() const override;
- GLsizei getSamples() const override;
-
- IDirect3DSurface9 *getSurface() override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(SurfaceRenderTarget9);
-
- SwapChain9 *mSwapChain;
- bool mDepth;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_RENDERTARGET9_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp
deleted file mode 100644
index 18e6e2d7f0..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp
+++ /dev/null
@@ -1,3171 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// Renderer9.cpp: Implements a back-end specific class for the D3D9 renderer.
-
-#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
-#include "libGLESv2/renderer/d3d/d3d9/renderer9_utils.h"
-#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h"
-#include "libGLESv2/renderer/d3d/d3d9/ShaderExecutable9.h"
-#include "libGLESv2/renderer/d3d/d3d9/SwapChain9.h"
-#include "libGLESv2/renderer/d3d/d3d9/TextureStorage9.h"
-#include "libGLESv2/renderer/d3d/d3d9/Image9.h"
-#include "libGLESv2/renderer/d3d/d3d9/Blit9.h"
-#include "libGLESv2/renderer/d3d/d3d9/RenderTarget9.h"
-#include "libGLESv2/renderer/d3d/d3d9/VertexBuffer9.h"
-#include "libGLESv2/renderer/d3d/d3d9/IndexBuffer9.h"
-#include "libGLESv2/renderer/d3d/d3d9/Buffer9.h"
-#include "libGLESv2/renderer/d3d/d3d9/Query9.h"
-#include "libGLESv2/renderer/d3d/d3d9/Fence9.h"
-#include "libGLESv2/renderer/d3d/d3d9/VertexArray9.h"
-#include "libGLESv2/renderer/d3d/IndexDataManager.h"
-#include "libGLESv2/renderer/d3d/ProgramD3D.h"
-#include "libGLESv2/renderer/d3d/ShaderD3D.h"
-#include "libGLESv2/renderer/d3d/TextureD3D.h"
-#include "libGLESv2/renderer/d3d/TransformFeedbackD3D.h"
-#include "libGLESv2/renderer/d3d/RenderbufferD3D.h"
-#include "libGLESv2/main.h"
-#include "libGLESv2/Buffer.h"
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/FramebufferAttachment.h"
-#include "libGLESv2/Renderbuffer.h"
-#include "libGLESv2/ProgramBinary.h"
-#include "libGLESv2/State.h"
-#include "libGLESv2/angletypes.h"
-
-#include "libEGL/Display.h"
-
-#include "common/features.h"
-#include "common/utilities.h"
-
-#include <sstream>
-
-// Can also be enabled by defining FORCE_REF_RAST in the project's predefined macros
-#define REF_RAST 0
-
-#if !defined(ANGLE_COMPILE_OPTIMIZATION_LEVEL)
-#define ANGLE_COMPILE_OPTIMIZATION_LEVEL D3DCOMPILE_OPTIMIZATION_LEVEL3
-#endif
-
-const D3DFORMAT D3DFMT_INTZ = ((D3DFORMAT)(MAKEFOURCC('I','N','T','Z')));
-const D3DFORMAT D3DFMT_NULL = ((D3DFORMAT)(MAKEFOURCC('N','U','L','L')));
-
-namespace rx
-{
-static const D3DFORMAT RenderTargetFormats[] =
- {
- D3DFMT_A1R5G5B5,
- // D3DFMT_A2R10G10B10, // The color_ramp conformance test uses ReadPixels with UNSIGNED_BYTE causing it to think that rendering skipped a colour value.
- D3DFMT_A8R8G8B8,
- D3DFMT_R5G6B5,
- // D3DFMT_X1R5G5B5, // Has no compatible OpenGL ES renderbuffer format
- D3DFMT_X8R8G8B8
- };
-
-static const D3DFORMAT DepthStencilFormats[] =
- {
- D3DFMT_UNKNOWN,
- // D3DFMT_D16_LOCKABLE,
- D3DFMT_D32,
- // D3DFMT_D15S1,
- D3DFMT_D24S8,
- D3DFMT_D24X8,
- // D3DFMT_D24X4S4,
- D3DFMT_D16,
- // D3DFMT_D32F_LOCKABLE,
- // D3DFMT_D24FS8
- };
-
-enum
-{
- MAX_VERTEX_CONSTANT_VECTORS_D3D9 = 256,
- MAX_PIXEL_CONSTANT_VECTORS_SM2 = 32,
- MAX_PIXEL_CONSTANT_VECTORS_SM3 = 224,
- MAX_VARYING_VECTORS_SM2 = 8,
- MAX_VARYING_VECTORS_SM3 = 10,
-
- MAX_TEXTURE_IMAGE_UNITS_VTF_SM3 = 4
-};
-
-Renderer9::Renderer9(egl::Display *display, EGLNativeDisplayType hDc, const egl::AttributeMap &attributes)
- : RendererD3D(display),
- mDc(hDc)
-{
- mD3d9Module = NULL;
-
- mD3d9 = NULL;
- mD3d9Ex = NULL;
- mDevice = NULL;
- mDeviceEx = NULL;
- mDeviceWindow = NULL;
- mBlit = NULL;
-
- mAdapter = D3DADAPTER_DEFAULT;
-
- #if REF_RAST == 1 || defined(FORCE_REF_RAST)
- mDeviceType = D3DDEVTYPE_REF;
- #else
- mDeviceType = D3DDEVTYPE_HAL;
- #endif
-
- mDeviceLost = false;
-
- mMaskedClearSavedState = NULL;
-
- mVertexDataManager = NULL;
- mIndexDataManager = NULL;
- mLineLoopIB = NULL;
- mCountingIB = NULL;
-
- mMaxNullColorbufferLRU = 0;
- for (int i = 0; i < NUM_NULL_COLORBUFFER_CACHE_ENTRIES; i++)
- {
- mNullColorbufferCache[i].lruCount = 0;
- mNullColorbufferCache[i].width = 0;
- mNullColorbufferCache[i].height = 0;
- mNullColorbufferCache[i].buffer = NULL;
- }
-
- mAppliedVertexShader = NULL;
- mAppliedPixelShader = NULL;
- mAppliedProgramSerial = 0;
-}
-
-Renderer9::~Renderer9()
-{
- if (mDevice)
- {
- // If the device is lost, reset it first to prevent leaving the driver in an unstable state
- if (testDeviceLost(false))
- {
- resetDevice();
- }
- }
-
- release();
-}
-
-void Renderer9::release()
-{
- RendererD3D::cleanup();
-
- releaseShaderCompiler();
- releaseDeviceResources();
-
- SafeRelease(mDevice);
- SafeRelease(mDeviceEx);
- SafeRelease(mD3d9);
- SafeRelease(mD3d9Ex);
-
- mCompiler.release();
-
- if (mDeviceWindow)
- {
- DestroyWindow(mDeviceWindow);
- mDeviceWindow = NULL;
- }
-
- mD3d9Module = NULL;
-}
-
-Renderer9 *Renderer9::makeRenderer9(Renderer *renderer)
-{
- ASSERT(HAS_DYNAMIC_TYPE(Renderer9*, renderer));
- return static_cast<Renderer9*>(renderer);
-}
-
-EGLint Renderer9::initialize()
-{
- if (!mCompiler.initialize())
- {
- return EGL_NOT_INITIALIZED;
- }
-
- mD3d9Module = GetModuleHandle(TEXT("d3d9.dll"));
-
- if (mD3d9Module == NULL)
- {
- ERR("No D3D9 module found - aborting!\n");
- return EGL_NOT_INITIALIZED;
- }
-
- typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT, IDirect3D9Ex**);
- Direct3DCreate9ExFunc Direct3DCreate9ExPtr = reinterpret_cast<Direct3DCreate9ExFunc>(GetProcAddress(mD3d9Module, "Direct3DCreate9Ex"));
-
- // Use Direct3D9Ex if available. Among other things, this version is less
- // inclined to report a lost context, for example when the user switches
- // desktop. Direct3D9Ex is available in Windows Vista and later if suitable drivers are available.
- if (ANGLE_D3D9EX == ANGLE_ENABLED && Direct3DCreate9ExPtr && SUCCEEDED(Direct3DCreate9ExPtr(D3D_SDK_VERSION, &mD3d9Ex)))
- {
- ASSERT(mD3d9Ex);
- mD3d9Ex->QueryInterface(IID_IDirect3D9, reinterpret_cast<void**>(&mD3d9));
- ASSERT(mD3d9);
- }
- else
- {
- mD3d9 = Direct3DCreate9(D3D_SDK_VERSION);
- }
-
- if (!mD3d9)
- {
- ERR("Could not create D3D9 device - aborting!\n");
- return EGL_NOT_INITIALIZED;
- }
-
- if (mDc != NULL)
- {
- // UNIMPLEMENTED(); // FIXME: Determine which adapter index the device context corresponds to
- }
-
- HRESULT result;
-
- // Give up on getting device caps after about one second.
- {
- for (int i = 0; i < 10; ++i)
- {
- result = mD3d9->GetDeviceCaps(mAdapter, mDeviceType, &mDeviceCaps);
- if (SUCCEEDED(result))
- {
- break;
- }
- else if (result == D3DERR_NOTAVAILABLE)
- {
- Sleep(100); // Give the driver some time to initialize/recover
- }
- else if (FAILED(result)) // D3DERR_OUTOFVIDEOMEMORY, E_OUTOFMEMORY, D3DERR_INVALIDDEVICE, or another error we can't recover from
- {
- ERR("failed to get device caps (0x%x)\n", result);
- return EGL_NOT_INITIALIZED;
- }
- }
- }
-
- if (mDeviceCaps.PixelShaderVersion < D3DPS_VERSION(2, 0))
- {
- ERR("Renderer does not support PS 2.0. aborting!\n");
- return EGL_NOT_INITIALIZED;
- }
-
- // When DirectX9 is running with an older DirectX8 driver, a StretchRect from a regular texture to a render target texture is not supported.
- // This is required by Texture2D::ensureRenderTarget.
- if ((mDeviceCaps.DevCaps2 & D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES) == 0)
- {
- ERR("Renderer does not support stretctrect from textures!\n");
- return EGL_NOT_INITIALIZED;
- }
-
- {
- mD3d9->GetAdapterIdentifier(mAdapter, 0, &mAdapterIdentifier);
- }
-
- mMinSwapInterval = 4;
- mMaxSwapInterval = 0;
-
- if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_IMMEDIATE)
- {
- mMinSwapInterval = std::min(mMinSwapInterval, 0);
- mMaxSwapInterval = std::max(mMaxSwapInterval, 0);
- }
- if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_ONE)
- {
- mMinSwapInterval = std::min(mMinSwapInterval, 1);
- mMaxSwapInterval = std::max(mMaxSwapInterval, 1);
- }
- if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_TWO)
- {
- mMinSwapInterval = std::min(mMinSwapInterval, 2);
- mMaxSwapInterval = std::max(mMaxSwapInterval, 2);
- }
- if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_THREE)
- {
- mMinSwapInterval = std::min(mMinSwapInterval, 3);
- mMaxSwapInterval = std::max(mMaxSwapInterval, 3);
- }
- if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_FOUR)
- {
- mMinSwapInterval = std::min(mMinSwapInterval, 4);
- mMaxSwapInterval = std::max(mMaxSwapInterval, 4);
- }
-
- static const TCHAR windowName[] = TEXT("AngleHiddenWindow");
- static const TCHAR className[] = TEXT("STATIC");
-
- {
- mDeviceWindow = CreateWindowEx(WS_EX_NOACTIVATE, className, windowName, WS_DISABLED | WS_POPUP, 0, 0, 1, 1, HWND_MESSAGE, NULL, GetModuleHandle(NULL), NULL);
- }
-
- D3DPRESENT_PARAMETERS presentParameters = getDefaultPresentParameters();
- DWORD behaviorFlags = D3DCREATE_FPU_PRESERVE | D3DCREATE_NOWINDOWCHANGES;
-
- static wchar_t *qt_d3dcreate_multihreaded_var = _wgetenv(L"QT_D3DCREATE_MULTITHREADED");
- if (qt_d3dcreate_multihreaded_var && wcsstr(qt_d3dcreate_multihreaded_var, L"1"))
- behaviorFlags |= D3DCREATE_MULTITHREADED;
-
- {
- result = mD3d9->CreateDevice(mAdapter, mDeviceType, mDeviceWindow, behaviorFlags | D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE, &presentParameters, &mDevice);
- }
- if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_DEVICELOST)
- {
- return EGL_BAD_ALLOC;
- }
-
- if (FAILED(result))
- {
- result = mD3d9->CreateDevice(mAdapter, mDeviceType, mDeviceWindow, behaviorFlags | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &presentParameters, &mDevice);
-
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_NOTAVAILABLE || result == D3DERR_DEVICELOST);
- return EGL_BAD_ALLOC;
- }
- }
-
- if (mD3d9Ex)
- {
- result = mDevice->QueryInterface(IID_IDirect3DDevice9Ex, (void**)&mDeviceEx);
- ASSERT(SUCCEEDED(result));
- }
-
- {
- mVertexShaderCache.initialize(mDevice);
- mPixelShaderCache.initialize(mDevice);
- }
-
- D3DDISPLAYMODE currentDisplayMode;
- mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
-
- // Check vertex texture support
- // Only Direct3D 10 ready devices support all the necessary vertex texture formats.
- // We test this using D3D9 by checking support for the R16F format.
- mVertexTextureSupport = mDeviceCaps.PixelShaderVersion >= D3DPS_VERSION(3, 0) &&
- SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format,
- D3DUSAGE_QUERY_VERTEXTEXTURE, D3DRTYPE_TEXTURE, D3DFMT_R16F));
-
- initializeDevice();
-
- return EGL_SUCCESS;
-}
-
-// do any one-time device initialization
-// NOTE: this is also needed after a device lost/reset
-// to reset the scene status and ensure the default states are reset.
-void Renderer9::initializeDevice()
-{
- // Permanent non-default states
- mDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE);
- mDevice->SetRenderState(D3DRS_LASTPIXEL, FALSE);
-
- if (mDeviceCaps.PixelShaderVersion >= D3DPS_VERSION(3, 0))
- {
- mDevice->SetRenderState(D3DRS_POINTSIZE_MAX, (DWORD&)mDeviceCaps.MaxPointSize);
- }
- else
- {
- mDevice->SetRenderState(D3DRS_POINTSIZE_MAX, 0x3F800000); // 1.0f
- }
-
- const gl::Caps &rendererCaps = getRendererCaps();
-
- mForceSetVertexSamplerStates.resize(rendererCaps.maxVertexTextureImageUnits);
- mCurVertexSamplerStates.resize(rendererCaps.maxVertexTextureImageUnits);
-
- mForceSetPixelSamplerStates.resize(rendererCaps.maxTextureImageUnits);
- mCurPixelSamplerStates.resize(rendererCaps.maxTextureImageUnits);
-
- mCurVertexTextureSerials.resize(rendererCaps.maxVertexTextureImageUnits);
- mCurPixelTextureSerials.resize(rendererCaps.maxTextureImageUnits);
-
- markAllStateDirty();
-
- mSceneStarted = false;
-
- ASSERT(!mBlit);
- mBlit = new Blit9(this);
- mBlit->initialize();
-
- ASSERT(!mVertexDataManager && !mIndexDataManager);
- mVertexDataManager = new VertexDataManager(this);
- mIndexDataManager = new IndexDataManager(this);
-}
-
-D3DPRESENT_PARAMETERS Renderer9::getDefaultPresentParameters()
-{
- D3DPRESENT_PARAMETERS presentParameters = {0};
-
- // The default swap chain is never actually used. Surface will create a new swap chain with the proper parameters.
- presentParameters.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
- presentParameters.BackBufferCount = 1;
- presentParameters.BackBufferFormat = D3DFMT_UNKNOWN;
- presentParameters.BackBufferWidth = 1;
- presentParameters.BackBufferHeight = 1;
- presentParameters.EnableAutoDepthStencil = FALSE;
- presentParameters.Flags = 0;
- presentParameters.hDeviceWindow = mDeviceWindow;
- presentParameters.MultiSampleQuality = 0;
- presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE;
- presentParameters.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
- presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
- presentParameters.Windowed = TRUE;
-
- return presentParameters;
-}
-
-int Renderer9::generateConfigs(ConfigDesc **configDescList)
-{
- D3DDISPLAYMODE currentDisplayMode;
- mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
-
- unsigned int numRenderFormats = ArraySize(RenderTargetFormats);
- unsigned int numDepthFormats = ArraySize(DepthStencilFormats);
- (*configDescList) = new ConfigDesc[numRenderFormats * numDepthFormats];
- int numConfigs = 0;
-
- for (unsigned int formatIndex = 0; formatIndex < numRenderFormats; formatIndex++)
- {
- const d3d9::D3DFormat &renderTargetFormatInfo = d3d9::GetD3DFormatInfo(RenderTargetFormats[formatIndex]);
- const gl::TextureCaps &renderTargetFormatCaps = getRendererTextureCaps().get(renderTargetFormatInfo.internalFormat);
- if (renderTargetFormatCaps.renderable)
- {
- for (unsigned int depthStencilIndex = 0; depthStencilIndex < numDepthFormats; depthStencilIndex++)
- {
- const d3d9::D3DFormat &depthStencilFormatInfo = d3d9::GetD3DFormatInfo(DepthStencilFormats[depthStencilIndex]);
- const gl::TextureCaps &depthStencilFormatCaps = getRendererTextureCaps().get(depthStencilFormatInfo.internalFormat);
- if (depthStencilFormatCaps.renderable || DepthStencilFormats[depthStencilIndex] == D3DFMT_UNKNOWN)
- {
- ConfigDesc newConfig;
- newConfig.renderTargetFormat = renderTargetFormatInfo.internalFormat;
- newConfig.depthStencilFormat = depthStencilFormatInfo.internalFormat;
- newConfig.multiSample = 0; // FIXME: enumerate multi-sampling
- newConfig.fastConfig = (currentDisplayMode.Format == RenderTargetFormats[formatIndex]);
- newConfig.es3Capable = false;
-
- (*configDescList)[numConfigs++] = newConfig;
- }
- }
- }
- }
-
- return numConfigs;
-}
-
-void Renderer9::deleteConfigs(ConfigDesc *configDescList)
-{
- delete [] (configDescList);
-}
-
-void Renderer9::startScene()
-{
- if (!mSceneStarted)
- {
- long result = mDevice->BeginScene();
- if (SUCCEEDED(result)) {
- // This is defensive checking against the device being
- // lost at unexpected times.
- mSceneStarted = true;
- }
- }
-}
-
-void Renderer9::endScene()
-{
- if (mSceneStarted)
- {
- // EndScene can fail if the device was lost, for example due
- // to a TDR during a draw call.
- mDevice->EndScene();
- mSceneStarted = false;
- }
-}
-
-gl::Error Renderer9::sync(bool block)
-{
- IDirect3DQuery9* query = NULL;
- gl::Error error = allocateEventQuery(&query);
- if (error.isError())
- {
- return error;
- }
-
- HRESULT result = query->Issue(D3DISSUE_END);
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to issue event query, result: 0x%X.", result);
- }
-
- // Grab the query data once in blocking and non-blocking case
- result = query->GetData(NULL, 0, D3DGETDATA_FLUSH);
- if (FAILED(result))
- {
- if (d3d9::isDeviceLostError(result))
- {
- notifyDeviceLost();
- }
-
- freeEventQuery(query);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to get event query data, result: 0x%X.", result);
- }
-
- // If blocking, loop until the query completes
- while (block && result == S_FALSE)
- {
- // Keep polling, but allow other threads to do something useful first
- Sleep(0);
-
- result = query->GetData(NULL, 0, D3DGETDATA_FLUSH);
-
- // explicitly check for device loss
- // some drivers seem to return S_FALSE even if the device is lost
- // instead of D3DERR_DEVICELOST like they should
- if (result == S_FALSE && testDeviceLost(false))
- {
- result = D3DERR_DEVICELOST;
- }
-
- if (FAILED(result))
- {
- if (d3d9::isDeviceLostError(result))
- {
- notifyDeviceLost();
- }
-
- freeEventQuery(query);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to get event query data, result: 0x%X.", result);
- }
-
- }
-
- freeEventQuery(query);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-SwapChain *Renderer9::createSwapChain(NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat)
-{
- return new SwapChain9(this, nativeWindow, shareHandle, backBufferFormat, depthBufferFormat);
-}
-
-gl::Error Renderer9::allocateEventQuery(IDirect3DQuery9 **outQuery)
-{
- if (mEventQueryPool.empty())
- {
- HRESULT result = mDevice->CreateQuery(D3DQUERYTYPE_EVENT, outQuery);
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate event query, result: 0x%X.", result);
- }
- }
- else
- {
- *outQuery = mEventQueryPool.back();
- mEventQueryPool.pop_back();
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void Renderer9::freeEventQuery(IDirect3DQuery9* query)
-{
- if (mEventQueryPool.size() > 1000)
- {
- SafeRelease(query);
- }
- else
- {
- mEventQueryPool.push_back(query);
- }
-}
-
-gl::Error Renderer9::createVertexShader(const DWORD *function, size_t length, IDirect3DVertexShader9 **outShader)
-{
- return mVertexShaderCache.create(function, length, outShader);
-}
-
-gl::Error Renderer9::createPixelShader(const DWORD *function, size_t length, IDirect3DPixelShader9 **outShader)
-{
- return mPixelShaderCache.create(function, length, outShader);
-}
-
-HRESULT Renderer9::createVertexBuffer(UINT Length, DWORD Usage, IDirect3DVertexBuffer9 **ppVertexBuffer)
-{
- D3DPOOL Pool = getBufferPool(Usage);
- return mDevice->CreateVertexBuffer(Length, Usage, 0, Pool, ppVertexBuffer, NULL);
-}
-
-VertexBuffer *Renderer9::createVertexBuffer()
-{
- return new VertexBuffer9(this);
-}
-
-HRESULT Renderer9::createIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, IDirect3DIndexBuffer9 **ppIndexBuffer)
-{
- D3DPOOL Pool = getBufferPool(Usage);
- return mDevice->CreateIndexBuffer(Length, Usage, Format, Pool, ppIndexBuffer, NULL);
-}
-
-IndexBuffer *Renderer9::createIndexBuffer()
-{
- return new IndexBuffer9(this);
-}
-
-BufferImpl *Renderer9::createBuffer()
-{
- return new Buffer9(this);
-}
-
-VertexArrayImpl *Renderer9::createVertexArray()
-{
- return new VertexArray9(this);
-}
-
-QueryImpl *Renderer9::createQuery(GLenum type)
-{
- return new Query9(this, type);
-}
-
-FenceNVImpl *Renderer9::createFenceNV()
-{
- return new FenceNV9(this);
-}
-
-FenceSyncImpl *Renderer9::createFenceSync()
-{
- // Renderer9 doesn't support ES 3.0 and its sync objects.
- UNREACHABLE();
- return NULL;
-}
-
-TransformFeedbackImpl* Renderer9::createTransformFeedback()
-{
- return new TransformFeedbackD3D();
-}
-
-bool Renderer9::supportsFastCopyBufferToTexture(GLenum internalFormat) const
-{
- // Pixel buffer objects are not supported in D3D9, since D3D9 is ES2-only and PBOs are ES3.
- return false;
-}
-
-gl::Error Renderer9::fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
- GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea)
-{
- // Pixel buffer objects are not supported in D3D9, since D3D9 is ES2-only and PBOs are ES3.
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
-}
-
-gl::Error Renderer9::generateSwizzle(gl::Texture *texture)
-{
- // Swizzled textures are not available in ES2 or D3D9
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
-}
-
-gl::Error Renderer9::setSamplerState(gl::SamplerType type, int index, gl::Texture *texture, const gl::SamplerState &samplerState)
-{
- std::vector<bool> &forceSetSamplers = (type == gl::SAMPLER_PIXEL) ? mForceSetPixelSamplerStates : mForceSetVertexSamplerStates;
- std::vector<gl::SamplerState> &appliedSamplers = (type == gl::SAMPLER_PIXEL) ? mCurPixelSamplerStates: mCurVertexSamplerStates;
-
- if (forceSetSamplers[index] || memcmp(&samplerState, &appliedSamplers[index], sizeof(gl::SamplerState)) != 0)
- {
- int d3dSamplerOffset = (type == gl::SAMPLER_PIXEL) ? 0 : D3DVERTEXTEXTURESAMPLER0;
- int d3dSampler = index + d3dSamplerOffset;
-
- // Make sure to add the level offset for our tiny compressed texture workaround
- TextureD3D *textureD3D = TextureD3D::makeTextureD3D(texture->getImplementation());
- DWORD baseLevel = samplerState.baseLevel + textureD3D->getNativeTexture()->getTopLevel();
-
- mDevice->SetSamplerState(d3dSampler, D3DSAMP_ADDRESSU, gl_d3d9::ConvertTextureWrap(samplerState.wrapS));
- mDevice->SetSamplerState(d3dSampler, D3DSAMP_ADDRESSV, gl_d3d9::ConvertTextureWrap(samplerState.wrapT));
-
- mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAGFILTER, gl_d3d9::ConvertMagFilter(samplerState.magFilter, samplerState.maxAnisotropy));
- D3DTEXTUREFILTERTYPE d3dMinFilter, d3dMipFilter;
- gl_d3d9::ConvertMinFilter(samplerState.minFilter, &d3dMinFilter, &d3dMipFilter, samplerState.maxAnisotropy);
- mDevice->SetSamplerState(d3dSampler, D3DSAMP_MINFILTER, d3dMinFilter);
- mDevice->SetSamplerState(d3dSampler, D3DSAMP_MIPFILTER, d3dMipFilter);
- mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAXMIPLEVEL, baseLevel);
- if (getRendererExtensions().textureFilterAnisotropic)
- {
- mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAXANISOTROPY, (DWORD)samplerState.maxAnisotropy);
- }
- }
-
- forceSetSamplers[index] = false;
- appliedSamplers[index] = samplerState;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer9::setTexture(gl::SamplerType type, int index, gl::Texture *texture)
-{
- int d3dSamplerOffset = (type == gl::SAMPLER_PIXEL) ? 0 : D3DVERTEXTEXTURESAMPLER0;
- int d3dSampler = index + d3dSamplerOffset;
- IDirect3DBaseTexture9 *d3dTexture = NULL;
- unsigned int serial = 0;
- bool forceSetTexture = false;
-
- std::vector<unsigned int> &appliedSerials = (type == gl::SAMPLER_PIXEL) ? mCurPixelTextureSerials : mCurVertexTextureSerials;
-
- if (texture)
- {
- TextureD3D* textureImpl = TextureD3D::makeTextureD3D(texture->getImplementation());
-
- TextureStorage *texStorage = textureImpl->getNativeTexture();
- if (texStorage)
- {
- TextureStorage9 *storage9 = TextureStorage9::makeTextureStorage9(texStorage);
-
- gl::Error error = storage9->getBaseTexture(&d3dTexture);
- if (error.isError())
- {
- return error;
- }
- }
- // If we get NULL back from getBaseTexture here, something went wrong
- // in the texture class and we're unexpectedly missing the d3d texture
- ASSERT(d3dTexture != NULL);
-
- serial = texture->getTextureSerial();
- forceSetTexture = textureImpl->hasDirtyImages();
- textureImpl->resetDirty();
- }
-
- if (forceSetTexture || appliedSerials[index] != serial)
- {
- mDevice->SetTexture(d3dSampler, d3dTexture);
- }
-
- appliedSerials[index] = serial;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer9::setUniformBuffers(const gl::Buffer* /*vertexUniformBuffers*/[], const gl::Buffer* /*fragmentUniformBuffers*/[])
-{
- // No effect in ES2/D3D9
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer9::setRasterizerState(const gl::RasterizerState &rasterState)
-{
- bool rasterStateChanged = mForceSetRasterState || memcmp(&rasterState, &mCurRasterState, sizeof(gl::RasterizerState)) != 0;
-
- if (rasterStateChanged)
- {
- // Set the cull mode
- if (rasterState.cullFace)
- {
- mDevice->SetRenderState(D3DRS_CULLMODE, gl_d3d9::ConvertCullMode(rasterState.cullMode, rasterState.frontFace));
- }
- else
- {
- mDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- }
-
- if (rasterState.polygonOffsetFill)
- {
- if (mCurDepthSize > 0)
- {
- mDevice->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS, *(DWORD*)&rasterState.polygonOffsetFactor);
-
- float depthBias = ldexp(rasterState.polygonOffsetUnits, -static_cast<int>(mCurDepthSize));
- mDevice->SetRenderState(D3DRS_DEPTHBIAS, *(DWORD*)&depthBias);
- }
- }
- else
- {
- mDevice->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS, 0);
- mDevice->SetRenderState(D3DRS_DEPTHBIAS, 0);
- }
-
- mCurRasterState = rasterState;
- }
-
- mForceSetRasterState = false;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer9::setBlendState(const gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor,
- unsigned int sampleMask)
-{
- bool blendStateChanged = mForceSetBlendState || memcmp(&blendState, &mCurBlendState, sizeof(gl::BlendState)) != 0;
- bool blendColorChanged = mForceSetBlendState || memcmp(&blendColor, &mCurBlendColor, sizeof(gl::ColorF)) != 0;
- bool sampleMaskChanged = mForceSetBlendState || sampleMask != mCurSampleMask;
-
- if (blendStateChanged || blendColorChanged)
- {
- if (blendState.blend)
- {
- mDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
-
- if (blendState.sourceBlendRGB != GL_CONSTANT_ALPHA && blendState.sourceBlendRGB != GL_ONE_MINUS_CONSTANT_ALPHA &&
- blendState.destBlendRGB != GL_CONSTANT_ALPHA && blendState.destBlendRGB != GL_ONE_MINUS_CONSTANT_ALPHA)
- {
- mDevice->SetRenderState(D3DRS_BLENDFACTOR, gl_d3d9::ConvertColor(blendColor));
- }
- else
- {
- mDevice->SetRenderState(D3DRS_BLENDFACTOR, D3DCOLOR_RGBA(gl::unorm<8>(blendColor.alpha),
- gl::unorm<8>(blendColor.alpha),
- gl::unorm<8>(blendColor.alpha),
- gl::unorm<8>(blendColor.alpha)));
- }
-
- mDevice->SetRenderState(D3DRS_SRCBLEND, gl_d3d9::ConvertBlendFunc(blendState.sourceBlendRGB));
- mDevice->SetRenderState(D3DRS_DESTBLEND, gl_d3d9::ConvertBlendFunc(blendState.destBlendRGB));
- mDevice->SetRenderState(D3DRS_BLENDOP, gl_d3d9::ConvertBlendOp(blendState.blendEquationRGB));
-
- if (blendState.sourceBlendRGB != blendState.sourceBlendAlpha ||
- blendState.destBlendRGB != blendState.destBlendAlpha ||
- blendState.blendEquationRGB != blendState.blendEquationAlpha)
- {
- mDevice->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE);
-
- mDevice->SetRenderState(D3DRS_SRCBLENDALPHA, gl_d3d9::ConvertBlendFunc(blendState.sourceBlendAlpha));
- mDevice->SetRenderState(D3DRS_DESTBLENDALPHA, gl_d3d9::ConvertBlendFunc(blendState.destBlendAlpha));
- mDevice->SetRenderState(D3DRS_BLENDOPALPHA, gl_d3d9::ConvertBlendOp(blendState.blendEquationAlpha));
- }
- else
- {
- mDevice->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, FALSE);
- }
- }
- else
- {
- mDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- }
-
- if (blendState.sampleAlphaToCoverage)
- {
- FIXME("Sample alpha to coverage is unimplemented.");
- }
-
- gl::FramebufferAttachment *attachment = framebuffer->getFirstColorbuffer();
- GLenum internalFormat = attachment ? attachment->getInternalFormat() : GL_NONE;
-
- // Set the color mask
- bool zeroColorMaskAllowed = getAdapterVendor() != VENDOR_ID_AMD;
- // Apparently some ATI cards have a bug where a draw with a zero color
- // write mask can cause later draws to have incorrect results. Instead,
- // set a nonzero color write mask but modify the blend state so that no
- // drawing is done.
- // http://code.google.com/p/angleproject/issues/detail?id=169
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
- DWORD colorMask = gl_d3d9::ConvertColorMask(formatInfo.redBits > 0 && blendState.colorMaskRed,
- formatInfo.greenBits > 0 && blendState.colorMaskGreen,
- formatInfo.blueBits > 0 && blendState.colorMaskBlue,
- formatInfo.alphaBits > 0 && blendState.colorMaskAlpha);
- if (colorMask == 0 && !zeroColorMaskAllowed)
- {
- // Enable green channel, but set blending so nothing will be drawn.
- mDevice->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_GREEN);
- mDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
-
- mDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
- mDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
- mDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
- }
- else
- {
- mDevice->SetRenderState(D3DRS_COLORWRITEENABLE, colorMask);
- }
-
- mDevice->SetRenderState(D3DRS_DITHERENABLE, blendState.dither ? TRUE : FALSE);
-
- mCurBlendState = blendState;
- mCurBlendColor = blendColor;
- }
-
- if (sampleMaskChanged)
- {
- // Set the multisample mask
- mDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE);
- mDevice->SetRenderState(D3DRS_MULTISAMPLEMASK, static_cast<DWORD>(sampleMask));
-
- mCurSampleMask = sampleMask;
- }
-
- mForceSetBlendState = false;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer9::setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
- int stencilBackRef, bool frontFaceCCW)
-{
- bool depthStencilStateChanged = mForceSetDepthStencilState ||
- memcmp(&depthStencilState, &mCurDepthStencilState, sizeof(gl::DepthStencilState)) != 0;
- bool stencilRefChanged = mForceSetDepthStencilState || stencilRef != mCurStencilRef ||
- stencilBackRef != mCurStencilBackRef;
- bool frontFaceCCWChanged = mForceSetDepthStencilState || frontFaceCCW != mCurFrontFaceCCW;
-
- if (depthStencilStateChanged)
- {
- if (depthStencilState.depthTest)
- {
- mDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
- mDevice->SetRenderState(D3DRS_ZFUNC, gl_d3d9::ConvertComparison(depthStencilState.depthFunc));
- }
- else
- {
- mDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
- }
-
- mCurDepthStencilState = depthStencilState;
- }
-
- if (depthStencilStateChanged || stencilRefChanged || frontFaceCCWChanged)
- {
- if (depthStencilState.stencilTest && mCurStencilSize > 0)
- {
- mDevice->SetRenderState(D3DRS_STENCILENABLE, TRUE);
- mDevice->SetRenderState(D3DRS_TWOSIDEDSTENCILMODE, TRUE);
-
- // FIXME: Unsupported by D3D9
- const D3DRENDERSTATETYPE D3DRS_CCW_STENCILREF = D3DRS_STENCILREF;
- const D3DRENDERSTATETYPE D3DRS_CCW_STENCILMASK = D3DRS_STENCILMASK;
- const D3DRENDERSTATETYPE D3DRS_CCW_STENCILWRITEMASK = D3DRS_STENCILWRITEMASK;
-
- ASSERT(depthStencilState.stencilWritemask == depthStencilState.stencilBackWritemask);
- ASSERT(stencilRef == stencilBackRef);
- ASSERT(depthStencilState.stencilMask == depthStencilState.stencilBackMask);
-
- // get the maximum size of the stencil ref
- unsigned int maxStencil = (1 << mCurStencilSize) - 1;
-
- mDevice->SetRenderState(frontFaceCCW ? D3DRS_STENCILWRITEMASK : D3DRS_CCW_STENCILWRITEMASK,
- depthStencilState.stencilWritemask);
- mDevice->SetRenderState(frontFaceCCW ? D3DRS_STENCILFUNC : D3DRS_CCW_STENCILFUNC,
- gl_d3d9::ConvertComparison(depthStencilState.stencilFunc));
-
- mDevice->SetRenderState(frontFaceCCW ? D3DRS_STENCILREF : D3DRS_CCW_STENCILREF,
- (stencilRef < (int)maxStencil) ? stencilRef : maxStencil);
- mDevice->SetRenderState(frontFaceCCW ? D3DRS_STENCILMASK : D3DRS_CCW_STENCILMASK,
- depthStencilState.stencilMask);
-
- mDevice->SetRenderState(frontFaceCCW ? D3DRS_STENCILFAIL : D3DRS_CCW_STENCILFAIL,
- gl_d3d9::ConvertStencilOp(depthStencilState.stencilFail));
- mDevice->SetRenderState(frontFaceCCW ? D3DRS_STENCILZFAIL : D3DRS_CCW_STENCILZFAIL,
- gl_d3d9::ConvertStencilOp(depthStencilState.stencilPassDepthFail));
- mDevice->SetRenderState(frontFaceCCW ? D3DRS_STENCILPASS : D3DRS_CCW_STENCILPASS,
- gl_d3d9::ConvertStencilOp(depthStencilState.stencilPassDepthPass));
-
- mDevice->SetRenderState(!frontFaceCCW ? D3DRS_STENCILWRITEMASK : D3DRS_CCW_STENCILWRITEMASK,
- depthStencilState.stencilBackWritemask);
- mDevice->SetRenderState(!frontFaceCCW ? D3DRS_STENCILFUNC : D3DRS_CCW_STENCILFUNC,
- gl_d3d9::ConvertComparison(depthStencilState.stencilBackFunc));
-
- mDevice->SetRenderState(!frontFaceCCW ? D3DRS_STENCILREF : D3DRS_CCW_STENCILREF,
- (stencilBackRef < (int)maxStencil) ? stencilBackRef : maxStencil);
- mDevice->SetRenderState(!frontFaceCCW ? D3DRS_STENCILMASK : D3DRS_CCW_STENCILMASK,
- depthStencilState.stencilBackMask);
-
- mDevice->SetRenderState(!frontFaceCCW ? D3DRS_STENCILFAIL : D3DRS_CCW_STENCILFAIL,
- gl_d3d9::ConvertStencilOp(depthStencilState.stencilBackFail));
- mDevice->SetRenderState(!frontFaceCCW ? D3DRS_STENCILZFAIL : D3DRS_CCW_STENCILZFAIL,
- gl_d3d9::ConvertStencilOp(depthStencilState.stencilBackPassDepthFail));
- mDevice->SetRenderState(!frontFaceCCW ? D3DRS_STENCILPASS : D3DRS_CCW_STENCILPASS,
- gl_d3d9::ConvertStencilOp(depthStencilState.stencilBackPassDepthPass));
- }
- else
- {
- mDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- }
-
- mDevice->SetRenderState(D3DRS_ZWRITEENABLE, depthStencilState.depthMask ? TRUE : FALSE);
-
- mCurStencilRef = stencilRef;
- mCurStencilBackRef = stencilBackRef;
- mCurFrontFaceCCW = frontFaceCCW;
- }
-
- mForceSetDepthStencilState = false;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void Renderer9::setScissorRectangle(const gl::Rectangle &scissor, bool enabled)
-{
- bool scissorChanged = mForceSetScissor ||
- memcmp(&scissor, &mCurScissor, sizeof(gl::Rectangle)) != 0 ||
- enabled != mScissorEnabled;
-
- if (scissorChanged)
- {
- if (enabled)
- {
- RECT rect;
- rect.left = gl::clamp(scissor.x, 0, static_cast<int>(mRenderTargetDesc.width));
- rect.top = gl::clamp(scissor.y, 0, static_cast<int>(mRenderTargetDesc.height));
- rect.right = gl::clamp(scissor.x + scissor.width, 0, static_cast<int>(mRenderTargetDesc.width));
- rect.bottom = gl::clamp(scissor.y + scissor.height, 0, static_cast<int>(mRenderTargetDesc.height));
- mDevice->SetScissorRect(&rect);
- }
-
- mDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, enabled ? TRUE : FALSE);
-
- mScissorEnabled = enabled;
- mCurScissor = scissor;
- }
-
- mForceSetScissor = false;
-}
-
-void Renderer9::setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace,
- bool ignoreViewport)
-{
- gl::Rectangle actualViewport = viewport;
- float actualZNear = gl::clamp01(zNear);
- float actualZFar = gl::clamp01(zFar);
- if (ignoreViewport)
- {
- actualViewport.x = 0;
- actualViewport.y = 0;
- actualViewport.width = mRenderTargetDesc.width;
- actualViewport.height = mRenderTargetDesc.height;
- actualZNear = 0.0f;
- actualZFar = 1.0f;
- }
-
- D3DVIEWPORT9 dxViewport;
- dxViewport.X = gl::clamp(actualViewport.x, 0, static_cast<int>(mRenderTargetDesc.width));
- dxViewport.Y = gl::clamp(actualViewport.y, 0, static_cast<int>(mRenderTargetDesc.height));
- dxViewport.Width = gl::clamp(actualViewport.width, 0, static_cast<int>(mRenderTargetDesc.width) - static_cast<int>(dxViewport.X));
- dxViewport.Height = gl::clamp(actualViewport.height, 0, static_cast<int>(mRenderTargetDesc.height) - static_cast<int>(dxViewport.Y));
- dxViewport.MinZ = actualZNear;
- dxViewport.MaxZ = actualZFar;
-
- float depthFront = !gl::IsTriangleMode(drawMode) ? 0.0f : (frontFace == GL_CCW ? 1.0f : -1.0f);
-
- bool viewportChanged = mForceSetViewport || memcmp(&actualViewport, &mCurViewport, sizeof(gl::Rectangle)) != 0 ||
- actualZNear != mCurNear || actualZFar != mCurFar || mCurDepthFront != depthFront;
- if (viewportChanged)
- {
- mDevice->SetViewport(&dxViewport);
-
- mCurViewport = actualViewport;
- mCurNear = actualZNear;
- mCurFar = actualZFar;
- mCurDepthFront = depthFront;
-
- dx_VertexConstants vc = {0};
- dx_PixelConstants pc = {0};
-
- vc.viewAdjust[0] = (float)((actualViewport.width - (int)dxViewport.Width) + 2 * (actualViewport.x - (int)dxViewport.X) - 1) / dxViewport.Width;
- vc.viewAdjust[1] = (float)((actualViewport.height - (int)dxViewport.Height) + 2 * (actualViewport.y - (int)dxViewport.Y) - 1) / dxViewport.Height;
- vc.viewAdjust[2] = (float)actualViewport.width / dxViewport.Width;
- vc.viewAdjust[3] = (float)actualViewport.height / dxViewport.Height;
-
- pc.viewCoords[0] = actualViewport.width * 0.5f;
- pc.viewCoords[1] = actualViewport.height * 0.5f;
- pc.viewCoords[2] = actualViewport.x + (actualViewport.width * 0.5f);
- pc.viewCoords[3] = actualViewport.y + (actualViewport.height * 0.5f);
-
- pc.depthFront[0] = (actualZFar - actualZNear) * 0.5f;
- pc.depthFront[1] = (actualZNear + actualZFar) * 0.5f;
- pc.depthFront[2] = depthFront;
-
- vc.depthRange[0] = actualZNear;
- vc.depthRange[1] = actualZFar;
- vc.depthRange[2] = actualZFar - actualZNear;
-
- pc.depthRange[0] = actualZNear;
- pc.depthRange[1] = actualZFar;
- pc.depthRange[2] = actualZFar - actualZNear;
-
- if (memcmp(&vc, &mVertexConstants, sizeof(dx_VertexConstants)) != 0)
- {
- mVertexConstants = vc;
- mDxUniformsDirty = true;
- }
-
- if (memcmp(&pc, &mPixelConstants, sizeof(dx_PixelConstants)) != 0)
- {
- mPixelConstants = pc;
- mDxUniformsDirty = true;
- }
- }
-
- mForceSetViewport = false;
-}
-
-bool Renderer9::applyPrimitiveType(GLenum mode, GLsizei count)
-{
- switch (mode)
- {
- case GL_POINTS:
- mPrimitiveType = D3DPT_POINTLIST;
- mPrimitiveCount = count;
- break;
- case GL_LINES:
- mPrimitiveType = D3DPT_LINELIST;
- mPrimitiveCount = count / 2;
- break;
- case GL_LINE_LOOP:
- mPrimitiveType = D3DPT_LINESTRIP;
- mPrimitiveCount = count - 1; // D3D doesn't support line loops, so we draw the last line separately
- break;
- case GL_LINE_STRIP:
- mPrimitiveType = D3DPT_LINESTRIP;
- mPrimitiveCount = count - 1;
- break;
- case GL_TRIANGLES:
- mPrimitiveType = D3DPT_TRIANGLELIST;
- mPrimitiveCount = count / 3;
- break;
- case GL_TRIANGLE_STRIP:
- mPrimitiveType = D3DPT_TRIANGLESTRIP;
- mPrimitiveCount = count - 2;
- break;
- case GL_TRIANGLE_FAN:
- mPrimitiveType = D3DPT_TRIANGLEFAN;
- mPrimitiveCount = count - 2;
- break;
- default:
- UNREACHABLE();
- return false;
- }
-
- return mPrimitiveCount > 0;
-}
-
-
-gl::Error Renderer9::getNullColorbuffer(gl::FramebufferAttachment *depthbuffer, gl::FramebufferAttachment **outColorBuffer)
-{
- ASSERT(depthbuffer);
-
- GLsizei width = depthbuffer->getWidth();
- GLsizei height = depthbuffer->getHeight();
-
- // search cached nullcolorbuffers
- for (int i = 0; i < NUM_NULL_COLORBUFFER_CACHE_ENTRIES; i++)
- {
- if (mNullColorbufferCache[i].buffer != NULL &&
- mNullColorbufferCache[i].width == width &&
- mNullColorbufferCache[i].height == height)
- {
- mNullColorbufferCache[i].lruCount = ++mMaxNullColorbufferLRU;
- *outColorBuffer = mNullColorbufferCache[i].buffer;
- return gl::Error(GL_NO_ERROR);
- }
- }
-
- gl::Renderbuffer *nullRenderbuffer = new gl::Renderbuffer(createRenderbuffer(), 0);
- gl::Error error = nullRenderbuffer->setStorage(width, height, GL_NONE, 0);
- if (error.isError())
- {
- SafeDelete(nullRenderbuffer);
- return error;
- }
-
- gl::RenderbufferAttachment *nullbuffer = new gl::RenderbufferAttachment(GL_NONE, nullRenderbuffer);
-
- // add nullbuffer to the cache
- NullColorbufferCacheEntry *oldest = &mNullColorbufferCache[0];
- for (int i = 1; i < NUM_NULL_COLORBUFFER_CACHE_ENTRIES; i++)
- {
- if (mNullColorbufferCache[i].lruCount < oldest->lruCount)
- {
- oldest = &mNullColorbufferCache[i];
- }
- }
-
- delete oldest->buffer;
- oldest->buffer = nullbuffer;
- oldest->lruCount = ++mMaxNullColorbufferLRU;
- oldest->width = width;
- oldest->height = height;
-
- *outColorBuffer = nullbuffer;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer9::applyRenderTarget(const gl::Framebuffer *framebuffer)
-{
- // if there is no color attachment we must synthesize a NULL colorattachment
- // to keep the D3D runtime happy. This should only be possible if depth texturing.
- gl::FramebufferAttachment *attachment = framebuffer->getColorbuffer(0);
- if (!attachment)
- {
- gl::Error error = getNullColorbuffer(framebuffer->getDepthbuffer(), &attachment);
- if (error.isError())
- {
- return error;
- }
- }
- ASSERT(attachment);
-
- bool renderTargetChanged = false;
- unsigned int renderTargetSerial = GetAttachmentSerial(attachment);
- if (renderTargetSerial != mAppliedRenderTargetSerial)
- {
- // Apply the render target on the device
- RenderTarget9 *renderTarget = NULL;
- gl::Error error = d3d9::GetAttachmentRenderTarget(attachment, &renderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(renderTarget);
-
- IDirect3DSurface9 *renderTargetSurface = renderTarget->getSurface();
- ASSERT(renderTargetSurface);
-
- mDevice->SetRenderTarget(0, renderTargetSurface);
- SafeRelease(renderTargetSurface);
-
- mAppliedRenderTargetSerial = renderTargetSerial;
- renderTargetChanged = true;
- }
-
- gl::FramebufferAttachment *depthStencil = framebuffer->getDepthbuffer();
- unsigned int depthbufferSerial = 0;
- unsigned int stencilbufferSerial = 0;
- if (depthStencil)
- {
- depthbufferSerial = GetAttachmentSerial(depthStencil);
- }
- else if (framebuffer->getStencilbuffer())
- {
- depthStencil = framebuffer->getStencilbuffer();
- stencilbufferSerial = GetAttachmentSerial(depthStencil);
- }
-
- if (depthbufferSerial != mAppliedDepthbufferSerial ||
- stencilbufferSerial != mAppliedStencilbufferSerial ||
- !mDepthStencilInitialized)
- {
- unsigned int depthSize = 0;
- unsigned int stencilSize = 0;
-
- // Apply the depth stencil on the device
- if (depthStencil)
- {
- RenderTarget9 *depthStencilRenderTarget = NULL;
- gl::Error error = d3d9::GetAttachmentRenderTarget(depthStencil, &depthStencilRenderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(depthStencilRenderTarget);
-
- IDirect3DSurface9 *depthStencilSurface = depthStencilRenderTarget->getSurface();
- ASSERT(depthStencilSurface);
-
- mDevice->SetDepthStencilSurface(depthStencilSurface);
- SafeRelease(depthStencilSurface);
-
- depthSize = depthStencil->getDepthSize();
- stencilSize = depthStencil->getStencilSize();
- }
- else
- {
- mDevice->SetDepthStencilSurface(NULL);
- }
-
- if (!mDepthStencilInitialized || depthSize != mCurDepthSize)
- {
- mCurDepthSize = depthSize;
- mForceSetRasterState = true;
- }
-
- if (!mDepthStencilInitialized || stencilSize != mCurStencilSize)
- {
- mCurStencilSize = stencilSize;
- mForceSetDepthStencilState = true;
- }
-
- mAppliedDepthbufferSerial = depthbufferSerial;
- mAppliedStencilbufferSerial = stencilbufferSerial;
- mDepthStencilInitialized = true;
- }
-
- if (renderTargetChanged || !mRenderTargetDescInitialized)
- {
- mForceSetScissor = true;
- mForceSetViewport = true;
- mForceSetBlendState = true;
-
- mRenderTargetDesc.width = attachment->getWidth();
- mRenderTargetDesc.height = attachment->getHeight();
- mRenderTargetDesc.format = attachment->getActualFormat();
- mRenderTargetDescInitialized = true;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer9::applyVertexBuffer(const gl::State &state, GLint first, GLsizei count, GLsizei instances)
-{
- TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS];
- gl::Error error = mVertexDataManager->prepareVertexData(state, first, count, attributes, instances);
- if (error.isError())
- {
- return error;
- }
-
- return mVertexDeclarationCache.applyDeclaration(mDevice, attributes, state.getCurrentProgramBinary(), instances, &mRepeatDraw);
-}
-
-// Applies the indices and element array bindings to the Direct3D 9 device
-gl::Error Renderer9::applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo)
-{
- gl::Error error = mIndexDataManager->prepareIndexData(type, count, elementArrayBuffer, indices, indexInfo);
- if (error.isError())
- {
- return error;
- }
-
- // Directly binding the storage buffer is not supported for d3d9
- ASSERT(indexInfo->storage == NULL);
-
- if (indexInfo->serial != mAppliedIBSerial)
- {
- IndexBuffer9* indexBuffer = IndexBuffer9::makeIndexBuffer9(indexInfo->indexBuffer);
-
- mDevice->SetIndices(indexBuffer->getBuffer());
- mAppliedIBSerial = indexInfo->serial;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void Renderer9::applyTransformFeedbackBuffers(const gl::State& state)
-{
- UNREACHABLE();
-}
-
-gl::Error Renderer9::drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive)
-{
- ASSERT(!transformFeedbackActive);
-
- startScene();
-
- if (mode == GL_LINE_LOOP)
- {
- return drawLineLoop(count, GL_NONE, NULL, 0, NULL);
- }
- else if (instances > 0)
- {
- StaticIndexBufferInterface *countingIB = NULL;
- gl::Error error = getCountingIB(count, &countingIB);
- if (error.isError())
- {
- return error;
- }
-
- if (mAppliedIBSerial != countingIB->getSerial())
- {
- IndexBuffer9 *indexBuffer = IndexBuffer9::makeIndexBuffer9(countingIB->getIndexBuffer());
-
- mDevice->SetIndices(indexBuffer->getBuffer());
- mAppliedIBSerial = countingIB->getSerial();
- }
-
- for (int i = 0; i < mRepeatDraw; i++)
- {
- mDevice->DrawIndexedPrimitive(mPrimitiveType, 0, 0, count, 0, mPrimitiveCount);
- }
-
- return gl::Error(GL_NO_ERROR);
- }
- else // Regular case
- {
- mDevice->DrawPrimitive(mPrimitiveType, 0, mPrimitiveCount);
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-gl::Error Renderer9::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
- gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo, GLsizei /*instances*/)
-{
- startScene();
-
- int minIndex = static_cast<int>(indexInfo.indexRange.start);
-
- if (mode == GL_POINTS)
- {
- return drawIndexedPoints(count, type, indices, minIndex, elementArrayBuffer);
- }
- else if (mode == GL_LINE_LOOP)
- {
- return drawLineLoop(count, type, indices, minIndex, elementArrayBuffer);
- }
- else
- {
- for (int i = 0; i < mRepeatDraw; i++)
- {
- GLsizei vertexCount = static_cast<int>(indexInfo.indexRange.length()) + 1;
- mDevice->DrawIndexedPrimitive(mPrimitiveType, -minIndex, minIndex, vertexCount, indexInfo.startIndex, mPrimitiveCount);
- }
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-gl::Error Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer)
-{
- // Get the raw indices for an indexed draw
- if (type != GL_NONE && elementArrayBuffer)
- {
- BufferD3D *storage = BufferD3D::makeFromBuffer(elementArrayBuffer);
- intptr_t offset = reinterpret_cast<intptr_t>(indices);
- const uint8_t *bufferData = NULL;
- gl::Error error = storage->getData(&bufferData);
- if (error.isError())
- {
- return error;
- }
- indices = bufferData + offset;
- }
-
- unsigned int startIndex = 0;
-
- if (getRendererExtensions().elementIndexUint)
- {
- if (!mLineLoopIB)
- {
- mLineLoopIB = new StreamingIndexBufferInterface(this);
- gl::Error error = mLineLoopIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT);
- if (error.isError())
- {
- SafeDelete(mLineLoopIB);
- return error;
- }
- }
-
- // Checked by Renderer9::applyPrimitiveType
- ASSERT(count >= 0);
-
- if (static_cast<unsigned int>(count) + 1 > (std::numeric_limits<unsigned int>::max() / sizeof(unsigned int)))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create a 32-bit looping index buffer for GL_LINE_LOOP, too many indices required.");
- }
-
- const unsigned int spaceNeeded = (static_cast<unsigned int>(count)+1) * sizeof(unsigned int);
- gl::Error error = mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT);
- if (error.isError())
- {
- return error;
- }
-
- void* mappedMemory = NULL;
- unsigned int offset = 0;
- error = mLineLoopIB->mapBuffer(spaceNeeded, &mappedMemory, &offset);
- if (error.isError())
- {
- return error;
- }
-
- startIndex = static_cast<unsigned int>(offset) / 4;
- unsigned int *data = reinterpret_cast<unsigned int*>(mappedMemory);
-
- switch (type)
- {
- case GL_NONE: // Non-indexed draw
- for (int i = 0; i < count; i++)
- {
- data[i] = i;
- }
- data[count] = 0;
- break;
- case GL_UNSIGNED_BYTE:
- for (int i = 0; i < count; i++)
- {
- data[i] = static_cast<const GLubyte*>(indices)[i];
- }
- data[count] = static_cast<const GLubyte*>(indices)[0];
- break;
- case GL_UNSIGNED_SHORT:
- for (int i = 0; i < count; i++)
- {
- data[i] = static_cast<const GLushort*>(indices)[i];
- }
- data[count] = static_cast<const GLushort*>(indices)[0];
- break;
- case GL_UNSIGNED_INT:
- for (int i = 0; i < count; i++)
- {
- data[i] = static_cast<const GLuint*>(indices)[i];
- }
- data[count] = static_cast<const GLuint*>(indices)[0];
- break;
- default: UNREACHABLE();
- }
-
- error = mLineLoopIB->unmapBuffer();
- if (error.isError())
- {
- return error;
- }
- }
- else
- {
- if (!mLineLoopIB)
- {
- mLineLoopIB = new StreamingIndexBufferInterface(this);
- gl::Error error = mLineLoopIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_SHORT);
- if (error.isError())
- {
- SafeDelete(mLineLoopIB);
- return error;
- }
- }
-
- // Checked by Renderer9::applyPrimitiveType
- ASSERT(count >= 0);
-
- if (static_cast<unsigned int>(count) + 1 > (std::numeric_limits<unsigned short>::max() / sizeof(unsigned short)))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create a 16-bit looping index buffer for GL_LINE_LOOP, too many indices required.");
- }
-
- const unsigned int spaceNeeded = (static_cast<unsigned int>(count) + 1) * sizeof(unsigned short);
- gl::Error error = mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_SHORT);
- if (error.isError())
- {
- return error;
- }
-
- void* mappedMemory = NULL;
- unsigned int offset;
- error = mLineLoopIB->mapBuffer(spaceNeeded, &mappedMemory, &offset);
- if (error.isError())
- {
- return error;
- }
-
- startIndex = static_cast<unsigned int>(offset) / 2;
- unsigned short *data = reinterpret_cast<unsigned short*>(mappedMemory);
-
- switch (type)
- {
- case GL_NONE: // Non-indexed draw
- for (int i = 0; i < count; i++)
- {
- data[i] = i;
- }
- data[count] = 0;
- break;
- case GL_UNSIGNED_BYTE:
- for (int i = 0; i < count; i++)
- {
- data[i] = static_cast<const GLubyte*>(indices)[i];
- }
- data[count] = static_cast<const GLubyte*>(indices)[0];
- break;
- case GL_UNSIGNED_SHORT:
- for (int i = 0; i < count; i++)
- {
- data[i] = static_cast<const GLushort*>(indices)[i];
- }
- data[count] = static_cast<const GLushort*>(indices)[0];
- break;
- case GL_UNSIGNED_INT:
- for (int i = 0; i < count; i++)
- {
- data[i] = static_cast<const GLuint*>(indices)[i];
- }
- data[count] = static_cast<const GLuint*>(indices)[0];
- break;
- default: UNREACHABLE();
- }
-
- error = mLineLoopIB->unmapBuffer();
- if (error.isError())
- {
- return error;
- }
- }
-
- if (mAppliedIBSerial != mLineLoopIB->getSerial())
- {
- IndexBuffer9 *indexBuffer = IndexBuffer9::makeIndexBuffer9(mLineLoopIB->getIndexBuffer());
-
- mDevice->SetIndices(indexBuffer->getBuffer());
- mAppliedIBSerial = mLineLoopIB->getSerial();
- }
-
- mDevice->DrawIndexedPrimitive(D3DPT_LINESTRIP, -minIndex, minIndex, count, startIndex, count);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-template <typename T>
-static gl::Error drawPoints(IDirect3DDevice9* device, GLsizei count, const GLvoid *indices, int minIndex)
-{
- for (int i = 0; i < count; i++)
- {
- unsigned int indexValue = static_cast<unsigned int>(static_cast<const T*>(indices)[i]) - minIndex;
- device->DrawPrimitive(D3DPT_POINTLIST, indexValue, 1);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer9::drawIndexedPoints(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer)
-{
- // Drawing index point lists is unsupported in d3d9, fall back to a regular DrawPrimitive call
- // for each individual point. This call is not expected to happen often.
-
- if (elementArrayBuffer)
- {
- BufferD3D *storage = BufferD3D::makeFromBuffer(elementArrayBuffer);
- intptr_t offset = reinterpret_cast<intptr_t>(indices);
-
- const uint8_t *bufferData = NULL;
- gl::Error error = storage->getData(&bufferData);
- if (error.isError())
- {
- return error;
- }
-
- indices = bufferData + offset;
- }
-
- switch (type)
- {
- case GL_UNSIGNED_BYTE: return drawPoints<GLubyte>(mDevice, count, indices, minIndex);
- case GL_UNSIGNED_SHORT: return drawPoints<GLushort>(mDevice, count, indices, minIndex);
- case GL_UNSIGNED_INT: return drawPoints<GLuint>(mDevice, count, indices, minIndex);
- default: UNREACHABLE(); return gl::Error(GL_INVALID_OPERATION);
- }
-}
-
-gl::Error Renderer9::getCountingIB(size_t count, StaticIndexBufferInterface **outIB)
-{
- // Update the counting index buffer if it is not large enough or has not been created yet.
- if (count <= 65536) // 16-bit indices
- {
- const unsigned int spaceNeeded = count * sizeof(unsigned short);
-
- if (!mCountingIB || mCountingIB->getBufferSize() < spaceNeeded)
- {
- SafeDelete(mCountingIB);
- mCountingIB = new StaticIndexBufferInterface(this);
- mCountingIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_SHORT);
-
- void *mappedMemory = NULL;
- gl::Error error = mCountingIB->mapBuffer(spaceNeeded, &mappedMemory, NULL);
- if (error.isError())
- {
- return error;
- }
-
- unsigned short *data = reinterpret_cast<unsigned short*>(mappedMemory);
- for (size_t i = 0; i < count; i++)
- {
- data[i] = i;
- }
-
- error = mCountingIB->unmapBuffer();
- if (error.isError())
- {
- return error;
- }
- }
- }
- else if (getRendererExtensions().elementIndexUint)
- {
- const unsigned int spaceNeeded = count * sizeof(unsigned int);
-
- if (!mCountingIB || mCountingIB->getBufferSize() < spaceNeeded)
- {
- SafeDelete(mCountingIB);
- mCountingIB = new StaticIndexBufferInterface(this);
- mCountingIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT);
-
- void *mappedMemory = NULL;
- gl::Error error = mCountingIB->mapBuffer(spaceNeeded, &mappedMemory, NULL);
- if (error.isError())
- {
- return error;
- }
-
- unsigned int *data = reinterpret_cast<unsigned int*>(mappedMemory);
- for (size_t i = 0; i < count; i++)
- {
- data[i] = i;
- }
-
- error = mCountingIB->unmapBuffer();
- if (error.isError())
- {
- return error;
- }
- }
- }
- else
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Could not create a counting index buffer for glDrawArraysInstanced.");
- }
-
- *outIB = mCountingIB;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer9::applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
- bool rasterizerDiscard, bool transformFeedbackActive)
-{
- ASSERT(!transformFeedbackActive);
- ASSERT(!rasterizerDiscard);
-
- ProgramD3D *programD3D = ProgramD3D::makeProgramD3D(programBinary->getImplementation());
-
- ShaderExecutable *vertexExe = NULL;
- gl::Error error = programD3D->getVertexExecutableForInputLayout(inputLayout, &vertexExe);
- if (error.isError())
- {
- return error;
- }
-
- ShaderExecutable *pixelExe = NULL;
- error = programD3D->getPixelExecutableForFramebuffer(framebuffer, &pixelExe);
- if (error.isError())
- {
- return error;
- }
-
- IDirect3DVertexShader9 *vertexShader = (vertexExe ? ShaderExecutable9::makeShaderExecutable9(vertexExe)->getVertexShader() : NULL);
- IDirect3DPixelShader9 *pixelShader = (pixelExe ? ShaderExecutable9::makeShaderExecutable9(pixelExe)->getPixelShader() : NULL);
-
- if (vertexShader != mAppliedVertexShader)
- {
- mDevice->SetVertexShader(vertexShader);
- mAppliedVertexShader = vertexShader;
- }
-
- if (pixelShader != mAppliedPixelShader)
- {
- mDevice->SetPixelShader(pixelShader);
- mAppliedPixelShader = pixelShader;
- }
-
- // D3D9 has a quirk where creating multiple shaders with the same content
- // can return the same shader pointer. Because GL programs store different data
- // per-program, checking the program serial guarantees we upload fresh
- // uniform data even if our shader pointers are the same.
- // https://code.google.com/p/angleproject/issues/detail?id=661
- unsigned int programSerial = programBinary->getSerial();
- if (programSerial != mAppliedProgramSerial)
- {
- programD3D->dirtyAllUniforms();
- mDxUniformsDirty = true;
- mAppliedProgramSerial = programSerial;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer9::applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray)
-{
- for (size_t uniformIndex = 0; uniformIndex < uniformArray.size(); uniformIndex++)
- {
- gl::LinkedUniform *targetUniform = uniformArray[uniformIndex];
-
- if (targetUniform->dirty)
- {
- GLfloat *f = (GLfloat*)targetUniform->data;
- GLint *i = (GLint*)targetUniform->data;
-
- switch (targetUniform->type)
- {
- case GL_SAMPLER_2D:
- case GL_SAMPLER_CUBE:
- break;
- case GL_BOOL:
- case GL_BOOL_VEC2:
- case GL_BOOL_VEC3:
- case GL_BOOL_VEC4:
- applyUniformnbv(targetUniform, i);
- break;
- case GL_FLOAT:
- case GL_FLOAT_VEC2:
- case GL_FLOAT_VEC3:
- case GL_FLOAT_VEC4:
- case GL_FLOAT_MAT2:
- case GL_FLOAT_MAT3:
- case GL_FLOAT_MAT4:
- applyUniformnfv(targetUniform, f);
- break;
- case GL_INT:
- case GL_INT_VEC2:
- case GL_INT_VEC3:
- case GL_INT_VEC4:
- applyUniformniv(targetUniform, i);
- break;
- default:
- UNREACHABLE();
- }
- }
- }
-
- // Driver uniforms
- if (mDxUniformsDirty)
- {
- mDevice->SetVertexShaderConstantF(0, (float*)&mVertexConstants, sizeof(dx_VertexConstants) / sizeof(float[4]));
- mDevice->SetPixelShaderConstantF(0, (float*)&mPixelConstants, sizeof(dx_PixelConstants) / sizeof(float[4]));
- mDxUniformsDirty = false;
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void Renderer9::applyUniformnfv(gl::LinkedUniform *targetUniform, const GLfloat *v)
-{
- if (targetUniform->isReferencedByFragmentShader())
- {
- mDevice->SetPixelShaderConstantF(targetUniform->psRegisterIndex, v, targetUniform->registerCount);
- }
-
- if (targetUniform->isReferencedByVertexShader())
- {
- mDevice->SetVertexShaderConstantF(targetUniform->vsRegisterIndex, v, targetUniform->registerCount);
- }
-}
-
-void Renderer9::applyUniformniv(gl::LinkedUniform *targetUniform, const GLint *v)
-{
- ASSERT(targetUniform->registerCount <= MAX_VERTEX_CONSTANT_VECTORS_D3D9);
- GLfloat vector[MAX_VERTEX_CONSTANT_VECTORS_D3D9][4];
-
- for (unsigned int i = 0; i < targetUniform->registerCount; i++)
- {
- vector[i][0] = (GLfloat)v[4 * i + 0];
- vector[i][1] = (GLfloat)v[4 * i + 1];
- vector[i][2] = (GLfloat)v[4 * i + 2];
- vector[i][3] = (GLfloat)v[4 * i + 3];
- }
-
- applyUniformnfv(targetUniform, (GLfloat*)vector);
-}
-
-void Renderer9::applyUniformnbv(gl::LinkedUniform *targetUniform, const GLint *v)
-{
- ASSERT(targetUniform->registerCount <= MAX_VERTEX_CONSTANT_VECTORS_D3D9);
- GLfloat vector[MAX_VERTEX_CONSTANT_VECTORS_D3D9][4];
-
- for (unsigned int i = 0; i < targetUniform->registerCount; i++)
- {
- vector[i][0] = (v[4 * i + 0] == GL_FALSE) ? 0.0f : 1.0f;
- vector[i][1] = (v[4 * i + 1] == GL_FALSE) ? 0.0f : 1.0f;
- vector[i][2] = (v[4 * i + 2] == GL_FALSE) ? 0.0f : 1.0f;
- vector[i][3] = (v[4 * i + 3] == GL_FALSE) ? 0.0f : 1.0f;
- }
-
- applyUniformnfv(targetUniform, (GLfloat*)vector);
-}
-
-gl::Error Renderer9::clear(const gl::ClearParameters &clearParams, const gl::Framebuffer *frameBuffer)
-{
- if (clearParams.colorClearType != GL_FLOAT)
- {
- // Clearing buffers with non-float values is not supported by Renderer9 and ES 2.0
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
- }
-
- bool clearColor = clearParams.clearColor[0];
- for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++)
- {
- if (clearParams.clearColor[i] != clearColor)
- {
- // Clearing individual buffers other than buffer zero is not supported by Renderer9 and ES 2.0
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
- }
- }
-
- float depth = gl::clamp01(clearParams.depthClearValue);
- DWORD stencil = clearParams.stencilClearValue & 0x000000FF;
-
- unsigned int stencilUnmasked = 0x0;
- if (clearParams.clearStencil && frameBuffer->hasStencil())
- {
- unsigned int stencilSize = gl::GetInternalFormatInfo((frameBuffer->getStencilbuffer()->getActualFormat())).stencilBits;
- stencilUnmasked = (0x1 << stencilSize) - 1;
- }
-
- const bool needMaskedStencilClear = clearParams.clearStencil &&
- (clearParams.stencilWriteMask & stencilUnmasked) != stencilUnmasked;
-
- bool needMaskedColorClear = false;
- D3DCOLOR color = D3DCOLOR_ARGB(255, 0, 0, 0);
- if (clearColor)
- {
- const gl::FramebufferAttachment *attachment = frameBuffer->getFirstColorbuffer();
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(attachment->getInternalFormat());
- const gl::InternalFormat &actualFormatInfo = gl::GetInternalFormatInfo(attachment->getActualFormat());
-
- color = D3DCOLOR_ARGB(gl::unorm<8>((formatInfo.alphaBits == 0 && actualFormatInfo.alphaBits > 0) ? 1.0f : clearParams.colorFClearValue.alpha),
- gl::unorm<8>((formatInfo.redBits == 0 && actualFormatInfo.redBits > 0) ? 0.0f : clearParams.colorFClearValue.red),
- gl::unorm<8>((formatInfo.greenBits == 0 && actualFormatInfo.greenBits > 0) ? 0.0f : clearParams.colorFClearValue.green),
- gl::unorm<8>((formatInfo.blueBits == 0 && actualFormatInfo.blueBits > 0) ? 0.0f : clearParams.colorFClearValue.blue));
-
- if ((formatInfo.redBits > 0 && !clearParams.colorMaskRed) ||
- (formatInfo.greenBits > 0 && !clearParams.colorMaskGreen) ||
- (formatInfo.blueBits > 0 && !clearParams.colorMaskBlue) ||
- (formatInfo.alphaBits > 0 && !clearParams.colorMaskAlpha))
- {
- needMaskedColorClear = true;
- }
- }
-
- if (needMaskedColorClear || needMaskedStencilClear)
- {
- // State which is altered in all paths from this point to the clear call is saved.
- // State which is altered in only some paths will be flagged dirty in the case that
- // that path is taken.
- HRESULT hr;
- if (mMaskedClearSavedState == NULL)
- {
- hr = mDevice->BeginStateBlock();
- ASSERT(SUCCEEDED(hr) || hr == D3DERR_OUTOFVIDEOMEMORY || hr == E_OUTOFMEMORY);
-
- mDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
- mDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
- mDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
- mDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- mDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
- mDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
- mDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- mDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
- mDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
- mDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- mDevice->SetPixelShader(NULL);
- mDevice->SetVertexShader(NULL);
- mDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
- mDevice->SetStreamSource(0, NULL, 0, 0);
- mDevice->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE);
- mDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
- mDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
- mDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
- mDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);
- mDevice->SetRenderState(D3DRS_TEXTUREFACTOR, color);
- mDevice->SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
-
- for(int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- mDevice->SetStreamSourceFreq(i, 1);
- }
-
- hr = mDevice->EndStateBlock(&mMaskedClearSavedState);
- ASSERT(SUCCEEDED(hr) || hr == D3DERR_OUTOFVIDEOMEMORY || hr == E_OUTOFMEMORY);
- }
-
- ASSERT(mMaskedClearSavedState != NULL);
-
- if (mMaskedClearSavedState != NULL)
- {
- hr = mMaskedClearSavedState->Capture();
- ASSERT(SUCCEEDED(hr));
- }
-
- mDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
- mDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
- mDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
- mDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- mDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
- mDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
- mDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- mDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
-
- if (clearColor)
- {
- mDevice->SetRenderState(D3DRS_COLORWRITEENABLE,
- gl_d3d9::ConvertColorMask(clearParams.colorMaskRed,
- clearParams.colorMaskGreen,
- clearParams.colorMaskBlue,
- clearParams.colorMaskAlpha));
- }
- else
- {
- mDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
- }
-
- if (stencilUnmasked != 0x0 && clearParams.clearStencil)
- {
- mDevice->SetRenderState(D3DRS_STENCILENABLE, TRUE);
- mDevice->SetRenderState(D3DRS_TWOSIDEDSTENCILMODE, FALSE);
- mDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_ALWAYS);
- mDevice->SetRenderState(D3DRS_STENCILREF, stencil);
- mDevice->SetRenderState(D3DRS_STENCILWRITEMASK, clearParams.stencilWriteMask);
- mDevice->SetRenderState(D3DRS_STENCILFAIL, D3DSTENCILOP_REPLACE);
- mDevice->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_REPLACE);
- mDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_REPLACE);
- }
- else
- {
- mDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- }
-
- mDevice->SetPixelShader(NULL);
- mDevice->SetVertexShader(NULL);
- mDevice->SetFVF(D3DFVF_XYZRHW);
- mDevice->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE);
- mDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
- mDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
- mDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
- mDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);
- mDevice->SetRenderState(D3DRS_TEXTUREFACTOR, color);
- mDevice->SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
-
- for(int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- mDevice->SetStreamSourceFreq(i, 1);
- }
-
- float quad[4][4]; // A quadrilateral covering the target, aligned to match the edges
- quad[0][0] = -0.5f;
- quad[0][1] = mRenderTargetDesc.height - 0.5f;
- quad[0][2] = 0.0f;
- quad[0][3] = 1.0f;
-
- quad[1][0] = mRenderTargetDesc.width - 0.5f;
- quad[1][1] = mRenderTargetDesc.height - 0.5f;
- quad[1][2] = 0.0f;
- quad[1][3] = 1.0f;
-
- quad[2][0] = -0.5f;
- quad[2][1] = -0.5f;
- quad[2][2] = 0.0f;
- quad[2][3] = 1.0f;
-
- quad[3][0] = mRenderTargetDesc.width - 0.5f;
- quad[3][1] = -0.5f;
- quad[3][2] = 0.0f;
- quad[3][3] = 1.0f;
-
- startScene();
- mDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, quad, sizeof(float[4]));
-
- if (clearParams.clearDepth)
- {
- mDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
- mDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
- mDevice->Clear(0, NULL, D3DCLEAR_ZBUFFER, color, depth, stencil);
- }
-
- if (mMaskedClearSavedState != NULL)
- {
- mMaskedClearSavedState->Apply();
- }
- }
- else if (clearColor || clearParams.clearDepth || clearParams.clearStencil)
- {
- DWORD dxClearFlags = 0;
- if (clearColor)
- {
- dxClearFlags |= D3DCLEAR_TARGET;
- }
- if (clearParams.clearDepth)
- {
- dxClearFlags |= D3DCLEAR_ZBUFFER;
- }
- if (clearParams.clearStencil)
- {
- dxClearFlags |= D3DCLEAR_STENCIL;
- }
-
- mDevice->Clear(0, NULL, dxClearFlags, color, depth, stencil);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void Renderer9::markAllStateDirty()
-{
- mAppliedRenderTargetSerial = 0;
- mAppliedDepthbufferSerial = 0;
- mAppliedStencilbufferSerial = 0;
- mDepthStencilInitialized = false;
- mRenderTargetDescInitialized = false;
-
- mForceSetDepthStencilState = true;
- mForceSetRasterState = true;
- mForceSetScissor = true;
- mForceSetViewport = true;
- mForceSetBlendState = true;
-
- ASSERT(mForceSetVertexSamplerStates.size() == mCurVertexTextureSerials.size());
- for (unsigned int i = 0; i < mForceSetVertexSamplerStates.size(); i++)
- {
- mForceSetVertexSamplerStates[i] = true;
- mCurVertexTextureSerials[i] = 0;
- }
-
- ASSERT(mForceSetPixelSamplerStates.size() == mCurPixelTextureSerials.size());
- for (unsigned int i = 0; i < mForceSetPixelSamplerStates.size(); i++)
- {
- mForceSetPixelSamplerStates[i] = true;
- mCurPixelTextureSerials[i] = 0;
- }
-
- mAppliedIBSerial = 0;
- mAppliedVertexShader = NULL;
- mAppliedPixelShader = NULL;
- mAppliedProgramSerial = 0;
- mDxUniformsDirty = true;
-
- mVertexDeclarationCache.markStateDirty();
-}
-
-void Renderer9::releaseDeviceResources()
-{
- for (size_t i = 0; i < mEventQueryPool.size(); i++)
- {
- SafeRelease(mEventQueryPool[i]);
- }
- mEventQueryPool.clear();
-
- SafeRelease(mMaskedClearSavedState);
-
- mVertexShaderCache.clear();
- mPixelShaderCache.clear();
-
- SafeDelete(mBlit);
- SafeDelete(mVertexDataManager);
- SafeDelete(mIndexDataManager);
- SafeDelete(mLineLoopIB);
- SafeDelete(mCountingIB);
-
- for (int i = 0; i < NUM_NULL_COLORBUFFER_CACHE_ENTRIES; i++)
- {
- SafeDelete(mNullColorbufferCache[i].buffer);
- }
-}
-
-void Renderer9::notifyDeviceLost()
-{
- mDeviceLost = true;
- mDisplay->notifyDeviceLost();
-}
-
-bool Renderer9::isDeviceLost()
-{
- return mDeviceLost;
-}
-
-// set notify to true to broadcast a message to all contexts of the device loss
-bool Renderer9::testDeviceLost(bool notify)
-{
- HRESULT status = getDeviceStatusCode();
- bool isLost = FAILED(status);
-
- if (isLost)
- {
- // ensure we note the device loss --
- // we'll probably get this done again by notifyDeviceLost
- // but best to remember it!
- // Note that we don't want to clear the device loss status here
- // -- this needs to be done by resetDevice
- mDeviceLost = true;
- if (notify)
- {
- notifyDeviceLost();
- }
- }
-
- return isLost;
-}
-
-HRESULT Renderer9::getDeviceStatusCode()
-{
- HRESULT status = D3D_OK;
-
- if (mDeviceEx)
- {
- status = mDeviceEx->CheckDeviceState(NULL);
- }
- else if (mDevice)
- {
- status = mDevice->TestCooperativeLevel();
- }
-
- return status;
-}
-
-bool Renderer9::testDeviceResettable()
-{
- // On D3D9Ex, DEVICELOST represents a hung device that needs to be restarted
- // DEVICEREMOVED indicates the device has been stopped and must be recreated
- switch (getDeviceStatusCode())
- {
- case D3DERR_DEVICENOTRESET:
- case D3DERR_DEVICEHUNG:
- return true;
- case D3DERR_DEVICELOST:
- return (mDeviceEx != NULL);
- case D3DERR_DEVICEREMOVED:
- ASSERT(mDeviceEx != NULL);
- return isRemovedDeviceResettable();
- default:
- return false;
- }
-}
-
-bool Renderer9::resetDevice()
-{
- releaseDeviceResources();
-
- D3DPRESENT_PARAMETERS presentParameters = getDefaultPresentParameters();
-
- HRESULT result = D3D_OK;
- bool lost = testDeviceLost(false);
- bool removedDevice = (getDeviceStatusCode() == D3DERR_DEVICEREMOVED);
-
- // Device Removed is a feature which is only present with D3D9Ex
- ASSERT(mDeviceEx != NULL || !removedDevice);
-
- for (int attempts = 3; lost && attempts > 0; attempts--)
- {
- if (removedDevice)
- {
- // Device removed, which may trigger on driver reinstallation,
- // may cause a longer wait other reset attempts before the
- // system is ready to handle creating a new device.
- Sleep(800);
- lost = !resetRemovedDevice();
- }
- else if (mDeviceEx)
- {
- Sleep(500); // Give the graphics driver some CPU time
- result = mDeviceEx->ResetEx(&presentParameters, NULL);
- lost = testDeviceLost(false);
- }
- else
- {
- result = mDevice->TestCooperativeLevel();
- while (result == D3DERR_DEVICELOST)
- {
- Sleep(100); // Give the graphics driver some CPU time
- result = mDevice->TestCooperativeLevel();
- }
-
- if (result == D3DERR_DEVICENOTRESET)
- {
- result = mDevice->Reset(&presentParameters);
- }
- lost = testDeviceLost(false);
- }
- }
-
- if (FAILED(result))
- {
- ERR("Reset/ResetEx failed multiple times: 0x%08X", result);
- return false;
- }
-
- if (removedDevice && lost)
- {
- ERR("Device lost reset failed multiple times");
- return false;
- }
-
- // If the device was removed, we already finished re-initialization in resetRemovedDevice
- if (!removedDevice)
- {
- // reset device defaults
- initializeDevice();
- }
-
- mDeviceLost = false;
-
- return true;
-}
-
-bool Renderer9::isRemovedDeviceResettable() const
-{
- bool success = false;
-
-#if ANGLE_D3D9EX == ANGLE_ENABLED
- IDirect3D9Ex *d3d9Ex = NULL;
- typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT, IDirect3D9Ex**);
- Direct3DCreate9ExFunc Direct3DCreate9ExPtr = reinterpret_cast<Direct3DCreate9ExFunc>(GetProcAddress(mD3d9Module, "Direct3DCreate9Ex"));
-
- if (Direct3DCreate9ExPtr && SUCCEEDED(Direct3DCreate9ExPtr(D3D_SDK_VERSION, &d3d9Ex)))
- {
- D3DCAPS9 deviceCaps;
- HRESULT result = d3d9Ex->GetDeviceCaps(mAdapter, mDeviceType, &deviceCaps);
- success = SUCCEEDED(result);
- }
-
- SafeRelease(d3d9Ex);
-#else
- ASSERT(UNREACHABLE());
-#endif
-
- return success;
-}
-
-bool Renderer9::resetRemovedDevice()
-{
- // From http://msdn.microsoft.com/en-us/library/windows/desktop/bb172554(v=vs.85).aspx:
- // The hardware adapter has been removed. Application must destroy the device, do enumeration of
- // adapters and create another Direct3D device. If application continues rendering without
- // calling Reset, the rendering calls will succeed. Applies to Direct3D 9Ex only.
- release();
- return (initialize() == EGL_SUCCESS);
-}
-
-DWORD Renderer9::getAdapterVendor() const
-{
- return mAdapterIdentifier.VendorId;
-}
-
-std::string Renderer9::getRendererDescription() const
-{
- std::ostringstream rendererString;
-
- rendererString << mAdapterIdentifier.Description;
- if (getShareHandleSupport())
- {
- rendererString << " Direct3D9Ex";
- }
- else
- {
- rendererString << " Direct3D9";
- }
-
- rendererString << " vs_" << D3DSHADER_VERSION_MAJOR(mDeviceCaps.VertexShaderVersion) << "_" << D3DSHADER_VERSION_MINOR(mDeviceCaps.VertexShaderVersion);
- rendererString << " ps_" << D3DSHADER_VERSION_MAJOR(mDeviceCaps.PixelShaderVersion) << "_" << D3DSHADER_VERSION_MINOR(mDeviceCaps.PixelShaderVersion);
-
- return rendererString.str();
-}
-
-GUID Renderer9::getAdapterIdentifier() const
-{
- return mAdapterIdentifier.DeviceIdentifier;
-}
-
-unsigned int Renderer9::getReservedVertexUniformVectors() const
-{
- return 2; // dx_ViewAdjust and dx_DepthRange.
-}
-
-unsigned int Renderer9::getReservedFragmentUniformVectors() const
-{
- return 3; // dx_ViewCoords, dx_DepthFront and dx_DepthRange.
-}
-
-unsigned int Renderer9::getReservedVertexUniformBuffers() const
-{
- return 0;
-}
-
-unsigned int Renderer9::getReservedFragmentUniformBuffers() const
-{
- return 0;
-}
-
-bool Renderer9::getShareHandleSupport() const
-{
- // PIX doesn't seem to support using share handles, so disable them.
- return (mD3d9Ex != NULL) && !gl::perfActive();
-}
-
-bool Renderer9::getPostSubBufferSupport() const
-{
- return true;
-}
-
-int Renderer9::getMajorShaderModel() const
-{
- return D3DSHADER_VERSION_MAJOR(mDeviceCaps.PixelShaderVersion);
-}
-
-DWORD Renderer9::getCapsDeclTypes() const
-{
- return mDeviceCaps.DeclTypes;
-}
-
-int Renderer9::getMinSwapInterval() const
-{
- return mMinSwapInterval;
-}
-
-int Renderer9::getMaxSwapInterval() const
-{
- return mMaxSwapInterval;
-}
-
-D3DPOOL Renderer9::getBufferPool(DWORD usage) const
-{
- if (mD3d9Ex != NULL)
- {
- return D3DPOOL_DEFAULT;
- }
- else
- {
- if (!(usage & D3DUSAGE_DYNAMIC))
- {
- return D3DPOOL_MANAGED;
- }
- }
-
- return D3DPOOL_DEFAULT;
-}
-
-gl::Error Renderer9::copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level)
-{
- RECT rect;
- rect.left = sourceRect.x;
- rect.top = sourceRect.y;
- rect.right = sourceRect.x + sourceRect.width;
- rect.bottom = sourceRect.y + sourceRect.height;
-
- return mBlit->copy2D(framebuffer, rect, destFormat, xoffset, yoffset, storage, level);
-}
-
-gl::Error Renderer9::copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level)
-{
- RECT rect;
- rect.left = sourceRect.x;
- rect.top = sourceRect.y;
- rect.right = sourceRect.x + sourceRect.width;
- rect.bottom = sourceRect.y + sourceRect.height;
-
- return mBlit->copyCube(framebuffer, rect, destFormat, xoffset, yoffset, storage, target, level);
-}
-
-gl::Error Renderer9::copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level)
-{
- // 3D textures are not available in the D3D9 backend.
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
-}
-
-gl::Error Renderer9::copyImage2DArray(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level)
-{
- // 2D array textures are not available in the D3D9 backend.
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
-}
-
-gl::Error Renderer9::blitRect(const gl::Framebuffer *readFramebuffer, const gl::Rectangle &readRect,
- const gl::Framebuffer *drawFramebuffer, const gl::Rectangle &drawRect,
- const gl::Rectangle *scissor, bool blitRenderTarget,
- bool blitDepth, bool blitStencil, GLenum filter)
-{
- ASSERT(filter == GL_NEAREST);
-
- endScene();
-
- if (blitRenderTarget)
- {
- gl::FramebufferAttachment *readBuffer = readFramebuffer->getColorbuffer(0);
- ASSERT(readBuffer);
-
- RenderTarget9 *readRenderTarget = NULL;
- gl::Error error = d3d9::GetAttachmentRenderTarget(readBuffer, &readRenderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(readRenderTarget);
-
- gl::FramebufferAttachment *drawBuffer = drawFramebuffer->getColorbuffer(0);
- ASSERT(drawBuffer);
-
- RenderTarget9 *drawRenderTarget = NULL;
- error = d3d9::GetAttachmentRenderTarget(drawBuffer, &drawRenderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(drawRenderTarget);
-
- // The getSurface calls do an AddRef so save them until after no errors are possible
- IDirect3DSurface9* readSurface = readRenderTarget->getSurface();
- ASSERT(readSurface);
-
- IDirect3DSurface9* drawSurface = drawRenderTarget->getSurface();
- ASSERT(drawSurface);
-
- gl::Extents srcSize(readRenderTarget->getWidth(), readRenderTarget->getHeight(), 1);
- gl::Extents dstSize(drawRenderTarget->getWidth(), drawRenderTarget->getHeight(), 1);
-
- RECT srcRect;
- srcRect.left = readRect.x;
- srcRect.right = readRect.x + readRect.width;
- srcRect.top = readRect.y;
- srcRect.bottom = readRect.y + readRect.height;
-
- RECT dstRect;
- dstRect.left = drawRect.x;
- dstRect.right = drawRect.x + drawRect.width;
- dstRect.top = drawRect.y;
- dstRect.bottom = drawRect.y + drawRect.height;
-
- // Clip the rectangles to the scissor rectangle
- if (scissor)
- {
- if (dstRect.left < scissor->x)
- {
- srcRect.left += (scissor->x - dstRect.left);
- dstRect.left = scissor->x;
- }
- if (dstRect.top < scissor->y)
- {
- srcRect.top += (scissor->y - dstRect.top);
- dstRect.top = scissor->y;
- }
- if (dstRect.right > scissor->x + scissor->width)
- {
- srcRect.right -= (dstRect.right - (scissor->x + scissor->width));
- dstRect.right = scissor->x + scissor->width;
- }
- if (dstRect.bottom > scissor->y + scissor->height)
- {
- srcRect.bottom -= (dstRect.bottom - (scissor->y + scissor->height));
- dstRect.bottom = scissor->y + scissor->height;
- }
- }
-
- // Clip the rectangles to the destination size
- if (dstRect.left < 0)
- {
- srcRect.left += -dstRect.left;
- dstRect.left = 0;
- }
- if (dstRect.right > dstSize.width)
- {
- srcRect.right -= (dstRect.right - dstSize.width);
- dstRect.right = dstSize.width;
- }
- if (dstRect.top < 0)
- {
- srcRect.top += -dstRect.top;
- dstRect.top = 0;
- }
- if (dstRect.bottom > dstSize.height)
- {
- srcRect.bottom -= (dstRect.bottom - dstSize.height);
- dstRect.bottom = dstSize.height;
- }
-
- // Clip the rectangles to the source size
- if (srcRect.left < 0)
- {
- dstRect.left += -srcRect.left;
- srcRect.left = 0;
- }
- if (srcRect.right > srcSize.width)
- {
- dstRect.right -= (srcRect.right - srcSize.width);
- srcRect.right = srcSize.width;
- }
- if (srcRect.top < 0)
- {
- dstRect.top += -srcRect.top;
- srcRect.top = 0;
- }
- if (srcRect.bottom > srcSize.height)
- {
- dstRect.bottom -= (srcRect.bottom - srcSize.height);
- srcRect.bottom = srcSize.height;
- }
-
- HRESULT result = mDevice->StretchRect(readSurface, &srcRect, drawSurface, &dstRect, D3DTEXF_NONE);
-
- SafeRelease(readSurface);
- SafeRelease(drawSurface);
-
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal blit failed, StretchRect returned 0x%X.", result);
- }
- }
-
- if (blitDepth || blitStencil)
- {
- gl::FramebufferAttachment *readBuffer = readFramebuffer->getDepthOrStencilbuffer();
- ASSERT(readBuffer);
-
- RenderTarget9 *readDepthStencil = NULL;
- gl::Error error = d3d9::GetAttachmentRenderTarget(readBuffer, &readDepthStencil);
- if (error.isError())
- {
- return error;
- }
- ASSERT(readDepthStencil);
-
- gl::FramebufferAttachment *drawBuffer = drawFramebuffer->getDepthOrStencilbuffer();
- ASSERT(drawBuffer);
-
- RenderTarget9 *drawDepthStencil = NULL;
- error = d3d9::GetAttachmentRenderTarget(drawBuffer, &drawDepthStencil);
- if (error.isError())
- {
- return error;
- }
- ASSERT(drawDepthStencil);
-
- // The getSurface calls do an AddRef so save them until after no errors are possible
- IDirect3DSurface9* readSurface = readDepthStencil->getSurface();
- ASSERT(readDepthStencil);
-
- IDirect3DSurface9* drawSurface = drawDepthStencil->getSurface();
- ASSERT(drawDepthStencil);
-
- HRESULT result = mDevice->StretchRect(readSurface, NULL, drawSurface, NULL, D3DTEXF_NONE);
-
- SafeRelease(readSurface);
- SafeRelease(drawSurface);
-
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal blit failed, StretchRect returned 0x%X.", result);
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer9::readPixels(const gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
- GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels)
-{
- ASSERT(pack.pixelBuffer.get() == NULL);
-
- gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(0);
- ASSERT(colorbuffer);
-
- RenderTarget9 *renderTarget = NULL;
- gl::Error error = d3d9::GetAttachmentRenderTarget(colorbuffer, &renderTarget);
- if (error.isError())
- {
- return error;
- }
- ASSERT(renderTarget);
-
- IDirect3DSurface9 *surface = renderTarget->getSurface();
- ASSERT(surface);
-
- D3DSURFACE_DESC desc;
- surface->GetDesc(&desc);
-
- if (desc.MultiSampleType != D3DMULTISAMPLE_NONE)
- {
- UNIMPLEMENTED(); // FIXME: Requires resolve using StretchRect into non-multisampled render target
- SafeRelease(surface);
- return gl::Error(GL_OUT_OF_MEMORY, "ReadPixels is unimplemented for multisampled framebuffer attachments.");
- }
-
- HRESULT result;
- IDirect3DSurface9 *systemSurface = NULL;
- bool directToPixels = !pack.reverseRowOrder && pack.alignment <= 4 && getShareHandleSupport() &&
- x == 0 && y == 0 && UINT(width) == desc.Width && UINT(height) == desc.Height &&
- desc.Format == D3DFMT_A8R8G8B8 && format == GL_BGRA_EXT && type == GL_UNSIGNED_BYTE;
- if (directToPixels)
- {
- // Use the pixels ptr as a shared handle to write directly into client's memory
- result = mDevice->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format,
- D3DPOOL_SYSTEMMEM, &systemSurface, reinterpret_cast<void**>(&pixels));
- if (FAILED(result))
- {
- // Try again without the shared handle
- directToPixels = false;
- }
- }
-
- if (!directToPixels)
- {
- result = mDevice->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format,
- D3DPOOL_SYSTEMMEM, &systemSurface, NULL);
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- SafeRelease(surface);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate internal texture for ReadPixels.");
- }
- }
-
- result = mDevice->GetRenderTargetData(surface, systemSurface);
- SafeRelease(surface);
-
- if (FAILED(result))
- {
- SafeRelease(systemSurface);
-
- // It turns out that D3D will sometimes produce more error
- // codes than those documented.
- if (d3d9::isDeviceLostError(result))
- {
- notifyDeviceLost();
- }
- else
- {
- UNREACHABLE();
- }
-
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to read internal render target data.");
- }
-
- if (directToPixels)
- {
- SafeRelease(systemSurface);
- return gl::Error(GL_NO_ERROR);
- }
-
- RECT rect;
- rect.left = gl::clamp(x, 0L, static_cast<LONG>(desc.Width));
- rect.top = gl::clamp(y, 0L, static_cast<LONG>(desc.Height));
- rect.right = gl::clamp(x + width, 0L, static_cast<LONG>(desc.Width));
- rect.bottom = gl::clamp(y + height, 0L, static_cast<LONG>(desc.Height));
-
- D3DLOCKED_RECT lock;
- result = systemSurface->LockRect(&lock, &rect, D3DLOCK_READONLY);
-
- if (FAILED(result))
- {
- UNREACHABLE();
- SafeRelease(systemSurface);
-
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock internal render target.");
- }
-
- uint8_t *source;
- int inputPitch;
- if (pack.reverseRowOrder)
- {
- source = reinterpret_cast<uint8_t*>(lock.pBits) + lock.Pitch * (rect.bottom - rect.top - 1);
- inputPitch = -lock.Pitch;
- }
- else
- {
- source = reinterpret_cast<uint8_t*>(lock.pBits);
- inputPitch = lock.Pitch;
- }
-
- const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(desc.Format);
- const gl::InternalFormat &sourceFormatInfo = gl::GetInternalFormatInfo(d3dFormatInfo.internalFormat);
- if (sourceFormatInfo.format == format && sourceFormatInfo.type == type)
- {
- // Direct copy possible
- for (int y = 0; y < rect.bottom - rect.top; y++)
- {
- memcpy(pixels + y * outputPitch, source + y * inputPitch, (rect.right - rect.left) * sourceFormatInfo.pixelBytes);
- }
- }
- else
- {
- const d3d9::D3DFormat &sourceD3DFormatInfo = d3d9::GetD3DFormatInfo(desc.Format);
- ColorCopyFunction fastCopyFunc = sourceD3DFormatInfo.getFastCopyFunction(format, type);
-
- const gl::FormatType &destFormatTypeInfo = gl::GetFormatTypeInfo(format, type);
- const gl::InternalFormat &destFormatInfo = gl::GetInternalFormatInfo(destFormatTypeInfo.internalFormat);
-
- if (fastCopyFunc)
- {
- // Fast copy is possible through some special function
- for (int y = 0; y < rect.bottom - rect.top; y++)
- {
- for (int x = 0; x < rect.right - rect.left; x++)
- {
- uint8_t *dest = pixels + y * outputPitch + x * destFormatInfo.pixelBytes;
- const uint8_t *src = source + y * inputPitch + x * sourceFormatInfo.pixelBytes;
-
- fastCopyFunc(src, dest);
- }
- }
- }
- else
- {
- uint8_t temp[sizeof(gl::ColorF)];
- for (int y = 0; y < rect.bottom - rect.top; y++)
- {
- for (int x = 0; x < rect.right - rect.left; x++)
- {
- uint8_t *dest = pixels + y * outputPitch + x * destFormatInfo.pixelBytes;
- const uint8_t *src = source + y * inputPitch + x * sourceFormatInfo.pixelBytes;
-
- // readFunc and writeFunc will be using the same type of color, CopyTexImage
- // will not allow the copy otherwise.
- sourceD3DFormatInfo.colorReadFunction(src, temp);
- destFormatTypeInfo.colorWriteFunction(temp, dest);
- }
- }
- }
- }
-
- systemSurface->UnlockRect();
- SafeRelease(systemSurface);
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer9::createRenderTarget(SwapChain *swapChain, bool depth, RenderTarget **outRT)
-{
- SwapChain9 *swapChain9 = SwapChain9::makeSwapChain9(swapChain);
- *outRT = new SurfaceRenderTarget9(swapChain9, depth);
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer9::createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTarget **outRT)
-{
- const d3d9::TextureFormat &d3d9FormatInfo = d3d9::GetTextureFormatInfo(format);
-
- const gl::TextureCaps &textureCaps = getRendererTextureCaps().get(format);
- GLuint supportedSamples = textureCaps.getNearestSamples(samples);
-
- IDirect3DSurface9 *renderTarget = NULL;
- if (width > 0 && height > 0)
- {
- bool requiresInitialization = false;
- HRESULT result = D3DERR_INVALIDCALL;
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
- if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0)
- {
- result = mDevice->CreateDepthStencilSurface(width, height, d3d9FormatInfo.renderFormat,
- gl_d3d9::GetMultisampleType(supportedSamples),
- 0, FALSE, &renderTarget, NULL);
- }
- else
- {
- requiresInitialization = (d3d9FormatInfo.dataInitializerFunction != NULL);
- result = mDevice->CreateRenderTarget(width, height, d3d9FormatInfo.renderFormat,
- gl_d3d9::GetMultisampleType(supportedSamples),
- 0, FALSE, &renderTarget, NULL);
- }
-
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target, result: 0x%X.", result);
- }
-
- if (requiresInitialization)
- {
- // This format requires that the data be initialized before the render target can be used
- // Unfortunately this requires a Get call on the d3d device but it is far better than having
- // to mark the render target as lockable and copy data to the gpu.
- IDirect3DSurface9 *prevRenderTarget = NULL;
- mDevice->GetRenderTarget(0, &prevRenderTarget);
- mDevice->SetRenderTarget(0, renderTarget);
- mDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_RGBA(0, 0, 0, 255), 0.0f, 0);
- mDevice->SetRenderTarget(0, prevRenderTarget);
- }
- }
-
- *outRT = new TextureRenderTarget9(renderTarget, format, width, height, 1, supportedSamples);
- return gl::Error(GL_NO_ERROR);
-}
-
-ShaderImpl *Renderer9::createShader(const gl::Data &data, GLenum type)
-{
- return new ShaderD3D(data, type, this);
-}
-
-ProgramImpl *Renderer9::createProgram()
-{
- return new ProgramD3D(this);
-}
-
-void Renderer9::releaseShaderCompiler()
-{
- ShaderD3D::releaseCompiler();
-}
-
-gl::Error Renderer9::loadExecutable(const void *function, size_t length, ShaderType type,
- const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
- bool separatedOutputBuffers, ShaderExecutable **outExecutable)
-{
- // Transform feedback is not supported in ES2 or D3D9
- ASSERT(transformFeedbackVaryings.size() == 0);
-
- switch (type)
- {
- case SHADER_VERTEX:
- {
- IDirect3DVertexShader9 *vshader = NULL;
- gl::Error error = createVertexShader((DWORD*)function, length, &vshader);
- if (error.isError())
- {
- return error;
- }
- *outExecutable = new ShaderExecutable9(function, length, vshader);
- }
- break;
- case SHADER_PIXEL:
- {
- IDirect3DPixelShader9 *pshader = NULL;
- gl::Error error = createPixelShader((DWORD*)function, length, &pshader);
- if (error.isError())
- {
- return error;
- }
- *outExecutable = new ShaderExecutable9(function, length, pshader);
- }
- break;
- default:
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer9::compileToExecutable(gl::InfoLog &infoLog, const std::string &shaderHLSL, ShaderType type,
- const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
- bool separatedOutputBuffers, D3DWorkaroundType workaround,
- ShaderExecutable **outExectuable)
-{
- // Transform feedback is not supported in ES2 or D3D9
- ASSERT(transformFeedbackVaryings.size() == 0);
-
- const char *profileType = NULL;
- switch (type)
- {
- case SHADER_VERTEX:
- profileType = "vs";
- break;
- case SHADER_PIXEL:
- profileType = "ps";
- break;
- default:
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
- }
- unsigned int profileMajorVersion = (getMajorShaderModel() >= 3) ? 3 : 2;
- unsigned int profileMinorVersion = 0;
- std::string profile = FormatString("%s_%u_%u", profileType, profileMajorVersion, profileMinorVersion);
-
- UINT flags = ANGLE_COMPILE_OPTIMIZATION_LEVEL;
-
- if (workaround == ANGLE_D3D_WORKAROUND_SKIP_OPTIMIZATION)
- {
- flags = D3DCOMPILE_SKIP_OPTIMIZATION;
- }
- else if (workaround == ANGLE_D3D_WORKAROUND_MAX_OPTIMIZATION)
- {
- flags = D3DCOMPILE_OPTIMIZATION_LEVEL3;
- }
- else ASSERT(workaround == ANGLE_D3D_WORKAROUND_NONE);
-
- if (gl::perfActive())
- {
-#ifndef NDEBUG
- flags = D3DCOMPILE_SKIP_OPTIMIZATION;
-#endif
-
- flags |= D3DCOMPILE_DEBUG;
- }
-
- // Sometimes D3DCompile will fail with the default compilation flags for complicated shaders when it would otherwise pass with alternative options.
- // Try the default flags first and if compilation fails, try some alternatives.
- std::vector<CompileConfig> configs;
- configs.push_back(CompileConfig(flags, "default" ));
- configs.push_back(CompileConfig(flags | D3DCOMPILE_AVOID_FLOW_CONTROL, "avoid flow control" ));
- configs.push_back(CompileConfig(flags | D3DCOMPILE_PREFER_FLOW_CONTROL, "prefer flow control"));
-
- ID3DBlob *binary = NULL;
- std::string debugInfo;
- gl::Error error = mCompiler.compileToBinary(infoLog, shaderHLSL, profile, configs, NULL, &binary, &debugInfo);
- if (error.isError())
- {
- return error;
- }
-
- // It's possible that binary is NULL if the compiler failed in all configurations. Set the executable to NULL
- // and return GL_NO_ERROR to signify that there was a link error but the internal state is still OK.
- if (!binary)
- {
- *outExectuable = NULL;
- return gl::Error(GL_NO_ERROR);
- }
-
- error = loadExecutable(binary->GetBufferPointer(), binary->GetBufferSize(), type,
- transformFeedbackVaryings, separatedOutputBuffers, outExectuable);
-
- SafeRelease(binary);
- if (error.isError())
- {
- return error;
- }
-
- if (!debugInfo.empty())
- {
- (*outExectuable)->appendDebugInfo(debugInfo);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-UniformStorage *Renderer9::createUniformStorage(size_t storageSize)
-{
- return new UniformStorage(storageSize);
-}
-
-gl::Error Renderer9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
-{
- return mBlit->boxFilter(source, dest);
-}
-
-D3DPOOL Renderer9::getTexturePool(DWORD usage) const
-{
- if (mD3d9Ex != NULL)
- {
- return D3DPOOL_DEFAULT;
- }
- else
- {
- if (!(usage & (D3DUSAGE_DEPTHSTENCIL | D3DUSAGE_RENDERTARGET)))
- {
- return D3DPOOL_MANAGED;
- }
- }
-
- return D3DPOOL_DEFAULT;
-}
-
-gl::Error Renderer9::copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *source, bool fromManaged)
-{
- ASSERT(source && dest);
-
- HRESULT result = D3DERR_OUTOFVIDEOMEMORY;
-
- if (fromManaged)
- {
- D3DSURFACE_DESC desc;
- source->GetDesc(&desc);
-
- IDirect3DSurface9 *surf = 0;
- result = mDevice->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surf, NULL);
-
- if (SUCCEEDED(result))
- {
- Image9::copyLockableSurfaces(surf, source);
- result = mDevice->UpdateSurface(surf, NULL, dest, NULL);
- SafeRelease(surf);
- }
- }
- else
- {
- endScene();
- result = mDevice->StretchRect(source, NULL, dest, NULL, D3DTEXF_NONE);
- }
-
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to blit internal texture, result: 0x%X.", result);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-Image *Renderer9::createImage()
-{
- return new Image9();
-}
-
-gl::Error Renderer9::generateMipmap(Image *dest, Image *src)
-{
- Image9 *src9 = Image9::makeImage9(src);
- Image9 *dst9 = Image9::makeImage9(dest);
- return Image9::generateMipmap(dst9, src9);
-}
-
-TextureStorage *Renderer9::createTextureStorage2D(SwapChain *swapChain)
-{
- SwapChain9 *swapChain9 = SwapChain9::makeSwapChain9(swapChain);
- return new TextureStorage9_2D(this, swapChain9);
-}
-
-TextureStorage *Renderer9::createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels)
-{
- return new TextureStorage9_2D(this, internalformat, renderTarget, width, height, levels);
-}
-
-TextureStorage *Renderer9::createTextureStorageCube(GLenum internalformat, bool renderTarget, int size, int levels)
-{
- return new TextureStorage9_Cube(this, internalformat, renderTarget, size, levels);
-}
-
-TextureStorage *Renderer9::createTextureStorage3D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels)
-{
- // 3D textures are not supported by the D3D9 backend.
- UNREACHABLE();
-
- return NULL;
-}
-
-TextureStorage *Renderer9::createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels)
-{
- // 2D array textures are not supported by the D3D9 backend.
- UNREACHABLE();
-
- return NULL;
-}
-
-TextureImpl *Renderer9::createTexture(GLenum target)
-{
- switch(target)
- {
- case GL_TEXTURE_2D: return new TextureD3D_2D(this);
- case GL_TEXTURE_CUBE_MAP: return new TextureD3D_Cube(this);
- default: UNREACHABLE();
- }
-
- return NULL;
-}
-
-RenderbufferImpl *Renderer9::createRenderbuffer()
-{
- RenderbufferD3D *renderbuffer = new RenderbufferD3D(this);
- return renderbuffer;
-}
-
-RenderbufferImpl *Renderer9::createRenderbuffer(SwapChain *swapChain, bool depth)
-{
- RenderbufferD3D *renderbuffer = new RenderbufferD3D(this);
- renderbuffer->setStorage(swapChain, depth);
- return renderbuffer;
-}
-
-bool Renderer9::getLUID(LUID *adapterLuid) const
-{
- adapterLuid->HighPart = 0;
- adapterLuid->LowPart = 0;
-
- if (mD3d9Ex)
- {
- mD3d9Ex->GetAdapterLUID(mAdapter, adapterLuid);
- return true;
- }
-
- return false;
-}
-
-VertexConversionType Renderer9::getVertexConversionType(const gl::VertexFormat &vertexFormat) const
-{
- return d3d9::GetVertexFormatInfo(getCapsDeclTypes(), vertexFormat).conversionType;
-}
-
-GLenum Renderer9::getVertexComponentType(const gl::VertexFormat &vertexFormat) const
-{
- return d3d9::GetVertexFormatInfo(getCapsDeclTypes(), vertexFormat).componentType;
-}
-
-void Renderer9::generateCaps(gl::Caps *outCaps, gl::TextureCapsMap *outTextureCaps, gl::Extensions *outExtensions) const
-{
- d3d9_gl::GenerateCaps(mD3d9, mDevice, mDeviceType, mAdapter, outCaps, outTextureCaps, outExtensions);
-}
-
-Workarounds Renderer9::generateWorkarounds() const
-{
- return d3d9::GenerateWorkarounds();
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Renderer9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Renderer9.h
deleted file mode 100644
index 10d2fb11e8..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/Renderer9.h
+++ /dev/null
@@ -1,352 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// Renderer9.h: Defines a back-end specific class for the D3D9 renderer.
-
-#ifndef LIBGLESV2_RENDERER_RENDERER9_H_
-#define LIBGLESV2_RENDERER_RENDERER9_H_
-
-#include "common/angleutils.h"
-#include "common/mathutil.h"
-#include "libGLESv2/renderer/d3d/d3d9/ShaderCache.h"
-#include "libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.h"
-#include "libGLESv2/renderer/d3d/HLSLCompiler.h"
-#include "libGLESv2/renderer/d3d/RendererD3D.h"
-#include "libGLESv2/renderer/RenderTarget.h"
-
-namespace gl
-{
-class FramebufferAttachment;
-}
-
-namespace egl
-{
-class AttributeMap;
-}
-
-namespace rx
-{
-class VertexDataManager;
-class IndexDataManager;
-class StreamingIndexBufferInterface;
-class StaticIndexBufferInterface;
-struct TranslatedAttribute;
-class Blit9;
-
-class Renderer9 : public RendererD3D
-{
- public:
- Renderer9(egl::Display *display, EGLNativeDisplayType hDc, const egl::AttributeMap &attributes);
- virtual ~Renderer9();
-
- static Renderer9 *makeRenderer9(Renderer *renderer);
-
- virtual EGLint initialize();
- virtual bool resetDevice();
-
- virtual int generateConfigs(ConfigDesc **configDescList);
- virtual void deleteConfigs(ConfigDesc *configDescList);
-
- void startScene();
- void endScene();
-
- virtual gl::Error sync(bool block);
-
- virtual SwapChain *createSwapChain(NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat);
-
- gl::Error allocateEventQuery(IDirect3DQuery9 **outQuery);
- void freeEventQuery(IDirect3DQuery9* query);
-
- // resource creation
- gl::Error createVertexShader(const DWORD *function, size_t length, IDirect3DVertexShader9 **outShader);
- gl::Error createPixelShader(const DWORD *function, size_t length, IDirect3DPixelShader9 **outShader);
- HRESULT createVertexBuffer(UINT Length, DWORD Usage, IDirect3DVertexBuffer9 **ppVertexBuffer);
- HRESULT createIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, IDirect3DIndexBuffer9 **ppIndexBuffer);
- virtual gl::Error generateSwizzle(gl::Texture *texture);
- virtual gl::Error setSamplerState(gl::SamplerType type, int index, gl::Texture *texture, const gl::SamplerState &sampler);
- virtual gl::Error setTexture(gl::SamplerType type, int index, gl::Texture *texture);
-
- virtual gl::Error setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]);
-
- virtual gl::Error setRasterizerState(const gl::RasterizerState &rasterState);
- gl::Error setBlendState(const gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor,
- unsigned int sampleMask) override;
- virtual gl::Error setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
- int stencilBackRef, bool frontFaceCCW);
-
- virtual void setScissorRectangle(const gl::Rectangle &scissor, bool enabled);
- virtual void setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace,
- bool ignoreViewport);
-
- gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer) override;
- virtual gl::Error applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
- bool rasterizerDiscard, bool transformFeedbackActive);
- virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray);
- virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount);
- virtual gl::Error applyVertexBuffer(const gl::State &state, GLint first, GLsizei count, GLsizei instances);
- virtual gl::Error applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo);
-
- virtual void applyTransformFeedbackBuffers(const gl::State& state);
-
- virtual gl::Error drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive);
- virtual gl::Error drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
- gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo, GLsizei instances);
-
- gl::Error clear(const gl::ClearParameters &clearParams, const gl::Framebuffer *frameBuffer) override;
-
- virtual void markAllStateDirty();
-
- // lost device
- void notifyDeviceLost() override;
- bool isDeviceLost() override;
- bool testDeviceLost(bool notify) override;
- bool testDeviceResettable() override;
-
- DWORD getAdapterVendor() const override;
- std::string getRendererDescription() const override;
- GUID getAdapterIdentifier() const override;
-
- IDirect3DDevice9 *getDevice() { return mDevice; }
-
- virtual unsigned int getReservedVertexUniformVectors() const;
- virtual unsigned int getReservedFragmentUniformVectors() const;
- virtual unsigned int getReservedVertexUniformBuffers() const;
- virtual unsigned int getReservedFragmentUniformBuffers() const;
- virtual bool getShareHandleSupport() const;
- virtual bool getPostSubBufferSupport() const;
-
- virtual int getMajorShaderModel() const;
- DWORD getCapsDeclTypes() const;
- virtual int getMinSwapInterval() const;
- virtual int getMaxSwapInterval() const;
-
- // Pixel operations
- virtual gl::Error copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level);
- virtual gl::Error copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level);
- virtual gl::Error copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level);
- virtual gl::Error copyImage2DArray(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
- GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level);
-
- gl::Error blitRect(const gl::Framebuffer *readTarget, const gl::Rectangle &readRect,
- const gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
- const gl::Rectangle *scissor, bool blitRenderTarget,
- bool blitDepth, bool blitStencil, GLenum filter) override;
-
- virtual gl::Error readPixels(const gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
- GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels);
-
- // RenderTarget creation
- virtual gl::Error createRenderTarget(SwapChain *swapChain, bool depth, RenderTarget **outRT);
- virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTarget **outRT);
-
- // Shader creation
- virtual ShaderImpl *createShader(const gl::Data &data, GLenum type);
- virtual ProgramImpl *createProgram();
-
- // Shader operations
- void releaseShaderCompiler() override;
- virtual gl::Error loadExecutable(const void *function, size_t length, ShaderType type,
- const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
- bool separatedOutputBuffers, ShaderExecutable **outExecutable);
- virtual gl::Error compileToExecutable(gl::InfoLog &infoLog, const std::string &shaderHLSL, ShaderType type,
- const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
- bool separatedOutputBuffers, D3DWorkaroundType workaround,
- ShaderExecutable **outExectuable);
- virtual UniformStorage *createUniformStorage(size_t storageSize);
-
- // Image operations
- virtual Image *createImage();
- gl::Error generateMipmap(Image *dest, Image *source) override;
- virtual TextureStorage *createTextureStorage2D(SwapChain *swapChain);
- virtual TextureStorage *createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels);
- virtual TextureStorage *createTextureStorageCube(GLenum internalformat, bool renderTarget, int size, int levels);
- virtual TextureStorage *createTextureStorage3D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels);
- virtual TextureStorage *createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels);
-
- // Texture creation
- virtual TextureImpl *createTexture(GLenum target);
-
- // Renderbuffer creation
- virtual RenderbufferImpl *createRenderbuffer();
- virtual RenderbufferImpl *createRenderbuffer(SwapChain *swapChain, bool depth);
-
- // Buffer creation
- virtual BufferImpl *createBuffer();
- virtual VertexBuffer *createVertexBuffer();
- virtual IndexBuffer *createIndexBuffer();
-
- // Vertex Array creation
- virtual VertexArrayImpl *createVertexArray();
-
- // Query and Fence creation
- virtual QueryImpl *createQuery(GLenum type);
- virtual FenceNVImpl *createFenceNV();
- virtual FenceSyncImpl *createFenceSync();
-
- // Transform Feedback creation
- virtual TransformFeedbackImpl* createTransformFeedback();
-
- // Buffer-to-texture and Texture-to-buffer copies
- virtual bool supportsFastCopyBufferToTexture(GLenum internalFormat) const;
- virtual gl::Error fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
- GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea);
-
- // D3D9-renderer specific methods
- gl::Error boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest);
-
- D3DPOOL getTexturePool(DWORD usage) const;
-
- virtual bool getLUID(LUID *adapterLuid) const;
- virtual VertexConversionType getVertexConversionType(const gl::VertexFormat &vertexFormat) const;
- virtual GLenum getVertexComponentType(const gl::VertexFormat &vertexFormat) const;
-
- gl::Error copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *source, bool fromManaged);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Renderer9);
-
- void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap *outTextureCaps, gl::Extensions *outExtensions) const override;
- Workarounds generateWorkarounds() const override;
-
- void release();
-
- void applyUniformnfv(gl::LinkedUniform *targetUniform, const GLfloat *v);
- void applyUniformniv(gl::LinkedUniform *targetUniform, const GLint *v);
- void applyUniformnbv(gl::LinkedUniform *targetUniform, const GLint *v);
-
- gl::Error drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
- gl::Error drawIndexedPoints(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
-
- gl::Error getCountingIB(size_t count, StaticIndexBufferInterface **outIB);
-
- gl::Error getNullColorbuffer(gl::FramebufferAttachment *depthbuffer, gl::FramebufferAttachment **outColorBuffer);
-
- D3DPOOL getBufferPool(DWORD usage) const;
-
- HMODULE mD3d9Module;
- HDC mDc;
-
- void initializeDevice();
- D3DPRESENT_PARAMETERS getDefaultPresentParameters();
- void releaseDeviceResources();
-
- HRESULT getDeviceStatusCode();
- bool isRemovedDeviceResettable() const;
- bool resetRemovedDevice();
-
- UINT mAdapter;
- D3DDEVTYPE mDeviceType;
- IDirect3D9 *mD3d9; // Always valid after successful initialization.
- IDirect3D9Ex *mD3d9Ex; // Might be null if D3D9Ex is not supported.
- IDirect3DDevice9 *mDevice;
- IDirect3DDevice9Ex *mDeviceEx; // Might be null if D3D9Ex is not supported.
-
- HLSLCompiler mCompiler;
-
- Blit9 *mBlit;
-
- HWND mDeviceWindow;
-
- bool mDeviceLost;
- D3DCAPS9 mDeviceCaps;
- D3DADAPTER_IDENTIFIER9 mAdapterIdentifier;
-
- D3DPRIMITIVETYPE mPrimitiveType;
- int mPrimitiveCount;
- GLsizei mRepeatDraw;
-
- bool mSceneStarted;
- int mMinSwapInterval;
- int mMaxSwapInterval;
-
- bool mVertexTextureSupport;
-
- // current render target states
- unsigned int mAppliedRenderTargetSerial;
- unsigned int mAppliedDepthbufferSerial;
- unsigned int mAppliedStencilbufferSerial;
- bool mDepthStencilInitialized;
- bool mRenderTargetDescInitialized;
- RenderTarget::Desc mRenderTargetDesc;
- unsigned int mCurStencilSize;
- unsigned int mCurDepthSize;
-
- IDirect3DStateBlock9 *mMaskedClearSavedState;
-
- // previously set render states
- bool mForceSetDepthStencilState;
- gl::DepthStencilState mCurDepthStencilState;
- int mCurStencilRef;
- int mCurStencilBackRef;
- bool mCurFrontFaceCCW;
-
- bool mForceSetRasterState;
- gl::RasterizerState mCurRasterState;
-
- bool mForceSetScissor;
- gl::Rectangle mCurScissor;
- bool mScissorEnabled;
-
- bool mForceSetViewport;
- gl::Rectangle mCurViewport;
- float mCurNear;
- float mCurFar;
- float mCurDepthFront;
-
- bool mForceSetBlendState;
- gl::BlendState mCurBlendState;
- gl::ColorF mCurBlendColor;
- GLuint mCurSampleMask;
-
- // Currently applied sampler states
- std::vector<bool> mForceSetVertexSamplerStates;
- std::vector<gl::SamplerState> mCurVertexSamplerStates;
-
- std::vector<bool> mForceSetPixelSamplerStates;
- std::vector<gl::SamplerState> mCurPixelSamplerStates;
-
- // Currently applied textures
- std::vector<unsigned int> mCurVertexTextureSerials;
- std::vector<unsigned int> mCurPixelTextureSerials;
-
- unsigned int mAppliedIBSerial;
- IDirect3DVertexShader9 *mAppliedVertexShader;
- IDirect3DPixelShader9 *mAppliedPixelShader;
- unsigned int mAppliedProgramSerial;
-
- dx_VertexConstants mVertexConstants;
- dx_PixelConstants mPixelConstants;
- bool mDxUniformsDirty;
-
- // A pool of event queries that are currently unused.
- std::vector<IDirect3DQuery9*> mEventQueryPool;
- VertexShaderCache mVertexShaderCache;
- PixelShaderCache mPixelShaderCache;
-
- VertexDataManager *mVertexDataManager;
- VertexDeclarationCache mVertexDeclarationCache;
-
- IndexDataManager *mIndexDataManager;
- StreamingIndexBufferInterface *mLineLoopIB;
- StaticIndexBufferInterface *mCountingIB;
-
- enum { NUM_NULL_COLORBUFFER_CACHE_ENTRIES = 12 };
- struct NullColorbufferCacheEntry
- {
- UINT lruCount;
- int width;
- int height;
- gl::FramebufferAttachment *buffer;
- } mNullColorbufferCache[NUM_NULL_COLORBUFFER_CACHE_ENTRIES];
- UINT mMaxNullColorbufferLRU;
-
-};
-
-}
-#endif // LIBGLESV2_RENDERER_RENDERER9_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderCache.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderCache.h
deleted file mode 100644
index 6d7d2d648f..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderCache.h
+++ /dev/null
@@ -1,110 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// ShaderCache: Defines rx::ShaderCache, a cache of Direct3D shader objects
-// keyed by their byte code.
-
-#ifndef LIBGLESV2_RENDERER_SHADER_CACHE_H_
-#define LIBGLESV2_RENDERER_SHADER_CACHE_H_
-
-#include "libGLESv2/Error.h"
-
-#include "common/debug.h"
-
-#include <cstddef>
-#include <unordered_map>
-#include <string>
-
-namespace rx
-{
-template <typename ShaderObject>
-class ShaderCache
-{
- public:
- ShaderCache() : mDevice(NULL)
- {
- }
-
- ~ShaderCache()
- {
- // Call clear while the device is still valid.
- ASSERT(mMap.empty());
- }
-
- void initialize(IDirect3DDevice9* device)
- {
- mDevice = device;
- }
-
- gl::Error create(const DWORD *function, size_t length, ShaderObject **outShaderObject)
- {
- std::string key(reinterpret_cast<const char*>(function), length);
- typename Map::iterator it = mMap.find(key);
- if (it != mMap.end())
- {
- it->second->AddRef();
- *outShaderObject = it->second;
- return gl::Error(GL_NO_ERROR);
- }
-
- ShaderObject *shader;
- HRESULT result = createShader(function, &shader);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create shader, result: 0x%X.", result);
- }
-
- // Random eviction policy.
- if (mMap.size() >= kMaxMapSize)
- {
- SafeRelease(mMap.begin()->second);
- mMap.erase(mMap.begin());
- }
-
- shader->AddRef();
- mMap[key] = shader;
-
- *outShaderObject = shader;
- return gl::Error(GL_NO_ERROR);
- }
-
- void clear()
- {
- for (typename Map::iterator it = mMap.begin(); it != mMap.end(); ++it)
- {
- SafeRelease(it->second);
- }
-
- mMap.clear();
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ShaderCache);
-
- const static size_t kMaxMapSize = 100;
-
- HRESULT createShader(const DWORD *function, IDirect3DVertexShader9 **shader)
- {
- return mDevice->CreateVertexShader(function, shader);
- }
-
- HRESULT createShader(const DWORD *function, IDirect3DPixelShader9 **shader)
- {
- return mDevice->CreatePixelShader(function, shader);
- }
-
- typedef std::unordered_map<std::string, ShaderObject*> Map;
- Map mMap;
-
- IDirect3DDevice9 *mDevice;
-};
-
-typedef ShaderCache<IDirect3DVertexShader9> VertexShaderCache;
-typedef ShaderCache<IDirect3DPixelShader9> PixelShaderCache;
-
-}
-
-#endif // LIBGLESV2_RENDERER_SHADER_CACHE_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderExecutable9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderExecutable9.cpp
deleted file mode 100644
index bc7120461b..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderExecutable9.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// Copyright (c) 2012-2013 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.
-//
-
-// ShaderExecutable9.cpp: Implements a D3D9-specific class to contain shader
-// executable implementation details.
-
-#include "libGLESv2/renderer/d3d/d3d9/ShaderExecutable9.h"
-
-#include "common/debug.h"
-
-namespace rx
-{
-
-ShaderExecutable9::ShaderExecutable9(const void *function, size_t length, IDirect3DPixelShader9 *executable)
- : ShaderExecutable(function, length)
-{
- mPixelExecutable = executable;
- mVertexExecutable = NULL;
-}
-
-ShaderExecutable9::ShaderExecutable9(const void *function, size_t length, IDirect3DVertexShader9 *executable)
- : ShaderExecutable(function, length)
-{
- mVertexExecutable = executable;
- mPixelExecutable = NULL;
-}
-
-ShaderExecutable9::~ShaderExecutable9()
-{
- SafeRelease(mVertexExecutable);
- SafeRelease(mPixelExecutable);
-}
-
-ShaderExecutable9 *ShaderExecutable9::makeShaderExecutable9(ShaderExecutable *executable)
-{
- ASSERT(HAS_DYNAMIC_TYPE(ShaderExecutable9*, executable));
- return static_cast<ShaderExecutable9*>(executable);
-}
-
-IDirect3DVertexShader9 *ShaderExecutable9::getVertexShader() const
-{
- return mVertexExecutable;
-}
-
-IDirect3DPixelShader9 *ShaderExecutable9::getPixelShader() const
-{
- return mPixelExecutable;
-}
-
-} \ No newline at end of file
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderExecutable9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderExecutable9.h
deleted file mode 100644
index fa1e6c2844..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderExecutable9.h
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// Copyright (c) 2012-2013 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.
-//
-
-// ShaderExecutable9.h: Defines a D3D9-specific class to contain shader
-// executable implementation details.
-
-#ifndef LIBGLESV2_RENDERER_SHADEREXECUTABLE9_H_
-#define LIBGLESV2_RENDERER_SHADEREXECUTABLE9_H_
-
-#include "libGLESv2/renderer/ShaderExecutable.h"
-
-namespace rx
-{
-
-class ShaderExecutable9 : public ShaderExecutable
-{
- public:
- ShaderExecutable9(const void *function, size_t length, IDirect3DPixelShader9 *executable);
- ShaderExecutable9(const void *function, size_t length, IDirect3DVertexShader9 *executable);
- virtual ~ShaderExecutable9();
-
- static ShaderExecutable9 *makeShaderExecutable9(ShaderExecutable *executable);
-
- IDirect3DPixelShader9 *getPixelShader() const;
- IDirect3DVertexShader9 *getVertexShader() const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ShaderExecutable9);
-
- IDirect3DPixelShader9 *mPixelExecutable;
- IDirect3DVertexShader9 *mVertexExecutable;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_SHADEREXECUTABLE9_H_ \ No newline at end of file
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.cpp
deleted file mode 100644
index 95eb1a4371..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.cpp
+++ /dev/null
@@ -1,422 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// SwapChain9.cpp: Implements a back-end specific class for the D3D9 swap chain.
-
-#include "libGLESv2/renderer/d3d/d3d9/SwapChain9.h"
-#include "libGLESv2/renderer/d3d/d3d9/renderer9_utils.h"
-#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h"
-#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
-
-#include "common/features.h"
-
-namespace rx
-{
-
-SwapChain9::SwapChain9(Renderer9 *renderer, NativeWindow nativeWindow, HANDLE shareHandle,
- GLenum backBufferFormat, GLenum depthBufferFormat)
- : mRenderer(renderer),
- SwapChain(nativeWindow, shareHandle, backBufferFormat, depthBufferFormat)
-{
- mSwapChain = NULL;
- mBackBuffer = NULL;
- mDepthStencil = NULL;
- mRenderTarget = NULL;
- mOffscreenTexture = NULL;
- mWidth = -1;
- mHeight = -1;
- mSwapInterval = -1;
-}
-
-SwapChain9::~SwapChain9()
-{
- release();
-}
-
-void SwapChain9::release()
-{
- SafeRelease(mSwapChain);
- SafeRelease(mBackBuffer);
- SafeRelease(mDepthStencil);
- SafeRelease(mRenderTarget);
- SafeRelease(mOffscreenTexture);
-
- if (mNativeWindow.getNativeWindow())
- {
- mShareHandle = NULL;
- }
-}
-
-static DWORD convertInterval(EGLint interval)
-{
-#if ANGLE_VSYNC == ANGLE_DISABLED
- return D3DPRESENT_INTERVAL_IMMEDIATE;
-#else
- switch(interval)
- {
- case 0: return D3DPRESENT_INTERVAL_IMMEDIATE;
- case 1: return D3DPRESENT_INTERVAL_ONE;
- case 2: return D3DPRESENT_INTERVAL_TWO;
- case 3: return D3DPRESENT_INTERVAL_THREE;
- case 4: return D3DPRESENT_INTERVAL_FOUR;
- default: UNREACHABLE();
- }
-
- return D3DPRESENT_INTERVAL_DEFAULT;
-#endif
-}
-
-EGLint SwapChain9::resize(int backbufferWidth, int backbufferHeight)
-{
- // D3D9 does not support resizing swap chains without recreating them
- return reset(backbufferWidth, backbufferHeight, mSwapInterval);
-}
-
-EGLint SwapChain9::reset(int backbufferWidth, int backbufferHeight, EGLint swapInterval)
-{
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- if (device == NULL)
- {
- return EGL_BAD_ACCESS;
- }
-
- // Evict all non-render target textures to system memory and release all resources
- // before reallocating them to free up as much video memory as possible.
- device->EvictManagedResources();
-
- HRESULT result;
-
- // Release specific resources to free up memory for the new render target, while the
- // old render target still exists for the purpose of preserving its contents.
- SafeRelease(mSwapChain);
- SafeRelease(mBackBuffer);
- SafeRelease(mOffscreenTexture);
- SafeRelease(mDepthStencil);
-
- HANDLE *pShareHandle = NULL;
- if (!mNativeWindow.getNativeWindow() && mRenderer->getShareHandleSupport())
- {
- pShareHandle = &mShareHandle;
- }
-
- const d3d9::TextureFormat &backBufferd3dFormatInfo = d3d9::GetTextureFormatInfo(mBackBufferFormat);
- result = device->CreateTexture(backbufferWidth, backbufferHeight, 1, D3DUSAGE_RENDERTARGET,
- backBufferd3dFormatInfo.texFormat, D3DPOOL_DEFAULT, &mOffscreenTexture,
- pShareHandle);
- if (FAILED(result))
- {
- ERR("Could not create offscreen texture: %08lX", result);
- release();
-
- if (d3d9::isDeviceLostError(result))
- {
- return EGL_CONTEXT_LOST;
- }
- else
- {
- return EGL_BAD_ALLOC;
- }
- }
-
- IDirect3DSurface9 *oldRenderTarget = mRenderTarget;
-
- result = mOffscreenTexture->GetSurfaceLevel(0, &mRenderTarget);
- ASSERT(SUCCEEDED(result));
-
- if (oldRenderTarget)
- {
- RECT rect =
- {
- 0, 0,
- mWidth, mHeight
- };
-
- if (rect.right > static_cast<LONG>(backbufferWidth))
- {
- rect.right = backbufferWidth;
- }
-
- if (rect.bottom > static_cast<LONG>(backbufferHeight))
- {
- rect.bottom = backbufferHeight;
- }
-
- mRenderer->endScene();
-
- result = device->StretchRect(oldRenderTarget, &rect, mRenderTarget, &rect, D3DTEXF_NONE);
- ASSERT(SUCCEEDED(result));
-
- SafeRelease(oldRenderTarget);
- }
-
- const d3d9::TextureFormat &depthBufferd3dFormatInfo = d3d9::GetTextureFormatInfo(mDepthBufferFormat);
-
- EGLNativeWindowType window = mNativeWindow.getNativeWindow();
- if (window)
- {
- D3DPRESENT_PARAMETERS presentParameters = {0};
- presentParameters.AutoDepthStencilFormat = depthBufferd3dFormatInfo.renderFormat;
- presentParameters.BackBufferCount = 1;
- presentParameters.BackBufferFormat = backBufferd3dFormatInfo.renderFormat;
- presentParameters.EnableAutoDepthStencil = FALSE;
- presentParameters.Flags = 0;
- presentParameters.hDeviceWindow = window;
- presentParameters.MultiSampleQuality = 0; // FIXME: Unimplemented
- presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE; // FIXME: Unimplemented
- presentParameters.PresentationInterval = convertInterval(swapInterval);
- presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
- presentParameters.Windowed = TRUE;
- presentParameters.BackBufferWidth = backbufferWidth;
- presentParameters.BackBufferHeight = backbufferHeight;
-
- // http://crbug.com/140239
- // http://crbug.com/143434
- //
- // Some AMD/Intel switchable systems / drivers appear to round swap chain surfaces to a multiple of 64 pixels in width
- // when using the integrated Intel. This rounds the width up rather than down.
- //
- // Some non-switchable AMD GPUs / drivers do not respect the source rectangle to Present. Therefore, when the vendor ID
- // is not Intel, the back buffer width must be exactly the same width as the window or horizontal scaling will occur.
- if (mRenderer->getAdapterVendor() == VENDOR_ID_INTEL)
- {
- presentParameters.BackBufferWidth = (presentParameters.BackBufferWidth + 63) / 64 * 64;
- }
-
- result = device->CreateAdditionalSwapChain(&presentParameters, &mSwapChain);
-
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_INVALIDCALL || result == D3DERR_DEVICELOST);
-
- ERR("Could not create additional swap chains or offscreen surfaces: %08lX", result);
- release();
-
- if (d3d9::isDeviceLostError(result))
- {
- return EGL_CONTEXT_LOST;
- }
- else
- {
- return EGL_BAD_ALLOC;
- }
- }
-
- result = mSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &mBackBuffer);
- ASSERT(SUCCEEDED(result));
- InvalidateRect(window, NULL, FALSE);
- }
-
- if (mDepthBufferFormat != GL_NONE)
- {
- result = device->CreateDepthStencilSurface(backbufferWidth, backbufferHeight,
- depthBufferd3dFormatInfo.renderFormat,
- D3DMULTISAMPLE_NONE, 0, FALSE, &mDepthStencil, NULL);
-
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_INVALIDCALL);
-
- ERR("Could not create depthstencil surface for new swap chain: 0x%08X", result);
- release();
-
- if (d3d9::isDeviceLostError(result))
- {
- return EGL_CONTEXT_LOST;
- }
- else
- {
- return EGL_BAD_ALLOC;
- }
- }
- }
-
- mWidth = backbufferWidth;
- mHeight = backbufferHeight;
- mSwapInterval = swapInterval;
-
- return EGL_SUCCESS;
-}
-
-// parameters should be validated/clamped by caller
-EGLint SwapChain9::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
-{
- if (!mSwapChain)
- {
- return EGL_SUCCESS;
- }
-
- IDirect3DDevice9 *device = mRenderer->getDevice();
-
- // Disable all pipeline operations
- device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
- device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
- device->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
- device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- device->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
- device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
- device->SetRenderState(D3DRS_SRGBWRITEENABLE, FALSE);
- device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
- device->SetPixelShader(NULL);
- device->SetVertexShader(NULL);
-
- device->SetRenderTarget(0, mBackBuffer);
- device->SetDepthStencilSurface(NULL);
-
- device->SetTexture(0, mOffscreenTexture);
- device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
- device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
- device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
- device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
- device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
- device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
- device->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
-
- for (UINT streamIndex = 0; streamIndex < gl::MAX_VERTEX_ATTRIBS; streamIndex++)
- {
- device->SetStreamSourceFreq(streamIndex, 1);
- }
-
- D3DVIEWPORT9 viewport = {0, 0, mWidth, mHeight, 0.0f, 1.0f};
- device->SetViewport(&viewport);
-
- float x1 = x - 0.5f;
- float y1 = (mHeight - y - height) - 0.5f;
- float x2 = (x + width) - 0.5f;
- float y2 = (mHeight - y) - 0.5f;
-
- float u1 = x / float(mWidth);
- float v1 = y / float(mHeight);
- float u2 = (x + width) / float(mWidth);
- float v2 = (y + height) / float(mHeight);
-
- float quad[4][6] = {{x1, y1, 0.0f, 1.0f, u1, v2},
- {x2, y1, 0.0f, 1.0f, u2, v2},
- {x2, y2, 0.0f, 1.0f, u2, v1},
- {x1, y2, 0.0f, 1.0f, u1, v1}}; // x, y, z, rhw, u, v
-
- mRenderer->startScene();
- device->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, quad, 6 * sizeof(float));
- mRenderer->endScene();
-
- device->SetTexture(0, NULL);
-
- RECT rect =
- {
- x, mHeight - y - height,
- x + width, mHeight - y
- };
-
- HRESULT result = mSwapChain->Present(&rect, &rect, NULL, NULL, 0);
-
- mRenderer->markAllStateDirty();
-
- if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_DRIVERINTERNALERROR)
- {
- return EGL_BAD_ALLOC;
- }
-
- // On Windows 8 systems, IDirect3DSwapChain9::Present sometimes returns 0x88760873 when the windows is
- // in the process of entering/exiting fullscreen. This code doesn't seem to have any documentation. The
- // device appears to be ok after emitting this error so simply return a failure to swap.
- if (result == 0x88760873)
- {
- return EGL_BAD_MATCH;
- }
-
- // http://crbug.com/313210
- // If our swap failed, trigger a device lost event. Resetting will work around an AMD-specific
- // device removed bug with lost contexts when reinstalling drivers.
- if (FAILED(result))
- {
- mRenderer->notifyDeviceLost();
- return EGL_CONTEXT_LOST;
- }
-
- return EGL_SUCCESS;
-}
-
-// Increments refcount on surface.
-// caller must Release() the returned surface
-// TODO: remove the AddRef to match SwapChain11
-IDirect3DSurface9 *SwapChain9::getRenderTarget()
-{
- if (mRenderTarget)
- {
- mRenderTarget->AddRef();
- }
-
- return mRenderTarget;
-}
-
-// Increments refcount on surface.
-// caller must Release() the returned surface
-// TODO: remove the AddRef to match SwapChain11
-IDirect3DSurface9 *SwapChain9::getDepthStencil()
-{
- if (mDepthStencil)
- {
- mDepthStencil->AddRef();
- }
-
- return mDepthStencil;
-}
-
-// Increments refcount on texture.
-// caller must Release() the returned texture
-// TODO: remove the AddRef to match SwapChain11
-IDirect3DTexture9 *SwapChain9::getOffscreenTexture()
-{
- if (mOffscreenTexture)
- {
- mOffscreenTexture->AddRef();
- }
-
- return mOffscreenTexture;
-}
-
-SwapChain9 *SwapChain9::makeSwapChain9(SwapChain *swapChain)
-{
- ASSERT(HAS_DYNAMIC_TYPE(SwapChain9*, swapChain));
- return static_cast<SwapChain9*>(swapChain);
-}
-
-void SwapChain9::recreate()
-{
- if (!mSwapChain)
- {
- return;
- }
-
- IDirect3DDevice9 *device = mRenderer->getDevice();
- if (device == NULL)
- {
- return;
- }
-
- D3DPRESENT_PARAMETERS presentParameters;
- HRESULT result = mSwapChain->GetPresentParameters(&presentParameters);
- ASSERT(SUCCEEDED(result));
-
- IDirect3DSwapChain9* newSwapChain = NULL;
- result = device->CreateAdditionalSwapChain(&presentParameters, &newSwapChain);
- if (FAILED(result))
- {
- return;
- }
-
- SafeRelease(mSwapChain);
- mSwapChain = newSwapChain;
-
- SafeRelease(mBackBuffer);
- result = mSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &mBackBuffer);
- ASSERT(SUCCEEDED(result));
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.h
deleted file mode 100644
index cb33bfbc0c..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.h
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// SwapChain9.h: Defines a back-end specific class for the D3D9 swap chain.
-
-#ifndef LIBGLESV2_RENDERER_SWAPCHAIN9_H_
-#define LIBGLESV2_RENDERER_SWAPCHAIN9_H_
-
-#include "common/angleutils.h"
-#include "libGLESv2/renderer/SwapChain.h"
-
-namespace rx
-{
-class Renderer9;
-
-class SwapChain9 : public SwapChain
-{
- public:
- SwapChain9(Renderer9 *renderer, NativeWindow nativeWindow, HANDLE shareHandle,
- GLenum backBufferFormat, GLenum depthBufferFormat);
- virtual ~SwapChain9();
-
- EGLint resize(EGLint backbufferWidth, EGLint backbufferHeight);
- virtual EGLint reset(EGLint backbufferWidth, EGLint backbufferHeight, EGLint swapInterval);
- virtual EGLint swapRect(EGLint x, EGLint y, EGLint width, EGLint height);
- virtual void recreate();
-
- virtual IDirect3DSurface9 *getRenderTarget();
- virtual IDirect3DSurface9 *getDepthStencil();
- virtual IDirect3DTexture9 *getOffscreenTexture();
-
- EGLint getWidth() const { return mWidth; }
- EGLint getHeight() const { return mHeight; }
-
- static SwapChain9 *makeSwapChain9(SwapChain *swapChain);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(SwapChain9);
-
- void release();
-
- Renderer9 *mRenderer;
- EGLint mHeight;
- EGLint mWidth;
- EGLint mSwapInterval;
-
- IDirect3DSwapChain9 *mSwapChain;
- IDirect3DSurface9 *mBackBuffer;
- IDirect3DSurface9 *mRenderTarget;
- IDirect3DSurface9 *mDepthStencil;
- IDirect3DTexture9* mOffscreenTexture;
-};
-
-}
-#endif // LIBGLESV2_RENDERER_SWAPCHAIN9_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.cpp
deleted file mode 100644
index 0ff4fd3b0f..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.cpp
+++ /dev/null
@@ -1,472 +0,0 @@
-//
-// Copyright (c) 2012-2014 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.
-//
-
-// TextureStorage9.cpp: Implements the abstract rx::TextureStorage9 class and its concrete derived
-// classes TextureStorage9_2D and TextureStorage9_Cube, which act as the interface to the
-// D3D9 texture.
-
-#include "libGLESv2/renderer/d3d/d3d9/TextureStorage9.h"
-#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
-#include "libGLESv2/renderer/d3d/d3d9/SwapChain9.h"
-#include "libGLESv2/renderer/d3d/d3d9/RenderTarget9.h"
-#include "libGLESv2/renderer/d3d/d3d9/renderer9_utils.h"
-#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h"
-#include "libGLESv2/renderer/d3d/TextureD3D.h"
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/main.h"
-
-namespace rx
-{
-TextureStorage9::TextureStorage9(Renderer9 *renderer, DWORD usage)
- : mTopLevel(0),
- mMipLevels(0),
- mTextureWidth(0),
- mTextureHeight(0),
- mInternalFormat(GL_NONE),
- mTextureFormat(D3DFMT_UNKNOWN),
- mRenderer(Renderer9::makeRenderer9(renderer)),
- mD3DUsage(usage),
- mD3DPool(mRenderer->getTexturePool(usage))
-{
-}
-
-TextureStorage9::~TextureStorage9()
-{
-}
-
-TextureStorage9 *TextureStorage9::makeTextureStorage9(TextureStorage *storage)
-{
- ASSERT(HAS_DYNAMIC_TYPE(TextureStorage9*, storage));
- return static_cast<TextureStorage9*>(storage);
-}
-
-DWORD TextureStorage9::GetTextureUsage(GLenum internalformat, bool renderTarget)
-{
- DWORD d3dusage = 0;
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
- const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(internalformat);
- if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0)
- {
- d3dusage |= D3DUSAGE_DEPTHSTENCIL;
- }
- else if (renderTarget && (d3dFormatInfo.renderFormat != D3DFMT_UNKNOWN))
- {
- d3dusage |= D3DUSAGE_RENDERTARGET;
- }
-
- return d3dusage;
-}
-
-
-bool TextureStorage9::isRenderTarget() const
-{
- return (mD3DUsage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)) != 0;
-}
-
-bool TextureStorage9::isManaged() const
-{
- return (mD3DPool == D3DPOOL_MANAGED);
-}
-
-D3DPOOL TextureStorage9::getPool() const
-{
- return mD3DPool;
-}
-
-DWORD TextureStorage9::getUsage() const
-{
- return mD3DUsage;
-}
-
-int TextureStorage9::getTopLevel() const
-{
- return mTopLevel;
-}
-
-int TextureStorage9::getLevelCount() const
-{
- return mMipLevels - mTopLevel;
-}
-
-gl::Error TextureStorage9::setData(const gl::ImageIndex &index, Image *image, const gl::Box *destBox, GLenum type,
- const gl::PixelUnpackState &unpack, const uint8_t *pixelData)
-{
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
-}
-
-TextureStorage9_2D::TextureStorage9_2D(Renderer9 *renderer, SwapChain9 *swapchain)
- : TextureStorage9(renderer, D3DUSAGE_RENDERTARGET)
-{
- IDirect3DTexture9 *surfaceTexture = swapchain->getOffscreenTexture();
- mTexture = surfaceTexture;
- mMipLevels = surfaceTexture->GetLevelCount();
-
- mInternalFormat = swapchain->GetBackBufferInternalFormat();
-
- D3DSURFACE_DESC surfaceDesc;
- surfaceTexture->GetLevelDesc(0, &surfaceDesc);
- mTextureWidth = surfaceDesc.Width;
- mTextureHeight = surfaceDesc.Height;
- mTextureFormat = surfaceDesc.Format;
-
- mRenderTarget = NULL;
-
- initializeSerials(1, 1);
-}
-
-TextureStorage9_2D::TextureStorage9_2D(Renderer9 *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels)
- : TextureStorage9(renderer, GetTextureUsage(internalformat, renderTarget))
-{
- mTexture = NULL;
- mRenderTarget = NULL;
-
- mInternalFormat = internalformat;
-
- const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(internalformat);
- mTextureFormat = d3dFormatInfo.texFormat;
-
- d3d9::MakeValidSize(false, d3dFormatInfo.texFormat, &width, &height, &mTopLevel);
- mTextureWidth = width;
- mTextureHeight = height;
- mMipLevels = mTopLevel + levels;
-
- initializeSerials(getLevelCount(), 1);
-}
-
-TextureStorage9_2D::~TextureStorage9_2D()
-{
- SafeRelease(mTexture);
- SafeDelete(mRenderTarget);
-}
-
-TextureStorage9_2D *TextureStorage9_2D::makeTextureStorage9_2D(TextureStorage *storage)
-{
- ASSERT(HAS_DYNAMIC_TYPE(TextureStorage9_2D*, storage));
- return static_cast<TextureStorage9_2D*>(storage);
-}
-
-// Increments refcount on surface.
-// caller must Release() the returned surface
-gl::Error TextureStorage9_2D::getSurfaceLevel(int level, bool dirty, IDirect3DSurface9 **outSurface)
-{
- IDirect3DBaseTexture9 *baseTexture = NULL;
- gl::Error error = getBaseTexture(&baseTexture);
- if (error.isError())
- {
- return error;
- }
-
- IDirect3DTexture9 *texture = static_cast<IDirect3DTexture9*>(baseTexture);
-
- HRESULT result = texture->GetSurfaceLevel(level + mTopLevel, outSurface);
-
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to get the surface from a texture, result: 0x%X.", result);
- }
-
- // With managed textures the driver needs to be informed of updates to the lower mipmap levels
- if (level + mTopLevel != 0 && isManaged() && dirty)
- {
- texture->AddDirtyRect(NULL);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage9_2D::getRenderTarget(const gl::ImageIndex &/*index*/, RenderTarget **outRT)
-{
- if (!mRenderTarget && isRenderTarget())
- {
- IDirect3DSurface9 *surface = NULL;
- gl::Error error = getSurfaceLevel(0, false, &surface);
- if (error.isError())
- {
- return error;
- }
-
- mRenderTarget = new TextureRenderTarget9(surface, mInternalFormat, mTextureWidth, mTextureHeight, 1, 0);
- }
-
- ASSERT(outRT);
- *outRT = mRenderTarget;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage9_2D::generateMipmap(const gl::ImageIndex &sourceIndex, const gl::ImageIndex &destIndex)
-{
- IDirect3DSurface9 *upper = NULL;
- gl::Error error = getSurfaceLevel(sourceIndex.mipIndex, false, &upper);
- if (error.isError())
- {
- return error;
- }
-
- IDirect3DSurface9 *lower = NULL;
- error = getSurfaceLevel(destIndex.mipIndex, true, &lower);
- if (error.isError())
- {
- SafeRelease(upper);
- return error;
- }
-
- ASSERT(upper && lower);
- error = mRenderer->boxFilter(upper, lower);
-
- SafeRelease(upper);
- SafeRelease(lower);
-
- return error;
-}
-
-gl::Error TextureStorage9_2D::getBaseTexture(IDirect3DBaseTexture9 **outTexture)
-{
- // if the width or height is not positive this should be treated as an incomplete texture
- // we handle that here by skipping the d3d texture creation
- if (mTexture == NULL && mTextureWidth > 0 && mTextureHeight > 0)
- {
- ASSERT(mMipLevels > 0);
-
- IDirect3DDevice9 *device = mRenderer->getDevice();
- HRESULT result = device->CreateTexture(mTextureWidth, mTextureHeight, mMipLevels, getUsage(), mTextureFormat,
- getPool(), &mTexture, NULL);
-
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create 2D storage texture, result: 0x%X.", result);
- }
- }
-
- *outTexture = mTexture;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage9_2D::copyToStorage(TextureStorage *destStorage)
-{
- ASSERT(destStorage);
-
- TextureStorage9_2D *dest9 = TextureStorage9_2D::makeTextureStorage9_2D(destStorage);
-
- int levels = getLevelCount();
- for (int i = 0; i < levels; ++i)
- {
- IDirect3DSurface9 *srcSurf = NULL;
- gl::Error error = getSurfaceLevel(i, false, &srcSurf);
- if (error.isError())
- {
- return error;
- }
-
- IDirect3DSurface9 *dstSurf = NULL;
- error = dest9->getSurfaceLevel(i, true, &dstSurf);
- if (error.isError())
- {
- SafeRelease(srcSurf);
- return error;
- }
-
- error = mRenderer->copyToRenderTarget(dstSurf, srcSurf, isManaged());
-
- SafeRelease(srcSurf);
- SafeRelease(dstSurf);
-
- if (error.isError())
- {
- return error;
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-TextureStorage9_Cube::TextureStorage9_Cube(Renderer9 *renderer, GLenum internalformat, bool renderTarget, int size, int levels)
- : TextureStorage9(renderer, GetTextureUsage(internalformat, renderTarget))
-{
- mTexture = NULL;
- for (int i = 0; i < CUBE_FACE_COUNT; ++i)
- {
- mRenderTarget[i] = NULL;
- }
-
- mInternalFormat = internalformat;
-
- const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(internalformat);
- mTextureFormat = d3dFormatInfo.texFormat;
-
- int height = size;
- d3d9::MakeValidSize(false, d3dFormatInfo.texFormat, &size, &height, &mTopLevel);
- mTextureWidth = size;
- mTextureHeight = size;
- mMipLevels = mTopLevel + levels;
-
- initializeSerials(getLevelCount() * CUBE_FACE_COUNT, CUBE_FACE_COUNT);
-}
-
-TextureStorage9_Cube::~TextureStorage9_Cube()
-{
- SafeRelease(mTexture);
-
- for (int i = 0; i < CUBE_FACE_COUNT; ++i)
- {
- SafeDelete(mRenderTarget[i]);
- }
-}
-
-TextureStorage9_Cube *TextureStorage9_Cube::makeTextureStorage9_Cube(TextureStorage *storage)
-{
- ASSERT(HAS_DYNAMIC_TYPE(TextureStorage9_Cube*, storage));
- return static_cast<TextureStorage9_Cube*>(storage);
-}
-
-// Increments refcount on surface.
-// caller must Release() the returned surface
-gl::Error TextureStorage9_Cube::getCubeMapSurface(GLenum faceTarget, int level, bool dirty, IDirect3DSurface9 **outSurface)
-{
- IDirect3DBaseTexture9 *baseTexture = NULL;
- gl::Error error = getBaseTexture(&baseTexture);
- if (error.isError())
- {
- return error;
- }
-
- IDirect3DCubeTexture9 *texture = static_cast<IDirect3DCubeTexture9*>(baseTexture);
-
- D3DCUBEMAP_FACES face = gl_d3d9::ConvertCubeFace(faceTarget);
- HRESULT result = texture->GetCubeMapSurface(face, level + mTopLevel, outSurface);
-
- ASSERT(SUCCEEDED(result));
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to get the surface from a texture, result: 0x%X.", result);
- }
-
- // With managed textures the driver needs to be informed of updates to the lower mipmap levels
- if (level != 0 && isManaged() && dirty)
- {
- texture->AddDirtyRect(face, NULL);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage9_Cube::getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT)
-{
- ASSERT(outRT);
- ASSERT(index.mipIndex == 0);
- ASSERT(index.layerIndex >= 0 && index.layerIndex < CUBE_FACE_COUNT);
-
- if (mRenderTarget[index.layerIndex] == NULL && isRenderTarget())
- {
- IDirect3DSurface9 *surface = NULL;
- gl::Error error = getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + index.layerIndex, 0, false, &surface);
- if (error.isError())
- {
- return error;
- }
-
- mRenderTarget[index.layerIndex] = new TextureRenderTarget9(surface, mInternalFormat, mTextureWidth, mTextureHeight, 1, 0);
- }
-
- *outRT = mRenderTarget[index.layerIndex];
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage9_Cube::generateMipmap(const gl::ImageIndex &sourceIndex, const gl::ImageIndex &destIndex)
-{
- IDirect3DSurface9 *upper = NULL;
- gl::Error error = getCubeMapSurface(sourceIndex.type, sourceIndex.mipIndex, false, &upper);
- if (error.isError())
- {
- return error;
- }
-
- IDirect3DSurface9 *lower = NULL;
- error = getCubeMapSurface(destIndex.type, destIndex.mipIndex, true, &lower);
- if (error.isError())
- {
- SafeRelease(upper);
- return error;
- }
-
- ASSERT(upper && lower);
- error = mRenderer->boxFilter(upper, lower);
-
- SafeRelease(upper);
- SafeRelease(lower);
-
- return error;
-}
-
-gl::Error TextureStorage9_Cube::getBaseTexture(IDirect3DBaseTexture9 **outTexture)
-{
- // if the size is not positive this should be treated as an incomplete texture
- // we handle that here by skipping the d3d texture creation
- if (mTexture == NULL && mTextureWidth > 0 && mTextureHeight > 0)
- {
- ASSERT(mMipLevels > 0);
- ASSERT(mTextureWidth == mTextureHeight);
-
- IDirect3DDevice9 *device = mRenderer->getDevice();
- HRESULT result = device->CreateCubeTexture(mTextureWidth, mMipLevels, getUsage(), mTextureFormat, getPool(),
- &mTexture, NULL);
-
- if (FAILED(result))
- {
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create cube storage texture, result: 0x%X.", result);
- }
- }
-
- *outTexture = mTexture;
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error TextureStorage9_Cube::copyToStorage(TextureStorage *destStorage)
-{
- ASSERT(destStorage);
-
- TextureStorage9_Cube *dest9 = TextureStorage9_Cube::makeTextureStorage9_Cube(destStorage);
-
- int levels = getLevelCount();
- for (int f = 0; f < CUBE_FACE_COUNT; f++)
- {
- for (int i = 0; i < levels; i++)
- {
- IDirect3DSurface9 *srcSurf = NULL;
- gl::Error error = getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, i, false, &srcSurf);
- if (error.isError())
- {
- return error;
- }
-
- IDirect3DSurface9 *dstSurf = NULL;
- error = dest9->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, i, true, &dstSurf);
- if (error.isError())
- {
- SafeRelease(srcSurf);
- return error;
- }
-
- error = mRenderer->copyToRenderTarget(dstSurf, srcSurf, isManaged());
-
- SafeRelease(srcSurf);
- SafeRelease(dstSurf);
-
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.h
deleted file mode 100644
index da0e1f2f18..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.h
+++ /dev/null
@@ -1,114 +0,0 @@
-//
-// Copyright (c) 2012-2013 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.
-//
-
-// TextureStorage9.h: Defines the abstract rx::TextureStorage9 class and its concrete derived
-// classes TextureStorage9_2D and TextureStorage9_Cube, which act as the interface to the
-// D3D9 texture.
-
-#ifndef LIBGLESV2_RENDERER_TEXTURESTORAGE9_H_
-#define LIBGLESV2_RENDERER_TEXTURESTORAGE9_H_
-
-#include "libGLESv2/renderer/d3d/TextureStorage.h"
-#include "common/debug.h"
-
-namespace rx
-{
-class Renderer9;
-class SwapChain9;
-class RenderTarget;
-class RenderTarget9;
-
-class TextureStorage9 : public TextureStorage
-{
- public:
- virtual ~TextureStorage9();
-
- static TextureStorage9 *makeTextureStorage9(TextureStorage *storage);
-
- static DWORD GetTextureUsage(GLenum internalformat, bool renderTarget);
-
- D3DPOOL getPool() const;
- DWORD getUsage() const;
-
- virtual gl::Error getBaseTexture(IDirect3DBaseTexture9 **outTexture) = 0;
- virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT) = 0;
-
- virtual int getTopLevel() const;
- virtual bool isRenderTarget() const;
- virtual bool isManaged() const;
- virtual int getLevelCount() const;
-
- virtual gl::Error setData(const gl::ImageIndex &index, Image *image, const gl::Box *destBox, GLenum type,
- const gl::PixelUnpackState &unpack, const uint8_t *pixelData);
-
- protected:
- int mTopLevel;
- size_t mMipLevels;
- size_t mTextureWidth;
- size_t mTextureHeight;
- GLenum mInternalFormat;
- D3DFORMAT mTextureFormat;
-
- Renderer9 *mRenderer;
-
- TextureStorage9(Renderer9 *renderer, DWORD usage);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureStorage9);
-
- const DWORD mD3DUsage;
- const D3DPOOL mD3DPool;
-};
-
-class TextureStorage9_2D : public TextureStorage9
-{
- public:
- TextureStorage9_2D(Renderer9 *renderer, SwapChain9 *swapchain);
- TextureStorage9_2D(Renderer9 *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels);
- virtual ~TextureStorage9_2D();
-
- static TextureStorage9_2D *makeTextureStorage9_2D(TextureStorage *storage);
-
- gl::Error getSurfaceLevel(int level, bool dirty, IDirect3DSurface9 **outSurface);
- virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT);
- virtual gl::Error getBaseTexture(IDirect3DBaseTexture9 **outTexture);
- virtual gl::Error generateMipmap(const gl::ImageIndex &sourceIndex, const gl::ImageIndex &destIndex);
- virtual gl::Error copyToStorage(TextureStorage *destStorage);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureStorage9_2D);
-
- IDirect3DTexture9 *mTexture;
- RenderTarget9 *mRenderTarget;
-};
-
-class TextureStorage9_Cube : public TextureStorage9
-{
- public:
- TextureStorage9_Cube(Renderer9 *renderer, GLenum internalformat, bool renderTarget, int size, int levels);
- virtual ~TextureStorage9_Cube();
-
- static TextureStorage9_Cube *makeTextureStorage9_Cube(TextureStorage *storage);
-
- gl::Error getCubeMapSurface(GLenum faceTarget, int level, bool dirty, IDirect3DSurface9 **outSurface);
- virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTarget **outRT);
- virtual gl::Error getBaseTexture(IDirect3DBaseTexture9 **outTexture);
- virtual gl::Error generateMipmap(const gl::ImageIndex &sourceIndex, const gl::ImageIndex &destIndex);
- virtual gl::Error copyToStorage(TextureStorage *destStorage);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TextureStorage9_Cube);
-
- static const size_t CUBE_FACE_COUNT = 6;
-
- IDirect3DCubeTexture9 *mTexture;
- RenderTarget9 *mRenderTarget[CUBE_FACE_COUNT];
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_TEXTURESTORAGE9_H_
-
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexArray9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexArray9.h
deleted file mode 100644
index 791c108462..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexArray9.h
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// Copyright 2014 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.
-//
-
-// VertexArray9.h: Defines the rx::VertexArray9 class which implements rx::VertexArrayImpl.
-
-#ifndef LIBGLESV2_RENDERER_VERTEXARRAY9_H_
-#define LIBGLESV2_RENDERER_VERTEXARRAY9_H_
-
-#include "libGLESv2/renderer/VertexArrayImpl.h"
-#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
-
-namespace rx
-{
-class Renderer9;
-
-class VertexArray9 : public VertexArrayImpl
-{
- public:
- VertexArray9(Renderer9 *renderer)
- : VertexArrayImpl(),
- mRenderer(renderer)
- {
- }
-
- virtual ~VertexArray9() { }
-
- virtual void setElementArrayBuffer(const gl::Buffer *buffer) { }
- virtual void setAttribute(size_t idx, const gl::VertexAttribute &attr) { }
- virtual void setAttributeDivisor(size_t idx, GLuint divisor) { }
- virtual void enableAttribute(size_t idx, bool enabledState) { }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(VertexArray9);
-
- Renderer9 *mRenderer;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_VERTEXARRAY9_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexBuffer9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexBuffer9.cpp
deleted file mode 100644
index b90133097c..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexBuffer9.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-//
-// 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.
-//
-
-// VertexBuffer9.cpp: Defines the D3D9 VertexBuffer implementation.
-
-#include "libGLESv2/renderer/d3d/d3d9/VertexBuffer9.h"
-#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
-#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h"
-#include "libGLESv2/renderer/vertexconversion.h"
-#include "libGLESv2/renderer/d3d/BufferD3D.h"
-#include "libGLESv2/VertexAttribute.h"
-#include "libGLESv2/Buffer.h"
-
-namespace rx
-{
-
-VertexBuffer9::VertexBuffer9(Renderer9 *renderer) : mRenderer(renderer)
-{
- mVertexBuffer = NULL;
- mBufferSize = 0;
- mDynamicUsage = false;
-}
-
-VertexBuffer9::~VertexBuffer9()
-{
- SafeRelease(mVertexBuffer);
-}
-
-gl::Error VertexBuffer9::initialize(unsigned int size, bool dynamicUsage)
-{
- SafeRelease(mVertexBuffer);
-
- updateSerial();
-
- if (size > 0)
- {
- DWORD flags = D3DUSAGE_WRITEONLY;
- if (dynamicUsage)
- {
- flags |= D3DUSAGE_DYNAMIC;
- }
-
- HRESULT result = mRenderer->createVertexBuffer(size, flags, &mVertexBuffer);
-
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate internal vertex buffer of size, %lu.", size);
- }
- }
-
- mBufferSize = size;
- mDynamicUsage = dynamicUsage;
- return gl::Error(GL_NO_ERROR);
-}
-
-VertexBuffer9 *VertexBuffer9::makeVertexBuffer9(VertexBuffer *vertexBuffer)
-{
- ASSERT(HAS_DYNAMIC_TYPE(VertexBuffer9*, vertexBuffer));
- return static_cast<VertexBuffer9*>(vertexBuffer);
-}
-
-gl::Error VertexBuffer9::storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
- GLint start, GLsizei count, GLsizei instances, unsigned int offset)
-{
- if (!mVertexBuffer)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal vertex buffer is not initialized.");
- }
-
- gl::Buffer *buffer = attrib.buffer.get();
-
- int inputStride = gl::ComputeVertexAttributeStride(attrib);
- int elementSize = gl::ComputeVertexAttributeTypeSize(attrib);
-
- DWORD lockFlags = mDynamicUsage ? D3DLOCK_NOOVERWRITE : 0;
-
- uint8_t *mapPtr = NULL;
-
- unsigned int mapSize;
- gl::Error error = spaceRequired(attrib, count, instances, &mapSize);
- if (error.isError())
- {
- return error;
- }
-
- HRESULT result = mVertexBuffer->Lock(offset, mapSize, reinterpret_cast<void**>(&mapPtr), lockFlags);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock internal vertex buffer, HRESULT: 0x%08x.", result);
- }
-
- const uint8_t *input = NULL;
- if (attrib.enabled)
- {
- if (buffer)
- {
- BufferD3D *storage = BufferD3D::makeFromBuffer(buffer);
- ASSERT(storage);
- gl::Error error = storage->getData(&input);
- if (error.isError())
- {
- return error;
- }
- input += static_cast<int>(attrib.offset);
- }
- else
- {
- input = static_cast<const uint8_t*>(attrib.pointer);
- }
- }
- else
- {
- input = reinterpret_cast<const uint8_t*>(currentValue.FloatValues);
- }
-
- if (instances == 0 || attrib.divisor == 0)
- {
- input += inputStride * start;
- }
-
- gl::VertexFormat vertexFormat(attrib, currentValue.Type);
- const d3d9::VertexFormat &d3dVertexInfo = d3d9::GetVertexFormatInfo(mRenderer->getCapsDeclTypes(), vertexFormat);
- bool needsConversion = (d3dVertexInfo.conversionType & VERTEX_CONVERT_CPU) > 0;
-
- if (!needsConversion && inputStride == elementSize)
- {
- size_t copySize = static_cast<size_t>(count) * static_cast<size_t>(inputStride);
- memcpy(mapPtr, input, copySize);
- }
- else
- {
- d3dVertexInfo.copyFunction(input, inputStride, count, mapPtr);
- }
-
- mVertexBuffer->Unlock();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error VertexBuffer9::getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances,
- unsigned int *outSpaceRequired) const
-{
- return spaceRequired(attrib, count, instances, outSpaceRequired);
-}
-
-unsigned int VertexBuffer9::getBufferSize() const
-{
- return mBufferSize;
-}
-
-gl::Error VertexBuffer9::setBufferSize(unsigned int size)
-{
- if (size > mBufferSize)
- {
- return initialize(size, mDynamicUsage);
- }
- else
- {
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-gl::Error VertexBuffer9::discard()
-{
- if (!mVertexBuffer)
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Internal vertex buffer is not initialized.");
- }
-
- void *dummy;
- HRESULT result;
-
- result = mVertexBuffer->Lock(0, 1, &dummy, D3DLOCK_DISCARD);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock internal buffer for discarding, HRESULT: 0x%08x", result);
- }
-
- result = mVertexBuffer->Unlock();
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to unlock internal buffer for discarding, HRESULT: 0x%08x", result);
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-IDirect3DVertexBuffer9 * VertexBuffer9::getBuffer() const
-{
- return mVertexBuffer;
-}
-
-gl::Error VertexBuffer9::spaceRequired(const gl::VertexAttribute &attrib, std::size_t count, GLsizei instances,
- unsigned int *outSpaceRequired) const
-{
- gl::VertexFormat vertexFormat(attrib, GL_FLOAT);
- const d3d9::VertexFormat &d3d9VertexInfo = d3d9::GetVertexFormatInfo(mRenderer->getCapsDeclTypes(), vertexFormat);
-
- if (attrib.enabled)
- {
- unsigned int elementCount = 0;
- if (instances == 0 || attrib.divisor == 0)
- {
- elementCount = count;
- }
- else
- {
- // Round up to divisor, if possible
- elementCount = UnsignedCeilDivide(static_cast<unsigned int>(instances), attrib.divisor);
- }
-
- if (d3d9VertexInfo.outputElementSize <= std::numeric_limits<unsigned int>::max() / elementCount)
- {
- if (outSpaceRequired)
- {
- *outSpaceRequired = d3d9VertexInfo.outputElementSize * elementCount;
- }
- return gl::Error(GL_NO_ERROR);
- }
- else
- {
- return gl::Error(GL_OUT_OF_MEMORY, "New vertex buffer size would result in an overflow.");
- }
- }
- else
- {
- const unsigned int elementSize = 4;
- if (outSpaceRequired)
- {
- *outSpaceRequired = elementSize * 4;
- }
- return gl::Error(GL_NO_ERROR);
- }
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexBuffer9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexBuffer9.h
deleted file mode 100644
index 9af2b98a6e..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexBuffer9.h
+++ /dev/null
@@ -1,54 +0,0 @@
-//
-// 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.
-//
-
-// VertexBuffer9.h: Defines the D3D9 VertexBuffer implementation.
-
-#ifndef LIBGLESV2_RENDERER_VERTEXBUFFER9_H_
-#define LIBGLESV2_RENDERER_VERTEXBUFFER9_H_
-
-#include "libGLESv2/renderer/d3d/VertexBuffer.h"
-
-namespace rx
-{
-class Renderer9;
-
-class VertexBuffer9 : public VertexBuffer
-{
- public:
- explicit VertexBuffer9(Renderer9 *renderer);
- virtual ~VertexBuffer9();
-
- virtual gl::Error initialize(unsigned int size, bool dynamicUsage);
-
- static VertexBuffer9 *makeVertexBuffer9(VertexBuffer *vertexBuffer);
-
- virtual gl::Error storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
- GLint start, GLsizei count, GLsizei instances, unsigned int offset);
-
- virtual gl::Error getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances, unsigned int *outSpaceRequired) const;
-
- virtual unsigned int getBufferSize() const;
- virtual gl::Error setBufferSize(unsigned int size);
- virtual gl::Error discard();
-
- IDirect3DVertexBuffer9 *getBuffer() const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(VertexBuffer9);
-
- Renderer9 *mRenderer;
-
- IDirect3DVertexBuffer9 *mVertexBuffer;
- unsigned int mBufferSize;
- bool mDynamicUsage;
-
- gl::Error spaceRequired(const gl::VertexAttribute &attrib, std::size_t count, GLsizei instances,
- unsigned int *outSpaceRequired) const;
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_VERTEXBUFFER9_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.cpp
deleted file mode 100644
index cefd786f11..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// VertexDeclarationCache.cpp: Implements a helper class to construct and cache vertex declarations.
-
-#include "libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.h"
-#include "libGLESv2/renderer/d3d/d3d9/VertexBuffer9.h"
-#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h"
-#include "libGLESv2/ProgramBinary.h"
-#include "libGLESv2/VertexAttribute.h"
-
-namespace rx
-{
-
-VertexDeclarationCache::VertexDeclarationCache() : mMaxLru(0)
-{
- for (int i = 0; i < NUM_VERTEX_DECL_CACHE_ENTRIES; i++)
- {
- mVertexDeclCache[i].vertexDeclaration = NULL;
- mVertexDeclCache[i].lruCount = 0;
- }
-
- for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- mAppliedVBs[i].serial = 0;
- }
-
- mLastSetVDecl = NULL;
- mInstancingEnabled = true;
-}
-
-VertexDeclarationCache::~VertexDeclarationCache()
-{
- for (int i = 0; i < NUM_VERTEX_DECL_CACHE_ENTRIES; i++)
- {
- SafeRelease(mVertexDeclCache[i].vertexDeclaration);
- }
-}
-
-gl::Error VertexDeclarationCache::applyDeclaration(IDirect3DDevice9 *device, TranslatedAttribute attributes[], gl::ProgramBinary *programBinary, GLsizei instances, GLsizei *repeatDraw)
-{
- *repeatDraw = 1;
-
- int indexedAttribute = gl::MAX_VERTEX_ATTRIBS;
- int instancedAttribute = gl::MAX_VERTEX_ATTRIBS;
-
- if (instances == 0)
- {
- for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; ++i)
- {
- if (attributes[i].divisor != 0)
- {
- // If a divisor is set, it still applies even if an instanced draw was not used, so treat
- // as a single-instance draw.
- instances = 1;
- break;
- }
- }
- }
-
- if (instances > 0)
- {
- // Find an indexed attribute to be mapped to D3D stream 0
- for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- if (attributes[i].active)
- {
- if (indexedAttribute == gl::MAX_VERTEX_ATTRIBS && attributes[i].divisor == 0)
- {
- indexedAttribute = i;
- }
- else if (instancedAttribute == gl::MAX_VERTEX_ATTRIBS && attributes[i].divisor != 0)
- {
- instancedAttribute = i;
- }
- if (indexedAttribute != gl::MAX_VERTEX_ATTRIBS && instancedAttribute != gl::MAX_VERTEX_ATTRIBS)
- break; // Found both an indexed and instanced attribute
- }
- }
-
- // The validation layer checks that there is at least one active attribute with a zero divisor as per
- // the GL_ANGLE_instanced_arrays spec.
- ASSERT(indexedAttribute != gl::MAX_VERTEX_ATTRIBS);
- }
-
- D3DCAPS9 caps;
- device->GetDeviceCaps(&caps);
-
- D3DVERTEXELEMENT9 elements[gl::MAX_VERTEX_ATTRIBS + 1];
- D3DVERTEXELEMENT9 *element = &elements[0];
-
- for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- if (attributes[i].active)
- {
- // Directly binding the storage buffer is not supported for d3d9
- ASSERT(attributes[i].storage == NULL);
-
- int stream = i;
-
- if (instances > 0)
- {
- // Due to a bug on ATI cards we can't enable instancing when none of the attributes are instanced.
- if (instancedAttribute == gl::MAX_VERTEX_ATTRIBS)
- {
- *repeatDraw = instances;
- }
- else
- {
- if (i == indexedAttribute)
- {
- stream = 0;
- }
- else if (i == 0)
- {
- stream = indexedAttribute;
- }
-
- UINT frequency = 1;
-
- if (attributes[i].divisor == 0)
- {
- frequency = D3DSTREAMSOURCE_INDEXEDDATA | instances;
- }
- else
- {
- frequency = D3DSTREAMSOURCE_INSTANCEDATA | attributes[i].divisor;
- }
-
- device->SetStreamSourceFreq(stream, frequency);
- mInstancingEnabled = true;
- }
- }
-
- VertexBuffer9 *vertexBuffer = VertexBuffer9::makeVertexBuffer9(attributes[i].vertexBuffer);
-
- if (mAppliedVBs[stream].serial != attributes[i].serial ||
- mAppliedVBs[stream].stride != attributes[i].stride ||
- mAppliedVBs[stream].offset != attributes[i].offset)
- {
- device->SetStreamSource(stream, vertexBuffer->getBuffer(), attributes[i].offset, attributes[i].stride);
- mAppliedVBs[stream].serial = attributes[i].serial;
- mAppliedVBs[stream].stride = attributes[i].stride;
- mAppliedVBs[stream].offset = attributes[i].offset;
- }
-
- gl::VertexFormat vertexFormat(*attributes[i].attribute, GL_FLOAT);
- const d3d9::VertexFormat &d3d9VertexInfo = d3d9::GetVertexFormatInfo(caps.DeclTypes, vertexFormat);
-
- element->Stream = stream;
- element->Offset = 0;
- element->Type = d3d9VertexInfo.nativeFormat;
- element->Method = D3DDECLMETHOD_DEFAULT;
- element->Usage = D3DDECLUSAGE_TEXCOORD;
- element->UsageIndex = programBinary->getSemanticIndex(i);
- element++;
- }
- }
-
- if (instances == 0 || instancedAttribute == gl::MAX_VERTEX_ATTRIBS)
- {
- if (mInstancingEnabled)
- {
- for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- device->SetStreamSourceFreq(i, 1);
- }
-
- mInstancingEnabled = false;
- }
- }
-
- static const D3DVERTEXELEMENT9 end = D3DDECL_END();
- *(element++) = end;
-
- for (int i = 0; i < NUM_VERTEX_DECL_CACHE_ENTRIES; i++)
- {
- VertexDeclCacheEntry *entry = &mVertexDeclCache[i];
- if (memcmp(entry->cachedElements, elements, (element - elements) * sizeof(D3DVERTEXELEMENT9)) == 0 && entry->vertexDeclaration)
- {
- entry->lruCount = ++mMaxLru;
- if(entry->vertexDeclaration != mLastSetVDecl)
- {
- device->SetVertexDeclaration(entry->vertexDeclaration);
- mLastSetVDecl = entry->vertexDeclaration;
- }
-
- return gl::Error(GL_NO_ERROR);
- }
- }
-
- VertexDeclCacheEntry *lastCache = mVertexDeclCache;
-
- for (int i = 0; i < NUM_VERTEX_DECL_CACHE_ENTRIES; i++)
- {
- if (mVertexDeclCache[i].lruCount < lastCache->lruCount)
- {
- lastCache = &mVertexDeclCache[i];
- }
- }
-
- if (lastCache->vertexDeclaration != NULL)
- {
- SafeRelease(lastCache->vertexDeclaration);
- // mLastSetVDecl is set to the replacement, so we don't have to worry
- // about it.
- }
-
- memcpy(lastCache->cachedElements, elements, (element - elements) * sizeof(D3DVERTEXELEMENT9));
- HRESULT result = device->CreateVertexDeclaration(elements, &lastCache->vertexDeclaration);
- if (FAILED(result))
- {
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal vertex declaration, result: 0x%X.", result);
- }
-
- device->SetVertexDeclaration(lastCache->vertexDeclaration);
- mLastSetVDecl = lastCache->vertexDeclaration;
- lastCache->lruCount = ++mMaxLru;
-
- return gl::Error(GL_NO_ERROR);
-}
-
-void VertexDeclarationCache::markStateDirty()
-{
- for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
- {
- mAppliedVBs[i].serial = 0;
- }
-
- mLastSetVDecl = NULL;
- mInstancingEnabled = true; // Forces it to be disabled when not used
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.h
deleted file mode 100644
index 9af36e0d7a..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.h
+++ /dev/null
@@ -1,59 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-// VertexDeclarationCache.h: Defines a helper class to construct and cache vertex declarations.
-
-#ifndef LIBGLESV2_RENDERER_VERTEXDECLARATIONCACHE_H_
-#define LIBGLESV2_RENDERER_VERTEXDECLARATIONCACHE_H_
-
-#include "libGLESv2/Error.h"
-#include "libGLESv2/renderer/d3d/VertexDataManager.h"
-
-namespace gl
-{
-class VertexDataManager;
-}
-
-namespace rx
-{
-
-class VertexDeclarationCache
-{
- public:
- VertexDeclarationCache();
- ~VertexDeclarationCache();
-
- gl::Error applyDeclaration(IDirect3DDevice9 *device, TranslatedAttribute attributes[], gl::ProgramBinary *programBinary, GLsizei instances, GLsizei *repeatDraw);
-
- void markStateDirty();
-
- private:
- UINT mMaxLru;
-
- enum { NUM_VERTEX_DECL_CACHE_ENTRIES = 32 };
-
- struct VBData
- {
- unsigned int serial;
- unsigned int stride;
- unsigned int offset;
- };
-
- VBData mAppliedVBs[gl::MAX_VERTEX_ATTRIBS];
- IDirect3DVertexDeclaration9 *mLastSetVDecl;
- bool mInstancingEnabled;
-
- struct VertexDeclCacheEntry
- {
- D3DVERTEXELEMENT9 cachedElements[gl::MAX_VERTEX_ATTRIBS + 1];
- UINT lruCount;
- IDirect3DVertexDeclaration9 *vertexDeclaration;
- } mVertexDeclCache[NUM_VERTEX_DECL_CACHE_ENTRIES];
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_VERTEXDECLARATIONCACHE_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/formatutils9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/formatutils9.cpp
deleted file mode 100644
index f3acaf7987..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/formatutils9.cpp
+++ /dev/null
@@ -1,588 +0,0 @@
-//
-// Copyright (c) 2013-2014 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.
-//
-
-// formatutils9.cpp: Queries for GL image formats and their translations to D3D9
-// formats.
-
-#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h"
-#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
-#include "libGLESv2/renderer/generatemip.h"
-#include "libGLESv2/renderer/loadimage.h"
-#include "libGLESv2/renderer/copyimage.h"
-#include "libGLESv2/renderer/vertexconversion.h"
-
-namespace rx
-{
-
-namespace d3d9
-{
-
-const D3DFORMAT D3DFMT_INTZ = ((D3DFORMAT)(MAKEFOURCC('I', 'N', 'T', 'Z')));
-const D3DFORMAT D3DFMT_NULL = ((D3DFORMAT)(MAKEFOURCC('N', 'U', 'L', 'L')));
-
-struct D3D9FastCopyFormat
-{
- GLenum destFormat;
- GLenum destType;
- ColorCopyFunction copyFunction;
-
- D3D9FastCopyFormat(GLenum destFormat, GLenum destType, ColorCopyFunction copyFunction)
- : destFormat(destFormat), destType(destType), copyFunction(copyFunction)
- { }
-
- bool operator<(const D3D9FastCopyFormat& other) const
- {
- return memcmp(this, &other, sizeof(D3D9FastCopyFormat)) < 0;
- }
-};
-
-typedef std::multimap<D3DFORMAT, D3D9FastCopyFormat> D3D9FastCopyMap;
-
-static D3D9FastCopyMap BuildFastCopyMap()
-{
- D3D9FastCopyMap map;
-
- map.insert(std::make_pair(D3DFMT_A8R8G8B8, D3D9FastCopyFormat(GL_RGBA, GL_UNSIGNED_BYTE, CopyBGRA8ToRGBA8)));
-
- return map;
-}
-
-// A map to determine the pixel size and mip generation function of a given D3D format
-typedef std::map<D3DFORMAT, D3DFormat> D3D9FormatInfoMap;
-
-D3DFormat::D3DFormat()
- : pixelBytes(0),
- blockWidth(0),
- blockHeight(0),
- internalFormat(GL_NONE),
- mipGenerationFunction(NULL),
- colorReadFunction(NULL),
- fastCopyFunctions()
-{
-}
-
-ColorCopyFunction D3DFormat::getFastCopyFunction(GLenum format, GLenum type) const
-{
- FastCopyFunctionMap::const_iterator iter = fastCopyFunctions.find(std::make_pair(format, type));
- return (iter != fastCopyFunctions.end()) ? iter->second : NULL;
-}
-
-static inline void InsertD3DFormatInfo(D3D9FormatInfoMap *map, D3DFORMAT format, GLuint bits, GLuint blockWidth,
- GLuint blockHeight, GLenum internalFormat, MipGenerationFunction mipFunc,
- ColorReadFunction colorReadFunc)
-{
- D3DFormat info;
- info.pixelBytes = bits / 8;
- info.blockWidth = blockWidth;
- info.blockHeight = blockHeight;
- info.internalFormat = internalFormat;
- info.mipGenerationFunction = mipFunc;
- info.colorReadFunction = colorReadFunc;
-
- static const D3D9FastCopyMap fastCopyMap = BuildFastCopyMap();
- std::pair<D3D9FastCopyMap::const_iterator, D3D9FastCopyMap::const_iterator> fastCopyIter = fastCopyMap.equal_range(format);
- for (D3D9FastCopyMap::const_iterator i = fastCopyIter.first; i != fastCopyIter.second; i++)
- {
- info.fastCopyFunctions.insert(std::make_pair(std::make_pair(i->second.destFormat, i->second.destType), i->second.copyFunction));
- }
-
- map->insert(std::make_pair(format, info));
-}
-
-static D3D9FormatInfoMap BuildD3D9FormatInfoMap()
-{
- D3D9FormatInfoMap map;
-
- // | D3DFORMAT | S |W |H | Internal format | Mip generation function | Color read function |
- InsertD3DFormatInfo(&map, D3DFMT_NULL, 0, 0, 0, GL_NONE, NULL, NULL );
- InsertD3DFormatInfo(&map, D3DFMT_UNKNOWN, 0, 0, 0, GL_NONE, NULL, NULL );
-
- InsertD3DFormatInfo(&map, D3DFMT_L8, 8, 1, 1, GL_LUMINANCE8_EXT, GenerateMip<L8>, ReadColor<L8, GLfloat> );
- InsertD3DFormatInfo(&map, D3DFMT_A8, 8, 1, 1, GL_ALPHA8_EXT, GenerateMip<A8>, ReadColor<A8, GLfloat> );
- InsertD3DFormatInfo(&map, D3DFMT_A8L8, 16, 1, 1, GL_LUMINANCE8_ALPHA8_EXT, GenerateMip<A8L8>, ReadColor<A8L8, GLfloat> );
- InsertD3DFormatInfo(&map, D3DFMT_A4R4G4B4, 16, 1, 1, GL_BGRA4_ANGLEX, GenerateMip<B4G4R4A4>, ReadColor<B4G4R4A4, GLfloat> );
- InsertD3DFormatInfo(&map, D3DFMT_A1R5G5B5, 16, 1, 1, GL_BGR5_A1_ANGLEX, GenerateMip<B5G5R5A1>, ReadColor<B5G5R5A1, GLfloat> );
- InsertD3DFormatInfo(&map, D3DFMT_R5G6B5, 16, 1, 1, GL_RGB565, GenerateMip<R5G6B5>, ReadColor<R5G6B5, GLfloat> );
- InsertD3DFormatInfo(&map, D3DFMT_X8R8G8B8, 32, 1, 1, GL_BGRA8_EXT, GenerateMip<B8G8R8X8>, ReadColor<B8G8R8X8, GLfloat> );
- InsertD3DFormatInfo(&map, D3DFMT_A8R8G8B8, 32, 1, 1, GL_BGRA8_EXT, GenerateMip<B8G8R8A8>, ReadColor<B8G8R8A8, GLfloat> );
- InsertD3DFormatInfo(&map, D3DFMT_R16F, 16, 1, 1, GL_R16F_EXT, GenerateMip<R16F>, ReadColor<R16F, GLfloat> );
- InsertD3DFormatInfo(&map, D3DFMT_G16R16F, 32, 1, 1, GL_RG16F_EXT, GenerateMip<R16G16F>, ReadColor<R16G16F, GLfloat> );
- InsertD3DFormatInfo(&map, D3DFMT_A16B16G16R16F, 64, 1, 1, GL_RGBA16F_EXT, GenerateMip<R16G16B16A16F>, ReadColor<R16G16B16A16F, GLfloat>);
- InsertD3DFormatInfo(&map, D3DFMT_R32F, 32, 1, 1, GL_R32F_EXT, GenerateMip<R32F>, ReadColor<R32F, GLfloat> );
- InsertD3DFormatInfo(&map, D3DFMT_G32R32F, 64, 1, 1, GL_RG32F_EXT, GenerateMip<R32G32F>, ReadColor<R32G32F, GLfloat> );
- InsertD3DFormatInfo(&map, D3DFMT_A32B32G32R32F, 128, 1, 1, GL_RGBA32F_EXT, GenerateMip<R32G32B32A32F>, ReadColor<R32G32B32A32F, GLfloat>);
-
- InsertD3DFormatInfo(&map, D3DFMT_D16, 16, 1, 1, GL_DEPTH_COMPONENT16, NULL, NULL );
- InsertD3DFormatInfo(&map, D3DFMT_D24S8, 32, 1, 1, GL_DEPTH24_STENCIL8_OES, NULL, NULL );
- InsertD3DFormatInfo(&map, D3DFMT_D24X8, 32, 1, 1, GL_DEPTH_COMPONENT16, NULL, NULL );
- InsertD3DFormatInfo(&map, D3DFMT_D32, 32, 1, 1, GL_DEPTH_COMPONENT32_OES, NULL, NULL );
-
- InsertD3DFormatInfo(&map, D3DFMT_INTZ, 32, 1, 1, GL_DEPTH24_STENCIL8_OES, NULL, NULL );
-
- InsertD3DFormatInfo(&map, D3DFMT_DXT1, 64, 4, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, NULL, NULL );
- InsertD3DFormatInfo(&map, D3DFMT_DXT3, 128, 4, 4, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, NULL, NULL );
- InsertD3DFormatInfo(&map, D3DFMT_DXT5, 128, 4, 4, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, NULL, NULL );
-
- return map;
-}
-
-const D3DFormat &GetD3DFormatInfo(D3DFORMAT format)
-{
- static const D3D9FormatInfoMap infoMap = BuildD3D9FormatInfoMap();
- D3D9FormatInfoMap::const_iterator iter = infoMap.find(format);
- if (iter != infoMap.end())
- {
- return iter->second;
- }
- else
- {
- static const D3DFormat defaultInfo;
- return defaultInfo;
- }
-}
-
-
-
-typedef std::pair<GLint, InitializeTextureDataFunction> InternalFormatInitialzerPair;
-typedef std::map<GLint, InitializeTextureDataFunction> InternalFormatInitialzerMap;
-
-static InternalFormatInitialzerMap BuildInternalFormatInitialzerMap()
-{
- InternalFormatInitialzerMap map;
-
- map.insert(InternalFormatInitialzerPair(GL_RGB16F, Initialize4ComponentData<GLhalf, 0x0000, 0x0000, 0x0000, gl::Float16One>));
- map.insert(InternalFormatInitialzerPair(GL_RGB32F, Initialize4ComponentData<GLfloat, 0x00000000, 0x00000000, 0x00000000, gl::Float32One>));
-
- return map;
-}
-
-// Each GL internal format corresponds to one D3D format and data loading function.
-// Due to not all formats being available all the time, some of the function/format types are wrapped
-// in templates that perform format support queries on a Renderer9 object which is supplied
-// when requesting the function or format.
-
-typedef bool(*FallbackPredicateFunction)();
-
-template <FallbackPredicateFunction pred, LoadImageFunction prefered, LoadImageFunction fallback>
-static void FallbackLoad(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- if (pred())
- {
- prefered(width, height, depth, input, inputRowPitch, inputDepthPitch, output, outputRowPitch, outputDepthPitch);
- }
- else
- {
- fallback(width, height, depth, input, inputRowPitch, inputDepthPitch, output, outputRowPitch, outputDepthPitch);
- }
-}
-
-static void UnreachableLoad(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- UNREACHABLE();
-}
-
-typedef std::pair<GLenum, TextureFormat> D3D9FormatPair;
-typedef std::map<GLenum, TextureFormat> D3D9FormatMap;
-
-TextureFormat::TextureFormat()
- : texFormat(D3DFMT_NULL),
- renderFormat(D3DFMT_NULL),
- dataInitializerFunction(NULL),
- loadFunction(UnreachableLoad)
-{
-}
-
-static inline void InsertD3D9FormatInfo(D3D9FormatMap *map, GLenum internalFormat, D3DFORMAT texFormat,
- D3DFORMAT renderFormat, LoadImageFunction loadFunction)
-{
- TextureFormat info;
- info.texFormat = texFormat;
- info.renderFormat = renderFormat;
-
- static const InternalFormatInitialzerMap dataInitializationMap = BuildInternalFormatInitialzerMap();
- InternalFormatInitialzerMap::const_iterator dataInitIter = dataInitializationMap.find(internalFormat);
- info.dataInitializerFunction = (dataInitIter != dataInitializationMap.end()) ? dataInitIter->second : NULL;
-
- info.loadFunction = loadFunction;
-
- map->insert(std::make_pair(internalFormat, info));
-}
-
-static D3D9FormatMap BuildD3D9FormatMap()
-{
- D3D9FormatMap map;
-
- // | Internal format | Texture format | Render format | Load function |
- InsertD3D9FormatInfo(&map, GL_NONE, D3DFMT_NULL, D3DFMT_NULL, UnreachableLoad );
-
- // We choose to downsample the GL_DEPTH_COMPONENT32_OES format to a 24-bit format because D3DFMT_D32 is not widely
- // supported. We're allowed to do this because:
- // - The ES spec 2.0.25 sec 3.7.1 states that we're allowed to store texture formats with internal format
- // resolutions of our own choosing.
- // - OES_depth_texture states that downsampling of the depth formats is allowed.
- // - ANGLE_depth_texture does not state minimum required resolutions of the depth texture formats it
- // introduces.
- // In ES3 however, there are minimum resolutions for the texture formats and this would not be allowed.
-
- InsertD3D9FormatInfo(&map, GL_DEPTH_COMPONENT16, D3DFMT_INTZ, D3DFMT_D24S8, UnreachableLoad );
- InsertD3D9FormatInfo(&map, GL_DEPTH_COMPONENT32_OES, D3DFMT_INTZ, D3DFMT_D24X8, UnreachableLoad );
- InsertD3D9FormatInfo(&map, GL_DEPTH24_STENCIL8_OES, D3DFMT_INTZ, D3DFMT_D24S8, UnreachableLoad );
- InsertD3D9FormatInfo(&map, GL_STENCIL_INDEX8, D3DFMT_UNKNOWN, D3DFMT_D24S8, UnreachableLoad ); // TODO: What's the texture format?
-
- InsertD3D9FormatInfo(&map, GL_RGBA32F_EXT, D3DFMT_A32B32G32R32F, D3DFMT_A32B32G32R32F, LoadToNative<GLfloat, 4> );
- InsertD3D9FormatInfo(&map, GL_RGB32F_EXT, D3DFMT_A32B32G32R32F, D3DFMT_A32B32G32R32F, LoadToNative3To4<GLfloat, gl::Float32One>);
- InsertD3D9FormatInfo(&map, GL_RG32F_EXT, D3DFMT_G32R32F, D3DFMT_G32R32F, LoadToNative<GLfloat, 2> );
- InsertD3D9FormatInfo(&map, GL_R32F_EXT, D3DFMT_R32F, D3DFMT_R32F, LoadToNative<GLfloat, 1> );
- InsertD3D9FormatInfo(&map, GL_ALPHA32F_EXT, D3DFMT_A32B32G32R32F, D3DFMT_UNKNOWN, LoadA32FToRGBA32F );
- InsertD3D9FormatInfo(&map, GL_LUMINANCE32F_EXT, D3DFMT_A32B32G32R32F, D3DFMT_UNKNOWN, LoadL32FToRGBA32F );
- InsertD3D9FormatInfo(&map, GL_LUMINANCE_ALPHA32F_EXT, D3DFMT_A32B32G32R32F, D3DFMT_UNKNOWN, LoadLA32FToRGBA32F );
-
- InsertD3D9FormatInfo(&map, GL_RGBA16F_EXT, D3DFMT_A16B16G16R16F, D3DFMT_A16B16G16R16F, LoadToNative<GLhalf, 4> );
- InsertD3D9FormatInfo(&map, GL_RGB16F_EXT, D3DFMT_A16B16G16R16F, D3DFMT_A16B16G16R16F, LoadToNative3To4<GLhalf, gl::Float16One> );
- InsertD3D9FormatInfo(&map, GL_RG16F_EXT, D3DFMT_G16R16F, D3DFMT_G16R16F, LoadToNative<GLhalf, 2> );
- InsertD3D9FormatInfo(&map, GL_R16F_EXT, D3DFMT_R16F, D3DFMT_R16F, LoadToNative<GLhalf, 1> );
- InsertD3D9FormatInfo(&map, GL_ALPHA16F_EXT, D3DFMT_A16B16G16R16F, D3DFMT_UNKNOWN, LoadA16FToRGBA16F );
- InsertD3D9FormatInfo(&map, GL_LUMINANCE16F_EXT, D3DFMT_A16B16G16R16F, D3DFMT_UNKNOWN, LoadL16FToRGBA16F );
- InsertD3D9FormatInfo(&map, GL_LUMINANCE_ALPHA16F_EXT, D3DFMT_A16B16G16R16F, D3DFMT_UNKNOWN, LoadLA16FToRGBA16F );
-
- InsertD3D9FormatInfo(&map, GL_ALPHA8_EXT, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, FallbackLoad<gl::supportsSSE2, LoadA8ToBGRA8_SSE2, LoadA8ToBGRA8>);
-
- InsertD3D9FormatInfo(&map, GL_RGB8_OES, D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, LoadRGB8ToBGRX8 );
- InsertD3D9FormatInfo(&map, GL_RGB565, D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, LoadR5G6B5ToBGRA8 );
- InsertD3D9FormatInfo(&map, GL_RGBA8_OES, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, FallbackLoad<gl::supportsSSE2, LoadRGBA8ToBGRA8_SSE2, LoadRGBA8ToBGRA8>);
- InsertD3D9FormatInfo(&map, GL_RGBA4, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, LoadRGBA4ToBGRA8 );
- InsertD3D9FormatInfo(&map, GL_RGB5_A1, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, LoadRGB5A1ToBGRA8 );
- InsertD3D9FormatInfo(&map, GL_R8_EXT, D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, LoadR8ToBGRX8 );
- InsertD3D9FormatInfo(&map, GL_RG8_EXT, D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, LoadRG8ToBGRX8 );
-
- InsertD3D9FormatInfo(&map, GL_BGRA8_EXT, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, LoadToNative<GLubyte, 4> );
- InsertD3D9FormatInfo(&map, GL_BGRA4_ANGLEX, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, LoadBGRA4ToBGRA8 );
- InsertD3D9FormatInfo(&map, GL_BGR5_A1_ANGLEX, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, LoadBGR5A1ToBGRA8 );
-
- InsertD3D9FormatInfo(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, D3DFMT_DXT1, D3DFMT_UNKNOWN, LoadCompressedToNative<4, 4, 8> );
- InsertD3D9FormatInfo(&map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, D3DFMT_DXT1, D3DFMT_UNKNOWN, LoadCompressedToNative<4, 4, 8> );
- InsertD3D9FormatInfo(&map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, D3DFMT_DXT3, D3DFMT_UNKNOWN, LoadCompressedToNative<4, 4, 16> );
- InsertD3D9FormatInfo(&map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, D3DFMT_DXT5, D3DFMT_UNKNOWN, LoadCompressedToNative<4, 4, 16> );
-
- // These formats require checking if the renderer supports D3DFMT_L8 or D3DFMT_A8L8 and
- // then changing the format and loading function appropriately.
- InsertD3D9FormatInfo(&map, GL_LUMINANCE8_EXT, D3DFMT_L8, D3DFMT_UNKNOWN, LoadToNative<GLubyte, 1> );
- InsertD3D9FormatInfo(&map, GL_LUMINANCE8_ALPHA8_EXT, D3DFMT_A8L8, D3DFMT_UNKNOWN, LoadToNative<GLubyte, 2> );
-
- return map;
-}
-
-const TextureFormat &GetTextureFormatInfo(GLenum internalFormat)
-{
- static const D3D9FormatMap formatMap = BuildD3D9FormatMap();
- D3D9FormatMap::const_iterator iter = formatMap.find(internalFormat);
- if (iter != formatMap.end())
- {
- return iter->second;
- }
- else
- {
- static const TextureFormat defaultInfo;
- return defaultInfo;
- }
-}
-
-static GLenum GetDeclTypeComponentType(D3DDECLTYPE declType)
-{
- switch (declType)
- {
- case D3DDECLTYPE_FLOAT1: return GL_FLOAT;
- case D3DDECLTYPE_FLOAT2: return GL_FLOAT;
- case D3DDECLTYPE_FLOAT3: return GL_FLOAT;
- case D3DDECLTYPE_FLOAT4: return GL_FLOAT;
- case D3DDECLTYPE_UBYTE4: return GL_UNSIGNED_INT;
- case D3DDECLTYPE_SHORT2: return GL_INT;
- case D3DDECLTYPE_SHORT4: return GL_INT;
- case D3DDECLTYPE_UBYTE4N: return GL_UNSIGNED_NORMALIZED;
- case D3DDECLTYPE_SHORT4N: return GL_SIGNED_NORMALIZED;
- case D3DDECLTYPE_USHORT4N: return GL_UNSIGNED_NORMALIZED;
- case D3DDECLTYPE_SHORT2N: return GL_SIGNED_NORMALIZED;
- case D3DDECLTYPE_USHORT2N: return GL_UNSIGNED_NORMALIZED;
- default: UNREACHABLE(); return GL_NONE;
- }
-}
-
-// Attribute format conversion
-enum { NUM_GL_VERTEX_ATTRIB_TYPES = 6 };
-
-struct TranslationDescription
-{
- DWORD capsFlag;
- VertexFormat preferredConversion;
- VertexFormat fallbackConversion;
-};
-
-// Mapping from OpenGL-ES vertex attrib type to D3D decl type:
-//
-// BYTE SHORT (Cast)
-// BYTE-norm FLOAT (Normalize) (can't be exactly represented as SHORT-norm)
-// UNSIGNED_BYTE UBYTE4 (Identity) or SHORT (Cast)
-// UNSIGNED_BYTE-norm UBYTE4N (Identity) or FLOAT (Normalize)
-// SHORT SHORT (Identity)
-// SHORT-norm SHORT-norm (Identity) or FLOAT (Normalize)
-// UNSIGNED_SHORT FLOAT (Cast)
-// UNSIGNED_SHORT-norm USHORT-norm (Identity) or FLOAT (Normalize)
-// FIXED (not in WebGL) FLOAT (FixedToFloat)
-// FLOAT FLOAT (Identity)
-
-// GLToCType maps from GL type (as GLenum) to the C typedef.
-template <GLenum GLType> struct GLToCType { };
-
-template <> struct GLToCType<GL_BYTE> { typedef GLbyte type; };
-template <> struct GLToCType<GL_UNSIGNED_BYTE> { typedef GLubyte type; };
-template <> struct GLToCType<GL_SHORT> { typedef GLshort type; };
-template <> struct GLToCType<GL_UNSIGNED_SHORT> { typedef GLushort type; };
-template <> struct GLToCType<GL_FIXED> { typedef GLuint type; };
-template <> struct GLToCType<GL_FLOAT> { typedef GLfloat type; };
-
-// This differs from D3DDECLTYPE in that it is unsized. (Size expansion is applied last.)
-enum D3DVertexType
-{
- D3DVT_FLOAT,
- D3DVT_SHORT,
- D3DVT_SHORT_NORM,
- D3DVT_UBYTE,
- D3DVT_UBYTE_NORM,
- D3DVT_USHORT_NORM
-};
-
-// D3DToCType maps from D3D vertex type (as enum D3DVertexType) to the corresponding C type.
-template <unsigned int D3DType> struct D3DToCType { };
-
-template <> struct D3DToCType<D3DVT_FLOAT> { typedef float type; };
-template <> struct D3DToCType<D3DVT_SHORT> { typedef short type; };
-template <> struct D3DToCType<D3DVT_SHORT_NORM> { typedef short type; };
-template <> struct D3DToCType<D3DVT_UBYTE> { typedef unsigned char type; };
-template <> struct D3DToCType<D3DVT_UBYTE_NORM> { typedef unsigned char type; };
-template <> struct D3DToCType<D3DVT_USHORT_NORM> { typedef unsigned short type; };
-
-// Encode the type/size combinations that D3D permits. For each type/size it expands to a widener that will provide the appropriate final size.
-template <unsigned int type, int size> struct WidenRule { };
-
-template <int size> struct WidenRule<D3DVT_FLOAT, size> : NoWiden<size> { };
-template <int size> struct WidenRule<D3DVT_SHORT, size> : WidenToEven<size> { };
-template <int size> struct WidenRule<D3DVT_SHORT_NORM, size> : WidenToEven<size> { };
-template <int size> struct WidenRule<D3DVT_UBYTE, size> : WidenToFour<size> { };
-template <int size> struct WidenRule<D3DVT_UBYTE_NORM, size> : WidenToFour<size> { };
-template <int size> struct WidenRule<D3DVT_USHORT_NORM, size> : WidenToEven<size> { };
-
-// VertexTypeFlags encodes the D3DCAPS9::DeclType flag and vertex declaration flag for each D3D vertex type & size combination.
-template <unsigned int d3dtype, int size> struct VertexTypeFlags { };
-
-template <unsigned int _capflag, unsigned int _declflag>
-struct VertexTypeFlagsHelper
-{
- enum { capflag = _capflag };
- enum { declflag = _declflag };
-};
-
-template <> struct VertexTypeFlags<D3DVT_FLOAT, 1> : VertexTypeFlagsHelper<0, D3DDECLTYPE_FLOAT1> { };
-template <> struct VertexTypeFlags<D3DVT_FLOAT, 2> : VertexTypeFlagsHelper<0, D3DDECLTYPE_FLOAT2> { };
-template <> struct VertexTypeFlags<D3DVT_FLOAT, 3> : VertexTypeFlagsHelper<0, D3DDECLTYPE_FLOAT3> { };
-template <> struct VertexTypeFlags<D3DVT_FLOAT, 4> : VertexTypeFlagsHelper<0, D3DDECLTYPE_FLOAT4> { };
-template <> struct VertexTypeFlags<D3DVT_SHORT, 2> : VertexTypeFlagsHelper<0, D3DDECLTYPE_SHORT2> { };
-template <> struct VertexTypeFlags<D3DVT_SHORT, 4> : VertexTypeFlagsHelper<0, D3DDECLTYPE_SHORT4> { };
-template <> struct VertexTypeFlags<D3DVT_SHORT_NORM, 2> : VertexTypeFlagsHelper<D3DDTCAPS_SHORT2N, D3DDECLTYPE_SHORT2N> { };
-template <> struct VertexTypeFlags<D3DVT_SHORT_NORM, 4> : VertexTypeFlagsHelper<D3DDTCAPS_SHORT4N, D3DDECLTYPE_SHORT4N> { };
-template <> struct VertexTypeFlags<D3DVT_UBYTE, 4> : VertexTypeFlagsHelper<D3DDTCAPS_UBYTE4, D3DDECLTYPE_UBYTE4> { };
-template <> struct VertexTypeFlags<D3DVT_UBYTE_NORM, 4> : VertexTypeFlagsHelper<D3DDTCAPS_UBYTE4N, D3DDECLTYPE_UBYTE4N> { };
-template <> struct VertexTypeFlags<D3DVT_USHORT_NORM, 2> : VertexTypeFlagsHelper<D3DDTCAPS_USHORT2N, D3DDECLTYPE_USHORT2N> { };
-template <> struct VertexTypeFlags<D3DVT_USHORT_NORM, 4> : VertexTypeFlagsHelper<D3DDTCAPS_USHORT4N, D3DDECLTYPE_USHORT4N> { };
-
-
-// VertexTypeMapping maps GL type & normalized flag to preferred and fallback D3D vertex types (as D3DVertexType enums).
-template <GLenum GLtype, bool normalized> struct VertexTypeMapping { };
-
-template <D3DVertexType Preferred, D3DVertexType Fallback = Preferred>
-struct VertexTypeMappingBase
-{
- enum { preferred = Preferred };
- enum { fallback = Fallback };
-};
-
-template <> struct VertexTypeMapping<GL_BYTE, false> : VertexTypeMappingBase<D3DVT_SHORT> { }; // Cast
-template <> struct VertexTypeMapping<GL_BYTE, true> : VertexTypeMappingBase<D3DVT_FLOAT> { }; // Normalize
-template <> struct VertexTypeMapping<GL_UNSIGNED_BYTE, false> : VertexTypeMappingBase<D3DVT_UBYTE, D3DVT_FLOAT> { }; // Identity, Cast
-template <> struct VertexTypeMapping<GL_UNSIGNED_BYTE, true> : VertexTypeMappingBase<D3DVT_UBYTE_NORM, D3DVT_FLOAT> { }; // Identity, Normalize
-template <> struct VertexTypeMapping<GL_SHORT, false> : VertexTypeMappingBase<D3DVT_SHORT> { }; // Identity
-template <> struct VertexTypeMapping<GL_SHORT, true> : VertexTypeMappingBase<D3DVT_SHORT_NORM, D3DVT_FLOAT> { }; // Cast, Normalize
-template <> struct VertexTypeMapping<GL_UNSIGNED_SHORT, false> : VertexTypeMappingBase<D3DVT_FLOAT> { }; // Cast
-template <> struct VertexTypeMapping<GL_UNSIGNED_SHORT, true> : VertexTypeMappingBase<D3DVT_USHORT_NORM, D3DVT_FLOAT> { }; // Cast, Normalize
-template <bool normalized> struct VertexTypeMapping<GL_FIXED, normalized> : VertexTypeMappingBase<D3DVT_FLOAT> { }; // FixedToFloat
-template <bool normalized> struct VertexTypeMapping<GL_FLOAT, normalized> : VertexTypeMappingBase<D3DVT_FLOAT> { }; // Identity
-
-
-// Given a GL type & norm flag and a D3D type, ConversionRule provides the type conversion rule (Cast, Normalize, Identity, FixedToFloat).
-// The conversion rules themselves are defined in vertexconversion.h.
-
-// Almost all cases are covered by Cast (including those that are actually Identity since Cast<T,T> knows it's an identity mapping).
-template <GLenum fromType, bool normalized, unsigned int toType>
-struct ConversionRule : Cast<typename GLToCType<fromType>::type, typename D3DToCType<toType>::type> { };
-
-// All conversions from normalized types to float use the Normalize operator.
-template <GLenum fromType> struct ConversionRule<fromType, true, D3DVT_FLOAT> : Normalize<typename GLToCType<fromType>::type> { };
-
-// Use a full specialization for this so that it preferentially matches ahead of the generic normalize-to-float rules.
-template <> struct ConversionRule<GL_FIXED, true, D3DVT_FLOAT> : FixedToFloat<GLint, 16> { };
-template <> struct ConversionRule<GL_FIXED, false, D3DVT_FLOAT> : FixedToFloat<GLint, 16> { };
-
-// A 2-stage construction is used for DefaultVertexValues because float must use SimpleDefaultValues (i.e. 0/1)
-// whether it is normalized or not.
-template <class T, bool normalized> struct DefaultVertexValuesStage2 { };
-
-template <class T> struct DefaultVertexValuesStage2<T, true> : NormalizedDefaultValues<T> { };
-template <class T> struct DefaultVertexValuesStage2<T, false> : SimpleDefaultValues<T> { };
-
-// Work out the default value rule for a D3D type (expressed as the C type) and
-template <class T, bool normalized> struct DefaultVertexValues : DefaultVertexValuesStage2<T, normalized> { };
-template <bool normalized> struct DefaultVertexValues<float, normalized> : SimpleDefaultValues<float> { };
-
-// Policy rules for use with Converter, to choose whether to use the preferred or fallback conversion.
-// The fallback conversion produces an output that all D3D9 devices must support.
-template <class T> struct UsePreferred { enum { type = T::preferred }; };
-template <class T> struct UseFallback { enum { type = T::fallback }; };
-
-// Converter ties it all together. Given an OpenGL type/norm/size and choice of preferred/fallback conversion,
-// it provides all the members of the appropriate VertexDataConverter, the D3DCAPS9::DeclTypes flag in cap flag
-// and the D3DDECLTYPE member needed for the vertex declaration in declflag.
-template <GLenum fromType, bool normalized, int size, template <class T> class PreferenceRule>
-struct Converter
- : VertexDataConverter<typename GLToCType<fromType>::type,
- WidenRule<PreferenceRule< VertexTypeMapping<fromType, normalized> >::type, size>,
- ConversionRule<fromType,
- normalized,
- PreferenceRule< VertexTypeMapping<fromType, normalized> >::type>,
- DefaultVertexValues<typename D3DToCType<PreferenceRule< VertexTypeMapping<fromType, normalized> >::type>::type, normalized > >
-{
-private:
- enum { d3dtype = PreferenceRule< VertexTypeMapping<fromType, normalized> >::type };
- enum { d3dsize = WidenRule<d3dtype, size>::finalWidth };
-
-public:
- enum { capflag = VertexTypeFlags<d3dtype, d3dsize>::capflag };
- enum { declflag = VertexTypeFlags<d3dtype, d3dsize>::declflag };
-};
-
-VertexFormat::VertexFormat()
- : conversionType(VERTEX_CONVERT_NONE),
- outputElementSize(0),
- copyFunction(NULL),
- nativeFormat(D3DDECLTYPE_UNUSED),
- componentType(GL_NONE)
-{
-}
-
-// Initialize a TranslationInfo
-VertexFormat CreateVertexFormatInfo(bool identity, size_t elementSize, VertexCopyFunction copyFunc, D3DDECLTYPE nativeFormat)
-{
- VertexFormat formatInfo;
- formatInfo.conversionType = identity ? VERTEX_CONVERT_NONE : VERTEX_CONVERT_CPU;
- formatInfo.outputElementSize = elementSize;
- formatInfo.copyFunction = copyFunc;
- formatInfo.nativeFormat = nativeFormat;
- formatInfo.componentType = GetDeclTypeComponentType(nativeFormat);
- return formatInfo;
-}
-
-#define TRANSLATION(type, norm, size, preferred) \
- CreateVertexFormatInfo \
- ( \
- Converter<type, norm, size, preferred>::identity, \
- Converter<type, norm, size, preferred>::finalSize, \
- Converter<type, norm, size, preferred>::convertArray, \
- static_cast<D3DDECLTYPE>(Converter<type, norm, size, preferred>::declflag) \
- )
-
-#define TRANSLATION_FOR_TYPE_NORM_SIZE(type, norm, size) \
- { \
- Converter<type, norm, size, UsePreferred>::capflag, \
- TRANSLATION(type, norm, size, UsePreferred), \
- TRANSLATION(type, norm, size, UseFallback) \
- }
-
-#define TRANSLATIONS_FOR_TYPE(type) \
- { \
- { TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 1), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 2), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 3), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 4) }, \
- { TRANSLATION_FOR_TYPE_NORM_SIZE(type, true, 1), TRANSLATION_FOR_TYPE_NORM_SIZE(type, true, 2), TRANSLATION_FOR_TYPE_NORM_SIZE(type, true, 3), TRANSLATION_FOR_TYPE_NORM_SIZE(type, true, 4) }, \
- }
-
-#define TRANSLATIONS_FOR_TYPE_NO_NORM(type) \
- { \
- { TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 1), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 2), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 3), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 4) }, \
- { TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 1), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 2), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 3), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 4) }, \
- }
-
-static inline unsigned int ComputeTypeIndex(GLenum type)
-{
- switch (type)
- {
- case GL_BYTE: return 0;
- case GL_UNSIGNED_BYTE: return 1;
- case GL_SHORT: return 2;
- case GL_UNSIGNED_SHORT: return 3;
- case GL_FIXED: return 4;
- case GL_FLOAT: return 5;
-
- default: UNREACHABLE(); return 5;
- }
-}
-
-const VertexFormat &GetVertexFormatInfo(DWORD supportedDeclTypes, const gl::VertexFormat &vertexFormat)
-{
- static bool initialized = false;
- static DWORD intializedDeclTypes = 0;
- static VertexFormat formatConverters[NUM_GL_VERTEX_ATTRIB_TYPES][2][4];
- if (!initialized)
- {
- const TranslationDescription translations[NUM_GL_VERTEX_ATTRIB_TYPES][2][4] = // [GL types as enumerated by typeIndex()][normalized][size-1]
- {
- TRANSLATIONS_FOR_TYPE(GL_BYTE),
- TRANSLATIONS_FOR_TYPE(GL_UNSIGNED_BYTE),
- TRANSLATIONS_FOR_TYPE(GL_SHORT),
- TRANSLATIONS_FOR_TYPE(GL_UNSIGNED_SHORT),
- TRANSLATIONS_FOR_TYPE_NO_NORM(GL_FIXED),
- TRANSLATIONS_FOR_TYPE_NO_NORM(GL_FLOAT)
- };
- for (unsigned int i = 0; i < NUM_GL_VERTEX_ATTRIB_TYPES; i++)
- {
- for (unsigned int j = 0; j < 2; j++)
- {
- for (unsigned int k = 0; k < 4; k++)
- {
- if (translations[i][j][k].capsFlag == 0 || (supportedDeclTypes & translations[i][j][k].capsFlag) != 0)
- {
- formatConverters[i][j][k] = translations[i][j][k].preferredConversion;
- }
- else
- {
- formatConverters[i][j][k] = translations[i][j][k].fallbackConversion;
- }
- }
- }
- }
- initialized = true;
- intializedDeclTypes = supportedDeclTypes;
- }
-
- ASSERT(intializedDeclTypes == supportedDeclTypes);
-
- // Pure integer attributes only supported in ES3.0
- ASSERT(!vertexFormat.mPureInteger);
- return formatConverters[ComputeTypeIndex(vertexFormat.mType)][vertexFormat.mNormalized][vertexFormat.mComponents - 1];
-}
-
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/formatutils9.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/formatutils9.h
deleted file mode 100644
index f26fe43b36..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/formatutils9.h
+++ /dev/null
@@ -1,74 +0,0 @@
-//
-// Copyright (c) 2013-2014 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.
-//
-
-// formatutils9.h: Queries for GL image formats and their translations to D3D9
-// formats.
-
-#ifndef LIBGLESV2_RENDERER_FORMATUTILS9_H_
-#define LIBGLESV2_RENDERER_FORMATUTILS9_H_
-
-#include "libGLESv2/formatutils.h"
-
-#include <map>
-
-namespace rx
-{
-
-class Renderer9;
-
-namespace d3d9
-{
-
-typedef std::map<std::pair<GLenum, GLenum>, ColorCopyFunction> FastCopyFunctionMap;
-
-struct D3DFormat
-{
- D3DFormat();
-
- GLuint pixelBytes;
- GLuint blockWidth;
- GLuint blockHeight;
-
- GLenum internalFormat;
-
- MipGenerationFunction mipGenerationFunction;
- ColorReadFunction colorReadFunction;
-
- FastCopyFunctionMap fastCopyFunctions;
- ColorCopyFunction getFastCopyFunction(GLenum format, GLenum type) const;
-};
-const D3DFormat &GetD3DFormatInfo(D3DFORMAT format);
-
-struct VertexFormat
-{
- VertexFormat();
-
- VertexConversionType conversionType;
- size_t outputElementSize;
- VertexCopyFunction copyFunction;
- D3DDECLTYPE nativeFormat;
- GLenum componentType;
-};
-const VertexFormat &GetVertexFormatInfo(DWORD supportedDeclTypes, const gl::VertexFormat &vertexFormat);
-
-struct TextureFormat
-{
- TextureFormat();
-
- D3DFORMAT texFormat;
- D3DFORMAT renderFormat;
-
- InitializeTextureDataFunction dataInitializerFunction;
-
- LoadImageFunction loadFunction;
-};
-const TextureFormat &GetTextureFormatInfo(GLenum internalFormat);
-
-}
-
-}
-
-#endif // LIBGLESV2_RENDERER_FORMATUTILS9_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/renderer9_utils.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/renderer9_utils.cpp
deleted file mode 100644
index a98b2081f3..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/renderer9_utils.cpp
+++ /dev/null
@@ -1,558 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// renderer9_utils.cpp: Conversion functions and other utility routines
-// specific to the D3D9 renderer.
-
-#include "libGLESv2/renderer/d3d/d3d9/renderer9_utils.h"
-#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h"
-#include "libGLESv2/renderer/Workarounds.h"
-#include "libGLESv2/formatutils.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/renderer/d3d/d3d9/RenderTarget9.h"
-
-#include "common/mathutil.h"
-#include "common/debug.h"
-
-#include "third_party/systeminfo/SystemInfo.h"
-
-namespace rx
-{
-
-namespace gl_d3d9
-{
-
-D3DCMPFUNC ConvertComparison(GLenum comparison)
-{
- D3DCMPFUNC d3dComp = D3DCMP_ALWAYS;
- switch (comparison)
- {
- case GL_NEVER: d3dComp = D3DCMP_NEVER; break;
- case GL_ALWAYS: d3dComp = D3DCMP_ALWAYS; break;
- case GL_LESS: d3dComp = D3DCMP_LESS; break;
- case GL_LEQUAL: d3dComp = D3DCMP_LESSEQUAL; break;
- case GL_EQUAL: d3dComp = D3DCMP_EQUAL; break;
- case GL_GREATER: d3dComp = D3DCMP_GREATER; break;
- case GL_GEQUAL: d3dComp = D3DCMP_GREATEREQUAL; break;
- case GL_NOTEQUAL: d3dComp = D3DCMP_NOTEQUAL; break;
- default: UNREACHABLE();
- }
-
- return d3dComp;
-}
-
-D3DCOLOR ConvertColor(gl::ColorF color)
-{
- return D3DCOLOR_RGBA(gl::unorm<8>(color.red),
- gl::unorm<8>(color.green),
- gl::unorm<8>(color.blue),
- gl::unorm<8>(color.alpha));
-}
-
-D3DBLEND ConvertBlendFunc(GLenum blend)
-{
- D3DBLEND d3dBlend = D3DBLEND_ZERO;
-
- switch (blend)
- {
- case GL_ZERO: d3dBlend = D3DBLEND_ZERO; break;
- case GL_ONE: d3dBlend = D3DBLEND_ONE; break;
- case GL_SRC_COLOR: d3dBlend = D3DBLEND_SRCCOLOR; break;
- case GL_ONE_MINUS_SRC_COLOR: d3dBlend = D3DBLEND_INVSRCCOLOR; break;
- case GL_DST_COLOR: d3dBlend = D3DBLEND_DESTCOLOR; break;
- case GL_ONE_MINUS_DST_COLOR: d3dBlend = D3DBLEND_INVDESTCOLOR; break;
- case GL_SRC_ALPHA: d3dBlend = D3DBLEND_SRCALPHA; break;
- case GL_ONE_MINUS_SRC_ALPHA: d3dBlend = D3DBLEND_INVSRCALPHA; break;
- case GL_DST_ALPHA: d3dBlend = D3DBLEND_DESTALPHA; break;
- case GL_ONE_MINUS_DST_ALPHA: d3dBlend = D3DBLEND_INVDESTALPHA; break;
- case GL_CONSTANT_COLOR: d3dBlend = D3DBLEND_BLENDFACTOR; break;
- case GL_ONE_MINUS_CONSTANT_COLOR: d3dBlend = D3DBLEND_INVBLENDFACTOR; break;
- case GL_CONSTANT_ALPHA: d3dBlend = D3DBLEND_BLENDFACTOR; break;
- case GL_ONE_MINUS_CONSTANT_ALPHA: d3dBlend = D3DBLEND_INVBLENDFACTOR; break;
- case GL_SRC_ALPHA_SATURATE: d3dBlend = D3DBLEND_SRCALPHASAT; break;
- default: UNREACHABLE();
- }
-
- return d3dBlend;
-}
-
-D3DBLENDOP ConvertBlendOp(GLenum blendOp)
-{
- D3DBLENDOP d3dBlendOp = D3DBLENDOP_ADD;
-
- switch (blendOp)
- {
- case GL_FUNC_ADD: d3dBlendOp = D3DBLENDOP_ADD; break;
- case GL_FUNC_SUBTRACT: d3dBlendOp = D3DBLENDOP_SUBTRACT; break;
- case GL_FUNC_REVERSE_SUBTRACT: d3dBlendOp = D3DBLENDOP_REVSUBTRACT; break;
- case GL_MIN_EXT: d3dBlendOp = D3DBLENDOP_MIN; break;
- case GL_MAX_EXT: d3dBlendOp = D3DBLENDOP_MAX; break;
- default: UNREACHABLE();
- }
-
- return d3dBlendOp;
-}
-
-D3DSTENCILOP ConvertStencilOp(GLenum stencilOp)
-{
- D3DSTENCILOP d3dStencilOp = D3DSTENCILOP_KEEP;
-
- switch (stencilOp)
- {
- case GL_ZERO: d3dStencilOp = D3DSTENCILOP_ZERO; break;
- case GL_KEEP: d3dStencilOp = D3DSTENCILOP_KEEP; break;
- case GL_REPLACE: d3dStencilOp = D3DSTENCILOP_REPLACE; break;
- case GL_INCR: d3dStencilOp = D3DSTENCILOP_INCRSAT; break;
- case GL_DECR: d3dStencilOp = D3DSTENCILOP_DECRSAT; break;
- case GL_INVERT: d3dStencilOp = D3DSTENCILOP_INVERT; break;
- case GL_INCR_WRAP: d3dStencilOp = D3DSTENCILOP_INCR; break;
- case GL_DECR_WRAP: d3dStencilOp = D3DSTENCILOP_DECR; break;
- default: UNREACHABLE();
- }
-
- return d3dStencilOp;
-}
-
-D3DTEXTUREADDRESS ConvertTextureWrap(GLenum wrap)
-{
- D3DTEXTUREADDRESS d3dWrap = D3DTADDRESS_WRAP;
-
- switch (wrap)
- {
- case GL_REPEAT: d3dWrap = D3DTADDRESS_WRAP; break;
- case GL_CLAMP_TO_EDGE: d3dWrap = D3DTADDRESS_CLAMP; break;
- case GL_MIRRORED_REPEAT: d3dWrap = D3DTADDRESS_MIRROR; break;
- default: UNREACHABLE();
- }
-
- return d3dWrap;
-}
-
-D3DCULL ConvertCullMode(GLenum cullFace, GLenum frontFace)
-{
- D3DCULL cull = D3DCULL_CCW;
- switch (cullFace)
- {
- case GL_FRONT:
- cull = (frontFace == GL_CCW ? D3DCULL_CW : D3DCULL_CCW);
- break;
- case GL_BACK:
- cull = (frontFace == GL_CCW ? D3DCULL_CCW : D3DCULL_CW);
- break;
- case GL_FRONT_AND_BACK:
- cull = D3DCULL_NONE; // culling will be handled during draw
- break;
- default: UNREACHABLE();
- }
-
- return cull;
-}
-
-D3DCUBEMAP_FACES ConvertCubeFace(GLenum cubeFace)
-{
- D3DCUBEMAP_FACES face = D3DCUBEMAP_FACE_POSITIVE_X;
-
- switch (cubeFace)
- {
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- face = D3DCUBEMAP_FACE_POSITIVE_X;
- break;
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- face = D3DCUBEMAP_FACE_NEGATIVE_X;
- break;
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- face = D3DCUBEMAP_FACE_POSITIVE_Y;
- break;
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- face = D3DCUBEMAP_FACE_NEGATIVE_Y;
- break;
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- face = D3DCUBEMAP_FACE_POSITIVE_Z;
- break;
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- face = D3DCUBEMAP_FACE_NEGATIVE_Z;
- break;
- default: UNREACHABLE();
- }
-
- return face;
-}
-
-DWORD ConvertColorMask(bool red, bool green, bool blue, bool alpha)
-{
- return (red ? D3DCOLORWRITEENABLE_RED : 0) |
- (green ? D3DCOLORWRITEENABLE_GREEN : 0) |
- (blue ? D3DCOLORWRITEENABLE_BLUE : 0) |
- (alpha ? D3DCOLORWRITEENABLE_ALPHA : 0);
-}
-
-D3DTEXTUREFILTERTYPE ConvertMagFilter(GLenum magFilter, float maxAnisotropy)
-{
- if (maxAnisotropy > 1.0f)
- {
- return D3DTEXF_ANISOTROPIC;
- }
-
- D3DTEXTUREFILTERTYPE d3dMagFilter = D3DTEXF_POINT;
- switch (magFilter)
- {
- case GL_NEAREST: d3dMagFilter = D3DTEXF_POINT; break;
- case GL_LINEAR: d3dMagFilter = D3DTEXF_LINEAR; break;
- default: UNREACHABLE();
- }
-
- return d3dMagFilter;
-}
-
-void ConvertMinFilter(GLenum minFilter, D3DTEXTUREFILTERTYPE *d3dMinFilter, D3DTEXTUREFILTERTYPE *d3dMipFilter, float maxAnisotropy)
-{
- switch (minFilter)
- {
- case GL_NEAREST:
- *d3dMinFilter = D3DTEXF_POINT;
- *d3dMipFilter = D3DTEXF_NONE;
- break;
- case GL_LINEAR:
- *d3dMinFilter = D3DTEXF_LINEAR;
- *d3dMipFilter = D3DTEXF_NONE;
- break;
- case GL_NEAREST_MIPMAP_NEAREST:
- *d3dMinFilter = D3DTEXF_POINT;
- *d3dMipFilter = D3DTEXF_POINT;
- break;
- case GL_LINEAR_MIPMAP_NEAREST:
- *d3dMinFilter = D3DTEXF_LINEAR;
- *d3dMipFilter = D3DTEXF_POINT;
- break;
- case GL_NEAREST_MIPMAP_LINEAR:
- *d3dMinFilter = D3DTEXF_POINT;
- *d3dMipFilter = D3DTEXF_LINEAR;
- break;
- case GL_LINEAR_MIPMAP_LINEAR:
- *d3dMinFilter = D3DTEXF_LINEAR;
- *d3dMipFilter = D3DTEXF_LINEAR;
- break;
- default:
- *d3dMinFilter = D3DTEXF_POINT;
- *d3dMipFilter = D3DTEXF_NONE;
- UNREACHABLE();
- }
-
- if (maxAnisotropy > 1.0f)
- {
- *d3dMinFilter = D3DTEXF_ANISOTROPIC;
- }
-}
-
-D3DMULTISAMPLE_TYPE GetMultisampleType(GLuint samples)
-{
- return (samples > 1) ? static_cast<D3DMULTISAMPLE_TYPE>(samples) : D3DMULTISAMPLE_NONE;
-}
-
-}
-
-namespace d3d9_gl
-{
-
-GLsizei GetSamplesCount(D3DMULTISAMPLE_TYPE type)
-{
- return (type != D3DMULTISAMPLE_NONMASKABLE) ? type : 0;
-}
-
-bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format)
-{
- GLenum internalFormat = d3d9::GetD3DFormatInfo(d3dformat).internalFormat;
- GLenum convertedFormat = gl::GetInternalFormatInfo(internalFormat).format;
- return convertedFormat == format;
-}
-
-static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, IDirect3D9 *d3d9, D3DDEVTYPE deviceType,
- UINT adapter, D3DFORMAT adapterFormat)
-{
- gl::TextureCaps textureCaps;
-
- const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(internalFormat);
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
- if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0)
- {
- textureCaps.texturable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat));
- }
- else
- {
- textureCaps.texturable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat)) &&
- SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_CUBETEXTURE, d3dFormatInfo.texFormat));
- }
-
- textureCaps.filterable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat));
- textureCaps.renderable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, d3dFormatInfo.renderFormat)) ||
- SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, d3dFormatInfo.renderFormat));
-
- textureCaps.sampleCounts.insert(1);
- for (size_t i = D3DMULTISAMPLE_2_SAMPLES; i <= D3DMULTISAMPLE_16_SAMPLES; i++)
- {
- D3DMULTISAMPLE_TYPE multisampleType = D3DMULTISAMPLE_TYPE(i);
-
- HRESULT result = d3d9->CheckDeviceMultiSampleType(adapter, deviceType, d3dFormatInfo.renderFormat, TRUE, multisampleType, NULL);
- if (SUCCEEDED(result))
- {
- textureCaps.sampleCounts.insert(i);
- }
- }
-
- return textureCaps;
-}
-
-void GenerateCaps(IDirect3D9 *d3d9, IDirect3DDevice9 *device, D3DDEVTYPE deviceType, UINT adapter, gl::Caps *caps,
- gl::TextureCapsMap *textureCapsMap, gl::Extensions *extensions)
-{
- D3DCAPS9 deviceCaps;
- if (FAILED(d3d9->GetDeviceCaps(adapter, deviceType, &deviceCaps)))
- {
- // Can't continue with out device caps
- return;
- }
-
- D3DDISPLAYMODE currentDisplayMode;
- d3d9->GetAdapterDisplayMode(adapter, &currentDisplayMode);
-
- GLuint maxSamples = 0;
- const gl::FormatSet &allFormats = gl::GetAllSizedInternalFormats();
- for (gl::FormatSet::const_iterator internalFormat = allFormats.begin(); internalFormat != allFormats.end(); ++internalFormat)
- {
- gl::TextureCaps textureCaps = GenerateTextureFormatCaps(*internalFormat, d3d9, deviceType, adapter,
- currentDisplayMode.Format);
- textureCapsMap->insert(*internalFormat, textureCaps);
-
- maxSamples = std::max(maxSamples, textureCaps.getMaxSamples());
-
- if (gl::GetInternalFormatInfo(*internalFormat).compressed)
- {
- caps->compressedTextureFormats.push_back(*internalFormat);
- }
- }
-
- // GL core feature limits
- caps->maxElementIndex = static_cast<GLint64>(std::numeric_limits<unsigned int>::max());
-
- // 3D textures are unimplemented in D3D9
- caps->max3DTextureSize = 1;
-
- // Only one limit in GL, use the minimum dimension
- caps->max2DTextureSize = std::min(deviceCaps.MaxTextureWidth, deviceCaps.MaxTextureHeight);
-
- // D3D treats cube maps as a special case of 2D textures
- caps->maxCubeMapTextureSize = caps->max2DTextureSize;
-
- // Array textures are not available in D3D9
- caps->maxArrayTextureLayers = 1;
-
- // ES3-only feature
- caps->maxLODBias = 0.0f;
-
- // No specific limits on render target size, maximum 2D texture size is equivalent
- caps->maxRenderbufferSize = caps->max2DTextureSize;
-
- // Draw buffers are not supported in D3D9
- caps->maxDrawBuffers = 1;
- caps->maxColorAttachments = 1;
-
- // No specific limits on viewport size, maximum 2D texture size is equivalent
- caps->maxViewportWidth = caps->max2DTextureSize;
- caps->maxViewportHeight = caps->maxViewportWidth;
-
- // Point size is clamped to 1.0f when the shader model is less than 3
- caps->minAliasedPointSize = 1.0f;
- caps->maxAliasedPointSize = ((D3DSHADER_VERSION_MAJOR(deviceCaps.PixelShaderVersion) >= 3) ? deviceCaps.MaxPointSize : 1.0f);
-
- // Wide lines not supported
- caps->minAliasedLineWidth = 1.0f;
- caps->maxAliasedLineWidth = 1.0f;
-
- // Primitive count limits (unused in ES2)
- caps->maxElementsIndices = 0;
- caps->maxElementsVertices = 0;
-
- // Program and shader binary formats (no supported shader binary formats)
- caps->programBinaryFormats.push_back(GL_PROGRAM_BINARY_ANGLE);
-
- // WaitSync is ES3-only, set to zero
- caps->maxServerWaitTimeout = 0;
-
- // Vertex shader limits
- caps->maxVertexAttributes = 16;
-
- const size_t reservedVertexUniformVectors = 2; // dx_ViewAdjust and dx_DepthRange.
- const size_t MAX_VERTEX_CONSTANT_VECTORS_D3D9 = 256;
- caps->maxVertexUniformVectors = MAX_VERTEX_CONSTANT_VECTORS_D3D9 - reservedVertexUniformVectors;
- caps->maxVertexUniformComponents = caps->maxVertexUniformVectors * 4;
-
- caps->maxVertexUniformBlocks = 0;
-
- // SM3 only supports 11 output variables, with a special 12th register for PSIZE.
- const size_t MAX_VERTEX_OUTPUT_VECTORS_SM3 = 9;
- const size_t MAX_VERTEX_OUTPUT_VECTORS_SM2 = 7;
- caps->maxVertexOutputComponents = ((deviceCaps.VertexShaderVersion >= D3DVS_VERSION(3, 0)) ? MAX_VERTEX_OUTPUT_VECTORS_SM3
- : MAX_VERTEX_OUTPUT_VECTORS_SM2) * 4;
-
- // Only Direct3D 10 ready devices support all the necessary vertex texture formats.
- // We test this using D3D9 by checking support for the R16F format.
- if (deviceCaps.VertexShaderVersion >= D3DVS_VERSION(3, 0) &&
- SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, currentDisplayMode.Format,
- D3DUSAGE_QUERY_VERTEXTEXTURE, D3DRTYPE_TEXTURE, D3DFMT_R16F)))
- {
- const size_t MAX_TEXTURE_IMAGE_UNITS_VTF_SM3 = 4;
- caps->maxVertexTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS_VTF_SM3;
- }
- else
- {
- caps->maxVertexTextureImageUnits = 0;
- }
-
- // Fragment shader limits
- const size_t reservedPixelUniformVectors = 3; // dx_ViewCoords, dx_DepthFront and dx_DepthRange.
-
- const size_t MAX_PIXEL_CONSTANT_VECTORS_SM3 = 224;
- const size_t MAX_PIXEL_CONSTANT_VECTORS_SM2 = 32;
- caps->maxFragmentUniformVectors = ((deviceCaps.PixelShaderVersion >= D3DPS_VERSION(3, 0)) ? MAX_PIXEL_CONSTANT_VECTORS_SM3
- : MAX_PIXEL_CONSTANT_VECTORS_SM2) - reservedPixelUniformVectors;
- caps->maxFragmentUniformComponents = caps->maxFragmentUniformVectors * 4;
- caps->maxFragmentUniformBlocks = 0;
- caps->maxFragmentInputComponents = caps->maxVertexOutputComponents;
- caps->maxTextureImageUnits = 16;
- caps->minProgramTexelOffset = 0;
- caps->maxProgramTexelOffset = 0;
-
- // Aggregate shader limits (unused in ES2)
- caps->maxUniformBufferBindings = 0;
- caps->maxUniformBlockSize = 0;
- caps->uniformBufferOffsetAlignment = 0;
- caps->maxCombinedUniformBlocks = 0;
- caps->maxCombinedVertexUniformComponents = 0;
- caps->maxCombinedFragmentUniformComponents = 0;
- caps->maxVaryingComponents = 0;
-
- // Aggregate shader limits
- caps->maxVaryingVectors = caps->maxVertexOutputComponents / 4;
- caps->maxCombinedTextureImageUnits = caps->maxVertexTextureImageUnits + caps->maxTextureImageUnits;
-
- // Transform feedback limits
- caps->maxTransformFeedbackInterleavedComponents = 0;
- caps->maxTransformFeedbackSeparateAttributes = 0;
- caps->maxTransformFeedbackSeparateComponents = 0;
-
- // GL extension support
- extensions->setTextureExtensionSupport(*textureCapsMap);
- extensions->elementIndexUint = deviceCaps.MaxVertexIndex >= (1 << 16);
- extensions->packedDepthStencil = true;
- extensions->getProgramBinary = true;
- extensions->rgb8rgba8 = true;
- extensions->readFormatBGRA = true;
- extensions->pixelBufferObject = false;
- extensions->mapBuffer = false;
- extensions->mapBufferRange = false;
-
- // ATI cards on XP have problems with non-power-of-two textures.
- D3DADAPTER_IDENTIFIER9 adapterId = { 0 };
- if (SUCCEEDED(d3d9->GetAdapterIdentifier(adapter, 0, &adapterId)))
- {
- extensions->textureNPOT = !(deviceCaps.TextureCaps & D3DPTEXTURECAPS_POW2) &&
- !(deviceCaps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP_POW2) &&
- !(deviceCaps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) &&
- !(!isWindowsVistaOrGreater() && adapterId.VendorId == VENDOR_ID_AMD);
- }
- else
- {
- extensions->textureNPOT = false;
- }
-
- extensions->drawBuffers = false;
- extensions->textureStorage = true;
-
- // Must support a minimum of 2:1 anisotropy for max anisotropy to be considered supported, per the spec
- extensions->textureFilterAnisotropic = (deviceCaps.RasterCaps & D3DPRASTERCAPS_ANISOTROPY) != 0 && deviceCaps.MaxAnisotropy >= 2;
- extensions->maxTextureAnisotropy = static_cast<GLfloat>(deviceCaps.MaxAnisotropy);
-
- // Check occlusion query support by trying to create one
- IDirect3DQuery9 *occlusionQuery = NULL;
- extensions->occlusionQueryBoolean = SUCCEEDED(device->CreateQuery(D3DQUERYTYPE_OCCLUSION, &occlusionQuery)) && occlusionQuery;
- SafeRelease(occlusionQuery);
-
- // Check event query support by trying to create one
- IDirect3DQuery9 *eventQuery = NULL;
- extensions->fence = SUCCEEDED(device->CreateQuery(D3DQUERYTYPE_EVENT, &eventQuery)) && eventQuery;
- SafeRelease(eventQuery);
-
- extensions->timerQuery = false; // Unimplemented
- extensions->robustness = true;
- extensions->blendMinMax = true;
- extensions->framebufferBlit = true;
- extensions->framebufferMultisample = true;
- extensions->maxSamples = maxSamples;
- extensions->instancedArrays = deviceCaps.PixelShaderVersion >= D3DPS_VERSION(3, 0);
- extensions->packReverseRowOrder = true;
- extensions->standardDerivatives = (deviceCaps.PS20Caps.Caps & D3DPS20CAPS_GRADIENTINSTRUCTIONS) != 0;
- extensions->shaderTextureLOD = true;
- extensions->fragDepth = true;
- extensions->textureUsage = true;
- extensions->translatedShaderSource = true;
- extensions->colorBufferFloat = false;
-}
-
-}
-
-namespace d3d9
-{
-
-GLuint ComputeBlockSize(D3DFORMAT format, GLuint width, GLuint height)
-{
- const D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(format);
- GLuint numBlocksWide = (width + d3dFormatInfo.blockWidth - 1) / d3dFormatInfo.blockWidth;
- GLuint numBlocksHight = (height + d3dFormatInfo.blockHeight - 1) / d3dFormatInfo.blockHeight;
- return (d3dFormatInfo.pixelBytes * numBlocksWide * numBlocksHight);
-}
-
-void MakeValidSize(bool isImage, D3DFORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset)
-{
- const D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(format);
-
- int upsampleCount = 0;
- // Don't expand the size of full textures that are at least (blockWidth x blockHeight) already.
- if (isImage || *requestWidth < static_cast<GLsizei>(d3dFormatInfo.blockWidth) ||
- *requestHeight < static_cast<GLsizei>(d3dFormatInfo.blockHeight))
- {
- while (*requestWidth % d3dFormatInfo.blockWidth != 0 || *requestHeight % d3dFormatInfo.blockHeight != 0)
- {
- *requestWidth <<= 1;
- *requestHeight <<= 1;
- upsampleCount++;
- }
- }
- *levelOffset = upsampleCount;
-}
-
-gl::Error GetAttachmentRenderTarget(gl::FramebufferAttachment *attachment, RenderTarget9 **outRT)
-{
- RenderTarget *renderTarget = NULL;
- gl::Error error = rx::GetAttachmentRenderTarget(attachment, &renderTarget);
- if (error.isError())
- {
- return error;
- }
- *outRT = RenderTarget9::makeRenderTarget9(renderTarget);
- return gl::Error(GL_NO_ERROR);
-}
-
-Workarounds GenerateWorkarounds()
-{
- Workarounds workarounds;
- workarounds.mrtPerfWorkaround = true;
- workarounds.setDataFasterThanImageUpload = false;
- return workarounds;
-}
-
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/renderer9_utils.h b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/renderer9_utils.h
deleted file mode 100644
index 9760b9735a..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/renderer9_utils.h
+++ /dev/null
@@ -1,86 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// renderer9_utils.h: Conversion functions and other utility routines
-// specific to the D3D9 renderer
-
-#ifndef LIBGLESV2_RENDERER_RENDERER9_UTILS_H
-#define LIBGLESV2_RENDERER_RENDERER9_UTILS_H
-
-#include "libGLESv2/angletypes.h"
-#include "libGLESv2/Caps.h"
-#include "libGLESv2/Error.h"
-
-namespace gl
-{
-class FramebufferAttachment;
-}
-
-namespace rx
-{
-class RenderTarget9;
-struct Workarounds;
-
-namespace gl_d3d9
-{
-
-D3DCMPFUNC ConvertComparison(GLenum comparison);
-D3DCOLOR ConvertColor(gl::ColorF color);
-D3DBLEND ConvertBlendFunc(GLenum blend);
-D3DBLENDOP ConvertBlendOp(GLenum blendOp);
-D3DSTENCILOP ConvertStencilOp(GLenum stencilOp);
-D3DTEXTUREADDRESS ConvertTextureWrap(GLenum wrap);
-D3DCULL ConvertCullMode(GLenum cullFace, GLenum frontFace);
-D3DCUBEMAP_FACES ConvertCubeFace(GLenum cubeFace);
-DWORD ConvertColorMask(bool red, bool green, bool blue, bool alpha);
-D3DTEXTUREFILTERTYPE ConvertMagFilter(GLenum magFilter, float maxAnisotropy);
-void ConvertMinFilter(GLenum minFilter, D3DTEXTUREFILTERTYPE *d3dMinFilter, D3DTEXTUREFILTERTYPE *d3dMipFilter, float maxAnisotropy);
-
-D3DMULTISAMPLE_TYPE GetMultisampleType(GLuint samples);
-
-}
-
-namespace d3d9_gl
-{
-
-GLsizei GetSamplesCount(D3DMULTISAMPLE_TYPE type);
-
-bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format);
-
-void GenerateCaps(IDirect3D9 *d3d9, IDirect3DDevice9 *device, D3DDEVTYPE deviceType, UINT adapter, gl::Caps *caps,
- gl::TextureCapsMap *textureCapsMap, gl::Extensions *extensions);
-
-}
-
-namespace d3d9
-{
-
-GLuint ComputeBlockSize(D3DFORMAT format, GLuint width, GLuint height);
-
-void MakeValidSize(bool isImage, D3DFORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset);
-
-inline bool isDeviceLostError(HRESULT errorCode)
-{
- switch (errorCode)
- {
- case D3DERR_DRIVERINTERNALERROR:
- case D3DERR_DEVICELOST:
- case D3DERR_DEVICEHUNG:
- case D3DERR_DEVICEREMOVED:
- return true;
- default:
- return false;
- }
-}
-
-gl::Error GetAttachmentRenderTarget(gl::FramebufferAttachment *attachment, RenderTarget9 **outRT);
-Workarounds GenerateWorkarounds();
-
-}
-
-}
-
-#endif // LIBGLESV2_RENDERER_RENDERER9_UTILS_H
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/Blit.ps b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/Blit.ps
deleted file mode 100644
index eb43eb3e7a..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/Blit.ps
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-sampler2D tex : s0;
-
-uniform float4 mult : c0;
-uniform float4 add : c1;
-
-// Passthrough Pixel Shader
-// Outputs texture 0 sampled at texcoord 0.
-float4 PS_passthrough(float4 texcoord : TEXCOORD0) : COLOR
-{
- return tex2D(tex, texcoord.xy);
-};
-
-// Luminance Conversion Pixel Shader
-// Performs a mad operation using the LA data from the texture with mult.xw and add.xw.
-// Returns data in the form of llla
-float4 PS_luminance(float4 texcoord : TEXCOORD0) : COLOR
-{
- return (tex2D(tex, texcoord.xy).xw * mult.xw + add.xw).xxxy;
-};
-
-// RGB/A Component Mask Pixel Shader
-// Performs a mad operation using the texture's RGBA data with mult.xyzw and add.xyzw.
-// Returns data in the form of rgba
-float4 PS_componentmask(float4 texcoord : TEXCOORD0) : COLOR
-{
- return tex2D(tex, texcoord.xy) * mult + add;
-};
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/Blit.vs b/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/Blit.vs
deleted file mode 100644
index 3bd611ba5d..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/Blit.vs
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// Copyright (c) 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.
-//
-
-struct VS_OUTPUT
-{
- float4 position : POSITION;
- float4 texcoord : TEXCOORD0;
-};
-
-uniform float4 halfPixelSize : c0;
-
-// Standard Vertex Shader
-// Input 0 is the homogenous position.
-// Outputs the homogenous position as-is.
-// Outputs a tex coord with (0,0) in the upper-left corner of the screen and (1,1) in the bottom right.
-// C0.X must be negative half-pixel width, C0.Y must be half-pixel height. C0.ZW must be 0.
-VS_OUTPUT VS_standard(in float4 position : POSITION)
-{
- VS_OUTPUT Out;
-
- Out.position = position + halfPixelSize;
- Out.texcoord = position * float4(0.5, -0.5, 1.0, 1.0) + float4(0.5, 0.5, 0, 0);
-
- return Out;
-};
-
-// Flip Y Vertex Shader
-// Input 0 is the homogenous position.
-// Outputs the homogenous position as-is.
-// Outputs a tex coord with (0,1) in the upper-left corner of the screen and (1,0) in the bottom right.
-// C0.XY must be the half-pixel width and height. C0.ZW must be 0.
-VS_OUTPUT VS_flipy(in float4 position : POSITION)
-{
- VS_OUTPUT Out;
-
- Out.position = position + halfPixelSize;
- Out.texcoord = position * float4(0.5, 0.5, 1.0, 1.0) + float4(0.5, 0.5, 0, 0);
-
- return Out;
-};
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/generatemip.h b/src/3rdparty/angle/src/libGLESv2/renderer/generatemip.h
deleted file mode 100644
index a57b00d444..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/generatemip.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// generatemip.h: Defines the GenerateMip function, templated on the format
-// type of the image for which mip levels are being generated.
-
-#ifndef LIBGLESV2_RENDERER_GENERATEMIP_H_
-#define LIBGLESV2_RENDERER_GENERATEMIP_H_
-
-#include "libGLESv2/renderer/imageformats.h"
-#include "libGLESv2/angletypes.h"
-
-namespace rx
-{
-
-template <typename T>
-inline void GenerateMip(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
- const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch,
- uint8_t *destData, size_t destRowPitch, size_t destDepthPitch);
-
-}
-
-#include "generatemip.inl"
-
-#endif // LIBGLESV2_RENDERER_GENERATEMIP_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/generatemip.inl b/src/3rdparty/angle/src/libGLESv2/renderer/generatemip.inl
deleted file mode 100644
index 6788a42f03..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/generatemip.inl
+++ /dev/null
@@ -1,266 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-// generatemip.inl: Defines the GenerateMip function, templated on the format
-// type of the image for which mip levels are being generated.
-
-#include "common/mathutil.h"
-
-namespace rx
-{
-
-namespace priv
-{
-
-template <typename T>
-static inline T *GetPixel(uint8_t *data, size_t x, size_t y, size_t z, size_t rowPitch, size_t depthPitch)
-{
- return reinterpret_cast<T*>(data + (x * sizeof(T)) + (y * rowPitch) + (z * depthPitch));
-}
-
-template <typename T>
-static inline const T *GetPixel(const uint8_t *data, size_t x, size_t y, size_t z, size_t rowPitch, size_t depthPitch)
-{
- return reinterpret_cast<const T*>(data + (x * sizeof(T)) + (y * rowPitch) + (z * depthPitch));
-}
-
-template <typename T>
-static void GenerateMip_Y(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
- const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch,
- size_t destWidth, size_t destHeight, size_t destDepth,
- uint8_t *destData, size_t destRowPitch, size_t destDepthPitch)
-{
- ASSERT(sourceWidth == 1);
- ASSERT(sourceHeight > 1);
- ASSERT(sourceDepth == 1);
-
- for (size_t y = 0; y < destHeight; y++)
- {
- const T *src0 = GetPixel<T>(sourceData, 0, y * 2, 0, sourceRowPitch, sourceDepthPitch);
- const T *src1 = GetPixel<T>(sourceData, 0, y * 2 + 1, 0, sourceRowPitch, sourceDepthPitch);
- T *dst = GetPixel<T>(destData, 0, y, 0, destRowPitch, destDepthPitch);
-
- T::average(dst, src0, src1);
- }
-}
-
-template <typename T>
-static void GenerateMip_X(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
- const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch,
- size_t destWidth, size_t destHeight, size_t destDepth,
- uint8_t *destData, size_t destRowPitch, size_t destDepthPitch)
-{
- ASSERT(sourceWidth > 1);
- ASSERT(sourceHeight == 1);
- ASSERT(sourceDepth == 1);
-
- for (size_t x = 0; x < destWidth; x++)
- {
- const T *src0 = GetPixel<T>(sourceData, x * 2, 0, 0, sourceRowPitch, sourceDepthPitch);
- const T *src1 = GetPixel<T>(sourceData, x * 2 + 1, 0, 0, sourceRowPitch, sourceDepthPitch);
- T *dst = GetPixel<T>(destData, x, 0, 0, destRowPitch, destDepthPitch);
-
- T::average(dst, src0, src1);
- }
-}
-
-template <typename T>
-static void GenerateMip_Z(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
- const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch,
- size_t destWidth, size_t destHeight, size_t destDepth,
- uint8_t *destData, size_t destRowPitch, size_t destDepthPitch)
-{
- ASSERT(sourceWidth == 1);
- ASSERT(sourceHeight == 1);
- ASSERT(sourceDepth > 1);
-
- for (size_t z = 0; z < destDepth; z++)
- {
- const T *src0 = GetPixel<T>(sourceData, 0, 0, z * 2, sourceRowPitch, sourceDepthPitch);
- const T *src1 = GetPixel<T>(sourceData, 0, 0, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
- T *dst = GetPixel<T>(destData, 0, 0, z, destRowPitch, destDepthPitch);
-
- T::average(dst, src0, src1);
- }
-}
-
-template <typename T>
-static void GenerateMip_XY(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
- const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch,
- size_t destWidth, size_t destHeight, size_t destDepth,
- uint8_t *destData, size_t destRowPitch, size_t destDepthPitch)
-{
- ASSERT(sourceWidth > 1);
- ASSERT(sourceHeight > 1);
- ASSERT(sourceDepth == 1);
-
- for (size_t y = 0; y < destHeight; y++)
- {
- for (size_t x = 0; x < destWidth; x++)
- {
- const T *src0 = GetPixel<T>(sourceData, x * 2, y * 2, 0, sourceRowPitch, sourceDepthPitch);
- const T *src1 = GetPixel<T>(sourceData, x * 2, y * 2 + 1, 0, sourceRowPitch, sourceDepthPitch);
- const T *src2 = GetPixel<T>(sourceData, x * 2 + 1, y * 2, 0, sourceRowPitch, sourceDepthPitch);
- const T *src3 = GetPixel<T>(sourceData, x * 2 + 1, y * 2 + 1, 0, sourceRowPitch, sourceDepthPitch);
- T *dst = GetPixel<T>(destData, x, y, 0, destRowPitch, destDepthPitch);
-
- T tmp0, tmp1;
-
- T::average(&tmp0, src0, src1);
- T::average(&tmp1, src2, src3);
- T::average(dst, &tmp0, &tmp1);
- }
- }
-}
-
-template <typename T>
-static void GenerateMip_YZ(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
- const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch,
- size_t destWidth, size_t destHeight, size_t destDepth,
- uint8_t *destData, size_t destRowPitch, size_t destDepthPitch)
-{
- ASSERT(sourceWidth == 1);
- ASSERT(sourceHeight > 1);
- ASSERT(sourceDepth > 1);
-
- for (size_t z = 0; z < destDepth; z++)
- {
- for (size_t y = 0; y < destHeight; y++)
- {
- const T *src0 = GetPixel<T>(sourceData, 0, y * 2, z * 2, sourceRowPitch, sourceDepthPitch);
- const T *src1 = GetPixel<T>(sourceData, 0, y * 2, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
- const T *src2 = GetPixel<T>(sourceData, 0, y * 2 + 1, z * 2, sourceRowPitch, sourceDepthPitch);
- const T *src3 = GetPixel<T>(sourceData, 0, y * 2 + 1, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
- T *dst = GetPixel<T>(destData, 0, y, z, destRowPitch, destDepthPitch);
-
- T tmp0, tmp1;
-
- T::average(&tmp0, src0, src1);
- T::average(&tmp1, src2, src3);
- T::average(dst, &tmp0, &tmp1);
- }
- }
-}
-
-template <typename T>
-static void GenerateMip_XZ(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
- const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch,
- size_t destWidth, size_t destHeight, size_t destDepth,
- uint8_t *destData, size_t destRowPitch, size_t destDepthPitch)
-{
- ASSERT(sourceWidth > 1);
- ASSERT(sourceHeight == 1);
- ASSERT(sourceDepth > 1);
-
- for (size_t z = 0; z < destDepth; z++)
- {
- for (size_t x = 0; x < destWidth; x++)
- {
- const T *src0 = GetPixel<T>(sourceData, x * 2, 0, z * 2, sourceRowPitch, sourceDepthPitch);
- const T *src1 = GetPixel<T>(sourceData, x * 2, 0, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
- const T *src2 = GetPixel<T>(sourceData, x * 2 + 1, 0, z * 2, sourceRowPitch, sourceDepthPitch);
- const T *src3 = GetPixel<T>(sourceData, x * 2 + 1, 0, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
- T *dst = GetPixel<T>(destData, x, 0, z, destRowPitch, destDepthPitch);
-
- T tmp0, tmp1;
-
- T::average(&tmp0, src0, src1);
- T::average(&tmp1, src2, src3);
- T::average(dst, &tmp0, &tmp1);
- }
- }
-}
-
-template <typename T>
-static void GenerateMip_XYZ(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
- const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch,
- size_t destWidth, size_t destHeight, size_t destDepth,
- uint8_t *destData, size_t destRowPitch, size_t destDepthPitch)
-{
- ASSERT(sourceWidth > 1);
- ASSERT(sourceHeight > 1);
- ASSERT(sourceDepth > 1);
-
- for (size_t z = 0; z < destDepth; z++)
- {
- for (size_t y = 0; y < destHeight; y++)
- {
- for (size_t x = 0; x < destWidth; x++)
- {
- const T *src0 = GetPixel<T>(sourceData, x * 2, y * 2, z * 2, sourceRowPitch, sourceDepthPitch);
- const T *src1 = GetPixel<T>(sourceData, x * 2, y * 2, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
- const T *src2 = GetPixel<T>(sourceData, x * 2, y * 2 + 1, z * 2, sourceRowPitch, sourceDepthPitch);
- const T *src3 = GetPixel<T>(sourceData, x * 2, y * 2 + 1, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
- const T *src4 = GetPixel<T>(sourceData, x * 2 + 1, y * 2, z * 2, sourceRowPitch, sourceDepthPitch);
- const T *src5 = GetPixel<T>(sourceData, x * 2 + 1, y * 2, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
- const T *src6 = GetPixel<T>(sourceData, x * 2 + 1, y * 2 + 1, z * 2, sourceRowPitch, sourceDepthPitch);
- const T *src7 = GetPixel<T>(sourceData, x * 2 + 1, y * 2 + 1, z * 2 + 1, sourceRowPitch, sourceDepthPitch);
- T *dst = GetPixel<T>(destData, x, y, z, destRowPitch, destDepthPitch);
-
- T tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
-
- T::average(&tmp0, src0, src1);
- T::average(&tmp1, src2, src3);
- T::average(&tmp2, src4, src5);
- T::average(&tmp3, src6, src7);
-
- T::average(&tmp4, &tmp0, &tmp1);
- T::average(&tmp5, &tmp2, &tmp3);
-
- T::average(dst, &tmp4, &tmp5);
- }
- }
- }
-}
-
-
-typedef void (*MipGenerationFunction)(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
- const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch,
- size_t destWidth, size_t destHeight, size_t destDepth,
- uint8_t *destData, size_t destRowPitch, size_t destDepthPitch);
-
-template <typename T>
-static MipGenerationFunction GetMipGenerationFunction(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth)
-{
- uint8_t index = ((sourceWidth > 1) ? 1 : 0) |
- ((sourceHeight > 1) ? 2 : 0) |
- ((sourceDepth > 1) ? 4 : 0);
-
- switch (index)
- {
- case 0: return NULL;
- case 1: return GenerateMip_X<T>; // W x 1 x 1
- case 2: return GenerateMip_Y<T>; // 1 x H x 1
- case 3: return GenerateMip_XY<T>; // W x H x 1
- case 4: return GenerateMip_Z<T>; // 1 x 1 x D
- case 5: return GenerateMip_XZ<T>; // W x 1 x D
- case 6: return GenerateMip_YZ<T>; // 1 x H x D
- case 7: return GenerateMip_XYZ<T>; // W x H x D
- }
-
- UNREACHABLE();
- return NULL;
-}
-
-}
-
-template <typename T>
-inline void GenerateMip(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
- const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch,
- uint8_t *destData, size_t destRowPitch, size_t destDepthPitch)
-{
- size_t mipWidth = std::max<size_t>(1, sourceWidth >> 1);
- size_t mipHeight = std::max<size_t>(1, sourceHeight >> 1);
- size_t mipDepth = std::max<size_t>(1, sourceDepth >> 1);
-
- priv::MipGenerationFunction generationFunction = priv::GetMipGenerationFunction<T>(sourceWidth, sourceHeight, sourceDepth);
- ASSERT(generationFunction != NULL);
-
- generationFunction(sourceWidth, sourceHeight, sourceDepth, sourceData, sourceRowPitch, sourceDepthPitch,
- mipWidth, mipHeight, mipDepth, destData, destRowPitch, destDepthPitch);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/imageformats.h b/src/3rdparty/angle/src/libGLESv2/renderer/imageformats.h
deleted file mode 100644
index 2140a9ee72..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/imageformats.h
+++ /dev/null
@@ -1,2029 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// imageformats.h: Defines image format types with functions for mip generation
-// and copying.
-
-#ifndef LIBGLESV2_RENDERER_IMAGEFORMATS_H_
-#define LIBGLESV2_RENDERER_IMAGEFORMATS_H_
-
-#include "common/mathutil.h"
-
-namespace rx
-{
-
-// Several structures share functionality for reading, writing or mipmapping but the layout
-// must match the texture format which the structure represents. If collapsing or typedefing
-// structs in this header, make sure the functionality and memory layout is exactly the same.
-
-struct L8
-{
- unsigned char L;
-
- static void readColor(gl::ColorF *dst, const L8 *src)
- {
- const float lum = gl::normalizedToFloat(src->L);
- dst->red = lum;
- dst->green = lum;
- dst->blue = lum;
- dst->alpha = 1.0f;
- }
-
- static void writeColor(L8 *dst, const gl::ColorF *src)
- {
- dst->L = gl::floatToNormalized<unsigned char>((src->red + src->green + src->blue) / 3.0f);
- }
-
- static void average(L8 *dst, const L8 *src1, const L8 *src2)
- {
- dst->L = gl::average(src1->L, src2->L);
- }
-};
-
-struct R8
-{
- unsigned char R;
-
- static void readColor(gl::ColorF *dst, const R8 *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = 0.0f;
- dst->blue = 0.0f;
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorUI *dst, const R8 *src)
- {
- dst->red = src->R;
- dst->green = 0;
- dst->blue = 0;
- dst->alpha = 1;
- }
-
- static void writeColor(R8 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<unsigned char>(src->red);
- }
-
- static void writeColor(R8 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned char>(src->red);
- }
-
- static void average(R8 *dst, const R8 *src1, const R8 *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- }
-};
-
-struct A8
-{
- unsigned char A;
-
- static void readColor(gl::ColorF *dst, const A8 *src)
- {
- dst->red = 0.0f;
- dst->green = 0.0f;
- dst->blue = 0.0f;
- dst->alpha = gl::normalizedToFloat(src->A);
- }
-
- static void writeColor(A8 *dst, const gl::ColorF *src)
- {
- dst->A = gl::floatToNormalized<unsigned char>(src->alpha);
- }
-
- static void average(A8 *dst, const A8 *src1, const A8 *src2)
- {
- dst->A = gl::average(src1->A, src2->A);
- }
-};
-
-struct L8A8
-{
- unsigned char L;
- unsigned char A;
-
- static void readColor(gl::ColorF *dst, const L8A8 *src)
- {
- const float lum = gl::normalizedToFloat(src->L);
- dst->red = lum;
- dst->green = lum;
- dst->blue = lum;
- dst->alpha = gl::normalizedToFloat(src->A);
- }
-
- static void writeColor(L8A8 *dst, const gl::ColorF *src)
- {
- dst->L = gl::floatToNormalized<unsigned char>((src->red + src->green + src->blue) / 3.0f);
- dst->A = gl::floatToNormalized<unsigned char>(src->alpha);
- }
-
- static void average(L8A8 *dst, const L8A8 *src1, const L8A8 *src2)
- {
- *(unsigned short*)dst = (((*(unsigned short*)src1 ^ *(unsigned short*)src2) & 0xFEFE) >> 1) + (*(unsigned short*)src1 & *(unsigned short*)src2);
- }
-};
-
-struct A8L8
-{
- unsigned char A;
- unsigned char L;
-
- static void readColor(gl::ColorF *dst, const A8L8 *src)
- {
- const float lum = gl::normalizedToFloat(src->L);
- dst->red = lum;
- dst->green = lum;
- dst->blue = lum;
- dst->alpha = gl::normalizedToFloat(src->A);
- }
-
- static void writeColor(A8L8 *dst, const gl::ColorF *src)
- {
- dst->L = gl::floatToNormalized<unsigned char>((src->red + src->green + src->blue) / 3.0f);
- dst->A = gl::floatToNormalized<unsigned char>(src->alpha);
- }
-
- static void average(A8L8 *dst, const A8L8 *src1, const A8L8 *src2)
- {
- *(unsigned short*)dst = (((*(unsigned short*)src1 ^ *(unsigned short*)src2) & 0xFEFE) >> 1) + (*(unsigned short*)src1 & *(unsigned short*)src2);
- }
-};
-
-struct R8G8
-{
- unsigned char R;
- unsigned char G;
-
- static void readColor(gl::ColorF *dst, const R8G8 *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = 0.0f;
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorUI *dst, const R8G8 *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = 0;
- dst->alpha = 1;
- }
-
- static void writeColor(R8G8 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<unsigned char>(src->red);
- dst->G = gl::floatToNormalized<unsigned char>(src->green);
- }
-
- static void writeColor(R8G8 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned char>(src->red);
- dst->G = static_cast<unsigned char>(src->green);
- }
-
- static void average(R8G8 *dst, const R8G8 *src1, const R8G8 *src2)
- {
- *(unsigned short*)dst = (((*(unsigned short*)src1 ^ *(unsigned short*)src2) & 0xFEFE) >> 1) + (*(unsigned short*)src1 & *(unsigned short*)src2);
- }
-};
-
-struct R8G8B8
-{
- unsigned char R;
- unsigned char G;
- unsigned char B;
-
- static void readColor(gl::ColorF *dst, const R8G8B8 *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = gl::normalizedToFloat(src->B);
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorUI *dst, const R8G8B8 *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->G;
- dst->alpha = 1;
- }
-
- static void writeColor(R8G8B8 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<unsigned char>(src->red);
- dst->G = gl::floatToNormalized<unsigned char>(src->green);
- dst->B = gl::floatToNormalized<unsigned char>(src->blue);
- }
-
- static void writeColor(R8G8B8 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned char>(src->red);
- dst->G = static_cast<unsigned char>(src->green);
- dst->B = static_cast<unsigned char>(src->blue);
- }
-
- static void average(R8G8B8 *dst, const R8G8B8 *src1, const R8G8B8 *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- }
-};
-
-struct B8G8R8
-{
- unsigned char B;
- unsigned char G;
- unsigned char R;
-
- static void readColor(gl::ColorF *dst, const B8G8R8 *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = gl::normalizedToFloat(src->B);
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorUI *dst, const B8G8R8 *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->G;
- dst->alpha = 1;
- }
-
- static void writeColor(B8G8R8 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<unsigned char>(src->red);
- dst->G = gl::floatToNormalized<unsigned char>(src->green);
- dst->B = gl::floatToNormalized<unsigned char>(src->blue);
- }
-
- static void writeColor(B8G8R8 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned char>(src->red);
- dst->G = static_cast<unsigned char>(src->green);
- dst->B = static_cast<unsigned char>(src->blue);
- }
-
- static void average(B8G8R8 *dst, const B8G8R8 *src1, const B8G8R8 *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- }
-};
-
-struct R5G6B5
-{
- unsigned short RGB;
-
- static void readColor(gl::ColorF *dst, const R5G6B5 *src)
- {
- dst->red = gl::normalizedToFloat<5>(gl::getShiftedData<5, 11>(src->RGB));
- dst->green = gl::normalizedToFloat<6>(gl::getShiftedData<6, 5>(src->RGB));
- dst->blue = gl::normalizedToFloat<5>(gl::getShiftedData<5, 0>(src->RGB));
- dst->alpha = 1.0f;
- }
-
- static void writeColor(R5G6B5 *dst, const gl::ColorF *src)
- {
- dst->RGB = gl::shiftData<5, 11>(gl::floatToNormalized<5, unsigned short>(src->red)) |
- gl::shiftData<6, 5>(gl::floatToNormalized<6, unsigned short>(src->green)) |
- gl::shiftData<5, 0>(gl::floatToNormalized<5, unsigned short>(src->blue));
- }
-
- static void average(R5G6B5 *dst, const R5G6B5 *src1, const R5G6B5 *src2)
- {
- dst->RGB = gl::shiftData<5, 11>(gl::average(gl::getShiftedData<5, 11>(src1->RGB), gl::getShiftedData<5, 11>(src2->RGB))) |
- gl::shiftData<6, 5>(gl::average(gl::getShiftedData<6, 5>(src1->RGB), gl::getShiftedData<6, 5>(src2->RGB))) |
- gl::shiftData<5, 0>(gl::average(gl::getShiftedData<5, 0>(src1->RGB), gl::getShiftedData<5, 0>(src2->RGB)));
- }
-};
-
-struct A8R8G8B8
-{
- unsigned char A;
- unsigned char R;
- unsigned char G;
- unsigned char B;
-
- static void readColor(gl::ColorF *dst, const A8R8G8B8 *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = gl::normalizedToFloat(src->B);
- dst->alpha = gl::normalizedToFloat(src->A);
- }
-
- static void readColor(gl::ColorUI *dst, const A8R8G8B8 *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = src->A;
- }
-
- static void writeColor(A8R8G8B8 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<unsigned char>(src->red);
- dst->G = gl::floatToNormalized<unsigned char>(src->green);
- dst->B = gl::floatToNormalized<unsigned char>(src->blue);
- dst->A = gl::floatToNormalized<unsigned char>(src->alpha);
- }
-
- static void writeColor(A8R8G8B8 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned char>(src->red);
- dst->G = static_cast<unsigned char>(src->green);
- dst->B = static_cast<unsigned char>(src->blue);
- dst->A = static_cast<unsigned char>(src->alpha);
- }
-
- static void average(A8R8G8B8 *dst, const A8R8G8B8 *src1, const A8R8G8B8 *src2)
- {
- *(unsigned int*)dst = (((*(unsigned int*)src1 ^ *(unsigned int*)src2) & 0xFEFEFEFE) >> 1) + (*(unsigned int*)src1 & *(unsigned int*)src2);
- }
-};
-
-struct R8G8B8A8
-{
- unsigned char R;
- unsigned char G;
- unsigned char B;
- unsigned char A;
-
- static void readColor(gl::ColorF *dst, const R8G8B8A8 *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = gl::normalizedToFloat(src->B);
- dst->alpha = gl::normalizedToFloat(src->A);
- }
-
- static void readColor(gl::ColorUI *dst, const R8G8B8A8 *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = src->A;
- }
-
- static void writeColor(R8G8B8A8 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<unsigned char>(src->red);
- dst->G = gl::floatToNormalized<unsigned char>(src->green);
- dst->B = gl::floatToNormalized<unsigned char>(src->blue);
- dst->A = gl::floatToNormalized<unsigned char>(src->alpha);
- }
-
- static void writeColor(R8G8B8A8 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned char>(src->red);
- dst->G = static_cast<unsigned char>(src->green);
- dst->B = static_cast<unsigned char>(src->blue);
- dst->A = static_cast<unsigned char>(src->alpha);
- }
-
- static void average(R8G8B8A8 *dst, const R8G8B8A8 *src1, const R8G8B8A8 *src2)
- {
- *(unsigned int*)dst = (((*(unsigned int*)src1 ^ *(unsigned int*)src2) & 0xFEFEFEFE) >> 1) + (*(unsigned int*)src1 & *(unsigned int*)src2);
- }
-};
-
-struct B8G8R8A8
-{
- unsigned char B;
- unsigned char G;
- unsigned char R;
- unsigned char A;
-
- static void readColor(gl::ColorF *dst, const B8G8R8A8 *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = gl::normalizedToFloat(src->B);
- dst->alpha = gl::normalizedToFloat(src->A);
- }
-
- static void readColor(gl::ColorUI *dst, const B8G8R8A8 *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = src->A;
- }
-
- static void writeColor(B8G8R8A8 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<unsigned char>(src->red);
- dst->G = gl::floatToNormalized<unsigned char>(src->green);
- dst->B = gl::floatToNormalized<unsigned char>(src->blue);
- dst->A = gl::floatToNormalized<unsigned char>(src->alpha);
- }
-
- static void writeColor(B8G8R8A8 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned char>(src->red);
- dst->G = static_cast<unsigned char>(src->green);
- dst->B = static_cast<unsigned char>(src->blue);
- dst->A = static_cast<unsigned char>(src->alpha);
- }
-
- static void average(B8G8R8A8 *dst, const B8G8R8A8 *src1, const B8G8R8A8 *src2)
- {
- *(unsigned int*)dst = (((*(unsigned int*)src1 ^ *(unsigned int*)src2) & 0xFEFEFEFE) >> 1) + (*(unsigned int*)src1 & *(unsigned int*)src2);
- }
-};
-
-struct B8G8R8X8
-{
- unsigned char B;
- unsigned char G;
- unsigned char R;
- unsigned char X;
-
- static void readColor(gl::ColorF *dst, const B8G8R8X8 *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = gl::normalizedToFloat(src->B);
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorUI *dst, const B8G8R8X8 *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = 1;
- }
-
- static void writeColor(B8G8R8X8 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<unsigned char>(src->red);
- dst->G = gl::floatToNormalized<unsigned char>(src->green);
- dst->B = gl::floatToNormalized<unsigned char>(src->blue);
- dst->X = 255;
- }
-
- static void writeColor(B8G8R8X8 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned char>(src->red);
- dst->G = static_cast<unsigned char>(src->green);
- dst->B = static_cast<unsigned char>(src->blue);
- dst->X = 255;
- }
-
- static void average(B8G8R8X8 *dst, const B8G8R8X8 *src1, const B8G8R8X8 *src2)
- {
- *(unsigned int*)dst = (((*(unsigned int*)src1 ^ *(unsigned int*)src2) & 0xFEFEFEFE) >> 1) + (*(unsigned int*)src1 & *(unsigned int*)src2);
- dst->X = 255;
- }
-};
-
-struct B5G5R5A1
-{
- unsigned short BGRA;
-
- static void readColor(gl::ColorF *dst, const B5G5R5A1 *src)
- {
- dst->alpha = gl::normalizedToFloat<1>(gl::getShiftedData<1, 15>(src->BGRA));
- dst->red = gl::normalizedToFloat<5>(gl::getShiftedData<5, 10>(src->BGRA));
- dst->green = gl::normalizedToFloat<5>(gl::getShiftedData<5, 5>(src->BGRA));
- dst->blue = gl::normalizedToFloat<5>(gl::getShiftedData<5, 0>(src->BGRA));
- }
-
- static void writeColor(B5G5R5A1 *dst, const gl::ColorF *src)
- {
- dst->BGRA = gl::shiftData<1, 15>(gl::floatToNormalized<1, unsigned short>(src->alpha)) |
- gl::shiftData<5, 10>(gl::floatToNormalized<5, unsigned short>(src->red)) |
- gl::shiftData<5, 5>(gl::floatToNormalized<5, unsigned short>(src->green)) |
- gl::shiftData<5, 0>(gl::floatToNormalized<5, unsigned short>(src->blue));
- }
-
- static void average(B5G5R5A1 *dst, const B5G5R5A1 *src1, const B5G5R5A1 *src2)
- {
- dst->BGRA = gl::shiftData<1, 15>(gl::average(gl::getShiftedData<1, 15>(src1->BGRA), gl::getShiftedData<1, 15>(src2->BGRA))) |
- gl::shiftData<5, 10>(gl::average(gl::getShiftedData<5, 10>(src1->BGRA), gl::getShiftedData<5, 10>(src2->BGRA))) |
- gl::shiftData<5, 5>(gl::average(gl::getShiftedData<5, 5>(src1->BGRA), gl::getShiftedData<5, 5>(src2->BGRA))) |
- gl::shiftData<5, 0>(gl::average(gl::getShiftedData<5, 0>(src1->BGRA), gl::getShiftedData<5, 0>(src2->BGRA)));
- }
-};
-
-struct R5G5B5A1
-{
- unsigned short RGBA;
-
- static void readColor(gl::ColorF *dst, const R5G5B5A1 *src)
- {
- dst->alpha = gl::normalizedToFloat<1>(gl::getShiftedData<1, 15>(src->RGBA));
- dst->blue = gl::normalizedToFloat<5>(gl::getShiftedData<5, 10>(src->RGBA));
- dst->green = gl::normalizedToFloat<5>(gl::getShiftedData<5, 5>(src->RGBA));
- dst->red = gl::normalizedToFloat<5>(gl::getShiftedData<5, 0>(src->RGBA));
- }
-
- static void writeColor(R5G5B5A1 *dst, const gl::ColorF *src)
- {
- dst->RGBA = gl::shiftData<1, 15>(gl::floatToNormalized<1, unsigned short>(src->alpha)) |
- gl::shiftData<5, 10>(gl::floatToNormalized<5, unsigned short>(src->blue)) |
- gl::shiftData<5, 5>(gl::floatToNormalized<5, unsigned short>(src->green)) |
- gl::shiftData<5, 0>(gl::floatToNormalized<5, unsigned short>(src->red));
- }
-
- static void average(R5G5B5A1 *dst, const R5G5B5A1 *src1, const R5G5B5A1 *src2)
- {
- dst->RGBA = gl::shiftData<1, 15>(gl::average(gl::getShiftedData<1, 15>(src1->RGBA), gl::getShiftedData<1, 15>(src2->RGBA))) |
- gl::shiftData<5, 10>(gl::average(gl::getShiftedData<5, 10>(src1->RGBA), gl::getShiftedData<5, 10>(src2->RGBA))) |
- gl::shiftData<5, 5>(gl::average(gl::getShiftedData<5, 5>(src1->RGBA), gl::getShiftedData<5, 5>(src2->RGBA))) |
- gl::shiftData<5, 0>(gl::average(gl::getShiftedData<5, 0>(src1->RGBA), gl::getShiftedData<5, 0>(src2->RGBA)));
- }
-};
-
-struct R4G4B4A4
-{
- unsigned char R : 4;
- unsigned char G : 4;
- unsigned char B : 4;
- unsigned char A : 4;
-
- static void readColor(gl::ColorF *dst, const R4G4B4A4 *src)
- {
- dst->red = gl::normalizedToFloat<4>(src->R);
- dst->green = gl::normalizedToFloat<4>(src->G);
- dst->blue = gl::normalizedToFloat<4>(src->B);
- dst->alpha = gl::normalizedToFloat<4>(src->A);
- }
-
- static void writeColor(R4G4B4A4 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<4, unsigned char>(src->red);
- dst->G = gl::floatToNormalized<4, unsigned char>(src->green);
- dst->B = gl::floatToNormalized<4, unsigned char>(src->blue);
- dst->A = gl::floatToNormalized<4, unsigned char>(src->alpha);
- }
-
- static void average(R4G4B4A4 *dst, const R4G4B4A4 *src1, const R4G4B4A4 *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- dst->A = gl::average(src1->A, src2->A);
- }
-};
-
-struct A4R4G4B4
-{
- unsigned char A : 4;
- unsigned char R : 4;
- unsigned char G : 4;
- unsigned char B : 4;
-
- static void readColor(gl::ColorF *dst, const A4R4G4B4 *src)
- {
- dst->red = gl::normalizedToFloat<4>(src->R);
- dst->green = gl::normalizedToFloat<4>(src->G);
- dst->blue = gl::normalizedToFloat<4>(src->B);
- dst->alpha = gl::normalizedToFloat<4>(src->A);
- }
-
- static void writeColor(A4R4G4B4 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<4, unsigned char>(src->red);
- dst->G = gl::floatToNormalized<4, unsigned char>(src->green);
- dst->B = gl::floatToNormalized<4, unsigned char>(src->blue);
- dst->A = gl::floatToNormalized<4, unsigned char>(src->alpha);
- }
-
- static void average(A4R4G4B4 *dst, const A4R4G4B4 *src1, const A4R4G4B4 *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- dst->A = gl::average(src1->A, src2->A);
- }
-};
-
-struct B4G4R4A4
-{
- unsigned char B : 4;
- unsigned char G : 4;
- unsigned char R : 4;
- unsigned char A : 4;
-
- static void readColor(gl::ColorF *dst, const B4G4R4A4 *src)
- {
- dst->red = gl::normalizedToFloat<4>(src->R);
- dst->green = gl::normalizedToFloat<4>(src->G);
- dst->blue = gl::normalizedToFloat<4>(src->B);
- dst->alpha = gl::normalizedToFloat<4>(src->A);
- }
-
- static void writeColor(B4G4R4A4 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<4, unsigned char>(src->red);
- dst->G = gl::floatToNormalized<4, unsigned char>(src->green);
- dst->B = gl::floatToNormalized<4, unsigned char>(src->blue);
- dst->A = gl::floatToNormalized<4, unsigned char>(src->alpha);
- }
-
- static void average(B4G4R4A4 *dst, const B4G4R4A4 *src1, const B4G4R4A4 *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- dst->A = gl::average(src1->A, src2->A);
- }
-};
-
-struct R16
-{
- unsigned short R;
-
- static void readColor(gl::ColorF *dst, const R16 *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = 0.0f;
- dst->blue = 0.0f;
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorUI *dst, const R16 *src)
- {
- dst->red = src->R;
- dst->green = 0;
- dst->blue = 0;
- dst->alpha = 1;
- }
-
- static void writeColor(R16 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<unsigned short>(src->red);
- }
-
- static void writeColor(R16 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned short>(src->red);
- }
-
- static void average(R16 *dst, const R16 *src1, const R16 *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- }
-};
-
-struct R16G16
-{
- unsigned short R;
- unsigned short G;
-
- static void readColor(gl::ColorF *dst, const R16G16 *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = 0.0f;
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorUI *dst, const R16G16 *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = 0;
- dst->alpha = 1;
- }
-
- static void writeColor(R16G16 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<unsigned short>(src->red);
- dst->G = gl::floatToNormalized<unsigned short>(src->green);
- }
-
- static void writeColor(R16G16 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned short>(src->red);
- dst->G = static_cast<unsigned short>(src->green);
- }
-
- static void average(R16G16 *dst, const R16G16 *src1, const R16G16 *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- }
-};
-
-struct R16G16B16
-{
- unsigned short R;
- unsigned short G;
- unsigned short B;
-
- static void readColor(gl::ColorF *dst, const R16G16B16 *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = gl::normalizedToFloat(src->B);
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorUI *dst, const R16G16B16 *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = 1;
- }
-
- static void writeColor(R16G16B16 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<unsigned short>(src->red);
- dst->G = gl::floatToNormalized<unsigned short>(src->green);
- dst->B = gl::floatToNormalized<unsigned short>(src->blue);
- }
-
- static void writeColor(R16G16B16 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned short>(src->red);
- dst->G = static_cast<unsigned short>(src->green);
- dst->B = static_cast<unsigned short>(src->blue);
- }
-
- static void average(R16G16B16 *dst, const R16G16B16 *src1, const R16G16B16 *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- }
-};
-
-struct R16G16B16A16
-{
- unsigned short R;
- unsigned short G;
- unsigned short B;
- unsigned short A;
-
- static void readColor(gl::ColorF *dst, const R16G16B16A16 *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = gl::normalizedToFloat(src->B);
- dst->alpha = gl::normalizedToFloat(src->A);
- }
-
- static void readColor(gl::ColorUI *dst, const R16G16B16A16 *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = src->A;
- }
-
- static void writeColor(R16G16B16A16 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<unsigned short>(src->red);
- dst->G = gl::floatToNormalized<unsigned short>(src->green);
- dst->B = gl::floatToNormalized<unsigned short>(src->blue);
- dst->A = gl::floatToNormalized<unsigned short>(src->alpha);
- }
-
- static void writeColor(R16G16B16A16 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned short>(src->red);
- dst->G = static_cast<unsigned short>(src->green);
- dst->B = static_cast<unsigned short>(src->blue);
- dst->A = static_cast<unsigned short>(src->alpha);
- }
-
- static void average(R16G16B16A16 *dst, const R16G16B16A16 *src1, const R16G16B16A16 *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- dst->A = gl::average(src1->A, src2->A);
- }
-};
-
-struct R32
-{
- unsigned int R;
-
- static void readColor(gl::ColorF *dst, const R32 *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = 0.0f;
- dst->blue = 0.0f;
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorUI *dst, const R32 *src)
- {
- dst->red = src->R;
- dst->green = 0;
- dst->blue = 0;
- dst->alpha = 1;
- }
-
- static void writeColor(R32 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<unsigned int>(src->red);
- }
-
- static void writeColor(R32 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned int>(src->red);
- }
-
- static void average(R32 *dst, const R32 *src1, const R32 *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- }
-};
-
-struct R32G32
-{
- unsigned int R;
- unsigned int G;
-
- static void readColor(gl::ColorF *dst, const R32G32 *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = 0.0f;
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorUI *dst, const R32G32 *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = 0;
- dst->alpha = 1;
- }
-
- static void writeColor(R32G32 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<unsigned int>(src->red);
- dst->G = gl::floatToNormalized<unsigned int>(src->green);
- }
-
- static void writeColor(R32G32 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned int>(src->red);
- dst->G = static_cast<unsigned int>(src->green);
- }
-
- static void average(R32G32 *dst, const R32G32 *src1, const R32G32 *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- }
-};
-
-struct R32G32B32
-{
- unsigned int R;
- unsigned int G;
- unsigned int B;
-
- static void readColor(gl::ColorF *dst, const R32G32B32 *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = gl::normalizedToFloat(src->B);
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorUI *dst, const R32G32B32 *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = 1;
- }
-
- static void writeColor(R32G32B32 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<unsigned int>(src->red);
- dst->G = gl::floatToNormalized<unsigned int>(src->green);
- dst->B = gl::floatToNormalized<unsigned int>(src->blue);
- }
-
- static void writeColor(R32G32B32 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned int>(src->red);
- dst->G = static_cast<unsigned int>(src->green);
- dst->B = static_cast<unsigned int>(src->blue);
- }
-
- static void average(R32G32B32 *dst, const R32G32B32 *src1, const R32G32B32 *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- }
-};
-
-struct R32G32B32A32
-{
- unsigned int R;
- unsigned int G;
- unsigned int B;
- unsigned int A;
-
- static void readColor(gl::ColorF *dst, const R32G32B32A32 *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = gl::normalizedToFloat(src->B);
- dst->alpha = gl::normalizedToFloat(src->A);
- }
-
- static void readColor(gl::ColorUI *dst, const R32G32B32A32 *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = src->A;
- }
-
- static void writeColor(R32G32B32A32 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<unsigned int>(src->red);
- dst->G = gl::floatToNormalized<unsigned int>(src->green);
- dst->B = gl::floatToNormalized<unsigned int>(src->blue);
- dst->A = gl::floatToNormalized<unsigned int>(src->alpha);
- }
-
- static void writeColor(R32G32B32A32 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned int>(src->red);
- dst->G = static_cast<unsigned int>(src->green);
- dst->B = static_cast<unsigned int>(src->blue);
- dst->A = static_cast<unsigned int>(src->alpha);
- }
-
- static void average(R32G32B32A32 *dst, const R32G32B32A32 *src1, const R32G32B32A32 *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- dst->A = gl::average(src1->A, src2->A);
- }
-};
-
-struct R8S
-{
- char R;
-
- static void readColor(gl::ColorF *dst, const R8S *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = 0.0f;
- dst->blue = 0.0f;
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorI *dst, const R8S *src)
- {
- dst->red = src->R;
- dst->green = 0;
- dst->blue = 0;
- dst->alpha = 1;
- }
-
- static void writeColor(R8S *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<char>(src->red);
- }
-
- static void writeColor(R8S *dst, const gl::ColorI *src)
- {
- dst->R = static_cast<char>(src->red);
- }
-
- static void average(R8S *dst, const R8S *src1, const R8S *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- }
-};
-
-struct R8G8S
-{
- char R;
- char G;
-
- static void readColor(gl::ColorF *dst, const R8G8S *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = 0.0f;
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorI *dst, const R8G8S *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = 0;
- dst->alpha = 1;
- }
-
- static void writeColor(R8G8S *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<char>(src->red);
- dst->G = gl::floatToNormalized<char>(src->green);
- }
-
- static void writeColor(R8G8S *dst, const gl::ColorI *src)
- {
- dst->R = static_cast<char>(src->red);
- dst->G = static_cast<char>(src->green);
- }
-
- static void average(R8G8S *dst, const R8G8S *src1, const R8G8S *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- }
-};
-
-struct R8G8B8S
-{
- char R;
- char G;
- char B;
-
- static void readColor(gl::ColorF *dst, const R8G8B8S *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = gl::normalizedToFloat(src->B);
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorI *dst, const R8G8B8S *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = 1;
- }
-
- static void writeColor(R8G8B8S *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<char>(src->red);
- dst->G = gl::floatToNormalized<char>(src->green);
- dst->B = gl::floatToNormalized<char>(src->blue);
- }
-
- static void writeColor(R8G8B8S *dst, const gl::ColorI *src)
- {
- dst->R = static_cast<char>(src->red);
- dst->G = static_cast<char>(src->green);
- dst->B = static_cast<char>(src->blue);
- }
-
- static void average(R8G8B8S *dst, const R8G8B8S *src1, const R8G8B8S *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- }
-};
-
-struct R8G8B8A8S
-{
- char R;
- char G;
- char B;
- char A;
-
- static void readColor(gl::ColorF *dst, const R8G8B8A8S *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = gl::normalizedToFloat(src->B);
- dst->alpha = gl::normalizedToFloat(src->A);
- }
-
- static void readColor(gl::ColorI *dst, const R8G8B8A8S *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = src->A;
- }
-
- static void writeColor(R8G8B8A8S *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<char>(src->red);
- dst->G = gl::floatToNormalized<char>(src->green);
- dst->B = gl::floatToNormalized<char>(src->blue);
- dst->A = gl::floatToNormalized<char>(src->alpha);
- }
-
- static void writeColor(R8G8B8A8S *dst, const gl::ColorI *src)
- {
- dst->R = static_cast<char>(src->red);
- dst->G = static_cast<char>(src->green);
- dst->B = static_cast<char>(src->blue);
- dst->A = static_cast<char>(src->alpha);
- }
-
- static void average(R8G8B8A8S *dst, const R8G8B8A8S *src1, const R8G8B8A8S *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- dst->A = gl::average(src1->A, src2->A);
- }
-};
-
-struct R16S
-{
- short R;
-
- static void readColor(gl::ColorF *dst, const R16S *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = 0.0f;
- dst->blue = 0.0f;
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorI *dst, const R16S *src)
- {
- dst->red = src->R;
- dst->green = 0;
- dst->blue = 0;
- dst->alpha = 1;
- }
-
- static void writeColor(R16S *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<short>(src->red);
- }
-
- static void writeColor(R16S *dst, const gl::ColorI *src)
- {
- dst->R = static_cast<short>(src->red);
- }
-
- static void average(R16S *dst, const R16S *src1, const R16S *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- }
-};
-
-struct R16G16S
-{
- short R;
- short G;
-
- static void readColor(gl::ColorF *dst, const R16G16S *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = 0.0f;
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorI *dst, const R16G16S *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = 0;
- dst->alpha = 1;
- }
-
- static void writeColor(R16G16S *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<short>(src->red);
- dst->G = gl::floatToNormalized<short>(src->green);
- }
-
- static void writeColor(R16G16S *dst, const gl::ColorI *src)
- {
- dst->R = static_cast<short>(src->red);
- dst->G = static_cast<short>(src->green);
- }
-
- static void average(R16G16S *dst, const R16G16S *src1, const R16G16S *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- }
-};
-
-struct R16G16B16S
-{
- short R;
- short G;
- short B;
-
- static void readColor(gl::ColorF *dst, const R16G16B16S *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = gl::normalizedToFloat(src->B);
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorI *dst, const R16G16B16S *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = 1;
- }
-
- static void writeColor(R16G16B16S *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<short>(src->red);
- dst->G = gl::floatToNormalized<short>(src->green);
- dst->B = gl::floatToNormalized<short>(src->blue);
- }
-
- static void writeColor(R16G16B16S *dst, const gl::ColorI *src)
- {
- dst->R = static_cast<short>(src->red);
- dst->G = static_cast<short>(src->green);
- dst->B = static_cast<short>(src->blue);
- }
-
- static void average(R16G16B16S *dst, const R16G16B16S *src1, const R16G16B16S *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- }
-};
-
-struct R16G16B16A16S
-{
- short R;
- short G;
- short B;
- short A;
-
- static void readColor(gl::ColorF *dst, const R16G16B16A16S *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = gl::normalizedToFloat(src->B);
- dst->alpha = gl::normalizedToFloat(src->A);
- }
-
- static void readColor(gl::ColorI *dst, const R16G16B16A16S *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = src->A;
- }
-
- static void writeColor(R16G16B16A16S *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<short>(src->red);
- dst->G = gl::floatToNormalized<short>(src->green);
- dst->B = gl::floatToNormalized<short>(src->blue);
- dst->A = gl::floatToNormalized<short>(src->alpha);
- }
-
- static void writeColor(R16G16B16A16S *dst, const gl::ColorI *src)
- {
- dst->R = static_cast<short>(src->red);
- dst->G = static_cast<short>(src->green);
- dst->B = static_cast<short>(src->blue);
- dst->A = static_cast<short>(src->alpha);
- }
-
- static void average(R16G16B16A16S *dst, const R16G16B16A16S *src1, const R16G16B16A16S *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- dst->A = gl::average(src1->A, src2->A);
- }
-};
-
-struct R32S
-{
- int R;
-
- static void readColor(gl::ColorF *dst, const R32S *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = 0.0f;
- dst->blue = 0.0f;
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorI *dst, const R32S *src)
- {
- dst->red = src->R;
- dst->green = 0;
- dst->blue = 0;
- dst->alpha = 1;
- }
-
- static void writeColor(R32S *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<int>(src->red);
- }
-
- static void writeColor(R32S *dst, const gl::ColorI *src)
- {
- dst->R = static_cast<int>(src->red);
- }
-
- static void average(R32S *dst, const R32S *src1, const R32S *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- }
-};
-
-struct R32G32S
-{
- int R;
- int G;
-
- static void readColor(gl::ColorF *dst, const R32G32S *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = 0.0f;
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorI *dst, const R32G32S *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = 0;
- dst->alpha = 1;
- }
-
- static void writeColor(R32G32S *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<int>(src->red);
- dst->G = gl::floatToNormalized<int>(src->green);
- }
-
- static void writeColor(R32G32S *dst, const gl::ColorI *src)
- {
- dst->R = static_cast<int>(src->red);
- dst->G = static_cast<int>(src->green);
- }
-
- static void average(R32G32S *dst, const R32G32S *src1, const R32G32S *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- }
-};
-
-struct R32G32B32S
-{
- int R;
- int G;
- int B;
-
- static void readColor(gl::ColorF *dst, const R32G32B32S *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = gl::normalizedToFloat(src->B);
- dst->alpha = 1.0f;
- }
-
- static void readColor(gl::ColorI *dst, const R32G32B32S *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = 1;
- }
-
- static void writeColor(R32G32B32S *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<int>(src->red);
- dst->G = gl::floatToNormalized<int>(src->green);
- dst->B = gl::floatToNormalized<int>(src->blue);
- }
-
- static void writeColor(R32G32B32S *dst, const gl::ColorI *src)
- {
- dst->R = static_cast<int>(src->red);
- dst->G = static_cast<int>(src->green);
- dst->B = static_cast<int>(src->blue);
- }
-
- static void average(R32G32B32S *dst, const R32G32B32S *src1, const R32G32B32S *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- }
-};
-
-struct R32G32B32A32S
-{
- int R;
- int G;
- int B;
- int A;
-
- static void readColor(gl::ColorF *dst, const R32G32B32A32S *src)
- {
- dst->red = gl::normalizedToFloat(src->R);
- dst->green = gl::normalizedToFloat(src->G);
- dst->blue = gl::normalizedToFloat(src->B);
- dst->alpha = gl::normalizedToFloat(src->A);
- }
-
- static void readColor(gl::ColorI *dst, const R32G32B32A32S *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = src->A;
- }
-
- static void writeColor(R32G32B32A32S *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<int>(src->red);
- dst->G = gl::floatToNormalized<int>(src->green);
- dst->B = gl::floatToNormalized<int>(src->blue);
- dst->A = gl::floatToNormalized<int>(src->alpha);
- }
-
- static void writeColor(R32G32B32A32S *dst, const gl::ColorI *src)
- {
- dst->R = static_cast<int>(src->red);
- dst->G = static_cast<int>(src->green);
- dst->B = static_cast<int>(src->blue);
- dst->A = static_cast<int>(src->alpha);
- }
-
- static void average(R32G32B32A32S *dst, const R32G32B32A32S *src1, const R32G32B32A32S *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- dst->A = gl::average(src1->A, src2->A);
- }
-};
-
-struct A16B16G16R16F
-{
- unsigned short A;
- unsigned short R;
- unsigned short G;
- unsigned short B;
-
- static void readColor(gl::ColorF *dst, const A16B16G16R16F *src)
- {
- dst->red = gl::float16ToFloat32(src->R);
- dst->green = gl::float16ToFloat32(src->G);
- dst->blue = gl::float16ToFloat32(src->B);
- dst->alpha = gl::float16ToFloat32(src->A);
- }
-
- static void writeColor(A16B16G16R16F *dst, const gl::ColorF *src)
- {
- dst->R = gl::float32ToFloat16(src->red);
- dst->G = gl::float32ToFloat16(src->green);
- dst->B = gl::float32ToFloat16(src->blue);
- dst->A = gl::float32ToFloat16(src->alpha);
- }
-
- static void average(A16B16G16R16F *dst, const A16B16G16R16F *src1, const A16B16G16R16F *src2)
- {
- dst->R = gl::averageHalfFloat(src1->R, src2->R);
- dst->G = gl::averageHalfFloat(src1->G, src2->G);
- dst->B = gl::averageHalfFloat(src1->B, src2->B);
- dst->A = gl::averageHalfFloat(src1->A, src2->A);
- }
-};
-
-struct R16G16B16A16F
-{
- unsigned short R;
- unsigned short G;
- unsigned short B;
- unsigned short A;
-
- static void readColor(gl::ColorF *dst, const R16G16B16A16F *src)
- {
- dst->red = gl::float16ToFloat32(src->R);
- dst->green = gl::float16ToFloat32(src->G);
- dst->blue = gl::float16ToFloat32(src->B);
- dst->alpha = gl::float16ToFloat32(src->A);
- }
-
- static void writeColor(R16G16B16A16F *dst, const gl::ColorF *src)
- {
- dst->R = gl::float32ToFloat16(src->red);
- dst->G = gl::float32ToFloat16(src->green);
- dst->B = gl::float32ToFloat16(src->blue);
- dst->A = gl::float32ToFloat16(src->alpha);
- }
-
- static void average(R16G16B16A16F *dst, const R16G16B16A16F *src1, const R16G16B16A16F *src2)
- {
- dst->R = gl::averageHalfFloat(src1->R, src2->R);
- dst->G = gl::averageHalfFloat(src1->G, src2->G);
- dst->B = gl::averageHalfFloat(src1->B, src2->B);
- dst->A = gl::averageHalfFloat(src1->A, src2->A);
- }
-};
-
-struct R16F
-{
- unsigned short R;
-
- static void readColor(gl::ColorF *dst, const R16F *src)
- {
- dst->red = gl::float16ToFloat32(src->R);
- dst->green = 0.0f;
- dst->blue = 0.0f;
- dst->alpha = 1.0f;
- }
-
- static void writeColor(R16F *dst, const gl::ColorF *src)
- {
- dst->R = gl::float32ToFloat16(src->red);
- }
-
- static void average(R16F *dst, const R16F *src1, const R16F *src2)
- {
- dst->R = gl::averageHalfFloat(src1->R, src2->R);
- }
-};
-
-struct A16F
-{
- unsigned short A;
-
- static void readColor(gl::ColorF *dst, const A16F *src)
- {
- dst->red = 0.0f;
- dst->green = 0.0f;
- dst->blue = 0.0f;
- dst->alpha = gl::float16ToFloat32(src->A);
- }
-
- static void writeColor(A16F *dst, const gl::ColorF *src)
- {
- dst->A = gl::float32ToFloat16(src->alpha);
- }
-
- static void average(A16F *dst, const A16F *src1, const A16F *src2)
- {
- dst->A = gl::averageHalfFloat(src1->A, src2->A);
- }
-};
-
-struct L16F
-{
- unsigned short L;
-
- static void readColor(gl::ColorF *dst, const L16F *src)
- {
- float lum = gl::float16ToFloat32(src->L);
- dst->red = lum;
- dst->green = lum;
- dst->blue = lum;
- dst->alpha = 1.0f;
- }
-
- static void writeColor(L16F *dst, const gl::ColorF *src)
- {
- dst->L = gl::float32ToFloat16((src->red + src->green + src->blue) / 3.0f);
- }
-
- static void average(L16F *dst, const L16F *src1, const L16F *src2)
- {
- dst->L = gl::averageHalfFloat(src1->L, src2->L);
- }
-};
-
-struct L16A16F
-{
- unsigned short L;
- unsigned short A;
-
- static void readColor(gl::ColorF *dst, const L16A16F *src)
- {
- float lum = gl::float16ToFloat32(src->L);
- dst->red = lum;
- dst->green = lum;
- dst->blue = lum;
- dst->alpha = gl::float16ToFloat32(src->A);
- }
-
- static void writeColor(L16A16F *dst, const gl::ColorF *src)
- {
- dst->L = gl::float32ToFloat16((src->red + src->green + src->blue) / 3.0f);
- dst->A = gl::float32ToFloat16(src->alpha);
- }
-
- static void average(L16A16F *dst, const L16A16F *src1, const L16A16F *src2)
- {
- dst->L = gl::averageHalfFloat(src1->L, src2->L);
- dst->A = gl::averageHalfFloat(src1->A, src2->A);
- }
-};
-
-struct R16G16F
-{
- unsigned short R;
- unsigned short G;
-
- static void readColor(gl::ColorF *dst, const R16G16F *src)
- {
- dst->red = gl::float16ToFloat32(src->R);
- dst->green = gl::float16ToFloat32(src->G);
- dst->blue = 0.0f;
- dst->alpha = 1.0f;
- }
-
- static void writeColor(R16G16F *dst, const gl::ColorF *src)
- {
- dst->R = gl::float32ToFloat16(src->red);
- dst->G = gl::float32ToFloat16(src->green);
- }
-
- static void average(R16G16F *dst, const R16G16F *src1, const R16G16F *src2)
- {
- dst->R = gl::averageHalfFloat(src1->R, src2->R);
- dst->G = gl::averageHalfFloat(src1->G, src2->G);
- }
-};
-
-struct R16G16B16F
-{
- unsigned short R;
- unsigned short G;
- unsigned short B;
-
- static void readColor(gl::ColorF *dst, const R16G16B16F *src)
- {
- dst->red = gl::float16ToFloat32(src->R);
- dst->green = gl::float16ToFloat32(src->G);
- dst->blue = gl::float16ToFloat32(src->B);
- dst->alpha = 1.0f;
- }
-
- static void writeColor(R16G16B16F *dst, const gl::ColorF *src)
- {
- dst->R = gl::float32ToFloat16(src->red);
- dst->G = gl::float32ToFloat16(src->green);
- dst->B = gl::float32ToFloat16(src->blue);
- }
-
- static void average(R16G16B16F *dst, const R16G16B16F *src1, const R16G16B16F *src2)
- {
- dst->R = gl::averageHalfFloat(src1->R, src2->R);
- dst->G = gl::averageHalfFloat(src1->G, src2->G);
- dst->B = gl::averageHalfFloat(src1->B, src2->B);
- }
-};
-
-struct A32B32G32R32F
-{
- float A;
- float R;
- float G;
- float B;
-
- static void readColor(gl::ColorF *dst, const A32B32G32R32F *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = src->A;
- }
-
- static void writeColor(A32B32G32R32F *dst, const gl::ColorF *src)
- {
- dst->R = src->red;
- dst->G = src->green;
- dst->B = src->blue;
- dst->A = src->alpha;
- }
-
- static void average(A32B32G32R32F *dst, const A32B32G32R32F *src1, const A32B32G32R32F *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- dst->A = gl::average(src1->A, src2->A);
- }
-};
-
-struct R32G32B32A32F
-{
- float R;
- float G;
- float B;
- float A;
-
- static void readColor(gl::ColorF *dst, const R32G32B32A32F *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = src->A;
- }
-
- static void writeColor(R32G32B32A32F *dst, const gl::ColorF *src)
- {
- dst->R = src->red;
- dst->G = src->green;
- dst->B = src->blue;
- dst->A = src->alpha;
- }
-
- static void average(R32G32B32A32F *dst, const R32G32B32A32F *src1, const R32G32B32A32F *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- dst->A = gl::average(src1->A, src2->A);
- }
-};
-
-struct R32F
-{
- float R;
-
- static void readColor(gl::ColorF *dst, const R32F *src)
- {
- dst->red = src->R;
- dst->green = 0.0f;
- dst->blue = 0.0f;
- dst->alpha = 1.0f;
- }
-
- static void writeColor(R32F *dst, const gl::ColorF *src)
- {
- dst->R = src->red;
- }
-
- static void average(R32F *dst, const R32F *src1, const R32F *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- }
-};
-
-struct A32F
-{
- float A;
-
- static void readColor(gl::ColorF *dst, const A32F *src)
- {
- dst->red = 0.0f;
- dst->green = 0.0f;
- dst->blue = 0.0f;
- dst->alpha = src->A;
- }
-
- static void writeColor(A32F *dst, const gl::ColorF *src)
- {
- dst->A = src->alpha;
- }
-
- static void average(A32F *dst, const A32F *src1, const A32F *src2)
- {
- dst->A = gl::average(src1->A, src2->A);
- }
-};
-
-struct L32F
-{
- float L;
-
- static void readColor(gl::ColorF *dst, const L32F *src)
- {
- dst->red = src->L;
- dst->green = src->L;
- dst->blue = src->L;
- dst->alpha = 1.0f;
- }
-
- static void writeColor(L32F *dst, const gl::ColorF *src)
- {
- dst->L = (src->red + src->green + src->blue) / 3.0f;
- }
-
- static void average(L32F *dst, const L32F *src1, const L32F *src2)
- {
- dst->L = gl::average(src1->L, src2->L);
- }
-};
-
-struct L32A32F
-{
- float L;
- float A;
-
- static void readColor(gl::ColorF *dst, const L32A32F *src)
- {
- dst->red = src->L;
- dst->green = src->L;
- dst->blue = src->L;
- dst->alpha = src->A;
- }
-
- static void writeColor(L32A32F *dst, const gl::ColorF *src)
- {
- dst->L = (src->red + src->green + src->blue) / 3.0f;
- dst->A = src->alpha;
- }
-
- static void average(L32A32F *dst, const L32A32F *src1, const L32A32F *src2)
- {
- dst->L = gl::average(src1->L, src2->L);
- dst->A = gl::average(src1->A, src2->A);
- }
-};
-
-struct R32G32F
-{
- float R;
- float G;
-
- static void readColor(gl::ColorF *dst, const R32G32F *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = 0.0f;
- dst->alpha = 1.0f;
- }
-
- static void writeColor(R32G32F *dst, const gl::ColorF *src)
- {
- dst->R = src->red;
- dst->G = src->green;
- }
-
- static void average(R32G32F *dst, const R32G32F *src1, const R32G32F *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- }
-};
-
-struct R32G32B32F
-{
- float R;
- float G;
- float B;
-
- static void readColor(gl::ColorF *dst, const R32G32B32F *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = 1.0f;
- }
-
- static void writeColor(R32G32B32F *dst, const gl::ColorF *src)
- {
- dst->R = src->red;
- dst->G = src->green;
- dst->B = src->blue;
- }
-
- static void average(R32G32B32F *dst, const R32G32B32F *src1, const R32G32B32F *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- }
-};
-
-struct R10G10B10A2
-{
- unsigned int R : 10;
- unsigned int G : 10;
- unsigned int B : 10;
- unsigned int A : 2;
-
- static void readColor(gl::ColorF *dst, const R10G10B10A2 *src)
- {
- dst->red = gl::normalizedToFloat<10>(src->R);
- dst->green = gl::normalizedToFloat<10>(src->G);
- dst->blue = gl::normalizedToFloat<10>(src->B);
- dst->alpha = gl::normalizedToFloat< 2>(src->A);
- }
-
- static void readColor(gl::ColorUI *dst, const R10G10B10A2 *src)
- {
- dst->red = src->R;
- dst->green = src->G;
- dst->blue = src->B;
- dst->alpha = src->A;
- }
-
- static void writeColor(R10G10B10A2 *dst, const gl::ColorF *src)
- {
- dst->R = gl::floatToNormalized<10, unsigned int>(src->red);
- dst->G = gl::floatToNormalized<10, unsigned int>(src->green);
- dst->B = gl::floatToNormalized<10, unsigned int>(src->blue);
- dst->A = gl::floatToNormalized< 2, unsigned int>(src->alpha);
- }
-
- static void writeColor(R10G10B10A2 *dst, const gl::ColorUI *src)
- {
- dst->R = static_cast<unsigned int>(src->red);
- dst->G = static_cast<unsigned int>(src->green);
- dst->B = static_cast<unsigned int>(src->blue);
- dst->A = static_cast<unsigned int>(src->alpha);
- }
-
- static void average(R10G10B10A2 *dst, const R10G10B10A2 *src1, const R10G10B10A2 *src2)
- {
- dst->R = gl::average(src1->R, src2->R);
- dst->G = gl::average(src1->G, src2->G);
- dst->B = gl::average(src1->B, src2->B);
- dst->A = gl::average(src1->A, src2->A);
- }
-};
-
-struct R9G9B9E5
-{
- unsigned int R : 9;
- unsigned int G : 9;
- unsigned int B : 9;
- unsigned int E : 5;
-
- static void readColor(gl::ColorF *dst, const R9G9B9E5 *src)
- {
- gl::convert999E5toRGBFloats(gl::bitCast<unsigned int>(*src), &dst->red, &dst->green, &dst->blue);
- dst->alpha = 1.0f;
- }
-
- static void writeColor(R9G9B9E5 *dst, const gl::ColorF *src)
- {
- *reinterpret_cast<unsigned int*>(dst) = gl::convertRGBFloatsTo999E5(src->red,
- src->green,
- src->blue);
- }
-
- static void average(R9G9B9E5 *dst, const R9G9B9E5 *src1, const R9G9B9E5 *src2)
- {
- float r1, g1, b1;
- gl::convert999E5toRGBFloats(*reinterpret_cast<const unsigned int*>(src1), &r1, &g1, &b1);
-
- float r2, g2, b2;
- gl::convert999E5toRGBFloats(*reinterpret_cast<const unsigned int*>(src2), &r2, &g2, &b2);
-
- *reinterpret_cast<unsigned int*>(dst) = gl::convertRGBFloatsTo999E5(gl::average(r1, r2),
- gl::average(g1, g2),
- gl::average(b1, b2));
- }
-};
-
-struct R11G11B10F
-{
- unsigned int R : 11;
- unsigned int G : 11;
- unsigned int B : 10;
-
- static void readColor(gl::ColorF *dst, const R11G11B10F *src)
- {
- dst->red = gl::float11ToFloat32(src->R);
- dst->green = gl::float11ToFloat32(src->G);
- dst->blue = gl::float10ToFloat32(src->B);
- dst->alpha = 1.0f;
- }
-
- static void writeColor(R11G11B10F *dst, const gl::ColorF *src)
- {
- dst->R = gl::float32ToFloat11(src->red);
- dst->G = gl::float32ToFloat11(src->green);
- dst->B = gl::float32ToFloat10(src->blue);
- }
-
- static void average(R11G11B10F *dst, const R11G11B10F *src1, const R11G11B10F *src2)
- {
- dst->R = gl::averageFloat11(src1->R, src2->R);
- dst->G = gl::averageFloat11(src1->G, src2->G);
- dst->B = gl::averageFloat10(src1->B, src2->B);
- }
-};
-
-}
-
-#endif // LIBGLESV2_RENDERER_IMAGEFORMATS_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/loadimage.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/loadimage.cpp
deleted file mode 100644
index 1986191a75..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/loadimage.cpp
+++ /dev/null
@@ -1,661 +0,0 @@
-//
-// Copyright (c) 2013-2014 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.
-//
-
-// loadimage.cpp: Defines image loading functions.
-
-#include "libGLESv2/renderer/loadimage.h"
-
-namespace rx
-{
-
-void LoadA8ToRGBA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint8_t *source = OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[x] = static_cast<uint32_t>(source[x]) << 24;
- }
- }
- }
-}
-
-void LoadA8ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- // Same as loading to RGBA
- LoadA8ToRGBA8(width, height, depth, input, inputRowPitch, inputDepthPitch, output, outputRowPitch, outputDepthPitch);
-}
-
-void LoadA32FToRGBA32F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const float *source = OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- float *dest = OffsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[4 * x + 0] = 0.0f;
- dest[4 * x + 1] = 0.0f;
- dest[4 * x + 2] = 0.0f;
- dest[4 * x + 3] = source[x];
- }
- }
- }
-}
-
-void LoadA16FToRGBA16F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint16_t *dest = OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[4 * x + 0] = 0;
- dest[4 * x + 1] = 0;
- dest[4 * x + 2] = 0;
- dest[4 * x + 3] = source[x];
- }
- }
- }
-}
-
-void LoadL8ToRGBA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint8_t *source = OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[4 * x + 0] = source[x];
- dest[4 * x + 1] = source[x];
- dest[4 * x + 2] = source[x];
- dest[4 * x + 3] = 0xFF;
- }
- }
- }
-}
-
-void LoadL8ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- // Same as loading to RGBA
- LoadL8ToRGBA8(width, height, depth, input, inputRowPitch, inputDepthPitch, output, outputRowPitch, outputDepthPitch);
-}
-
-void LoadL32FToRGBA32F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const float *source = OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- float *dest = OffsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[4 * x + 0] = source[x];
- dest[4 * x + 1] = source[x];
- dest[4 * x + 2] = source[x];
- dest[4 * x + 3] = 1.0f;
- }
- }
- }
-}
-
-void LoadL16FToRGBA16F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint16_t *dest = OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[4 * x + 0] = source[x];
- dest[4 * x + 1] = source[x];
- dest[4 * x + 2] = source[x];
- dest[4 * x + 3] = gl::Float16One;
- }
- }
- }
-}
-
-void LoadLA8ToRGBA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint8_t *source = OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[4 * x + 0] = source[2 * x + 0];
- dest[4 * x + 1] = source[2 * x + 0];
- dest[4 * x + 2] = source[2 * x + 0];
- dest[4 * x + 3] = source[2 * x + 1];
- }
- }
- }
-}
-
-void LoadLA8ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- // Same as loading to RGBA
- LoadLA8ToRGBA8(width, height, depth, input, inputRowPitch, inputDepthPitch, output, outputRowPitch, outputDepthPitch);
-}
-
-void LoadLA32FToRGBA32F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const float *source = OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- float *dest = OffsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[4 * x + 0] = source[2 * x + 0];
- dest[4 * x + 1] = source[2 * x + 0];
- dest[4 * x + 2] = source[2 * x + 0];
- dest[4 * x + 3] = source[2 * x + 1];
- }
- }
- }
-}
-
-void LoadLA16FToRGBA16F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint16_t *dest = OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[4 * x + 0] = source[2 * x + 0];
- dest[4 * x + 1] = source[2 * x + 0];
- dest[4 * x + 2] = source[2 * x + 0];
- dest[4 * x + 3] = source[2 * x + 1];
- }
- }
- }
-}
-
-void LoadRGB8ToBGRX8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint8_t *source = OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[4 * x + 0] = source[x * 3 + 2];
- dest[4 * x + 1] = source[x * 3 + 1];
- dest[4 * x + 2] = source[x * 3 + 0];
- dest[4 * x + 3] = 0xFF;
- }
- }
- }
-}
-
-void LoadRG8ToBGRX8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint8_t *source = OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[4 * x + 0] = 0x00;
- dest[4 * x + 1] = source[x * 2 + 1];
- dest[4 * x + 2] = source[x * 2 + 0];
- dest[4 * x + 3] = 0xFF;
- }
- }
- }
-}
-
-void LoadR8ToBGRX8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint8_t *source = OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[4 * x + 0] = 0x00;
- dest[4 * x + 1] = 0x00;
- dest[4 * x + 2] = source[x];
- dest[4 * x + 3] = 0xFF;
- }
- }
- }
-}
-
-void LoadR5G6B5ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- uint16_t rgb = source[x];
- dest[4 * x + 0] = ((rgb & 0x001F) << 3) | ((rgb & 0x001F) >> 2);
- dest[4 * x + 1] = ((rgb & 0x07E0) >> 3) | ((rgb & 0x07E0) >> 9);
- dest[4 * x + 2] = ((rgb & 0xF800) >> 8) | ((rgb & 0xF800) >> 13);
- dest[4 * x + 3] = 0xFF;
- }
- }
- }
-}
-
-void LoadR5G6B5ToRGBA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- uint16_t rgb = source[x];
- dest[4 * x + 0] = ((rgb & 0xF800) >> 8) | ((rgb & 0xF800) >> 13);
- dest[4 * x + 1] = ((rgb & 0x07E0) >> 3) | ((rgb & 0x07E0) >> 9);
- dest[4 * x + 2] = ((rgb & 0x001F) << 3) | ((rgb & 0x001F) >> 2);
- dest[4 * x + 3] = 0xFF;
- }
- }
- }
-}
-
-void LoadRGBA8ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint32_t *source = OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- uint32_t rgba = source[x];
- dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00);
- }
- }
- }
-}
-
-void LoadRGBA4ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- uint16_t rgba = source[x];
- dest[4 * x + 0] = ((rgba & 0x00F0) << 0) | ((rgba & 0x00F0) >> 4);
- dest[4 * x + 1] = ((rgba & 0x0F00) >> 4) | ((rgba & 0x0F00) >> 8);
- dest[4 * x + 2] = ((rgba & 0xF000) >> 8) | ((rgba & 0xF000) >> 12);
- dest[4 * x + 3] = ((rgba & 0x000F) << 4) | ((rgba & 0x000F) >> 0);
- }
- }
- }
-}
-
-void LoadRGBA4ToRGBA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- uint16_t rgba = source[x];
- dest[4 * x + 0] = ((rgba & 0xF000) >> 8) | ((rgba & 0xF000) >> 12);
- dest[4 * x + 1] = ((rgba & 0x0F00) >> 4) | ((rgba & 0x0F00) >> 8);
- dest[4 * x + 2] = ((rgba & 0x00F0) << 0) | ((rgba & 0x00F0) >> 4);
- dest[4 * x + 3] = ((rgba & 0x000F) << 4) | ((rgba & 0x000F) >> 0);
- }
- }
- }
-}
-
-void LoadBGRA4ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- uint16_t bgra = source[x];
- dest[4 * x + 0] = ((bgra & 0xF000) >> 8) | ((bgra & 0xF000) >> 12);
- dest[4 * x + 1] = ((bgra & 0x0F00) >> 4) | ((bgra & 0x0F00) >> 8);
- dest[4 * x + 2] = ((bgra & 0x00F0) << 0) | ((bgra & 0x00F0) >> 4);
- dest[4 * x + 3] = ((bgra & 0x000F) << 4) | ((bgra & 0x000F) >> 0);
- }
- }
- }
-}
-
-void LoadRGB5A1ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- uint16_t rgba = source[x];
- dest[4 * x + 0] = ((rgba & 0x003E) << 2) | ((rgba & 0x003E) >> 3);
- dest[4 * x + 1] = ((rgba & 0x07C0) >> 3) | ((rgba & 0x07C0) >> 8);
- dest[4 * x + 2] = ((rgba & 0xF800) >> 8) | ((rgba & 0xF800) >> 13);
- dest[4 * x + 3] = (rgba & 0x0001) ? 0xFF : 0;
- }
- }
- }
-}
-
-void LoadRGB5A1ToRGBA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- uint16_t rgba = source[x];
- dest[4 * x + 0] = ((rgba & 0xF800) >> 8) | ((rgba & 0xF800) >> 13);
- dest[4 * x + 1] = ((rgba & 0x07C0) >> 3) | ((rgba & 0x07C0) >> 8);
- dest[4 * x + 2] = ((rgba & 0x003E) << 2) | ((rgba & 0x003E) >> 3);
- dest[4 * x + 3] = (rgba & 0x0001) ? 0xFF : 0;
- }
- }
- }
-}
-
-
-void LoadBGR5A1ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- uint16_t bgra = source[x];
- dest[4 * x + 0] = ((bgra & 0xF800) >> 8) | ((bgra & 0xF800) >> 13);
- dest[4 * x + 1] = ((bgra & 0x07C0) >> 3) | ((bgra & 0x07C0) >> 8);
- dest[4 * x + 2] = ((bgra & 0x003E) << 2) | ((bgra & 0x003E) >> 3);
- dest[4 * x + 3] = (bgra & 0x0001) ? 0xFF : 0;
- }
- }
- }
-}
-
-void LoadRGB10A2ToRGBA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint32_t *source = OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- uint32_t rgba = source[x];
- dest[4 * x + 0] = (rgba & 0x000003FF) >> 2;
- dest[4 * x + 1] = (rgba & 0x000FFC00) >> 12;
- dest[4 * x + 2] = (rgba & 0x3FF00000) >> 22;
- dest[4 * x + 3] = ((rgba & 0xC0000000) >> 30) * 0x55;
- }
- }
- }
-}
-
-void LoadRGB16FToRGB9E5(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[x] = gl::convertRGBFloatsTo999E5(gl::float16ToFloat32(source[x * 3 + 0]),
- gl::float16ToFloat32(source[x * 3 + 1]),
- gl::float16ToFloat32(source[x * 3 + 2]));
- }
- }
- }
-}
-
-void LoadRGB32FToRGB9E5(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const float *source = OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[x] = gl::convertRGBFloatsTo999E5(source[x * 3 + 0], source[x * 3 + 1], source[x * 3 + 2]);
- }
- }
- }
-}
-
-void LoadRGB16FToRG11B10F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[x] = (gl::float32ToFloat11(gl::float16ToFloat32(source[x * 3 + 0])) << 0) |
- (gl::float32ToFloat11(gl::float16ToFloat32(source[x * 3 + 1])) << 11) |
- (gl::float32ToFloat10(gl::float16ToFloat32(source[x * 3 + 2])) << 22);
- }
- }
- }
-}
-
-void LoadRGB32FToRG11B10F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const float *source = OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[x] = (gl::float32ToFloat11(source[x * 3 + 0]) << 0) |
- (gl::float32ToFloat11(source[x * 3 + 1]) << 11) |
- (gl::float32ToFloat10(source[x * 3 + 2]) << 22);
- }
- }
- }
-}
-
-void LoadG8R24ToR24G8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint32_t *source = OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- uint32_t d = source[x] >> 8;
- uint8_t s = source[x] & 0xFF;
- dest[x] = d | (s << 24);
- }
- }
- }
-}
-
-void LoadRGB32FToRGBA16F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const float *source = OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- uint16_t *dest = OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[x * 4 + 0] = gl::float32ToFloat16(source[x * 3 + 0]);
- dest[x * 4 + 1] = gl::float32ToFloat16(source[x * 3 + 1]);
- dest[x * 4 + 2] = gl::float32ToFloat16(source[x * 3 + 2]);
- dest[x * 4 + 3] = gl::Float16One;
- }
- }
- }
-}
-
-void LoadR32ToR16(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint32_t *source = OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint16_t *dest = OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[x] = source[x] >> 16;
- }
- }
- }
-}
-
-void LoadR32ToR24G8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint32_t *source = OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
-
- for (size_t x = 0; x < width; x++)
- {
- dest[x] = source[x] >> 8;
- }
- }
- }
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/loadimage.h b/src/3rdparty/angle/src/libGLESv2/renderer/loadimage.h
deleted file mode 100644
index bcdff24a66..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/loadimage.h
+++ /dev/null
@@ -1,193 +0,0 @@
-//
-// Copyright (c) 2013-2014 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.
-//
-
-// loadimage.h: Defines image loading functions
-
-#ifndef LIBGLESV2_RENDERER_LOADIMAGE_H_
-#define LIBGLESV2_RENDERER_LOADIMAGE_H_
-
-#include "libGLESv2/angletypes.h"
-
-#include <cstdint>
-
-namespace rx
-{
-
-void LoadA8ToRGBA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadA8ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadA32FToRGBA32F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadA16FToRGBA16F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadL8ToRGBA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadL8ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadL32FToRGBA32F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadL16FToRGBA16F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadLA8ToRGBA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadLA8ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadLA32FToRGBA32F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadLA16FToRGBA16F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadRGB8ToBGRX8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadRG8ToBGRX8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadR8ToBGRX8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadR5G6B5ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadR5G6B5ToRGBA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadRGBA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadRGBA8ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadRGBA4ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadRGBA4ToRGBA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadBGRA4ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadRGB5A1ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadRGB5A1ToRGBA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadBGR5A1ToBGRA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadRGB10A2ToRGBA8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadRGB16FToRGB9E5(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadRGB32FToRGB9E5(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadRGB16FToRG11B10F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadRGB32FToRG11B10F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadG8R24ToR24G8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-template <typename type, size_t componentCount>
-inline void LoadToNative(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-template <typename type, uint32_t fourthComponentBits>
-inline void LoadToNative3To4(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-template <size_t componentCount>
-inline void Load32FTo16F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadRGB32FToRGBA16F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-template <size_t blockWidth, size_t blockHeight, size_t blockSize>
-inline void LoadCompressedToNative(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadR32ToR16(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-template <typename type, uint32_t firstBits, uint32_t secondBits, uint32_t thirdBits, uint32_t fourthBits>
-inline void Initialize4ComponentData(size_t width, size_t height, size_t depth,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-void LoadR32ToR24G8(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
-
-template <typename T>
-inline T *OffsetDataPointer(uint8_t *data, size_t y, size_t z, size_t rowPitch, size_t depthPitch);
-
-template <typename T>
-inline const T *OffsetDataPointer(const uint8_t *data, size_t y, size_t z, size_t rowPitch, size_t depthPitch);
-
-}
-
-#include "loadimage.inl"
-
-#endif // LIBGLESV2_RENDERER_LOADIMAGE_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/loadimage.inl b/src/3rdparty/angle/src/libGLESv2/renderer/loadimage.inl
deleted file mode 100644
index abd0a3673c..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/loadimage.inl
+++ /dev/null
@@ -1,156 +0,0 @@
-//
-// Copyright (c) 2014 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.
-//
-
-#include "common/mathutil.h"
-
-namespace rx
-{
-
-template <typename T>
-inline T *OffsetDataPointer(uint8_t *data, size_t y, size_t z, size_t rowPitch, size_t depthPitch)
-{
- return reinterpret_cast<T*>(data + (y * rowPitch) + (z * depthPitch));
-}
-
-template <typename T>
-inline const T *OffsetDataPointer(const uint8_t *data, size_t y, size_t z, size_t rowPitch, size_t depthPitch)
-{
- return reinterpret_cast<const T*>(data + (y * rowPitch) + (z * depthPitch));
-}
-
-template <typename type, size_t componentCount>
-inline void LoadToNative(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- const size_t rowSize = width * sizeof(type) * componentCount;
- const size_t layerSize = rowSize * height;
- const size_t imageSize = layerSize * depth;
-
- if (layerSize == inputDepthPitch && layerSize == outputDepthPitch)
- {
- ASSERT(rowSize == inputRowPitch && rowSize == outputRowPitch);
- memcpy(output, input, imageSize);
- }
- else if (rowSize == inputRowPitch && rowSize == outputRowPitch)
- {
- for (size_t z = 0; z < depth; z++)
- {
- const type *source = OffsetDataPointer<type>(input, 0, z, inputRowPitch, inputDepthPitch);
- type *dest = OffsetDataPointer<type>(output, 0, z, outputRowPitch, outputDepthPitch);
-
- memcpy(dest, source, layerSize);
- }
- }
- else
- {
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const type *source = OffsetDataPointer<type>(input, y, z, inputRowPitch, inputDepthPitch);
- type *dest = OffsetDataPointer<type>(output, y, z, outputRowPitch, outputDepthPitch);
- memcpy(dest, source, width * sizeof(type) * componentCount);
- }
- }
- }
-}
-
-template <typename type, uint32_t fourthComponentBits>
-inline void LoadToNative3To4(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- const type fourthValue = gl::bitCast<type>(fourthComponentBits);
-
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const type *source = OffsetDataPointer<type>(input, y, z, inputRowPitch, inputDepthPitch);
- type *dest = OffsetDataPointer<type>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- dest[x * 4 + 0] = source[x * 3 + 0];
- dest[x * 4 + 1] = source[x * 3 + 1];
- dest[x * 4 + 2] = source[x * 3 + 2];
- dest[x * 4 + 3] = fourthValue;
- }
- }
- }
-}
-
-template <size_t componentCount>
-inline void Load32FTo16F(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- const size_t elementWidth = componentCount * width;
-
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const float *source = OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- uint16_t *dest = OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch);
-
- for (size_t x = 0; x < elementWidth; x++)
- {
- dest[x] = gl::float32ToFloat16(source[x]);
- }
- }
- }
-}
-
-template <size_t blockWidth, size_t blockHeight, size_t blockSize>
-inline void LoadCompressedToNative(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- const size_t columns = (width + (blockWidth - 1)) / blockWidth;
- const size_t rows = (height + (blockHeight - 1)) / blockHeight;
-
- for (size_t z = 0; z < depth; ++z)
- {
- for (size_t y = 0; y < rows; ++y)
- {
- const uint8_t *source = OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
- memcpy(dest, source, columns * blockSize);
- }
- }
-}
-
-template <typename type, uint32_t firstBits, uint32_t secondBits, uint32_t thirdBits, uint32_t fourthBits>
-inline void Initialize4ComponentData(size_t width, size_t height, size_t depth,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
- type writeValues[4] =
- {
- gl::bitCast<type>(firstBits),
- gl::bitCast<type>(secondBits),
- gl::bitCast<type>(thirdBits),
- gl::bitCast<type>(fourthBits),
- };
-
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- type *destRow = OffsetDataPointer<type>(output, y, z, outputRowPitch, outputDepthPitch);
- for (size_t x = 0; x < width; x++)
- {
- type* destPixel = destRow + x * 4;
-
- // This could potentially be optimized by generating an entire row of initialization
- // data and copying row by row instead of pixel by pixel.
- memcpy(destPixel, writeValues, sizeof(type) * 4);
- }
- }
- }
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/loadimageSSE2.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/loadimageSSE2.cpp
deleted file mode 100644
index 159b4c7e9f..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/loadimageSSE2.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-//
-// Copyright (c) 2002-2014 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.
-//
-
-// loadimageSSE2.cpp: Defines image loading functions. It's
-// in a separated file for GCC, which can enable SSE usage only per-file,
-// not for code blocks that use SSE2 explicitly.
-
-#include "libGLESv2/renderer/loadimage.h"
-
-namespace rx
-{
-
-void LoadA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
-#if defined(_M_ARM)
- // Ensure that this function is reported as not implemented for ARM builds because
- // the instructions below are not present for that architecture.
- UNIMPLEMENTED();
- return;
-#else
- __m128i zeroWide = _mm_setzero_si128();
-
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint8_t *source = OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
-
- size_t x = 0;
-
- // Make output writes aligned
- for (; ((reinterpret_cast<intptr_t>(&dest[x]) & 0xF) != 0 && x < width); x++)
- {
- dest[x] = static_cast<uint32_t>(source[x]) << 24;
- }
-
- for (; x + 7 < width; x += 8)
- {
- __m128i sourceData = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(&source[x]));
- // Interleave each byte to 16bit, make the lower byte to zero
- sourceData = _mm_unpacklo_epi8(zeroWide, sourceData);
- // Interleave each 16bit to 32bit, make the lower 16bit to zero
- __m128i lo = _mm_unpacklo_epi16(zeroWide, sourceData);
- __m128i hi = _mm_unpackhi_epi16(zeroWide, sourceData);
-
- _mm_store_si128(reinterpret_cast<__m128i*>(&dest[x]), lo);
- _mm_store_si128(reinterpret_cast<__m128i*>(&dest[x + 4]), hi);
- }
-
- // Handle the remainder
- for (; x < width; x++)
- {
- dest[x] = static_cast<uint32_t>(source[x]) << 24;
- }
- }
- }
-#endif
-}
-
-void LoadRGBA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth,
- const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
- uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
-{
-#if defined(_M_ARM)
- // Ensure that this function is reported as not implemented for ARM builds because
- // the instructions below are not present for that architecture.
- UNIMPLEMENTED();
- return;
-#else
- __m128i brMask = _mm_set1_epi32(0x00ff00ff);
-
- for (size_t z = 0; z < depth; z++)
- {
- for (size_t y = 0; y < height; y++)
- {
- const uint32_t *source = OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch);
- uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
-
- size_t x = 0;
-
- // Make output writes aligned
- for (; ((reinterpret_cast<intptr_t>(&dest[x]) & 15) != 0) && x < width; x++)
- {
- uint32_t rgba = source[x];
- dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00);
- }
-
- for (; x + 3 < width; x += 4)
- {
- __m128i sourceData = _mm_loadu_si128(reinterpret_cast<const __m128i*>(&source[x]));
- // Mask out g and a, which don't change
- __m128i gaComponents = _mm_andnot_si128(brMask, sourceData);
- // Mask out b and r
- __m128i brComponents = _mm_and_si128(sourceData, brMask);
- // Swap b and r
- __m128i brSwapped = _mm_shufflehi_epi16(_mm_shufflelo_epi16(brComponents, _MM_SHUFFLE(2, 3, 0, 1)), _MM_SHUFFLE(2, 3, 0, 1));
- __m128i result = _mm_or_si128(gaComponents, brSwapped);
- _mm_store_si128(reinterpret_cast<__m128i*>(&dest[x]), result);
- }
-
- // Perform leftover writes
- for (; x < width; x++)
- {
- uint32_t rgba = source[x];
- dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00);
- }
- }
- }
-#endif
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/vertexconversion.h b/src/3rdparty/angle/src/libGLESv2/renderer/vertexconversion.h
deleted file mode 100644
index 81ba8a0767..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/renderer/vertexconversion.h
+++ /dev/null
@@ -1,197 +0,0 @@
-//
-// Copyright (c) 2002-2010 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.
-//
-
-// vertexconversion.h: A library of vertex conversion classes that can be used to build
-// the FormatConverter objects used by the buffer conversion system.
-
-#ifndef LIBGLESV2_VERTEXCONVERSION_H_
-#define LIBGLESV2_VERTEXCONVERSION_H_
-
-#include <limits>
-#include <cstdint>
-#include <cstddef>
-
-namespace rx
-{
-
-// Conversion types:
-// static const bool identity: true if this is an identity transform, false otherwise
-// static U convert(T): convert a single element from the input type to the output type
-// typedef ... OutputType: the type produced by this conversion
-
-template <class T>
-struct Identity
-{
- static const bool identity = true;
-
- typedef T OutputType;
-
- static T convert(T x)
- {
- return x;
- }
-};
-
-template <class FromT, class ToT>
-struct Cast
-{
- static const bool identity = false;
-
- typedef ToT OutputType;
-
- static ToT convert(FromT x)
- {
- return static_cast<ToT>(x);
- }
-};
-
-template <class T>
-struct Cast<T, T>
-{
- static const bool identity = true;
-
- typedef T OutputType;
-
- static T convert(T x)
- {
- return static_cast<T>(x);
- }
-};
-
-template <class T>
-struct Normalize
-{
- static const bool identity = false;
-
- typedef float OutputType;
-
- static float convert(T x)
- {
- typedef std::numeric_limits<T> NL;
- float f = static_cast<float>(x);
-
- if (NL::is_signed)
- {
- // const float => VC2008 computes it at compile time
- // static const float => VC2008 computes it the first time we get here, stores it to memory with static guard and all that.
- const float divisor = 1.0f/(2*static_cast<float>(NL::max())+1);
- return (2*f+1)*divisor;
- }
- else
- {
- return f/NL::max();
- }
- }
-};
-
-template <class FromType, std::size_t ScaleBits>
-struct FixedToFloat
-{
- static const bool identity = false;
-
- typedef float OutputType;
-
- static float convert(FromType x)
- {
- const float divisor = 1.0f / static_cast<float>(static_cast<FromType>(1) << ScaleBits);
- return static_cast<float>(x) * divisor;
- }
-};
-
-// Widen types:
-// static const unsigned int initialWidth: number of components before conversion
-// static const unsigned int finalWidth: number of components after conversion
-
-// Float is supported at any size.
-template <std::size_t N>
-struct NoWiden
-{
- static const std::size_t initialWidth = N;
- static const std::size_t finalWidth = N;
-};
-
-// SHORT, norm-SHORT, norm-UNSIGNED_SHORT are supported but only with 2 or 4 components
-template <std::size_t N>
-struct WidenToEven
-{
- static const std::size_t initialWidth = N;
- static const std::size_t finalWidth = N+(N&1);
-};
-
-template <std::size_t N>
-struct WidenToFour
-{
- static const std::size_t initialWidth = N;
- static const std::size_t finalWidth = 4;
-};
-
-// Most types have 0 and 1 that are just that.
-template <class T>
-struct SimpleDefaultValues
-{
- static T zero() { return static_cast<T>(0); }
- static T one() { return static_cast<T>(1); }
-};
-
-// But normalised types only store [0,1] or [-1,1] so 1.0 is represented by the max value.
-template <class T>
-struct NormalizedDefaultValues
-{
- static T zero() { return static_cast<T>(0); }
- static T one() { return std::numeric_limits<T>::max(); }
-};
-
-// Converter:
-// static const bool identity: true if this is an identity transform (with no widening)
-// static const std::size_t finalSize: number of bytes per output vertex
-// static void convertArray(const void *in, std::size_t stride, std::size_t n, void *out): convert an array of vertices. Input may be strided, but output will be unstrided.
-
-template <class InT, class WidenRule, class Converter, class DefaultValueRule = SimpleDefaultValues<InT> >
-struct VertexDataConverter
-{
- typedef typename Converter::OutputType OutputType;
- typedef InT InputType;
-
- static const bool identity = (WidenRule::initialWidth == WidenRule::finalWidth) && Converter::identity;
- static const std::size_t finalSize = WidenRule::finalWidth * sizeof(OutputType);
-
- static void convertArray(const uint8_t *input, size_t stride, size_t n, uint8_t *output)
- {
- OutputType *out = reinterpret_cast<OutputType*>(output);
-
- for (std::size_t i = 0; i < n; i++)
- {
- const InputType *ein = reinterpret_cast<const InputType*>(input + i * stride);
-
- copyComponent(out, ein, 0, static_cast<OutputType>(DefaultValueRule::zero()));
- copyComponent(out, ein, 1, static_cast<OutputType>(DefaultValueRule::zero()));
- copyComponent(out, ein, 2, static_cast<OutputType>(DefaultValueRule::zero()));
- copyComponent(out, ein, 3, static_cast<OutputType>(DefaultValueRule::one()));
-
- out += WidenRule::finalWidth;
- }
- }
-
- private:
- static void copyComponent(OutputType *out, const InputType *in, std::size_t elementindex, OutputType defaultvalue)
- {
- if (WidenRule::finalWidth > elementindex)
- {
- if (WidenRule::initialWidth > elementindex)
- {
- out[elementindex] = Converter::convert(in[elementindex]);
- }
- else
- {
- out[elementindex] = defaultvalue;
- }
- }
- }
-};
-
-}
-
-#endif // LIBGLESV2_VERTEXCONVERSION_H_
diff --git a/src/3rdparty/angle/src/libGLESv2/validationES.cpp b/src/3rdparty/angle/src/libGLESv2/validationES.cpp
deleted file mode 100644
index 265f4b4fba..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/validationES.cpp
+++ /dev/null
@@ -1,1954 +0,0 @@
-//
-// Copyright (c) 2013-2014 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.
-//
-
-// validationES.h: Validation functions for generic OpenGL ES entry point parameters
-
-#include "libGLESv2/validationES.h"
-#include "libGLESv2/validationES2.h"
-#include "libGLESv2/validationES3.h"
-#include "libGLESv2/Context.h"
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/FramebufferAttachment.h"
-#include "libGLESv2/formatutils.h"
-#include "libGLESv2/main.h"
-#include "libGLESv2/Query.h"
-#include "libGLESv2/ProgramBinary.h"
-#include "libGLESv2/TransformFeedback.h"
-#include "libGLESv2/VertexArray.h"
-#include "libGLESv2/renderer/BufferImpl.h"
-
-#include "common/mathutil.h"
-#include "common/utilities.h"
-
-// FIXME(jmadill): remove this when we support buffer data caching
-#include "libGLESv2/renderer/d3d/BufferD3D.h"
-
-namespace gl
-{
-
-bool ValidCap(const Context *context, GLenum cap)
-{
- switch (cap)
- {
- case GL_CULL_FACE:
- case GL_POLYGON_OFFSET_FILL:
- case GL_SAMPLE_ALPHA_TO_COVERAGE:
- case GL_SAMPLE_COVERAGE:
- case GL_SCISSOR_TEST:
- case GL_STENCIL_TEST:
- case GL_DEPTH_TEST:
- case GL_BLEND:
- case GL_DITHER:
- return true;
- case GL_PRIMITIVE_RESTART_FIXED_INDEX:
- case GL_RASTERIZER_DISCARD:
- return (context->getClientVersion() >= 3);
- default:
- return false;
- }
-}
-
-bool ValidTextureTarget(const Context *context, GLenum target)
-{
- switch (target)
- {
- case GL_TEXTURE_2D:
- case GL_TEXTURE_CUBE_MAP:
- return true;
-
- case GL_TEXTURE_3D:
- case GL_TEXTURE_2D_ARRAY:
- return (context->getClientVersion() >= 3);
-
- default:
- return false;
- }
-}
-
-// This function differs from ValidTextureTarget in that the target must be
-// usable as the destination of a 2D operation-- so a cube face is valid, but
-// GL_TEXTURE_CUBE_MAP is not.
-// Note: duplicate of IsInternalTextureTarget
-bool ValidTexture2DDestinationTarget(const Context *context, GLenum target)
-{
- switch (target)
- {
- case GL_TEXTURE_2D:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- return true;
- case GL_TEXTURE_2D_ARRAY:
- case GL_TEXTURE_3D:
- return (context->getClientVersion() >= 3);
- default:
- return false;
- }
-}
-
-bool ValidFramebufferTarget(GLenum target)
-{
- META_ASSERT(GL_DRAW_FRAMEBUFFER_ANGLE == GL_DRAW_FRAMEBUFFER && GL_READ_FRAMEBUFFER_ANGLE == GL_READ_FRAMEBUFFER);
-
- switch (target)
- {
- case GL_FRAMEBUFFER: return true;
- case GL_READ_FRAMEBUFFER: return true;
- case GL_DRAW_FRAMEBUFFER: return true;
- default: return false;
- }
-}
-
-bool ValidBufferTarget(const Context *context, GLenum target)
-{
- switch (target)
- {
- case GL_ARRAY_BUFFER:
- case GL_ELEMENT_ARRAY_BUFFER:
- return true;
-
- case GL_PIXEL_PACK_BUFFER:
- case GL_PIXEL_UNPACK_BUFFER:
- return context->getExtensions().pixelBufferObject;
-
- case GL_COPY_READ_BUFFER:
- case GL_COPY_WRITE_BUFFER:
- case GL_TRANSFORM_FEEDBACK_BUFFER:
- case GL_UNIFORM_BUFFER:
- return (context->getClientVersion() >= 3);
-
- default:
- return false;
- }
-}
-
-bool ValidBufferParameter(const Context *context, GLenum pname)
-{
- switch (pname)
- {
- case GL_BUFFER_USAGE:
- case GL_BUFFER_SIZE:
- return true;
-
- // GL_BUFFER_MAP_POINTER is a special case, and may only be
- // queried with GetBufferPointerv
- case GL_BUFFER_ACCESS_FLAGS:
- case GL_BUFFER_MAPPED:
- case GL_BUFFER_MAP_OFFSET:
- case GL_BUFFER_MAP_LENGTH:
- return (context->getClientVersion() >= 3);
-
- default:
- return false;
- }
-}
-
-bool ValidMipLevel(const Context *context, GLenum target, GLint level)
-{
- size_t maxDimension = 0;
- switch (target)
- {
- case GL_TEXTURE_2D: maxDimension = context->getCaps().max2DTextureSize; break;
- case GL_TEXTURE_CUBE_MAP:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: maxDimension = context->getCaps().maxCubeMapTextureSize; break;
- case GL_TEXTURE_3D: maxDimension = context->getCaps().max3DTextureSize; break;
- case GL_TEXTURE_2D_ARRAY: maxDimension = context->getCaps().max2DTextureSize; break;
- default: UNREACHABLE();
- }
-
- return level <= gl::log2(maxDimension);
-}
-
-bool ValidImageSize(const Context *context, GLenum target, GLint level,
- GLsizei width, GLsizei height, GLsizei depth)
-{
- if (level < 0 || width < 0 || height < 0 || depth < 0)
- {
- return false;
- }
-
- if (!context->getExtensions().textureNPOT &&
- (level != 0 && (!gl::isPow2(width) || !gl::isPow2(height) || !gl::isPow2(depth))))
- {
- return false;
- }
-
- if (!ValidMipLevel(context, target, level))
- {
- return false;
- }
-
- return true;
-}
-
-bool ValidCompressedImageSize(const Context *context, GLenum internalFormat, GLsizei width, GLsizei height)
-{
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
- if (!formatInfo.compressed)
- {
- return false;
- }
-
- if (width < 0 || (static_cast<GLuint>(width) > formatInfo.compressedBlockWidth && width % formatInfo.compressedBlockWidth != 0) ||
- height < 0 || (static_cast<GLuint>(height) > formatInfo.compressedBlockHeight && height % formatInfo.compressedBlockHeight != 0))
- {
- return false;
- }
-
- return true;
-}
-
-bool ValidQueryType(const Context *context, GLenum queryType)
-{
- META_ASSERT(GL_ANY_SAMPLES_PASSED == GL_ANY_SAMPLES_PASSED_EXT);
- META_ASSERT(GL_ANY_SAMPLES_PASSED_CONSERVATIVE == GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT);
-
- switch (queryType)
- {
- case GL_ANY_SAMPLES_PASSED:
- case GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
- return true;
- case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
- return (context->getClientVersion() >= 3);
- default:
- return false;
- }
-}
-
-bool ValidProgram(Context *context, GLuint id)
-{
- // ES3 spec (section 2.11.1) -- "Commands that accept shader or program object names will generate the
- // error INVALID_VALUE if the provided name is not the name of either a shader or program object and
- // INVALID_OPERATION if the provided name identifies an object that is not the expected type."
-
- if (context->getProgram(id) != NULL)
- {
- return true;
- }
- else if (context->getShader(id) != NULL)
- {
- // ID is the wrong type
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- else
- {
- // No shader/program object has this ID
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-}
-
-bool ValidateAttachmentTarget(gl::Context *context, GLenum attachment)
-{
- if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
- {
- const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
-
- if (colorAttachment >= context->getCaps().maxColorAttachments)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- }
- else
- {
- switch (attachment)
- {
- case GL_DEPTH_ATTACHMENT:
- case GL_STENCIL_ATTACHMENT:
- break;
-
- case GL_DEPTH_STENCIL_ATTACHMENT:
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
-
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- }
-
- return true;
-}
-
-bool ValidateRenderbufferStorageParameters(gl::Context *context, GLenum target, GLsizei samples,
- GLenum internalformat, GLsizei width, GLsizei height,
- bool angleExtension)
-{
- switch (target)
- {
- case GL_RENDERBUFFER:
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if (width < 0 || height < 0 || samples < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
- if (!formatCaps.renderable)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- // ANGLE_framebuffer_multisample does not explicitly state that the internal format must be
- // sized but it does state that the format must be in the ES2.0 spec table 4.5 which contains
- // only sized internal formats. The ES3 spec (section 4.4.2) does, however, state that the
- // internal format must be sized and not an integer format if samples is greater than zero.
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
- if (formatInfo.pixelBytes == 0)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if ((formatInfo.componentType == GL_UNSIGNED_INT || formatInfo.componentType == GL_INT) && samples > 0)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (static_cast<GLuint>(std::max(width, height)) > context->getCaps().maxRenderbufferSize)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- // ANGLE_framebuffer_multisample states that the value of samples must be less than or equal
- // to MAX_SAMPLES_ANGLE (Context::getMaxSupportedSamples) while the ES3.0 spec (section 4.4.2)
- // states that samples must be less than or equal to the maximum samples for the specified
- // internal format.
- if (angleExtension)
- {
- ASSERT(context->getExtensions().framebufferMultisample);
- if (static_cast<GLuint>(samples) > context->getExtensions().maxSamples)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- // Check if this specific format supports enough samples
- if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples())
- {
- context->recordError(Error(GL_OUT_OF_MEMORY));
- return false;
- }
- }
- else
- {
- if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples())
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- }
-
- GLuint handle = context->getState().getRenderbufferId();
- if (handle == 0)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- return true;
-}
-
-bool ValidateFramebufferRenderbufferParameters(gl::Context *context, GLenum target, GLenum attachment,
- GLenum renderbuffertarget, GLuint renderbuffer)
-{
- if (!ValidFramebufferTarget(target))
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
- GLuint framebufferHandle = context->getState().getTargetFramebuffer(target)->id();
-
- if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (!ValidateAttachmentTarget(context, attachment))
- {
- return false;
- }
-
- // [OpenGL ES 2.0.25] Section 4.4.3 page 112
- // [OpenGL ES 3.0.2] Section 4.4.2 page 201
- // 'renderbuffer' must be either zero or the name of an existing renderbuffer object of
- // type 'renderbuffertarget', otherwise an INVALID_OPERATION error is generated.
- if (renderbuffer != 0)
- {
- if (!context->getRenderbuffer(renderbuffer))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
-
- return true;
-}
-
-static bool IsPartialBlit(gl::Context *context, gl::FramebufferAttachment *readBuffer, gl::FramebufferAttachment *writeBuffer,
- GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
- GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1)
-{
- if (srcX0 != 0 || srcY0 != 0 || dstX0 != 0 || dstY0 != 0 ||
- dstX1 != writeBuffer->getWidth() || dstY1 != writeBuffer->getHeight() ||
- srcX1 != readBuffer->getWidth() || srcY1 != readBuffer->getHeight())
- {
- return true;
- }
- else if (context->getState().isScissorTestEnabled())
- {
- const Rectangle &scissor = context->getState().getScissor();
-
- return scissor.x > 0 || scissor.y > 0 ||
- scissor.width < writeBuffer->getWidth() ||
- scissor.height < writeBuffer->getHeight();
- }
- else
- {
- return false;
- }
-}
-
-bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
- GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask,
- GLenum filter, bool fromAngleExtension)
-{
- switch (filter)
- {
- case GL_NEAREST:
- break;
- case GL_LINEAR:
- if (fromAngleExtension)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (mask == 0)
- {
- // ES3.0 spec, section 4.3.2 specifies that a mask of zero is valid and no
- // buffers are copied.
- return false;
- }
-
- if (fromAngleExtension && (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0))
- {
- ERR("Scaling and flipping in BlitFramebufferANGLE not supported by this implementation.");
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- // ES3.0 spec, section 4.3.2 states that linear filtering is only available for the
- // color buffer, leaving only nearest being unfiltered from above
- if ((mask & ~GL_COLOR_BUFFER_BIT) != 0 && filter != GL_NEAREST)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (context->getState().getReadFramebuffer()->id() == context->getState().getDrawFramebuffer()->id())
- {
- if (fromAngleExtension)
- {
- ERR("Blits with the same source and destination framebuffer are not supported by this "
- "implementation.");
- }
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- gl::Framebuffer *readFramebuffer = context->getState().getReadFramebuffer();
- gl::Framebuffer *drawFramebuffer = context->getState().getDrawFramebuffer();
-
- if (!readFramebuffer || !drawFramebuffer)
- {
- context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
- return false;
- }
-
- if (!readFramebuffer->completeness(context->getData()))
- {
- context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
- return false;
- }
-
- if (!drawFramebuffer->completeness(context->getData()))
- {
- context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
- return false;
- }
-
- if (drawFramebuffer->getSamples(context->getData()) != 0)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- bool sameBounds = srcX0 == dstX0 && srcY0 == dstY0 && srcX1 == dstX1 && srcY1 == dstY1;
-
- if (mask & GL_COLOR_BUFFER_BIT)
- {
- gl::FramebufferAttachment *readColorBuffer = readFramebuffer->getReadColorbuffer();
- gl::FramebufferAttachment *drawColorBuffer = drawFramebuffer->getFirstColorbuffer();
-
- if (readColorBuffer && drawColorBuffer)
- {
- GLenum readInternalFormat = readColorBuffer->getActualFormat();
- const InternalFormat &readFormatInfo = GetInternalFormatInfo(readInternalFormat);
-
- for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; i++)
- {
- if (drawFramebuffer->isEnabledColorAttachment(i))
- {
- GLenum drawInternalFormat = drawFramebuffer->getColorbuffer(i)->getActualFormat();
- const InternalFormat &drawFormatInfo = GetInternalFormatInfo(drawInternalFormat);
-
- // The GL ES 3.0.2 spec (pg 193) states that:
- // 1) If the read buffer is fixed point format, the draw buffer must be as well
- // 2) If the read buffer is an unsigned integer format, the draw buffer must be as well
- // 3) If the read buffer is a signed integer format, the draw buffer must be as well
- if ( (readFormatInfo.componentType == GL_UNSIGNED_NORMALIZED || readFormatInfo.componentType == GL_SIGNED_NORMALIZED) &&
- !(drawFormatInfo.componentType == GL_UNSIGNED_NORMALIZED || drawFormatInfo.componentType == GL_SIGNED_NORMALIZED))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (readFormatInfo.componentType == GL_UNSIGNED_INT && drawFormatInfo.componentType != GL_UNSIGNED_INT)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (readFormatInfo.componentType == GL_INT && drawFormatInfo.componentType != GL_INT)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (readColorBuffer->getSamples() > 0 && (readInternalFormat != drawInternalFormat || !sameBounds))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
- }
-
- if ((readFormatInfo.componentType == GL_INT || readFormatInfo.componentType == GL_UNSIGNED_INT) && filter == GL_LINEAR)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (fromAngleExtension)
- {
- const GLenum readColorbufferType = readFramebuffer->getReadColorbufferType();
- if (readColorbufferType != GL_TEXTURE_2D && readColorbufferType != GL_RENDERBUFFER)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
- {
- if (drawFramebuffer->isEnabledColorAttachment(colorAttachment))
- {
- FramebufferAttachment *attachment = drawFramebuffer->getColorbuffer(colorAttachment);
- ASSERT(attachment);
-
- if (attachment->type() != GL_TEXTURE_2D && attachment->type() != GL_RENDERBUFFER)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- // Return an error if the destination formats do not match
- if (attachment->getInternalFormat() != readColorBuffer->getInternalFormat())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
- }
-
- int readSamples = readFramebuffer->getSamples(context->getData());
-
- if (readSamples != 0 && IsPartialBlit(context, readColorBuffer, drawColorBuffer,
- srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
- }
- }
-
- if (mask & GL_DEPTH_BUFFER_BIT)
- {
- gl::FramebufferAttachment *readDepthBuffer = readFramebuffer->getDepthbuffer();
- gl::FramebufferAttachment *drawDepthBuffer = drawFramebuffer->getDepthbuffer();
-
- if (readDepthBuffer && drawDepthBuffer)
- {
- if (readDepthBuffer->getActualFormat() != drawDepthBuffer->getActualFormat())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (readDepthBuffer->getSamples() > 0 && !sameBounds)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (fromAngleExtension)
- {
- if (IsPartialBlit(context, readDepthBuffer, drawDepthBuffer,
- srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1))
- {
- ERR("Only whole-buffer depth and stencil blits are supported by this implementation.");
- context->recordError(Error(GL_INVALID_OPERATION)); // only whole-buffer copies are permitted
- return false;
- }
-
- if (readDepthBuffer->getSamples() != 0 || drawDepthBuffer->getSamples() != 0)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
- }
- }
-
- if (mask & GL_STENCIL_BUFFER_BIT)
- {
- gl::FramebufferAttachment *readStencilBuffer = readFramebuffer->getStencilbuffer();
- gl::FramebufferAttachment *drawStencilBuffer = drawFramebuffer->getStencilbuffer();
-
- if (readStencilBuffer && drawStencilBuffer)
- {
- if (readStencilBuffer->getActualFormat() != drawStencilBuffer->getActualFormat())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (readStencilBuffer->getSamples() > 0 && !sameBounds)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (fromAngleExtension)
- {
- if (IsPartialBlit(context, readStencilBuffer, drawStencilBuffer,
- srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1))
- {
- ERR("Only whole-buffer depth and stencil blits are supported by this implementation.");
- context->recordError(Error(GL_INVALID_OPERATION)); // only whole-buffer copies are permitted
- return false;
- }
-
- if (readStencilBuffer->getSamples() != 0 || drawStencilBuffer->getSamples() != 0)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
- }
- }
-
- return true;
-}
-
-bool ValidateGetVertexAttribParameters(Context *context, GLenum pname)
-{
- switch (pname)
- {
- case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
- case GL_VERTEX_ATTRIB_ARRAY_SIZE:
- case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
- case GL_VERTEX_ATTRIB_ARRAY_TYPE:
- case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
- case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
- case GL_CURRENT_VERTEX_ATTRIB:
- return true;
-
- case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
- // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses
- // the same constant.
- META_ASSERT(GL_VERTEX_ATTRIB_ARRAY_DIVISOR == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE);
- return true;
-
- case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- return true;
-
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-}
-
-bool ValidateTexParamParameters(gl::Context *context, GLenum pname, GLint param)
-{
- switch (pname)
- {
- case GL_TEXTURE_WRAP_R:
- case GL_TEXTURE_SWIZZLE_R:
- case GL_TEXTURE_SWIZZLE_G:
- case GL_TEXTURE_SWIZZLE_B:
- case GL_TEXTURE_SWIZZLE_A:
- case GL_TEXTURE_BASE_LEVEL:
- case GL_TEXTURE_MAX_LEVEL:
- case GL_TEXTURE_COMPARE_MODE:
- case GL_TEXTURE_COMPARE_FUNC:
- case GL_TEXTURE_MIN_LOD:
- case GL_TEXTURE_MAX_LOD:
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
-
- default: break;
- }
-
- switch (pname)
- {
- case GL_TEXTURE_WRAP_S:
- case GL_TEXTURE_WRAP_T:
- case GL_TEXTURE_WRAP_R:
- switch (param)
- {
- case GL_REPEAT:
- case GL_CLAMP_TO_EDGE:
- case GL_MIRRORED_REPEAT:
- return true;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- case GL_TEXTURE_MIN_FILTER:
- switch (param)
- {
- case GL_NEAREST:
- case GL_LINEAR:
- case GL_NEAREST_MIPMAP_NEAREST:
- case GL_LINEAR_MIPMAP_NEAREST:
- case GL_NEAREST_MIPMAP_LINEAR:
- case GL_LINEAR_MIPMAP_LINEAR:
- return true;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
-
- case GL_TEXTURE_MAG_FILTER:
- switch (param)
- {
- case GL_NEAREST:
- case GL_LINEAR:
- return true;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
-
- case GL_TEXTURE_USAGE_ANGLE:
- switch (param)
- {
- case GL_NONE:
- case GL_FRAMEBUFFER_ATTACHMENT_ANGLE:
- return true;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
-
- case GL_TEXTURE_MAX_ANISOTROPY_EXT:
- if (!context->getExtensions().textureFilterAnisotropic)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- // we assume the parameter passed to this validation method is truncated, not rounded
- if (param < 1)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- return true;
-
- case GL_TEXTURE_MIN_LOD:
- case GL_TEXTURE_MAX_LOD:
- // any value is permissible
- return true;
-
- case GL_TEXTURE_COMPARE_MODE:
- // Acceptable mode parameters from GLES 3.0.2 spec, table 3.17
- switch (param)
- {
- case GL_NONE:
- case GL_COMPARE_REF_TO_TEXTURE:
- return true;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
-
- case GL_TEXTURE_COMPARE_FUNC:
- // Acceptable function parameters from GLES 3.0.2 spec, table 3.17
- switch (param)
- {
- case GL_LEQUAL:
- case GL_GEQUAL:
- case GL_LESS:
- case GL_GREATER:
- case GL_EQUAL:
- case GL_NOTEQUAL:
- case GL_ALWAYS:
- case GL_NEVER:
- return true;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
-
- case GL_TEXTURE_SWIZZLE_R:
- case GL_TEXTURE_SWIZZLE_G:
- case GL_TEXTURE_SWIZZLE_B:
- case GL_TEXTURE_SWIZZLE_A:
- switch (param)
- {
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_ALPHA:
- case GL_ZERO:
- case GL_ONE:
- return true;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
-
- case GL_TEXTURE_BASE_LEVEL:
- case GL_TEXTURE_MAX_LEVEL:
- if (param < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- return true;
-
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-}
-
-bool ValidateSamplerObjectParameter(gl::Context *context, GLenum pname)
-{
- switch (pname)
- {
- case GL_TEXTURE_MIN_FILTER:
- case GL_TEXTURE_MAG_FILTER:
- case GL_TEXTURE_WRAP_S:
- case GL_TEXTURE_WRAP_T:
- case GL_TEXTURE_WRAP_R:
- case GL_TEXTURE_MIN_LOD:
- case GL_TEXTURE_MAX_LOD:
- case GL_TEXTURE_COMPARE_MODE:
- case GL_TEXTURE_COMPARE_FUNC:
- return true;
-
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-}
-
-bool ValidateReadPixelsParameters(gl::Context *context, GLint x, GLint y, GLsizei width, GLsizei height,
- GLenum format, GLenum type, GLsizei *bufSize, GLvoid *pixels)
-{
- gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
- ASSERT(framebuffer);
-
- if (framebuffer->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
- {
- context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
- return false;
- }
-
- if (context->getState().getReadFramebuffer()->id() != 0 &&
- framebuffer->getSamples(context->getData()) != 0)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (!framebuffer->getReadColorbuffer())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- GLenum currentInternalFormat, currentFormat, currentType;
- GLuint clientVersion = context->getClientVersion();
-
- context->getCurrentReadFormatType(&currentInternalFormat, &currentFormat, &currentType);
-
- bool validReadFormat = (clientVersion < 3) ? ValidES2ReadFormatType(context, format, type) :
- ValidES3ReadFormatType(context, currentInternalFormat, format, type);
-
- if (!(currentFormat == format && currentType == type) && !validReadFormat)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- GLenum sizedInternalFormat = GetSizedInternalFormat(format, type);
- const InternalFormat &sizedFormatInfo = GetInternalFormatInfo(sizedInternalFormat);
-
- GLsizei outputPitch = sizedFormatInfo.computeRowPitch(type, width, context->getState().getPackAlignment());
- // sized query sanity check
- if (bufSize)
- {
- int requiredSize = outputPitch * height;
- if (requiredSize > *bufSize)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
-
- return true;
-}
-
-bool ValidateBeginQuery(gl::Context *context, GLenum target, GLuint id)
-{
- if (!ValidQueryType(context, target))
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if (id == 0)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- // From EXT_occlusion_query_boolean: If BeginQueryEXT is called with an <id>
- // of zero, if the active query object name for <target> is non-zero (for the
- // targets ANY_SAMPLES_PASSED_EXT and ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, if
- // the active query for either target is non-zero), if <id> is the name of an
- // existing query object whose type does not match <target>, or if <id> is the
- // active query object name for any query type, the error INVALID_OPERATION is
- // generated.
-
- // Ensure no other queries are active
- // NOTE: If other queries than occlusion are supported, we will need to check
- // separately that:
- // a) The query ID passed is not the current active query for any target/type
- // b) There are no active queries for the requested target (and in the case
- // of GL_ANY_SAMPLES_PASSED_EXT and GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT,
- // no query may be active for either if glBeginQuery targets either.
- if (context->getState().isQueryActive())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- Query *queryObject = context->getQuery(id, true, target);
-
- // check that name was obtained with glGenQueries
- if (!queryObject)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- // check for type mismatch
- if (queryObject->getType() != target)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- return true;
-}
-
-bool ValidateEndQuery(gl::Context *context, GLenum target)
-{
- if (!ValidQueryType(context, target))
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- const Query *queryObject = context->getState().getActiveQuery(target);
-
- if (queryObject == NULL)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- return true;
-}
-
-static bool ValidateUniformCommonBase(gl::Context *context, GLenum targetUniformType,
- GLint location, GLsizei count, LinkedUniform **uniformOut)
-{
- if (count < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
- if (!programBinary)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (location == -1)
- {
- // Silently ignore the uniform command
- return false;
- }
-
- if (!programBinary->isValidUniformLocation(location))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- LinkedUniform *uniform = programBinary->getUniformByLocation(location);
-
- // attempting to write an array to a non-array uniform is an INVALID_OPERATION
- if (uniform->elementCount() == 1 && count > 1)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- *uniformOut = uniform;
- return true;
-}
-
-bool ValidateUniform(gl::Context *context, GLenum uniformType, GLint location, GLsizei count)
-{
- // Check for ES3 uniform entry points
- if (VariableComponentType(uniformType) == GL_UNSIGNED_INT && context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- LinkedUniform *uniform = NULL;
- if (!ValidateUniformCommonBase(context, uniformType, location, count, &uniform))
- {
- return false;
- }
-
- GLenum targetBoolType = VariableBoolVectorType(uniformType);
- bool samplerUniformCheck = (IsSampler(uniform->type) && uniformType == GL_INT);
- if (!samplerUniformCheck && uniformType != uniform->type && targetBoolType != uniform->type)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- return true;
-}
-
-bool ValidateUniformMatrix(gl::Context *context, GLenum matrixType, GLint location, GLsizei count,
- GLboolean transpose)
-{
- // Check for ES3 uniform entry points
- int rows = VariableRowCount(matrixType);
- int cols = VariableColumnCount(matrixType);
- if (rows != cols && context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (transpose != GL_FALSE && context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- LinkedUniform *uniform = NULL;
- if (!ValidateUniformCommonBase(context, matrixType, location, count, &uniform))
- {
- return false;
- }
-
- if (uniform->type != matrixType)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- return true;
-}
-
-bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType, unsigned int *numParams)
-{
- if (!context->getQueryParameterInfo(pname, nativeType, numParams))
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if (pname >= GL_DRAW_BUFFER0 && pname <= GL_DRAW_BUFFER15)
- {
- unsigned int colorAttachment = (pname - GL_DRAW_BUFFER0);
-
- if (colorAttachment >= context->getCaps().maxDrawBuffers)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
-
- switch (pname)
- {
- case GL_TEXTURE_BINDING_2D:
- case GL_TEXTURE_BINDING_CUBE_MAP:
- case GL_TEXTURE_BINDING_3D:
- case GL_TEXTURE_BINDING_2D_ARRAY:
- if (context->getState().getActiveSampler() >= context->getCaps().maxCombinedTextureImageUnits)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
-
- case GL_IMPLEMENTATION_COLOR_READ_TYPE:
- case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
- {
- Framebuffer *framebuffer = context->getState().getReadFramebuffer();
- ASSERT(framebuffer);
- if (framebuffer->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- FramebufferAttachment *attachment = framebuffer->getReadColorbuffer();
- if (!attachment)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
- break;
-
- default:
- break;
- }
-
- // pname is valid, but there are no parameters to return
- if (numParams == 0)
- {
- return false;
- }
-
- return true;
-}
-
-bool ValidateCopyTexImageParametersBase(gl::Context* context, GLenum target, GLint level, GLenum internalformat, bool isSubImage,
- GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height,
- GLint border, GLenum *textureFormatOut)
-{
-
- if (!ValidTexture2DDestinationTarget(context, target))
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if (level < 0 || xoffset < 0 || yoffset < 0 || zoffset < 0 || width < 0 || height < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (border != 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (!ValidMipLevel(context, target, level))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
- if (framebuffer->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
- {
- context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
- return false;
- }
-
- if (context->getState().getReadFramebuffer()->id() != 0 && framebuffer->getSamples(context->getData()) != 0)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- const gl::Caps &caps = context->getCaps();
-
- gl::Texture *texture = NULL;
- GLenum textureInternalFormat = GL_NONE;
- GLint textureLevelWidth = 0;
- GLint textureLevelHeight = 0;
- GLint textureLevelDepth = 0;
- GLuint maxDimension = 0;
-
- switch (target)
- {
- case GL_TEXTURE_2D:
- {
- gl::Texture2D *texture2d = context->getTexture2D();
- if (texture2d)
- {
- textureInternalFormat = texture2d->getInternalFormat(level);
- textureLevelWidth = texture2d->getWidth(level);
- textureLevelHeight = texture2d->getHeight(level);
- textureLevelDepth = 1;
- texture = texture2d;
- maxDimension = caps.max2DTextureSize;
- }
- }
- break;
-
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- {
- gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
- if (textureCube)
- {
- textureInternalFormat = textureCube->getInternalFormat(target, level);
- textureLevelWidth = textureCube->getWidth(target, level);
- textureLevelHeight = textureCube->getHeight(target, level);
- textureLevelDepth = 1;
- texture = textureCube;
- maxDimension = caps.maxCubeMapTextureSize;
- }
- }
- break;
-
- case GL_TEXTURE_2D_ARRAY:
- {
- gl::Texture2DArray *texture2dArray = context->getTexture2DArray();
- if (texture2dArray)
- {
- textureInternalFormat = texture2dArray->getInternalFormat(level);
- textureLevelWidth = texture2dArray->getWidth(level);
- textureLevelHeight = texture2dArray->getHeight(level);
- textureLevelDepth = texture2dArray->getLayers(level);
- texture = texture2dArray;
- maxDimension = caps.max2DTextureSize;
- }
- }
- break;
-
- case GL_TEXTURE_3D:
- {
- gl::Texture3D *texture3d = context->getTexture3D();
- if (texture3d)
- {
- textureInternalFormat = texture3d->getInternalFormat(level);
- textureLevelWidth = texture3d->getWidth(level);
- textureLevelHeight = texture3d->getHeight(level);
- textureLevelDepth = texture3d->getDepth(level);
- texture = texture3d;
- maxDimension = caps.max3DTextureSize;
- }
- }
- break;
-
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if (!texture)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (texture->isImmutable() && !isSubImage)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
-
- if (formatInfo.depthBits > 0)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (formatInfo.compressed)
- {
- if (((width % formatInfo.compressedBlockWidth) != 0 && width != textureLevelWidth) ||
- ((height % formatInfo.compressedBlockHeight) != 0 && height != textureLevelHeight))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
-
- if (isSubImage)
- {
- if (xoffset + width > textureLevelWidth ||
- yoffset + height > textureLevelHeight ||
- zoffset >= textureLevelDepth)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- }
- else
- {
- if (IsCubemapTextureTarget(target) && width != height)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions()))
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- int maxLevelDimension = (maxDimension >> level);
- if (static_cast<int>(width) > maxLevelDimension || static_cast<int>(height) > maxLevelDimension)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- }
-
- *textureFormatOut = textureInternalFormat;
- return true;
-}
-
-static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsizei maxVertex, GLsizei primcount)
-{
- switch (mode)
- {
- case GL_POINTS:
- case GL_LINES:
- case GL_LINE_LOOP:
- case GL_LINE_STRIP:
- case GL_TRIANGLES:
- case GL_TRIANGLE_STRIP:
- case GL_TRIANGLE_FAN:
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if (count < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- const State &state = context->getState();
-
- // Check for mapped buffers
- if (state.hasMappedBuffer(GL_ARRAY_BUFFER))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- const gl::DepthStencilState &depthStencilState = state.getDepthStencilState();
- if (depthStencilState.stencilWritemask != depthStencilState.stencilBackWritemask ||
- state.getStencilRef() != state.getStencilBackRef() ||
- depthStencilState.stencilMask != depthStencilState.stencilBackMask)
- {
- // Note: these separate values are not supported in WebGL, due to D3D's limitations.
- // See Section 6.10 of the WebGL 1.0 spec
- ERR("This ANGLE implementation does not support separate front/back stencil "
- "writemasks, reference values, or stencil mask values.");
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- const gl::Framebuffer *fbo = state.getDrawFramebuffer();
- if (!fbo || fbo->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
- {
- context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
- return false;
- }
-
- if (state.getCurrentProgramId() == 0)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- gl::ProgramBinary *programBinary = state.getCurrentProgramBinary();
- if (!programBinary->validateSamplers(NULL, context->getCaps()))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- // Buffer validations
- const VertexArray *vao = state.getVertexArray();
- for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
- {
- const VertexAttribute &attrib = vao->getVertexAttribute(attributeIndex);
- bool attribActive = (programBinary->getSemanticIndex(attributeIndex) != -1);
- if (attribActive && attrib.enabled)
- {
- gl::Buffer *buffer = attrib.buffer.get();
-
- if (buffer)
- {
- GLint64 attribStride = static_cast<GLint64>(ComputeVertexAttributeStride(attrib));
- GLint64 maxVertexElement = 0;
-
- if (attrib.divisor > 0)
- {
- maxVertexElement = static_cast<GLint64>(primcount) / static_cast<GLint64>(attrib.divisor);
- }
- else
- {
- maxVertexElement = static_cast<GLint64>(maxVertex);
- }
-
- GLint64 attribDataSize = maxVertexElement * attribStride;
-
- // [OpenGL ES 3.0.2] section 2.9.4 page 40:
- // We can return INVALID_OPERATION if our vertex attribute does not have
- // enough backing data.
- if (attribDataSize > buffer->getSize())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
- else if (attrib.pointer == NULL)
- {
- // This is an application error that would normally result in a crash,
- // but we catch it and return an error
- context->recordError(Error(GL_INVALID_OPERATION, "An enabled vertex array has no buffer and no pointer."));
- return false;
- }
- }
- }
-
- // No-op if zero count
- return (count > 0);
-}
-
-bool ValidateDrawArrays(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount)
-{
- if (first < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- const State &state = context->getState();
- gl::TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback();
- if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused() &&
- curTransformFeedback->getDrawMode() != mode)
- {
- // It is an invalid operation to call DrawArrays or DrawArraysInstanced with a draw mode
- // that does not match the current transform feedback object's draw mode (if transform feedback
- // is active), (3.0.2, section 2.14, pg 86)
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (!ValidateDrawBase(context, mode, count, count, primcount))
- {
- return false;
- }
-
- return true;
-}
-
-bool ValidateDrawArraysInstanced(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount)
-{
- if (primcount < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (!ValidateDrawArrays(context, mode, first, count, primcount))
- {
- return false;
- }
-
- // No-op if zero primitive count
- return (primcount > 0);
-}
-
-static bool ValidateDrawInstancedANGLE(Context *context)
-{
- // Verify there is at least one active attribute with a divisor of zero
- const gl::State& state = context->getState();
-
- gl::ProgramBinary *programBinary = state.getCurrentProgramBinary();
-
- const VertexArray *vao = state.getVertexArray();
- for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
- {
- const VertexAttribute &attrib = vao->getVertexAttribute(attributeIndex);
- bool active = (programBinary->getSemanticIndex(attributeIndex) != -1);
- if (active && attrib.divisor == 0)
- {
- return true;
- }
- }
-
- context->recordError(Error(GL_INVALID_OPERATION, "ANGLE_instanced_arrays requires that at least one active attribute"
- "has a divisor of zero."));
- return false;
-}
-
-bool ValidateDrawArraysInstancedANGLE(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount)
-{
- if (!ValidateDrawInstancedANGLE(context))
- {
- return false;
- }
-
- return ValidateDrawArraysInstanced(context, mode, first, count, primcount);
-}
-
-bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum type,
- const GLvoid* indices, GLsizei primcount, rx::RangeUI *indexRangeOut)
-{
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- case GL_UNSIGNED_SHORT:
- break;
- case GL_UNSIGNED_INT:
- if (!context->getExtensions().elementIndexUint)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- const State &state = context->getState();
-
- gl::TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback();
- if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
- {
- // It is an invalid operation to call DrawElements, DrawRangeElements or DrawElementsInstanced
- // while transform feedback is active, (3.0.2, section 2.14, pg 86)
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- // Check for mapped buffers
- if (state.hasMappedBuffer(GL_ELEMENT_ARRAY_BUFFER))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- const gl::VertexArray *vao = state.getVertexArray();
- const gl::Buffer *elementArrayBuffer = vao->getElementArrayBuffer();
- if (!indices && !elementArrayBuffer)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (elementArrayBuffer)
- {
- const gl::Type &typeInfo = gl::GetTypeInfo(type);
-
- GLint64 offset = reinterpret_cast<GLint64>(indices);
- GLint64 byteCount = static_cast<GLint64>(typeInfo.bytes) * static_cast<GLint64>(count)+offset;
-
- // check for integer overflows
- if (static_cast<GLuint>(count) > (std::numeric_limits<GLuint>::max() / typeInfo.bytes) ||
- byteCount > static_cast<GLint64>(std::numeric_limits<GLuint>::max()))
- {
- context->recordError(Error(GL_OUT_OF_MEMORY));
- return false;
- }
-
- // Check for reading past the end of the bound buffer object
- if (byteCount > elementArrayBuffer->getSize())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
- else if (!indices)
- {
- // Catch this programming error here
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- // Use max index to validate if our vertex buffers are large enough for the pull.
- // TODO: offer fast path, with disabled index validation.
- // TODO: also disable index checking on back-ends that are robust to out-of-range accesses.
- if (elementArrayBuffer)
- {
- uintptr_t offset = reinterpret_cast<uintptr_t>(indices);
- if (!elementArrayBuffer->getIndexRangeCache()->findRange(type, offset, count, indexRangeOut, NULL))
- {
- // FIXME(jmadill): Use buffer data caching instead of the D3D back-end
- rx::BufferD3D *bufferD3D = rx::BufferD3D::makeBufferD3D(elementArrayBuffer->getImplementation());
- const uint8_t *dataPointer = NULL;
- Error error = bufferD3D->getData(&dataPointer);
- if (error.isError())
- {
- context->recordError(error);
- return false;
- }
-
- const uint8_t *offsetPointer = dataPointer + offset;
- *indexRangeOut = rx::IndexRangeCache::ComputeRange(type, offsetPointer, count);
- }
- }
- else
- {
- *indexRangeOut = rx::IndexRangeCache::ComputeRange(type, indices, count);
- }
-
- if (!ValidateDrawBase(context, mode, count, static_cast<GLsizei>(indexRangeOut->end), primcount))
- {
- return false;
- }
-
- return true;
-}
-
-bool ValidateDrawElementsInstanced(Context *context,
- GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices, GLsizei primcount,
- rx::RangeUI *indexRangeOut)
-{
- if (primcount < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (!ValidateDrawElements(context, mode, count, type, indices, primcount, indexRangeOut))
- {
- return false;
- }
-
- // No-op zero primitive count
- return (primcount > 0);
-}
-
-bool ValidateDrawElementsInstancedANGLE(Context *context, GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices, GLsizei primcount, rx::RangeUI *indexRangeOut)
-{
- if (!ValidateDrawInstancedANGLE(context))
- {
- return false;
- }
-
- return ValidateDrawElementsInstanced(context, mode, count, type, indices, primcount, indexRangeOut);
-}
-
-bool ValidateFramebufferTextureBase(Context *context, GLenum target, GLenum attachment,
- GLuint texture, GLint level)
-{
- if (!ValidFramebufferTarget(target))
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if (!ValidateAttachmentTarget(context, attachment))
- {
- return false;
- }
-
- if (texture != 0)
- {
- gl::Texture *tex = context->getTexture(texture);
-
- if (tex == NULL)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (level < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- }
-
- const gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
- GLuint framebufferHandle = context->getState().getTargetFramebuffer(target)->id();
-
- if (framebufferHandle == 0 || !framebuffer)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- return true;
-}
-
-bool ValidateFramebufferTexture2D(Context *context, GLenum target, GLenum attachment,
- GLenum textarget, GLuint texture, GLint level)
-{
- // Attachments are required to be bound to level 0 in ES2
- if (context->getClientVersion() < 3 && level != 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (!ValidateFramebufferTextureBase(context, target, attachment, texture, level))
- {
- return false;
- }
-
- if (texture != 0)
- {
- gl::Texture *tex = context->getTexture(texture);
- ASSERT(tex);
-
- const gl::Caps &caps = context->getCaps();
-
- switch (textarget)
- {
- case GL_TEXTURE_2D:
- {
- if (level > gl::log2(caps.max2DTextureSize))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- if (tex->getTarget() != GL_TEXTURE_2D)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- gl::Texture2D *tex2d = static_cast<gl::Texture2D *>(tex);
- if (tex2d->isCompressed(level))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
- break;
-
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- {
- if (level > gl::log2(caps.maxCubeMapTextureSize))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- if (tex->getTarget() != GL_TEXTURE_CUBE_MAP)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- gl::TextureCubeMap *texcube = static_cast<gl::TextureCubeMap *>(tex);
- if (texcube->isCompressed(textarget, level))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
- break;
-
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- }
-
- return true;
-}
-
-bool ValidateGetUniformBase(Context *context, GLuint program, GLint location)
-{
- if (program == 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (!ValidProgram(context, program))
- {
- return false;
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject || !programObject->isLinked())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
- if (!programBinary)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (!programBinary->isValidUniformLocation(location))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- return true;
-}
-
-bool ValidateGetUniformfv(Context *context, GLuint program, GLint location, GLfloat* params)
-{
- return ValidateGetUniformBase(context, program, location);
-}
-
-bool ValidateGetUniformiv(Context *context, GLuint program, GLint location, GLint* params)
-{
- return ValidateGetUniformBase(context, program, location);
-}
-
-static bool ValidateSizedGetUniform(Context *context, GLuint program, GLint location, GLsizei bufSize)
-{
- if (!ValidateGetUniformBase(context, program, location))
- {
- return false;
- }
-
- gl::Program *programObject = context->getProgram(program);
- ASSERT(programObject);
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
-
- // sized queries -- ensure the provided buffer is large enough
- LinkedUniform *uniform = programBinary->getUniformByLocation(location);
- size_t requiredBytes = VariableExternalSize(uniform->type);
- if (static_cast<size_t>(bufSize) < requiredBytes)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- return true;
-}
-
-bool ValidateGetnUniformfvEXT(Context *context, GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
-{
- return ValidateSizedGetUniform(context, program, location, bufSize);
-}
-
-bool ValidateGetnUniformivEXT(Context *context, GLuint program, GLint location, GLsizei bufSize, GLint* params)
-{
- return ValidateSizedGetUniform(context, program, location, bufSize);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/validationES.h b/src/3rdparty/angle/src/libGLESv2/validationES.h
deleted file mode 100644
index 1fdb633cb6..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/validationES.h
+++ /dev/null
@@ -1,92 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// validationES.h: Validation functions for generic OpenGL ES entry point parameters
-
-#ifndef LIBGLESV2_VALIDATION_ES_H
-#define LIBGLESV2_VALIDATION_ES_H
-
-#include "common/mathutil.h"
-
-#include <GLES2/gl2.h>
-#include <GLES3/gl3.h>
-
-namespace gl
-{
-
-class Context;
-
-bool ValidCap(const Context *context, GLenum cap);
-bool ValidTextureTarget(const Context *context, GLenum target);
-bool ValidTexture2DDestinationTarget(const Context *context, GLenum target);
-bool ValidFramebufferTarget(GLenum target);
-bool ValidBufferTarget(const Context *context, GLenum target);
-bool ValidBufferParameter(const Context *context, GLenum pname);
-bool ValidMipLevel(const Context *context, GLenum target, GLint level);
-bool ValidImageSize(const Context *context, GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth);
-bool ValidCompressedImageSize(const Context *context, GLenum internalFormat, GLsizei width, GLsizei height);
-bool ValidQueryType(const Context *context, GLenum queryType);
-bool ValidProgram(Context *context, GLuint id);
-
-bool ValidateAttachmentTarget(Context *context, GLenum attachment);
-bool ValidateRenderbufferStorageParameters(Context *context, GLenum target, GLsizei samples,
- GLenum internalformat, GLsizei width, GLsizei height,
- bool angleExtension);
-bool ValidateFramebufferRenderbufferParameters(Context *context, GLenum target, GLenum attachment,
- GLenum renderbuffertarget, GLuint renderbuffer);
-
-bool ValidateBlitFramebufferParameters(Context *context, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
- GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask,
- GLenum filter, bool fromAngleExtension);
-
-bool ValidateGetVertexAttribParameters(Context *context, GLenum pname);
-
-bool ValidateTexParamParameters(Context *context, GLenum pname, GLint param);
-
-bool ValidateSamplerObjectParameter(Context *context, GLenum pname);
-
-bool ValidateReadPixelsParameters(Context *context, GLint x, GLint y, GLsizei width, GLsizei height,
- GLenum format, GLenum type, GLsizei *bufSize, GLvoid *pixels);
-
-bool ValidateBeginQuery(Context *context, GLenum target, GLuint id);
-bool ValidateEndQuery(Context *context, GLenum target);
-
-bool ValidateUniform(Context *context, GLenum uniformType, GLint location, GLsizei count);
-bool ValidateUniformMatrix(Context *context, GLenum matrixType, GLint location, GLsizei count,
- GLboolean transpose);
-
-bool ValidateStateQuery(Context *context, GLenum pname, GLenum *nativeType, unsigned int *numParams);
-
-bool ValidateCopyTexImageParametersBase(Context* context, GLenum target, GLint level, GLenum internalformat, bool isSubImage,
- GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height,
- GLint border, GLenum *textureInternalFormatOut);
-
-bool ValidateDrawArrays(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount);
-bool ValidateDrawArraysInstanced(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount);
-bool ValidateDrawArraysInstancedANGLE(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount);
-
-bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum type,
- const GLvoid* indices, GLsizei primcount, rx::RangeUI *indexRangeOut);
-
-bool ValidateDrawElementsInstanced(Context *context, GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices, GLsizei primcount, rx::RangeUI *indexRangeOut);
-bool ValidateDrawElementsInstancedANGLE(Context *context, GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices, GLsizei primcount, rx::RangeUI *indexRangeOut);
-
-bool ValidateFramebufferTextureBase(Context *context, GLenum target, GLenum attachment,
- GLuint texture, GLint level);
-bool ValidateFramebufferTexture2D(Context *context, GLenum target, GLenum attachment,
- GLenum textarget, GLuint texture, GLint level);
-
-bool ValidateGetUniformBase(Context *context, GLuint program, GLint location);
-bool ValidateGetUniformfv(Context *context, GLuint program, GLint location, GLfloat* params);
-bool ValidateGetUniformiv(Context *context, GLuint program, GLint location, GLint* params);
-bool ValidateGetnUniformfvEXT(Context *context, GLuint program, GLint location, GLsizei bufSize, GLfloat* params);
-bool ValidateGetnUniformivEXT(Context *context, GLuint program, GLint location, GLsizei bufSize, GLint* params);
-
-}
-
-#endif // LIBGLESV2_VALIDATION_ES_H
diff --git a/src/3rdparty/angle/src/libGLESv2/validationES2.cpp b/src/3rdparty/angle/src/libGLESv2/validationES2.cpp
deleted file mode 100644
index f950454df0..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/validationES2.cpp
+++ /dev/null
@@ -1,980 +0,0 @@
-//
-// Copyright (c) 2013-2014 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.
-//
-
-// validationES2.cpp: Validation functions for OpenGL ES 2.0 entry point parameters
-
-#include "libGLESv2/validationES2.h"
-#include "libGLESv2/validationES.h"
-#include "libGLESv2/Context.h"
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/Renderbuffer.h"
-#include "libGLESv2/formatutils.h"
-#include "libGLESv2/main.h"
-#include "libGLESv2/FramebufferAttachment.h"
-
-#include "common/mathutil.h"
-#include "common/utilities.h"
-
-namespace gl
-{
-
-static bool ValidateSubImageParams2D(Context *context, bool compressed, GLsizei width, GLsizei height,
- GLint xoffset, GLint yoffset, GLint level, GLenum format, GLenum type,
- gl::Texture2D *texture)
-{
- if (!texture)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (compressed != texture->isCompressed(level))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (format != GL_NONE)
- {
- if (gl::GetFormatTypeInfo(format, type).internalFormat != texture->getInternalFormat(level))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
-
- if (compressed)
- {
- if ((width % 4 != 0 && width != texture->getWidth(level)) ||
- (height % 4 != 0 && height != texture->getHeight(level)))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
-
- if (xoffset + width > texture->getWidth(level) ||
- yoffset + height > texture->getHeight(level))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- return true;
-}
-
-static bool ValidateSubImageParamsCube(Context *context, bool compressed, GLsizei width, GLsizei height,
- GLint xoffset, GLint yoffset, GLenum target, GLint level, GLenum format, GLenum type,
- gl::TextureCubeMap *texture)
-{
- if (!texture)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (compressed != texture->isCompressed(target, level))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (format != GL_NONE)
- {
- if (gl::GetFormatTypeInfo(format, type).internalFormat != texture->getInternalFormat(target, level))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
-
- if (compressed)
- {
- if ((width % 4 != 0 && width != texture->getWidth(target, 0)) ||
- (height % 4 != 0 && height != texture->getHeight(target, 0)))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
-
- if (xoffset + width > texture->getWidth(target, level) ||
- yoffset + height > texture->getHeight(target, level))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- return true;
-}
-
-bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, GLenum internalformat, bool isCompressed, bool isSubImage,
- GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
- GLint border, GLenum format, GLenum type, const GLvoid *pixels)
-{
- if (!ValidTexture2DDestinationTarget(context, target))
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if (!ValidImageSize(context, target, level, width, height, 1))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (level < 0 || xoffset < 0 ||
- std::numeric_limits<GLsizei>::max() - xoffset < width ||
- std::numeric_limits<GLsizei>::max() - yoffset < height)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (!isSubImage && !isCompressed && internalformat != format)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- const gl::Caps &caps = context->getCaps();
-
- gl::Texture *texture = NULL;
- bool textureCompressed = false;
- GLenum textureInternalFormat = GL_NONE;
- GLint textureLevelWidth = 0;
- GLint textureLevelHeight = 0;
- switch (target)
- {
- case GL_TEXTURE_2D:
- {
- if (static_cast<GLuint>(width) > (caps.max2DTextureSize >> level) ||
- static_cast<GLuint>(height) > (caps.max2DTextureSize >> level))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- gl::Texture2D *tex2d = context->getTexture2D();
- if (tex2d)
- {
- textureCompressed = tex2d->isCompressed(level);
- textureInternalFormat = tex2d->getInternalFormat(level);
- textureLevelWidth = tex2d->getWidth(level);
- textureLevelHeight = tex2d->getHeight(level);
- texture = tex2d;
- }
-
- if (isSubImage && !ValidateSubImageParams2D(context, isCompressed, width, height, xoffset, yoffset,
- level, format, type, tex2d))
- {
- return false;
- }
-
- texture = tex2d;
- }
- break;
-
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- {
- if (!isSubImage && width != height)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (static_cast<GLuint>(width) > (caps.maxCubeMapTextureSize >> level) ||
- static_cast<GLuint>(height) > (caps.maxCubeMapTextureSize >> level))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- gl::TextureCubeMap *texCube = context->getTextureCubeMap();
- if (texCube)
- {
- textureCompressed = texCube->isCompressed(target, level);
- textureInternalFormat = texCube->getInternalFormat(target, level);
- textureLevelWidth = texCube->getWidth(target, level);
- textureLevelHeight = texCube->getHeight(target, level);
- texture = texCube;
- }
-
- if (isSubImage && !ValidateSubImageParamsCube(context, isCompressed, width, height, xoffset, yoffset,
- target, level, format, type, texCube))
- {
- return false;
- }
- }
- break;
-
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if (!texture)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (!isSubImage && texture->isImmutable())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- // Verify zero border
- if (border != 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat;
- if (isCompressed)
- {
- if (!ValidCompressedImageSize(context, actualInternalFormat, width, height))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- switch (actualInternalFormat)
- {
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- if (!context->getExtensions().textureCompressionDXT1)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
- if (!context->getExtensions().textureCompressionDXT1)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
- if (!context->getExtensions().textureCompressionDXT5)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- }
- else
- {
- // validate <type> by itself (used as secondary key below)
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT:
- case GL_UNSIGNED_INT:
- case GL_UNSIGNED_INT_24_8_OES:
- case GL_HALF_FLOAT_OES:
- case GL_FLOAT:
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- // validate <format> + <type> combinations
- // - invalid <format> -> sets INVALID_ENUM
- // - invalid <format>+<type> combination -> sets INVALID_OPERATION
- switch (format)
- {
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_LUMINANCE_ALPHA:
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- case GL_FLOAT:
- case GL_HALF_FLOAT_OES:
- break;
- default:
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_RED:
- case GL_RG:
- if (!context->getExtensions().textureRG)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- case GL_FLOAT:
- case GL_HALF_FLOAT_OES:
- break;
- default:
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_RGB:
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_FLOAT:
- case GL_HALF_FLOAT_OES:
- break;
- default:
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_RGBA:
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_FLOAT:
- case GL_HALF_FLOAT_OES:
- break;
- default:
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_BGRA_EXT:
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- break;
- default:
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_SRGB_EXT:
- case GL_SRGB_ALPHA_EXT:
- if (!context->getExtensions().sRGB)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- break;
- default:
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
- break;
- case GL_DEPTH_COMPONENT:
- switch (type)
- {
- case GL_UNSIGNED_SHORT:
- case GL_UNSIGNED_INT:
- break;
- default:
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_DEPTH_STENCIL_OES:
- switch (type)
- {
- case GL_UNSIGNED_INT_24_8_OES:
- break;
- default:
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- switch (format)
- {
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- if (context->getExtensions().textureCompressionDXT1)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- else
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
- if (context->getExtensions().textureCompressionDXT3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- else
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
- if (context->getExtensions().textureCompressionDXT5)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- else
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_STENCIL_OES:
- if (!context->getExtensions().depthTextures)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- if (target != GL_TEXTURE_2D)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- // OES_depth_texture supports loading depth data and multiple levels,
- // but ANGLE_depth_texture does not
- if (pixels != NULL || level != 0)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- default:
- break;
- }
-
- if (type == GL_FLOAT)
- {
- if (!context->getExtensions().textureFloat)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- }
- else if (type == GL_HALF_FLOAT_OES)
- {
- if (!context->getExtensions().textureHalfFloat)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- }
- }
-
- return true;
-}
-
-
-
-bool ValidateES2CopyTexImageParameters(Context* context, GLenum target, GLint level, GLenum internalformat, bool isSubImage,
- GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height,
- GLint border)
-{
- GLenum textureInternalFormat = GL_NONE;
-
- if (!ValidateCopyTexImageParametersBase(context, target, level, internalformat, isSubImage,
- xoffset, yoffset, 0, x, y, width, height, border, &textureInternalFormat))
- {
- return false;
- }
-
- gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
- GLenum colorbufferFormat = framebuffer->getReadColorbuffer()->getInternalFormat();
- GLenum textureFormat = gl::GetInternalFormatInfo(textureInternalFormat).format;
-
- // [OpenGL ES 2.0.24] table 3.9
- if (isSubImage)
- {
- switch (textureFormat)
- {
- case GL_ALPHA:
- if (colorbufferFormat != GL_ALPHA8_EXT &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
- colorbufferFormat != GL_RGBA8_OES)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_LUMINANCE:
- if (colorbufferFormat != GL_R8_EXT &&
- colorbufferFormat != GL_RG8_EXT &&
- colorbufferFormat != GL_RGB565 &&
- colorbufferFormat != GL_RGB8_OES &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
- colorbufferFormat != GL_RGBA8_OES)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_RED_EXT:
- if (colorbufferFormat != GL_R8_EXT &&
- colorbufferFormat != GL_RG8_EXT &&
- colorbufferFormat != GL_RGB565 &&
- colorbufferFormat != GL_RGB8_OES &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
- colorbufferFormat != GL_RGBA8_OES)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_RG_EXT:
- if (colorbufferFormat != GL_RG8_EXT &&
- colorbufferFormat != GL_RGB565 &&
- colorbufferFormat != GL_RGB8_OES &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
- colorbufferFormat != GL_RGBA8_OES)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_RGB:
- if (colorbufferFormat != GL_RGB565 &&
- colorbufferFormat != GL_RGB8_OES &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
- colorbufferFormat != GL_RGBA8_OES)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_LUMINANCE_ALPHA:
- case GL_RGBA:
- if (colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
- colorbufferFormat != GL_RGBA8_OES)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_STENCIL_OES:
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- default:
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
- else
- {
- switch (internalformat)
- {
- case GL_ALPHA:
- if (colorbufferFormat != GL_ALPHA8_EXT &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
- colorbufferFormat != GL_BGRA8_EXT &&
- colorbufferFormat != GL_RGBA8_OES)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_LUMINANCE:
- if (colorbufferFormat != GL_R8_EXT &&
- colorbufferFormat != GL_RG8_EXT &&
- colorbufferFormat != GL_RGB565 &&
- colorbufferFormat != GL_RGB8_OES &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
- colorbufferFormat != GL_BGRA8_EXT &&
- colorbufferFormat != GL_RGBA8_OES)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_RED_EXT:
- if (colorbufferFormat != GL_R8_EXT &&
- colorbufferFormat != GL_RG8_EXT &&
- colorbufferFormat != GL_RGB565 &&
- colorbufferFormat != GL_RGB8_OES &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
- colorbufferFormat != GL_BGRA8_EXT &&
- colorbufferFormat != GL_RGBA8_OES)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_RG_EXT:
- if (colorbufferFormat != GL_RG8_EXT &&
- colorbufferFormat != GL_RGB565 &&
- colorbufferFormat != GL_RGB8_OES &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
- colorbufferFormat != GL_BGRA8_EXT &&
- colorbufferFormat != GL_RGBA8_OES)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_RGB:
- if (colorbufferFormat != GL_RGB565 &&
- colorbufferFormat != GL_RGB8_OES &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
- colorbufferFormat != GL_BGRA8_EXT &&
- colorbufferFormat != GL_RGBA8_OES)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_LUMINANCE_ALPHA:
- case GL_RGBA:
- if (colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
- colorbufferFormat != GL_BGRA8_EXT &&
- colorbufferFormat != GL_RGBA8_OES)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- if (context->getExtensions().textureCompressionDXT1)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- else
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
- if (context->getExtensions().textureCompressionDXT3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- else
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
- if (context->getExtensions().textureCompressionDXT5)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- else
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_COMPONENT16:
- case GL_DEPTH_COMPONENT32_OES:
- case GL_DEPTH_STENCIL_OES:
- case GL_DEPTH24_STENCIL8_OES:
- if (context->getExtensions().depthTextures)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- else
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- }
-
- // If width or height is zero, it is a no-op. Return false without setting an error.
- return (width > 0 && height > 0);
-}
-
-bool ValidateES2TexStorageParameters(Context *context, GLenum target, GLsizei levels, GLenum internalformat,
- GLsizei width, GLsizei height)
-{
- if (target != GL_TEXTURE_2D && target != GL_TEXTURE_CUBE_MAP)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if (width < 1 || height < 1 || levels < 1)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (target == GL_TEXTURE_CUBE_MAP && width != height)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (levels != 1 && levels != gl::log2(std::max(width, height)) + 1)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
- if (formatInfo.format == GL_NONE || formatInfo.type == GL_NONE)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- const gl::Caps &caps = context->getCaps();
-
- switch (target)
- {
- case GL_TEXTURE_2D:
- if (static_cast<GLuint>(width) > caps.max2DTextureSize ||
- static_cast<GLuint>(height) > caps.max2DTextureSize)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- break;
- case GL_TEXTURE_CUBE_MAP:
- if (static_cast<GLuint>(width) > caps.maxCubeMapTextureSize ||
- static_cast<GLuint>(height) > caps.maxCubeMapTextureSize)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if (levels != 1 && !context->getExtensions().textureNPOT)
- {
- if (!gl::isPow2(width) || !gl::isPow2(height))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
-
- switch (internalformat)
- {
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- if (!context->getExtensions().textureCompressionDXT1)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
- if (!context->getExtensions().textureCompressionDXT3)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
- if (!context->getExtensions().textureCompressionDXT5)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- case GL_RGBA32F_EXT:
- case GL_RGB32F_EXT:
- case GL_ALPHA32F_EXT:
- case GL_LUMINANCE32F_EXT:
- case GL_LUMINANCE_ALPHA32F_EXT:
- if (!context->getExtensions().textureFloat)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- case GL_RGBA16F_EXT:
- case GL_RGB16F_EXT:
- case GL_ALPHA16F_EXT:
- case GL_LUMINANCE16F_EXT:
- case GL_LUMINANCE_ALPHA16F_EXT:
- if (!context->getExtensions().textureHalfFloat)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- case GL_R8_EXT:
- case GL_RG8_EXT:
- case GL_R16F_EXT:
- case GL_RG16F_EXT:
- case GL_R32F_EXT:
- case GL_RG32F_EXT:
- if (!context->getExtensions().textureRG)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- case GL_DEPTH_COMPONENT16:
- case GL_DEPTH_COMPONENT32_OES:
- case GL_DEPTH24_STENCIL8_OES:
- if (!context->getExtensions().depthTextures)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- if (target != GL_TEXTURE_2D)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- // ANGLE_depth_texture only supports 1-level textures
- if (levels != 1)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- default:
- break;
- }
-
- gl::Texture *texture = NULL;
- switch(target)
- {
- case GL_TEXTURE_2D:
- texture = context->getTexture2D();
- break;
- case GL_TEXTURE_CUBE_MAP:
- texture = context->getTextureCubeMap();
- break;
- default:
- UNREACHABLE();
- }
-
- if (!texture || texture->id() == 0)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (texture->isImmutable())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- return true;
-}
-
-// check for combinations of format and type that are valid for ReadPixels
-bool ValidES2ReadFormatType(Context *context, GLenum format, GLenum type)
-{
- switch (format)
- {
- case GL_RGBA:
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- break;
- default:
- return false;
- }
- break;
- case GL_BGRA_EXT:
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
- break;
- default:
- return false;
- }
- break;
- case GL_RG_EXT:
- case GL_RED_EXT:
- if (!context->getExtensions().textureRG)
- {
- return false;
- }
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- break;
- default:
- return false;
- }
- break;
-
- default:
- return false;
- }
- return true;
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/validationES2.h b/src/3rdparty/angle/src/libGLESv2/validationES2.h
deleted file mode 100644
index 53a0b630ea..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/validationES2.h
+++ /dev/null
@@ -1,34 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// validationES2.h: Validation functions for OpenGL ES 2.0 entry point parameters
-
-#ifndef LIBGLESV2_VALIDATION_ES2_H
-#define LIBGLESV2_VALIDATION_ES2_H
-
-#include <GLES2/gl2.h>
-
-namespace gl
-{
-
-class Context;
-
-bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, GLenum internalformat, bool isCompressed, bool isSubImage,
- GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
- GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-
-bool ValidateES2CopyTexImageParameters(Context* context, GLenum target, GLint level, GLenum internalformat, bool isSubImage,
- GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height,
- GLint border);
-
-bool ValidateES2TexStorageParameters(Context *context, GLenum target, GLsizei levels, GLenum internalformat,
- GLsizei width, GLsizei height);
-
-bool ValidES2ReadFormatType(Context *context, GLenum format, GLenum type);
-
-}
-
-#endif // LIBGLESV2_VALIDATION_ES2_H
diff --git a/src/3rdparty/angle/src/libGLESv2/validationES3.cpp b/src/3rdparty/angle/src/libGLESv2/validationES3.cpp
deleted file mode 100644
index 2d3a039e13..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/validationES3.cpp
+++ /dev/null
@@ -1,1286 +0,0 @@
-//
-// Copyright (c) 2013-2014 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.
-//
-
-// validationES3.cpp: Validation functions for OpenGL ES 3.0 entry point parameters
-
-#include "libGLESv2/validationES3.h"
-#include "libGLESv2/validationES.h"
-#include "libGLESv2/Context.h"
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/Framebuffer.h"
-#include "libGLESv2/Renderbuffer.h"
-#include "libGLESv2/formatutils.h"
-#include "libGLESv2/main.h"
-#include "libGLESv2/FramebufferAttachment.h"
-
-#include "common/mathutil.h"
-
-namespace gl
-{
-
-struct ES3FormatCombination
-{
- GLenum internalFormat;
- GLenum format;
- GLenum type;
-};
-
-bool operator<(const ES3FormatCombination& a, const ES3FormatCombination& b)
-{
- return memcmp(&a, &b, sizeof(ES3FormatCombination)) < 0;
-}
-
-typedef std::set<ES3FormatCombination> ES3FormatCombinationSet;
-
-static inline void InsertES3FormatCombo(ES3FormatCombinationSet *set, GLenum internalFormat, GLenum format, GLenum type)
-{
- ES3FormatCombination info;
- info.internalFormat = internalFormat;
- info.format = format;
- info.type = type;
- set->insert(info);
-}
-
-ES3FormatCombinationSet BuildES3FormatSet()
-{
- ES3FormatCombinationSet set;
-
- // Format combinations from ES 3.0.1 spec, table 3.2
-
- // | Internal format | Format | Type |
- // | | | |
- InsertES3FormatCombo(&set, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_RGBA4, GL_RGBA, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_RGBA8_SNORM, GL_RGBA, GL_BYTE );
- InsertES3FormatCombo(&set, GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4 );
- InsertES3FormatCombo(&set, GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV );
- InsertES3FormatCombo(&set, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV );
- InsertES3FormatCombo(&set, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 );
- InsertES3FormatCombo(&set, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT );
- InsertES3FormatCombo(&set, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT_OES );
- InsertES3FormatCombo(&set, GL_RGBA32F, GL_RGBA, GL_FLOAT );
- InsertES3FormatCombo(&set, GL_RGBA16F, GL_RGBA, GL_FLOAT );
- InsertES3FormatCombo(&set, GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE );
- InsertES3FormatCombo(&set, GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT );
- InsertES3FormatCombo(&set, GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT );
- InsertES3FormatCombo(&set, GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT );
- InsertES3FormatCombo(&set, GL_RGBA32I, GL_RGBA_INTEGER, GL_INT );
- InsertES3FormatCombo(&set, GL_RGB10_A2UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV );
- InsertES3FormatCombo(&set, GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_RGB565, GL_RGB, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_RGB8_SNORM, GL_RGB, GL_BYTE );
- InsertES3FormatCombo(&set, GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5 );
- InsertES3FormatCombo(&set, GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV );
- InsertES3FormatCombo(&set, GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV );
- InsertES3FormatCombo(&set, GL_RGB16F, GL_RGB, GL_HALF_FLOAT );
- InsertES3FormatCombo(&set, GL_RGB16F, GL_RGB, GL_HALF_FLOAT_OES );
- InsertES3FormatCombo(&set, GL_R11F_G11F_B10F, GL_RGB, GL_HALF_FLOAT );
- InsertES3FormatCombo(&set, GL_R11F_G11F_B10F, GL_RGB, GL_HALF_FLOAT_OES );
- InsertES3FormatCombo(&set, GL_RGB9_E5, GL_RGB, GL_HALF_FLOAT );
- InsertES3FormatCombo(&set, GL_RGB9_E5, GL_RGB, GL_HALF_FLOAT_OES );
- InsertES3FormatCombo(&set, GL_RGB32F, GL_RGB, GL_FLOAT );
- InsertES3FormatCombo(&set, GL_RGB16F, GL_RGB, GL_FLOAT );
- InsertES3FormatCombo(&set, GL_R11F_G11F_B10F, GL_RGB, GL_FLOAT );
- InsertES3FormatCombo(&set, GL_RGB9_E5, GL_RGB, GL_FLOAT );
- InsertES3FormatCombo(&set, GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_RGB8I, GL_RGB_INTEGER, GL_BYTE );
- InsertES3FormatCombo(&set, GL_RGB16UI, GL_RGB_INTEGER, GL_UNSIGNED_SHORT );
- InsertES3FormatCombo(&set, GL_RGB16I, GL_RGB_INTEGER, GL_SHORT );
- InsertES3FormatCombo(&set, GL_RGB32UI, GL_RGB_INTEGER, GL_UNSIGNED_INT );
- InsertES3FormatCombo(&set, GL_RGB32I, GL_RGB_INTEGER, GL_INT );
- InsertES3FormatCombo(&set, GL_RG8, GL_RG, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_RG8_SNORM, GL_RG, GL_BYTE );
- InsertES3FormatCombo(&set, GL_RG16F, GL_RG, GL_HALF_FLOAT );
- InsertES3FormatCombo(&set, GL_RG16F, GL_RG, GL_HALF_FLOAT_OES );
- InsertES3FormatCombo(&set, GL_RG32F, GL_RG, GL_FLOAT );
- InsertES3FormatCombo(&set, GL_RG16F, GL_RG, GL_FLOAT );
- InsertES3FormatCombo(&set, GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_RG8I, GL_RG_INTEGER, GL_BYTE );
- InsertES3FormatCombo(&set, GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT );
- InsertES3FormatCombo(&set, GL_RG16I, GL_RG_INTEGER, GL_SHORT );
- InsertES3FormatCombo(&set, GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT );
- InsertES3FormatCombo(&set, GL_RG32I, GL_RG_INTEGER, GL_INT );
- InsertES3FormatCombo(&set, GL_R8, GL_RED, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_R8_SNORM, GL_RED, GL_BYTE );
- InsertES3FormatCombo(&set, GL_R16F, GL_RED, GL_HALF_FLOAT );
- InsertES3FormatCombo(&set, GL_R16F, GL_RED, GL_HALF_FLOAT_OES );
- InsertES3FormatCombo(&set, GL_R32F, GL_RED, GL_FLOAT );
- InsertES3FormatCombo(&set, GL_R16F, GL_RED, GL_FLOAT );
- InsertES3FormatCombo(&set, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_R8I, GL_RED_INTEGER, GL_BYTE );
- InsertES3FormatCombo(&set, GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT );
- InsertES3FormatCombo(&set, GL_R16I, GL_RED_INTEGER, GL_SHORT );
- InsertES3FormatCombo(&set, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT );
- InsertES3FormatCombo(&set, GL_R32I, GL_RED_INTEGER, GL_INT );
-
- // Unsized formats
- InsertES3FormatCombo(&set, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4 );
- InsertES3FormatCombo(&set, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 );
- InsertES3FormatCombo(&set, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5 );
- InsertES3FormatCombo(&set, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_SRGB_ALPHA_EXT, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_SRGB_EXT, GL_SRGB_EXT, GL_UNSIGNED_BYTE );
-
- // Depth stencil formats
- InsertES3FormatCombo(&set, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT );
- InsertES3FormatCombo(&set, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT );
- InsertES3FormatCombo(&set, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT );
- InsertES3FormatCombo(&set, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT );
- InsertES3FormatCombo(&set, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8 );
- InsertES3FormatCombo(&set, GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
-
- // From GL_EXT_sRGB
- InsertES3FormatCombo(&set, GL_SRGB8_ALPHA8_EXT, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_SRGB8, GL_SRGB_EXT, GL_UNSIGNED_BYTE );
-
- // From GL_OES_texture_float
- InsertES3FormatCombo(&set, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_FLOAT );
- InsertES3FormatCombo(&set, GL_LUMINANCE, GL_LUMINANCE, GL_FLOAT );
- InsertES3FormatCombo(&set, GL_ALPHA, GL_ALPHA, GL_FLOAT );
-
- // From GL_OES_texture_half_float
- InsertES3FormatCombo(&set, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT );
- InsertES3FormatCombo(&set, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES );
- InsertES3FormatCombo(&set, GL_LUMINANCE, GL_LUMINANCE, GL_HALF_FLOAT );
- InsertES3FormatCombo(&set, GL_LUMINANCE, GL_LUMINANCE, GL_HALF_FLOAT_OES );
- InsertES3FormatCombo(&set, GL_ALPHA, GL_ALPHA, GL_HALF_FLOAT );
- InsertES3FormatCombo(&set, GL_ALPHA, GL_ALPHA, GL_HALF_FLOAT_OES );
-
- // From GL_EXT_texture_format_BGRA8888
- InsertES3FormatCombo(&set, GL_BGRA_EXT, GL_BGRA_EXT, GL_UNSIGNED_BYTE );
-
- // From GL_EXT_texture_storage
- // | Internal format | Format | Type |
- // | | | |
- InsertES3FormatCombo(&set, GL_ALPHA8_EXT, GL_ALPHA, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_LUMINANCE8_EXT, GL_LUMINANCE, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_LUMINANCE8_ALPHA8_EXT, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_ALPHA32F_EXT, GL_ALPHA, GL_FLOAT );
- InsertES3FormatCombo(&set, GL_LUMINANCE32F_EXT, GL_LUMINANCE, GL_FLOAT );
- InsertES3FormatCombo(&set, GL_LUMINANCE_ALPHA32F_EXT, GL_LUMINANCE_ALPHA, GL_FLOAT );
- InsertES3FormatCombo(&set, GL_ALPHA16F_EXT, GL_ALPHA, GL_HALF_FLOAT );
- InsertES3FormatCombo(&set, GL_ALPHA16F_EXT, GL_ALPHA, GL_HALF_FLOAT_OES );
- InsertES3FormatCombo(&set, GL_LUMINANCE16F_EXT, GL_LUMINANCE, GL_HALF_FLOAT );
- InsertES3FormatCombo(&set, GL_LUMINANCE16F_EXT, GL_LUMINANCE, GL_HALF_FLOAT_OES );
- InsertES3FormatCombo(&set, GL_LUMINANCE_ALPHA16F_EXT, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT );
- InsertES3FormatCombo(&set, GL_LUMINANCE_ALPHA16F_EXT, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES );
-
- // From GL_EXT_texture_storage and GL_EXT_texture_format_BGRA8888
- InsertES3FormatCombo(&set, GL_BGRA8_EXT, GL_BGRA_EXT, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_BGRA4_ANGLEX, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT);
- InsertES3FormatCombo(&set, GL_BGRA4_ANGLEX, GL_BGRA_EXT, GL_UNSIGNED_BYTE );
- InsertES3FormatCombo(&set, GL_BGR5_A1_ANGLEX, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT);
- InsertES3FormatCombo(&set, GL_BGR5_A1_ANGLEX, GL_BGRA_EXT, GL_UNSIGNED_BYTE );
-
- // From GL_ANGLE_depth_texture
- InsertES3FormatCombo(&set, GL_DEPTH_COMPONENT32_OES, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT_24_8_OES );
-
- // Compressed formats
- // From ES 3.0.1 spec, table 3.16
- // | Internal format | Format | Type |
- // | | | |
- InsertES3FormatCombo(&set, GL_COMPRESSED_R11_EAC, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE);
- InsertES3FormatCombo(&set, GL_COMPRESSED_R11_EAC, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE);
- InsertES3FormatCombo(&set, GL_COMPRESSED_SIGNED_R11_EAC, GL_COMPRESSED_SIGNED_R11_EAC, GL_UNSIGNED_BYTE);
- InsertES3FormatCombo(&set, GL_COMPRESSED_RG11_EAC, GL_COMPRESSED_RG11_EAC, GL_UNSIGNED_BYTE);
- InsertES3FormatCombo(&set, GL_COMPRESSED_SIGNED_RG11_EAC, GL_COMPRESSED_SIGNED_RG11_EAC, GL_UNSIGNED_BYTE);
- InsertES3FormatCombo(&set, GL_COMPRESSED_RGB8_ETC2, GL_COMPRESSED_RGB8_ETC2, GL_UNSIGNED_BYTE);
- InsertES3FormatCombo(&set, GL_COMPRESSED_SRGB8_ETC2, GL_COMPRESSED_SRGB8_ETC2, GL_UNSIGNED_BYTE);
- InsertES3FormatCombo(&set, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE);
- InsertES3FormatCombo(&set, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE);
- InsertES3FormatCombo(&set, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_UNSIGNED_BYTE);
- InsertES3FormatCombo(&set, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_UNSIGNED_BYTE);
-
-
- // From GL_EXT_texture_compression_dxt1
- InsertES3FormatCombo(&set, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE);
- InsertES3FormatCombo(&set, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE);
-
- // From GL_ANGLE_texture_compression_dxt3
- InsertES3FormatCombo(&set, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE);
-
- // From GL_ANGLE_texture_compression_dxt5
- InsertES3FormatCombo(&set, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE);
-
- return set;
-}
-
-static bool ValidateTexImageFormatCombination(gl::Context *context, GLenum internalFormat, GLenum format, GLenum type)
-{
- // Note: dEQP 2013.4 expects an INVALID_VALUE error for TexImage3D with an invalid
- // internal format. (dEQP-GLES3.functional.negative_api.texture.teximage3d)
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
- if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions()))
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- // The type and format are valid if any supported internal format has that type and format
- bool formatSupported = false;
- bool typeSupported = false;
-
- static const ES3FormatCombinationSet es3FormatSet = BuildES3FormatSet();
- for (ES3FormatCombinationSet::const_iterator i = es3FormatSet.begin(); i != es3FormatSet.end(); i++)
- {
- if (i->format == format || i->type == type)
- {
- const gl::InternalFormat &info = gl::GetInternalFormatInfo(i->internalFormat);
- bool supported = info.textureSupport(context->getClientVersion(), context->getExtensions());
- if (supported && i->type == type)
- {
- typeSupported = true;
- }
- if (supported && i->format == format)
- {
- formatSupported = true;
- }
-
- // Early-out if both type and format are supported now
- if (typeSupported && formatSupported)
- {
- break;
- }
- }
- }
-
- if (!typeSupported || !formatSupported)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- // Check if this is a valid format combination to load texture data
- ES3FormatCombination searchFormat;
- searchFormat.internalFormat = internalFormat;
- searchFormat.format = format;
- searchFormat.type = type;
-
- if (es3FormatSet.find(searchFormat) == es3FormatSet.end())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- return true;
-}
-
-bool ValidateES3TexImageParameters(Context *context, GLenum target, GLint level, GLenum internalformat, bool isCompressed, bool isSubImage,
- GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
- GLint border, GLenum format, GLenum type, const GLvoid *pixels)
-{
- if (!ValidTexture2DDestinationTarget(context, target))
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- // Validate image size
- if (!ValidImageSize(context, target, level, width, height, depth))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- // Verify zero border
- if (border != 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (xoffset < 0 || yoffset < 0 || zoffset < 0 ||
- std::numeric_limits<GLsizei>::max() - xoffset < width ||
- std::numeric_limits<GLsizei>::max() - yoffset < height ||
- std::numeric_limits<GLsizei>::max() - zoffset < depth)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- const gl::Caps &caps = context->getCaps();
-
- gl::Texture *texture = NULL;
- bool textureCompressed = false;
- GLenum textureInternalFormat = GL_NONE;
- GLint textureLevelWidth = 0;
- GLint textureLevelHeight = 0;
- GLint textureLevelDepth = 0;
- switch (target)
- {
- case GL_TEXTURE_2D:
- {
- if (static_cast<GLuint>(width) > (caps.max2DTextureSize >> level) ||
- static_cast<GLuint>(height) > (caps.max2DTextureSize >> level))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- gl::Texture2D *texture2d = context->getTexture2D();
- if (texture2d)
- {
- textureCompressed = texture2d->isCompressed(level);
- textureInternalFormat = texture2d->getInternalFormat(level);
- textureLevelWidth = texture2d->getWidth(level);
- textureLevelHeight = texture2d->getHeight(level);
- textureLevelDepth = 1;
- texture = texture2d;
- }
- }
- break;
-
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- {
- if (!isSubImage && width != height)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (static_cast<GLuint>(width) > (caps.maxCubeMapTextureSize >> level))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
- if (textureCube)
- {
- textureCompressed = textureCube->isCompressed(target, level);
- textureInternalFormat = textureCube->getInternalFormat(target, level);
- textureLevelWidth = textureCube->getWidth(target, level);
- textureLevelHeight = textureCube->getHeight(target, level);
- textureLevelDepth = 1;
- texture = textureCube;
- }
- }
- break;
-
- case GL_TEXTURE_3D:
- {
- if (static_cast<GLuint>(width) > (caps.max3DTextureSize >> level) ||
- static_cast<GLuint>(height) > (caps.max3DTextureSize >> level) ||
- static_cast<GLuint>(depth) > (caps.max3DTextureSize >> level))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- gl::Texture3D *texture3d = context->getTexture3D();
- if (texture3d)
- {
- textureCompressed = texture3d->isCompressed(level);
- textureInternalFormat = texture3d->getInternalFormat(level);
- textureLevelWidth = texture3d->getWidth(level);
- textureLevelHeight = texture3d->getHeight(level);
- textureLevelDepth = texture3d->getDepth(level);
- texture = texture3d;
- }
- }
- break;
-
- case GL_TEXTURE_2D_ARRAY:
- {
- if (static_cast<GLuint>(width) > (caps.max2DTextureSize >> level) ||
- static_cast<GLuint>(height) > (caps.max2DTextureSize >> level) ||
- static_cast<GLuint>(depth) > (caps.maxArrayTextureLayers >> level))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- gl::Texture2DArray *texture2darray = context->getTexture2DArray();
- if (texture2darray)
- {
- textureCompressed = texture2darray->isCompressed(level);
- textureInternalFormat = texture2darray->getInternalFormat(level);
- textureLevelWidth = texture2darray->getWidth(level);
- textureLevelHeight = texture2darray->getHeight(level);
- textureLevelDepth = texture2darray->getLayers(level);
- texture = texture2darray;
- }
- }
- break;
-
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if (!texture)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (texture->isImmutable() && !isSubImage)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- // Validate texture formats
- GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat;
- const gl::InternalFormat &actualFormatInfo = gl::GetInternalFormatInfo(actualInternalFormat);
- if (isCompressed)
- {
- if (!ValidCompressedImageSize(context, actualInternalFormat, width, height))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (!actualFormatInfo.compressed)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if (target == GL_TEXTURE_3D)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
- else
- {
- if (!ValidateTexImageFormatCombination(context, actualInternalFormat, format, type))
- {
- return false;
- }
-
- if (target == GL_TEXTURE_3D && (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
-
- // Validate sub image parameters
- if (isSubImage)
- {
- if (isCompressed != textureCompressed)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (isCompressed)
- {
- if ((width % 4 != 0 && width != textureLevelWidth) ||
- (height % 4 != 0 && height != textureLevelHeight))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
-
- if (width == 0 || height == 0 || depth == 0)
- {
- return false;
- }
-
- if (xoffset < 0 || yoffset < 0 || zoffset < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (std::numeric_limits<GLsizei>::max() - xoffset < width ||
- std::numeric_limits<GLsizei>::max() - yoffset < height ||
- std::numeric_limits<GLsizei>::max() - zoffset < depth)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (xoffset + width > textureLevelWidth ||
- yoffset + height > textureLevelHeight ||
- zoffset + depth > textureLevelDepth)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- }
-
- // Check for pixel unpack buffer related API errors
- gl::Buffer *pixelUnpackBuffer = context->getState().getTargetBuffer(GL_PIXEL_UNPACK_BUFFER);
- if (pixelUnpackBuffer != NULL)
- {
- // ...the data would be unpacked from the buffer object such that the memory reads required
- // would exceed the data store size.
- size_t widthSize = static_cast<size_t>(width);
- size_t heightSize = static_cast<size_t>(height);
- size_t depthSize = static_cast<size_t>(depth);
- GLenum sizedFormat = GetSizedInternalFormat(actualInternalFormat, type);
-
- size_t pixelBytes = static_cast<size_t>(gl::GetInternalFormatInfo(sizedFormat).pixelBytes);
-
- if (!rx::IsUnsignedMultiplicationSafe(widthSize, heightSize) ||
- !rx::IsUnsignedMultiplicationSafe(widthSize * heightSize, depthSize) ||
- !rx::IsUnsignedMultiplicationSafe(widthSize * heightSize * depthSize, pixelBytes))
- {
- // Overflow past the end of the buffer
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(sizedFormat);
- size_t copyBytes = formatInfo.computeBlockSize(type, width, height);
- size_t offset = reinterpret_cast<size_t>(pixels);
-
- if (!rx::IsUnsignedAdditionSafe(offset, copyBytes) ||
- ((offset + copyBytes) > static_cast<size_t>(pixelUnpackBuffer->getSize())))
- {
- // Overflow past the end of the buffer
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- // ...data is not evenly divisible into the number of bytes needed to store in memory a datum
- // indicated by type.
- if (!isCompressed)
- {
- size_t dataBytesPerPixel = static_cast<size_t>(gl::GetTypeInfo(type).bytes);
-
- if ((offset % dataBytesPerPixel) != 0)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
-
- // ...the buffer object's data store is currently mapped.
- if (pixelUnpackBuffer->isMapped())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
-
- return true;
-}
-
-struct EffectiveInternalFormatInfo
-{
- GLenum mEffectiveFormat;
- GLenum mDestFormat;
- GLuint mMinRedBits;
- GLuint mMaxRedBits;
- GLuint mMinGreenBits;
- GLuint mMaxGreenBits;
- GLuint mMinBlueBits;
- GLuint mMaxBlueBits;
- GLuint mMinAlphaBits;
- GLuint mMaxAlphaBits;
-
- EffectiveInternalFormatInfo(GLenum effectiveFormat, GLenum destFormat, GLuint minRedBits, GLuint maxRedBits,
- GLuint minGreenBits, GLuint maxGreenBits, GLuint minBlueBits, GLuint maxBlueBits,
- GLuint minAlphaBits, GLuint maxAlphaBits)
- : mEffectiveFormat(effectiveFormat), mDestFormat(destFormat), mMinRedBits(minRedBits),
- mMaxRedBits(maxRedBits), mMinGreenBits(minGreenBits), mMaxGreenBits(maxGreenBits),
- mMinBlueBits(minBlueBits), mMaxBlueBits(maxBlueBits), mMinAlphaBits(minAlphaBits),
- mMaxAlphaBits(maxAlphaBits) {};
-};
-
-typedef std::vector<EffectiveInternalFormatInfo> EffectiveInternalFormatList;
-
-static EffectiveInternalFormatList BuildSizedEffectiveInternalFormatList()
-{
- EffectiveInternalFormatList list;
-
- // OpenGL ES 3.0.3 Specification, Table 3.17, pg 141: Effective internal format coresponding to destination internal format and
- // linear source buffer component sizes.
- // | Source channel min/max sizes |
- // Effective Internal Format | N/A | R | G | B | A |
- list.push_back(EffectiveInternalFormatInfo(GL_ALPHA8_EXT, GL_NONE, 0, 0, 0, 0, 0, 0, 1, 8));
- list.push_back(EffectiveInternalFormatInfo(GL_R8, GL_NONE, 1, 8, 0, 0, 0, 0, 0, 0));
- list.push_back(EffectiveInternalFormatInfo(GL_RG8, GL_NONE, 1, 8, 1, 8, 0, 0, 0, 0));
- list.push_back(EffectiveInternalFormatInfo(GL_RGB565, GL_NONE, 1, 5, 1, 6, 1, 5, 0, 0));
- list.push_back(EffectiveInternalFormatInfo(GL_RGB8, GL_NONE, 6, 8, 7, 8, 6, 8, 0, 0));
- list.push_back(EffectiveInternalFormatInfo(GL_RGBA4, GL_NONE, 1, 4, 1, 4, 1, 4, 1, 4));
- list.push_back(EffectiveInternalFormatInfo(GL_RGB5_A1, GL_NONE, 5, 5, 5, 5, 5, 5, 1, 1));
- list.push_back(EffectiveInternalFormatInfo(GL_RGBA8, GL_NONE, 5, 8, 5, 8, 5, 8, 2, 8));
- list.push_back(EffectiveInternalFormatInfo(GL_RGB10_A2, GL_NONE, 9, 10, 9, 10, 9, 10, 2, 2));
-
- return list;
-}
-
-static EffectiveInternalFormatList BuildUnsizedEffectiveInternalFormatList()
-{
- EffectiveInternalFormatList list;
-
- // OpenGL ES 3.0.3 Specification, Table 3.17, pg 141: Effective internal format coresponding to destination internal format and
- // linear source buffer component sizes.
- // | Source channel min/max sizes |
- // Effective Internal Format | Dest Format | R | G | B | A |
- list.push_back(EffectiveInternalFormatInfo(GL_ALPHA8_EXT, GL_ALPHA, 0, UINT_MAX, 0, UINT_MAX, 0, UINT_MAX, 1, 8));
- list.push_back(EffectiveInternalFormatInfo(GL_LUMINANCE8_EXT, GL_LUMINANCE, 1, 8, 0, UINT_MAX, 0, UINT_MAX, 0, UINT_MAX));
- list.push_back(EffectiveInternalFormatInfo(GL_LUMINANCE8_ALPHA8_EXT, GL_LUMINANCE_ALPHA, 1, 8, 0, UINT_MAX, 0, UINT_MAX, 1, 8));
- list.push_back(EffectiveInternalFormatInfo(GL_RGB565, GL_RGB, 1, 5, 1, 6, 1, 5, 0, UINT_MAX));
- list.push_back(EffectiveInternalFormatInfo(GL_RGB8, GL_RGB, 6, 8, 7, 8, 6, 8, 0, UINT_MAX));
- list.push_back(EffectiveInternalFormatInfo(GL_RGBA4, GL_RGBA, 1, 4, 1, 4, 1, 4, 1, 4));
- list.push_back(EffectiveInternalFormatInfo(GL_RGB5_A1, GL_RGBA, 5, 5, 5, 5, 5, 5, 1, 1));
- list.push_back(EffectiveInternalFormatInfo(GL_RGBA8, GL_RGBA, 5, 8, 5, 8, 5, 8, 5, 8));
-
- return list;
-}
-
-static bool GetEffectiveInternalFormat(const InternalFormat &srcFormat, const InternalFormat &destFormat,
- GLenum *outEffectiveFormat)
-{
- const EffectiveInternalFormatList *list = NULL;
- GLenum targetFormat = GL_NONE;
-
- if (destFormat.pixelBytes > 0)
- {
- static const EffectiveInternalFormatList sizedList = BuildSizedEffectiveInternalFormatList();
- list = &sizedList;
- }
- else
- {
- static const EffectiveInternalFormatList unsizedList = BuildUnsizedEffectiveInternalFormatList();
- list = &unsizedList;
- targetFormat = destFormat.format;
- }
-
- for (size_t curFormat = 0; curFormat < list->size(); ++curFormat)
- {
- const EffectiveInternalFormatInfo& formatInfo = list->at(curFormat);
- if ((formatInfo.mDestFormat == targetFormat) &&
- (formatInfo.mMinRedBits <= srcFormat.redBits && formatInfo.mMaxRedBits >= srcFormat.redBits) &&
- (formatInfo.mMinGreenBits <= srcFormat.greenBits && formatInfo.mMaxGreenBits >= srcFormat.greenBits) &&
- (formatInfo.mMinBlueBits <= srcFormat.blueBits && formatInfo.mMaxBlueBits >= srcFormat.blueBits) &&
- (formatInfo.mMinAlphaBits <= srcFormat.alphaBits && formatInfo.mMaxAlphaBits >= srcFormat.alphaBits))
- {
- *outEffectiveFormat = formatInfo.mEffectiveFormat;
- return true;
- }
- }
-
- return false;
-}
-
-struct CopyConversion
-{
- GLenum mTextureFormat;
- GLenum mFramebufferFormat;
-
- CopyConversion(GLenum textureFormat, GLenum framebufferFormat)
- : mTextureFormat(textureFormat), mFramebufferFormat(framebufferFormat) { }
-
- bool operator<(const CopyConversion& other) const
- {
- return memcmp(this, &other, sizeof(CopyConversion)) < 0;
- }
-};
-
-typedef std::set<CopyConversion> CopyConversionSet;
-
-static CopyConversionSet BuildValidES3CopyTexImageCombinations()
-{
- CopyConversionSet set;
-
- // From ES 3.0.1 spec, table 3.15
- set.insert(CopyConversion(GL_ALPHA, GL_RGBA));
- set.insert(CopyConversion(GL_LUMINANCE, GL_RED));
- set.insert(CopyConversion(GL_LUMINANCE, GL_RG));
- set.insert(CopyConversion(GL_LUMINANCE, GL_RGB));
- set.insert(CopyConversion(GL_LUMINANCE, GL_RGBA));
- set.insert(CopyConversion(GL_LUMINANCE_ALPHA, GL_RGBA));
- set.insert(CopyConversion(GL_RED, GL_RED));
- set.insert(CopyConversion(GL_RED, GL_RG));
- set.insert(CopyConversion(GL_RED, GL_RGB));
- set.insert(CopyConversion(GL_RED, GL_RGBA));
- set.insert(CopyConversion(GL_RG, GL_RG));
- set.insert(CopyConversion(GL_RG, GL_RGB));
- set.insert(CopyConversion(GL_RG, GL_RGBA));
- set.insert(CopyConversion(GL_RGB, GL_RGB));
- set.insert(CopyConversion(GL_RGB, GL_RGBA));
- set.insert(CopyConversion(GL_RGBA, GL_RGBA));
-
- // Necessary for ANGLE back-buffers
- set.insert(CopyConversion(GL_ALPHA, GL_BGRA_EXT));
- set.insert(CopyConversion(GL_LUMINANCE, GL_BGRA_EXT));
- set.insert(CopyConversion(GL_LUMINANCE_ALPHA, GL_BGRA_EXT));
- set.insert(CopyConversion(GL_RED, GL_BGRA_EXT));
- set.insert(CopyConversion(GL_RG, GL_BGRA_EXT));
- set.insert(CopyConversion(GL_RGB, GL_BGRA_EXT));
- set.insert(CopyConversion(GL_RGBA, GL_BGRA_EXT));
-
- set.insert(CopyConversion(GL_RED_INTEGER, GL_RED_INTEGER));
- set.insert(CopyConversion(GL_RED_INTEGER, GL_RG_INTEGER));
- set.insert(CopyConversion(GL_RED_INTEGER, GL_RGB_INTEGER));
- set.insert(CopyConversion(GL_RED_INTEGER, GL_RGBA_INTEGER));
- set.insert(CopyConversion(GL_RG_INTEGER, GL_RG_INTEGER));
- set.insert(CopyConversion(GL_RG_INTEGER, GL_RGB_INTEGER));
- set.insert(CopyConversion(GL_RG_INTEGER, GL_RGBA_INTEGER));
- set.insert(CopyConversion(GL_RGB_INTEGER, GL_RGB_INTEGER));
- set.insert(CopyConversion(GL_RGB_INTEGER, GL_RGBA_INTEGER));
- set.insert(CopyConversion(GL_RGBA_INTEGER, GL_RGBA_INTEGER));
-
- return set;
-}
-
-static bool IsValidES3CopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBufferInternalFormat, GLuint readBufferHandle)
-{
- const InternalFormat &textureInternalFormatInfo = GetInternalFormatInfo(textureInternalFormat);
- const InternalFormat &framebufferInternalFormatInfo = GetInternalFormatInfo(frameBufferInternalFormat);
-
- static const CopyConversionSet conversionSet = BuildValidES3CopyTexImageCombinations();
- if (conversionSet.find(CopyConversion(textureInternalFormatInfo.format, framebufferInternalFormatInfo.format)) != conversionSet.end())
- {
- // Section 3.8.5 of the GLES 3.0.3 spec states that source and destination formats
- // must both be signed, unsigned, or fixed point and both source and destinations
- // must be either both SRGB or both not SRGB. EXT_color_buffer_float adds allowed
- // conversion between fixed and floating point.
-
- if ((textureInternalFormatInfo.colorEncoding == GL_SRGB) != (framebufferInternalFormatInfo.colorEncoding == GL_SRGB))
- {
- return false;
- }
-
- if (((textureInternalFormatInfo.componentType == GL_INT) != (framebufferInternalFormatInfo.componentType == GL_INT )) ||
- ((textureInternalFormatInfo.componentType == GL_UNSIGNED_INT) != (framebufferInternalFormatInfo.componentType == GL_UNSIGNED_INT)))
- {
- return false;
- }
-
- if ((textureInternalFormatInfo.componentType == GL_UNSIGNED_NORMALIZED ||
- textureInternalFormatInfo.componentType == GL_SIGNED_NORMALIZED ||
- textureInternalFormatInfo.componentType == GL_FLOAT) &&
- !(framebufferInternalFormatInfo.componentType == GL_UNSIGNED_NORMALIZED ||
- framebufferInternalFormatInfo.componentType == GL_SIGNED_NORMALIZED ||
- framebufferInternalFormatInfo.componentType == GL_FLOAT))
- {
- return false;
- }
-
- // GLES specification 3.0.3, sec 3.8.5, pg 139-140:
- // The effective internal format of the source buffer is determined with the following rules applied in order:
- // * If the source buffer is a texture or renderbuffer that was created with a sized internal format then the
- // effective internal format is the source buffer's sized internal format.
- // * If the source buffer is a texture that was created with an unsized base internal format, then the
- // effective internal format is the source image array's effective internal format, as specified by table
- // 3.12, which is determined from the <format> and <type> that were used when the source image array was
- // specified by TexImage*.
- // * Otherwise the effective internal format is determined by the row in table 3.17 or 3.18 where
- // Destination Internal Format matches internalformat and where the [source channel sizes] are consistent
- // with the values of the source buffer's [channel sizes]. Table 3.17 is used if the
- // FRAMEBUFFER_ATTACHMENT_ENCODING is LINEAR and table 3.18 is used if the FRAMEBUFFER_ATTACHMENT_ENCODING
- // is SRGB.
- const InternalFormat *sourceEffectiveFormat = NULL;
- if (readBufferHandle != 0)
- {
- // Not the default framebuffer, therefore the read buffer must be a user-created texture or renderbuffer
- if (framebufferInternalFormatInfo.pixelBytes > 0)
- {
- sourceEffectiveFormat = &framebufferInternalFormatInfo;
- }
- else
- {
- // Renderbuffers cannot be created with an unsized internal format, so this must be an unsized-format
- // texture. We can use the same table we use when creating textures to get its effective sized format.
- const FormatType &typeInfo = GetFormatTypeInfo(framebufferInternalFormatInfo.format, framebufferInternalFormatInfo.type);
- sourceEffectiveFormat = &GetInternalFormatInfo(typeInfo.internalFormat);
- }
- }
- else
- {
- // The effective internal format must be derived from the source framebuffer's channel sizes.
- // This is done in GetEffectiveInternalFormat for linear buffers (table 3.17)
- if (framebufferInternalFormatInfo.colorEncoding == GL_LINEAR)
- {
- GLenum effectiveFormat;
- if (GetEffectiveInternalFormat(framebufferInternalFormatInfo, textureInternalFormatInfo, &effectiveFormat))
- {
- sourceEffectiveFormat = &GetInternalFormatInfo(effectiveFormat);
- }
- else
- {
- return false;
- }
- }
- else if (framebufferInternalFormatInfo.colorEncoding == GL_SRGB)
- {
- // SRGB buffers can only be copied to sized format destinations according to table 3.18
- if ((textureInternalFormatInfo.pixelBytes > 0) &&
- (framebufferInternalFormatInfo.redBits >= 1 && framebufferInternalFormatInfo.redBits <= 8) &&
- (framebufferInternalFormatInfo.greenBits >= 1 && framebufferInternalFormatInfo.greenBits <= 8) &&
- (framebufferInternalFormatInfo.blueBits >= 1 && framebufferInternalFormatInfo.blueBits <= 8) &&
- (framebufferInternalFormatInfo.alphaBits >= 1 && framebufferInternalFormatInfo.alphaBits <= 8))
- {
- sourceEffectiveFormat = &GetInternalFormatInfo(GL_SRGB8_ALPHA8);
- }
- else
- {
- return false;
- }
- }
- else
- {
- UNREACHABLE();
- return false;
- }
- }
-
- if (textureInternalFormatInfo.pixelBytes > 0)
- {
- // Section 3.8.5 of the GLES 3.0.3 spec, pg 139, requires that, if the destination format is sized,
- // component sizes of the source and destination formats must exactly match
- if (textureInternalFormatInfo.redBits != sourceEffectiveFormat->redBits ||
- textureInternalFormatInfo.greenBits != sourceEffectiveFormat->greenBits ||
- textureInternalFormatInfo.blueBits != sourceEffectiveFormat->blueBits ||
- textureInternalFormatInfo.alphaBits != sourceEffectiveFormat->alphaBits)
- {
- return false;
- }
- }
-
-
- return true; // A conversion function exists, and no rule in the specification has precluded conversion
- // between these formats.
- }
-
- return false;
-}
-
-bool ValidateES3CopyTexImageParameters(Context *context, GLenum target, GLint level, GLenum internalformat,
- bool isSubImage, GLint xoffset, GLint yoffset, GLint zoffset,
- GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
-{
- GLenum textureInternalFormat;
- if (!ValidateCopyTexImageParametersBase(context, target, level, internalformat, isSubImage,
- xoffset, yoffset, zoffset, x, y, width, height,
- border, &textureInternalFormat))
- {
- return false;
- }
-
- gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
-
- if (framebuffer->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
- {
- context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
- return false;
- }
-
- if (context->getState().getReadFramebuffer()->id() != 0 &&
- framebuffer->getSamples(context->getData()) != 0)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- gl::FramebufferAttachment *source = framebuffer->getReadColorbuffer();
- GLenum colorbufferInternalFormat = source->getInternalFormat();
-
- if (isSubImage)
- {
- if (!IsValidES3CopyTexImageCombination(textureInternalFormat, colorbufferInternalFormat,
- context->getState().getReadFramebuffer()->id()))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
- else
- {
- if (!gl::IsValidES3CopyTexImageCombination(internalformat, colorbufferInternalFormat,
- context->getState().getReadFramebuffer()->id()))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
-
- // If width or height is zero, it is a no-op. Return false without setting an error.
- return (width > 0 && height > 0);
-}
-
-bool ValidateES3TexStorageParameters(Context *context, GLenum target, GLsizei levels, GLenum internalformat,
- GLsizei width, GLsizei height, GLsizei depth)
-{
- if (width < 1 || height < 1 || depth < 1 || levels < 1)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (levels > gl::log2(std::max(std::max(width, height), depth)) + 1)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- const gl::Caps &caps = context->getCaps();
-
- gl::Texture *texture = NULL;
- switch (target)
- {
- case GL_TEXTURE_2D:
- {
- texture = context->getTexture2D();
-
- if (static_cast<GLuint>(width) > caps.max2DTextureSize ||
- static_cast<GLuint>(height) > caps.max2DTextureSize)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- }
- break;
-
- case GL_TEXTURE_CUBE_MAP:
- {
- texture = context->getTextureCubeMap();
-
- if (width != height)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (static_cast<GLuint>(width) > caps.maxCubeMapTextureSize)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- }
- break;
-
- case GL_TEXTURE_3D:
- {
- texture = context->getTexture3D();
-
- if (static_cast<GLuint>(width) > caps.max3DTextureSize ||
- static_cast<GLuint>(height) > caps.max3DTextureSize ||
- static_cast<GLuint>(depth) > caps.max3DTextureSize)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- }
- break;
-
- case GL_TEXTURE_2D_ARRAY:
- {
- texture = context->getTexture2DArray();
-
- if (static_cast<GLuint>(width) > caps.max2DTextureSize ||
- static_cast<GLuint>(height) > caps.max2DTextureSize ||
- static_cast<GLuint>(depth) > caps.maxArrayTextureLayers)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
- }
- break;
-
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if (!texture || texture->id() == 0)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (texture->isImmutable())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
- if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions()))
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if (formatInfo.pixelBytes == 0)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- return true;
-}
-
-bool ValidateFramebufferTextureLayer(Context *context, GLenum target, GLenum attachment,
- GLuint texture, GLint level, GLint layer)
-{
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (layer < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (!ValidateFramebufferTextureBase(context, target, attachment, texture, level))
- {
- return false;
- }
-
- const gl::Caps &caps = context->getCaps();
- if (texture != 0)
- {
- gl::Texture *tex = context->getTexture(texture);
- ASSERT(tex);
-
- switch (tex->getTarget())
- {
- case GL_TEXTURE_2D_ARRAY:
- {
- if (level > gl::log2(caps.max2DTextureSize))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (static_cast<GLuint>(layer) >= caps.maxArrayTextureLayers)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- gl::Texture2DArray *texArray = static_cast<gl::Texture2DArray *>(tex);
- if (texArray->isCompressed(level))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
- break;
-
- case GL_TEXTURE_3D:
- {
- if (level > gl::log2(caps.max3DTextureSize))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (static_cast<GLuint>(layer) >= caps.max3DTextureSize)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- gl::Texture3D *tex3d = static_cast<gl::Texture3D *>(tex);
- if (tex3d->isCompressed(level))
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
- break;
-
- default:
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
-
- return true;
-}
-
-bool ValidES3ReadFormatType(Context *context, GLenum internalFormat, GLenum format, GLenum type)
-{
- const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat);
-
- switch (format)
- {
- case GL_RGBA:
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- break;
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- if (internalFormat != GL_RGB10_A2)
- {
- return false;
- }
- break;
- case GL_FLOAT:
- if (internalFormatInfo.componentType != GL_FLOAT)
- {
- return false;
- }
- break;
- default:
- return false;
- }
- break;
- case GL_RGBA_INTEGER:
- switch (type)
- {
- case GL_INT:
- if (internalFormatInfo.componentType != GL_INT)
- {
- return false;
- }
- break;
- case GL_UNSIGNED_INT:
- if (internalFormatInfo.componentType != GL_UNSIGNED_INT)
- {
- return false;
- }
- break;
- default:
- return false;
- }
- break;
- case GL_BGRA_EXT:
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
- break;
- default:
- return false;
- }
- break;
- case GL_RG_EXT:
- case GL_RED_EXT:
- if (!context->getExtensions().textureRG)
- {
- return false;
- }
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- break;
- default:
- return false;
- }
- break;
- default:
- return false;
- }
- return true;
-}
-
-bool ValidateInvalidateFramebufferParameters(Context *context, GLenum target, GLsizei numAttachments,
- const GLenum* attachments)
-{
- bool defaultFramebuffer = false;
-
- switch (target)
- {
- case GL_DRAW_FRAMEBUFFER:
- case GL_FRAMEBUFFER:
- defaultFramebuffer = context->getState().getDrawFramebuffer()->id() == 0;
- break;
- case GL_READ_FRAMEBUFFER:
- defaultFramebuffer = context->getState().getReadFramebuffer()->id() == 0;
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- for (int i = 0; i < numAttachments; ++i)
- {
- if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15)
- {
- if (defaultFramebuffer)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getCaps().maxColorAttachments)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
- }
- else
- {
- switch (attachments[i])
- {
- case GL_DEPTH_ATTACHMENT:
- case GL_STENCIL_ATTACHMENT:
- case GL_DEPTH_STENCIL_ATTACHMENT:
- if (defaultFramebuffer)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- case GL_COLOR:
- case GL_DEPTH:
- case GL_STENCIL:
- if (!defaultFramebuffer)
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return false;
- }
- }
- }
-
- return true;
-}
-
-bool ValidateClearBuffer(Context *context)
-{
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- const gl::Framebuffer *fbo = context->getState().getDrawFramebuffer();
- if (!fbo || fbo->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
- {
- context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
- return false;
- }
-
- return true;
-}
-
-bool ValidateGetUniformuiv(Context *context, GLuint program, GLint location, GLuint* params)
-{
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- return ValidateGetUniformBase(context, program, location);
-}
-
-}
diff --git a/src/3rdparty/angle/src/libGLESv2/validationES3.h b/src/3rdparty/angle/src/libGLESv2/validationES3.h
deleted file mode 100644
index cafacca601..0000000000
--- a/src/3rdparty/angle/src/libGLESv2/validationES3.h
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-// validationES3.h: Validation functions for OpenGL ES 3.0 entry point parameters
-
-#ifndef LIBGLESV2_VALIDATION_ES3_H
-#define LIBGLESV2_VALIDATION_ES3_H
-
-#include <GLES3/gl3.h>
-
-namespace gl
-{
-
-class Context;
-
-bool ValidateES3TexImageParameters(Context *context, GLenum target, GLint level, GLenum internalformat, bool isCompressed, bool isSubImage,
- GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
- GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-
-bool ValidateES3CopyTexImageParameters(Context *context, GLenum target, GLint level, GLenum internalformat,
- bool isSubImage, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y,
- GLsizei width, GLsizei height, GLint border);
-
-bool ValidateES3TexStorageParameters(Context *context, GLenum target, GLsizei levels, GLenum internalformat,
- GLsizei width, GLsizei height, GLsizei depth);
-
-bool ValidateFramebufferTextureLayer(Context *context, GLenum target, GLenum attachment,
- GLuint texture, GLint level, GLint layer);
-
-bool ValidES3ReadFormatType(Context *context, GLenum internalFormat, GLenum format, GLenum type);
-
-bool ValidateInvalidateFramebufferParameters(Context *context, GLenum target, GLsizei numAttachments,
- const GLenum* attachments);
-
-bool ValidateClearBuffer(Context *context);
-
-bool ValidateGetUniformuiv(Context *context, GLuint program, GLint location, GLuint* params);
-
-}
-
-#endif // LIBGLESV2_VALIDATION_ES3_H