diff --git a/gfx/angle/BUILD.gn b/gfx/angle/BUILD.gn deleted file mode 100644 index 9ffa2d435452..000000000000 --- a/gfx/angle/BUILD.gn +++ /dev/null @@ -1,638 +0,0 @@ -# Copyright 2014 The Chromium 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 config is applied to internal Angle targets (not pushed to dependents). -config("internal_config") { - include_dirs = [ - "include", - "src", - ] -} - -component("translator") { - sources = [ - "src/compiler/translator/ShaderLang.cpp", - ] - - defines = [ "ANGLE_TRANSLATOR_IMPLEMENTATION" ] - - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - ":internal_config", - "//build/config/compiler:no_chromium_code", - ] - - deps = [ - ":translator_lib", - ] -} - -# Holds the shared includes so we only need to list them once. -source_set("includes") { - sources = [ - "include/EGL/egl.h", - "include/EGL/eglext.h", - "include/EGL/eglplatform.h", - "include/GLES2/gl2.h", - "include/GLES2/gl2ext.h", - "include/GLES2/gl2platform.h", - "include/GLES3/gl3.h", - "include/GLES3/gl3ext.h", - "include/GLES3/gl3platform.h", - "include/GLSLANG/ShaderLang.h", - "include/KHR/khrplatform.h", - ] -} - -static_library("preprocessor") { - sources = [ - "src/compiler/preprocessor/DiagnosticsBase.cpp", - "src/compiler/preprocessor/DiagnosticsBase.h", - "src/compiler/preprocessor/DirectiveHandlerBase.cpp", - "src/compiler/preprocessor/DirectiveHandlerBase.h", - "src/compiler/preprocessor/DirectiveParser.cpp", - "src/compiler/preprocessor/DirectiveParser.h", - "src/compiler/preprocessor/ExpressionParser.cpp", - "src/compiler/preprocessor/ExpressionParser.h", - "src/compiler/preprocessor/ExpressionParser.y", - "src/compiler/preprocessor/Input.cpp", - "src/compiler/preprocessor/Input.h", - "src/compiler/preprocessor/Lexer.cpp", - "src/compiler/preprocessor/Lexer.h", - "src/compiler/preprocessor/Macro.cpp", - "src/compiler/preprocessor/Macro.h", - "src/compiler/preprocessor/MacroExpander.cpp", - "src/compiler/preprocessor/MacroExpander.h", - "src/compiler/preprocessor/Preprocessor.cpp", - "src/compiler/preprocessor/Preprocessor.h", - "src/compiler/preprocessor/SourceLocation.h", - "src/compiler/preprocessor/Token.cpp", - "src/compiler/preprocessor/Token.h", - "src/compiler/preprocessor/Tokenizer.cpp", - "src/compiler/preprocessor/Tokenizer.h", - "src/compiler/preprocessor/Tokenizer.l", - "src/compiler/preprocessor/numeric_lex.h", - "src/compiler/preprocessor/pp_utils.h", - ] - - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - ":internal_config", - "//build/config/compiler:no_chromium_code", - ] - -} - -static_library("translator_lib") { - sources = [ - "src/common/RefCountObject.cpp", - "src/common/RefCountObject.h", - "src/common/angleutils.h", - "src/common/blocklayout.cpp", - "src/common/blocklayout.h", - "src/common/debug.cpp", - "src/common/debug.h", - "src/common/event_tracer.cpp", - "src/common/event_tracer.h", - "src/common/mathutil.cpp", - "src/common/mathutil.h", - "src/common/platform.h", - "src/common/shadervars.h", - "src/common/tls.cpp", - "src/common/tls.h", - "src/common/utilities.cpp", - "src/common/utilities.h", - "src/common/version.h", - "src/compiler/translator/BaseTypes.h", - "src/compiler/translator/BuiltInFunctionEmulator.cpp", - "src/compiler/translator/BuiltInFunctionEmulator.h", - "src/compiler/translator/CodeGen.cpp", - "src/compiler/translator/Common.h", - "src/compiler/translator/Compiler.cpp", - "src/compiler/translator/ConstantUnion.h", - "src/compiler/translator/DetectCallDepth.cpp", - "src/compiler/translator/DetectCallDepth.h", - "src/compiler/translator/DetectDiscontinuity.cpp", - "src/compiler/translator/DetectDiscontinuity.h", - "src/compiler/translator/Diagnostics.cpp", - "src/compiler/translator/Diagnostics.h", - "src/compiler/translator/DirectiveHandler.cpp", - "src/compiler/translator/DirectiveHandler.h", - "src/compiler/translator/ExtensionBehavior.h", - "src/compiler/translator/FlagStd140Structs.cpp", - "src/compiler/translator/FlagStd140Structs.h", - "src/compiler/translator/ForLoopUnroll.cpp", - "src/compiler/translator/ForLoopUnroll.h", - "src/compiler/translator/HashNames.h", - "src/compiler/translator/InfoSink.cpp", - "src/compiler/translator/InfoSink.h", - "src/compiler/translator/Initialize.cpp", - "src/compiler/translator/Initialize.h", - "src/compiler/translator/InitializeDll.cpp", - "src/compiler/translator/InitializeDll.h", - "src/compiler/translator/InitializeGlobals.h", - "src/compiler/translator/InitializeParseContext.cpp", - "src/compiler/translator/InitializeParseContext.h", - "src/compiler/translator/InitializeVariables.cpp", - "src/compiler/translator/InitializeVariables.h", - "src/compiler/translator/IntermTraverse.cpp", - "src/compiler/translator/Intermediate.cpp", - "src/compiler/translator/LoopInfo.cpp", - "src/compiler/translator/LoopInfo.h", - "src/compiler/translator/MMap.h", - "src/compiler/translator/NodeSearch.h", - "src/compiler/translator/OutputESSL.cpp", - "src/compiler/translator/OutputESSL.h", - "src/compiler/translator/OutputGLSL.cpp", - "src/compiler/translator/OutputGLSL.h", - "src/compiler/translator/OutputGLSLBase.cpp", - "src/compiler/translator/OutputGLSLBase.h", - "src/compiler/translator/OutputHLSL.cpp", - "src/compiler/translator/OutputHLSL.h", - "src/compiler/translator/ParseContext.cpp", - "src/compiler/translator/ParseContext.h", - "src/compiler/translator/PoolAlloc.cpp", - "src/compiler/translator/PoolAlloc.h", - "src/compiler/translator/Pragma.h", - "src/compiler/translator/QualifierAlive.cpp", - "src/compiler/translator/QualifierAlive.h", - "src/compiler/translator/RemoveTree.cpp", - "src/compiler/translator/RemoveTree.h", - "src/compiler/translator/RenameFunction.h", - "src/compiler/translator/RewriteElseBlocks.cpp", - "src/compiler/translator/RewriteElseBlocks.h", - "src/compiler/translator/SearchSymbol.cpp", - "src/compiler/translator/SearchSymbol.h", - "src/compiler/translator/ShHandle.h", - "src/compiler/translator/StructureHLSL.cpp", - "src/compiler/translator/StructureHLSL.h", - "src/compiler/translator/SymbolTable.cpp", - "src/compiler/translator/SymbolTable.h", - "src/compiler/translator/TranslatorESSL.cpp", - "src/compiler/translator/TranslatorESSL.h", - "src/compiler/translator/TranslatorGLSL.cpp", - "src/compiler/translator/TranslatorGLSL.h", - "src/compiler/translator/TranslatorHLSL.cpp", - "src/compiler/translator/TranslatorHLSL.h", - "src/compiler/translator/Types.cpp", - "src/compiler/translator/Types.h", - "src/compiler/translator/UnfoldShortCircuit.cpp", - "src/compiler/translator/UnfoldShortCircuit.h", - "src/compiler/translator/UnfoldShortCircuitAST.cpp", - "src/compiler/translator/UnfoldShortCircuitAST.h", - "src/compiler/translator/UniformHLSL.cpp", - "src/compiler/translator/UniformHLSL.h", - "src/compiler/translator/UtilsHLSL.cpp", - "src/compiler/translator/UtilsHLSL.h", - "src/compiler/translator/ValidateLimitations.cpp", - "src/compiler/translator/ValidateLimitations.h", - "src/compiler/translator/ValidateOutputs.cpp", - "src/compiler/translator/ValidateOutputs.h", - "src/compiler/translator/VariableInfo.cpp", - "src/compiler/translator/VariableInfo.h", - "src/compiler/translator/VariablePacker.cpp", - "src/compiler/translator/VariablePacker.h", - "src/compiler/translator/VersionGLSL.cpp", - "src/compiler/translator/VersionGLSL.h", - "src/compiler/translator/compilerdebug.cpp", - "src/compiler/translator/compilerdebug.h", - "src/compiler/translator/depgraph/DependencyGraph.cpp", - "src/compiler/translator/depgraph/DependencyGraph.h", - "src/compiler/translator/depgraph/DependencyGraphBuilder.cpp", - "src/compiler/translator/depgraph/DependencyGraphBuilder.h", - "src/compiler/translator/depgraph/DependencyGraphOutput.cpp", - "src/compiler/translator/depgraph/DependencyGraphOutput.h", - "src/compiler/translator/depgraph/DependencyGraphTraverse.cpp", - "src/compiler/translator/glslang.h", - "src/compiler/translator/glslang.l", - "src/compiler/translator/glslang.y", - "src/compiler/translator/glslang_lex.cpp", - "src/compiler/translator/glslang_tab.cpp", - "src/compiler/translator/glslang_tab.h", - "src/compiler/translator/intermOut.cpp", - "src/compiler/translator/intermediate.h", - "src/compiler/translator/length_limits.h", - "src/compiler/translator/localintermediate.h", - "src/compiler/translator/parseConst.cpp", - "src/compiler/translator/timing/RestrictFragmentShaderTiming.cpp", - "src/compiler/translator/timing/RestrictFragmentShaderTiming.h", - "src/compiler/translator/timing/RestrictVertexShaderTiming.cpp", - "src/compiler/translator/timing/RestrictVertexShaderTiming.h", - "src/compiler/translator/util.cpp", - "src/compiler/translator/util.h", - "src/third_party/compiler/ArrayBoundsClamper.cpp", - "src/third_party/compiler/ArrayBoundsClamper.h", - ] - - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - ":internal_config", - "//build/config/compiler:no_chromium_code", - ] - - deps = [ - ":includes", - ":preprocessor", - ] -} - -config("translator_static_config") { - defines = [ "ANGLE_TRANSLATOR_STATIC" ] -} - -static_library("translator_static") { - sources = [ - "src/compiler/translator/ShaderLang.cpp", - ] - - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - ":internal_config", - "//build/config/compiler:no_chromium_code", - ] - direct_dependent_configs = [ ":translator_static_config" ] - - deps = [ - ":translator_lib", - ] -} - -config("commit_id_config") { - include_dirs = [ "$root_gen_dir/angle" ] -} - -action("commit_id") { - script = "src/commit_id.py" - - output_file = "$root_gen_dir/angle/id/commit.h" - outputs = [ output_file ] - - args = [ - "gen", - rebase_path(".", root_build_dir), - rebase_path(output_file, root_build_dir), - ] - - direct_dependent_configs = [ ":commit_id_config" ] -} - -if (is_win) { - angle_enable_d3d9 = true - angle_enable_d3d11 = true - - shared_library("libGLESv2") { - sources = [ - "src/common/RefCountObject.cpp", - "src/common/RefCountObject.h", - "src/common/angleutils.h", - "src/common/blocklayout.cpp", - "src/common/blocklayout.h", - "src/common/debug.cpp", - "src/common/debug.h", - "src/common/event_tracer.cpp", - "src/common/event_tracer.h", - "src/common/mathutil.cpp", - "src/common/mathutil.h", - "src/common/platform.h", - "src/common/shadervars.h", - "src/common/tls.cpp", - "src/common/tls.h", - "src/common/utilities.cpp", - "src/common/utilities.h", - "src/common/version.h", - "src/libGLESv2/BinaryStream.h", - "src/libGLESv2/Buffer.cpp", - "src/libGLESv2/Buffer.h", - "src/libGLESv2/Caps.cpp", - "src/libGLESv2/Caps.h", - "src/libGLESv2/Context.cpp", - "src/libGLESv2/Context.h", - "src/libGLESv2/DynamicHLSL.cpp", - "src/libGLESv2/DynamicHLSL.h", - "src/libGLESv2/Fence.cpp", - "src/libGLESv2/Fence.h", - "src/libGLESv2/Float16ToFloat32.cpp", - "src/libGLESv2/Framebuffer.cpp", - "src/libGLESv2/Framebuffer.h", - "src/libGLESv2/FramebufferAttachment.cpp", - "src/libGLESv2/FramebufferAttachment.h", - "src/libGLESv2/HandleAllocator.cpp", - "src/libGLESv2/HandleAllocator.h", - "src/libGLESv2/Program.cpp", - "src/libGLESv2/Program.h", - "src/libGLESv2/ProgramBinary.cpp", - "src/libGLESv2/ProgramBinary.h", - "src/libGLESv2/Query.cpp", - "src/libGLESv2/Query.h", - "src/libGLESv2/Renderbuffer.cpp", - "src/libGLESv2/Renderbuffer.h", - "src/libGLESv2/RenderbufferProxySet.cpp", - "src/libGLESv2/RenderbufferProxySet.h", - "src/libGLESv2/ResourceManager.cpp", - "src/libGLESv2/ResourceManager.h", - "src/libGLESv2/Sampler.cpp", - "src/libGLESv2/Sampler.h", - "src/libGLESv2/Shader.cpp", - "src/libGLESv2/Shader.h", - "src/libGLESv2/Texture.cpp", - "src/libGLESv2/Texture.h", - "src/libGLESv2/TransformFeedback.cpp", - "src/libGLESv2/TransformFeedback.h", - "src/libGLESv2/Uniform.cpp", - "src/libGLESv2/Uniform.h", - "src/libGLESv2/VertexArray.cpp", - "src/libGLESv2/VertexArray.h", - "src/libGLESv2/VertexAttribute.h", - "src/libGLESv2/VertexAttribute.cpp", - "src/libGLESv2/angletypes.cpp", - "src/libGLESv2/angletypes.h", - "src/libGLESv2/constants.h", - "src/libGLESv2/formatutils.cpp", - "src/libGLESv2/formatutils.h", - "src/libGLESv2/libGLESv2.cpp", - "src/libGLESv2/libGLESv2.def", - "src/libGLESv2/libGLESv2.rc", - "src/libGLESv2/main.cpp", - "src/libGLESv2/main.h", - "src/libGLESv2/precompiled.cpp", - "src/libGLESv2/precompiled.h", - "src/libGLESv2/queryconversions.cpp", - "src/libGLESv2/queryconversions.h", - "src/libGLESv2/renderer/BufferStorage.cpp", - "src/libGLESv2/renderer/BufferStorage.h", - "src/libGLESv2/renderer/FenceImpl.h", - "src/libGLESv2/renderer/Image.cpp", - "src/libGLESv2/renderer/Image.h", - "src/libGLESv2/renderer/IndexBuffer.cpp", - "src/libGLESv2/renderer/IndexBuffer.h", - "src/libGLESv2/renderer/IndexDataManager.cpp", - "src/libGLESv2/renderer/IndexDataManager.h", - "src/libGLESv2/renderer/IndexRangeCache.cpp", - "src/libGLESv2/renderer/IndexRangeCache.h", - "src/libGLESv2/renderer/QueryImpl.h", - "src/libGLESv2/renderer/RenderTarget.h", - "src/libGLESv2/renderer/Renderer.cpp", - "src/libGLESv2/renderer/Renderer.h", - "src/libGLESv2/renderer/ShaderExecutable.h", - "src/libGLESv2/renderer/SwapChain.h", - "src/libGLESv2/renderer/TextureStorage.cpp", - "src/libGLESv2/renderer/TextureStorage.h", - "src/libGLESv2/renderer/VertexArrayImpl.h", - "src/libGLESv2/renderer/VertexBuffer.cpp", - "src/libGLESv2/renderer/VertexBuffer.h", - "src/libGLESv2/renderer/VertexDataManager.cpp", - "src/libGLESv2/renderer/VertexDataManager.h", - "src/libGLESv2/renderer/copyimage.cpp", - "src/libGLESv2/renderer/copyimage.h", - "src/libGLESv2/renderer/copyvertex.h", - "src/libGLESv2/renderer/generatemip.h", - "src/libGLESv2/renderer/imageformats.h", - "src/libGLESv2/renderer/loadimage.cpp", - "src/libGLESv2/renderer/loadimage.h", - "src/libGLESv2/renderer/loadimageSSE2.cpp", - "src/libGLESv2/renderer/vertexconversion.h", - "src/libGLESv2/resource.h", - "src/libGLESv2/validationES.cpp", - "src/libGLESv2/validationES.h", - "src/libGLESv2/validationES2.cpp", - "src/libGLESv2/validationES2.h", - "src/libGLESv2/validationES3.cpp", - "src/libGLESv2/validationES3.h", - "src/third_party/murmurhash/MurmurHash3.cpp", - "src/third_party/murmurhash/MurmurHash3.h", - "src/third_party/systeminfo/SystemInfo.cpp", - "src/third_party/systeminfo/SystemInfo.h", - ] - - defines = [ - "ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ " + - "TEXT(\"d3dcompiler_46.dll\"), TEXT(\"d3dcompiler_43.dll\") }", - "GL_APICALL=", - "GL_GLEXT_PROTOTYPES=", - "EGLAPI=", - ] - libs = [] - - # Shared D3dD sources. - if (angle_enable_d3d9 || angle_enable_d3d11) { - sources += [ - "src/libGLESv2/renderer/d3d/HLSLCompiler.cpp", - "src/libGLESv2/renderer/d3d/HLSLCompiler.h", - ] - } - - if (angle_enable_d3d9) { - sources += [ - "src/libGLESv2/renderer/d3d9/Blit9.cpp", - "src/libGLESv2/renderer/d3d9/Blit9.h", - "src/libGLESv2/renderer/d3d9/BufferStorage9.cpp", - "src/libGLESv2/renderer/d3d9/BufferStorage9.h", - "src/libGLESv2/renderer/d3d9/Fence9.cpp", - "src/libGLESv2/renderer/d3d9/Fence9.h", - "src/libGLESv2/renderer/d3d9/Image9.cpp", - "src/libGLESv2/renderer/d3d9/Image9.h", - "src/libGLESv2/renderer/d3d9/IndexBuffer9.cpp", - "src/libGLESv2/renderer/d3d9/IndexBuffer9.h", - "src/libGLESv2/renderer/d3d9/Query9.cpp", - "src/libGLESv2/renderer/d3d9/Query9.h", - "src/libGLESv2/renderer/d3d9/RenderTarget9.cpp", - "src/libGLESv2/renderer/d3d9/RenderTarget9.h", - "src/libGLESv2/renderer/d3d9/Renderer9.cpp", - "src/libGLESv2/renderer/d3d9/Renderer9.h", - "src/libGLESv2/renderer/d3d9/ShaderCache.h", - "src/libGLESv2/renderer/d3d9/ShaderExecutable9.cpp", - "src/libGLESv2/renderer/d3d9/ShaderExecutable9.h", - "src/libGLESv2/renderer/d3d9/SwapChain9.cpp", - "src/libGLESv2/renderer/d3d9/SwapChain9.h", - "src/libGLESv2/renderer/d3d9/TextureStorage9.cpp", - "src/libGLESv2/renderer/d3d9/TextureStorage9.h", - "src/libGLESv2/renderer/d3d9/VertexArray9.h", - "src/libGLESv2/renderer/d3d9/VertexBuffer9.cpp", - "src/libGLESv2/renderer/d3d9/VertexBuffer9.h", - "src/libGLESv2/renderer/d3d9/VertexDeclarationCache.cpp", - "src/libGLESv2/renderer/d3d9/VertexDeclarationCache.h", - "src/libGLESv2/renderer/d3d9/formatutils9.cpp", - "src/libGLESv2/renderer/d3d9/formatutils9.h", - "src/libGLESv2/renderer/d3d9/renderer9_utils.cpp", - "src/libGLESv2/renderer/d3d9/renderer9_utils.h", - "src/libGLESv2/renderer/d3d9/shaders/compiled/componentmaskps.h", - "src/libGLESv2/renderer/d3d9/shaders/compiled/flipyvs.h", - "src/libGLESv2/renderer/d3d9/shaders/compiled/luminanceps.h", - "src/libGLESv2/renderer/d3d9/shaders/compiled/passthroughps.h", - "src/libGLESv2/renderer/d3d9/shaders/compiled/standardvs.h", - ] - - defines += [ "ANGLE_ENABLE_D3D9" ] - libs += [ "d3d9.lib" ] - } - - if (angle_enable_d3d11) { - sources += [ - "src/libGLESv2/renderer/d3d11/Blit11.cpp", - "src/libGLESv2/renderer/d3d11/Blit11.h", - "src/libGLESv2/renderer/d3d11/BufferStorage11.cpp", - "src/libGLESv2/renderer/d3d11/BufferStorage11.h", - "src/libGLESv2/renderer/d3d11/Clear11.cpp", - "src/libGLESv2/renderer/d3d11/Clear11.h", - "src/libGLESv2/renderer/d3d11/Fence11.cpp", - "src/libGLESv2/renderer/d3d11/Fence11.h", - "src/libGLESv2/renderer/d3d11/Image11.cpp", - "src/libGLESv2/renderer/d3d11/Image11.h", - "src/libGLESv2/renderer/d3d11/IndexBuffer11.cpp", - "src/libGLESv2/renderer/d3d11/IndexBuffer11.h", - "src/libGLESv2/renderer/d3d11/InputLayoutCache.cpp", - "src/libGLESv2/renderer/d3d11/InputLayoutCache.h", - "src/libGLESv2/renderer/d3d11/PixelTransfer11.cpp", - "src/libGLESv2/renderer/d3d11/PixelTransfer11.h", - "src/libGLESv2/renderer/d3d11/Query11.cpp", - "src/libGLESv2/renderer/d3d11/Query11.h", - "src/libGLESv2/renderer/d3d11/RenderStateCache.cpp", - "src/libGLESv2/renderer/d3d11/RenderStateCache.h", - "src/libGLESv2/renderer/d3d11/RenderTarget11.cpp", - "src/libGLESv2/renderer/d3d11/RenderTarget11.h", - "src/libGLESv2/renderer/d3d11/Renderer11.cpp", - "src/libGLESv2/renderer/d3d11/Renderer11.h", - "src/libGLESv2/renderer/d3d11/ShaderExecutable11.cpp", - "src/libGLESv2/renderer/d3d11/ShaderExecutable11.h", - "src/libGLESv2/renderer/d3d11/SwapChain11.cpp", - "src/libGLESv2/renderer/d3d11/SwapChain11.h", - "src/libGLESv2/renderer/d3d11/TextureStorage11.cpp", - "src/libGLESv2/renderer/d3d11/TextureStorage11.h", - "src/libGLESv2/renderer/d3d11/VertexArray11.h", - "src/libGLESv2/renderer/d3d11/VertexBuffer11.cpp", - "src/libGLESv2/renderer/d3d11/VertexBuffer11.h", - "src/libGLESv2/renderer/d3d11/formatutils11.cpp", - "src/libGLESv2/renderer/d3d11/formatutils11.h", - "src/libGLESv2/renderer/d3d11/renderer11_utils.cpp", - "src/libGLESv2/renderer/d3d11/renderer11_utils.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_gs.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4f.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4i.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4ui.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_vs.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/clearfloat11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/clearfloat11vs.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/clearsint11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/clearsint11vs.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/clearuint11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/clearuint11vs.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough2d11vs.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough3d11gs.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough3d11vs.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughdepth2d11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum2d11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum3d11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha2d11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha3d11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2d11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2di11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2dui11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3d11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3di11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3dui11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2d11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2di11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2dui11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3d11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3di11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3dui11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2d11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2di11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2dui11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3d11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3di11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3dui11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2d11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2di11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2dui11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3d11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3di11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3dui11ps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlef2darrayps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlef2dps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlef3dps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlei2darrayps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlei2dps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlei3dps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/swizzleui2darrayps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/swizzleui2dps.h", - "src/libGLESv2/renderer/d3d11/shaders/compiled/swizzleui3dps.h", - ] - - defines += [ "ANGLE_ENABLE_D3D11" ] - libs += [ "dxguid.lib" ] - } - - if (is_debug) { - defines += [ "ANGLE_ENABLE_PERF" ] - libs += [ "d3d9.lib" ] - } - - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - ":internal_config", - "//build/config/compiler:no_chromium_code", - ] - - include_dirs = [ "src/libGLESv2" ] - - deps = [ - ":commit_id", - ":includes", - ":translator", - #":copy_compiler_dll", TODO(GYP) - ] - } - - shared_library("libEGL") { - sources = [ - "src/common/RefCountObject.cpp", - "src/common/RefCountObject.h", - "src/common/angleutils.h", - "src/common/blocklayout.cpp", - "src/common/blocklayout.h", - "src/common/debug.cpp", - "src/common/debug.h", - "src/common/event_tracer.cpp", - "src/common/event_tracer.h", - "src/common/mathutil.cpp", - "src/common/mathutil.h", - "src/common/shadervars.h", - "src/common/utilities.cpp", - "src/common/utilities.h", - "src/common/version.h", - "src/libEGL/Config.cpp", - "src/libEGL/Config.h", - "src/libEGL/Display.cpp", - "src/libEGL/Display.h", - "src/libEGL/Surface.cpp", - "src/libEGL/Surface.h", - "src/libEGL/libEGL.cpp", - "src/libEGL/libEGL.def", - "src/libEGL/libEGL.rc", - "src/libEGL/main.cpp", - "src/libEGL/main.h", - "src/libEGL/resource.h", - ] - - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - ":internal_config", - "//build/config/compiler:no_chromium_code", - ] - - if (is_debug) { - defines = [ "ANGLE_ENABLE_PERF" ] - } - - include_dirs = [ "src/libGLESv2" ] - libs = [ "d3d9.lib" ] - - deps = [ - ":commit_id", - ":includes", - ":libGLESv2", - ] - } -} # is_win diff --git a/gfx/angle/README.mozilla b/gfx/angle/README.mozilla index d321c08c3b67..816c8603dd60 100644 --- a/gfx/angle/README.mozilla +++ b/gfx/angle/README.mozilla @@ -17,11 +17,8 @@ includes Mozilla-specific patches on top of upstream. git checkout mozilla 5. Rebase the mozilla branch on top of the new google master. Fix up patches along the way, - remove unneded commits. Google seems to have "chromium/2059" branches as well, that I - assume are merges into the Chromium tree. These might be a good point to rebase on - as well, instead of google/master: + remove unneded commits. git rebase -i google/master - or git rebase -i google/chromium/2081 (whatever the latest is in 'git branch -a') 6. Re-generate moz.build files: ./gyp_mozbuild @@ -36,13 +33,3 @@ includes Mozilla-specific patches on top of upstream. 9. Build. Fix things until it builds. 10. Try runs and reviews! - -11. Once reviews are done and checkin is ready, tag the equivalent git repo: - git tag -a mozilla-bug-123456 -m "ANGLE update for bug 123456" - -12. Push the new mozilla branch, along with the tags upstream: - git push --tags mozilla +mozilla - -The "mozilla" branch head will keep moving, since it will keep getting rebased. -The tags will point to the topmost commit that was used for a particular bug number, -so that we can see its history if needed. diff --git a/gfx/angle/include/EGL/egl.h b/gfx/angle/include/EGL/egl.h index 12590a0e2032..b55e6c640d8d 100644 --- a/gfx/angle/include/EGL/egl.h +++ b/gfx/angle/include/EGL/egl.h @@ -1,12 +1,11 @@ -#ifndef __egl_h_ -#define __egl_h_ 1 - -#ifdef __cplusplus -extern "C" { -#endif +/* -*- mode: c; tab-width: 8; -*- */ +/* vi: set sw=4 ts=8: */ +/* Reference version of egl.h for EGL 1.4. + * $Revision: 9356 $ on $Date: 2009-10-21 05:52:25 -0400 (Wed, 21 Oct 2009) $ + */ /* -** Copyright (c) 2013-2014 The Khronos Group Inc. +** Copyright (c) 2007-2009 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -27,272 +26,304 @@ extern "C" { ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -/* -** This header is generated from the Khronos OpenGL / OpenGL ES XML -** API Registry. The current version of the Registry, generator scripts -** used to make the header, and the header can be found at -** http://www.opengl.org/registry/ -** -** Khronos $Revision: 27018 $ on $Date: 2014-06-10 08:06:12 -0700 (Tue, 10 Jun 2014) $ -*/ +#ifndef __egl_h_ +#define __egl_h_ + +/* All platform-dependent types and macro boilerplate (such as EGLAPI + * and EGLAPIENTRY) should go in eglplatform.h. + */ #include -/* Generated on date 20140610 */ +#ifdef __cplusplus +extern "C" { +#endif -/* Generated C header for: - * API: egl - * Versions considered: .* - * Versions emitted: .* - * Default extensions included: None - * Additional extensions included: _nomatch_^ - * Extensions removed: _nomatch_^ +/* EGL Types */ +/* EGLint is defined in eglplatform.h */ +typedef unsigned int EGLBoolean; +typedef unsigned int EGLenum; +typedef void *EGLConfig; +typedef void *EGLContext; +typedef void *EGLDisplay; +typedef void *EGLSurface; +typedef void *EGLClientBuffer; + +/* EGL Versioning */ +#define EGL_VERSION_1_0 1 +#define EGL_VERSION_1_1 1 +#define EGL_VERSION_1_2 1 +#define EGL_VERSION_1_3 1 +#define EGL_VERSION_1_4 1 + +/* EGL Enumerants. Bitmasks and other exceptional cases aside, most + * enums are assigned unique values starting at 0x3000. */ -#ifndef EGL_VERSION_1_0 -#define EGL_VERSION_1_0 1 -typedef unsigned int EGLBoolean; -typedef void *EGLDisplay; -#include -#include -typedef void *EGLConfig; -typedef void *EGLSurface; -typedef void *EGLContext; +/* EGL aliases */ +#define EGL_FALSE 0 +#define EGL_TRUE 1 + +/* Out-of-band handle values */ +#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) +#define EGL_NO_CONTEXT ((EGLContext)0) +#define EGL_NO_DISPLAY ((EGLDisplay)0) +#define EGL_NO_SURFACE ((EGLSurface)0) + +/* Out-of-band attribute value */ +#define EGL_DONT_CARE ((EGLint)-1) + +/* Errors / GetError return values */ +#define EGL_SUCCESS 0x3000 +#define EGL_NOT_INITIALIZED 0x3001 +#define EGL_BAD_ACCESS 0x3002 +#define EGL_BAD_ALLOC 0x3003 +#define EGL_BAD_ATTRIBUTE 0x3004 +#define EGL_BAD_CONFIG 0x3005 +#define EGL_BAD_CONTEXT 0x3006 +#define EGL_BAD_CURRENT_SURFACE 0x3007 +#define EGL_BAD_DISPLAY 0x3008 +#define EGL_BAD_MATCH 0x3009 +#define EGL_BAD_NATIVE_PIXMAP 0x300A +#define EGL_BAD_NATIVE_WINDOW 0x300B +#define EGL_BAD_PARAMETER 0x300C +#define EGL_BAD_SURFACE 0x300D +#define EGL_CONTEXT_LOST 0x300E /* EGL 1.1 - IMG_power_management */ + +/* Reserved 0x300F-0x301F for additional errors */ + +/* Config attributes */ +#define EGL_BUFFER_SIZE 0x3020 +#define EGL_ALPHA_SIZE 0x3021 +#define EGL_BLUE_SIZE 0x3022 +#define EGL_GREEN_SIZE 0x3023 +#define EGL_RED_SIZE 0x3024 +#define EGL_DEPTH_SIZE 0x3025 +#define EGL_STENCIL_SIZE 0x3026 +#define EGL_CONFIG_CAVEAT 0x3027 +#define EGL_CONFIG_ID 0x3028 +#define EGL_LEVEL 0x3029 +#define EGL_MAX_PBUFFER_HEIGHT 0x302A +#define EGL_MAX_PBUFFER_PIXELS 0x302B +#define EGL_MAX_PBUFFER_WIDTH 0x302C +#define EGL_NATIVE_RENDERABLE 0x302D +#define EGL_NATIVE_VISUAL_ID 0x302E +#define EGL_NATIVE_VISUAL_TYPE 0x302F +#define EGL_SAMPLES 0x3031 +#define EGL_SAMPLE_BUFFERS 0x3032 +#define EGL_SURFACE_TYPE 0x3033 +#define EGL_TRANSPARENT_TYPE 0x3034 +#define EGL_TRANSPARENT_BLUE_VALUE 0x3035 +#define EGL_TRANSPARENT_GREEN_VALUE 0x3036 +#define EGL_TRANSPARENT_RED_VALUE 0x3037 +#define EGL_NONE 0x3038 /* Attrib list terminator */ +#define EGL_BIND_TO_TEXTURE_RGB 0x3039 +#define EGL_BIND_TO_TEXTURE_RGBA 0x303A +#define EGL_MIN_SWAP_INTERVAL 0x303B +#define EGL_MAX_SWAP_INTERVAL 0x303C +#define EGL_LUMINANCE_SIZE 0x303D +#define EGL_ALPHA_MASK_SIZE 0x303E +#define EGL_COLOR_BUFFER_TYPE 0x303F +#define EGL_RENDERABLE_TYPE 0x3040 +#define EGL_MATCH_NATIVE_PIXMAP 0x3041 /* Pseudo-attribute (not queryable) */ +#define EGL_CONFORMANT 0x3042 + +/* Reserved 0x3041-0x304F for additional config attributes */ + +/* Config attribute values */ +#define EGL_SLOW_CONFIG 0x3050 /* EGL_CONFIG_CAVEAT value */ +#define EGL_NON_CONFORMANT_CONFIG 0x3051 /* EGL_CONFIG_CAVEAT value */ +#define EGL_TRANSPARENT_RGB 0x3052 /* EGL_TRANSPARENT_TYPE value */ +#define EGL_RGB_BUFFER 0x308E /* EGL_COLOR_BUFFER_TYPE value */ +#define EGL_LUMINANCE_BUFFER 0x308F /* EGL_COLOR_BUFFER_TYPE value */ + +/* More config attribute values, for EGL_TEXTURE_FORMAT */ +#define EGL_NO_TEXTURE 0x305C +#define EGL_TEXTURE_RGB 0x305D +#define EGL_TEXTURE_RGBA 0x305E +#define EGL_TEXTURE_2D 0x305F + +/* Config attribute mask bits */ +#define EGL_PBUFFER_BIT 0x0001 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_PIXMAP_BIT 0x0002 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_WINDOW_BIT 0x0004 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 /* EGL_SURFACE_TYPE mask bits */ + +#define EGL_OPENGL_ES_BIT 0x0001 /* EGL_RENDERABLE_TYPE mask bits */ +#define EGL_OPENVG_BIT 0x0002 /* EGL_RENDERABLE_TYPE mask bits */ +#define EGL_OPENGL_ES2_BIT 0x0004 /* EGL_RENDERABLE_TYPE mask bits */ +#define EGL_OPENGL_BIT 0x0008 /* EGL_RENDERABLE_TYPE mask bits */ + +/* QueryString targets */ +#define EGL_VENDOR 0x3053 +#define EGL_VERSION 0x3054 +#define EGL_EXTENSIONS 0x3055 +#define EGL_CLIENT_APIS 0x308D + +/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */ +#define EGL_HEIGHT 0x3056 +#define EGL_WIDTH 0x3057 +#define EGL_LARGEST_PBUFFER 0x3058 +#define EGL_TEXTURE_FORMAT 0x3080 +#define EGL_TEXTURE_TARGET 0x3081 +#define EGL_MIPMAP_TEXTURE 0x3082 +#define EGL_MIPMAP_LEVEL 0x3083 +#define EGL_RENDER_BUFFER 0x3086 +#define EGL_VG_COLORSPACE 0x3087 +#define EGL_VG_ALPHA_FORMAT 0x3088 +#define EGL_HORIZONTAL_RESOLUTION 0x3090 +#define EGL_VERTICAL_RESOLUTION 0x3091 +#define EGL_PIXEL_ASPECT_RATIO 0x3092 +#define EGL_SWAP_BEHAVIOR 0x3093 +#define EGL_MULTISAMPLE_RESOLVE 0x3099 + +/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */ +#define EGL_BACK_BUFFER 0x3084 +#define EGL_SINGLE_BUFFER 0x3085 + +/* OpenVG color spaces */ +#define EGL_VG_COLORSPACE_sRGB 0x3089 /* EGL_VG_COLORSPACE value */ +#define EGL_VG_COLORSPACE_LINEAR 0x308A /* EGL_VG_COLORSPACE value */ + +/* OpenVG alpha formats */ +#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B /* EGL_ALPHA_FORMAT value */ +#define EGL_VG_ALPHA_FORMAT_PRE 0x308C /* EGL_ALPHA_FORMAT value */ + +/* Constant scale factor by which fractional display resolutions & + * aspect ratio are scaled when queried as integer values. + */ +#define EGL_DISPLAY_SCALING 10000 + +/* Unknown display resolution/aspect ratio */ +#define EGL_UNKNOWN ((EGLint)-1) + +/* Back buffer swap behaviors */ +#define EGL_BUFFER_PRESERVED 0x3094 /* EGL_SWAP_BEHAVIOR value */ +#define EGL_BUFFER_DESTROYED 0x3095 /* EGL_SWAP_BEHAVIOR value */ + +/* CreatePbufferFromClientBuffer buffer types */ +#define EGL_OPENVG_IMAGE 0x3096 + +/* QueryContext targets */ +#define EGL_CONTEXT_CLIENT_TYPE 0x3097 + +/* CreateContext attributes */ +#define EGL_CONTEXT_CLIENT_VERSION 0x3098 + +/* Multisample resolution behaviors */ +#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A /* EGL_MULTISAMPLE_RESOLVE value */ +#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B /* EGL_MULTISAMPLE_RESOLVE value */ + +/* BindAPI/QueryAPI targets */ +#define EGL_OPENGL_ES_API 0x30A0 +#define EGL_OPENVG_API 0x30A1 +#define EGL_OPENGL_API 0x30A2 + +/* GetCurrentSurface targets */ +#define EGL_DRAW 0x3059 +#define EGL_READ 0x305A + +/* WaitNative engines */ +#define EGL_CORE_NATIVE_ENGINE 0x305B + +/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */ +#define EGL_COLORSPACE EGL_VG_COLORSPACE +#define EGL_ALPHA_FORMAT EGL_VG_ALPHA_FORMAT +#define EGL_COLORSPACE_sRGB EGL_VG_COLORSPACE_sRGB +#define EGL_COLORSPACE_LINEAR EGL_VG_COLORSPACE_LINEAR +#define EGL_ALPHA_FORMAT_NONPRE EGL_VG_ALPHA_FORMAT_NONPRE +#define EGL_ALPHA_FORMAT_PRE EGL_VG_ALPHA_FORMAT_PRE + +/* EGL extensions must request enum blocks from the Khronos + * API Registrar, who maintains the enumerant registry. Submit + * a bug in Khronos Bugzilla against task "Registry". + */ + + + +/* EGL Functions */ + +EGLAPI EGLint EGLAPIENTRY eglGetError(void); + +EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id); +EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor); +EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy); + +EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name); + +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, + EGLint config_size, EGLint *num_config); +EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, + EGLConfig *configs, EGLint config_size, + EGLint *num_config); +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, + EGLint attribute, EGLint *value); + +EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, + EGLNativeWindowType win, + const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, + const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, + EGLNativePixmapType pixmap, + const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface); +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface, + EGLint attribute, EGLint *value); + +EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api); +EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void); + +EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void); + +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void); + +EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer( + EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, + EGLConfig config, const EGLint *attrib_list); + +EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, + EGLint attribute, EGLint value); +EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); + + +EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval); + + +EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, + EGLContext share_context, + const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx); +EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, + EGLSurface read, EGLContext ctx); + +EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void); +EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw); +EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx, + EGLint attribute, EGLint *value); + +EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine); +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface); +EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, + EGLNativePixmapType target); + +/* This is a generic function pointer type, whose name indicates it must + * be cast to the proper type *and calling convention* before use. + */ typedef void (*__eglMustCastToProperFunctionPointerType)(void); -#define EGL_ALPHA_SIZE 0x3021 -#define EGL_BAD_ACCESS 0x3002 -#define EGL_BAD_ALLOC 0x3003 -#define EGL_BAD_ATTRIBUTE 0x3004 -#define EGL_BAD_CONFIG 0x3005 -#define EGL_BAD_CONTEXT 0x3006 -#define EGL_BAD_CURRENT_SURFACE 0x3007 -#define EGL_BAD_DISPLAY 0x3008 -#define EGL_BAD_MATCH 0x3009 -#define EGL_BAD_NATIVE_PIXMAP 0x300A -#define EGL_BAD_NATIVE_WINDOW 0x300B -#define EGL_BAD_PARAMETER 0x300C -#define EGL_BAD_SURFACE 0x300D -#define EGL_BLUE_SIZE 0x3022 -#define EGL_BUFFER_SIZE 0x3020 -#define EGL_CONFIG_CAVEAT 0x3027 -#define EGL_CONFIG_ID 0x3028 -#define EGL_CORE_NATIVE_ENGINE 0x305B -#define EGL_DEPTH_SIZE 0x3025 -#define EGL_DONT_CARE ((EGLint)-1) -#define EGL_DRAW 0x3059 -#define EGL_EXTENSIONS 0x3055 -#define EGL_FALSE 0 -#define EGL_GREEN_SIZE 0x3023 -#define EGL_HEIGHT 0x3056 -#define EGL_LARGEST_PBUFFER 0x3058 -#define EGL_LEVEL 0x3029 -#define EGL_MAX_PBUFFER_HEIGHT 0x302A -#define EGL_MAX_PBUFFER_PIXELS 0x302B -#define EGL_MAX_PBUFFER_WIDTH 0x302C -#define EGL_NATIVE_RENDERABLE 0x302D -#define EGL_NATIVE_VISUAL_ID 0x302E -#define EGL_NATIVE_VISUAL_TYPE 0x302F -#define EGL_NONE 0x3038 -#define EGL_NON_CONFORMANT_CONFIG 0x3051 -#define EGL_NOT_INITIALIZED 0x3001 -#define EGL_NO_CONTEXT ((EGLContext)0) -#define EGL_NO_DISPLAY ((EGLDisplay)0) -#define EGL_NO_SURFACE ((EGLSurface)0) -#define EGL_PBUFFER_BIT 0x0001 -#define EGL_PIXMAP_BIT 0x0002 -#define EGL_READ 0x305A -#define EGL_RED_SIZE 0x3024 -#define EGL_SAMPLES 0x3031 -#define EGL_SAMPLE_BUFFERS 0x3032 -#define EGL_SLOW_CONFIG 0x3050 -#define EGL_STENCIL_SIZE 0x3026 -#define EGL_SUCCESS 0x3000 -#define EGL_SURFACE_TYPE 0x3033 -#define EGL_TRANSPARENT_BLUE_VALUE 0x3035 -#define EGL_TRANSPARENT_GREEN_VALUE 0x3036 -#define EGL_TRANSPARENT_RED_VALUE 0x3037 -#define EGL_TRANSPARENT_RGB 0x3052 -#define EGL_TRANSPARENT_TYPE 0x3034 -#define EGL_TRUE 1 -#define EGL_VENDOR 0x3053 -#define EGL_VERSION 0x3054 -#define EGL_WIDTH 0x3057 -#define EGL_WINDOW_BIT 0x0004 -EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); -EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); -EGLAPI EGLContext EGLAPIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface); -EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); -EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); -EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay (void); -EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface (EGLint readdraw); -EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay (EGLNativeDisplayType display_id); -EGLAPI EGLint EGLAPIENTRY eglGetError (void); -EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname); -EGLAPI EGLBoolean EGLAPIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor); -EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); -EGLAPI const char *EGLAPIENTRY eglQueryString (EGLDisplay dpy, EGLint name); -EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface surface); -EGLAPI EGLBoolean EGLAPIENTRY eglTerminate (EGLDisplay dpy); -EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL (void); -EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine); -#endif /* EGL_VERSION_1_0 */ -#ifndef EGL_VERSION_1_1 -#define EGL_VERSION_1_1 1 -#define EGL_BACK_BUFFER 0x3084 -#define EGL_BIND_TO_TEXTURE_RGB 0x3039 -#define EGL_BIND_TO_TEXTURE_RGBA 0x303A -#define EGL_CONTEXT_LOST 0x300E -#define EGL_MIN_SWAP_INTERVAL 0x303B -#define EGL_MAX_SWAP_INTERVAL 0x303C -#define EGL_MIPMAP_TEXTURE 0x3082 -#define EGL_MIPMAP_LEVEL 0x3083 -#define EGL_NO_TEXTURE 0x305C -#define EGL_TEXTURE_2D 0x305F -#define EGL_TEXTURE_FORMAT 0x3080 -#define EGL_TEXTURE_RGB 0x305D -#define EGL_TEXTURE_RGBA 0x305E -#define EGL_TEXTURE_TARGET 0x3081 -EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); -EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); -EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); -EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval (EGLDisplay dpy, EGLint interval); -#endif /* EGL_VERSION_1_1 */ - -#ifndef EGL_VERSION_1_2 -#define EGL_VERSION_1_2 1 -typedef unsigned int EGLenum; -typedef void *EGLClientBuffer; -#define EGL_ALPHA_FORMAT 0x3088 -#define EGL_ALPHA_FORMAT_NONPRE 0x308B -#define EGL_ALPHA_FORMAT_PRE 0x308C -#define EGL_ALPHA_MASK_SIZE 0x303E -#define EGL_BUFFER_PRESERVED 0x3094 -#define EGL_BUFFER_DESTROYED 0x3095 -#define EGL_CLIENT_APIS 0x308D -#define EGL_COLORSPACE 0x3087 -#define EGL_COLORSPACE_sRGB 0x3089 -#define EGL_COLORSPACE_LINEAR 0x308A -#define EGL_COLOR_BUFFER_TYPE 0x303F -#define EGL_CONTEXT_CLIENT_TYPE 0x3097 -#define EGL_DISPLAY_SCALING 10000 -#define EGL_HORIZONTAL_RESOLUTION 0x3090 -#define EGL_LUMINANCE_BUFFER 0x308F -#define EGL_LUMINANCE_SIZE 0x303D -#define EGL_OPENGL_ES_BIT 0x0001 -#define EGL_OPENVG_BIT 0x0002 -#define EGL_OPENGL_ES_API 0x30A0 -#define EGL_OPENVG_API 0x30A1 -#define EGL_OPENVG_IMAGE 0x3096 -#define EGL_PIXEL_ASPECT_RATIO 0x3092 -#define EGL_RENDERABLE_TYPE 0x3040 -#define EGL_RENDER_BUFFER 0x3086 -#define EGL_RGB_BUFFER 0x308E -#define EGL_SINGLE_BUFFER 0x3085 -#define EGL_SWAP_BEHAVIOR 0x3093 -#define EGL_UNKNOWN ((EGLint)-1) -#define EGL_VERTICAL_RESOLUTION 0x3091 -EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI (EGLenum api); -EGLAPI EGLenum EGLAPIENTRY eglQueryAPI (void); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread (void); -EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void); -#endif /* EGL_VERSION_1_2 */ - -#ifndef EGL_VERSION_1_3 -#define EGL_VERSION_1_3 1 -#define EGL_CONFORMANT 0x3042 -#define EGL_CONTEXT_CLIENT_VERSION 0x3098 -#define EGL_MATCH_NATIVE_PIXMAP 0x3041 -#define EGL_OPENGL_ES2_BIT 0x0004 -#define EGL_VG_ALPHA_FORMAT 0x3088 -#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B -#define EGL_VG_ALPHA_FORMAT_PRE 0x308C -#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 -#define EGL_VG_COLORSPACE 0x3087 -#define EGL_VG_COLORSPACE_sRGB 0x3089 -#define EGL_VG_COLORSPACE_LINEAR 0x308A -#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 -#endif /* EGL_VERSION_1_3 */ - -#ifndef EGL_VERSION_1_4 -#define EGL_VERSION_1_4 1 -#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) -#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 -#define EGL_MULTISAMPLE_RESOLVE 0x3099 -#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A -#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B -#define EGL_OPENGL_API 0x30A2 -#define EGL_OPENGL_BIT 0x0008 -#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 -EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext (void); -#endif /* EGL_VERSION_1_4 */ - -#ifndef EGL_VERSION_1_5 -#define EGL_VERSION_1_5 1 -typedef void *EGLSync; -typedef intptr_t EGLAttrib; -typedef khronos_utime_nanoseconds_t EGLTime; -#define EGL_CONTEXT_MAJOR_VERSION 0x3098 -#define EGL_CONTEXT_MINOR_VERSION 0x30FB -#define EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD -#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD -#define EGL_NO_RESET_NOTIFICATION 0x31BE -#define EGL_LOSE_CONTEXT_ON_RESET 0x31BF -#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001 -#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define EGL_CONTEXT_OPENGL_DEBUG 0x31B0 -#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1 -#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2 -#define EGL_OPENGL_ES3_BIT 0x00000040 -#define EGL_CL_EVENT_HANDLE 0x309C -#define EGL_SYNC_CL_EVENT 0x30FE -#define EGL_SYNC_CL_EVENT_COMPLETE 0x30FF -#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE 0x30F0 -#define EGL_SYNC_TYPE 0x30F7 -#define EGL_SYNC_STATUS 0x30F1 -#define EGL_SYNC_CONDITION 0x30F8 -#define EGL_SIGNALED 0x30F2 -#define EGL_UNSIGNALED 0x30F3 -#define EGL_SYNC_FLUSH_COMMANDS_BIT 0x0001 -#define EGL_FOREVER 0xFFFFFFFFFFFFFFFFull -#define EGL_TIMEOUT_EXPIRED 0x30F5 -#define EGL_CONDITION_SATISFIED 0x30F6 -#define EGL_NO_SYNC ((EGLSync)0) -#define EGL_SYNC_FENCE 0x30F9 -#define EGL_GL_COLORSPACE 0x309D -#define EGL_GL_COLORSPACE_SRGB 0x3089 -#define EGL_GL_COLORSPACE_LINEAR 0x308A -#define EGL_GL_RENDERBUFFER 0x30B9 -#define EGL_GL_TEXTURE_2D 0x30B1 -#define EGL_GL_TEXTURE_LEVEL 0x30BC -#define EGL_GL_TEXTURE_3D 0x30B2 -#define EGL_GL_TEXTURE_ZOFFSET 0x30BD -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8 -EGLAPI EGLSync EGLAPIENTRY eglCreateSync (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync (EGLDisplay dpy, EGLSync sync); -EGLAPI EGLint EGLAPIENTRY eglClientWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout); -EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttrib (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value); -EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay (EGLenum platform, void *native_display, const EGLAttrib *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags); -#endif /* EGL_VERSION_1_5 */ +/* Now, define eglGetProcAddress using the generic function ptr. type */ +EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY + eglGetProcAddress(const char *procname); #ifdef __cplusplus } #endif -#endif +#endif /* __egl_h_ */ diff --git a/gfx/angle/include/EGL/eglext.h b/gfx/angle/include/EGL/eglext.h index ee4f5fae07f4..937af4193b5c 100644 --- a/gfx/angle/include/EGL/eglext.h +++ b/gfx/angle/include/EGL/eglext.h @@ -1,12 +1,12 @@ #ifndef __eglext_h_ -#define __eglext_h_ 1 +#define __eglext_h_ #ifdef __cplusplus extern "C" { #endif /* -** Copyright (c) 2013-2014 The Khronos Group Inc. +** Copyright (c) 2007-2013 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -27,686 +27,186 @@ extern "C" { ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -/* -** This header is generated from the Khronos OpenGL / OpenGL ES XML -** API Registry. The current version of the Registry, generator scripts -** used to make the header, and the header can be found at -** http://www.opengl.org/registry/ -** -** Khronos $Revision: 27018 $ on $Date: 2014-06-10 08:06:12 -0700 (Tue, 10 Jun 2014) $ -*/ #include -#define EGL_EGLEXT_VERSION 20140610 +/*************************************************************/ -/* Generated C header for: - * API: egl - * Versions considered: .* - * Versions emitted: _nomatch_^ - * Default extensions included: egl - * Additional extensions included: _nomatch_^ - * Extensions removed: _nomatch_^ - */ - -#ifndef EGL_KHR_cl_event -#define EGL_KHR_cl_event 1 -#define EGL_CL_EVENT_HANDLE_KHR 0x309C -#define EGL_SYNC_CL_EVENT_KHR 0x30FE -#define EGL_SYNC_CL_EVENT_COMPLETE_KHR 0x30FF -#endif /* EGL_KHR_cl_event */ - -#ifndef EGL_KHR_cl_event2 -#define EGL_KHR_cl_event2 1 -typedef void *EGLSyncKHR; -typedef intptr_t EGLAttribKHR; -typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNC64KHRPROC) (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); -#endif -#endif /* EGL_KHR_cl_event2 */ - -#ifndef EGL_KHR_client_get_all_proc_addresses -#define EGL_KHR_client_get_all_proc_addresses 1 -#endif /* EGL_KHR_client_get_all_proc_addresses */ +/* Header file version number */ +/* Current version at http://www.khronos.org/registry/egl/ */ +/* $Revision: 20690 $ on $Date: 2013-02-22 20:15:05 -0500 (Fri, 22 Feb 2013) $ */ +#define EGL_EGLEXT_VERSION 15 #ifndef EGL_KHR_config_attribs #define EGL_KHR_config_attribs 1 -#define EGL_CONFORMANT_KHR 0x3042 -#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 -#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 -#endif /* EGL_KHR_config_attribs */ - -#ifndef EGL_KHR_create_context -#define EGL_KHR_create_context 1 -#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098 -#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB -#define EGL_CONTEXT_FLAGS_KHR 0x30FC -#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD -#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD -#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE -#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF -#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 -#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 -#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 -#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 -#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 -#define EGL_OPENGL_ES3_BIT_KHR 0x00000040 -#endif /* EGL_KHR_create_context */ - -#ifndef EGL_KHR_fence_sync -#define EGL_KHR_fence_sync 1 -#ifdef KHRONOS_SUPPORT_INT64 -#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0 -#define EGL_SYNC_CONDITION_KHR 0x30F8 -#define EGL_SYNC_FENCE_KHR 0x30F9 -#endif /* KHRONOS_SUPPORT_INT64 */ -#endif /* EGL_KHR_fence_sync */ - -#ifndef EGL_KHR_get_all_proc_addresses -#define EGL_KHR_get_all_proc_addresses 1 -#endif /* EGL_KHR_get_all_proc_addresses */ - -#ifndef EGL_KHR_gl_colorspace -#define EGL_KHR_gl_colorspace 1 -#define EGL_GL_COLORSPACE_KHR 0x309D -#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089 -#define EGL_GL_COLORSPACE_LINEAR_KHR 0x308A -#endif /* EGL_KHR_gl_colorspace */ - -#ifndef EGL_KHR_gl_renderbuffer_image -#define EGL_KHR_gl_renderbuffer_image 1 -#define EGL_GL_RENDERBUFFER_KHR 0x30B9 -#endif /* EGL_KHR_gl_renderbuffer_image */ - -#ifndef EGL_KHR_gl_texture_2D_image -#define EGL_KHR_gl_texture_2D_image 1 -#define EGL_GL_TEXTURE_2D_KHR 0x30B1 -#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC -#endif /* EGL_KHR_gl_texture_2D_image */ - -#ifndef EGL_KHR_gl_texture_3D_image -#define EGL_KHR_gl_texture_3D_image 1 -#define EGL_GL_TEXTURE_3D_KHR 0x30B2 -#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD -#endif /* EGL_KHR_gl_texture_3D_image */ - -#ifndef EGL_KHR_gl_texture_cubemap_image -#define EGL_KHR_gl_texture_cubemap_image 1 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 -#endif /* EGL_KHR_gl_texture_cubemap_image */ - -#ifndef EGL_KHR_image -#define EGL_KHR_image 1 -typedef void *EGLImageKHR; -#define EGL_NATIVE_PIXMAP_KHR 0x30B0 -#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) -typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image); +#define EGL_CONFORMANT_KHR 0x3042 /* EGLConfig attribute */ +#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 /* EGL_SURFACE_TYPE bitfield */ +#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 /* EGL_SURFACE_TYPE bitfield */ #endif -#endif /* EGL_KHR_image */ - -#ifndef EGL_KHR_image_base -#define EGL_KHR_image_base 1 -#define EGL_IMAGE_PRESERVED_KHR 0x30D2 -#endif /* EGL_KHR_image_base */ - -#ifndef EGL_KHR_image_pixmap -#define EGL_KHR_image_pixmap 1 -#endif /* EGL_KHR_image_pixmap */ #ifndef EGL_KHR_lock_surface #define EGL_KHR_lock_surface 1 -#define EGL_READ_SURFACE_BIT_KHR 0x0001 -#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 -#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 -#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 -#define EGL_MATCH_FORMAT_KHR 0x3043 -#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 -#define EGL_FORMAT_RGB_565_KHR 0x30C1 -#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 -#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 -#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 -#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 -#define EGL_BITMAP_POINTER_KHR 0x30C6 -#define EGL_BITMAP_PITCH_KHR 0x30C7 -#define EGL_BITMAP_ORIGIN_KHR 0x30C8 -#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 -#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA -#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB -#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC -#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD -#define EGL_LOWER_LEFT_KHR 0x30CE -#define EGL_UPPER_LEFT_KHR 0x30CF -typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface); +#define EGL_READ_SURFACE_BIT_KHR 0x0001 /* EGL_LOCK_USAGE_HINT_KHR bitfield */ +#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 /* EGL_LOCK_USAGE_HINT_KHR bitfield */ +#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 /* EGL_SURFACE_TYPE bitfield */ +#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 /* EGL_SURFACE_TYPE bitfield */ +#define EGL_MATCH_FORMAT_KHR 0x3043 /* EGLConfig attribute */ +#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 /* EGL_MATCH_FORMAT_KHR value */ +#define EGL_FORMAT_RGB_565_KHR 0x30C1 /* EGL_MATCH_FORMAT_KHR value */ +#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 /* EGL_MATCH_FORMAT_KHR value */ +#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 /* EGL_MATCH_FORMAT_KHR value */ +#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 /* eglLockSurfaceKHR attribute */ +#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 /* eglLockSurfaceKHR attribute */ +#define EGL_BITMAP_POINTER_KHR 0x30C6 /* eglQuerySurface attribute */ +#define EGL_BITMAP_PITCH_KHR 0x30C7 /* eglQuerySurface attribute */ +#define EGL_BITMAP_ORIGIN_KHR 0x30C8 /* eglQuerySurface attribute */ +#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 /* eglQuerySurface attribute */ +#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA /* eglQuerySurface attribute */ +#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB /* eglQuerySurface attribute */ +#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC /* eglQuerySurface attribute */ +#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD /* eglQuerySurface attribute */ +#define EGL_LOWER_LEFT_KHR 0x30CE /* EGL_BITMAP_ORIGIN_KHR value */ +#define EGL_UPPER_LEFT_KHR 0x30CF /* EGL_BITMAP_ORIGIN_KHR value */ #ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay dpy, EGLSurface surface); +EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface); #endif -#endif /* EGL_KHR_lock_surface */ -#ifndef EGL_KHR_lock_surface2 -#define EGL_KHR_lock_surface2 1 -#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 -#endif /* EGL_KHR_lock_surface2 */ - -#ifndef EGL_KHR_lock_surface3 -#define EGL_KHR_lock_surface3 1 -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACE64KHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); +#ifndef EGL_KHR_image +#define EGL_KHR_image 1 +#define EGL_NATIVE_PIXMAP_KHR 0x30B0 /* eglCreateImageKHR target */ +typedef void *EGLImageKHR; +#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) #ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface64KHR (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); #endif -#endif /* EGL_KHR_lock_surface3 */ -#ifndef EGL_KHR_platform_android -#define EGL_KHR_platform_android 1 -#define EGL_PLATFORM_ANDROID_KHR 0x3141 -#endif /* EGL_KHR_platform_android */ +#ifndef EGL_KHR_vg_parent_image +#define EGL_KHR_vg_parent_image 1 +#define EGL_VG_PARENT_IMAGE_KHR 0x30BA /* eglCreateImageKHR target */ +#endif -#ifndef EGL_KHR_platform_gbm -#define EGL_KHR_platform_gbm 1 -#define EGL_PLATFORM_GBM_KHR 0x31D7 -#endif /* EGL_KHR_platform_gbm */ +#ifndef EGL_KHR_gl_texture_2D_image +#define EGL_KHR_gl_texture_2D_image 1 +#define EGL_GL_TEXTURE_2D_KHR 0x30B1 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC /* eglCreateImageKHR attribute */ +#endif -#ifndef EGL_KHR_platform_wayland -#define EGL_KHR_platform_wayland 1 -#define EGL_PLATFORM_WAYLAND_KHR 0x31D8 -#endif /* EGL_KHR_platform_wayland */ +#ifndef EGL_KHR_gl_texture_cubemap_image +#define EGL_KHR_gl_texture_cubemap_image 1 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 /* eglCreateImageKHR target */ +#endif -#ifndef EGL_KHR_platform_x11 -#define EGL_KHR_platform_x11 1 -#define EGL_PLATFORM_X11_KHR 0x31D5 -#define EGL_PLATFORM_X11_SCREEN_KHR 0x31D6 -#endif /* EGL_KHR_platform_x11 */ +#ifndef EGL_KHR_gl_texture_3D_image +#define EGL_KHR_gl_texture_3D_image 1 +#define EGL_GL_TEXTURE_3D_KHR 0x30B2 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD /* eglCreateImageKHR attribute */ +#endif +#ifndef EGL_KHR_gl_renderbuffer_image +#define EGL_KHR_gl_renderbuffer_image 1 +#define EGL_GL_RENDERBUFFER_KHR 0x30B9 /* eglCreateImageKHR target */ +#endif + +#if KHRONOS_SUPPORT_INT64 /* EGLTimeKHR requires 64-bit uint support */ #ifndef EGL_KHR_reusable_sync #define EGL_KHR_reusable_sync 1 + +typedef void* EGLSyncKHR; typedef khronos_utime_nanoseconds_t EGLTimeKHR; -#ifdef KHRONOS_SUPPORT_INT64 -#define EGL_SYNC_STATUS_KHR 0x30F1 -#define EGL_SIGNALED_KHR 0x30F2 -#define EGL_UNSIGNALED_KHR 0x30F3 -#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 -#define EGL_CONDITION_SATISFIED_KHR 0x30F6 -#define EGL_SYNC_TYPE_KHR 0x30F7 -#define EGL_SYNC_REUSABLE_KHR 0x30FA -#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 -#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull -#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0) + +#define EGL_SYNC_STATUS_KHR 0x30F1 +#define EGL_SIGNALED_KHR 0x30F2 +#define EGL_UNSIGNALED_KHR 0x30F3 +#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 +#define EGL_CONDITION_SATISFIED_KHR 0x30F6 +#define EGL_SYNC_TYPE_KHR 0x30F7 +#define EGL_SYNC_REUSABLE_KHR 0x30FA +#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 /* eglClientWaitSyncKHR bitfield */ +#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull +#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0) +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync); typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR (EGLDisplay dpy, EGLSyncKHR sync); -EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); -EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); -EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); #endif -#endif /* KHRONOS_SUPPORT_INT64 */ -#endif /* EGL_KHR_reusable_sync */ - -#ifndef EGL_KHR_stream -#define EGL_KHR_stream 1 -typedef void *EGLStreamKHR; -typedef khronos_uint64_t EGLuint64KHR; -#ifdef KHRONOS_SUPPORT_INT64 -#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0) -#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 -#define EGL_PRODUCER_FRAME_KHR 0x3212 -#define EGL_CONSUMER_FRAME_KHR 0x3213 -#define EGL_STREAM_STATE_KHR 0x3214 -#define EGL_STREAM_STATE_CREATED_KHR 0x3215 -#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216 -#define EGL_STREAM_STATE_EMPTY_KHR 0x3217 -#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 -#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 -#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A -#define EGL_BAD_STREAM_KHR 0x321B -#define EGL_BAD_STATE_KHR 0x321C -typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC) (EGLDisplay dpy, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR (EGLDisplay dpy, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR (EGLDisplay dpy, EGLStreamKHR stream); -EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); #endif -#endif /* KHRONOS_SUPPORT_INT64 */ -#endif /* EGL_KHR_stream */ -#ifndef EGL_KHR_stream_consumer_gltexture -#define EGL_KHR_stream_consumer_gltexture 1 -#ifdef EGL_KHR_stream -#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR (EGLDisplay dpy, EGLStreamKHR stream); -EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR (EGLDisplay dpy, EGLStreamKHR stream); -EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR (EGLDisplay dpy, EGLStreamKHR stream); +#ifndef EGL_KHR_image_base +#define EGL_KHR_image_base 1 +/* Most interfaces defined by EGL_KHR_image_pixmap above */ +#define EGL_IMAGE_PRESERVED_KHR 0x30D2 /* eglCreateImageKHR attribute */ #endif -#endif /* EGL_KHR_stream */ -#endif /* EGL_KHR_stream_consumer_gltexture */ -#ifndef EGL_KHR_stream_cross_process_fd -#define EGL_KHR_stream_cross_process_fd 1 -typedef int EGLNativeFileDescriptorKHR; -#ifdef EGL_KHR_stream -#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1)) -typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); -typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR (EGLDisplay dpy, EGLStreamKHR stream); -EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#ifndef EGL_KHR_image_pixmap +#define EGL_KHR_image_pixmap 1 +/* Interfaces defined by EGL_KHR_image above */ #endif -#endif /* EGL_KHR_stream */ -#endif /* EGL_KHR_stream_cross_process_fd */ - -#ifndef EGL_KHR_stream_fifo -#define EGL_KHR_stream_fifo 1 -#ifdef EGL_KHR_stream -#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC -#define EGL_STREAM_TIME_NOW_KHR 0x31FD -#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE -#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); -#endif -#endif /* EGL_KHR_stream */ -#endif /* EGL_KHR_stream_fifo */ - -#ifndef EGL_KHR_stream_producer_aldatalocator -#define EGL_KHR_stream_producer_aldatalocator 1 -#ifdef EGL_KHR_stream -#endif /* EGL_KHR_stream */ -#endif /* EGL_KHR_stream_producer_aldatalocator */ - -#ifndef EGL_KHR_stream_producer_eglsurface -#define EGL_KHR_stream_producer_eglsurface 1 -#ifdef EGL_KHR_stream -#define EGL_STREAM_BIT_KHR 0x0800 -typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC) (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); -#endif -#endif /* EGL_KHR_stream */ -#endif /* EGL_KHR_stream_producer_eglsurface */ - -#ifndef EGL_KHR_surfaceless_context -#define EGL_KHR_surfaceless_context 1 -#endif /* EGL_KHR_surfaceless_context */ - -#ifndef EGL_KHR_vg_parent_image -#define EGL_KHR_vg_parent_image 1 -#define EGL_VG_PARENT_IMAGE_KHR 0x30BA -#endif /* EGL_KHR_vg_parent_image */ - -#ifndef EGL_KHR_wait_sync -#define EGL_KHR_wait_sync 1 -typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); -#endif -#endif /* EGL_KHR_wait_sync */ - -#ifndef EGL_ANDROID_blob_cache -#define EGL_ANDROID_blob_cache 1 -typedef khronos_ssize_t EGLsizeiANDROID; -typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize); -typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize); -typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC) (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); -#endif -#endif /* EGL_ANDROID_blob_cache */ - -#ifndef EGL_ANDROID_framebuffer_target -#define EGL_ANDROID_framebuffer_target 1 -#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147 -#endif /* EGL_ANDROID_framebuffer_target */ - -#ifndef EGL_ANDROID_image_native_buffer -#define EGL_ANDROID_image_native_buffer 1 -#define EGL_NATIVE_BUFFER_ANDROID 0x3140 -#endif /* EGL_ANDROID_image_native_buffer */ - -#ifndef EGL_ANDROID_native_fence_sync -#define EGL_ANDROID_native_fence_sync 1 -#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 -#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145 -#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146 -#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 -typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy, EGLSyncKHR sync); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID (EGLDisplay dpy, EGLSyncKHR sync); -#endif -#endif /* EGL_ANDROID_native_fence_sync */ - -#ifndef EGL_ANDROID_recordable -#define EGL_ANDROID_recordable 1 -#define EGL_RECORDABLE_ANDROID 0x3142 -#endif /* EGL_ANDROID_recordable */ - -#ifndef EGL_ANGLE_d3d_share_handle_client_buffer -#define EGL_ANGLE_d3d_share_handle_client_buffer 1 -#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 -#endif /* EGL_ANGLE_d3d_share_handle_client_buffer */ - -#ifndef EGL_ANGLE_window_fixed_size -#define EGL_ANGLE_window_fixed_size 1 -#define EGL_FIXED_SIZE_ANGLE 0x3201 -#endif /* EGL_ANGLE_window_fixed_size */ - -#ifndef EGL_ANGLE_query_surface_pointer -#define EGL_ANGLE_query_surface_pointer 1 -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); -#endif -#endif /* EGL_ANGLE_query_surface_pointer */ - -#ifndef EGL_ANGLE_software_display -#define EGL_ANGLE_software_display 1 -#define EGL_SOFTWARE_DISPLAY_ANGLE ((EGLNativeDisplayType)-1) -#endif /* EGL_ANGLE_software_display */ - -#ifndef EGL_ANGLE_direct3d_display -#define EGL_ANGLE_direct3d_display 1 -#define EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ((EGLNativeDisplayType)-2) -#define EGL_D3D11_ONLY_DISPLAY_ANGLE ((EGLNativeDisplayType)-3) -#endif /* EGL_ANGLE_direct3d_display */ - -#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle -#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 -#endif /* EGL_ANGLE_surface_d3d_texture_2d_share_handle */ - -#ifndef EGL_ARM_pixmap_multisample_discard -#define EGL_ARM_pixmap_multisample_discard 1 -#define EGL_DISCARD_SAMPLES_ARM 0x3286 -#endif /* EGL_ARM_pixmap_multisample_discard */ - -#ifndef EGL_EXT_buffer_age -#define EGL_EXT_buffer_age 1 -#define EGL_BUFFER_AGE_EXT 0x313D -#endif /* EGL_EXT_buffer_age */ - -#ifndef EGL_EXT_client_extensions -#define EGL_EXT_client_extensions 1 -#endif /* EGL_EXT_client_extensions */ - -#ifndef EGL_EXT_create_context_robustness -#define EGL_EXT_create_context_robustness 1 -#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF -#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138 -#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE -#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF -#endif /* EGL_EXT_create_context_robustness */ - -#ifndef EGL_EXT_device_base -#define EGL_EXT_device_base 1 -typedef void *EGLDeviceEXT; -#define EGL_NO_DEVICE_EXT ((EGLDeviceEXT)(0)) -#define EGL_BAD_DEVICE_EXT 0x322B -#define EGL_DEVICE_EXT 0x322C -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEATTRIBEXTPROC) (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); -typedef const char *(EGLAPIENTRYP PFNEGLQUERYDEVICESTRINGEXTPROC) (EGLDeviceEXT device, EGLint name); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC) (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBEXTPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceAttribEXT (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); -EGLAPI const char *EGLAPIENTRY eglQueryDeviceStringEXT (EGLDeviceEXT device, EGLint name); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryDevicesEXT (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); -#endif -#endif /* EGL_EXT_device_base */ - -#ifndef EGL_EXT_image_dma_buf_import -#define EGL_EXT_image_dma_buf_import 1 -#define EGL_LINUX_DMA_BUF_EXT 0x3270 -#define EGL_LINUX_DRM_FOURCC_EXT 0x3271 -#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 -#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 -#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 -#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 -#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 -#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 -#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 -#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 -#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A -#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B -#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C -#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D -#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E -#define EGL_ITU_REC601_EXT 0x327F -#define EGL_ITU_REC709_EXT 0x3280 -#define EGL_ITU_REC2020_EXT 0x3281 -#define EGL_YUV_FULL_RANGE_EXT 0x3282 -#define EGL_YUV_NARROW_RANGE_EXT 0x3283 -#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 -#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 -#endif /* EGL_EXT_image_dma_buf_import */ - -#ifndef EGL_EXT_multiview_window -#define EGL_EXT_multiview_window 1 -#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134 -#endif /* EGL_EXT_multiview_window */ - -#ifndef EGL_EXT_platform_base -#define EGL_EXT_platform_base 1 -typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list); -typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); -typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT (EGLenum platform, void *native_display, const EGLint *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); -#endif -#endif /* EGL_EXT_platform_base */ - -#ifndef EGL_EXT_platform_device -#define EGL_EXT_platform_device 1 -#define EGL_PLATFORM_DEVICE_EXT 0x313F -#endif /* EGL_EXT_platform_device */ - -#ifndef EGL_EXT_platform_wayland -#define EGL_EXT_platform_wayland 1 -#define EGL_PLATFORM_WAYLAND_EXT 0x31D8 -#endif /* EGL_EXT_platform_wayland */ - -#ifndef EGL_EXT_platform_x11 -#define EGL_EXT_platform_x11 1 -#define EGL_PLATFORM_X11_EXT 0x31D5 -#define EGL_PLATFORM_X11_SCREEN_EXT 0x31D6 -#endif /* EGL_EXT_platform_x11 */ - -#ifndef EGL_EXT_protected_surface -#define EGL_EXT_protected_surface 1 -#define EGL_PROTECTED_CONTENT_EXT 0x32C0 -#endif /* EGL_EXT_protected_surface */ - -#ifndef EGL_EXT_swap_buffers_with_damage -#define EGL_EXT_swap_buffers_with_damage 1 -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); -#endif -#endif /* EGL_EXT_swap_buffers_with_damage */ - -#ifndef EGL_HI_clientpixmap -#define EGL_HI_clientpixmap 1 -struct EGLClientPixmapHI { - void *pData; - EGLint iWidth; - EGLint iHeight; - EGLint iStride; -}; -#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74 -typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); -#endif -#endif /* EGL_HI_clientpixmap */ - -#ifndef EGL_HI_colorformats -#define EGL_HI_colorformats 1 -#define EGL_COLOR_FORMAT_HI 0x8F70 -#define EGL_COLOR_RGB_HI 0x8F71 -#define EGL_COLOR_RGBA_HI 0x8F72 -#define EGL_COLOR_ARGB_HI 0x8F73 -#endif /* EGL_HI_colorformats */ #ifndef EGL_IMG_context_priority #define EGL_IMG_context_priority 1 -#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 -#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 -#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 -#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 -#endif /* EGL_IMG_context_priority */ - -#ifndef EGL_MESA_drm_image -#define EGL_MESA_drm_image 1 -#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 -#define EGL_DRM_BUFFER_USE_MESA 0x31D1 -#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 -#define EGL_DRM_BUFFER_MESA 0x31D3 -#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 -#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 -#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 -typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 +#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 +#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 +#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 #endif -#endif /* EGL_MESA_drm_image */ -#ifndef EGL_MESA_platform_gbm -#define EGL_MESA_platform_gbm 1 -#define EGL_PLATFORM_GBM_MESA 0x31D7 -#endif /* EGL_MESA_platform_gbm */ - -#ifndef EGL_NOK_swap_region -#define EGL_NOK_swap_region 1 -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#ifndef EGL_KHR_lock_surface2 +#define EGL_KHR_lock_surface2 1 +#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 #endif -#endif /* EGL_NOK_swap_region */ - -#ifndef EGL_NOK_swap_region2 -#define EGL_NOK_swap_region2 1 -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGION2NOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegion2NOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); -#endif -#endif /* EGL_NOK_swap_region2 */ - -#ifndef EGL_NOK_texture_from_pixmap -#define EGL_NOK_texture_from_pixmap 1 -#define EGL_Y_INVERTED_NOK 0x307F -#endif /* EGL_NOK_texture_from_pixmap */ - -#ifndef EGL_NV_3dvision_surface -#define EGL_NV_3dvision_surface 1 -#define EGL_AUTO_STEREO_NV 0x3136 -#endif /* EGL_NV_3dvision_surface */ #ifndef EGL_NV_coverage_sample #define EGL_NV_coverage_sample 1 -#define EGL_COVERAGE_BUFFERS_NV 0x30E0 -#define EGL_COVERAGE_SAMPLES_NV 0x30E1 -#endif /* EGL_NV_coverage_sample */ - -#ifndef EGL_NV_coverage_sample_resolve -#define EGL_NV_coverage_sample_resolve 1 -#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131 -#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132 -#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133 -#endif /* EGL_NV_coverage_sample_resolve */ +#define EGL_COVERAGE_BUFFERS_NV 0x30E0 +#define EGL_COVERAGE_SAMPLES_NV 0x30E1 +#endif #ifndef EGL_NV_depth_nonlinear #define EGL_NV_depth_nonlinear 1 -#define EGL_DEPTH_ENCODING_NV 0x30E2 -#define EGL_DEPTH_ENCODING_NONE_NV 0 -#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 -#endif /* EGL_NV_depth_nonlinear */ - -#ifndef EGL_NV_native_query -#define EGL_NV_native_query 1 -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC) (EGLDisplay dpy, EGLNativeDisplayType *display_id); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV (EGLDisplay dpy, EGLNativeDisplayType *display_id); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); +#define EGL_DEPTH_ENCODING_NV 0x30E2 +#define EGL_DEPTH_ENCODING_NONE_NV 0 +#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 #endif -#endif /* EGL_NV_native_query */ - -#ifndef EGL_NV_post_convert_rounding -#define EGL_NV_post_convert_rounding 1 -#endif /* EGL_NV_post_convert_rounding */ - -#ifndef EGL_NV_post_sub_buffer -#define EGL_NV_post_sub_buffer 1 -#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE -typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); -#endif -#endif /* EGL_NV_post_sub_buffer */ - -#ifndef EGL_NV_stream_sync -#define EGL_NV_stream_sync 1 -#define EGL_SYNC_NEW_FRAME_NV 0x321F -typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESTREAMSYNCNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateStreamSyncNV (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); -#endif -#endif /* EGL_NV_stream_sync */ +#if KHRONOS_SUPPORT_INT64 /* EGLTimeNV requires 64-bit uint support */ #ifndef EGL_NV_sync #define EGL_NV_sync 1 -typedef void *EGLSyncNV; +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6 +#define EGL_SYNC_STATUS_NV 0x30E7 +#define EGL_SIGNALED_NV 0x30E8 +#define EGL_UNSIGNALED_NV 0x30E9 +#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001 +#define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull +#define EGL_ALREADY_SIGNALED_NV 0x30EA +#define EGL_TIMEOUT_EXPIRED_NV 0x30EB +#define EGL_CONDITION_SATISFIED_NV 0x30EC +#define EGL_SYNC_TYPE_NV 0x30ED +#define EGL_SYNC_CONDITION_NV 0x30EE +#define EGL_SYNC_FENCE_NV 0x30EF +#define EGL_NO_SYNC_NV ((EGLSyncNV)0) +typedef void* EGLSyncNV; typedef khronos_utime_nanoseconds_t EGLTimeNV; -#ifdef KHRONOS_SUPPORT_INT64 -#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6 -#define EGL_SYNC_STATUS_NV 0x30E7 -#define EGL_SIGNALED_NV 0x30E8 -#define EGL_UNSIGNALED_NV 0x30E9 -#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001 -#define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull -#define EGL_ALREADY_SIGNALED_NV 0x30EA -#define EGL_TIMEOUT_EXPIRED_NV 0x30EB -#define EGL_CONDITION_SATISFIED_NV 0x30EC -#define EGL_SYNC_TYPE_NV 0x30ED -#define EGL_SYNC_CONDITION_NV 0x30EE -#define EGL_SYNC_FENCE_NV 0x30EF -#define EGL_NO_SYNC_NV ((EGLSyncNV)0) -typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync); -typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync); @@ -714,25 +214,368 @@ EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync); EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value); +#endif #endif -#endif /* KHRONOS_SUPPORT_INT64 */ -#endif /* EGL_NV_sync */ +#if KHRONOS_SUPPORT_INT64 /* Dependent on EGL_KHR_reusable_sync which requires 64-bit uint support */ +#ifndef EGL_KHR_fence_sync +#define EGL_KHR_fence_sync 1 +/* Reuses most tokens and entry points from EGL_KHR_reusable_sync */ +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0 +#define EGL_SYNC_CONDITION_KHR 0x30F8 +#define EGL_SYNC_FENCE_KHR 0x30F9 +#endif +#endif + +#ifndef EGL_HI_clientpixmap +#define EGL_HI_clientpixmap 1 + +/* Surface Attribute */ +#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74 +/* + * Structure representing a client pixmap + * (pixmap's data is in client-space memory). + */ +struct EGLClientPixmapHI +{ + void* pData; + EGLint iWidth; + EGLint iHeight; + EGLint iStride; +}; +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap); +#endif /* EGL_HI_clientpixmap */ + +#ifndef EGL_HI_colorformats +#define EGL_HI_colorformats 1 +/* Config Attribute */ +#define EGL_COLOR_FORMAT_HI 0x8F70 +/* Color Formats */ +#define EGL_COLOR_RGB_HI 0x8F71 +#define EGL_COLOR_RGBA_HI 0x8F72 +#define EGL_COLOR_ARGB_HI 0x8F73 +#endif /* EGL_HI_colorformats */ + +#ifndef EGL_MESA_drm_image +#define EGL_MESA_drm_image 1 +#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 /* CreateDRMImageMESA attribute */ +#define EGL_DRM_BUFFER_USE_MESA 0x31D1 /* CreateDRMImageMESA attribute */ +#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 /* EGL_IMAGE_FORMAT_MESA attribute value */ +#define EGL_DRM_BUFFER_MESA 0x31D3 /* eglCreateImageKHR target */ +#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 +#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 /* EGL_DRM_BUFFER_USE_MESA bits */ +#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 /* EGL_DRM_BUFFER_USE_MESA bits */ +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#endif + +#ifndef EGL_NV_post_sub_buffer +#define EGL_NV_post_sub_buffer 1 +#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#endif + +#ifndef EGL_ANGLE_query_surface_pointer +#define EGL_ANGLE_query_surface_pointer 1 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); +#endif +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); +#endif + +#ifndef EGL_ANGLE_software_display +#define EGL_ANGLE_software_display 1 +#define EGL_SOFTWARE_DISPLAY_ANGLE ((EGLNativeDisplayType)-1) +#endif + +#ifndef EGL_ANGLE_direct3d_display +#define EGL_ANGLE_direct3d_display 1 +#define EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ((EGLNativeDisplayType)-2) +#define EGL_D3D11_ONLY_DISPLAY_ANGLE ((EGLNativeDisplayType)-3) +#endif + +#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle +#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 +#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 +#endif + +#ifndef EGL_NV_coverage_sample_resolve +#define EGL_NV_coverage_sample_resolve 1 +#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131 +#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132 +#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133 +#endif + +#if KHRONOS_SUPPORT_INT64 /* EGLuint64NV requires 64-bit uint support */ #ifndef EGL_NV_system_time #define EGL_NV_system_time 1 typedef khronos_utime_nanoseconds_t EGLuint64NV; -#ifdef KHRONOS_SUPPORT_INT64 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void); +EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV(void); +#endif /* EGL_EGLEXT_PROTOTYPES */ typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void); typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV (void); -EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void); #endif -#endif /* KHRONOS_SUPPORT_INT64 */ -#endif /* EGL_NV_system_time */ +#endif + +#if KHRONOS_SUPPORT_INT64 /* EGLuint64KHR requires 64-bit uint support */ +#ifndef EGL_KHR_stream +#define EGL_KHR_stream 1 +typedef void* EGLStreamKHR; +typedef khronos_uint64_t EGLuint64KHR; +#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0) +#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 +#define EGL_PRODUCER_FRAME_KHR 0x3212 +#define EGL_CONSUMER_FRAME_KHR 0x3213 +#define EGL_STREAM_STATE_KHR 0x3214 +#define EGL_STREAM_STATE_CREATED_KHR 0x3215 +#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216 +#define EGL_STREAM_STATE_EMPTY_KHR 0x3217 +#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 +#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 +#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A +#define EGL_BAD_STREAM_KHR 0x321B +#define EGL_BAD_STATE_KHR 0x321C +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC)(EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_consumer_gltexture +#define EGL_KHR_stream_consumer_gltexture 1 +#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_producer_eglsurface +#define EGL_KHR_stream_producer_eglsurface 1 +#define EGL_STREAM_BIT_KHR 0x0800 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_producer_aldatalocator +#define EGL_KHR_stream_producer_aldatalocator 1 +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_fifo +#define EGL_KHR_stream_fifo 1 +/* reuse EGLTimeKHR */ +#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC +#define EGL_STREAM_TIME_NOW_KHR 0x31FD +#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE +#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#endif +#endif + +#ifndef EGL_EXT_create_context_robustness +#define EGL_EXT_create_context_robustness 1 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138 +#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF +#endif + +#ifndef EGL_ANGLE_d3d_share_handle_client_buffer +#define EGL_ANGLE_d3d_share_handle_client_buffer 1 +/* reuse EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE */ +#endif + +#ifndef EGL_ANGLE_window_fixed_size +#define EGL_ANGLE_window_fixed_size 1 +#define EGL_FIXED_SIZE_ANGLE 0x3201 +#endif + +#ifndef EGL_KHR_create_context +#define EGL_KHR_create_context 1 +#define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION +#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB +#define EGL_CONTEXT_FLAGS_KHR 0x30FC +#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD +#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF +#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 +#define EGL_OPENGL_ES3_BIT_KHR 0x00000040 +#endif + +#ifndef EGL_KHR_surfaceless_context +#define EGL_KHR_surfaceless_context 1 +/* No tokens/entry points, just relaxes an error condition */ +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_cross_process_fd +#define EGL_KHR_stream_cross_process_fd 1 +typedef int EGLNativeFileDescriptorKHR; +#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1)) +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR(EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#endif +#endif + +#ifndef EGL_EXT_multiview_window +#define EGL_EXT_multiview_window 1 +#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134 +#endif + +#ifndef EGL_KHR_wait_sync +#define EGL_KHR_wait_sync 1 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#endif + +#ifndef EGL_NV_post_convert_rounding +#define EGL_NV_post_convert_rounding 1 +/* No tokens or entry points, just relaxes behavior of SwapBuffers */ +#endif + +#ifndef EGL_NV_native_query +#define EGL_NV_native_query 1 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV( EGLDisplay dpy, EGLNativeDisplayType* display_id); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV( EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType* window); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV( EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType* pixmap); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC)(EGLDisplay dpy, EGLNativeDisplayType *display_id); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); +#endif + +#ifndef EGL_NV_3dvision_surface +#define EGL_NV_3dvision_surface 1 +#define EGL_AUTO_STEREO_NV 0x3136 +#endif + +#ifndef EGL_ANDROID_framebuffer_target +#define EGL_ANDROID_framebuffer_target 1 +#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147 +#endif + +#ifndef EGL_ANDROID_blob_cache +#define EGL_ANDROID_blob_cache 1 +typedef khronos_ssize_t EGLsizeiANDROID; +typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize); +typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC)(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#endif + +#ifndef EGL_ANDROID_image_native_buffer +#define EGL_ANDROID_image_native_buffer 1 +#define EGL_NATIVE_BUFFER_ANDROID 0x3140 +#endif + +#ifndef EGL_ANDROID_native_fence_sync +#define EGL_ANDROID_native_fence_sync 1 +#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 +#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145 +#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146 +#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID( EGLDisplay dpy, EGLSyncKHR); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC)(EGLDisplay dpy, EGLSyncKHR); +#endif + +#ifndef EGL_ANDROID_recordable +#define EGL_ANDROID_recordable 1 +#define EGL_RECORDABLE_ANDROID 0x3142 +#endif + +#ifndef EGL_EXT_buffer_age +#define EGL_EXT_buffer_age 1 +#define EGL_BUFFER_AGE_EXT 0x313D +#endif + +#ifndef EGL_EXT_image_dma_buf_import +#define EGL_EXT_image_dma_buf_import 1 +#define EGL_LINUX_DMA_BUF_EXT 0x3270 +#define EGL_LINUX_DRM_FOURCC_EXT 0x3271 +#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 +#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 +#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 +#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 +#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 +#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 +#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 +#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 +#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A +#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B +#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C +#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D +#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E +#define EGL_ITU_REC601_EXT 0x327F +#define EGL_ITU_REC709_EXT 0x3280 +#define EGL_ITU_REC2020_EXT 0x3281 +#define EGL_YUV_FULL_RANGE_EXT 0x3282 +#define EGL_YUV_NARROW_RANGE_EXT 0x3283 +#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 +#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 +#endif #ifdef __cplusplus } #endif -#endif +#endif /* __eglext_h_ */ diff --git a/gfx/angle/include/EGL/eglplatform.h b/gfx/angle/include/EGL/eglplatform.h index 3ab8844f09c1..9a89420ebf93 100644 --- a/gfx/angle/include/EGL/eglplatform.h +++ b/gfx/angle/include/EGL/eglplatform.h @@ -2,7 +2,7 @@ #define __eglplatform_h_ /* -** Copyright (c) 2007-2013 The Khronos Group Inc. +** Copyright (c) 2007-2009 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -25,7 +25,7 @@ */ /* Platform-specific types and definitions for egl.h - * $Revision: 23432 $ on $Date: 2013-10-09 00:57:24 -0700 (Wed, 09 Oct 2013) $ + * $Revision: 12306 $ on $Date: 2010-08-25 12:51:28 -0400 (Wed, 25 Aug 2010) $ * * Adopters may modify khrplatform.h and this file to suit their platform. * You are encouraged to submit all modifications to the Khronos group so that @@ -83,16 +83,6 @@ typedef int EGLNativeDisplayType; typedef void *EGLNativeWindowType; typedef void *EGLNativePixmapType; -#elif defined(__ANDROID__) || defined(ANDROID) - -#include - -struct egl_native_pixmap_t; - -typedef struct ANativeWindow* EGLNativeWindowType; -typedef struct egl_native_pixmap_t* EGLNativePixmapType; -typedef void* EGLNativeDisplayType; - #elif defined(__unix__) /* X11 (tentative) */ diff --git a/gfx/angle/include/KHR/khrplatform.h b/gfx/angle/include/KHR/khrplatform.h old mode 100755 new mode 100644 diff --git a/gfx/angle/include/angle_gl.h b/gfx/angle/include/angle_gl.h deleted file mode 100644 index d093f75ee294..000000000000 --- a/gfx/angle/include/angle_gl.h +++ /dev/null @@ -1,23 +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. -// -// angle_gl.h: -// Includes all necessary GL headers and definitions for ANGLE. -// - -#ifndef ANGLE_GL_H_ -#define ANGLE_GL_H_ - -#include "GLES2/gl2.h" -#include "GLES2/gl2ext.h" -#include "GLES3/gl3.h" -#include "GLES3/gl3ext.h" - -// The following enum is used in ANGLE, but is from desktop GL -#ifndef GL_SAMPLER_2D_RECT_ARB -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#endif - -#endif // ANGLE_GL_H_ diff --git a/gfx/angle/moz.build b/gfx/angle/moz.build index d585fe12fe04..c8da8f0c5a8f 100644 --- a/gfx/angle/moz.build +++ b/gfx/angle/moz.build @@ -7,7 +7,6 @@ UNIFIED_SOURCES += [ 'src/common/event_tracer.cpp', 'src/common/mathutil.cpp', 'src/common/RefCountObject.cpp', - 'src/common/tls.cpp', 'src/common/utilities.cpp', 'src/compiler/preprocessor/DiagnosticsBase.cpp', 'src/compiler/preprocessor/DirectiveHandlerBase.cpp', @@ -55,7 +54,6 @@ UNIFIED_SOURCES += [ 'src/compiler/translator/RewriteElseBlocks.cpp', 'src/compiler/translator/SearchSymbol.cpp', 'src/compiler/translator/ShaderLang.cpp', - 'src/compiler/translator/StructureHLSL.cpp', 'src/compiler/translator/SymbolTable.cpp', 'src/compiler/translator/timing/RestrictFragmentShaderTiming.cpp', 'src/compiler/translator/timing/RestrictVertexShaderTiming.cpp', @@ -65,9 +63,7 @@ UNIFIED_SOURCES += [ 'src/compiler/translator/Types.cpp', 'src/compiler/translator/UnfoldShortCircuit.cpp', 'src/compiler/translator/UnfoldShortCircuitAST.cpp', - 'src/compiler/translator/UniformHLSL.cpp', 'src/compiler/translator/util.cpp', - 'src/compiler/translator/UtilsHLSL.cpp', 'src/compiler/translator/ValidateLimitations.cpp', 'src/compiler/translator/ValidateOutputs.cpp', 'src/compiler/translator/VariableInfo.cpp', @@ -79,6 +75,26 @@ SOURCES += [ 'src/compiler/translator/glslang_lex.cpp', 'src/compiler/translator/glslang_tab.cpp', ] +if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk'): + UNIFIED_SOURCES += [ + 'src/compiler/translator/ossource_posix.cpp', + ] +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': + UNIFIED_SOURCES += [ + 'src/compiler/translator/ossource_posix.cpp', + ] +if CONFIG['MOZ_WIDGET_GTK']: + UNIFIED_SOURCES += [ + 'src/compiler/translator/ossource_posix.cpp', + ] +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt': + UNIFIED_SOURCES += [ + 'src/compiler/translator/ossource_posix.cpp', + ] +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': + UNIFIED_SOURCES += [ + 'src/compiler/translator/ossource_win.cpp', + ] if CONFIG['GNU_CXX']: diff --git a/gfx/angle/src/angle.gypi b/gfx/angle/src/angle.gypi index 09f70ffa0561..5339369f41c2 100644 --- a/gfx/angle/src/angle.gypi +++ b/gfx/angle/src/angle.gypi @@ -7,12 +7,6 @@ { 'angle_code': 1, 'angle_post_build_script%': 0, - 'angle_gen_path': '<(SHARED_INTERMEDIATE_DIR)/angle', - 'angle_id_script_base': 'commit_id.py', - 'angle_id_script': '<(angle_gen_path)/<(angle_id_script_base)', - 'angle_id_header_base': 'commit.h', - 'angle_id_header': '<(angle_gen_path)/id/<(angle_id_header_base)', - 'angle_use_commit_id%': ' %1%\commit.h + +REM commit hash size +set _Str=#define ANGLE_COMMIT_HASH_SIZE 12 +echo %_Str% >> %1%\commit.h + +REM commit date +(FOR /F "delims=" %%i IN ('call git show -s --format^="%%ci" HEAD') DO set _Str=%%i) || (set _Str=Unknown Date) +set _Str=#define ANGLE_COMMIT_DATE "%_Str%" +echo %_Str% >> %1%\commit.h diff --git a/gfx/angle/src/commit_id.py b/gfx/angle/src/commit_id.py index 7f711e75a623..6339cca3f2cc 100644 --- a/gfx/angle/src/commit_id.py +++ b/gfx/angle/src/commit_id.py @@ -1,35 +1,19 @@ import subprocess as sp import sys -import os -# Usage: commit_id.py check (checks if git is present) -# Usage: commit_id.py gen (generates commit id) +def grab_output(*command): + return sp.Popen(command, stdout=sp.PIPE).communicate()[0].strip() -def grab_output(command, cwd): - return sp.Popen(command, stdout=sp.PIPE, shell=True, cwd=cwd).communicate()[0].strip() - -operation = sys.argv[1] -cwd = sys.argv[2] - -if operation == 'check': - index_path = os.path.join(cwd, '.git', 'index') - if os.path.exists(index_path): - print("1") - else: - print("0") - sys.exit(0) - -output_file = sys.argv[3] commit_id_size = 12 try: - commit_id = grab_output('git rev-parse --short=%d HEAD' % commit_id_size, cwd) - commit_date = grab_output('git show -s --format=%ci HEAD', cwd) + commit_id = grab_output('git', 'rev-parse', '--short=%d' % commit_id_size, 'HEAD') + commit_date = grab_output('git', 'show', '-s', '--format=%ci', 'HEAD') except: commit_id = 'invalid-hash' commit_date = 'invalid-date' -hfile = open(output_file, 'w') +hfile = open(sys.argv[1], 'w') hfile.write('#define ANGLE_COMMIT_HASH "%s"\n' % commit_id) hfile.write('#define ANGLE_COMMIT_HASH_SIZE %d\n' % commit_id_size) diff --git a/gfx/angle/src/common/RefCountObject.h b/gfx/angle/src/common/RefCountObject.h index 8635aa59d88f..88b639312249 100644 --- a/gfx/angle/src/common/RefCountObject.h +++ b/gfx/angle/src/common/RefCountObject.h @@ -14,7 +14,8 @@ #include -#include "angle_gl.h" +#include +#include #include "common/debug.h" @@ -61,6 +62,33 @@ class BindingPointer : public RefCountObjectBindingPointer ObjectType *operator->() const { return get(); } }; +template +class FramebufferTextureBindingPointer : public RefCountObjectBindingPointer +{ +public: + FramebufferTextureBindingPointer() : mType(GL_NONE), mMipLevel(0), mLayer(0) { } + + void set(ObjectType *newObject, GLenum type, GLint mipLevel, GLint layer) + { + RefCountObjectBindingPointer::set(newObject); + mType = type; + mMipLevel = mipLevel; + mLayer = layer; + } + + ObjectType *get() const { return static_cast(RefCountObjectBindingPointer::get()); } + ObjectType *operator->() const { return get(); } + + GLenum type() const { return mType; } + GLint mipLevel() const { return mMipLevel; } + GLint layer() const { return mLayer; } + +private: + GLenum mType; + GLint mMipLevel; + GLint mLayer; +}; + template class OffsetBindingPointer : public RefCountObjectBindingPointer { diff --git a/gfx/angle/src/common/angleutils.h b/gfx/angle/src/common/angleutils.h index 1cec9206a425..58f6494163df 100644 --- a/gfx/angle/src/common/angleutils.h +++ b/gfx/angle/src/common/angleutils.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -9,11 +9,7 @@ #ifndef COMMON_ANGLEUTILS_H_ #define COMMON_ANGLEUTILS_H_ -#include "common/platform.h" - #include -#include -#include // A macro to disallow the copy constructor and operator= functions // This must be used in the private: declarations for a class @@ -64,16 +60,6 @@ void SafeDelete(T*& resource) resource = NULL; } -template -void SafeDeleteContainer(T& resource) -{ - for (typename T::iterator i = resource.begin(); i != resource.end(); i++) - { - SafeDelete(*i); - } - resource.clear(); -} - template void SafeDeleteArray(T*& resource) { @@ -103,18 +89,6 @@ inline void StructZero(T *obj) memset(obj, 0, sizeof(T)); } -inline const char* MakeStaticString(const std::string &str) -{ - static std::set strings; - std::set::iterator it = strings.find(str); - if (it != strings.end()) - { - return it->c_str(); - } - - return strings.insert(str).first->c_str(); -} - #if defined(_MSC_VER) #define snprintf _snprintf #endif diff --git a/gfx/angle/src/common/blocklayout.cpp b/gfx/angle/src/common/blocklayout.cpp index cdb7d7fd9e98..a0c9289d7906 100644 --- a/gfx/angle/src/common/blocklayout.cpp +++ b/gfx/angle/src/common/blocklayout.cpp @@ -12,7 +12,7 @@ #include "common/mathutil.h" #include "common/utilities.h" -namespace sh +namespace gl { BlockLayoutEncoder::BlockLayoutEncoder(std::vector *blockInfoOut) @@ -103,7 +103,7 @@ void Std140BlockEncoder::exitAggregateType() void Std140BlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut) { // We assume we are only dealing with 4 byte components (no doubles or half-words currently) - ASSERT(gl::VariableComponentSize(gl::VariableComponentType(type)) == BytesPerComponent); + ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent); size_t baseAlignment = 0; int matrixStride = 0; @@ -127,7 +127,7 @@ void Std140BlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, } else { - const int numComponents = gl::VariableComponentCount(type); + const int numComponents = gl::UniformComponentCount(type); baseAlignment = (numComponents == 3 ? 4u : static_cast(numComponents)); } @@ -151,7 +151,7 @@ void Std140BlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool } else { - mCurrentOffset += gl::VariableComponentCount(type); + mCurrentOffset += gl::UniformComponentCount(type); } } @@ -173,7 +173,7 @@ void HLSLBlockEncoder::exitAggregateType() void HLSLBlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut) { // We assume we are only dealing with 4 byte components (no doubles or half-words currently) - ASSERT(gl::VariableComponentSize(gl::VariableComponentType(type)) == BytesPerComponent); + ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent); int matrixStride = 0; int arrayStride = 0; @@ -204,7 +204,7 @@ void HLSLBlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, b } else if (isPacked()) { - int numComponents = gl::VariableComponentCount(type); + int numComponents = gl::UniformComponentCount(type); if ((numComponents + (mCurrentOffset % ComponentsPerRegister)) > ComponentsPerRegister) { nextRegister(); @@ -232,7 +232,7 @@ void HLSLBlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool i } else if (isPacked()) { - mCurrentOffset += gl::VariableComponentCount(type); + mCurrentOffset += gl::UniformComponentCount(type); } else { @@ -245,8 +245,8 @@ void HLSLBlockEncoder::skipRegisters(unsigned int numRegisters) mCurrentOffset += (numRegisters * ComponentsPerRegister); } -void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable, HLSLBlockEncoder *encoder, - const std::vector &blockInfo, ShShaderOutput outputType) +void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, gl::Uniform *variable, HLSLBlockEncoder *encoder, + const std::vector &blockInfo, ShShaderOutput outputType) { // because this method computes offsets (element indexes) instead of any total sizes, // we can ignore the array size of the variable @@ -282,7 +282,7 @@ void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variab } } -void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable, ShShaderOutput outputType) +void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, gl::Uniform *variable, ShShaderOutput outputType) { std::vector blockInfo; HLSLBlockEncoder encoder(&blockInfo, diff --git a/gfx/angle/src/common/blocklayout.h b/gfx/angle/src/common/blocklayout.h index 4ee58004ebd9..e6ffff1a9e55 100644 --- a/gfx/angle/src/common/blocklayout.h +++ b/gfx/angle/src/common/blocklayout.h @@ -11,12 +11,14 @@ #define COMMON_BLOCKLAYOUT_H_ #include -#include "angle_gl.h" +#include +#include #include #include -namespace sh +namespace gl { + struct ShaderVariable; struct InterfaceBlockField; struct BlockMemberInfo; @@ -67,7 +69,7 @@ class Std140BlockEncoder : public BlockLayoutEncoder // Block layout packed according to the D3D9 or default D3D10+ register packing rules // See http://msdn.microsoft.com/en-us/library/windows/desktop/bb509632(v=vs.85).aspx -// The strategy should be ENCODE_LOOSE for D3D9 constant blocks, and ENCODE_PACKED +// The strategy should be ENCODE_LOOSE for D3D9 constnat blocks, and ENCODE_PACKED // for everything else (D3D10+ constant blocks and all attributes/varyings). class HLSLBlockEncoder : public BlockLayoutEncoder diff --git a/gfx/angle/src/common/debug.cpp b/gfx/angle/src/common/debug.cpp index d6eecf7157ce..ac0a86ae2ef5 100644 --- a/gfx/angle/src/common/debug.cpp +++ b/gfx/angle/src/common/debug.cpp @@ -7,13 +7,15 @@ // debug.cpp: Debugging utilities. #include "common/debug.h" -#include "common/platform.h" - #include #include #include #include +#if defined(ANGLE_ENABLE_PERF) +#include +#endif + namespace gl { #if defined(ANGLE_ENABLE_PERF) diff --git a/gfx/angle/src/common/debug.h b/gfx/angle/src/common/debug.h index 997ebca6be0d..09cd249f8cd4 100644 --- a/gfx/angle/src/common/debug.h +++ b/gfx/angle/src/common/debug.h @@ -83,12 +83,6 @@ namespace gl #define UNUSED_ASSERTION_VARIABLE(variable) ((void)variable) #endif -#ifndef ANGLE_ENABLE_TRACE -#define UNUSED_TRACE_VARIABLE(variable) ((void)variable) -#else -#define UNUSED_TRACE_VARIABLE(variable) -#endif - // A macro to indicate unimplemented functionality // Define NOASSERT_UNIMPLEMENTED to non zero to skip the assert fail in the unimplemented checks diff --git a/gfx/angle/src/common/event_tracer.h b/gfx/angle/src/common/event_tracer.h index fa97435faac4..14b7b298fd84 100644 --- a/gfx/angle/src/common/event_tracer.h +++ b/gfx/angle/src/common/event_tracer.h @@ -5,14 +5,12 @@ #ifndef COMMON_EVENT_TRACER_H_ #define COMMON_EVENT_TRACER_H_ -#include "common/platform.h" - #if !defined(TRACE_ENTRY) -# ifdef ANGLE_PLATFORM_WINDOWS -# define TRACE_ENTRY __stdcall -# else -# define TRACE_ENTRY -# endif // ANGLE_PLATFORM_WINDOWS +#if defined(_WIN32) +#define TRACE_ENTRY __stdcall +#else +#define TRACE_ENTRY +#endif // // _WIN32 #endif //TRACE_ENTRY extern "C" { diff --git a/gfx/angle/src/common/mathutil.h b/gfx/angle/src/common/mathutil.h index 58f9b4cb7807..2d36631b4114 100644 --- a/gfx/angle/src/common/mathutil.h +++ b/gfx/angle/src/common/mathutil.h @@ -10,7 +10,10 @@ #define LIBGLESV2_MATHUTIL_H_ #include "common/debug.h" -#include "common/platform.h" + +#if defined(_WIN32) +#include +#endif #include #include @@ -109,7 +112,7 @@ inline unsigned int unorm(float x) inline bool supportsSSE2() { -#ifdef ANGLE_PLATFORM_WINDOWS +#if defined(_WIN32) static bool checked = false; static bool supports = false; diff --git a/gfx/angle/src/common/platform.h b/gfx/angle/src/common/platform.h deleted file mode 100644 index d07297dfd4b4..000000000000 --- a/gfx/angle/src/common/platform.h +++ /dev/null @@ -1,67 +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. -// - -// platform.h: Operating system specific includes and defines. - -#ifndef COMMON_PLATFORM_H_ -#define COMMON_PLATFORM_H_ - -#if defined(_WIN32) || defined(_WIN64) -# define ANGLE_PLATFORM_WINDOWS 1 -#elif defined(__APPLE__) -# define ANGLE_PLATFORM_APPLE 1 -# define ANGLE_PLATFORM_POSIX 1 -#elif defined(__linux__) -# define ANGLE_PLATFORM_LINUX 1 -# define ANGLE_PLATFORM_POSIX 1 -#elif defined(ANDROID) -# define ANGLE_PLATFORM_ANDROID 1 -# define ANGLE_PLATFORM_POSIX 1 -#elif defined(__FreeBSD__) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) || \ - defined(__DragonFly__) || \ - defined(__sun) || \ - defined(__GLIBC__) || \ - defined(__GNU__) || \ - defined(__QNX__) -# define ANGLE_PLATFORM_POSIX 1 -#else -# error Unsupported platform. -#endif - -#ifdef ANGLE_PLATFORM_WINDOWS -# ifndef STRICT -# define STRICT 1 -# endif -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN 1 -# endif -# ifndef NOMINMAX -# define NOMINMAX 1 -# endif - -# include -# include - -# if defined(ANGLE_ENABLE_D3D9) || defined(ANGLE_ENABLE_PERF) -# include -# include -# endif - -# if defined(ANGLE_ENABLE_D3D11) -# include -# include -# include -# include -# include -# endif - -# undef near -# undef far -#endif - -#endif // COMMON_PLATFORM_H_ diff --git a/gfx/angle/src/common/shadervars.h b/gfx/angle/src/common/shadervars.h index bbbd3fcac442..99187a0dc19d 100644 --- a/gfx/angle/src/common/shadervars.h +++ b/gfx/angle/src/common/shadervars.h @@ -13,14 +13,13 @@ #include #include #include -#include "GLSLANG/ShaderLang.h" -namespace sh +#include +#include + +namespace gl { -// GLenum alias -typedef unsigned int GLenum; - // Varying interpolation qualifier, see section 4.3.9 of the ESSL 3.00.4 spec enum InterpolationType { @@ -40,115 +39,105 @@ enum BlockLayoutType // Base class for all variables defined in shaders, including Varyings, Uniforms, etc struct ShaderVariable { - ShaderVariable(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn) - : type(typeIn), - precision(precisionIn), - name(nameIn), - arraySize(arraySizeIn) - {} - - bool isArray() const { return arraySize > 0; } - unsigned int elementCount() const { return std::max(1u, arraySize); } - GLenum type; GLenum precision; std::string name; unsigned int arraySize; + + ShaderVariable(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn) + : type(typeIn), + precision(precisionIn), + name(nameIn), + arraySize(arraySizeIn) + {} + + bool isArray() const { return arraySize > 0; } + unsigned int elementCount() const { return std::max(1u, arraySize); } }; // Uniform registers (and element indices) are assigned when outputting shader code struct Uniform : public ShaderVariable { + unsigned int registerIndex; + unsigned int elementIndex; // Offset within a register, for struct members + std::vector fields; + Uniform(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, unsigned int registerIndexIn, unsigned int elementIndexIn) - : ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn), - registerIndex(registerIndexIn), - elementIndex(elementIndexIn) + : ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn), + registerIndex(registerIndexIn), + elementIndex(elementIndexIn) {} bool isStruct() const { return !fields.empty(); } - - std::vector fields; - - // HLSL-specific members - unsigned int registerIndex; - unsigned int elementIndex; // Offset within a register, for struct members }; struct Attribute : public ShaderVariable { + int location; + Attribute() - : ShaderVariable((GLenum)0, (GLenum)0, "", 0), - location(-1) + : ShaderVariable(GL_NONE, GL_NONE, "", 0), + location(-1) {} Attribute(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, int locationIn) : ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn), location(locationIn) {} - - int location; }; struct InterfaceBlockField : public ShaderVariable { + bool isRowMajorMatrix; + std::vector fields; + InterfaceBlockField(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, bool isRowMajorMatrix) - : ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn), - isRowMajorMatrix(isRowMajorMatrix) + : ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn), + isRowMajorMatrix(isRowMajorMatrix) {} bool isStruct() const { return !fields.empty(); } - - bool isRowMajorMatrix; - std::vector fields; }; struct Varying : public ShaderVariable { - Varying(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, InterpolationType interpolationIn) - : ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn), - interpolation(interpolationIn) - {} - - bool isStruct() const { return !fields.empty(); } - InterpolationType interpolation; std::vector fields; std::string structName; + + Varying(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, InterpolationType interpolationIn) + : ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn), + interpolation(interpolationIn) + {} + + bool isStruct() const { return !fields.empty(); } }; struct BlockMemberInfo { - BlockMemberInfo(int offset, int arrayStride, int matrixStride, bool isRowMajorMatrix) - : offset(offset), - arrayStride(arrayStride), - matrixStride(matrixStride), - isRowMajorMatrix(isRowMajorMatrix) - {} + int offset; + int arrayStride; + int matrixStride; + bool isRowMajorMatrix; static BlockMemberInfo getDefaultBlockInfo() { return BlockMemberInfo(-1, -1, -1, false); } - int offset; - int arrayStride; - int matrixStride; - bool isRowMajorMatrix; + BlockMemberInfo(int offset, int arrayStride, int matrixStride, bool isRowMajorMatrix) + : offset(offset), + arrayStride(arrayStride), + matrixStride(matrixStride), + isRowMajorMatrix(isRowMajorMatrix) + {} }; typedef std::vector BlockMemberInfoArray; struct InterfaceBlock { - InterfaceBlock(const char *name, unsigned int arraySize, unsigned int registerIndex) - : name(name), - arraySize(arraySize), - layout(BLOCKLAYOUT_SHARED), - registerIndex(registerIndex), - isRowMajorLayout(false) - {} - std::string name; unsigned int arraySize; size_t dataSize; @@ -157,8 +146,15 @@ struct InterfaceBlock std::vector fields; std::vector blockInfo; - // HLSL-specific members unsigned int registerIndex; + + InterfaceBlock(const char *name, unsigned int arraySize, unsigned int registerIndex) + : name(name), + arraySize(arraySize), + layout(BLOCKLAYOUT_SHARED), + registerIndex(registerIndex), + isRowMajorLayout(false) + {} }; } diff --git a/gfx/angle/src/common/tls.cpp b/gfx/angle/src/common/tls.cpp deleted file mode 100644 index 6b7821978557..000000000000 --- a/gfx/angle/src/common/tls.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. -// - -// tls.cpp: Simple cross-platform interface for thread local storage. - -#include "common/tls.h" - -#include - -TLSIndex CreateTLSIndex() -{ - TLSIndex index; - -#ifdef ANGLE_PLATFORM_WINDOWS - index = TlsAlloc(); -#elif defined(ANGLE_PLATFORM_POSIX) - // Create global pool key - if ((pthread_key_create(&index, NULL)) != 0) - { - index = TLS_INVALID_INDEX; - } -#endif - - assert(index != TLS_INVALID_INDEX && "CreateTLSIndex(): Unable to allocate Thread Local Storage"); - return index; -} - -bool DestroyTLSIndex(TLSIndex index) -{ - assert(index != TLS_INVALID_INDEX && "DestroyTLSIndex(): Invalid TLS Index"); - if (index == TLS_INVALID_INDEX) - { - return false; - } - -#ifdef ANGLE_PLATFORM_WINDOWS - return (TlsFree(index) == TRUE); -#elif defined(ANGLE_PLATFORM_POSIX) - return (pthread_key_delete(index) == 0); -#endif -} - -bool SetTLSValue(TLSIndex index, void *value) -{ - assert(index != TLS_INVALID_INDEX && "SetTLSValue(): Invalid TLS Index"); - if (index == TLS_INVALID_INDEX) - { - return false; - } - -#ifdef ANGLE_PLATFORM_WINDOWS - return (TlsSetValue(index, value) == TRUE); -#elif defined(ANGLE_PLATFORM_POSIX) - return (pthread_setspecific(index, value) == 0); -#endif -} - -void *GetTLSValue(TLSIndex index) -{ - assert(index != TLS_INVALID_INDEX && "GetTLSValue(): Invalid TLS Index"); - if (index == TLS_INVALID_INDEX) - { - return NULL; - } - -#ifdef ANGLE_PLATFORM_WINDOWS - return TlsGetValue(index); -#elif defined(ANGLE_PLATFORM_POSIX) - return pthread_getspecific(index); -#endif -} diff --git a/gfx/angle/src/common/tls.h b/gfx/angle/src/common/tls.h deleted file mode 100644 index 4b25fbc597d9..000000000000 --- a/gfx/angle/src/common/tls.h +++ /dev/null @@ -1,33 +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. -// - -// tls.h: Simple cross-platform interface for thread local storage. - -#ifndef COMMON_TLS_H_ -#define COMMON_TLS_H_ - -#include "common/platform.h" - -#ifdef ANGLE_PLATFORM_WINDOWS - typedef DWORD TLSIndex; -# define TLS_INVALID_INDEX (TLS_OUT_OF_INDEXES) -#elif defined(ANGLE_PLATFORM_POSIX) -# include -# include -# include - typedef pthread_key_t TLSIndex; -# define TLS_INVALID_INDEX (static_cast(-1)) -#else -# error Unsupported platform. -#endif - -TLSIndex CreateTLSIndex(); -bool DestroyTLSIndex(TLSIndex index); - -bool SetTLSValue(TLSIndex index, void *value); -void *GetTLSValue(TLSIndex index); - -#endif // COMMON_TLS_H_ diff --git a/gfx/angle/src/common/utilities.cpp b/gfx/angle/src/common/utilities.cpp index f47f8e548dc0..b1e989bbf640 100644 --- a/gfx/angle/src/common/utilities.cpp +++ b/gfx/angle/src/common/utilities.cpp @@ -8,14 +8,17 @@ #include "common/utilities.h" #include "common/mathutil.h" -#include "common/platform.h" + +#if defined(_WIN32) +#include +#endif #include namespace gl { -int VariableComponentCount(GLenum type) +int UniformComponentCount(GLenum type) { switch (type) { @@ -75,7 +78,7 @@ int VariableComponentCount(GLenum type) return 0; } -GLenum VariableComponentType(GLenum type) +GLenum UniformComponentType(GLenum type) { switch(type) { @@ -130,7 +133,7 @@ GLenum VariableComponentType(GLenum type) return GL_NONE; } -size_t VariableComponentSize(GLenum type) +size_t UniformComponentSize(GLenum type) { switch(type) { @@ -144,18 +147,18 @@ size_t VariableComponentSize(GLenum type) return 0; } -size_t VariableInternalSize(GLenum type) +size_t UniformInternalSize(GLenum type) { // Expanded to 4-element vectors - return VariableComponentSize(VariableComponentType(type)) * VariableRowCount(type) * 4; + return UniformComponentSize(UniformComponentType(type)) * VariableRowCount(type) * 4; } -size_t VariableExternalSize(GLenum type) +size_t UniformExternalSize(GLenum type) { - return VariableComponentSize(VariableComponentType(type)) * VariableComponentCount(type); + return UniformComponentSize(UniformComponentType(type)) * UniformComponentCount(type); } -GLenum VariableBoolVectorType(GLenum type) +GLenum UniformBoolVectorType(GLenum type) { switch (type) { @@ -362,7 +365,7 @@ int MatrixComponentCount(GLenum type, bool isRowMajorMatrix) return isRowMajorMatrix ? VariableColumnCount(type) : VariableRowCount(type); } -int VariableRegisterCount(GLenum type) +int AttributeRegisterCount(GLenum type) { return IsMatrixType(type) ? VariableColumnCount(type) : 1; } @@ -392,6 +395,24 @@ bool IsCubemapTextureTarget(GLenum target) return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z); } +bool IsInternalTextureTarget(GLenum target, GLuint clientVersion) +{ + if (clientVersion == 2) + { + return target == GL_TEXTURE_2D || IsCubemapTextureTarget(target); + } + else if (clientVersion == 3) + { + return target == GL_TEXTURE_2D || IsCubemapTextureTarget(target) || + target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY; + } + else + { + UNREACHABLE(); + return false; + } +} + bool IsTriangleMode(GLenum drawMode) { switch (drawMode) @@ -415,7 +436,7 @@ bool IsTriangleMode(GLenum drawMode) std::string getTempPath() { -#ifdef ANGLE_PLATFORM_WINDOWS +#if defined (_WIN32) char path[MAX_PATH]; DWORD pathLen = GetTempPathA(sizeof(path) / sizeof(path[0]), path); if (pathLen == 0) diff --git a/gfx/angle/src/common/utilities.h b/gfx/angle/src/common/utilities.h index 248b1f2761fc..f69e33a79d20 100644 --- a/gfx/angle/src/common/utilities.h +++ b/gfx/angle/src/common/utilities.h @@ -9,31 +9,36 @@ #ifndef LIBGLESV2_UTILITIES_H #define LIBGLESV2_UTILITIES_H -#include "angle_gl.h" +#include +#include +#include +#include + #include #include namespace gl { -int VariableComponentCount(GLenum type); -GLenum VariableComponentType(GLenum type); -size_t VariableComponentSize(GLenum type); -size_t VariableInternalSize(GLenum type); -size_t VariableExternalSize(GLenum type); -GLenum VariableBoolVectorType(GLenum type); +int UniformComponentCount(GLenum type); +GLenum UniformComponentType(GLenum type); +size_t UniformComponentSize(GLenum type); +size_t UniformInternalSize(GLenum type); +size_t UniformExternalSize(GLenum type); +GLenum UniformBoolVectorType(GLenum type); int VariableRowCount(GLenum type); int VariableColumnCount(GLenum type); bool IsSampler(GLenum type); bool IsMatrixType(GLenum type); GLenum TransposeMatrixType(GLenum type); -int VariableRegisterCount(GLenum type); +int AttributeRegisterCount(GLenum type); int MatrixRegisterCount(GLenum type, bool isRowMajorMatrix); int MatrixComponentCount(GLenum type, bool isRowMajorMatrix); int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize); bool IsCubemapTextureTarget(GLenum target); +bool IsInternalTextureTarget(GLenum target, GLuint clientVersion); bool IsTriangleMode(GLenum drawMode); diff --git a/gfx/angle/src/compiler.gypi b/gfx/angle/src/compiler.gypi index f71fa7d1b435..df62d1171f2f 100644 --- a/gfx/angle/src/compiler.gypi +++ b/gfx/angle/src/compiler.gypi @@ -28,6 +28,18 @@ -excludes compiler/translator/ShaderLang.cpp \ -types *.cpp *.h *.y *.l)', ], + 'conditions': + [ + ['OS=="win"', + { + 'msvs_disabled_warnings': [ 4267 ], + 'sources/': [ [ 'exclude', 'compiler/translator/ossource_posix.cpp' ], ], + }, + { # else: posix + 'sources/': [ [ 'exclude', 'compiler/translator/ossource_win.cpp' ], ], + } + ], + ], 'msvs_settings': { 'VCLibrarianTool': diff --git a/gfx/angle/src/compiler/preprocessor/generate_parser.sh b/gfx/angle/src/compiler/preprocessor/generate_parser.sh old mode 100755 new mode 100644 diff --git a/gfx/angle/src/compiler/translator/Compiler.cpp b/gfx/angle/src/compiler/translator/Compiler.cpp index 61c0c4e90885..402715b8af18 100644 --- a/gfx/angle/src/compiler/translator/Compiler.cpp +++ b/gfx/angle/src/compiler/translator/Compiler.cpp @@ -5,7 +5,6 @@ // #include "compiler/translator/BuiltInFunctionEmulator.h" -#include "compiler/translator/Compiler.h" #include "compiler/translator/DetectCallDepth.h" #include "compiler/translator/ForLoopUnroll.h" #include "compiler/translator/Initialize.h" @@ -13,6 +12,7 @@ #include "compiler/translator/InitializeVariables.h" #include "compiler/translator/ParseContext.h" #include "compiler/translator/RenameFunction.h" +#include "compiler/translator/ShHandle.h" #include "compiler/translator/UnfoldShortCircuitAST.h" #include "compiler/translator/ValidateLimitations.h" #include "compiler/translator/ValidateOutputs.h" diff --git a/gfx/angle/src/compiler/translator/ConstantUnion.h b/gfx/angle/src/compiler/translator/ConstantUnion.h index 5e86c64805c4..5fdba61546c1 100644 --- a/gfx/angle/src/compiler/translator/ConstantUnion.h +++ b/gfx/angle/src/compiler/translator/ConstantUnion.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -18,67 +18,6 @@ public: type = EbtVoid; } - bool cast(TBasicType newType, const ConstantUnion &constant) - { - switch (newType) - { - case EbtFloat: - switch (constant.type) - { - case EbtInt: setFConst(static_cast(constant.getIConst())); break; - case EbtUInt: setFConst(static_cast(constant.getUConst())); break; - case EbtBool: setFConst(static_cast(constant.getBConst())); break; - case EbtFloat: setFConst(static_cast(constant.getFConst())); break; - default: return false; - } - break; - case EbtInt: - switch (constant.type) - { - case EbtInt: setIConst(static_cast(constant.getIConst())); break; - case EbtUInt: setIConst(static_cast(constant.getUConst())); break; - case EbtBool: setIConst(static_cast(constant.getBConst())); break; - case EbtFloat: setIConst(static_cast(constant.getFConst())); break; - default: return false; - } - break; - case EbtUInt: - switch (constant.type) - { - case EbtInt: setUConst(static_cast(constant.getIConst())); break; - case EbtUInt: setUConst(static_cast(constant.getUConst())); break; - case EbtBool: setUConst(static_cast(constant.getBConst())); break; - case EbtFloat: setUConst(static_cast(constant.getFConst())); break; - default: return false; - } - break; - case EbtBool: - switch (constant.type) - { - case EbtInt: setBConst(constant.getIConst() != 0); break; - case EbtUInt: setBConst(constant.getUConst() != 0); break; - case EbtBool: setBConst(constant.getBConst()); break; - case EbtFloat: setBConst(constant.getFConst() != 0.0f); break; - default: return false; - } - break; - case EbtStruct: // Struct fields don't get cast - switch (constant.type) - { - case EbtInt: setIConst(constant.getIConst()); break; - case EbtUInt: setUConst(constant.getUConst()); break; - case EbtBool: setBConst(constant.getBConst()); break; - case EbtFloat: setFConst(constant.getFConst()); break; - default: return false; - } - break; - default: - return false; - } - - return true; - } - void setIConst(int i) {iConst = i; type = EbtInt; } void setUConst(unsigned int u) { uConst = u; type = EbtUInt; } void setFConst(float f) {fConst = f; type = EbtFloat; } diff --git a/gfx/angle/src/compiler/translator/Initialize.cpp b/gfx/angle/src/compiler/translator/Initialize.cpp index e542a3f22322..27e96f4014a2 100644 --- a/gfx/angle/src/compiler/translator/Initialize.cpp +++ b/gfx/angle/src/compiler/translator/Initialize.cpp @@ -566,10 +566,10 @@ void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltI fields->push_back(diff); TStructure *depthRangeStruct = new TStructure(NewPoolTString("gl_DepthRangeParameters"), fields); TVariable *depthRangeParameters = new TVariable(&depthRangeStruct->name(), depthRangeStruct, true); - symbolTable.insert(COMMON_BUILTINS, depthRangeParameters); + symbolTable.insert(COMMON_BUILTINS, *depthRangeParameters); TVariable *depthRange = new TVariable(NewPoolTString("gl_DepthRange"), TType(depthRangeStruct)); depthRange->setQualifier(EvqUniform); - symbolTable.insert(COMMON_BUILTINS, depthRange); + symbolTable.insert(COMMON_BUILTINS, *depthRange); // // Implementation dependent built-in constants. @@ -604,31 +604,31 @@ void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec, // switch(type) { case SH_FRAGMENT_SHADER: - symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4))); - symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1))); - symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointCoord"), TType(EbtFloat, EbpMedium, EvqPointCoord, 2))); + symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4))); + symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1))); + symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_PointCoord"), TType(EbtFloat, EbpMedium, EvqPointCoord, 2))); // // In CSS Shaders, gl_FragColor, gl_FragData, and gl_MaxDrawBuffers are not available. // Instead, css_MixColor and css_ColorMatrix are available. // if (spec != SH_CSS_SHADERS_SPEC) { - symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EbpMedium, EvqFragColor, 4))); - symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData, 4))); + symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EbpMedium, EvqFragColor, 4))); + symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData, 4))); if (resources.EXT_frag_depth) { - symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragDepthEXT"), TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepth, 1))); + symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragDepthEXT"), TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepth, 1))); symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_FragDepthEXT", "GL_EXT_frag_depth"); } } else { - symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("css_MixColor"), TType(EbtFloat, EbpMedium, EvqGlobal, 4))); - symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("css_ColorMatrix"), TType(EbtFloat, EbpMedium, EvqGlobal, 4, 4))); + symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("css_MixColor"), TType(EbtFloat, EbpMedium, EvqGlobal, 4))); + symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("css_ColorMatrix"), TType(EbtFloat, EbpMedium, EvqGlobal, 4, 4))); } break; case SH_VERTEX_SHADER: - symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4))); - symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1))); + symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4))); + symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1))); break; default: assert(false && "Language not supported"); @@ -735,7 +735,7 @@ void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec, // Set up gl_FragData. The array size. TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true); fragData.setArraySize(resources.MaxDrawBuffers); - symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData"), fragData)); + symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData"), fragData)); } break; default: break; diff --git a/gfx/angle/src/compiler/translator/Initialize.h b/gfx/angle/src/compiler/translator/Initialize.h index cf4069797a94..b5642869aa19 100644 --- a/gfx/angle/src/compiler/translator/Initialize.h +++ b/gfx/angle/src/compiler/translator/Initialize.h @@ -8,7 +8,7 @@ #define _INITIALIZE_INCLUDED_ #include "compiler/translator/Common.h" -#include "compiler/translator/Compiler.h" +#include "compiler/translator/ShHandle.h" #include "compiler/translator/SymbolTable.h" void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &table); diff --git a/gfx/angle/src/compiler/translator/InitializeDll.cpp b/gfx/angle/src/compiler/translator/InitializeDll.cpp index c98430662aab..43f81784d0ad 100644 --- a/gfx/angle/src/compiler/translator/InitializeDll.cpp +++ b/gfx/angle/src/compiler/translator/InitializeDll.cpp @@ -5,12 +5,10 @@ // #include "compiler/translator/InitializeDll.h" + #include "compiler/translator/InitializeGlobals.h" #include "compiler/translator/InitializeParseContext.h" - -#include "common/platform.h" - -#include +#include "compiler/translator/osinclude.h" bool InitProcess() { diff --git a/gfx/angle/src/compiler/translator/InitializeParseContext.cpp b/gfx/angle/src/compiler/translator/InitializeParseContext.cpp index c35cedb348be..b4defae56953 100644 --- a/gfx/angle/src/compiler/translator/InitializeParseContext.cpp +++ b/gfx/angle/src/compiler/translator/InitializeParseContext.cpp @@ -6,37 +6,35 @@ #include "compiler/translator/InitializeParseContext.h" -#include "common/tls.h" +#include "compiler/translator/osinclude.h" -#include - -TLSIndex GlobalParseContextIndex = TLS_INVALID_INDEX; +OS_TLSIndex GlobalParseContextIndex = OS_INVALID_TLS_INDEX; bool InitializeParseContextIndex() { - assert(GlobalParseContextIndex == TLS_INVALID_INDEX); + assert(GlobalParseContextIndex == OS_INVALID_TLS_INDEX); - GlobalParseContextIndex = CreateTLSIndex(); - return GlobalParseContextIndex != TLS_INVALID_INDEX; + GlobalParseContextIndex = OS_AllocTLSIndex(); + return GlobalParseContextIndex != OS_INVALID_TLS_INDEX; } void FreeParseContextIndex() { - assert(GlobalParseContextIndex != TLS_INVALID_INDEX); + assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX); - DestroyTLSIndex(GlobalParseContextIndex); - GlobalParseContextIndex = TLS_INVALID_INDEX; + OS_FreeTLSIndex(GlobalParseContextIndex); + GlobalParseContextIndex = OS_INVALID_TLS_INDEX; } void SetGlobalParseContext(TParseContext* context) { - assert(GlobalParseContextIndex != TLS_INVALID_INDEX); - SetTLSValue(GlobalParseContextIndex, context); + assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX); + OS_SetTLSValue(GlobalParseContextIndex, context); } TParseContext* GetGlobalParseContext() { - assert(GlobalParseContextIndex != TLS_INVALID_INDEX); - return static_cast(GetTLSValue(GlobalParseContextIndex)); + assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX); + return static_cast(OS_GetTLSValue(GlobalParseContextIndex)); } diff --git a/gfx/angle/src/compiler/translator/Intermediate.cpp b/gfx/angle/src/compiler/translator/Intermediate.cpp index d207cd8c80c7..9df2afc53c28 100644 --- a/gfx/angle/src/compiler/translator/Intermediate.cpp +++ b/gfx/angle/src/compiler/translator/Intermediate.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -78,6 +78,26 @@ const char* getOperatorString(TOperator op) case EOpPreIncrement: return "++"; case EOpPreDecrement: return "--"; + // Fall-through. + case EOpConvIntToBool: + case EOpConvUIntToBool: + case EOpConvFloatToBool: return "bool"; + + // Fall-through. + case EOpConvBoolToFloat: + case EOpConvUIntToFloat: + case EOpConvIntToFloat: return "float"; + + // Fall-through. + case EOpConvFloatToInt: + case EOpConvUIntToInt: + case EOpConvBoolToInt: return "int"; + + // Fall-through. + case EOpConvIntToUInt: + case EOpConvFloatToUInt: + case EOpConvBoolToUInt: return "uint"; + case EOpRadians: return "radians"; case EOpDegrees: return "degrees"; case EOpSin: return "sin"; @@ -168,9 +188,23 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn default: break; } - if (left->getBasicType() != right->getBasicType()) - { - return 0; + // + // First try converting the children to compatible types. + // + if (left->getType().getStruct() && right->getType().getStruct()) { + if (left->getType() != right->getType()) + return 0; + } else { + TIntermTyped* child = addConversion(op, left->getType(), right); + if (child) + right = child; + else { + child = addConversion(op, right->getType(), left); + if (child) + left = child; + else + return 0; + } } // @@ -207,19 +241,19 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn // TIntermTyped* TIntermediate::addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc& line) { - if (left->getType().getStruct() || right->getType().getStruct()) - { - if (left->getType() != right->getType()) - { - return 0; - } - } - + // + // Like adding binary math, except the conversion can only go + // from right to left. + // TIntermBinary* node = new TIntermBinary(op); node->setLine(line); + TIntermTyped* child = addConversion(op, left->getType(), right); + if (child == 0) + return 0; + node->setLeft(left); - node->setRight(right); + node->setRight(child); if (! node->promote(infoSink)) return 0; @@ -277,6 +311,42 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode, default: break; } + // + // Do we need to promote the operand? + // + // Note: Implicit promotions were removed from the language. + // + TBasicType newType = EbtVoid; + switch (op) { + case EOpConstructInt: newType = EbtInt; break; + case EOpConstructUInt: newType = EbtUInt; break; + case EOpConstructBool: newType = EbtBool; break; + case EOpConstructFloat: newType = EbtFloat; break; + default: break; + } + + if (newType != EbtVoid) { + child = addConversion(op, TType(newType, child->getPrecision(), EvqTemporary, + child->getNominalSize(), + child->getSecondarySize(), + child->isArray()), + child); + if (child == 0) + return 0; + } + + // + // For constructors, we are now done, it's all in the conversion. + // + switch (op) { + case EOpConstructInt: + case EOpConstructUInt: + case EOpConstructBool: + case EOpConstructFloat: + return child; + default: break; + } + TIntermConstantUnion *childTempConstant = 0; if (child->getAsConstantUnion()) childTempConstant = child->getAsConstantUnion(); @@ -339,6 +409,140 @@ TIntermAggregate* TIntermediate::setAggregateOperator(TIntermNode* node, TOperat return aggNode; } +// +// Convert one type to another. +// +// Returns the node representing the conversion, which could be the same +// node passed in if no conversion was needed. +// +// Return 0 if a conversion can't be done. +// +TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TIntermTyped* node) +{ + // + // Does the base type allow operation? + // + if (node->getBasicType() == EbtVoid || + IsSampler(node->getBasicType())) + { + return 0; + } + + // + // Otherwise, if types are identical, no problem + // + if (type == node->getType()) + return node; + + // + // If one's a structure, then no conversions. + // + if (type.getStruct() || node->getType().getStruct()) + return 0; + + // + // If one's an array, then no conversions. + // + if (type.isArray() || node->getType().isArray()) + return 0; + + TBasicType promoteTo; + + switch (op) { + // + // Explicit conversions + // + case EOpConstructBool: + promoteTo = EbtBool; + break; + case EOpConstructFloat: + promoteTo = EbtFloat; + break; + case EOpConstructInt: + promoteTo = EbtInt; + break; + case EOpConstructUInt: + promoteTo = EbtUInt; + break; + default: + // + // implicit conversions were removed from the language. + // + if (type.getBasicType() != node->getType().getBasicType()) + return 0; + // + // Size and structure could still differ, but that's + // handled by operator promotion. + // + return node; + } + + if (node->getAsConstantUnion()) { + + return (promoteConstantUnion(promoteTo, node->getAsConstantUnion())); + } else { + + // + // Add a new newNode for the conversion. + // + TIntermUnary* newNode = 0; + + TOperator newOp = EOpNull; + switch (promoteTo) { + case EbtFloat: + switch (node->getBasicType()) { + case EbtInt: newOp = EOpConvIntToFloat; break; + case EbtUInt: newOp = EOpConvFloatToUInt; break; + case EbtBool: newOp = EOpConvBoolToFloat; break; + default: + infoSink.info.message(EPrefixInternalError, node->getLine(), "Bad promotion node"); + return 0; + } + break; + case EbtBool: + switch (node->getBasicType()) { + case EbtInt: newOp = EOpConvIntToBool; break; + case EbtUInt: newOp = EOpConvBoolToUInt; break; + case EbtFloat: newOp = EOpConvFloatToBool; break; + default: + infoSink.info.message(EPrefixInternalError, node->getLine(), "Bad promotion node"); + return 0; + } + break; + case EbtInt: + switch (node->getBasicType()) { + case EbtUInt: newOp = EOpConvUIntToInt; break; + case EbtBool: newOp = EOpConvBoolToInt; break; + case EbtFloat: newOp = EOpConvFloatToInt; break; + default: + infoSink.info.message(EPrefixInternalError, node->getLine(), "Bad promotion node"); + return 0; + } + break; + case EbtUInt: + switch (node->getBasicType()) { + case EbtInt: newOp = EOpConvIntToUInt; break; + case EbtBool: newOp = EOpConvBoolToUInt; break; + case EbtFloat: newOp = EOpConvFloatToUInt; break; + default: + infoSink.info.message(EPrefixInternalError, node->getLine(), "Bad promotion node"); + return 0; + } + break; + default: + infoSink.info.message(EPrefixInternalError, node->getLine(), "Bad promotion type"); + return 0; + } + + TType type(promoteTo, node->getPrecision(), EvqTemporary, node->getNominalSize(), node->getSecondarySize(), node->isArray()); + newNode = new TIntermUnary(newOp, type); + newNode->setLine(node->getLine()); + newNode->setOperand(node); + + return newNode; + } +} + // // Safe way to combine two nodes into an aggregate. Works with null pointers, // a node that's not a aggregate yet, etc. @@ -436,9 +640,18 @@ TIntermTyped* TIntermediate::addComma(TIntermTyped* left, TIntermTyped* right, c // TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc& line) { - if (trueBlock->getType() != falseBlock->getType()) - { - return 0; + // + // Get compatible types. + // + TIntermTyped* child = addConversion(EOpSequence, trueBlock->getType(), falseBlock); + if (child) + falseBlock = child; + else { + child = addConversion(EOpSequence, falseBlock->getType(), trueBlock); + if (child) + trueBlock = child; + else + return 0; } // @@ -830,9 +1043,7 @@ bool TIntermBinary::promote(TInfoSink& infoSink) // GLSL ES 2.0 does not support implicit type casting. // So the basic type should always match. if (left->getBasicType() != right->getBasicType()) - { return false; - } // // Base assumption: just make the type the same as the left @@ -1513,6 +1724,104 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod } } +TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermConstantUnion* node) +{ + size_t size = node->getType().getObjectSize(); + + ConstantUnion *leftUnionArray = new ConstantUnion[size]; + + for (size_t i=0; i < size; i++) { + + switch (promoteTo) { + case EbtFloat: + switch (node->getType().getBasicType()) { + case EbtInt: + leftUnionArray[i].setFConst(static_cast(node->getIConst(i))); + break; + case EbtUInt: + leftUnionArray[i].setFConst(static_cast(node->getUConst(i))); + break; + case EbtBool: + leftUnionArray[i].setFConst(static_cast(node->getBConst(i))); + break; + case EbtFloat: + leftUnionArray[i].setFConst(static_cast(node->getFConst(i))); + break; + default: + infoSink.info.message(EPrefixInternalError, node->getLine(), "Cannot promote"); + return 0; + } + break; + case EbtInt: + switch (node->getType().getBasicType()) { + case EbtInt: + leftUnionArray[i].setIConst(static_cast(node->getIConst(i))); + break; + case EbtUInt: + leftUnionArray[i].setIConst(static_cast(node->getUConst(i))); + break; + case EbtBool: + leftUnionArray[i].setIConst(static_cast(node->getBConst(i))); + break; + case EbtFloat: + leftUnionArray[i].setIConst(static_cast(node->getFConst(i))); + break; + default: + infoSink.info.message(EPrefixInternalError, node->getLine(), "Cannot promote"); + return 0; + } + break; + case EbtUInt: + switch (node->getType().getBasicType()) { + case EbtInt: + leftUnionArray[i].setUConst(static_cast(node->getIConst(i))); + break; + case EbtUInt: + leftUnionArray[i].setUConst(static_cast(node->getUConst(i))); + break; + case EbtBool: + leftUnionArray[i].setUConst(static_cast(node->getBConst(i))); + break; + case EbtFloat: + leftUnionArray[i].setUConst(static_cast(node->getFConst(i))); + break; + default: + infoSink.info.message(EPrefixInternalError, node->getLine(), "Cannot promote"); + return 0; + } + break; + case EbtBool: + switch (node->getType().getBasicType()) { + case EbtInt: + leftUnionArray[i].setBConst(node->getIConst(i) != 0); + break; + case EbtUInt: + leftUnionArray[i].setBConst(node->getUConst(i) != 0); + break; + case EbtBool: + leftUnionArray[i].setBConst(node->getBConst(i)); + break; + case EbtFloat: + leftUnionArray[i].setBConst(node->getFConst(i) != 0.0f); + break; + default: + infoSink.info.message(EPrefixInternalError, node->getLine(), "Cannot promote"); + return 0; + } + + break; + default: + infoSink.info.message(EPrefixInternalError, node->getLine(), "Incorrect data type found"); + return 0; + } + + } + + const TType& t = node->getType(); + + return addConstantUnion(leftUnionArray, TType(promoteTo, t.getPrecision(), t.getQualifier(), t.getNominalSize(), t.getSecondarySize(), t.isArray()), node->getLine()); +} + // static TString TIntermTraverser::hash(const TString& name, ShHashFunction64 hashFunction) { diff --git a/gfx/angle/src/compiler/translator/OutputGLSLBase.cpp b/gfx/angle/src/compiler/translator/OutputGLSLBase.cpp index d14c70dc43e1..6995594e7606 100644 --- a/gfx/angle/src/compiler/translator/OutputGLSLBase.cpp +++ b/gfx/angle/src/compiler/translator/OutputGLSLBase.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -55,6 +55,8 @@ TOutputGLSLBase::TOutputGLSLBase(TInfoSinkBase &objSink, mSymbolTable(symbolTable), mShaderVersion(shaderVersion) { + // Set up global scope. + mDeclaredStructs.push_back(ScopedDeclaredStructs()); } void TOutputGLSLBase::writeTriplet( @@ -87,14 +89,8 @@ void TOutputGLSLBase::writeVariableType(const TType &type) // Declare the struct if we have not done so already. if (type.getBasicType() == EbtStruct && !structDeclared(type.getStruct())) { - TStructure *structure = type.getStruct(); - - declareStruct(structure); - - if (!structure->name().empty()) - { - mDeclaredStructs.insert(structure->uniqueId()); - } + declareStruct(type.getStruct()); + mDeclaredStructs[mDeclaredStructs.size() - 1].push_back(type.getStruct()); } else { @@ -402,6 +398,67 @@ bool TOutputGLSLBase::visitUnary(Visit visit, TIntermUnary *node) case EOpPreIncrement: preString = "(++"; break; case EOpPreDecrement: preString = "(--"; break; + case EOpConvIntToBool: + case EOpConvFloatToBool: + switch (node->getOperand()->getType().getNominalSize()) + { + case 1: + preString = "bool("; + break; + case 2: + preString = "bvec2("; + break; + case 3: + preString = "bvec3("; + break; + case 4: + preString = "bvec4("; + break; + default: + UNREACHABLE(); + } + break; + case EOpConvBoolToFloat: + case EOpConvIntToFloat: + switch (node->getOperand()->getType().getNominalSize()) + { + case 1: + preString = "float("; + break; + case 2: + preString = "vec2("; + break; + case 3: + preString = "vec3("; + break; + case 4: + preString = "vec4("; + break; + default: + UNREACHABLE(); + } + break; + case EOpConvFloatToInt: + case EOpConvBoolToInt: + switch (node->getOperand()->getType().getNominalSize()) + { + case 1: + preString = "int("; + break; + case 2: + preString = "ivec2("; + break; + case 3: + preString = "ivec3("; + break; + case 4: + preString = "ivec4("; + break; + default: + UNREACHABLE(); + } + break; + case EOpRadians: preString = "radians("; break; @@ -547,6 +604,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node) if (depth > 0) { out << "{\n"; + pushDeclaredStructsScope(); } incrementDepth(node); @@ -565,6 +623,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node) // Scope the sequences except when at the global scope. if (depth > 0) { + popDeclaredStructsScope(); out << "}\n"; } visitChildren = false; @@ -976,12 +1035,17 @@ TString TOutputGLSLBase::hashFunctionName(const TString &mangled_name) bool TOutputGLSLBase::structDeclared(const TStructure *structure) const { ASSERT(structure); - if (structure->name().empty()) + ASSERT(mDeclaredStructs.size() > 0); + for (size_t ii = mDeclaredStructs.size(); ii > 0; --ii) { - return false; + const ScopedDeclaredStructs &scope = mDeclaredStructs[ii - 1]; + for (size_t jj = 0; jj < scope.size(); ++jj) + { + if (scope[jj]->equals(*structure)) + return true; + } } - - return (mDeclaredStructs.count(structure->uniqueId()) > 0); + return false; } void TOutputGLSLBase::declareStruct(const TStructure *structure) @@ -1003,3 +1067,14 @@ void TOutputGLSLBase::declareStruct(const TStructure *structure) out << "}"; } +void TOutputGLSLBase::pushDeclaredStructsScope() +{ + mDeclaredStructs.push_back(ScopedDeclaredStructs()); +} + +void TOutputGLSLBase::popDeclaredStructsScope() +{ + // We should never pop the global scope. + ASSERT(mDeclaredStructs.size() >= 2); + mDeclaredStructs.pop_back(); +} diff --git a/gfx/angle/src/compiler/translator/OutputGLSLBase.h b/gfx/angle/src/compiler/translator/OutputGLSLBase.h index 42364de6f5d5..ae40f85e0d5e 100644 --- a/gfx/angle/src/compiler/translator/OutputGLSLBase.h +++ b/gfx/angle/src/compiler/translator/OutputGLSLBase.h @@ -7,7 +7,7 @@ #ifndef CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ #define CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ -#include +#include #include "compiler/translator/intermediate.h" #include "compiler/translator/LoopInfo.h" @@ -56,14 +56,22 @@ class TOutputGLSLBase : public TIntermTraverser private: bool structDeclared(const TStructure *structure) const; void declareStruct(const TStructure *structure); + void pushDeclaredStructsScope(); + void popDeclaredStructsScope(); void writeBuiltInFunctionTriplet(Visit visit, const char *preStr, bool useEmulatedFunction); TInfoSinkBase &mObjSink; bool mDeclaringVariables; - // This set contains all the ids of the structs from every scope. - std::set mDeclaredStructs; + // Structs are declared as the tree is traversed. This list contains all + // the structs already declared within a scope. It is maintained so that + // a struct is declared only once within a scope. + typedef std::vector ScopedDeclaredStructs; + // This vector contains all the structs from the global scope to the + // current scope. When the traverser exits a scope, the scope is discarded. + typedef std::vector DeclaredStructs; + DeclaredStructs mDeclaredStructs; // Stack of loops that need to be unrolled. TLoopStack mLoopUnrollStack; diff --git a/gfx/angle/src/compiler/translator/OutputHLSL.cpp b/gfx/angle/src/compiler/translator/OutputHLSL.cpp index 5974afb47541..2d7818b64b46 100644 --- a/gfx/angle/src/compiler/translator/OutputHLSL.cpp +++ b/gfx/angle/src/compiler/translator/OutputHLSL.cpp @@ -17,10 +17,6 @@ #include "compiler/translator/FlagStd140Structs.h" #include "compiler/translator/NodeSearch.h" #include "compiler/translator/RewriteElseBlocks.h" -#include "compiler/translator/UtilsHLSL.h" -#include "compiler/translator/util.h" -#include "compiler/translator/UniformHLSL.h" -#include "compiler/translator/StructureHLSL.h" #include #include @@ -73,6 +69,18 @@ TString OutputHLSL::TextureFunction::name() const return name + "("; } +const char *RegisterPrefix(const TType &type) +{ + if (IsSampler(type.getBasicType())) + { + return "s"; + } + else + { + return "c"; + } +} + bool OutputHLSL::TextureFunction::operator<(const TextureFunction &rhs) const { if (sampler < rhs.sampler) return true; @@ -128,6 +136,8 @@ OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resourc mNumRenderTargets = resources.EXT_draw_buffers ? resources.MaxDrawBuffers : 1; + mScopeDepth = 0; + mUniqueIndex = 0; mContainsLoopDiscontinuity = false; @@ -137,32 +147,30 @@ OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resourc mExcessiveLoopIndex = NULL; - mStructureHLSL = new StructureHLSL; - mUniformHLSL = new UniformHLSL(mStructureHLSL, mOutputType); - if (mOutputType == SH_HLSL9_OUTPUT) { if (mContext.shaderType == SH_FRAGMENT_SHADER) { - // Reserve registers for dx_DepthRange, dx_ViewCoords and dx_DepthFront - mUniformHLSL->reserveUniformRegisters(3); + mUniformRegister = 3; // Reserve registers for dx_DepthRange, dx_ViewCoords and dx_DepthFront } else { - // Reserve registers for dx_DepthRange and dx_ViewAdjust - mUniformHLSL->reserveUniformRegisters(2); + mUniformRegister = 2; // Reserve registers for dx_DepthRange and dx_ViewAdjust } } + else + { + mUniformRegister = 0; + } - // Reserve registers for the default uniform block and driver constants - mUniformHLSL->reserveInterfaceBlockRegisters(2); + mSamplerRegister = 0; + mInterfaceBlockRegister = 2; // Reserve registers for the default uniform block and driver constants + mPaddingCounter = 0; } OutputHLSL::~OutputHLSL() { - SafeDelete(mUnfoldShortCircuit); - SafeDelete(mStructureHLSL); - SafeDelete(mUniformHLSL); + delete mUnfoldShortCircuit; } void OutputHLSL::output() @@ -212,27 +220,27 @@ TInfoSinkBase &OutputHLSL::getBodyStream() return mBody; } -const std::vector &OutputHLSL::getUniforms() +const std::vector &OutputHLSL::getUniforms() { - return mUniformHLSL->getUniforms(); + return mActiveUniforms; } -const std::vector &OutputHLSL::getInterfaceBlocks() const +const std::vector &OutputHLSL::getInterfaceBlocks() const { - return mUniformHLSL->getInterfaceBlocks(); + return mActiveInterfaceBlocks; } -const std::vector &OutputHLSL::getOutputVariables() const +const std::vector &OutputHLSL::getOutputVariables() const { return mActiveOutputVariables; } -const std::vector &OutputHLSL::getAttributes() const +const std::vector &OutputHLSL::getAttributes() const { return mActiveAttributes; } -const std::vector &OutputHLSL::getVaryings() const +const std::vector &OutputHLSL::getVaryings() const { return mActiveVaryings; } @@ -245,6 +253,267 @@ int OutputHLSL::vectorSize(const TType &type) const return elementSize * arraySize; } +TString OutputHLSL::interfaceBlockFieldString(const TInterfaceBlock &interfaceBlock, const TField &field) +{ + if (interfaceBlock.hasInstanceName()) + { + return interfaceBlock.name() + "." + field.name(); + } + else + { + return field.name(); + } +} + +TString OutputHLSL::decoratePrivate(const TString &privateText) +{ + return "dx_" + privateText; +} + +TString OutputHLSL::interfaceBlockStructNameString(const TInterfaceBlock &interfaceBlock) +{ + return decoratePrivate(interfaceBlock.name()) + "_type"; +} + +TString OutputHLSL::interfaceBlockInstanceString(const TInterfaceBlock& interfaceBlock, unsigned int arrayIndex) +{ + if (!interfaceBlock.hasInstanceName()) + { + return ""; + } + else if (interfaceBlock.isArray()) + { + return decoratePrivate(interfaceBlock.instanceName()) + "_" + str(arrayIndex); + } + else + { + return decorate(interfaceBlock.instanceName()); + } +} + +TString OutputHLSL::interfaceBlockFieldTypeString(const TField &field, TLayoutBlockStorage blockStorage) +{ + const TType &fieldType = *field.type(); + const TLayoutMatrixPacking matrixPacking = fieldType.getLayoutQualifier().matrixPacking; + ASSERT(matrixPacking != EmpUnspecified); + + if (fieldType.isMatrix()) + { + // Use HLSL row-major packing for GLSL column-major matrices + const TString &matrixPackString = (matrixPacking == EmpRowMajor ? "column_major" : "row_major"); + return matrixPackString + " " + typeString(fieldType); + } + else if (fieldType.getStruct()) + { + // Use HLSL row-major packing for GLSL column-major matrices + return structureTypeName(*fieldType.getStruct(), matrixPacking == EmpColumnMajor, blockStorage == EbsStd140); + } + else + { + return typeString(fieldType); + } +} + +TString OutputHLSL::interfaceBlockFieldString(const TInterfaceBlock &interfaceBlock, TLayoutBlockStorage blockStorage) +{ + TString hlsl; + + int elementIndex = 0; + + for (unsigned int typeIndex = 0; typeIndex < interfaceBlock.fields().size(); typeIndex++) + { + const TField &field = *interfaceBlock.fields()[typeIndex]; + const TType &fieldType = *field.type(); + + if (blockStorage == EbsStd140) + { + // 2 and 3 component vector types in some cases need pre-padding + hlsl += std140PrePaddingString(fieldType, &elementIndex); + } + + hlsl += " " + interfaceBlockFieldTypeString(field, blockStorage) + + " " + decorate(field.name()) + arrayString(fieldType) + ";\n"; + + // must pad out after matrices and arrays, where HLSL usually allows itself room to pack stuff + if (blockStorage == EbsStd140) + { + const bool useHLSLRowMajorPacking = (fieldType.getLayoutQualifier().matrixPacking == EmpColumnMajor); + hlsl += std140PostPaddingString(fieldType, useHLSLRowMajorPacking); + } + } + + return hlsl; +} + +TString OutputHLSL::interfaceBlockStructString(const TInterfaceBlock &interfaceBlock) +{ + const TLayoutBlockStorage blockStorage = interfaceBlock.blockStorage(); + + return "struct " + interfaceBlockStructNameString(interfaceBlock) + "\n" + "{\n" + + interfaceBlockFieldString(interfaceBlock, blockStorage) + + "};\n\n"; +} + +TString OutputHLSL::interfaceBlockString(const TInterfaceBlock &interfaceBlock, unsigned int registerIndex, unsigned int arrayIndex) +{ + const TString &arrayIndexString = (arrayIndex != GL_INVALID_INDEX ? decorate(str(arrayIndex)) : ""); + const TString &blockName = interfaceBlock.name() + arrayIndexString; + TString hlsl; + + hlsl += "cbuffer " + blockName + " : register(b" + str(registerIndex) + ")\n" + "{\n"; + + if (interfaceBlock.hasInstanceName()) + { + hlsl += " " + interfaceBlockStructNameString(interfaceBlock) + " " + interfaceBlockInstanceString(interfaceBlock, arrayIndex) + ";\n"; + } + else + { + const TLayoutBlockStorage blockStorage = interfaceBlock.blockStorage(); + hlsl += interfaceBlockFieldString(interfaceBlock, blockStorage); + } + + hlsl += "};\n\n"; + + return hlsl; +} + +TString OutputHLSL::std140PrePaddingString(const TType &type, int *elementIndex) +{ + if (type.getBasicType() == EbtStruct || type.isMatrix() || type.isArray()) + { + // no padding needed, HLSL will align the field to a new register + *elementIndex = 0; + return ""; + } + + const GLenum glType = glVariableType(type); + const int numComponents = gl::UniformComponentCount(glType); + + if (numComponents >= 4) + { + // no padding needed, HLSL will align the field to a new register + *elementIndex = 0; + return ""; + } + + if (*elementIndex + numComponents > 4) + { + // no padding needed, HLSL will align the field to a new register + *elementIndex = numComponents; + return ""; + } + + TString padding; + + const int alignment = numComponents == 3 ? 4 : numComponents; + const int paddingOffset = (*elementIndex % alignment); + + if (paddingOffset != 0) + { + // padding is neccessary + for (int paddingIndex = paddingOffset; paddingIndex < alignment; paddingIndex++) + { + padding += " float pad_" + str(mPaddingCounter++) + ";\n"; + } + + *elementIndex += (alignment - paddingOffset); + } + + *elementIndex += numComponents; + *elementIndex %= 4; + + return padding; +} + +TString OutputHLSL::std140PostPaddingString(const TType &type, bool useHLSLRowMajorPacking) +{ + if (!type.isMatrix() && !type.isArray() && type.getBasicType() != EbtStruct) + { + return ""; + } + + int numComponents = 0; + + if (type.isMatrix()) + { + // This method can also be called from structureString, which does not use layout qualifiers. + // Thus, use the method parameter for determining the matrix packing. + // + // Note HLSL row major packing corresponds to GL API column-major, and vice-versa, since we + // wish to always transpose GL matrices to play well with HLSL's matrix array indexing. + // + const bool isRowMajorMatrix = !useHLSLRowMajorPacking; + const GLenum glType = glVariableType(type); + numComponents = gl::MatrixComponentCount(glType, isRowMajorMatrix); + } + else if (type.getStruct()) + { + const TString &structName = structureTypeName(*type.getStruct(), useHLSLRowMajorPacking, true); + numComponents = mStd140StructElementIndexes[structName]; + + if (numComponents == 0) + { + return ""; + } + } + else + { + const GLenum glType = glVariableType(type); + numComponents = gl::UniformComponentCount(glType); + } + + TString padding; + for (int paddingOffset = numComponents; paddingOffset < 4; paddingOffset++) + { + padding += " float pad_" + str(mPaddingCounter++) + ";\n"; + } + return padding; +} + +// Use the same layout for packed and shared +void setBlockLayout(gl::InterfaceBlock *interfaceBlock, gl::BlockLayoutType newLayout) +{ + interfaceBlock->layout = newLayout; + interfaceBlock->blockInfo.clear(); + + switch (newLayout) + { + case gl::BLOCKLAYOUT_SHARED: + case gl::BLOCKLAYOUT_PACKED: + { + gl::HLSLBlockEncoder hlslEncoder(&interfaceBlock->blockInfo, gl::HLSLBlockEncoder::ENCODE_PACKED); + hlslEncoder.encodeInterfaceBlockFields(interfaceBlock->fields); + interfaceBlock->dataSize = hlslEncoder.getBlockSize(); + } + break; + + case gl::BLOCKLAYOUT_STANDARD: + { + gl::Std140BlockEncoder stdEncoder(&interfaceBlock->blockInfo); + stdEncoder.encodeInterfaceBlockFields(interfaceBlock->fields); + interfaceBlock->dataSize = stdEncoder.getBlockSize(); + } + break; + + default: + UNREACHABLE(); + break; + } +} + +gl::BlockLayoutType convertBlockLayoutType(TLayoutBlockStorage blockStorage) +{ + switch (blockStorage) + { + case EbsPacked: return gl::BLOCKLAYOUT_PACKED; + case EbsShared: return gl::BLOCKLAYOUT_SHARED; + case EbsStd140: return gl::BLOCKLAYOUT_STANDARD; + default: UNREACHABLE(); return gl::BLOCKLAYOUT_SHARED; + } +} + TString OutputHLSL::structInitializerString(int indent, const TStructure &structure, const TString &rhsStructName) { TString init; @@ -268,7 +537,7 @@ TString OutputHLSL::structInitializerString(int indent, const TStructure &struct for (unsigned int fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++) { const TField &field = *fields[fieldIndex]; - const TString &fieldName = rhsStructName + "." + Decorate(field.name()); + const TString &fieldName = rhsStructName + "." + decorate(field.name()); const TType &fieldType = *field.type(); if (fieldType.getStruct()) @@ -290,10 +559,84 @@ void OutputHLSL::header() { TInfoSinkBase &out = mHeader; + TString uniforms; + TString interfaceBlocks; TString varyings; TString attributes; TString flaggedStructs; + for (ReferencedSymbols::const_iterator uniformIt = mReferencedUniforms.begin(); uniformIt != mReferencedUniforms.end(); uniformIt++) + { + const TIntermSymbol &uniform = *uniformIt->second; + const TType &type = uniform.getType(); + const TString &name = uniform.getSymbol(); + + int registerIndex = declareUniformAndAssignRegister(type, name); + + if (mOutputType == SH_HLSL11_OUTPUT && IsSampler(type.getBasicType())) // Also declare the texture + { + uniforms += "uniform " + samplerString(type) + " sampler_" + decorateUniform(name, type) + arrayString(type) + + " : register(s" + str(registerIndex) + ");\n"; + + uniforms += "uniform " + textureString(type) + " texture_" + decorateUniform(name, type) + arrayString(type) + + " : register(t" + str(registerIndex) + ");\n"; + } + else + { + const TStructure *structure = type.getStruct(); + const TString &typeName = (structure ? structureTypeName(*structure, false, false) : typeString(type)); + + const TString ®isterString = TString("register(") + RegisterPrefix(type) + str(registerIndex) + ")"; + + uniforms += "uniform " + typeName + " " + decorateUniform(name, type) + arrayString(type) + " : " + registerString + ";\n"; + } + } + + for (ReferencedSymbols::const_iterator interfaceBlockIt = mReferencedInterfaceBlocks.begin(); interfaceBlockIt != mReferencedInterfaceBlocks.end(); interfaceBlockIt++) + { + const TType &nodeType = interfaceBlockIt->second->getType(); + const TInterfaceBlock &interfaceBlock = *nodeType.getInterfaceBlock(); + const TFieldList &fieldList = interfaceBlock.fields(); + + unsigned int arraySize = static_cast(interfaceBlock.arraySize()); + gl::InterfaceBlock activeBlock(interfaceBlock.name().c_str(), arraySize, mInterfaceBlockRegister); + for (unsigned int typeIndex = 0; typeIndex < fieldList.size(); typeIndex++) + { + const TField &field = *fieldList[typeIndex]; + const TString &fullUniformName = interfaceBlockFieldString(interfaceBlock, field); + declareInterfaceBlockField(*field.type(), fullUniformName, activeBlock.fields); + } + + mInterfaceBlockRegister += std::max(1u, arraySize); + + gl::BlockLayoutType blockLayoutType = convertBlockLayoutType(interfaceBlock.blockStorage()); + setBlockLayout(&activeBlock, blockLayoutType); + + if (interfaceBlock.matrixPacking() == EmpRowMajor) + { + activeBlock.isRowMajorLayout = true; + } + + mActiveInterfaceBlocks.push_back(activeBlock); + + if (interfaceBlock.hasInstanceName()) + { + interfaceBlocks += interfaceBlockStructString(interfaceBlock); + } + + if (arraySize > 0) + { + for (unsigned int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) + { + interfaceBlocks += interfaceBlockString(interfaceBlock, activeBlock.registerIndex + arrayIndex, arrayIndex); + } + } + else + { + interfaceBlocks += interfaceBlockString(interfaceBlock, activeBlock.registerIndex, GL_INVALID_INDEX); + } + } + for (std::map::const_iterator flaggedStructIt = mFlaggedStructMappedNames.begin(); flaggedStructIt != mFlaggedStructMappedNames.end(); flaggedStructIt++) { TIntermTyped *structNode = flaggedStructIt->first; @@ -301,7 +644,7 @@ void OutputHLSL::header() const TStructure &structure = *structNode->getType().getStruct(); const TString &originalName = mFlaggedStructOriginalNames[structNode]; - flaggedStructs += "static " + Decorate(structure.name()) + " " + mappedName + " =\n"; + flaggedStructs += "static " + decorate(structure.name()) + " " + mappedName + " =\n"; flaggedStructs += structInitializerString(0, structure, originalName); flaggedStructs += "\n"; } @@ -312,8 +655,8 @@ void OutputHLSL::header() const TString &name = varying->second->getSymbol(); // Program linking depends on this exact format - varyings += "static " + InterpolationString(type.getQualifier()) + " " + TypeString(type) + " " + - Decorate(name) + ArrayString(type) + " = " + initializer(type) + ";\n"; + varyings += "static " + interpolationString(type.getQualifier()) + " " + typeString(type) + " " + + decorate(name) + arrayString(type) + " = " + initializer(type) + ";\n"; declareVaryingToList(type, type.getQualifier(), name, mActiveVaryings); } @@ -323,17 +666,22 @@ void OutputHLSL::header() const TType &type = attribute->second->getType(); const TString &name = attribute->second->getSymbol(); - attributes += "static " + TypeString(type) + " " + Decorate(name) + ArrayString(type) + " = " + initializer(type) + ";\n"; + attributes += "static " + typeString(type) + " " + decorate(name) + arrayString(type) + " = " + initializer(type) + ";\n"; - sh::Attribute attributeVar(GLVariableType(type), GLVariablePrecision(type), name.c_str(), + gl::Attribute attributeVar(glVariableType(type), glVariablePrecision(type), name.c_str(), (unsigned int)type.getArraySize(), type.getLayoutQualifier().location); mActiveAttributes.push_back(attributeVar); } - out << mStructureHLSL->structsHeader(); + for (StructDeclarations::iterator structDeclaration = mStructDeclarations.begin(); structDeclaration != mStructDeclarations.end(); structDeclaration++) + { + out << *structDeclaration; + } - out << mUniformHLSL->uniformsHeader(mOutputType, mReferencedUniforms); - out << mUniformHLSL->interfaceBlocksHeader(mReferencedInterfaceBlocks); + for (Constructors::iterator constructor = mConstructors.begin(); constructor != mConstructors.end(); constructor++) + { + out << *constructor; + } if (mUsesDiscardRewriting) { @@ -362,10 +710,10 @@ void OutputHLSL::header() const TType &variableType = outputVariableIt->second->getType(); const TLayoutQualifier &layoutQualifier = variableType.getLayoutQualifier(); - out << "static " + TypeString(variableType) + " out_" + variableName + ArrayString(variableType) + + out << "static " + typeString(variableType) + " out_" + variableName + arrayString(variableType) + " = " + initializer(variableType) + ";\n"; - sh::Attribute outputVar(GLVariableType(variableType), GLVariablePrecision(variableType), variableName.c_str(), + gl::Attribute outputVar(glVariableType(variableType), glVariablePrecision(variableType), variableName.c_str(), (unsigned int)variableType.getArraySize(), layoutQualifier.location); mActiveOutputVariables.push_back(outputVar); } @@ -469,13 +817,22 @@ void OutputHLSL::header() out << "static gl_DepthRangeParameters gl_DepthRange = {dx_DepthRange.x, dx_DepthRange.y, dx_DepthRange.z};\n" "\n"; } + + out << uniforms; + out << "\n"; - if (!flaggedStructs.empty()) + if (!interfaceBlocks.empty()) { - out << "// Std140 Structures accessed by value\n"; - out << "\n"; - out << flaggedStructs; + out << interfaceBlocks; out << "\n"; + + if (!flaggedStructs.empty()) + { + out << "// Std140 Structures accessed by value\n"; + out << "\n"; + out << flaggedStructs; + out << "\n"; + } } if (usingMRTExtension && mNumRenderTargets > 1) @@ -499,7 +856,7 @@ void OutputHLSL::header() out << attributes; out << "\n" "static float4 gl_Position = float4(0, 0, 0, 0);\n"; - + if (mUsesPointSize) { out << "static float gl_PointSize = float(1);\n"; @@ -549,12 +906,21 @@ void OutputHLSL::header() "\n"; } - if (!flaggedStructs.empty()) + out << uniforms; + out << "\n"; + + if (!interfaceBlocks.empty()) { - out << "// Std140 Structures accessed by value\n"; - out << "\n"; - out << flaggedStructs; + out << interfaceBlocks; out << "\n"; + + if (!flaggedStructs.empty()) + { + out << "// Std140 Structures accessed by value\n"; + out << "\n"; + out << flaggedStructs; + out << "\n"; + } } } @@ -1024,7 +1390,7 @@ void OutputHLSL::header() case 3: out << "int4("; break; default: UNREACHABLE(); } - + // Convert from normalized floating-point to integer if (textureFunction->method != TextureFunction::FETCH) { @@ -1059,7 +1425,7 @@ void OutputHLSL::header() } TString proj = ""; // Only used for projected textures - + if (textureFunction->proj) { switch(textureFunction->coords) @@ -1243,7 +1609,7 @@ void OutputHLSL::header() "}\n" "\n"; } - + if (mUsesMod3v) { out << "float3 mod(float3 x, float3 y)\n" @@ -1423,17 +1789,17 @@ void OutputHLSL::visitSymbol(TIntermSymbol *node) mReferencedUniforms[name] = node; } - out << DecorateUniform(name, nodeType); + out << decorateUniform(name, nodeType); } else if (qualifier == EvqAttribute || qualifier == EvqVertexIn) { mReferencedAttributes[name] = node; - out << Decorate(name); + out << decorate(name); } - else if (IsVarying(qualifier)) + else if (isVarying(qualifier)) { mReferencedVaryings[name] = node; - out << Decorate(name); + out << decorate(name); } else if (qualifier == EvqFragmentOut) { @@ -1481,7 +1847,7 @@ void OutputHLSL::visitSymbol(TIntermSymbol *node) } else { - out << Decorate(name); + out << decorate(name); } } } @@ -1547,7 +1913,7 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node) { out << " = mul("; node->getLeft()->traverse(this); - out << ", transpose("; + out << ", transpose("; } else { @@ -1563,7 +1929,7 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node) { out << " = mul("; node->getLeft()->traverse(this); - out << ", "; + out << ", "; } else { @@ -1580,8 +1946,10 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node) { TInterfaceBlock* interfaceBlock = leftType.getInterfaceBlock(); const int arrayIndex = node->getRight()->getAsConstantUnion()->getIConst(0); + mReferencedInterfaceBlocks[interfaceBlock->instanceName()] = node->getLeft()->getAsSymbolNode(); - out << mUniformHLSL->interfaceBlockInstanceString(*interfaceBlock, arrayIndex); + out << interfaceBlockInstanceString(*interfaceBlock, arrayIndex); + return false; } } @@ -1602,7 +1970,7 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node) const TStructure* structure = node->getLeft()->getType().getStruct(); const TIntermConstantUnion* index = node->getRight()->getAsConstantUnion(); const TField* field = structure->fields()[index->getIConst(0)]; - out << "." + DecorateField(field->name(), *structure); + out << "." + decorateField(field->name(), *structure); return false; } @@ -1613,7 +1981,7 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node) const TInterfaceBlock* interfaceBlock = node->getLeft()->getType().getInterfaceBlock(); const TIntermConstantUnion* index = node->getRight()->getAsConstantUnion(); const TField* field = interfaceBlock->fields()[index->getIConst(0)]; - out << "." + Decorate(field->name()); + out << "." + decorate(field->name()); return false; } @@ -1690,9 +2058,9 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node) const TField *field = fields[i]; node->getLeft()->traverse(this); - out << "." + DecorateField(field->name(), structure) + " == "; + out << "." + decorateField(field->name(), structure) + " == "; node->getRight()->traverse(this); - out << "." + DecorateField(field->name(), structure); + out << "." + decorateField(field->name(), structure); if (i < fields.size() - 1) { @@ -1763,13 +2131,61 @@ bool OutputHLSL::visitUnary(Visit visit, TIntermUnary *node) { switch (node->getOp()) { - case EOpNegative: outputTriplet(visit, "(-", "", ")"); break; - case EOpVectorLogicalNot: outputTriplet(visit, "(!", "", ")"); break; - case EOpLogicalNot: outputTriplet(visit, "(!", "", ")"); break; - case EOpPostIncrement: outputTriplet(visit, "(", "", "++)"); break; - case EOpPostDecrement: outputTriplet(visit, "(", "", "--)"); break; - case EOpPreIncrement: outputTriplet(visit, "(++", "", ")"); break; - case EOpPreDecrement: outputTriplet(visit, "(--", "", ")"); break; + case EOpNegative: outputTriplet(visit, "(-", "", ")"); break; + case EOpVectorLogicalNot: outputTriplet(visit, "(!", "", ")"); break; + case EOpLogicalNot: outputTriplet(visit, "(!", "", ")"); break; + case EOpPostIncrement: outputTriplet(visit, "(", "", "++)"); break; + case EOpPostDecrement: outputTriplet(visit, "(", "", "--)"); break; + case EOpPreIncrement: outputTriplet(visit, "(++", "", ")"); break; + case EOpPreDecrement: outputTriplet(visit, "(--", "", ")"); break; + case EOpConvIntToBool: + case EOpConvUIntToBool: + case EOpConvFloatToBool: + switch (node->getOperand()->getType().getNominalSize()) + { + case 1: outputTriplet(visit, "bool(", "", ")"); break; + case 2: outputTriplet(visit, "bool2(", "", ")"); break; + case 3: outputTriplet(visit, "bool3(", "", ")"); break; + case 4: outputTriplet(visit, "bool4(", "", ")"); break; + default: UNREACHABLE(); + } + break; + case EOpConvBoolToFloat: + case EOpConvIntToFloat: + case EOpConvUIntToFloat: + switch (node->getOperand()->getType().getNominalSize()) + { + case 1: outputTriplet(visit, "float(", "", ")"); break; + case 2: outputTriplet(visit, "float2(", "", ")"); break; + case 3: outputTriplet(visit, "float3(", "", ")"); break; + case 4: outputTriplet(visit, "float4(", "", ")"); break; + default: UNREACHABLE(); + } + break; + case EOpConvFloatToInt: + case EOpConvBoolToInt: + case EOpConvUIntToInt: + switch (node->getOperand()->getType().getNominalSize()) + { + case 1: outputTriplet(visit, "int(", "", ")"); break; + case 2: outputTriplet(visit, "int2(", "", ")"); break; + case 3: outputTriplet(visit, "int3(", "", ")"); break; + case 4: outputTriplet(visit, "int4(", "", ")"); break; + default: UNREACHABLE(); + } + break; + case EOpConvFloatToUInt: + case EOpConvBoolToUInt: + case EOpConvIntToUInt: + switch (node->getOperand()->getType().getNominalSize()) + { + case 1: outputTriplet(visit, "uint(", "", ")"); break; + case 2: outputTriplet(visit, "uint2(", "", ")"); break; + case 3: outputTriplet(visit, "uint3(", "", ")"); break; + case 4: outputTriplet(visit, "uint4(", "", ")"); break; + default: UNREACHABLE(); + } + break; case EOpRadians: outputTriplet(visit, "radians(", "", ")"); break; case EOpDegrees: outputTriplet(visit, "degrees(", "", ")"); break; case EOpSin: outputTriplet(visit, "sin(", "", ")"); break; @@ -1841,6 +2257,17 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) { outputLineDirective(node->getLine().first_line); out << "{\n"; + + mScopeDepth++; + + if (mScopeBracket.size() < mScopeDepth) + { + mScopeBracket.push_back(0); // New scope level + } + else + { + mScopeBracket[mScopeDepth - 1]++; // New scope at existing level + } } for (TIntermSequence::iterator sit = node->getSequence().begin(); sit != node->getSequence().end(); sit++) @@ -1856,6 +2283,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) { outputLineDirective(node->getLine().last_line); out << "}\n"; + + mScopeDepth--; } return false; @@ -1868,11 +2297,9 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) if (variable && (variable->getQualifier() == EvqTemporary || variable->getQualifier() == EvqGlobal)) { - TStructure *structure = variable->getType().getStruct(); - - if (structure) + if (variable->getType().getStruct()) { - mStructureHLSL->addConstructor(variable->getType(), StructNameString(*structure), NULL); + addConstructor(variable->getType(), scopedStruct(variable->getType().getStruct()->name()), NULL); } if (!variable->getAsSymbolNode() || variable->getAsSymbolNode()->getSymbol() != "") // Variable declaration @@ -1882,7 +2309,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) out << "static "; } - out << TypeString(variable->getType()) + " "; + out << typeString(variable->getType()) + " "; for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); sit++) { @@ -1891,7 +2318,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) if (symbol) { symbol->traverse(this); - out << ArrayString(symbol->getType()); + out << arrayString(symbol->getType()); out << " = " + initializer(symbol->getType()); } else @@ -1911,7 +2338,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) } else UNREACHABLE(); } - else if (variable && IsVaryingOut(variable->getQualifier())) + else if (variable && isVaryingOut(variable->getQualifier())) { for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); sit++) { @@ -1939,7 +2366,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) case EOpPrototype: if (visit == PreVisit) { - out << TypeString(node->getType()) << " " << Decorate(node->getName()) << (mOutputLod0Function ? "Lod0(" : "("); + out << typeString(node->getType()) << " " << decorate(node->getName()) << (mOutputLod0Function ? "Lod0(" : "("); TIntermSequence &arguments = node->getSequence(); @@ -1977,7 +2404,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) { TString name = TFunction::unmangleName(node->getName()); - out << TypeString(node->getType()) << " "; + out << typeString(node->getType()) << " "; if (name == "main") { @@ -1985,7 +2412,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) } else { - out << Decorate(name) << (mOutputLod0Function ? "Lod0(" : "("); + out << decorate(name) << (mOutputLod0Function ? "Lod0(" : "("); } TIntermSequence &sequence = node->getSequence(); @@ -1997,11 +2424,9 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) if (symbol) { - TStructure *structure = symbol->getType().getStruct(); - - if (structure) + if (symbol->getType().getStruct()) { - mStructureHLSL->addConstructor(symbol->getType(), StructNameString(*structure), NULL); + addConstructor(symbol->getType(), scopedStruct(symbol->getType().getStruct()->name()), NULL); } out << argumentString(symbol); @@ -2016,14 +2441,14 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) out << ")\n" "{\n"; - + if (sequence.size() > 1) { mInsideFunction = true; sequence[1]->traverse(this); mInsideFunction = false; } - + out << "}\n"; if (mContainsLoopDiscontinuity && !mOutputLod0Function) @@ -2047,7 +2472,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) if (node->isUserDefined()) { - out << Decorate(name) << (lod0 ? "Lod0(" : "("); + out << decorate(name) << (lod0 ? "Lod0(" : "("); } else { @@ -2191,32 +2616,86 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) return false; } break; - case EOpParameters: outputTriplet(visit, "(", ", ", ")\n{\n"); break; - case EOpConstructFloat: outputConstructor(visit, node->getType(), "vec1", &node->getSequence()); break; - case EOpConstructVec2: outputConstructor(visit, node->getType(), "vec2", &node->getSequence()); break; - case EOpConstructVec3: outputConstructor(visit, node->getType(), "vec3", &node->getSequence()); break; - case EOpConstructVec4: outputConstructor(visit, node->getType(), "vec4", &node->getSequence()); break; - case EOpConstructBool: outputConstructor(visit, node->getType(), "bvec1", &node->getSequence()); break; - case EOpConstructBVec2: outputConstructor(visit, node->getType(), "bvec2", &node->getSequence()); break; - case EOpConstructBVec3: outputConstructor(visit, node->getType(), "bvec3", &node->getSequence()); break; - case EOpConstructBVec4: outputConstructor(visit, node->getType(), "bvec4", &node->getSequence()); break; - case EOpConstructInt: outputConstructor(visit, node->getType(), "ivec1", &node->getSequence()); break; - case EOpConstructIVec2: outputConstructor(visit, node->getType(), "ivec2", &node->getSequence()); break; - case EOpConstructIVec3: outputConstructor(visit, node->getType(), "ivec3", &node->getSequence()); break; - case EOpConstructIVec4: outputConstructor(visit, node->getType(), "ivec4", &node->getSequence()); break; - case EOpConstructUInt: outputConstructor(visit, node->getType(), "uvec1", &node->getSequence()); break; - case EOpConstructUVec2: outputConstructor(visit, node->getType(), "uvec2", &node->getSequence()); break; - case EOpConstructUVec3: outputConstructor(visit, node->getType(), "uvec3", &node->getSequence()); break; - case EOpConstructUVec4: outputConstructor(visit, node->getType(), "uvec4", &node->getSequence()); break; - case EOpConstructMat2: outputConstructor(visit, node->getType(), "mat2", &node->getSequence()); break; - case EOpConstructMat3: outputConstructor(visit, node->getType(), "mat3", &node->getSequence()); break; - case EOpConstructMat4: outputConstructor(visit, node->getType(), "mat4", &node->getSequence()); break; + case EOpParameters: outputTriplet(visit, "(", ", ", ")\n{\n"); break; + case EOpConstructFloat: + addConstructor(node->getType(), "vec1", &node->getSequence()); + outputTriplet(visit, "vec1(", "", ")"); + break; + case EOpConstructVec2: + addConstructor(node->getType(), "vec2", &node->getSequence()); + outputTriplet(visit, "vec2(", ", ", ")"); + break; + case EOpConstructVec3: + addConstructor(node->getType(), "vec3", &node->getSequence()); + outputTriplet(visit, "vec3(", ", ", ")"); + break; + case EOpConstructVec4: + addConstructor(node->getType(), "vec4", &node->getSequence()); + outputTriplet(visit, "vec4(", ", ", ")"); + break; + case EOpConstructBool: + addConstructor(node->getType(), "bvec1", &node->getSequence()); + outputTriplet(visit, "bvec1(", "", ")"); + break; + case EOpConstructBVec2: + addConstructor(node->getType(), "bvec2", &node->getSequence()); + outputTriplet(visit, "bvec2(", ", ", ")"); + break; + case EOpConstructBVec3: + addConstructor(node->getType(), "bvec3", &node->getSequence()); + outputTriplet(visit, "bvec3(", ", ", ")"); + break; + case EOpConstructBVec4: + addConstructor(node->getType(), "bvec4", &node->getSequence()); + outputTriplet(visit, "bvec4(", ", ", ")"); + break; + case EOpConstructInt: + addConstructor(node->getType(), "ivec1", &node->getSequence()); + outputTriplet(visit, "ivec1(", "", ")"); + break; + case EOpConstructIVec2: + addConstructor(node->getType(), "ivec2", &node->getSequence()); + outputTriplet(visit, "ivec2(", ", ", ")"); + break; + case EOpConstructIVec3: + addConstructor(node->getType(), "ivec3", &node->getSequence()); + outputTriplet(visit, "ivec3(", ", ", ")"); + break; + case EOpConstructIVec4: + addConstructor(node->getType(), "ivec4", &node->getSequence()); + outputTriplet(visit, "ivec4(", ", ", ")"); + break; + case EOpConstructUInt: + addConstructor(node->getType(), "uvec1", &node->getSequence()); + outputTriplet(visit, "uvec1(", "", ")"); + break; + case EOpConstructUVec2: + addConstructor(node->getType(), "uvec2", &node->getSequence()); + outputTriplet(visit, "uvec2(", ", ", ")"); + break; + case EOpConstructUVec3: + addConstructor(node->getType(), "uvec3", &node->getSequence()); + outputTriplet(visit, "uvec3(", ", ", ")"); + break; + case EOpConstructUVec4: + addConstructor(node->getType(), "uvec4", &node->getSequence()); + outputTriplet(visit, "uvec4(", ", ", ")"); + break; + case EOpConstructMat2: + addConstructor(node->getType(), "mat2", &node->getSequence()); + outputTriplet(visit, "mat2(", ", ", ")"); + break; + case EOpConstructMat3: + addConstructor(node->getType(), "mat3", &node->getSequence()); + outputTriplet(visit, "mat3(", ", ", ")"); + break; + case EOpConstructMat4: + addConstructor(node->getType(), "mat4", &node->getSequence()); + outputTriplet(visit, "mat4(", ", ", ")"); + break; case EOpConstructStruct: - { - const TString &structName = StructNameString(*node->getType().getStruct()); - mStructureHLSL->addConstructor(node->getType(), structName, &node->getSequence()); - outputTriplet(visit, structName + "_ctor(", ", ", ")"); - } + addConstructor(node->getType(), scopedStruct(node->getType().getStruct()->name()), &node->getSequence()); + outputTriplet(visit, structLookup(node->getType().getStruct()->name()) + "_ctor(", ", ", ")"); break; case EOpLessThan: outputTriplet(visit, "(", " < ", ")"); break; case EOpGreaterThan: outputTriplet(visit, "(", " > ", ")"); break; @@ -2276,7 +2755,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) case 4: mUsesFaceforward4 = true; break; default: UNREACHABLE(); } - + outputTriplet(visit, "faceforward(", ", ", ")"); } break; @@ -2306,7 +2785,7 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node) node->getCondition()->traverse(this); out << ")\n"; - + outputLineDirective(node->getLine().first_line); out << "{\n"; @@ -2389,7 +2868,7 @@ bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node) else { out << "{for("; - + if (node->getInit()) { node->getInit()->traverse(this); @@ -2410,7 +2889,7 @@ bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node) } out << ")\n"; - + outputLineDirective(node->getLine().first_line); out << "{\n"; } @@ -2585,7 +3064,7 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node) if (index != NULL && node->getCondition()) { TIntermBinary *test = node->getCondition()->getAsBinaryNode(); - + if (test && test->getLeft()->getAsSymbolNode()->getId() == index->getId()) { TIntermConstantUnion *constant = test->getRight()->getAsConstantUnion(); @@ -2606,7 +3085,7 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node) { TIntermBinary *binaryTerminal = node->getExpression()->getAsBinaryNode(); TIntermUnary *unaryTerminal = node->getExpression()->getAsUnaryNode(); - + if (binaryTerminal) { TOperator op = binaryTerminal->getOp(); @@ -2686,7 +3165,7 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node) { mExcessiveLoopIndex = NULL; // Stops setting the Break flag } - + // for(int index = initial; index < clampedLimit; index += increment) out << "for("; @@ -2704,7 +3183,7 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node) out << " += "; out << increment; out << ")\n"; - + outputLineDirective(node->getLine().first_line); out << "{\n"; @@ -2726,7 +3205,7 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node) initial += MAX_LOOP_ITERATIONS * increment; iterations -= MAX_LOOP_ITERATIONS; } - + out << "}"; mExcessiveLoopIndex = restoreIndex; @@ -2768,7 +3247,7 @@ void OutputHLSL::outputLineDirective(int line) { mBody << " \"" << mContext.sourcePath << "\""; } - + mBody << "\n"; } } @@ -2785,16 +3264,181 @@ TString OutputHLSL::argumentString(const TIntermSymbol *symbol) } else { - name = Decorate(name); + name = decorate(name); } if (mOutputType == SH_HLSL11_OUTPUT && IsSampler(type.getBasicType())) { - return QualifierString(qualifier) + " " + TextureString(type) + " texture_" + name + ArrayString(type) + ", " + - QualifierString(qualifier) + " " + SamplerString(type) + " sampler_" + name + ArrayString(type); + return qualifierString(qualifier) + " " + textureString(type) + " texture_" + name + arrayString(type) + ", " + + qualifierString(qualifier) + " " + samplerString(type) + " sampler_" + name + arrayString(type); } - return QualifierString(qualifier) + " " + TypeString(type) + " " + name + ArrayString(type); + return qualifierString(qualifier) + " " + typeString(type) + " " + name + arrayString(type); +} + +TString OutputHLSL::interpolationString(TQualifier qualifier) +{ + switch(qualifier) + { + case EvqVaryingIn: return ""; + case EvqFragmentIn: return ""; + case EvqInvariantVaryingIn: return ""; + case EvqSmoothIn: return "linear"; + case EvqFlatIn: return "nointerpolation"; + case EvqCentroidIn: return "centroid"; + case EvqVaryingOut: return ""; + case EvqVertexOut: return ""; + case EvqInvariantVaryingOut: return ""; + case EvqSmoothOut: return "linear"; + case EvqFlatOut: return "nointerpolation"; + case EvqCentroidOut: return "centroid"; + default: UNREACHABLE(); + } + + return ""; +} + +TString OutputHLSL::qualifierString(TQualifier qualifier) +{ + switch(qualifier) + { + case EvqIn: return "in"; + case EvqOut: return "inout"; // 'out' results in an HLSL error if not all fields are written, for GLSL it's undefined + case EvqInOut: return "inout"; + case EvqConstReadOnly: return "const"; + default: UNREACHABLE(); + } + + return ""; +} + +TString OutputHLSL::typeString(const TType &type) +{ + const TStructure* structure = type.getStruct(); + if (structure) + { + const TString& typeName = structure->name(); + if (typeName != "") + { + return structLookup(typeName); + } + else // Nameless structure, define in place + { + return structureString(*structure, false, false); + } + } + else if (type.isMatrix()) + { + int cols = type.getCols(); + int rows = type.getRows(); + return "float" + str(cols) + "x" + str(rows); + } + else + { + switch (type.getBasicType()) + { + case EbtFloat: + switch (type.getNominalSize()) + { + case 1: return "float"; + case 2: return "float2"; + case 3: return "float3"; + case 4: return "float4"; + } + case EbtInt: + switch (type.getNominalSize()) + { + case 1: return "int"; + case 2: return "int2"; + case 3: return "int3"; + case 4: return "int4"; + } + case EbtUInt: + switch (type.getNominalSize()) + { + case 1: return "uint"; + case 2: return "uint2"; + case 3: return "uint3"; + case 4: return "uint4"; + } + case EbtBool: + switch (type.getNominalSize()) + { + case 1: return "bool"; + case 2: return "bool2"; + case 3: return "bool3"; + case 4: return "bool4"; + } + case EbtVoid: + return "void"; + case EbtSampler2D: + case EbtISampler2D: + case EbtUSampler2D: + case EbtSampler2DArray: + case EbtISampler2DArray: + case EbtUSampler2DArray: + return "sampler2D"; + case EbtSamplerCube: + case EbtISamplerCube: + case EbtUSamplerCube: + return "samplerCUBE"; + case EbtSamplerExternalOES: + return "sampler2D"; + default: + break; + } + } + + UNREACHABLE(); + return ""; +} + +TString OutputHLSL::textureString(const TType &type) +{ + switch (type.getBasicType()) + { + case EbtSampler2D: return "Texture2D"; + case EbtSamplerCube: return "TextureCube"; + case EbtSamplerExternalOES: return "Texture2D"; + case EbtSampler2DArray: return "Texture2DArray"; + case EbtSampler3D: return "Texture3D"; + case EbtISampler2D: return "Texture2D"; + case EbtISampler3D: return "Texture3D"; + case EbtISamplerCube: return "Texture2DArray"; + case EbtISampler2DArray: return "Texture2DArray"; + case EbtUSampler2D: return "Texture2D"; + case EbtUSampler3D: return "Texture3D"; + case EbtUSamplerCube: return "Texture2DArray"; + case EbtUSampler2DArray: return "Texture2DArray"; + case EbtSampler2DShadow: return "Texture2D"; + case EbtSamplerCubeShadow: return "TextureCube"; + case EbtSampler2DArrayShadow: return "Texture2DArray"; + default: UNREACHABLE(); + } + + return ""; +} + +TString OutputHLSL::samplerString(const TType &type) +{ + if (IsShadowSampler(type.getBasicType())) + { + return "SamplerComparisonState"; + } + else + { + return "SamplerState"; + } +} + +TString OutputHLSL::arrayString(const TType &type) +{ + if (!type.isArray()) + { + return ""; + } + + return "[" + str(type.getArraySize()) + "]"; } TString OutputHLSL::initializer(const TType &type) @@ -2815,24 +3459,292 @@ TString OutputHLSL::initializer(const TType &type) return "{" + string + "}"; } -void OutputHLSL::outputConstructor(Visit visit, const TType &type, const TString &name, const TIntermSequence *parameters) +TString OutputHLSL::structureString(const TStructure &structure, bool useHLSLRowMajorPacking, bool useStd140Packing) { - TInfoSinkBase &out = mBody; + const TFieldList &fields = structure.fields(); + const bool isNameless = (structure.name() == ""); + const TString &structName = structureTypeName(structure, useHLSLRowMajorPacking, useStd140Packing); + const TString declareString = (isNameless ? "struct" : "struct " + structName); - if (visit == PreVisit) - { - mStructureHLSL->addConstructor(type, name, parameters); + TString string; + string += declareString + "\n" + "{\n"; - out << name + "("; - } - else if (visit == InVisit) + int elementIndex = 0; + + for (unsigned int i = 0; i < fields.size(); i++) { - out << ", "; + const TField &field = *fields[i]; + const TType &fieldType = *field.type(); + const TStructure *fieldStruct = fieldType.getStruct(); + const TString &fieldTypeString = fieldStruct ? structureTypeName(*fieldStruct, useHLSLRowMajorPacking, useStd140Packing) : typeString(fieldType); + + if (useStd140Packing) + { + string += std140PrePaddingString(*field.type(), &elementIndex); + } + + string += " " + fieldTypeString + " " + decorateField(field.name(), structure) + arrayString(fieldType) + ";\n"; + + if (useStd140Packing) + { + string += std140PostPaddingString(*field.type(), useHLSLRowMajorPacking); + } } - else if (visit == PostVisit) + + // Nameless structs do not finish with a semicolon and newline, to leave room for an instance variable + string += (isNameless ? "} " : "};\n"); + + // Add remaining element index to the global map, for use with nested structs in standard layouts + if (useStd140Packing) { - out << ")"; + mStd140StructElementIndexes[structName] = elementIndex; } + + return string; +} + +TString OutputHLSL::structureTypeName(const TStructure &structure, bool useHLSLRowMajorPacking, bool useStd140Packing) +{ + if (structure.name() == "") + { + return ""; + } + + TString prefix = ""; + + // Structs packed with row-major matrices in HLSL are prefixed with "rm" + // GLSL column-major maps to HLSL row-major, and the converse is true + + if (useStd140Packing) + { + prefix += "std"; + } + + if (useHLSLRowMajorPacking) + { + if (prefix != "") prefix += "_"; + prefix += "rm"; + } + + return prefix + structLookup(structure.name()); +} + +void OutputHLSL::addConstructor(const TType &type, const TString &name, const TIntermSequence *parameters) +{ + if (name == "") + { + return; // Nameless structures don't have constructors + } + + if (type.getStruct() && mStructNames.find(decorate(name)) != mStructNames.end()) + { + return; // Already added + } + + TType ctorType = type; + ctorType.clearArrayness(); + ctorType.setPrecision(EbpHigh); + ctorType.setQualifier(EvqTemporary); + + TString ctorName = type.getStruct() ? decorate(name) : name; + + typedef std::vector ParameterArray; + ParameterArray ctorParameters; + + const TStructure* structure = type.getStruct(); + if (structure) + { + mStructNames.insert(decorate(name)); + + const TString &structString = structureString(*structure, false, false); + + if (std::find(mStructDeclarations.begin(), mStructDeclarations.end(), structString) == mStructDeclarations.end()) + { + // Add row-major packed struct for interface blocks + TString rowMajorString = "#pragma pack_matrix(row_major)\n" + + structureString(*structure, true, false) + + "#pragma pack_matrix(column_major)\n"; + + TString std140String = structureString(*structure, false, true); + TString std140RowMajorString = "#pragma pack_matrix(row_major)\n" + + structureString(*structure, true, true) + + "#pragma pack_matrix(column_major)\n"; + + mStructDeclarations.push_back(structString); + mStructDeclarations.push_back(rowMajorString); + mStructDeclarations.push_back(std140String); + mStructDeclarations.push_back(std140RowMajorString); + } + + const TFieldList &fields = structure->fields(); + for (unsigned int i = 0; i < fields.size(); i++) + { + ctorParameters.push_back(*fields[i]->type()); + } + } + else if (parameters) + { + for (TIntermSequence::const_iterator parameter = parameters->begin(); parameter != parameters->end(); parameter++) + { + ctorParameters.push_back((*parameter)->getAsTyped()->getType()); + } + } + else UNREACHABLE(); + + TString constructor; + + if (ctorType.getStruct()) + { + constructor += ctorName + " " + ctorName + "_ctor("; + } + else // Built-in type + { + constructor += typeString(ctorType) + " " + ctorName + "("; + } + + for (unsigned int parameter = 0; parameter < ctorParameters.size(); parameter++) + { + const TType &type = ctorParameters[parameter]; + + constructor += typeString(type) + " x" + str(parameter) + arrayString(type); + + if (parameter < ctorParameters.size() - 1) + { + constructor += ", "; + } + } + + constructor += ")\n" + "{\n"; + + if (ctorType.getStruct()) + { + constructor += " " + ctorName + " structure = {"; + } + else + { + constructor += " return " + typeString(ctorType) + "("; + } + + if (ctorType.isMatrix() && ctorParameters.size() == 1) + { + int rows = ctorType.getRows(); + int cols = ctorType.getCols(); + const TType ¶meter = ctorParameters[0]; + + if (parameter.isScalar()) + { + for (int row = 0; row < rows; row++) + { + for (int col = 0; col < cols; col++) + { + constructor += TString((row == col) ? "x0" : "0.0"); + + if (row < rows - 1 || col < cols - 1) + { + constructor += ", "; + } + } + } + } + else if (parameter.isMatrix()) + { + for (int row = 0; row < rows; row++) + { + for (int col = 0; col < cols; col++) + { + if (row < parameter.getRows() && col < parameter.getCols()) + { + constructor += TString("x0") + "[" + str(row) + "]" + "[" + str(col) + "]"; + } + else + { + constructor += TString((row == col) ? "1.0" : "0.0"); + } + + if (row < rows - 1 || col < cols - 1) + { + constructor += ", "; + } + } + } + } + else UNREACHABLE(); + } + else + { + size_t remainingComponents = ctorType.getObjectSize(); + size_t parameterIndex = 0; + + while (remainingComponents > 0) + { + const TType ¶meter = ctorParameters[parameterIndex]; + const size_t parameterSize = parameter.getObjectSize(); + bool moreParameters = parameterIndex + 1 < ctorParameters.size(); + + constructor += "x" + str(parameterIndex); + + if (parameter.isScalar()) + { + remainingComponents -= parameter.getObjectSize(); + } + else if (parameter.isVector()) + { + if (remainingComponents == parameterSize || moreParameters) + { + ASSERT(parameterSize <= remainingComponents); + remainingComponents -= parameterSize; + } + else if (remainingComponents < static_cast(parameter.getNominalSize())) + { + switch (remainingComponents) + { + case 1: constructor += ".x"; break; + case 2: constructor += ".xy"; break; + case 3: constructor += ".xyz"; break; + case 4: constructor += ".xyzw"; break; + default: UNREACHABLE(); + } + + remainingComponents = 0; + } + else UNREACHABLE(); + } + else if (parameter.isMatrix() || parameter.getStruct()) + { + ASSERT(remainingComponents == parameterSize || moreParameters); + ASSERT(parameterSize <= remainingComponents); + + remainingComponents -= parameterSize; + } + else UNREACHABLE(); + + if (moreParameters) + { + parameterIndex++; + } + + if (remainingComponents) + { + constructor += ", "; + } + } + } + + if (ctorType.getStruct()) + { + constructor += "};\n" + " return structure;\n" + "}\n"; + } + else + { + constructor += ");\n" + "}\n"; + } + + mConstructors.insert(constructor); } const ConstantUnion *OutputHLSL::writeConstantUnion(const TType &type, const ConstantUnion *constUnion) @@ -2842,13 +3754,14 @@ const ConstantUnion *OutputHLSL::writeConstantUnion(const TType &type, const Con const TStructure* structure = type.getStruct(); if (structure) { - out << StructNameString(*structure) + "_ctor("; - + out << structLookup(structure->name()) + "_ctor("; + const TFieldList& fields = structure->fields(); for (size_t i = 0; i < fields.size(); i++) { const TType *fieldType = fields[i]->type(); + constUnion = writeConstantUnion(*fieldType, constUnion); if (i != fields.size() - 1) @@ -2863,10 +3776,10 @@ const ConstantUnion *OutputHLSL::writeConstantUnion(const TType &type, const Con { size_t size = type.getObjectSize(); bool writeType = size > 1; - + if (writeType) { - out << TypeString(type) << "("; + out << typeString(type) << "("; } for (size_t i = 0; i < size; i++, constUnion++) @@ -2895,19 +3808,184 @@ const ConstantUnion *OutputHLSL::writeConstantUnion(const TType &type, const Con return constUnion; } -void OutputHLSL::declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector &fieldsOut) +TString OutputHLSL::scopeString(unsigned int depthLimit) +{ + TString string; + + for (unsigned int i = 0; i < mScopeBracket.size() && i < depthLimit; i++) + { + string += "_" + str(mScopeBracket[i]); + } + + return string; +} + +TString OutputHLSL::scopedStruct(const TString &typeName) +{ + if (typeName == "") + { + return typeName; + } + + return typeName + scopeString(mScopeDepth); +} + +TString OutputHLSL::structLookup(const TString &typeName) +{ + for (int depth = mScopeDepth; depth >= 0; depth--) + { + TString scopedName = decorate(typeName + scopeString(depth)); + + for (StructNames::iterator structName = mStructNames.begin(); structName != mStructNames.end(); structName++) + { + if (*structName == scopedName) + { + return scopedName; + } + } + } + + UNREACHABLE(); // Should have found a matching constructor + + return typeName; +} + +TString OutputHLSL::decorate(const TString &string) +{ + if (string.compare(0, 3, "gl_") != 0 && string.compare(0, 3, "dx_") != 0) + { + return "_" + string; + } + + return string; +} + +TString OutputHLSL::decorateUniform(const TString &string, const TType &type) +{ + if (type.getBasicType() == EbtSamplerExternalOES) + { + return "ex_" + string; + } + + return decorate(string); +} + +TString OutputHLSL::decorateField(const TString &string, const TStructure &structure) +{ + if (structure.name().compare(0, 3, "gl_") != 0) + { + return decorate(string); + } + + return string; +} + +void OutputHLSL::declareInterfaceBlockField(const TType &type, const TString &name, std::vector& output) { const TStructure *structure = type.getStruct(); - InterpolationType interpolation = GetInterpolationType(baseTypeQualifier); if (!structure) { - sh::Varying varying(GLVariableType(type), GLVariablePrecision(type), name.c_str(), (unsigned int)type.getArraySize(), interpolation); + const bool isRowMajorMatrix = (type.isMatrix() && type.getLayoutQualifier().matrixPacking == EmpRowMajor); + gl::InterfaceBlockField field(glVariableType(type), glVariablePrecision(type), name.c_str(), + (unsigned int)type.getArraySize(), isRowMajorMatrix); + output.push_back(field); + } + else + { + gl::InterfaceBlockField structField(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), false); + + const TFieldList &fields = structure->fields(); + + for (size_t fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++) + { + TField *field = fields[fieldIndex]; + TType *fieldType = field->type(); + + // make sure to copy matrix packing information + fieldType->setLayoutQualifier(type.getLayoutQualifier()); + + declareInterfaceBlockField(*fieldType, field->name(), structField.fields); + } + + output.push_back(structField); + } +} + +gl::Uniform OutputHLSL::declareUniformToList(const TType &type, const TString &name, int registerIndex, std::vector& output) +{ + const TStructure *structure = type.getStruct(); + + if (!structure) + { + gl::Uniform uniform(glVariableType(type), glVariablePrecision(type), name.c_str(), + (unsigned int)type.getArraySize(), (unsigned int)registerIndex, 0); + output.push_back(uniform); + + return uniform; + } + else + { + gl::Uniform structUniform(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), + (unsigned int)registerIndex, GL_INVALID_INDEX); + + const TFieldList &fields = structure->fields(); + + for (size_t fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++) + { + TField *field = fields[fieldIndex]; + TType *fieldType = field->type(); + + declareUniformToList(*fieldType, field->name(), GL_INVALID_INDEX, structUniform.fields); + } + + // assign register offset information -- this will override the information in any sub-structures. + HLSLVariableGetRegisterInfo(registerIndex, &structUniform, mOutputType); + + output.push_back(structUniform); + + return structUniform; + } +} + +gl::InterpolationType getInterpolationType(TQualifier qualifier) +{ + switch (qualifier) + { + case EvqFlatIn: + case EvqFlatOut: + return gl::INTERPOLATION_FLAT; + + case EvqSmoothIn: + case EvqSmoothOut: + case EvqVertexOut: + case EvqFragmentIn: + case EvqVaryingIn: + case EvqVaryingOut: + return gl::INTERPOLATION_SMOOTH; + + case EvqCentroidIn: + case EvqCentroidOut: + return gl::INTERPOLATION_CENTROID; + + default: UNREACHABLE(); + return gl::INTERPOLATION_SMOOTH; + } +} + +void OutputHLSL::declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector& fieldsOut) +{ + const TStructure *structure = type.getStruct(); + + gl::InterpolationType interpolation = getInterpolationType(baseTypeQualifier); + if (!structure) + { + gl::Varying varying(glVariableType(type), glVariablePrecision(type), name.c_str(), (unsigned int)type.getArraySize(), interpolation); fieldsOut.push_back(varying); } else { - sh::Varying structVarying(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), interpolation); + gl::Varying structVarying(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), interpolation); const TFieldList &fields = structure->fields(); structVarying.structName = structure->name().c_str(); @@ -2922,4 +4000,226 @@ void OutputHLSL::declareVaryingToList(const TType &type, TQualifier baseTypeQual } } +int OutputHLSL::declareUniformAndAssignRegister(const TType &type, const TString &name) +{ + int registerIndex = (IsSampler(type.getBasicType()) ? mSamplerRegister : mUniformRegister); + + const gl::Uniform &uniform = declareUniformToList(type, name, registerIndex, mActiveUniforms); + + if (IsSampler(type.getBasicType())) + { + mSamplerRegister += gl::HLSLVariableRegisterCount(uniform, mOutputType); + } + else + { + mUniformRegister += gl::HLSLVariableRegisterCount(uniform, mOutputType); + } + + return registerIndex; +} + +GLenum OutputHLSL::glVariableType(const TType &type) +{ + if (type.getBasicType() == EbtFloat) + { + if (type.isScalar()) + { + return GL_FLOAT; + } + else if (type.isVector()) + { + switch(type.getNominalSize()) + { + case 2: return GL_FLOAT_VEC2; + case 3: return GL_FLOAT_VEC3; + case 4: return GL_FLOAT_VEC4; + default: UNREACHABLE(); + } + } + else if (type.isMatrix()) + { + switch (type.getCols()) + { + case 2: + switch(type.getRows()) + { + case 2: return GL_FLOAT_MAT2; + case 3: return GL_FLOAT_MAT2x3; + case 4: return GL_FLOAT_MAT2x4; + default: UNREACHABLE(); + } + + case 3: + switch(type.getRows()) + { + case 2: return GL_FLOAT_MAT3x2; + case 3: return GL_FLOAT_MAT3; + case 4: return GL_FLOAT_MAT3x4; + default: UNREACHABLE(); + } + + case 4: + switch(type.getRows()) + { + case 2: return GL_FLOAT_MAT4x2; + case 3: return GL_FLOAT_MAT4x3; + case 4: return GL_FLOAT_MAT4; + default: UNREACHABLE(); + } + + default: UNREACHABLE(); + } + } + else UNREACHABLE(); + } + else if (type.getBasicType() == EbtInt) + { + if (type.isScalar()) + { + return GL_INT; + } + else if (type.isVector()) + { + switch(type.getNominalSize()) + { + case 2: return GL_INT_VEC2; + case 3: return GL_INT_VEC3; + case 4: return GL_INT_VEC4; + default: UNREACHABLE(); + } + } + else UNREACHABLE(); + } + else if (type.getBasicType() == EbtUInt) + { + if (type.isScalar()) + { + return GL_UNSIGNED_INT; + } + else if (type.isVector()) + { + switch(type.getNominalSize()) + { + case 2: return GL_UNSIGNED_INT_VEC2; + case 3: return GL_UNSIGNED_INT_VEC3; + case 4: return GL_UNSIGNED_INT_VEC4; + default: UNREACHABLE(); + } + } + else UNREACHABLE(); + } + else if (type.getBasicType() == EbtBool) + { + if (type.isScalar()) + { + return GL_BOOL; + } + else if (type.isVector()) + { + switch(type.getNominalSize()) + { + case 2: return GL_BOOL_VEC2; + case 3: return GL_BOOL_VEC3; + case 4: return GL_BOOL_VEC4; + default: UNREACHABLE(); + } + } + else UNREACHABLE(); + } + + switch(type.getBasicType()) + { + case EbtSampler2D: return GL_SAMPLER_2D; + case EbtSampler3D: return GL_SAMPLER_3D; + case EbtSamplerCube: return GL_SAMPLER_CUBE; + case EbtSampler2DArray: return GL_SAMPLER_2D_ARRAY; + case EbtISampler2D: return GL_INT_SAMPLER_2D; + case EbtISampler3D: return GL_INT_SAMPLER_3D; + case EbtISamplerCube: return GL_INT_SAMPLER_CUBE; + case EbtISampler2DArray: return GL_INT_SAMPLER_2D_ARRAY; + case EbtUSampler2D: return GL_UNSIGNED_INT_SAMPLER_2D; + case EbtUSampler3D: return GL_UNSIGNED_INT_SAMPLER_3D; + case EbtUSamplerCube: return GL_UNSIGNED_INT_SAMPLER_CUBE; + case EbtUSampler2DArray: return GL_UNSIGNED_INT_SAMPLER_2D_ARRAY; + case EbtSampler2DShadow: return GL_SAMPLER_2D_SHADOW; + case EbtSamplerCubeShadow: return GL_SAMPLER_CUBE_SHADOW; + case EbtSampler2DArrayShadow: return GL_SAMPLER_2D_ARRAY_SHADOW; + default: UNREACHABLE(); + } + + return GL_NONE; +} + +GLenum OutputHLSL::glVariablePrecision(const TType &type) +{ + if (type.getBasicType() == EbtFloat) + { + switch (type.getPrecision()) + { + case EbpHigh: return GL_HIGH_FLOAT; + case EbpMedium: return GL_MEDIUM_FLOAT; + case EbpLow: return GL_LOW_FLOAT; + case EbpUndefined: + // Should be defined as the default precision by the parser + default: UNREACHABLE(); + } + } + else if (type.getBasicType() == EbtInt || type.getBasicType() == EbtUInt) + { + switch (type.getPrecision()) + { + case EbpHigh: return GL_HIGH_INT; + case EbpMedium: return GL_MEDIUM_INT; + case EbpLow: return GL_LOW_INT; + case EbpUndefined: + // Should be defined as the default precision by the parser + default: UNREACHABLE(); + } + } + + // Other types (boolean, sampler) don't have a precision + return GL_NONE; +} + +bool OutputHLSL::isVaryingOut(TQualifier qualifier) +{ + switch(qualifier) + { + case EvqVaryingOut: + case EvqInvariantVaryingOut: + case EvqSmoothOut: + case EvqFlatOut: + case EvqCentroidOut: + case EvqVertexOut: + return true; + + default: break; + } + + return false; +} + +bool OutputHLSL::isVaryingIn(TQualifier qualifier) +{ + switch(qualifier) + { + case EvqVaryingIn: + case EvqInvariantVaryingIn: + case EvqSmoothIn: + case EvqFlatIn: + case EvqCentroidIn: + case EvqFragmentIn: + return true; + + default: break; + } + + return false; +} + +bool OutputHLSL::isVarying(TQualifier qualifier) +{ + return isVaryingIn(qualifier) || isVaryingOut(qualifier); +} + } diff --git a/gfx/angle/src/compiler/translator/OutputHLSL.h b/gfx/angle/src/compiler/translator/OutputHLSL.h index 4bcc82d16398..55d6441b2310 100644 --- a/gfx/angle/src/compiler/translator/OutputHLSL.h +++ b/gfx/angle/src/compiler/translator/OutputHLSL.h @@ -11,7 +11,9 @@ #include #include -#include "angle_gl.h" +#include +#include + #include "compiler/translator/intermediate.h" #include "compiler/translator/ParseContext.h" #include "common/shadervars.h" @@ -19,10 +21,6 @@ namespace sh { class UnfoldShortCircuit; -class StructureHLSL; -class UniformHLSL; - -typedef std::map ReferencedSymbols; class OutputHLSL : public TIntermTraverser { @@ -33,13 +31,24 @@ class OutputHLSL : public TIntermTraverser void output(); TInfoSinkBase &getBodyStream(); - const std::vector &getUniforms(); - const std::vector &getInterfaceBlocks() const; - const std::vector &getOutputVariables() const; - const std::vector &getAttributes() const; - const std::vector &getVaryings() const; + const std::vector &getUniforms(); + const std::vector &getInterfaceBlocks() const; + const std::vector &getOutputVariables() const; + const std::vector &getAttributes() const; + const std::vector &getVaryings() const; + TString typeString(const TType &type); + TString textureString(const TType &type); + TString samplerString(const TType &type); + TString interpolationString(TQualifier qualifier); + TString structureString(const TStructure &structure, bool useHLSLRowMajorPacking, bool useStd140Packing); + TString structureTypeName(const TStructure &structure, bool useHLSLRowMajorPacking, bool useStd140Packing); + static TString qualifierString(TQualifier qualifier); + static TString arrayString(const TType &type); static TString initializer(const TType &type); + static TString decorate(const TString &string); // Prepends an underscore to avoid naming clashes + static TString decorateUniform(const TString &string, const TType &type); + static TString decorateField(const TString &string, const TStructure &structure); protected: void header(); @@ -62,9 +71,13 @@ class OutputHLSL : public TIntermTraverser TString argumentString(const TIntermSymbol *symbol); int vectorSize(const TType &type) const; - void outputConstructor(Visit visit, const TType &type, const TString &name, const TIntermSequence *parameters); + void addConstructor(const TType &type, const TString &name, const TIntermSequence *parameters); const ConstantUnion *writeConstantUnion(const TType &type, const ConstantUnion *constUnion); + TString scopeString(unsigned int depthLimit); + TString scopedStruct(const TString &typeName); + TString structLookup(const TString &typeName); + TParseContext &mContext; const ShShaderOutput mOutputType; UnfoldShortCircuit *mUnfoldShortCircuit; @@ -75,15 +88,13 @@ class OutputHLSL : public TIntermTraverser TInfoSinkBase mBody; TInfoSinkBase mFooter; + typedef std::map ReferencedSymbols; ReferencedSymbols mReferencedUniforms; ReferencedSymbols mReferencedInterfaceBlocks; ReferencedSymbols mReferencedAttributes; ReferencedSymbols mReferencedVaryings; ReferencedSymbols mReferencedOutputVariables; - StructureHLSL *mStructureHLSL; - UniformHLSL *mUniformHLSL; - struct TextureFunction { enum Method @@ -142,6 +153,19 @@ class OutputHLSL : public TIntermTraverser int mNumRenderTargets; + typedef std::set Constructors; + Constructors mConstructors; + + typedef std::set StructNames; + StructNames mStructNames; + + typedef std::list StructDeclarations; + StructDeclarations mStructDeclarations; + + typedef std::vector ScopeBracket; + ScopeBracket mScopeBracket; + unsigned int mScopeDepth; + int mUniqueIndex; // For creating unique names bool mContainsLoopDiscontinuity; @@ -151,19 +175,51 @@ class OutputHLSL : public TIntermTraverser TIntermSymbol *mExcessiveLoopIndex; - void declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector& fieldsOut); + int mUniformRegister; + int mInterfaceBlockRegister; + int mSamplerRegister; + int mPaddingCounter; + TString registerString(TIntermSymbol *operand); + int samplerRegister(TIntermSymbol *sampler); + int uniformRegister(TIntermSymbol *uniform); + void declareInterfaceBlockField(const TType &type, const TString &name, std::vector& output); + gl::Uniform declareUniformToList(const TType &type, const TString &name, int registerIndex, std::vector& output); + void declareUniform(const TType &type, const TString &name, int index); + void declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector& fieldsOut); + + // Returns the uniform's register index + int declareUniformAndAssignRegister(const TType &type, const TString &name); + + TString interfaceBlockFieldString(const TInterfaceBlock &interfaceBlock, const TField &field); + TString decoratePrivate(const TString &privateText); + TString interfaceBlockStructNameString(const TInterfaceBlock &interfaceBlockType); + TString interfaceBlockInstanceString(const TInterfaceBlock& interfaceBlock, unsigned int arrayIndex); + TString interfaceBlockFieldTypeString(const TField &field, TLayoutBlockStorage blockStorage); + TString interfaceBlockFieldString(const TInterfaceBlock &interfaceBlock, TLayoutBlockStorage blockStorage); + TString interfaceBlockStructString(const TInterfaceBlock &interfaceBlock); + TString interfaceBlockString(const TInterfaceBlock &interfaceBlock, unsigned int registerIndex, unsigned int arrayIndex); + TString std140PrePaddingString(const TType &type, int *elementIndex); + TString std140PostPaddingString(const TType &type, bool useHLSLRowMajorPacking); TString structInitializerString(int indent, const TStructure &structure, const TString &rhsStructName); + + static GLenum glVariableType(const TType &type); + static GLenum glVariablePrecision(const TType &type); + static bool isVaryingIn(TQualifier qualifier); + static bool isVaryingOut(TQualifier qualifier); + static bool isVarying(TQualifier qualifier); - std::vector mActiveOutputVariables; - std::vector mActiveAttributes; - std::vector mActiveVaryings; + std::vector mActiveUniforms; + std::vector mActiveInterfaceBlocks; + std::vector mActiveOutputVariables; + std::vector mActiveAttributes; + std::vector mActiveVaryings; + std::map mStd140StructElementIndexes; std::map mFlaggedStructMappedNames; std::map mFlaggedStructOriginalNames; void makeFlaggedStructMaps(const std::vector &flaggedStructs); }; - } #endif // COMPILER_OUTPUTHLSL_H_ diff --git a/gfx/angle/src/compiler/translator/ParseContext.cpp b/gfx/angle/src/compiler/translator/ParseContext.cpp index 8b3bfed5d2e5..8ff9d30efbad 100644 --- a/gfx/angle/src/compiler/translator/ParseContext.cpp +++ b/gfx/angle/src/compiler/translator/ParseContext.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -701,44 +701,28 @@ bool TParseContext::arraySizeErrorCheck(const TSourceLoc& line, TIntermTyped* ex return true; } - unsigned int unsignedSize = 0; - if (constant->getBasicType() == EbtUInt) { - unsignedSize = constant->getUConst(0); - size = static_cast(unsignedSize); + unsigned int uintSize = constant->getUConst(0); + if (uintSize > static_cast(std::numeric_limits::max())) + { + error(line, "array size too large", ""); + size = 1; + return true; + } + + size = static_cast(uintSize); } else { size = constant->getIConst(0); - if (size < 0) + if (size <= 0) { - error(line, "array size must be non-negative", ""); + error(line, "array size must be a positive integer", ""); size = 1; return true; } - - unsignedSize = static_cast(size); - } - - if (size == 0) - { - error(line, "array size must be greater than zero", ""); - size = 1; - return true; - } - - // The size of arrays is restricted here to prevent issues further down the - // compiler/translator/driver stack. Shader Model 5 generation hardware is limited to - // 4096 registers so this should be reasonable even for aggressively optimizable code. - const unsigned int sizeLimit = 65536; - - if (unsignedSize > sizeLimit) - { - error(line, "array size too large", ""); - size = 1; - return true; } return false; @@ -804,7 +788,7 @@ bool TParseContext::arrayErrorCheck(const TSourceLoc& line, const TString& ident if (type.arraySize) variable->getType().setArraySize(type.arraySize); - if (! symbolTable.declare(variable)) { + if (! symbolTable.declare(*variable)) { delete variable; error(line, "INTERNAL ERROR inserting new symbol", identifier.c_str()); return true; @@ -884,7 +868,7 @@ bool TParseContext::nonInitErrorCheck(const TSourceLoc& line, const TString& ide variable = new TVariable(&identifier, TType(type)); - if (! symbolTable.declare(variable)) { + if (! symbolTable.declare(*variable)) { error(line, "redefinition", variable->getName().c_str()); delete variable; variable = 0; @@ -1066,7 +1050,7 @@ bool TParseContext::executeInitializer(const TSourceLoc& line, const TString& id // add variable to symbol table // variable = new TVariable(&identifier, type); - if (! symbolTable.declare(variable)) { + if (! symbolTable.declare(*variable)) { error(line, "redefinition", variable->getName().c_str()); return true; // don't delete variable, it's used by error recovery, and the pool @@ -1531,40 +1515,81 @@ TFunction *TParseContext::addConstructorFunc(TPublicType publicType) // // Returns 0 for an error or the constructed node (aggregate or typed) for no error. // -TIntermTyped *TParseContext::addConstructor(TIntermNode *arguments, const TType *type, TOperator op, TFunction *fnCall, const TSourceLoc &line) +TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type, TOperator op, TFunction* fnCall, const TSourceLoc& line) { - TIntermAggregate *aggregateArguments = arguments->getAsAggregate(); - - if (!aggregateArguments) - { - aggregateArguments = new TIntermAggregate; - aggregateArguments->getSequence().push_back(arguments); - } + if (node == 0) + return 0; + TIntermAggregate* aggrNode = node->getAsAggregate(); + + TFieldList::const_iterator memberTypes; if (op == EOpConstructStruct) - { - const TFieldList &fields = type->getStruct()->fields(); - TIntermSequence &args = aggregateArguments->getSequence(); + memberTypes = type->getStruct()->fields().begin(); + + TType elementType = *type; + if (type->isArray()) + elementType.clearArrayness(); - for (size_t i = 0; i < fields.size(); i++) - { - if (args[i]->getAsTyped()->getType() != *fields[i]->type()) - { - error(line, "Structure constructor arguments do not match structure fields", "Error"); - recover(); + bool singleArg; + if (aggrNode) { + if (aggrNode->getOp() != EOpNull || aggrNode->getSequence().size() == 1) + singleArg = true; + else + singleArg = false; + } else + singleArg = true; - return 0; - } + TIntermTyped *newNode; + if (singleArg) { + // If structure constructor or array constructor is being called + // for only one parameter inside the structure, we need to call constructStruct function once. + if (type->isArray()) + newNode = constructStruct(node, &elementType, 1, node->getLine(), false); + else if (op == EOpConstructStruct) + newNode = constructStruct(node, (*memberTypes)->type(), 1, node->getLine(), false); + else + newNode = constructBuiltIn(type, op, node, node->getLine(), false); + + if (newNode && newNode->getAsAggregate()) { + TIntermTyped* constConstructor = foldConstConstructor(newNode->getAsAggregate(), *type); + if (constConstructor) + return constConstructor; + } + + return newNode; + } + + // + // Handle list of arguments. + // + TIntermSequence &sequenceVector = aggrNode->getSequence() ; // Stores the information about the parameter to the constructor + // if the structure constructor contains more than one parameter, then construct + // each parameter + + int paramCount = 0; // keeps a track of the constructor parameter number being checked + + // for each parameter to the constructor call, check to see if the right type is passed or convert them + // to the right type if possible (and allowed). + // for structure constructors, just check if the right type is passed, no conversion is allowed. + + for (TIntermSequence::iterator p = sequenceVector.begin(); + p != sequenceVector.end(); p++, paramCount++) { + if (type->isArray()) + newNode = constructStruct(*p, &elementType, paramCount+1, node->getLine(), true); + else if (op == EOpConstructStruct) + newNode = constructStruct(*p, (memberTypes[paramCount])->type(), paramCount+1, node->getLine(), true); + else + newNode = constructBuiltIn(type, op, *p, node->getLine(), true); + + if (newNode) { + *p = newNode; } } - // Turn the argument list itself into a constructor - TIntermTyped *constructor = intermediate.setAggregateOperator(aggregateArguments, op, line); - TIntermTyped *constConstructor = foldConstConstructor(constructor->getAsAggregate(), *type); + TIntermTyped* constructor = intermediate.setAggregateOperator(aggrNode, op, line); + TIntermTyped* constConstructor = foldConstConstructor(constructor->getAsAggregate(), *type); if (constConstructor) - { return constConstructor; - } return constructor; } @@ -1591,6 +1616,102 @@ TIntermTyped* TParseContext::foldConstConstructor(TIntermAggregate* aggrNode, co return 0; } +// Function for constructor implementation. Calls addUnaryMath with appropriate EOp value +// for the parameter to the constructor (passed to this function). Essentially, it converts +// the parameter types correctly. If a constructor expects an int (like ivec2) and is passed a +// float, then float is converted to int. +// +// Returns 0 for an error or the constructed node. +// +TIntermTyped* TParseContext::constructBuiltIn(const TType* type, TOperator op, TIntermNode* node, const TSourceLoc& line, bool subset) +{ + TIntermTyped* newNode; + TOperator basicOp; + + // + // First, convert types as needed. + // + switch (op) { + case EOpConstructVec2: + case EOpConstructVec3: + case EOpConstructVec4: + case EOpConstructMat2: + case EOpConstructMat3: + case EOpConstructMat4: + case EOpConstructFloat: + basicOp = EOpConstructFloat; + break; + + case EOpConstructIVec2: + case EOpConstructIVec3: + case EOpConstructIVec4: + case EOpConstructInt: + basicOp = EOpConstructInt; + break; + + case EOpConstructUVec2: + case EOpConstructUVec3: + case EOpConstructUVec4: + case EOpConstructUInt: + basicOp = EOpConstructUInt; + break; + + case EOpConstructBVec2: + case EOpConstructBVec3: + case EOpConstructBVec4: + case EOpConstructBool: + basicOp = EOpConstructBool; + break; + + default: + error(line, "unsupported construction", ""); + recover(); + + return 0; + } + newNode = intermediate.addUnaryMath(basicOp, node, node->getLine()); + if (newNode == 0) { + error(line, "can't convert", "constructor"); + return 0; + } + + // + // Now, if there still isn't an operation to do the construction, and we need one, add one. + // + + // Otherwise, skip out early. + if (subset || (newNode != node && newNode->getType() == *type)) + return newNode; + + // setAggregateOperator will insert a new node for the constructor, as needed. + return intermediate.setAggregateOperator(newNode, op, line); +} + +// This function tests for the type of the parameters to the structures constructors. Raises +// an error message if the expected type does not match the parameter passed to the constructor. +// +// Returns 0 for an error or the input node itself if the expected and the given parameter types match. +// +TIntermTyped* TParseContext::constructStruct(TIntermNode* node, TType* type, int paramCount, const TSourceLoc& line, bool subset) +{ + if (*type == node->getAsTyped()->getType()) { + if (subset) + return node->getAsTyped(); + else + return intermediate.setAggregateOperator(node->getAsTyped(), EOpConstructStruct, line); + } else { + std::stringstream extraInfoStream; + extraInfoStream << "cannot convert parameter " << paramCount + << " from '" << node->getAsTyped()->getType().getBasicString() + << "' to '" << type->getBasicString() << "'"; + std::string extraInfo = extraInfoStream.str(); + error(line, "", "constructor", extraInfo.c_str()); + recover(); + } + + return 0; +} + // // This function returns the tree representation for the vector field(s) being accessed from contant vector. // If only one component of vector is accessed (v.x or v[0] where v is a contant vector), then a contant node is @@ -1774,7 +1895,7 @@ TIntermAggregate* TParseContext::addInterfaceBlock(const TPublicType& typeQualif } TSymbol* blockNameSymbol = new TInterfaceBlockName(&blockName); - if (!symbolTable.declare(blockNameSymbol)) { + if (!symbolTable.declare(*blockNameSymbol)) { error(nameLine, "redefinition", blockName.c_str(), "interface block name"); recover(); } @@ -1854,7 +1975,7 @@ TIntermAggregate* TParseContext::addInterfaceBlock(const TPublicType& typeQualif TVariable* fieldVariable = new TVariable(&field->name(), *fieldType); fieldVariable->setQualifier(typeQualifier.qualifier); - if (!symbolTable.declare(fieldVariable)) { + if (!symbolTable.declare(*fieldVariable)) { error(field->line(), "redefinition", field->name().c_str(), "interface block member name"); recover(); } @@ -1866,7 +1987,7 @@ TIntermAggregate* TParseContext::addInterfaceBlock(const TPublicType& typeQualif TVariable* instanceTypeDef = new TVariable(instanceName, interfaceBlockType, false); instanceTypeDef->setQualifier(typeQualifier.qualifier); - if (!symbolTable.declare(instanceTypeDef)) { + if (!symbolTable.declare(*instanceTypeDef)) { error(instanceLine, "redefinition", instanceName->c_str(), "interface block instance name"); recover(); } @@ -2446,8 +2567,6 @@ TPublicType TParseContext::addStructure(const TSourceLoc& structLine, const TSou TStructure* structure = new TStructure(structName, fieldList); TType* structureType = new TType(structure); - structure->setUniqueId(TSymbolTable::nextUniqueId()); - if (!structName->empty()) { if (reservedErrorCheck(nameLine, *structName)) @@ -2455,7 +2574,7 @@ TPublicType TParseContext::addStructure(const TSourceLoc& structLine, const TSou recover(); } TVariable* userTypeDef = new TVariable(structName, *structureType, true); - if (!symbolTable.declare(userTypeDef)) { + if (!symbolTable.declare(*userTypeDef)) { error(nameLine, "redefinition", structName->c_str(), "struct"); recover(); } diff --git a/gfx/angle/src/compiler/translator/ParseContext.h b/gfx/angle/src/compiler/translator/ParseContext.h index fc51ac86a7a4..3cd4b915e3ce 100644 --- a/gfx/angle/src/compiler/translator/ParseContext.h +++ b/gfx/angle/src/compiler/translator/ParseContext.h @@ -1,15 +1,15 @@ // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// 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. // #ifndef _PARSER_HELPER_INCLUDED_ #define _PARSER_HELPER_INCLUDED_ -#include "compiler/translator/Compiler.h" #include "compiler/translator/Diagnostics.h" #include "compiler/translator/DirectiveHandler.h" #include "compiler/translator/localintermediate.h" +#include "compiler/translator/ShHandle.h" #include "compiler/translator/SymbolTable.h" #include "compiler/preprocessor/Preprocessor.h" @@ -133,6 +133,8 @@ struct TParseContext { TFunction *addConstructorFunc(TPublicType publicType); TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, const TSourceLoc&); TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type); + TIntermTyped* constructStruct(TIntermNode*, TType*, int, const TSourceLoc&, bool subset); + TIntermTyped* constructBuiltIn(const TType*, TOperator, TIntermNode*, const TSourceLoc&, bool subset); TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, const TSourceLoc&); TIntermTyped* addConstMatrixNode(int , TIntermTyped*, const TSourceLoc&); TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, const TSourceLoc& line); diff --git a/gfx/angle/src/compiler/translator/PoolAlloc.cpp b/gfx/angle/src/compiler/translator/PoolAlloc.cpp index 887cb66504ab..abe70262f2d0 100644 --- a/gfx/angle/src/compiler/translator/PoolAlloc.cpp +++ b/gfx/angle/src/compiler/translator/PoolAlloc.cpp @@ -6,44 +6,43 @@ #include "compiler/translator/PoolAlloc.h" -#include "compiler/translator/InitializeGlobals.h" - -#include "common/platform.h" -#include "common/angleutils.h" -#include "common/tls.h" - +#ifndef _MSC_VER #include +#endif #include -#include -TLSIndex PoolIndex = TLS_INVALID_INDEX; +#include "common/angleutils.h" +#include "compiler/translator/InitializeGlobals.h" +#include "compiler/translator/osinclude.h" + +OS_TLSIndex PoolIndex = OS_INVALID_TLS_INDEX; bool InitializePoolIndex() { - assert(PoolIndex == TLS_INVALID_INDEX); + assert(PoolIndex == OS_INVALID_TLS_INDEX); - PoolIndex = CreateTLSIndex(); - return PoolIndex != TLS_INVALID_INDEX; + PoolIndex = OS_AllocTLSIndex(); + return PoolIndex != OS_INVALID_TLS_INDEX; } void FreePoolIndex() { - assert(PoolIndex != TLS_INVALID_INDEX); + assert(PoolIndex != OS_INVALID_TLS_INDEX); - DestroyTLSIndex(PoolIndex); - PoolIndex = TLS_INVALID_INDEX; + OS_FreeTLSIndex(PoolIndex); + PoolIndex = OS_INVALID_TLS_INDEX; } TPoolAllocator* GetGlobalPoolAllocator() { - assert(PoolIndex != TLS_INVALID_INDEX); - return static_cast(GetTLSValue(PoolIndex)); + assert(PoolIndex != OS_INVALID_TLS_INDEX); + return static_cast(OS_GetTLSValue(PoolIndex)); } void SetGlobalPoolAllocator(TPoolAllocator* poolAllocator) { - assert(PoolIndex != TLS_INVALID_INDEX); - SetTLSValue(PoolIndex, poolAllocator); + assert(PoolIndex != OS_INVALID_TLS_INDEX); + OS_SetTLSValue(PoolIndex, poolAllocator); } // diff --git a/gfx/angle/src/compiler/translator/Compiler.h b/gfx/angle/src/compiler/translator/ShHandle.h similarity index 98% rename from gfx/angle/src/compiler/translator/Compiler.h rename to gfx/angle/src/compiler/translator/ShHandle.h index af1bc98bbe2e..bb6a60c519f4 100644 --- a/gfx/angle/src/compiler/translator/Compiler.h +++ b/gfx/angle/src/compiler/translator/ShHandle.h @@ -115,7 +115,7 @@ protected: bool enforceTimingRestrictions(TIntermNode* root, bool outputGraph); // Returns true if the shader does not use samplers. bool enforceVertexShaderTimingRestrictions(TIntermNode* root); - // Returns true if the shader does not use sampler dependent values to affect control + // Returns true if the shader does not use sampler dependent values to affect control // flow or in operations whose time can depend on the input values. bool enforceFragmentShaderTimingRestrictions(const TDependencyGraph& graph); // Return true if the maximum expression complexity is below the limit. @@ -169,7 +169,7 @@ private: // and the machine dependent code. // // The machine dependent code should derive from the classes -// above. Then Construct*() and Delete*() will create and +// above. Then Construct*() and Delete*() will create and // destroy the machine dependent objects, which contain the // above machine independent information. // diff --git a/gfx/angle/src/compiler/translator/ShaderLang.cpp b/gfx/angle/src/compiler/translator/ShaderLang.cpp index 121a68cc3e74..bf0587a34ce2 100644 --- a/gfx/angle/src/compiler/translator/ShaderLang.cpp +++ b/gfx/angle/src/compiler/translator/ShaderLang.cpp @@ -11,9 +11,9 @@ #include "GLSLANG/ShaderLang.h" -#include "compiler/translator/Compiler.h" #include "compiler/translator/InitializeDll.h" #include "compiler/translator/length_limits.h" +#include "compiler/translator/ShHandle.h" #include "compiler/translator/TranslatorHLSL.h" #include "compiler/translator/VariablePacker.h" diff --git a/gfx/angle/src/compiler/translator/StructureHLSL.cpp b/gfx/angle/src/compiler/translator/StructureHLSL.cpp deleted file mode 100644 index 365985c85239..000000000000 --- a/gfx/angle/src/compiler/translator/StructureHLSL.cpp +++ /dev/null @@ -1,477 +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. -// -// StructureHLSL.cpp: -// Definitions of methods for HLSL translation of GLSL structures. -// - -#include "compiler/translator/StructureHLSL.h" -#include "common/utilities.h" -#include "compiler/translator/OutputHLSL.h" -#include "compiler/translator/Types.h" -#include "compiler/translator/util.h" -#include "compiler/translator/UtilsHLSL.h" - -namespace sh -{ - -Std140PaddingHelper::Std140PaddingHelper(const std::map &structElementIndexes) - : mPaddingCounter(0), - mElementIndex(0), - mStructElementIndexes(structElementIndexes) -{} - -int Std140PaddingHelper::prePadding(const TType &type) -{ - if (type.getBasicType() == EbtStruct || type.isMatrix() || type.isArray()) - { - // no padding needed, HLSL will align the field to a new register - mElementIndex = 0; - return 0; - } - - const GLenum glType = GLVariableType(type); - const int numComponents = gl::VariableComponentCount(glType); - - if (numComponents >= 4) - { - // no padding needed, HLSL will align the field to a new register - mElementIndex = 0; - return 0; - } - - if (mElementIndex + numComponents > 4) - { - // no padding needed, HLSL will align the field to a new register - mElementIndex = numComponents; - return 0; - } - - const int alignment = numComponents == 3 ? 4 : numComponents; - const int paddingOffset = (mElementIndex % alignment); - const int paddingCount = (paddingOffset != 0 ? (alignment - paddingOffset) : 0); - - mElementIndex += paddingCount; - mElementIndex += numComponents; - mElementIndex %= 4; - - return paddingCount; -} - -TString Std140PaddingHelper::prePaddingString(const TType &type) -{ - int paddingCount = prePadding(type); - - TString padding; - - for (int paddingIndex = 0; paddingIndex < paddingCount; paddingIndex++) - { - padding += " float pad_" + str(mPaddingCounter++) + ";\n"; - } - - return padding; -} - -TString Std140PaddingHelper::postPaddingString(const TType &type, bool useHLSLRowMajorPacking) -{ - if (!type.isMatrix() && !type.isArray() && type.getBasicType() != EbtStruct) - { - return ""; - } - - int numComponents = 0; - TStructure *structure = type.getStruct(); - - if (type.isMatrix()) - { - // This method can also be called from structureString, which does not use layout qualifiers. - // Thus, use the method parameter for determining the matrix packing. - // - // Note HLSL row major packing corresponds to GL API column-major, and vice-versa, since we - // wish to always transpose GL matrices to play well with HLSL's matrix array indexing. - // - const bool isRowMajorMatrix = !useHLSLRowMajorPacking; - const GLenum glType = GLVariableType(type); - numComponents = gl::MatrixComponentCount(glType, isRowMajorMatrix); - } - else if (structure) - { - const TString &structName = QualifiedStructNameString(*structure, - useHLSLRowMajorPacking, true); - numComponents = mStructElementIndexes.find(structName)->second; - - if (numComponents == 0) - { - return ""; - } - } - else - { - const GLenum glType = GLVariableType(type); - numComponents = gl::VariableComponentCount(glType); - } - - TString padding; - for (int paddingOffset = numComponents; paddingOffset < 4; paddingOffset++) - { - padding += " float pad_" + str(mPaddingCounter++) + ";\n"; - } - return padding; -} - -StructureHLSL::StructureHLSL() -{} - -TString StructureHLSL::defineQualified(const TStructure &structure, bool useHLSLRowMajorPacking, bool useStd140Packing) -{ - if (useStd140Packing) - { - Std140PaddingHelper padHelper(mStd140StructElementIndexes); - return define(structure, useHLSLRowMajorPacking, useStd140Packing, &padHelper); - } - else - { - return define(structure, useHLSLRowMajorPacking, useStd140Packing, NULL); - } -} - -TString StructureHLSL::defineNameless(const TStructure &structure) -{ - return define(structure, false, false, NULL); -} - -TString StructureHLSL::define(const TStructure &structure, bool useHLSLRowMajorPacking, - bool useStd140Packing, Std140PaddingHelper *padHelper) -{ - const TFieldList &fields = structure.fields(); - const bool isNameless = (structure.name() == ""); - const TString &structName = QualifiedStructNameString(structure, useHLSLRowMajorPacking, - useStd140Packing); - const TString declareString = (isNameless ? "struct" : "struct " + structName); - - TString string; - string += declareString + "\n" - "{\n"; - - for (unsigned int i = 0; i < fields.size(); i++) - { - const TField &field = *fields[i]; - const TType &fieldType = *field.type(); - const TStructure *fieldStruct = fieldType.getStruct(); - const TString &fieldTypeString = fieldStruct ? - QualifiedStructNameString(*fieldStruct, useHLSLRowMajorPacking, - useStd140Packing) : - TypeString(fieldType); - - if (padHelper) - { - string += padHelper->prePaddingString(fieldType); - } - - string += " " + fieldTypeString + " " + DecorateField(field.name(), structure) + ArrayString(fieldType) + ";\n"; - - if (padHelper) - { - string += padHelper->postPaddingString(fieldType, useHLSLRowMajorPacking); - } - } - - // Nameless structs do not finish with a semicolon and newline, to leave room for an instance variable - string += (isNameless ? "} " : "};\n"); - - return string; -} - -void StructureHLSL::addConstructor(const TType &type, const TString &name, const TIntermSequence *parameters) -{ - if (name == "") - { - return; // Nameless structures don't have constructors - } - - if (type.getStruct() && mStructNames.find(name) != mStructNames.end()) - { - return; // Already added - } - - TType ctorType = type; - ctorType.clearArrayness(); - ctorType.setPrecision(EbpHigh); - ctorType.setQualifier(EvqTemporary); - - typedef std::vector ParameterArray; - ParameterArray ctorParameters; - - const TStructure* structure = type.getStruct(); - if (structure) - { - mStructNames.insert(name); - - // Add element index - storeStd140ElementIndex(*structure, false); - storeStd140ElementIndex(*structure, true); - - const TString &structString = defineQualified(*structure, false, false); - - if (std::find(mStructDeclarations.begin(), mStructDeclarations.end(), structString) == mStructDeclarations.end()) - { - // Add row-major packed struct for interface blocks - TString rowMajorString = "#pragma pack_matrix(row_major)\n" + - defineQualified(*structure, true, false) + - "#pragma pack_matrix(column_major)\n"; - - TString std140String = defineQualified(*structure, false, true); - TString std140RowMajorString = "#pragma pack_matrix(row_major)\n" + - defineQualified(*structure, true, true) + - "#pragma pack_matrix(column_major)\n"; - - mStructDeclarations.push_back(structString); - mStructDeclarations.push_back(rowMajorString); - mStructDeclarations.push_back(std140String); - mStructDeclarations.push_back(std140RowMajorString); - } - - const TFieldList &fields = structure->fields(); - for (unsigned int i = 0; i < fields.size(); i++) - { - ctorParameters.push_back(*fields[i]->type()); - } - } - else if (parameters) - { - for (TIntermSequence::const_iterator parameter = parameters->begin(); parameter != parameters->end(); parameter++) - { - ctorParameters.push_back((*parameter)->getAsTyped()->getType()); - } - } - else UNREACHABLE(); - - TString constructor; - - if (ctorType.getStruct()) - { - constructor += name + " " + name + "_ctor("; - } - else // Built-in type - { - constructor += TypeString(ctorType) + " " + name + "("; - } - - for (unsigned int parameter = 0; parameter < ctorParameters.size(); parameter++) - { - const TType &type = ctorParameters[parameter]; - - constructor += TypeString(type) + " x" + str(parameter) + ArrayString(type); - - if (parameter < ctorParameters.size() - 1) - { - constructor += ", "; - } - } - - constructor += ")\n" - "{\n"; - - if (ctorType.getStruct()) - { - constructor += " " + name + " structure = {"; - } - else - { - constructor += " return " + TypeString(ctorType) + "("; - } - - if (ctorType.isMatrix() && ctorParameters.size() == 1) - { - int rows = ctorType.getRows(); - int cols = ctorType.getCols(); - const TType ¶meter = ctorParameters[0]; - - if (parameter.isScalar()) - { - for (int row = 0; row < rows; row++) - { - for (int col = 0; col < cols; col++) - { - constructor += TString((row == col) ? "x0" : "0.0"); - - if (row < rows - 1 || col < cols - 1) - { - constructor += ", "; - } - } - } - } - else if (parameter.isMatrix()) - { - for (int row = 0; row < rows; row++) - { - for (int col = 0; col < cols; col++) - { - if (row < parameter.getRows() && col < parameter.getCols()) - { - constructor += TString("x0") + "[" + str(row) + "][" + str(col) + "]"; - } - else - { - constructor += TString((row == col) ? "1.0" : "0.0"); - } - - if (row < rows - 1 || col < cols - 1) - { - constructor += ", "; - } - } - } - } - else - { - ASSERT(rows == 2 && cols == 2 && parameter.isVector() && parameter.getNominalSize() == 4); - - constructor += "x0"; - } - } - else - { - size_t remainingComponents = ctorType.getObjectSize(); - size_t parameterIndex = 0; - - while (remainingComponents > 0) - { - const TType ¶meter = ctorParameters[parameterIndex]; - const size_t parameterSize = parameter.getObjectSize(); - bool moreParameters = parameterIndex + 1 < ctorParameters.size(); - - constructor += "x" + str(parameterIndex); - - if (ctorType.getStruct()) - { - ASSERT(remainingComponents == parameterSize || moreParameters); - ASSERT(parameterSize <= remainingComponents); - - remainingComponents -= parameterSize; - } - else if (parameter.isScalar()) - { - remainingComponents -= parameter.getObjectSize(); - } - else if (parameter.isVector()) - { - if (remainingComponents == parameterSize || moreParameters) - { - ASSERT(parameterSize <= remainingComponents); - remainingComponents -= parameterSize; - } - else if (remainingComponents < static_cast(parameter.getNominalSize())) - { - switch (remainingComponents) - { - case 1: constructor += ".x"; break; - case 2: constructor += ".xy"; break; - case 3: constructor += ".xyz"; break; - case 4: constructor += ".xyzw"; break; - default: UNREACHABLE(); - } - - remainingComponents = 0; - } - else UNREACHABLE(); - } - else if (parameter.isMatrix()) - { - int column = 0; - while (remainingComponents > 0 && column < parameter.getCols()) - { - constructor += "[" + str(column) + "]"; - - if (remainingComponents < static_cast(parameter.getRows())) - { - switch (remainingComponents) - { - case 1: constructor += ".x"; break; - case 2: constructor += ".xy"; break; - case 3: constructor += ".xyz"; break; - default: UNREACHABLE(); - } - - remainingComponents = 0; - } - else - { - remainingComponents -= parameter.getRows(); - - if (remainingComponents > 0) - { - constructor += ", x" + str(parameterIndex); - } - } - - column++; - } - } - else UNREACHABLE(); - - if (moreParameters) - { - parameterIndex++; - } - - if (remainingComponents) - { - constructor += ", "; - } - } - } - - if (ctorType.getStruct()) - { - constructor += "};\n" - " return structure;\n" - "}\n"; - } - else - { - constructor += ");\n" - "}\n"; - } - - mConstructors.insert(constructor); -} - -std::string StructureHLSL::structsHeader() const -{ - TInfoSinkBase out; - - for (size_t structIndex = 0; structIndex < mStructDeclarations.size(); structIndex++) - { - out << mStructDeclarations[structIndex]; - } - - for (Constructors::const_iterator constructor = mConstructors.begin(); - constructor != mConstructors.end(); - constructor++) - { - out << *constructor; - } - - return out.str(); -} - -void StructureHLSL::storeStd140ElementIndex(const TStructure &structure, bool useHLSLRowMajorPacking) -{ - Std140PaddingHelper padHelper(mStd140StructElementIndexes); - const TFieldList &fields = structure.fields(); - - for (unsigned int i = 0; i < fields.size(); i++) - { - padHelper.prePadding(*fields[i]->type()); - } - - // Add remaining element index to the global map, for use with nested structs in standard layouts - const TString &structName = QualifiedStructNameString(structure, useHLSLRowMajorPacking, true); - mStd140StructElementIndexes[structName] = padHelper.elementIndex(); -} - -} diff --git a/gfx/angle/src/compiler/translator/StructureHLSL.h b/gfx/angle/src/compiler/translator/StructureHLSL.h deleted file mode 100644 index 63fbaaaf8eb7..000000000000 --- a/gfx/angle/src/compiler/translator/StructureHLSL.h +++ /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. -// -// StructureHLSL.h: -// Interfaces of methods for HLSL translation of GLSL structures. -// - -#ifndef TRANSLATOR_STRUCTUREHLSL_H_ -#define TRANSLATOR_STRUCTUREHLSL_H_ - -#include "compiler/translator/Common.h" -#include "compiler/translator/intermediate.h" - -#include - -class TInfoSinkBase; -class TScopeBracket; - -namespace sh -{ - -// This helper class assists structure and interface block definitions in determining -// how to pack std140 structs within HLSL's packing rules. -class Std140PaddingHelper -{ - public: - explicit Std140PaddingHelper(const std::map &structElementIndexes); - - int elementIndex() const { return mElementIndex; } - int prePadding(const TType &type); - TString prePaddingString(const TType &type); - TString postPaddingString(const TType &type, bool useHLSLRowMajorPacking); - - private: - int mPaddingCounter; - int mElementIndex; - const std::map &mStructElementIndexes; -}; - -class StructureHLSL -{ - public: - StructureHLSL(); - - void addConstructor(const TType &type, const TString &name, const TIntermSequence *parameters); - std::string structsHeader() const; - - TString defineQualified(const TStructure &structure, bool useHLSLRowMajorPacking, bool useStd140Packing); - static TString defineNameless(const TStructure &structure); - - Std140PaddingHelper getPaddingHelper() const { return Std140PaddingHelper(mStd140StructElementIndexes); } - - private: - std::map mStd140StructElementIndexes; - - typedef std::set StructNames; - StructNames mStructNames; - - typedef std::set Constructors; - Constructors mConstructors; - - typedef std::vector StructDeclarations; - StructDeclarations mStructDeclarations; - - void storeStd140ElementIndex(const TStructure &structure, bool useHLSLRowMajorPacking); - static TString define(const TStructure &structure, bool useHLSLRowMajorPacking, - bool useStd140Packing, Std140PaddingHelper *padHelper); -}; - -} - -#endif // COMPILER_STRUCTUREHLSL_H_ diff --git a/gfx/angle/src/compiler/translator/SymbolTable.cpp b/gfx/angle/src/compiler/translator/SymbolTable.cpp index ae4fcaa6c3fd..5eb043480baa 100644 --- a/gfx/angle/src/compiler/translator/SymbolTable.cpp +++ b/gfx/angle/src/compiler/translator/SymbolTable.cpp @@ -18,7 +18,7 @@ #include #include -int TSymbolTable::uniqueIdCounter = 0; +int TSymbolTableLevel::uniqueId = 0; // // Functions have buried pointers to delete. @@ -38,25 +38,6 @@ TSymbolTableLevel::~TSymbolTableLevel() delete (*it).second; } -bool TSymbolTableLevel::insert(TSymbol *symbol) -{ - symbol->setUniqueId(TSymbolTable::nextUniqueId()); - - // returning true means symbol was added to the table - tInsertResult result = level.insert(tLevelPair(symbol->getMangledName(), symbol)); - - return result.second; -} - -TSymbol *TSymbolTableLevel::find(const TString &name) const -{ - tLevel::const_iterator it = level.find(name); - if (it == level.end()) - return 0; - else - return (*it).second; -} - // // Change all function entries in the table with the non-mangled name // to be related to the provided built-in operation. This is a low @@ -207,7 +188,7 @@ void TSymbolTable::insertBuiltIn( } } - insert(level, function); + insert(level, *function); } TPrecision TSymbolTable::getDefaultPrecision(TBasicType type) diff --git a/gfx/angle/src/compiler/translator/SymbolTable.h b/gfx/angle/src/compiler/translator/SymbolTable.h index d3ddf19e34ac..2119d8b27450 100644 --- a/gfx/angle/src/compiler/translator/SymbolTable.h +++ b/gfx/angle/src/compiler/translator/SymbolTable.h @@ -185,7 +185,7 @@ class TFunction : public TSymbol defined(false) { } - TFunction(const TString *name, const TType &retType, TOperator tOp = EOpNull) + TFunction(const TString *name, TType &retType, TOperator tOp = EOpNull) : TSymbol(name), returnType(retType), mangledName(TFunction::mangleName(*name)), @@ -288,15 +288,36 @@ class TSymbolTableLevel } ~TSymbolTableLevel(); - bool insert(TSymbol *symbol); + bool insert(const TString &name, TSymbol &symbol) + { + symbol.setUniqueId(++uniqueId); - TSymbol *find(const TString &name) const; + // returning true means symbol was added to the table + tInsertResult result = level.insert(tLevelPair(name, &symbol)); + + return result.second; + } + + bool insert(TSymbol &symbol) + { + return insert(symbol.getMangledName(), symbol); + } + + TSymbol *find(const TString &name) const + { + tLevel::const_iterator it = level.find(name); + if (it == level.end()) + return 0; + else + return (*it).second; + } void relateToOperator(const char *name, TOperator op); void relateToExtension(const char *name, const TString &ext); protected: tLevel level; + static int uniqueId; // for unique identification in code generation }; enum ESymbolLevel @@ -350,12 +371,12 @@ class TSymbolTable precisionStack.pop_back(); } - bool declare(TSymbol *symbol) + bool declare(TSymbol &symbol) { return insert(currentLevel(), symbol); } - bool insert(ESymbolLevel level, TSymbol *symbol) + bool insert(ESymbolLevel level, TSymbol &symbol) { return table[level]->insert(symbol); } @@ -365,7 +386,7 @@ class TSymbolTable TVariable *constant = new TVariable( NewPoolTString(name), TType(EbtInt, EbpUndefined, EvqConst, 1)); constant->getConstPointer()->setIConst(value); - return insert(level, constant); + return insert(level, *constant); } void insertBuiltIn(ESymbolLevel level, TType *rvalue, const char *name, @@ -408,11 +429,6 @@ class TSymbolTable // for the specified TBasicType TPrecision getDefaultPrecision(TBasicType type); - static int nextUniqueId() - { - return ++uniqueIdCounter; - } - private: ESymbolLevel currentLevel() const { @@ -422,8 +438,6 @@ class TSymbolTable std::vector table; typedef TMap PrecisionStackLevel; std::vector< PrecisionStackLevel *> precisionStack; - - static int uniqueIdCounter; }; #endif // _SYMBOL_TABLE_INCLUDED_ diff --git a/gfx/angle/src/compiler/translator/TranslatorESSL.h b/gfx/angle/src/compiler/translator/TranslatorESSL.h index 6e7ea65eb811..e18f3c25ec8b 100644 --- a/gfx/angle/src/compiler/translator/TranslatorESSL.h +++ b/gfx/angle/src/compiler/translator/TranslatorESSL.h @@ -7,7 +7,7 @@ #ifndef COMPILER_TRANSLATORESSL_H_ #define COMPILER_TRANSLATORESSL_H_ -#include "compiler/translator/Compiler.h" +#include "compiler/translator/ShHandle.h" class TranslatorESSL : public TCompiler { public: diff --git a/gfx/angle/src/compiler/translator/TranslatorGLSL.h b/gfx/angle/src/compiler/translator/TranslatorGLSL.h index 301227e5ff3c..1e16b2605e4d 100644 --- a/gfx/angle/src/compiler/translator/TranslatorGLSL.h +++ b/gfx/angle/src/compiler/translator/TranslatorGLSL.h @@ -7,7 +7,7 @@ #ifndef COMPILER_TRANSLATORGLSL_H_ #define COMPILER_TRANSLATORGLSL_H_ -#include "compiler/translator/Compiler.h" +#include "compiler/translator/ShHandle.h" class TranslatorGLSL : public TCompiler { public: diff --git a/gfx/angle/src/compiler/translator/TranslatorHLSL.h b/gfx/angle/src/compiler/translator/TranslatorHLSL.h index 46867b0e188b..8b16587b6b13 100644 --- a/gfx/angle/src/compiler/translator/TranslatorHLSL.h +++ b/gfx/angle/src/compiler/translator/TranslatorHLSL.h @@ -7,7 +7,7 @@ #ifndef COMPILER_TRANSLATORHLSL_H_ #define COMPILER_TRANSLATORHLSL_H_ -#include "compiler/translator/Compiler.h" +#include "compiler/translator/ShHandle.h" #include "common/shadervars.h" class TranslatorHLSL : public TCompiler { @@ -15,20 +15,20 @@ public: TranslatorHLSL(ShShaderType type, ShShaderSpec spec, ShShaderOutput output); virtual TranslatorHLSL *getAsTranslatorHLSL() { return this; } - const std::vector &getUniforms() { return mActiveUniforms; } - const std::vector &getInterfaceBlocks() const { return mActiveInterfaceBlocks; } - const std::vector &getOutputVariables() { return mActiveOutputVariables; } - const std::vector &getAttributes() { return mActiveAttributes; } - const std::vector &getVaryings() { return mActiveVaryings; } + const std::vector &getUniforms() { return mActiveUniforms; } + const std::vector &getInterfaceBlocks() const { return mActiveInterfaceBlocks; } + const std::vector &getOutputVariables() { return mActiveOutputVariables; } + const std::vector &getAttributes() { return mActiveAttributes; } + const std::vector &getVaryings() { return mActiveVaryings; } protected: virtual void translate(TIntermNode* root); - std::vector mActiveUniforms; - std::vector mActiveInterfaceBlocks; - std::vector mActiveOutputVariables; - std::vector mActiveAttributes; - std::vector mActiveVaryings; + std::vector mActiveUniforms; + std::vector mActiveInterfaceBlocks; + std::vector mActiveOutputVariables; + std::vector mActiveAttributes; + std::vector mActiveVaryings; }; #endif // COMPILER_TRANSLATORHLSL_H_ diff --git a/gfx/angle/src/compiler/translator/Types.cpp b/gfx/angle/src/compiler/translator/Types.cpp index bafad0d64fc3..4763920f86eb 100644 --- a/gfx/angle/src/compiler/translator/Types.cpp +++ b/gfx/angle/src/compiler/translator/Types.cpp @@ -22,9 +22,57 @@ TType::TType(const TPublicType &p) structure = p.userDef->getStruct(); } +bool TType::equals(const TType &other) const +{ + if (type != other.type || precision != other.precision || + primarySize != other.primarySize || secondarySize != other.secondarySize || + array != other.array || (array && arraySize != other.arraySize) || + interfaceBlock != other.interfaceBlock || structure != other.structure) + { + return false; + } + if (interfaceBlock && !interfaceBlock->equals(*(other.interfaceBlock))) + return false; + if (structure && !structure->equals(*(other.structure))) + return false; + return true; +} + +bool TField::equals(const TField &other) const +{ + ASSERT(mType && mName); + ASSERT(other.mType && other.mName); + return mType->equals(*(other.mType)) && *mName == *(other.mName); +} + +bool TFieldListCollection::equals(const TFieldListCollection &other) const +{ + ASSERT(mName && mFields); + ASSERT(other.mName && other.mFields); + if (*mName != *(other.mName)) + return false; + if (mFields->size() != other.mFields->size()) + return false; + for (size_t ii = 0; ii < mFields->size(); ++ii) + { + ASSERT((*mFields)[ii] && (*(other.mFields))[ii]); + if (!(*mFields)[ii]->equals(*((*(other.mFields))[ii]))) + return false; + } + return true; +} + bool TStructure::equals(const TStructure &other) const { - return (uniqueId() == other.uniqueId()); + return TFieldListCollection::equals(other); +} + +bool TInterfaceBlock::equals(const TInterfaceBlock &other) const +{ + if (!TFieldListCollection::equals(other)) + return false; + // TODO(zmo): do we need to consider mBlockStorage and mMatrixPacking? + return mArraySize == other.mArraySize; } // diff --git a/gfx/angle/src/compiler/translator/Types.h b/gfx/angle/src/compiler/translator/Types.h index bc50a4dc648e..91c36a657b3b 100644 --- a/gfx/angle/src/compiler/translator/Types.h +++ b/gfx/angle/src/compiler/translator/Types.h @@ -15,7 +15,6 @@ struct TPublicType; class TType; -class TSymbol; class TField { @@ -48,6 +47,8 @@ class TField return mLine; } + bool equals(const TField &other) const; + private: DISALLOW_COPY_AND_ASSIGN(TField); TType *mType; @@ -98,6 +99,8 @@ class TFieldListCollection size_t calculateObjectSize() const; virtual TString mangledNamePrefix() const = 0; + bool equals(const TFieldListCollection &other) const; + const TString *mName; TFieldList *mFields; @@ -112,8 +115,7 @@ class TStructure : public TFieldListCollection POOL_ALLOCATOR_NEW_DELETE(); TStructure(const TString *name, TFieldList *fields) : TFieldListCollection(name, fields), - mDeepestNesting(0), - mUniqueId(0) + mDeepestNesting(0) { } @@ -127,17 +129,6 @@ class TStructure : public TFieldListCollection bool equals(const TStructure &other) const; - void setUniqueId(int uniqueId) - { - mUniqueId = uniqueId; - } - - int uniqueId() const - { - ASSERT(mUniqueId != 0); - return mUniqueId; - } - private: DISALLOW_COPY_AND_ASSIGN(TStructure); virtual TString mangledNamePrefix() const @@ -147,7 +138,6 @@ class TStructure : public TFieldListCollection int calculateDeepestNesting() const; mutable int mDeepestNesting; - int mUniqueId; }; class TInterfaceBlock : public TFieldListCollection @@ -189,6 +179,8 @@ class TInterfaceBlock : public TFieldListCollection return mMatrixPacking; } + bool equals(const TInterfaceBlock &other) const; + private: DISALLOW_COPY_AND_ASSIGN(TInterfaceBlock); virtual TString mangledNamePrefix() const @@ -379,6 +371,10 @@ class TType return mangled; } + // This is different from operator== as we also compare + // precision here. + bool equals(const TType &other) const; + bool sameElementType(const TType &right) const { return type == right.type && diff --git a/gfx/angle/src/compiler/translator/UnfoldShortCircuit.cpp b/gfx/angle/src/compiler/translator/UnfoldShortCircuit.cpp index 65f50c4cc37f..b7826119aea0 100644 --- a/gfx/angle/src/compiler/translator/UnfoldShortCircuit.cpp +++ b/gfx/angle/src/compiler/translator/UnfoldShortCircuit.cpp @@ -12,7 +12,6 @@ #include "compiler/translator/InfoSink.h" #include "compiler/translator/OutputHLSL.h" -#include "compiler/translator/UtilsHLSL.h" namespace sh { @@ -118,7 +117,7 @@ bool UnfoldShortCircuit::visitSelection(Visit visit, TIntermSelection *node) { int i = mTemporaryIndex; - out << TypeString(node->getType()) << " s" << i << ";\n"; + out << mOutputHLSL->typeString(node->getType()) << " s" << i << ";\n"; out << "{\n"; diff --git a/gfx/angle/src/compiler/translator/UniformHLSL.cpp b/gfx/angle/src/compiler/translator/UniformHLSL.cpp deleted file mode 100644 index fb2208c3a5ce..000000000000 --- a/gfx/angle/src/compiler/translator/UniformHLSL.cpp +++ /dev/null @@ -1,391 +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. -// -// UniformHLSL.cpp: -// Methods for GLSL to HLSL translation for uniforms and interface blocks. -// - -#include "OutputHLSL.h" -#include "common/blocklayout.h" -#include "common/utilities.h" -#include "compiler/translator/UniformHLSL.h" -#include "compiler/translator/StructureHLSL.h" -#include "compiler/translator/util.h" -#include "compiler/translator/UtilsHLSL.h" - -namespace sh -{ - -// Use the same layout for packed and shared -static void SetBlockLayout(InterfaceBlock *interfaceBlock, BlockLayoutType newLayout) -{ - interfaceBlock->layout = newLayout; - interfaceBlock->blockInfo.clear(); - - switch (newLayout) - { - case BLOCKLAYOUT_SHARED: - case BLOCKLAYOUT_PACKED: - { - HLSLBlockEncoder hlslEncoder(&interfaceBlock->blockInfo, HLSLBlockEncoder::ENCODE_PACKED); - hlslEncoder.encodeInterfaceBlockFields(interfaceBlock->fields); - interfaceBlock->dataSize = hlslEncoder.getBlockSize(); - } - break; - - case BLOCKLAYOUT_STANDARD: - { - Std140BlockEncoder stdEncoder(&interfaceBlock->blockInfo); - stdEncoder.encodeInterfaceBlockFields(interfaceBlock->fields); - interfaceBlock->dataSize = stdEncoder.getBlockSize(); - } - break; - - default: - UNREACHABLE(); - break; - } -} - -static BlockLayoutType ConvertBlockLayoutType(TLayoutBlockStorage blockStorage) -{ - switch (blockStorage) - { - case EbsPacked: return BLOCKLAYOUT_PACKED; - case EbsShared: return BLOCKLAYOUT_SHARED; - case EbsStd140: return BLOCKLAYOUT_STANDARD; - default: UNREACHABLE(); return BLOCKLAYOUT_SHARED; - } -} - -static const char *UniformRegisterPrefix(const TType &type) -{ - if (IsSampler(type.getBasicType())) - { - return "s"; - } - else - { - return "c"; - } -} - -static TString InterfaceBlockFieldName(const TInterfaceBlock &interfaceBlock, const TField &field) -{ - if (interfaceBlock.hasInstanceName()) - { - return interfaceBlock.name() + "." + field.name(); - } - else - { - return field.name(); - } -} - -static TString InterfaceBlockFieldTypeString(const TField &field, TLayoutBlockStorage blockStorage) -{ - const TType &fieldType = *field.type(); - const TLayoutMatrixPacking matrixPacking = fieldType.getLayoutQualifier().matrixPacking; - ASSERT(matrixPacking != EmpUnspecified); - TStructure *structure = fieldType.getStruct(); - - if (fieldType.isMatrix()) - { - // Use HLSL row-major packing for GLSL column-major matrices - const TString &matrixPackString = (matrixPacking == EmpRowMajor ? "column_major" : "row_major"); - return matrixPackString + " " + TypeString(fieldType); - } - else if (structure) - { - // Use HLSL row-major packing for GLSL column-major matrices - return QualifiedStructNameString(*structure, matrixPacking == EmpColumnMajor, - blockStorage == EbsStd140); - } - else - { - return TypeString(fieldType); - } -} - -static TString InterfaceBlockStructName(const TInterfaceBlock &interfaceBlock) -{ - return DecoratePrivate(interfaceBlock.name()) + "_type"; -} - -UniformHLSL::UniformHLSL(StructureHLSL *structureHLSL, ShShaderOutput outputType) - : mUniformRegister(0), - mInterfaceBlockRegister(0), - mSamplerRegister(0), - mStructureHLSL(structureHLSL), - mOutputType(outputType) -{} - -void UniformHLSL::reserveUniformRegisters(unsigned int registerCount) -{ - mUniformRegister = registerCount; -} - -void UniformHLSL::reserveInterfaceBlockRegisters(unsigned int registerCount) -{ - mInterfaceBlockRegister = registerCount; -} - -int UniformHLSL::declareUniformAndAssignRegister(const TType &type, const TString &name) -{ - int registerIndex = (IsSampler(type.getBasicType()) ? mSamplerRegister : mUniformRegister); - - const Uniform &uniform = declareUniformToList(type, name, registerIndex, &mActiveUniforms); - - if (IsSampler(type.getBasicType())) - { - mSamplerRegister += HLSLVariableRegisterCount(uniform, mOutputType); - } - else - { - mUniformRegister += HLSLVariableRegisterCount(uniform, mOutputType); - } - - return registerIndex; -} - -Uniform UniformHLSL::declareUniformToList(const TType &type, const TString &name, int registerIndex, std::vector *output) -{ - const TStructure *structure = type.getStruct(); - - if (!structure) - { - Uniform uniform(GLVariableType(type), GLVariablePrecision(type), name.c_str(), - (unsigned int)type.getArraySize(), (unsigned int)registerIndex, 0); - output->push_back(uniform); - - return uniform; - } - else - { - Uniform structUniform(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), - (unsigned int)registerIndex, GL_INVALID_INDEX); - - const TFieldList &fields = structure->fields(); - - for (size_t fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++) - { - TField *field = fields[fieldIndex]; - TType *fieldType = field->type(); - - declareUniformToList(*fieldType, field->name(), GL_INVALID_INDEX, &structUniform.fields); - } - - // assign register offset information -- this will override the information in any sub-structures. - HLSLVariableGetRegisterInfo(registerIndex, &structUniform, mOutputType); - - output->push_back(structUniform); - - return structUniform; - } -} - -TString UniformHLSL::uniformsHeader(ShShaderOutput outputType, const ReferencedSymbols &referencedUniforms) -{ - TString uniforms; - - for (ReferencedSymbols::const_iterator uniformIt = referencedUniforms.begin(); - uniformIt != referencedUniforms.end(); uniformIt++) - { - const TIntermSymbol &uniform = *uniformIt->second; - const TType &type = uniform.getType(); - const TString &name = uniform.getSymbol(); - - int registerIndex = declareUniformAndAssignRegister(type, name); - - if (outputType == SH_HLSL11_OUTPUT && IsSampler(type.getBasicType())) // Also declare the texture - { - uniforms += "uniform " + SamplerString(type) + " sampler_" + DecorateUniform(name, type) + ArrayString(type) + - " : register(s" + str(registerIndex) + ");\n"; - - uniforms += "uniform " + TextureString(type) + " texture_" + DecorateUniform(name, type) + ArrayString(type) + - " : register(t" + str(registerIndex) + ");\n"; - } - else - { - const TStructure *structure = type.getStruct(); - const TString &typeName = (structure ? QualifiedStructNameString(*structure, false, false) : TypeString(type)); - - const TString ®isterString = TString("register(") + UniformRegisterPrefix(type) + str(registerIndex) + ")"; - - uniforms += "uniform " + typeName + " " + DecorateUniform(name, type) + ArrayString(type) + " : " + registerString + ";\n"; - } - } - - return (uniforms.empty() ? "" : ("// Uniforms\n\n" + uniforms)); -} - -TString UniformHLSL::interfaceBlocksHeader(const ReferencedSymbols &referencedInterfaceBlocks) -{ - TString interfaceBlocks; - - for (ReferencedSymbols::const_iterator interfaceBlockIt = referencedInterfaceBlocks.begin(); - interfaceBlockIt != referencedInterfaceBlocks.end(); interfaceBlockIt++) - { - const TType &nodeType = interfaceBlockIt->second->getType(); - const TInterfaceBlock &interfaceBlock = *nodeType.getInterfaceBlock(); - const TFieldList &fieldList = interfaceBlock.fields(); - - unsigned int arraySize = static_cast(interfaceBlock.arraySize()); - InterfaceBlock activeBlock(interfaceBlock.name().c_str(), arraySize, mInterfaceBlockRegister); - for (unsigned int typeIndex = 0; typeIndex < fieldList.size(); typeIndex++) - { - const TField &field = *fieldList[typeIndex]; - const TString &fullUniformName = InterfaceBlockFieldName(interfaceBlock, field); - declareInterfaceBlockField(*field.type(), fullUniformName, activeBlock.fields); - } - - mInterfaceBlockRegister += std::max(1u, arraySize); - - BlockLayoutType blockLayoutType = ConvertBlockLayoutType(interfaceBlock.blockStorage()); - SetBlockLayout(&activeBlock, blockLayoutType); - - if (interfaceBlock.matrixPacking() == EmpRowMajor) - { - activeBlock.isRowMajorLayout = true; - } - - mActiveInterfaceBlocks.push_back(activeBlock); - - if (interfaceBlock.hasInstanceName()) - { - interfaceBlocks += interfaceBlockStructString(interfaceBlock); - } - - if (arraySize > 0) - { - for (unsigned int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) - { - interfaceBlocks += interfaceBlockString(interfaceBlock, activeBlock.registerIndex + arrayIndex, arrayIndex); - } - } - else - { - interfaceBlocks += interfaceBlockString(interfaceBlock, activeBlock.registerIndex, GL_INVALID_INDEX); - } - } - - return (interfaceBlocks.empty() ? "" : ("// Interface Blocks\n\n" + interfaceBlocks)); -} - -TString UniformHLSL::interfaceBlockString(const TInterfaceBlock &interfaceBlock, unsigned int registerIndex, unsigned int arrayIndex) -{ - const TString &arrayIndexString = (arrayIndex != GL_INVALID_INDEX ? Decorate(str(arrayIndex)) : ""); - const TString &blockName = interfaceBlock.name() + arrayIndexString; - TString hlsl; - - hlsl += "cbuffer " + blockName + " : register(b" + str(registerIndex) + ")\n" - "{\n"; - - if (interfaceBlock.hasInstanceName()) - { - hlsl += " " + InterfaceBlockStructName(interfaceBlock) + " " + - interfaceBlockInstanceString(interfaceBlock, arrayIndex) + ";\n"; - } - else - { - const TLayoutBlockStorage blockStorage = interfaceBlock.blockStorage(); - hlsl += interfaceBlockMembersString(interfaceBlock, blockStorage); - } - - hlsl += "};\n\n"; - - return hlsl; -} - -TString UniformHLSL::interfaceBlockInstanceString(const TInterfaceBlock& interfaceBlock, unsigned int arrayIndex) -{ - if (!interfaceBlock.hasInstanceName()) - { - return ""; - } - else if (interfaceBlock.isArray()) - { - return DecoratePrivate(interfaceBlock.instanceName()) + "_" + str(arrayIndex); - } - else - { - return Decorate(interfaceBlock.instanceName()); - } -} - -TString UniformHLSL::interfaceBlockMembersString(const TInterfaceBlock &interfaceBlock, TLayoutBlockStorage blockStorage) -{ - TString hlsl; - - Std140PaddingHelper padHelper = mStructureHLSL->getPaddingHelper(); - - for (unsigned int typeIndex = 0; typeIndex < interfaceBlock.fields().size(); typeIndex++) - { - const TField &field = *interfaceBlock.fields()[typeIndex]; - const TType &fieldType = *field.type(); - - if (blockStorage == EbsStd140) - { - // 2 and 3 component vector types in some cases need pre-padding - hlsl += padHelper.prePadding(fieldType); - } - - hlsl += " " + InterfaceBlockFieldTypeString(field, blockStorage) + - " " + Decorate(field.name()) + ArrayString(fieldType) + ";\n"; - - // must pad out after matrices and arrays, where HLSL usually allows itself room to pack stuff - if (blockStorage == EbsStd140) - { - const bool useHLSLRowMajorPacking = (fieldType.getLayoutQualifier().matrixPacking == EmpColumnMajor); - hlsl += padHelper.postPaddingString(fieldType, useHLSLRowMajorPacking); - } - } - - return hlsl; -} - -TString UniformHLSL::interfaceBlockStructString(const TInterfaceBlock &interfaceBlock) -{ - const TLayoutBlockStorage blockStorage = interfaceBlock.blockStorage(); - - return "struct " + InterfaceBlockStructName(interfaceBlock) + "\n" - "{\n" + - interfaceBlockMembersString(interfaceBlock, blockStorage) + - "};\n\n"; -} - -void UniformHLSL::declareInterfaceBlockField(const TType &type, const TString &name, std::vector& output) -{ - const TStructure *structure = type.getStruct(); - - if (!structure) - { - const bool isRowMajorMatrix = (type.isMatrix() && type.getLayoutQualifier().matrixPacking == EmpRowMajor); - InterfaceBlockField field(GLVariableType(type), GLVariablePrecision(type), name.c_str(), - (unsigned int)type.getArraySize(), isRowMajorMatrix); - output.push_back(field); - } - else - { - InterfaceBlockField structField(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), false); - - const TFieldList &fields = structure->fields(); - - for (size_t fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++) - { - TField *field = fields[fieldIndex]; - TType *fieldType = field->type(); - - // make sure to copy matrix packing information - fieldType->setLayoutQualifier(type.getLayoutQualifier()); - - declareInterfaceBlockField(*fieldType, field->name(), structField.fields); - } - - output.push_back(structField); - } -} - -} diff --git a/gfx/angle/src/compiler/translator/UniformHLSL.h b/gfx/angle/src/compiler/translator/UniformHLSL.h deleted file mode 100644 index 3060661b2d80..000000000000 --- a/gfx/angle/src/compiler/translator/UniformHLSL.h +++ /dev/null @@ -1,58 +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. -// -// UniformHLSL.h: -// Methods for GLSL to HLSL translation for uniforms and interface blocks. -// - -#ifndef TRANSLATOR_UNIFORMHLSL_H_ -#define TRANSLATOR_UNIFORMHLSL_H_ - -#include "common/shadervars.h" -#include "compiler/translator/Types.h" - -namespace sh -{ -class StructureHLSL; - -class UniformHLSL -{ - public: - UniformHLSL(StructureHLSL *structureHLSL, ShShaderOutput outputType); - - void reserveUniformRegisters(unsigned int registerCount); - void reserveInterfaceBlockRegisters(unsigned int registerCount); - TString uniformsHeader(ShShaderOutput outputType, const ReferencedSymbols &referencedUniforms); - TString interfaceBlocksHeader(const ReferencedSymbols &referencedInterfaceBlocks); - - // Used for direct index references - static TString interfaceBlockInstanceString(const TInterfaceBlock& interfaceBlock, unsigned int arrayIndex); - - const std::vector &getUniforms() const { return mActiveUniforms; } - const std::vector &getInterfaceBlocks() const { return mActiveInterfaceBlocks; } - - private: - TString interfaceBlockString(const TInterfaceBlock &interfaceBlock, unsigned int registerIndex, unsigned int arrayIndex); - TString interfaceBlockMembersString(const TInterfaceBlock &interfaceBlock, TLayoutBlockStorage blockStorage); - TString interfaceBlockStructString(const TInterfaceBlock &interfaceBlock); - - // Returns the uniform's register index - int declareUniformAndAssignRegister(const TType &type, const TString &name); - void declareInterfaceBlockField(const TType &type, const TString &name, std::vector& output); - Uniform declareUniformToList(const TType &type, const TString &name, int registerIndex, std::vector *output); - - unsigned int mUniformRegister; - unsigned int mInterfaceBlockRegister; - unsigned int mSamplerRegister; - StructureHLSL *mStructureHLSL; - ShShaderOutput mOutputType; - - std::vector mActiveUniforms; - std::vector mActiveInterfaceBlocks; -}; - -} - -#endif // TRANSLATOR_UNIFORMHLSL_H_ diff --git a/gfx/angle/src/compiler/translator/UtilsHLSL.cpp b/gfx/angle/src/compiler/translator/UtilsHLSL.cpp deleted file mode 100644 index dbe35a50ea98..000000000000 --- a/gfx/angle/src/compiler/translator/UtilsHLSL.cpp +++ /dev/null @@ -1,243 +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. -// -// UtilsHLSL.cpp: -// Utility methods for GLSL to HLSL translation. -// - -#include "compiler/translator/UtilsHLSL.h" -#include "compiler/translator/StructureHLSL.h" -#include "compiler/translator/SymbolTable.h" - -namespace sh -{ - -TString SamplerString(const TType &type) -{ - if (IsShadowSampler(type.getBasicType())) - { - return "SamplerComparisonState"; - } - else - { - return "SamplerState"; - } -} - -TString TextureString(const TType &type) -{ - switch (type.getBasicType()) - { - case EbtSampler2D: return "Texture2D"; - case EbtSamplerCube: return "TextureCube"; - case EbtSamplerExternalOES: return "Texture2D"; - case EbtSampler2DArray: return "Texture2DArray"; - case EbtSampler3D: return "Texture3D"; - case EbtISampler2D: return "Texture2D"; - case EbtISampler3D: return "Texture3D"; - case EbtISamplerCube: return "Texture2DArray"; - case EbtISampler2DArray: return "Texture2DArray"; - case EbtUSampler2D: return "Texture2D"; - case EbtUSampler3D: return "Texture3D"; - case EbtUSamplerCube: return "Texture2DArray"; - case EbtUSampler2DArray: return "Texture2DArray"; - case EbtSampler2DShadow: return "Texture2D"; - case EbtSamplerCubeShadow: return "TextureCube"; - case EbtSampler2DArrayShadow: return "Texture2DArray"; - default: UNREACHABLE(); - } - - return ""; -} - -TString DecorateUniform(const TString &string, const TType &type) -{ - if (type.getBasicType() == EbtSamplerExternalOES) - { - return "ex_" + string; - } - - return Decorate(string); -} - -TString DecorateField(const TString &string, const TStructure &structure) -{ - if (structure.name().compare(0, 3, "gl_") != 0) - { - return Decorate(string); - } - - return string; -} - -TString DecoratePrivate(const TString &privateText) -{ - return "dx_" + privateText; -} - -TString Decorate(const TString &string) -{ - if (string.compare(0, 3, "gl_")) - { - return "_" + string; - } - - return string; -} - -TString TypeString(const TType &type) -{ - const TStructure* structure = type.getStruct(); - if (structure) - { - const TString& typeName = structure->name(); - if (typeName != "") - { - return StructNameString(*structure); - } - else // Nameless structure, define in place - { - return StructureHLSL::defineNameless(*structure); - } - } - else if (type.isMatrix()) - { - int cols = type.getCols(); - int rows = type.getRows(); - return "float" + str(cols) + "x" + str(rows); - } - else - { - switch (type.getBasicType()) - { - case EbtFloat: - switch (type.getNominalSize()) - { - case 1: return "float"; - case 2: return "float2"; - case 3: return "float3"; - case 4: return "float4"; - } - case EbtInt: - switch (type.getNominalSize()) - { - case 1: return "int"; - case 2: return "int2"; - case 3: return "int3"; - case 4: return "int4"; - } - case EbtUInt: - switch (type.getNominalSize()) - { - case 1: return "uint"; - case 2: return "uint2"; - case 3: return "uint3"; - case 4: return "uint4"; - } - case EbtBool: - switch (type.getNominalSize()) - { - case 1: return "bool"; - case 2: return "bool2"; - case 3: return "bool3"; - case 4: return "bool4"; - } - case EbtVoid: - return "void"; - case EbtSampler2D: - case EbtISampler2D: - case EbtUSampler2D: - case EbtSampler2DArray: - case EbtISampler2DArray: - case EbtUSampler2DArray: - return "sampler2D"; - case EbtSamplerCube: - case EbtISamplerCube: - case EbtUSamplerCube: - return "samplerCUBE"; - case EbtSamplerExternalOES: - return "sampler2D"; - default: - break; - } - } - - UNREACHABLE(); - return ""; -} - -TString StructNameString(const TStructure &structure) -{ - if (structure.name().empty()) - { - return ""; - } - - return "ss" + str(structure.uniqueId()) + "_" + structure.name(); -} - -TString QualifiedStructNameString(const TStructure &structure, bool useHLSLRowMajorPacking, - bool useStd140Packing) -{ - if (structure.name() == "") - { - return ""; - } - - TString prefix = ""; - - // Structs packed with row-major matrices in HLSL are prefixed with "rm" - // GLSL column-major maps to HLSL row-major, and the converse is true - - if (useStd140Packing) - { - prefix += "std_"; - } - - if (useHLSLRowMajorPacking) - { - prefix += "rm_"; - } - - return prefix + StructNameString(structure); -} - -TString InterpolationString(TQualifier qualifier) -{ - switch (qualifier) - { - case EvqVaryingIn: return ""; - case EvqFragmentIn: return ""; - case EvqInvariantVaryingIn: return ""; - case EvqSmoothIn: return "linear"; - case EvqFlatIn: return "nointerpolation"; - case EvqCentroidIn: return "centroid"; - case EvqVaryingOut: return ""; - case EvqVertexOut: return ""; - case EvqInvariantVaryingOut: return ""; - case EvqSmoothOut: return "linear"; - case EvqFlatOut: return "nointerpolation"; - case EvqCentroidOut: return "centroid"; - default: UNREACHABLE(); - } - - return ""; -} - -TString QualifierString(TQualifier qualifier) -{ - switch (qualifier) - { - case EvqIn: return "in"; - case EvqOut: return "inout"; // 'out' results in an HLSL error if not all fields are written, for GLSL it's undefined - case EvqInOut: return "inout"; - case EvqConstReadOnly: return "const"; - default: UNREACHABLE(); - } - - return ""; -} - -} diff --git a/gfx/angle/src/compiler/translator/UtilsHLSL.h b/gfx/angle/src/compiler/translator/UtilsHLSL.h deleted file mode 100644 index aaa3ddf5d2ad..000000000000 --- a/gfx/angle/src/compiler/translator/UtilsHLSL.h +++ /dev/null @@ -1,37 +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. -// -// UtilsHLSL.h: -// Utility methods for GLSL to HLSL translation. -// - -#ifndef TRANSLATOR_UTILSHLSL_H_ -#define TRANSLATOR_UTILSHLSL_H_ - -#include -#include "compiler/translator/Types.h" - -#include "angle_gl.h" - -namespace sh -{ - -TString TextureString(const TType &type); -TString SamplerString(const TType &type); -// Prepends an underscore to avoid naming clashes -TString Decorate(const TString &string); -TString DecorateUniform(const TString &string, const TType &type); -TString DecorateField(const TString &string, const TStructure &structure); -TString DecoratePrivate(const TString &privateText); -TString TypeString(const TType &type); -TString StructNameString(const TStructure &structure); -TString QualifiedStructNameString(const TStructure &structure, bool useHLSLRowMajorPacking, - bool useStd140Packing); -TString InterpolationString(TQualifier qualifier); -TString QualifierString(TQualifier qualifier); - -} - -#endif // TRANSLATOR_UTILSHLSL_H_ diff --git a/gfx/angle/src/compiler/translator/VariablePacker.cpp b/gfx/angle/src/compiler/translator/VariablePacker.cpp index da4436ebdfb4..6390e3039410 100644 --- a/gfx/angle/src/compiler/translator/VariablePacker.cpp +++ b/gfx/angle/src/compiler/translator/VariablePacker.cpp @@ -6,6 +6,7 @@ #include "compiler/translator/VariablePacker.h" #include +#include "compiler/translator/ShHandle.h" namespace { int GetSortOrder(ShDataType type) diff --git a/gfx/angle/src/compiler/translator/VariablePacker.h b/gfx/angle/src/compiler/translator/VariablePacker.h index 2a9232111ccf..fd6090827cd8 100644 --- a/gfx/angle/src/compiler/translator/VariablePacker.h +++ b/gfx/angle/src/compiler/translator/VariablePacker.h @@ -8,7 +8,7 @@ #define _VARIABLEPACKER_INCLUDED_ #include -#include "compiler/translator/VariableInfo.h" +#include "compiler/translator/ShHandle.h" class VariablePacker { public: diff --git a/gfx/angle/src/compiler/translator/VersionGLSL.cpp b/gfx/angle/src/compiler/translator/VersionGLSL.cpp index 3027a7725dec..dd11f99eb89c 100644 --- a/gfx/angle/src/compiler/translator/VersionGLSL.cpp +++ b/gfx/angle/src/compiler/translator/VersionGLSL.cpp @@ -36,7 +36,8 @@ static const int GLSL_VERSION_120 = 120; // - varying vec3 color; invariant color; // TVersionGLSL::TVersionGLSL(ShShaderType type) - : mVersion(GLSL_VERSION_110) + : mShaderType(type), + mVersion(GLSL_VERSION_110) { } diff --git a/gfx/angle/src/compiler/translator/VersionGLSL.h b/gfx/angle/src/compiler/translator/VersionGLSL.h index d2fa21b4b547..8a401c4e92b9 100644 --- a/gfx/angle/src/compiler/translator/VersionGLSL.h +++ b/gfx/angle/src/compiler/translator/VersionGLSL.h @@ -49,6 +49,7 @@ protected: void updateVersion(int version); private: + ShShaderType mShaderType; int mVersion; }; diff --git a/gfx/angle/src/compiler/translator/generate_parser.sh b/gfx/angle/src/compiler/translator/generate_parser.sh old mode 100644 new mode 100755 diff --git a/gfx/angle/src/compiler/translator/glslang.y b/gfx/angle/src/compiler/translator/glslang.y index 1680f7999d8b..304e4a927fa9 100644 --- a/gfx/angle/src/compiler/translator/glslang.y +++ b/gfx/angle/src/compiler/translator/glslang.y @@ -237,7 +237,7 @@ variable_identifier { TType type(EbtFloat, EbpUndefined); TVariable *fakeVariable = new TVariable($1.string, type); - context->symbolTable.declare(fakeVariable); + context->symbolTable.declare(*fakeVariable); variable = fakeVariable; } @@ -887,8 +887,7 @@ function_prototype else { // Insert the unmangled name to detect potential future redefinition as a variable. - TFunction *function = new TFunction(NewPoolTString($1->getName().c_str()), $1->getReturnType()); - context->symbolTable.getOuterLevel()->insert(function); + context->symbolTable.getOuterLevel()->insert($1->getName(), *$1); } // @@ -900,7 +899,7 @@ function_prototype // We're at the inner scope level of the function's arguments and body statement. // Add the function prototype to the surrounding scope instead. - context->symbolTable.getOuterLevel()->insert($$.function); + context->symbolTable.getOuterLevel()->insert(*$$.function); } ; @@ -1256,7 +1255,7 @@ type_specifier $$ = $2; $$.precision = $1; - if (!SupportsPrecision($2.type)) { + if (!SupportsPrecision($2.type) { context->error(@1, "illegal type for precision qualifier", getBasicString($2.type)); context->recover(); } @@ -1900,7 +1899,7 @@ function_definition // // Insert the parameters with name in the symbol table. // - if (! context->symbolTable.declare(variable)) { + if (! context->symbolTable.declare(*variable)) { context->error(@1, "redefinition", variable->getName().c_str()); context->recover(); delete variable; diff --git a/gfx/angle/src/compiler/translator/glslang_tab.cpp b/gfx/angle/src/compiler/translator/glslang_tab.cpp index fc0169e2de44..4743696d8bd2 100644 --- a/gfx/angle/src/compiler/translator/glslang_tab.cpp +++ b/gfx/angle/src/compiler/translator/glslang_tab.cpp @@ -807,19 +807,19 @@ static const yytype_uint16 yyrline[] = 1064, 1068, 1072, 1079, 1083, 1087, 1094, 1098, 1102, 1123, 1132, 1138, 1141, 1147, 1153, 1160, 1169, 1178, 1186, 1189, 1196, 1200, 1207, 1210, 1214, 1218, 1227, 1236, 1244, 1254, - 1266, 1269, 1272, 1278, 1285, 1288, 1294, 1297, 1300, 1306, - 1309, 1324, 1328, 1332, 1336, 1340, 1344, 1349, 1354, 1359, - 1364, 1369, 1374, 1379, 1384, 1389, 1394, 1399, 1404, 1409, - 1414, 1419, 1424, 1429, 1434, 1439, 1444, 1449, 1453, 1457, - 1461, 1465, 1469, 1473, 1477, 1481, 1485, 1489, 1493, 1497, - 1501, 1505, 1509, 1517, 1525, 1529, 1542, 1542, 1545, 1545, - 1551, 1554, 1570, 1573, 1582, 1586, 1592, 1599, 1614, 1618, - 1622, 1623, 1629, 1630, 1631, 1632, 1633, 1637, 1638, 1638, - 1638, 1648, 1649, 1653, 1653, 1654, 1654, 1659, 1662, 1672, - 1675, 1681, 1682, 1686, 1694, 1698, 1708, 1713, 1730, 1730, - 1735, 1735, 1742, 1742, 1750, 1753, 1759, 1762, 1768, 1772, - 1779, 1786, 1793, 1800, 1811, 1820, 1824, 1831, 1834, 1840, - 1840 + 1261, 1264, 1267, 1273, 1280, 1283, 1289, 1292, 1295, 1301, + 1304, 1319, 1323, 1327, 1331, 1335, 1339, 1344, 1349, 1354, + 1359, 1364, 1369, 1374, 1379, 1384, 1389, 1394, 1399, 1404, + 1409, 1414, 1419, 1424, 1429, 1434, 1439, 1444, 1448, 1452, + 1456, 1460, 1464, 1468, 1472, 1476, 1480, 1484, 1488, 1492, + 1496, 1500, 1504, 1512, 1520, 1524, 1537, 1537, 1540, 1540, + 1546, 1549, 1565, 1568, 1577, 1581, 1587, 1594, 1609, 1613, + 1617, 1618, 1624, 1625, 1626, 1627, 1628, 1632, 1633, 1633, + 1633, 1643, 1644, 1648, 1648, 1649, 1649, 1654, 1657, 1667, + 1670, 1676, 1677, 1681, 1689, 1693, 1703, 1708, 1725, 1725, + 1730, 1730, 1737, 1737, 1745, 1748, 1754, 1757, 1763, 1767, + 1774, 1781, 1788, 1795, 1806, 1815, 1819, 1826, 1829, 1835, + 1835 }; #endif @@ -2575,7 +2575,7 @@ yyreduce: { TType type(EbtFloat, EbpUndefined); TVariable *fakeVariable = new TVariable((yyvsp[(1) - (1)].lex).string, type); - context->symbolTable.declare(fakeVariable); + context->symbolTable.declare(*fakeVariable); variable = fakeVariable; } @@ -3436,8 +3436,7 @@ yyreduce: else { // Insert the unmangled name to detect potential future redefinition as a variable. - TFunction *function = new TFunction(NewPoolTString((yyvsp[(1) - (2)].interm.function)->getName().c_str()), (yyvsp[(1) - (2)].interm.function)->getReturnType()); - context->symbolTable.getOuterLevel()->insert(function); + context->symbolTable.getOuterLevel()->insert((yyvsp[(1) - (2)].interm.function)->getName(), *(yyvsp[(1) - (2)].interm.function)); } // @@ -3449,7 +3448,7 @@ yyreduce: // We're at the inner scope level of the function's arguments and body statement. // Add the function prototype to the surrounding scope instead. - context->symbolTable.getOuterLevel()->insert((yyval.interm).function); + context->symbolTable.getOuterLevel()->insert(*(yyval.interm).function); } break; @@ -3940,7 +3939,7 @@ yyreduce: (yyval.interm.type).precision = (yyvsp[(1) - (2)].interm.precision); if (!SupportsPrecision((yyvsp[(2) - (2)].interm.type).type)) { - context->error((yylsp[(1) - (2)]), "illegal type for precision qualifier", getBasicString((yyvsp[(2) - (2)].interm.type).type)); + context->error((yylsp[(1) - (1)]), "illegal type for precision qualifier", getBasicString((yyvsp[(2) - (2)].interm.type).type)); context->recover(); } } @@ -4968,7 +4967,7 @@ yyreduce: // // Insert the parameters with name in the symbol table. // - if (! context->symbolTable.declare(variable)) { + if (! context->symbolTable.declare(*variable)) { context->error((yylsp[(1) - (1)]), "redefinition", variable->getName().c_str()); context->recover(); delete variable; diff --git a/gfx/angle/src/compiler/translator/intermOut.cpp b/gfx/angle/src/compiler/translator/intermOut.cpp index c1a8c8cf5443..7f94ac31416b 100644 --- a/gfx/angle/src/compiler/translator/intermOut.cpp +++ b/gfx/angle/src/compiler/translator/intermOut.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -153,6 +153,18 @@ bool TOutputTraverser::visitUnary(Visit visit, TIntermUnary* node) case EOpPreIncrement: out << "Pre-Increment"; break; case EOpPreDecrement: out << "Pre-Decrement"; break; + case EOpConvIntToBool: out << "Convert int to bool"; break; + case EOpConvUIntToBool: out << "Convert uint to bool"; break; + case EOpConvFloatToBool:out << "Convert float to bool";break; + case EOpConvBoolToFloat:out << "Convert bool to float";break; + case EOpConvIntToFloat: out << "Convert int to float"; break; + case EOpConvUIntToFloat:out << "Convert uint to float";break; + case EOpConvFloatToInt: out << "Convert float to int"; break; + case EOpConvBoolToInt: out << "Convert bool to int"; break; + case EOpConvIntToUInt: out << "Convert int to uint"; break; + case EOpConvFloatToUInt:out << "Convert float to uint";break; + case EOpConvBoolToUInt: out << "Convert bool to uint"; break; + case EOpRadians: out << "radians"; break; case EOpDegrees: out << "degrees"; break; case EOpSin: out << "sine"; break; diff --git a/gfx/angle/src/compiler/translator/intermediate.h b/gfx/angle/src/compiler/translator/intermediate.h index 0c3a82bba19d..7c72099fe49c 100644 --- a/gfx/angle/src/compiler/translator/intermediate.h +++ b/gfx/angle/src/compiler/translator/intermediate.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -50,6 +50,19 @@ enum TOperator { EOpPreIncrement, EOpPreDecrement, + EOpConvIntToBool, + EOpConvUIntToBool, + EOpConvFloatToBool, + EOpConvBoolToFloat, + EOpConvIntToFloat, + EOpConvUIntToFloat, + EOpConvFloatToInt, + EOpConvBoolToInt, + EOpConvUIntToInt, + EOpConvIntToUInt, + EOpConvFloatToUInt, + EOpConvBoolToUInt, + // // binary operations // diff --git a/gfx/angle/src/compiler/translator/localintermediate.h b/gfx/angle/src/compiler/translator/localintermediate.h index ed818015a9e1..125dcd989a26 100644 --- a/gfx/angle/src/compiler/translator/localintermediate.h +++ b/gfx/angle/src/compiler/translator/localintermediate.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -24,6 +24,7 @@ public: TIntermediate(TInfoSink& i) : infoSink(i) { } TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TSourceLoc&); + TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*); TIntermTyped* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&); TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&); TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, const TSourceLoc&); @@ -35,6 +36,7 @@ public: TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc&); TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, const TSourceLoc&); TIntermConstantUnion* addConstantUnion(ConstantUnion*, const TType&, const TSourceLoc&); + TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ; bool parseConstTree(const TSourceLoc&, TIntermNode*, ConstantUnion*, TOperator, TType, bool singleConstantParam = false); TIntermNode* addLoop(TLoopType, TIntermNode*, TIntermTyped*, TIntermTyped*, TIntermNode*, const TSourceLoc&); TIntermBranch* addBranch(TOperator, const TSourceLoc&); diff --git a/gfx/angle/src/compiler/translator/osinclude.h b/gfx/angle/src/compiler/translator/osinclude.h new file mode 100644 index 000000000000..c3063d624a87 --- /dev/null +++ b/gfx/angle/src/compiler/translator/osinclude.h @@ -0,0 +1,66 @@ +// +// 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. +// + +#ifndef __OSINCLUDE_H +#define __OSINCLUDE_H + +// +// This file contains contains os-specific datatypes and +// declares any os-specific functions. +// + +#if defined(_WIN32) || defined(_WIN64) +#define ANGLE_OS_WIN +#elif defined(__APPLE__) || defined(__linux__) || \ + defined(__FreeBSD__) || defined(__OpenBSD__) || \ + defined(__NetBSD__) || defined(__DragonFly__) || \ + defined(__sun) || defined(ANDROID) || \ + defined(__GLIBC__) || defined(__GNU__) || \ + defined(__QNX__) +#define ANGLE_OS_POSIX +#else +#error Unsupported platform. +#endif + +#if defined(ANGLE_OS_WIN) +#define STRICT +#define VC_EXTRALEAN 1 +#include +#elif defined(ANGLE_OS_POSIX) +#include +#include +#include +#endif // ANGLE_OS_WIN + + +#include "compiler/translator/compilerdebug.h" + +// +// Thread Local Storage Operations +// +#if defined(ANGLE_OS_WIN) +typedef DWORD OS_TLSIndex; +#define OS_INVALID_TLS_INDEX (TLS_OUT_OF_INDEXES) +#elif defined(ANGLE_OS_POSIX) +typedef pthread_key_t OS_TLSIndex; +#define OS_INVALID_TLS_INDEX (static_cast(-1)) +#endif // ANGLE_OS_WIN + +OS_TLSIndex OS_AllocTLSIndex(); +bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue); +bool OS_FreeTLSIndex(OS_TLSIndex nIndex); + +inline void* OS_GetTLSValue(OS_TLSIndex nIndex) +{ + ASSERT(nIndex != OS_INVALID_TLS_INDEX); +#if defined(ANGLE_OS_WIN) + return TlsGetValue(nIndex); +#elif defined(ANGLE_OS_POSIX) + return pthread_getspecific(nIndex); +#endif // ANGLE_OS_WIN +} + +#endif // __OSINCLUDE_H diff --git a/gfx/angle/src/compiler/translator/ossource_posix.cpp b/gfx/angle/src/compiler/translator/ossource_posix.cpp new file mode 100644 index 000000000000..90a37574441c --- /dev/null +++ b/gfx/angle/src/compiler/translator/ossource_posix.cpp @@ -0,0 +1,64 @@ +// +// 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. +// + +// +// This file contains the posix specific functions +// +#include "compiler/translator/osinclude.h" + +#if !defined(ANGLE_OS_POSIX) +#error Trying to build a posix specific file in a non-posix build. +#endif + +// +// Thread Local Storage Operations +// +OS_TLSIndex OS_AllocTLSIndex() +{ + pthread_key_t pPoolIndex; + + // + // Create global pool key. + // + if ((pthread_key_create(&pPoolIndex, NULL)) != 0) { + assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage"); + return false; + } + else { + return pPoolIndex; + } +} + + +bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue) +{ + if (nIndex == OS_INVALID_TLS_INDEX) { + assert(0 && "OS_SetTLSValue(): Invalid TLS Index"); + return false; + } + + if (pthread_setspecific(nIndex, lpvValue) == 0) + return true; + else + return false; +} + + +bool OS_FreeTLSIndex(OS_TLSIndex nIndex) +{ + if (nIndex == OS_INVALID_TLS_INDEX) { + assert(0 && "OS_SetTLSValue(): Invalid TLS Index"); + return false; + } + + // + // Delete the global pool key. + // + if (pthread_key_delete(nIndex) == 0) + return true; + else + return false; +} diff --git a/gfx/angle/src/compiler/translator/ossource_win.cpp b/gfx/angle/src/compiler/translator/ossource_win.cpp new file mode 100644 index 000000000000..2cc5871b71d3 --- /dev/null +++ b/gfx/angle/src/compiler/translator/ossource_win.cpp @@ -0,0 +1,57 @@ +// +// 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. +// + +#include "compiler/translator/osinclude.h" +// +// This file contains contains the window's specific functions +// + +#if !defined(ANGLE_OS_WIN) +#error Trying to build a windows specific file in a non windows build. +#endif + + +// +// Thread Local Storage Operations +// +OS_TLSIndex OS_AllocTLSIndex() +{ + DWORD dwIndex = TlsAlloc(); + if (dwIndex == TLS_OUT_OF_INDEXES) { + assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage"); + return OS_INVALID_TLS_INDEX; + } + + return dwIndex; +} + + +bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue) +{ + if (nIndex == OS_INVALID_TLS_INDEX) { + assert(0 && "OS_SetTLSValue(): Invalid TLS Index"); + return false; + } + + if (TlsSetValue(nIndex, lpvValue)) + return true; + else + return false; +} + + +bool OS_FreeTLSIndex(OS_TLSIndex nIndex) +{ + if (nIndex == OS_INVALID_TLS_INDEX) { + assert(0 && "OS_SetTLSValue(): Invalid TLS Index"); + return false; + } + + if (TlsFree(nIndex)) + return true; + else + return false; +} diff --git a/gfx/angle/src/compiler/translator/parseConst.cpp b/gfx/angle/src/compiler/translator/parseConst.cpp index 05cf91247537..33617e53d9a2 100644 --- a/gfx/angle/src/compiler/translator/parseConst.cpp +++ b/gfx/angle/src/compiler/translator/parseConst.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -162,7 +162,6 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node) ConstantUnion* leftUnionArray = unionArray; size_t instanceSize = type.getObjectSize(); - TBasicType basicType = type.getBasicType(); if (index >= instanceSize) return; @@ -174,7 +173,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node) for (size_t i=0; i < objectSize; i++) { if (index >= instanceSize) return; - leftUnionArray[index].cast(basicType, rightUnionArray[i]); + leftUnionArray[index] = rightUnionArray[i]; (index)++; } @@ -187,7 +186,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node) if (i >= instanceSize) return; - leftUnionArray[i].cast(basicType, rightUnionArray[count]); + leftUnionArray[i] = rightUnionArray[count]; (index)++; @@ -204,7 +203,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node) { if (col == row) { - leftUnionArray[i].cast(basicType, rightUnionArray[0]); + leftUnionArray[i] = rightUnionArray[0]; } else { diff --git a/gfx/angle/src/compiler/translator/util.cpp b/gfx/angle/src/compiler/translator/util.cpp index bd1336431edf..077bdcc48b86 100644 --- a/gfx/angle/src/compiler/translator/util.cpp +++ b/gfx/angle/src/compiler/translator/util.cpp @@ -9,7 +9,6 @@ #include #include "compiler/preprocessor/numeric_lex.h" -#include "common/shadervars.h" bool atof_clamp(const char *str, float *value) { @@ -27,254 +26,3 @@ bool atoi_clamp(const char *str, int *value) return success; } -namespace sh -{ - -GLenum GLVariableType(const TType &type) -{ - if (type.getBasicType() == EbtFloat) - { - if (type.isScalar()) - { - return GL_FLOAT; - } - else if (type.isVector()) - { - switch (type.getNominalSize()) - { - case 2: return GL_FLOAT_VEC2; - case 3: return GL_FLOAT_VEC3; - case 4: return GL_FLOAT_VEC4; - default: UNREACHABLE(); - } - } - else if (type.isMatrix()) - { - switch (type.getCols()) - { - case 2: - switch (type.getRows()) - { - case 2: return GL_FLOAT_MAT2; - case 3: return GL_FLOAT_MAT2x3; - case 4: return GL_FLOAT_MAT2x4; - default: UNREACHABLE(); - } - - case 3: - switch (type.getRows()) - { - case 2: return GL_FLOAT_MAT3x2; - case 3: return GL_FLOAT_MAT3; - case 4: return GL_FLOAT_MAT3x4; - default: UNREACHABLE(); - } - - case 4: - switch (type.getRows()) - { - case 2: return GL_FLOAT_MAT4x2; - case 3: return GL_FLOAT_MAT4x3; - case 4: return GL_FLOAT_MAT4; - default: UNREACHABLE(); - } - - default: UNREACHABLE(); - } - } - else UNREACHABLE(); - } - else if (type.getBasicType() == EbtInt) - { - if (type.isScalar()) - { - return GL_INT; - } - else if (type.isVector()) - { - switch (type.getNominalSize()) - { - case 2: return GL_INT_VEC2; - case 3: return GL_INT_VEC3; - case 4: return GL_INT_VEC4; - default: UNREACHABLE(); - } - } - else UNREACHABLE(); - } - else if (type.getBasicType() == EbtUInt) - { - if (type.isScalar()) - { - return GL_UNSIGNED_INT; - } - else if (type.isVector()) - { - switch (type.getNominalSize()) - { - case 2: return GL_UNSIGNED_INT_VEC2; - case 3: return GL_UNSIGNED_INT_VEC3; - case 4: return GL_UNSIGNED_INT_VEC4; - default: UNREACHABLE(); - } - } - else UNREACHABLE(); - } - else if (type.getBasicType() == EbtBool) - { - if (type.isScalar()) - { - return GL_BOOL; - } - else if (type.isVector()) - { - switch (type.getNominalSize()) - { - case 2: return GL_BOOL_VEC2; - case 3: return GL_BOOL_VEC3; - case 4: return GL_BOOL_VEC4; - default: UNREACHABLE(); - } - } - else UNREACHABLE(); - } - - switch (type.getBasicType()) - { - case EbtSampler2D: return GL_SAMPLER_2D; - case EbtSampler3D: return GL_SAMPLER_3D; - case EbtSamplerCube: return GL_SAMPLER_CUBE; - case EbtSampler2DArray: return GL_SAMPLER_2D_ARRAY; - case EbtISampler2D: return GL_INT_SAMPLER_2D; - case EbtISampler3D: return GL_INT_SAMPLER_3D; - case EbtISamplerCube: return GL_INT_SAMPLER_CUBE; - case EbtISampler2DArray: return GL_INT_SAMPLER_2D_ARRAY; - case EbtUSampler2D: return GL_UNSIGNED_INT_SAMPLER_2D; - case EbtUSampler3D: return GL_UNSIGNED_INT_SAMPLER_3D; - case EbtUSamplerCube: return GL_UNSIGNED_INT_SAMPLER_CUBE; - case EbtUSampler2DArray: return GL_UNSIGNED_INT_SAMPLER_2D_ARRAY; - case EbtSampler2DShadow: return GL_SAMPLER_2D_SHADOW; - case EbtSamplerCubeShadow: return GL_SAMPLER_CUBE_SHADOW; - case EbtSampler2DArrayShadow: return GL_SAMPLER_2D_ARRAY_SHADOW; - default: UNREACHABLE(); - } - - return GL_NONE; -} - -GLenum GLVariablePrecision(const TType &type) -{ - if (type.getBasicType() == EbtFloat) - { - switch (type.getPrecision()) - { - case EbpHigh: - return GL_HIGH_FLOAT; - case EbpMedium: - return GL_MEDIUM_FLOAT; - case EbpLow: - return GL_LOW_FLOAT; - case EbpUndefined: - // Should be defined as the default precision by the parser - default: - UNREACHABLE(); - } - } - else if (type.getBasicType() == EbtInt || type.getBasicType() == EbtUInt) - { - switch (type.getPrecision()) - { - case EbpHigh: - return GL_HIGH_INT; - case EbpMedium: - return GL_MEDIUM_INT; - case EbpLow: - return GL_LOW_INT; - case EbpUndefined: - // Should be defined as the default precision by the parser - default: - UNREACHABLE(); - } - } - - // Other types (boolean, sampler) don't have a precision - return GL_NONE; -} - -TString ArrayString(const TType &type) -{ - if (!type.isArray()) - { - return ""; - } - - return "[" + str(type.getArraySize()) + "]"; -} - -bool IsVaryingOut(TQualifier qualifier) -{ - switch (qualifier) - { - case EvqVaryingOut: - case EvqInvariantVaryingOut: - case EvqSmoothOut: - case EvqFlatOut: - case EvqCentroidOut: - case EvqVertexOut: - return true; - - default: break; - } - - return false; -} - -bool IsVaryingIn(TQualifier qualifier) -{ - switch (qualifier) - { - case EvqVaryingIn: - case EvqInvariantVaryingIn: - case EvqSmoothIn: - case EvqFlatIn: - case EvqCentroidIn: - case EvqFragmentIn: - return true; - - default: break; - } - - return false; -} - -bool IsVarying(TQualifier qualifier) -{ - return IsVaryingIn(qualifier) || IsVaryingOut(qualifier); -} - -InterpolationType GetInterpolationType(TQualifier qualifier) -{ - switch (qualifier) - { - case EvqFlatIn: - case EvqFlatOut: - return INTERPOLATION_FLAT; - - case EvqSmoothIn: - case EvqSmoothOut: - case EvqVertexOut: - case EvqFragmentIn: - case EvqVaryingIn: - case EvqVaryingOut: - return INTERPOLATION_SMOOTH; - - case EvqCentroidIn: - case EvqCentroidOut: - return INTERPOLATION_CENTROID; - - default: UNREACHABLE(); - return INTERPOLATION_SMOOTH; - } -} - -} diff --git a/gfx/angle/src/compiler/translator/util.h b/gfx/angle/src/compiler/translator/util.h index 4dbaf3c9b8f4..dc69f39060d2 100644 --- a/gfx/angle/src/compiler/translator/util.h +++ b/gfx/angle/src/compiler/translator/util.h @@ -7,10 +7,6 @@ #ifndef COMPILER_UTIL_H #define COMPILER_UTIL_H -#include "compiler/translator/Types.h" -#include "angle_gl.h" -#include "common/shadervars.h" - // atof_clamp is like atof but // 1. it forces C locale, i.e. forcing '.' as decimal point. // 2. it clamps the value to -FLT_MAX or FLT_MAX if overflow happens. @@ -21,17 +17,4 @@ extern bool atof_clamp(const char *str, float *value); // Return false if overflow happens. extern bool atoi_clamp(const char *str, int *value); -namespace sh -{ - -GLenum GLVariableType(const TType &type); -GLenum GLVariablePrecision(const TType &type); -bool IsVaryingIn(TQualifier qualifier); -bool IsVaryingOut(TQualifier qualifier); -bool IsVarying(TQualifier qualifier); -InterpolationType GetInterpolationType(TQualifier qualifier); -TString ArrayString(const TType &type); - -} - #endif // COMPILER_UTIL_H diff --git a/gfx/angle/src/libEGL/Config.cpp b/gfx/angle/src/libEGL/Config.cpp index fdc41a95f0b5..0b47d55e2cf4 100644 --- a/gfx/angle/src/libEGL/Config.cpp +++ b/gfx/angle/src/libEGL/Config.cpp @@ -13,7 +13,10 @@ #include #include -#include "angle_gl.h" +#include +#include +#include +#include #include #include "common/debug.h" diff --git a/gfx/angle/src/libEGL/Display.cpp b/gfx/angle/src/libEGL/Display.cpp index cd936aac7fca..07b2daca849a 100644 --- a/gfx/angle/src/libEGL/Display.cpp +++ b/gfx/angle/src/libEGL/Display.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -13,7 +13,6 @@ #include #include #include -#include #include "common/debug.h" #include "common/mathutil.h" @@ -113,7 +112,7 @@ bool Display::initialize() return false; } - initDisplayExtensionString(); + initExtensionString(); initVendorString(); return true; @@ -344,7 +343,7 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle, return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); } - if (textureFormat != EGL_NO_TEXTURE && !mRenderer->getCaps().extensions.textureNPOT && (!gl::isPow2(width) || !gl::isPow2(height))) + if (textureFormat != EGL_NO_TEXTURE && !mRenderer->getNonPower2TextureSupport() && (!gl::isPow2(width) || !gl::isPow2(height))) { return error(EGL_BAD_MATCH, EGL_NO_SURFACE); } @@ -501,58 +500,48 @@ bool Display::hasExistingWindowSurface(HWND window) return false; } -std::string Display::generateClientExtensionString() +void Display::initExtensionString() { - std::vector extensions; + bool shareHandleSupported = mRenderer->getShareHandleSupport(); - extensions.push_back("EGL_EXT_client_extensions"); - - std::ostringstream stream; - std::copy(extensions.begin(), extensions.end(), std::ostream_iterator(stream, " ")); - return stream.str(); -} - -void Display::initDisplayExtensionString() -{ - std::vector extensions; + mExtensionString = ""; // Multi-vendor (EXT) extensions - extensions.push_back("EGL_EXT_create_context_robustness"); + mExtensionString += "EGL_EXT_create_context_robustness "; // ANGLE-specific extensions - if (mRenderer->getShareHandleSupport()) + if (shareHandleSupported) { - extensions.push_back("EGL_ANGLE_d3d_share_handle_client_buffer"); - extensions.push_back("EGL_ANGLE_surface_d3d_texture_2d_share_handle"); + mExtensionString += "EGL_ANGLE_d3d_share_handle_client_buffer "; } - extensions.push_back("EGL_ANGLE_query_surface_pointer"); - extensions.push_back("EGL_ANGLE_window_fixed_size"); + mExtensionString += "EGL_ANGLE_query_surface_pointer "; + + mExtensionString += "EGL_ANGLE_window_fixed_size "; + + if (shareHandleSupported) + { + mExtensionString += "EGL_ANGLE_surface_d3d_texture_2d_share_handle "; + } if (mRenderer->getPostSubBufferSupport()) { - extensions.push_back("EGL_NV_post_sub_buffer"); + mExtensionString += "EGL_NV_post_sub_buffer "; } // TODO: complete support for the EGL_KHR_create_context extension - extensions.push_back("EGL_KHR_create_context"); + mExtensionString += "EGL_KHR_create_context "; - std::ostringstream stream; - std::copy(extensions.begin(), extensions.end(), std::ostream_iterator(stream, " ")); - mDisplayExtensionString = stream.str(); + std::string::size_type end = mExtensionString.find_last_not_of(' '); + if (end != std::string::npos) + { + mExtensionString.resize(end+1); + } } -const char *Display::getExtensionString(egl::Display *display) +const char *Display::getExtensionString() const { - if (display != EGL_NO_DISPLAY) - { - return display->mDisplayExtensionString.c_str(); - } - else - { - static std::string clientExtensions = generateClientExtensionString(); - return clientExtensions.c_str(); - } + return mExtensionString.c_str(); } void Display::initVendorString() diff --git a/gfx/angle/src/libEGL/Display.h b/gfx/angle/src/libEGL/Display.h index a4d137182c7a..e394260e3187 100644 --- a/gfx/angle/src/libEGL/Display.h +++ b/gfx/angle/src/libEGL/Display.h @@ -35,8 +35,6 @@ class Display static egl::Display *getDisplay(EGLNativeDisplayType displayId); - static const char *getExtensionString(egl::Display *display); - bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig); bool getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value); @@ -84,12 +82,9 @@ class Display rx::Renderer *mRenderer; - static std::string generateClientExtensionString(); - - void initDisplayExtensionString(); - std::string mDisplayExtensionString; - + void initExtensionString(); void initVendorString(); + std::string mExtensionString; std::string mVendorString; }; } diff --git a/gfx/angle/src/libEGL/libEGL.cpp b/gfx/angle/src/libEGL/libEGL.cpp index 47438fd49396..f5a60227f8b5 100644 --- a/gfx/angle/src/libEGL/libEGL.cpp +++ b/gfx/angle/src/libEGL/libEGL.cpp @@ -169,7 +169,8 @@ const char *__stdcall eglQueryString(EGLDisplay dpy, EGLint name) ANGLE_TRY { egl::Display *display = static_cast(dpy); - if (!(display == EGL_NO_DISPLAY && name == EGL_EXTENSIONS) && !validateDisplay(display)) + + if (!validateDisplay(display)) { return NULL; } @@ -179,14 +180,14 @@ const char *__stdcall eglQueryString(EGLDisplay dpy, EGLint name) case EGL_CLIENT_APIS: return egl::success("OpenGL_ES"); case EGL_EXTENSIONS: - return egl::success(egl::Display::getExtensionString(display)); + return egl::success(display->getExtensionString()); case EGL_VENDOR: return egl::success(display->getVendorString()); case EGL_VERSION: return egl::success("1.4 (ANGLE " ANGLE_VERSION_STRING ")"); - default: - return egl::error(EGL_BAD_PARAMETER, (const char*)NULL); } + + return egl::error(EGL_BAD_PARAMETER, (const char*)NULL); } ANGLE_CATCH_ALL { diff --git a/gfx/angle/src/libEGL/libEGL.def b/gfx/angle/src/libEGL/libEGL.def index 2cede25d7c91..71a5e6797704 100644 --- a/gfx/angle/src/libEGL/libEGL.def +++ b/gfx/angle/src/libEGL/libEGL.def @@ -1,36 +1,36 @@ -LIBRARY libEGL +LIBRARY libEGL EXPORTS - eglBindAPI @14 - eglBindTexImage @20 - eglChooseConfig @7 - eglCopyBuffers @33 - eglCreateContext @23 - eglCreatePbufferFromClientBuffer @18 - eglCreatePbufferSurface @10 - eglCreatePixmapSurface @11 - eglCreateWindowSurface @9 - eglDestroyContext @24 - eglDestroySurface @12 - eglGetConfigAttrib @8 - eglGetConfigs @6 - eglGetCurrentContext @26 - eglGetCurrentDisplay @28 - eglGetCurrentSurface @27 - eglGetDisplay @2 - eglGetError @1 - eglGetProcAddress @34 - eglInitialize @3 - eglMakeCurrent @25 - eglQueryAPI @15 - eglQueryContext @29 - eglQueryString @5 - eglQuerySurface @13 - eglReleaseTexImage @21 - eglReleaseThread @17 - eglSurfaceAttrib @19 - eglSwapBuffers @32 - eglSwapInterval @22 - eglTerminate @4 - eglWaitClient @16 - eglWaitGL @30 - eglWaitNative @31 + eglBindAPI @14 + eglBindTexImage @20 + eglChooseConfig @7 + eglCopyBuffers @33 + eglCreateContext @23 + eglCreatePbufferFromClientBuffer @18 + eglCreatePbufferSurface @10 + eglCreatePixmapSurface @11 + eglCreateWindowSurface @9 + eglDestroyContext @24 + eglDestroySurface @12 + eglGetConfigAttrib @8 + eglGetConfigs @6 + eglGetCurrentContext @26 + eglGetCurrentDisplay @28 + eglGetCurrentSurface @27 + eglGetDisplay @2 + eglGetError @1 + eglGetProcAddress @34 + eglInitialize @3 + eglMakeCurrent @25 + eglQueryAPI @15 + eglQueryContext @29 + eglQueryString @5 + eglQuerySurface @13 + eglReleaseTexImage @21 + eglReleaseThread @17 + eglSurfaceAttrib @19 + eglSwapBuffers @32 + eglSwapInterval @22 + eglTerminate @4 + eglWaitClient @16 + eglWaitGL @30 + eglWaitNative @31 \ No newline at end of file diff --git a/gfx/angle/src/libEGL/main.cpp b/gfx/angle/src/libEGL/main.cpp index 0f8439c4a453..80dcc3458075 100644 --- a/gfx/angle/src/libEGL/main.cpp +++ b/gfx/angle/src/libEGL/main.cpp @@ -9,42 +9,42 @@ #include "libEGL/main.h" #include "common/debug.h" -#include "common/tls.h" -static TLSIndex currentTLS = TLS_OUT_OF_INDEXES; +static DWORD currentTLS = TLS_OUT_OF_INDEXES; namespace egl { Current *AllocateCurrent() { - ASSERT(currentTLS != TLS_OUT_OF_INDEXES); - if (currentTLS == TLS_OUT_OF_INDEXES) + Current *current = (egl::Current*)LocalAlloc(LPTR, sizeof(egl::Current)); + + if (!current) { + ERR("Could not allocate thread local storage."); return NULL; } - Current *current = new Current(); + ASSERT(currentTLS != TLS_OUT_OF_INDEXES); + TlsSetValue(currentTLS, current); + current->error = EGL_SUCCESS; current->API = EGL_OPENGL_ES_API; current->display = EGL_NO_DISPLAY; current->drawSurface = EGL_NO_SURFACE; current->readSurface = EGL_NO_SURFACE; - if (!SetTLSValue(currentTLS, current)) - { - ERR("Could not set thread local storage."); - return NULL; - } - return current; } void DeallocateCurrent() { - Current *current = reinterpret_cast(GetTLSValue(currentTLS)); - SafeDelete(current); - SetTLSValue(currentTLS, NULL); + void *current = TlsGetValue(currentTLS); + + if (current) + { + LocalFree((HLOCAL)current); + } } } @@ -70,13 +70,14 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved } #endif - currentTLS = CreateTLSIndex(); + currentTLS = TlsAlloc(); + if (currentTLS == TLS_OUT_OF_INDEXES) { return FALSE; } } - // Fall through to initialize index + // Fall throught to initialize index case DLL_THREAD_ATTACH: { egl::AllocateCurrent(); @@ -90,7 +91,7 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved case DLL_PROCESS_DETACH: { egl::DeallocateCurrent(); - DestroyTLSIndex(currentTLS); + TlsFree(currentTLS); } break; default: @@ -105,7 +106,7 @@ namespace egl Current *GetCurrentData() { - Current *current = reinterpret_cast(GetTLSValue(currentTLS)); + Current *current = (Current*)TlsGetValue(currentTLS); // ANGLE issue 488: when the dll is loaded after thread initialization, // thread local storage (current) might not exist yet. diff --git a/gfx/angle/src/libEGL/moz.build b/gfx/angle/src/libEGL/moz.build index 14e384f8b2fb..1542034fd06e 100644 --- a/gfx/angle/src/libEGL/moz.build +++ b/gfx/angle/src/libEGL/moz.build @@ -7,7 +7,6 @@ UNIFIED_SOURCES += [ '../common/event_tracer.cpp', '../common/mathutil.cpp', '../common/RefCountObject.cpp', - '../common/tls.cpp', '../common/utilities.cpp', 'Config.cpp', 'Display.cpp', @@ -54,7 +53,6 @@ DISABLE_STL_WRAPPING = True LOCAL_INCLUDES += [ '../../include', '../../src' ] USE_LIBS += [ 'libGLESv2' ] -EXTRA_DSO_LDOPTS += [ '../libGLESv2/libGLESv2.lib' ] SharedLibrary('libEGL') diff --git a/gfx/angle/src/libGLESv2.gypi b/gfx/angle/src/libGLESv2.gypi index 0c535cae1d6e..b2dce1224da6 100644 --- a/gfx/angle/src/libGLESv2.gypi +++ b/gfx/angle/src/libGLESv2.gypi @@ -38,7 +38,7 @@ 'createBufferStorage(); } Buffer::~Buffer() { - delete mBuffer; + delete mBufferStorage; + delete mStaticVertexBuffer; + delete mStaticIndexBuffer; } void Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage) { + mBufferStorage->clear(); + mIndexRangeCache.clear(); + mBufferStorage->setData(data, size, 0); + mUsage = usage; - mSize = size; - mBuffer->setData(data, size, usage); + + invalidateStaticData(); + + if (usage == GL_STATIC_DRAW) + { + mStaticVertexBuffer = new rx::StaticVertexBufferInterface(mRenderer); + mStaticIndexBuffer = new rx::StaticIndexBufferInterface(mRenderer); + } } void Buffer::bufferSubData(const void *data, GLsizeiptr size, GLintptr offset) { - mBuffer->setSubData(data, size, offset); + mBufferStorage->setData(data, size, offset); + mIndexRangeCache.invalidateRange(offset, size); + invalidateStaticData(); } void Buffer::copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) { - mBuffer->copySubData(source->getImplementation(), size, sourceOffset, destOffset); + mBufferStorage->copyData(source->mBufferStorage, size, sourceOffset, destOffset); + invalidateStaticData(); } GLvoid *Buffer::mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access) { ASSERT(!mMapped); - ASSERT(offset + length <= mSize); - void *dataPointer = mBuffer->map(offset, length, access); + void *dataPointer = mBufferStorage->map(access); mMapped = GL_TRUE; - mMapPointer = static_cast(static_cast(dataPointer)); + mMapPointer = static_cast(static_cast(dataPointer) + offset); mMapOffset = static_cast(offset); mMapLength = static_cast(length); mAccessFlags = static_cast(access); @@ -71,7 +92,7 @@ void Buffer::unmap() { ASSERT(mMapped); - mBuffer->unmap(); + mBufferStorage->unmap(); mMapped = GL_FALSE; mMapPointer = NULL; @@ -80,10 +101,94 @@ void Buffer::unmap() mAccessFlags = 0; } +rx::BufferStorage *Buffer::getStorage() const +{ + return mBufferStorage; +} + +GLint64 Buffer::size() const +{ + return static_cast(mBufferStorage->getSize()); +} + +GLenum Buffer::usage() const +{ + return mUsage; +} + +GLint Buffer::accessFlags() const +{ + return mAccessFlags; +} + +GLboolean Buffer::mapped() const +{ + return mMapped; +} + +GLvoid *Buffer::mapPointer() const +{ + return mMapPointer; +} + +GLint64 Buffer::mapOffset() const +{ + return mMapOffset; +} + +GLint64 Buffer::mapLength() const +{ + return mMapLength; +} + void Buffer::markTransformFeedbackUsage() { - // TODO: Only used by the DX11 backend. Refactor to a more appropriate place. - mBuffer->markTransformFeedbackUsage(); + mBufferStorage->markTransformFeedbackUsage(); + invalidateStaticData(); +} + +rx::StaticVertexBufferInterface *Buffer::getStaticVertexBuffer() +{ + return mStaticVertexBuffer; +} + +rx::StaticIndexBufferInterface *Buffer::getStaticIndexBuffer() +{ + return mStaticIndexBuffer; +} + +void Buffer::invalidateStaticData() +{ + if ((mStaticVertexBuffer && mStaticVertexBuffer->getBufferSize() != 0) || (mStaticIndexBuffer && mStaticIndexBuffer->getBufferSize() != 0)) + { + delete mStaticVertexBuffer; + mStaticVertexBuffer = NULL; + + delete mStaticIndexBuffer; + mStaticIndexBuffer = NULL; + } + + mUnmodifiedDataUse = 0; +} + +// Creates static buffers if sufficient used data has been left unmodified +void Buffer::promoteStaticUsage(int dataSize) +{ + if (!mStaticVertexBuffer && !mStaticIndexBuffer) + { + mUnmodifiedDataUse += dataSize; + + if (mUnmodifiedDataUse > 3 * mBufferStorage->getSize()) + { + mStaticVertexBuffer = new rx::StaticVertexBufferInterface(mRenderer); + mStaticIndexBuffer = new rx::StaticIndexBufferInterface(mRenderer); + } + } +} + +rx::IndexRangeCache *Buffer::getIndexRangeCache() +{ + return &mIndexRangeCache; } } diff --git a/gfx/angle/src/libGLESv2/Buffer.h b/gfx/angle/src/libGLESv2/Buffer.h index 389c3d4b00c1..55fbdeb1c9b3 100644 --- a/gfx/angle/src/libGLESv2/Buffer.h +++ b/gfx/angle/src/libGLESv2/Buffer.h @@ -13,11 +13,14 @@ #include "common/angleutils.h" #include "common/RefCountObject.h" +#include "libGLESv2/renderer/IndexRangeCache.h" namespace rx { class Renderer; -class BufferImpl; +class BufferStorage; +class StaticIndexBufferInterface; +class StaticVertexBufferInterface; }; namespace gl @@ -26,7 +29,7 @@ namespace gl class Buffer : public RefCountObject { public: - Buffer(rx::BufferImpl *impl, GLuint id); + Buffer(rx::Renderer *renderer, GLuint id); virtual ~Buffer(); @@ -36,30 +39,43 @@ class Buffer : public RefCountObject GLvoid *mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access); void 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; } + GLenum usage() const; + GLint accessFlags() const; + GLboolean mapped() const; + GLvoid *mapPointer() const; + GLint64 mapOffset() const; + GLint64 mapLength() const; - rx::BufferImpl *getImplementation() const { return mBuffer; } + rx::BufferStorage *getStorage() const; + GLint64 size() const; void markTransformFeedbackUsage(); + rx::StaticVertexBufferInterface *getStaticVertexBuffer(); + rx::StaticIndexBufferInterface *getStaticIndexBuffer(); + void invalidateStaticData(); + void promoteStaticUsage(int dataSize); + + rx::IndexRangeCache *getIndexRangeCache(); + private: DISALLOW_COPY_AND_ASSIGN(Buffer); - rx::BufferImpl *mBuffer; - + rx::Renderer *mRenderer; GLenum mUsage; - GLsizeiptr mSize; GLint mAccessFlags; GLboolean mMapped; GLvoid *mMapPointer; GLint64 mMapOffset; GLint64 mMapLength; + + rx::BufferStorage *mBufferStorage; + + rx::IndexRangeCache mIndexRangeCache; + + rx::StaticVertexBufferInterface *mStaticVertexBuffer; + rx::StaticIndexBufferInterface *mStaticIndexBuffer; + unsigned int mUnmodifiedDataUse; }; } diff --git a/gfx/angle/src/libGLESv2/Caps.cpp b/gfx/angle/src/libGLESv2/Caps.cpp deleted file mode 100644 index 39e81dd9085a..000000000000 --- a/gfx/angle/src/libGLESv2/Caps.cpp +++ /dev/null @@ -1,346 +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 -#include - -namespace gl -{ - -TextureCaps::TextureCaps() - : texture2D(false), - textureCubeMap(false), - texture3D(false), - texture2DArray(false), - filtering(false), - colorRendering(false), - depthRendering(false), - stencilRendering(false), - sampleCounts() -{ -} - -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; -} - -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, GLuint minClientVersion, GLuint maxClientVersion, bool supported, - GLuint curClientVersion, std::vector *extensionVector) -{ - if (supported && minClientVersion >= curClientVersion && (maxClientVersion == 0 || curClientVersion <= maxClientVersion)) - { - extensionVector->push_back(extension); - } -} - -std::vector Extensions::getStrings(GLuint clientVersion) const -{ - std::vector extensionStrings; - - // | Extension name | Min | Max | Supported flag | Current | Output vector | - // | | ver | ver | | version | | - InsertExtensionString("GL_OES_element_index_uint", 2, 0, elementIndexUint, clientVersion, &extensionStrings); - InsertExtensionString("GL_OES_packed_depth_stencil", 2, 0, packedDepthStencil, clientVersion, &extensionStrings); - InsertExtensionString("GL_OES_get_program_binary", 2, 0, getProgramBinary, clientVersion, &extensionStrings); - InsertExtensionString("GL_OES_rgb8_rgba8", 2, 0, rgb8rgba8, clientVersion, &extensionStrings); - InsertExtensionString("GL_EXT_texture_format_BGRA8888", 2, 0, textureFormatBGRA8888, clientVersion, &extensionStrings); - InsertExtensionString("GL_EXT_read_format_bgra", 2, 0, readFormatBGRA, clientVersion, &extensionStrings); - InsertExtensionString("GL_NV_pixel_buffer_object", 2, 0, pixelBufferObject, clientVersion, &extensionStrings); - InsertExtensionString("GL_OES_mapbuffer", 2, 0, mapBuffer, clientVersion, &extensionStrings); - InsertExtensionString("GL_EXT_map_buffer_range", 2, 0, mapBufferRange, clientVersion, &extensionStrings); - InsertExtensionString("GL_OES_texture_half_float", 2, 0, textureHalfFloat, clientVersion, &extensionStrings); - InsertExtensionString("GL_OES_texture_half_float_linear", 2, 0, textureHalfFloatLinear, clientVersion, &extensionStrings); - InsertExtensionString("GL_OES_texture_float", 2, 0, textureFloat, clientVersion, &extensionStrings); - InsertExtensionString("GL_OES_texture_float_linear", 2, 0, textureFloatLinear, clientVersion, &extensionStrings); - InsertExtensionString("GL_EXT_texture_rg", 2, 0, textureRG, clientVersion, &extensionStrings); - InsertExtensionString("GL_EXT_texture_compression_dxt1", 2, 0, textureCompressionDXT1, clientVersion, &extensionStrings); - InsertExtensionString("GL_ANGLE_texture_compression_dxt3", 2, 0, textureCompressionDXT3, clientVersion, &extensionStrings); - InsertExtensionString("GL_ANGLE_texture_compression_dxt5", 2, 0, textureCompressionDXT5, clientVersion, &extensionStrings); - InsertExtensionString("GL_EXT_sRGB", 2, 0, sRGB, clientVersion, &extensionStrings); // FIXME: Don't advertise in ES3 - InsertExtensionString("GL_ANGLE_depth_texture", 2, 0, depthTextures, clientVersion, &extensionStrings); - InsertExtensionString("GL_EXT_texture_storage", 2, 0, textureStorage, clientVersion, &extensionStrings); - InsertExtensionString("GL_OES_texture_npot", 2, 0, textureNPOT, clientVersion, &extensionStrings); - InsertExtensionString("GL_EXT_draw_buffers", 2, 0, drawBuffers, clientVersion, &extensionStrings); - InsertExtensionString("GL_EXT_texture_filter_anisotropic", 2, 0, textureFilterAnisotropic, clientVersion, &extensionStrings); - InsertExtensionString("GL_EXT_occlusion_query_boolean", 2, 0, occlusionQueryBoolean, clientVersion, &extensionStrings); - InsertExtensionString("GL_NV_fence", 2, 0, fence, clientVersion, &extensionStrings); - InsertExtensionString("GL_ANGLE_timer_query", 2, 0, timerQuery, clientVersion, &extensionStrings); - InsertExtensionString("GL_EXT_robustness", 2, 0, robustness, clientVersion, &extensionStrings); - InsertExtensionString("GL_EXT_blend_minmax", 2, 0, blendMinMax, clientVersion, &extensionStrings); - InsertExtensionString("GL_ANGLE_framebuffer_blit", 2, 0, framebufferBlit, clientVersion, &extensionStrings); - InsertExtensionString("GL_ANGLE_framebuffer_multisample", 2, 0, framebufferMultisample, clientVersion, &extensionStrings); - InsertExtensionString("GL_ANGLE_instanced_arrays", 2, 0, instancedArrays, clientVersion, &extensionStrings); - InsertExtensionString("GL_ANGLE_pack_reverse_row_order", 2, 0, packReverseRowOrder, clientVersion, &extensionStrings); - InsertExtensionString("GL_OES_standard_derivatives", 2, 0, standardDerivatives, clientVersion, &extensionStrings); - InsertExtensionString("GL_EXT_shader_texture_lod", 2, 0, shaderTextureLOD, clientVersion, &extensionStrings); - InsertExtensionString("GL_EXT_frag_depth", 2, 0, fragDepth, clientVersion, &extensionStrings); - InsertExtensionString("GL_ANGLE_texture_usage", 2, 0, textureUsage, clientVersion, &extensionStrings); - InsertExtensionString("GL_ANGLE_translated_shader_source", 2, 0, translatedShaderSource, clientVersion, &extensionStrings); - InsertExtensionString("GL_EXT_color_buffer_float", 3, 0, colorBufferFloat, clientVersion, &extensionStrings); - - return extensionStrings; -} - -static bool GetFormatSupport(const TextureCapsMap &textureCaps, const std::vector &requiredFormats, - bool requiresFiltering, bool requiresColorBuffer, bool requiresDepthStencil) -{ - for (size_t i = 0; i < requiredFormats.size(); i++) - { - const TextureCaps &cap = textureCaps.get(requiredFormats[i]); - - if (requiresFiltering && !cap.filtering) - { - return false; - } - - if (requiresColorBuffer && !cap.colorRendering) - { - return false; - } - - if (requiresDepthStencil && !cap.depthRendering) - { - return false; - } - } - - return true; -} - -// Checks for GL_OES_rgb8_rgba8 support -static bool DetermineRGB8AndRGBA8TextureSupport(const TextureCapsMap &textureCaps) -{ - std::vector requiredFormats; - requiredFormats.push_back(GL_RGB8); - requiredFormats.push_back(GL_RGBA8); - - return GetFormatSupport(textureCaps, requiredFormats, true, true, false); -} - -// Checks for GL_EXT_texture_format_BGRA8888 support -static bool DetermineBGRA8TextureSupport(const TextureCapsMap &textureCaps) -{ - std::vector requiredFormats; - requiredFormats.push_back(GL_BGRA8_EXT); - - return GetFormatSupport(textureCaps, requiredFormats, true, true, false); -} - -// Checks for GL_OES_texture_half_float support -static bool DetermineHalfFloatTextureSupport(const TextureCapsMap &textureCaps) -{ - std::vector requiredFormats; - requiredFormats.push_back(GL_RGB16F); - requiredFormats.push_back(GL_RGBA16F); - - return GetFormatSupport(textureCaps, requiredFormats, false, true, false); -} - -// Checks for GL_OES_texture_half_float_linear support -static bool DetermineHalfFloatTextureFilteringSupport(const TextureCapsMap &textureCaps) -{ - std::vector requiredFormats; - requiredFormats.push_back(GL_RGB16F); - requiredFormats.push_back(GL_RGBA16F); - - return GetFormatSupport(textureCaps, requiredFormats, true, false, false); -} - -// Checks for GL_OES_texture_float support -static bool DetermineFloatTextureSupport(const TextureCapsMap &textureCaps) -{ - std::vector requiredFormats; - requiredFormats.push_back(GL_RGB32F); - requiredFormats.push_back(GL_RGBA32F); - - return GetFormatSupport(textureCaps, requiredFormats, false, true, false); -} - -// Checks for GL_OES_texture_float_linear support -static bool DetermineFloatTextureFilteringSupport(const TextureCapsMap &textureCaps) -{ - std::vector requiredFormats; - requiredFormats.push_back(GL_RGB32F); - requiredFormats.push_back(GL_RGBA32F); - - return GetFormatSupport(textureCaps, requiredFormats, true, false, false); -} - -// Checks for GL_EXT_texture_rg support -static bool DetermineRGTextureSupport(const TextureCapsMap &textureCaps, bool checkHalfFloatFormats, bool checkFloatFormats) -{ - std::vector 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, false, false); -} - -// Check for GL_EXT_texture_compression_dxt1 -static bool DetermineDXT1TextureSupport(const TextureCapsMap &textureCaps) -{ - std::vector requiredFormats; - requiredFormats.push_back(GL_COMPRESSED_RGB_S3TC_DXT1_EXT); - requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT); - - return GetFormatSupport(textureCaps, requiredFormats, true, false, false); -} - -// Check for GL_ANGLE_texture_compression_dxt3 -static bool DetermineDXT3TextureSupport(const TextureCapsMap &textureCaps) -{ - std::vector requiredFormats; - requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE); - - return GetFormatSupport(textureCaps, requiredFormats, true, false, false); -} - -// Check for GL_ANGLE_texture_compression_dxt5 -static bool DetermineDXT5TextureSupport(const TextureCapsMap &textureCaps) -{ - std::vector requiredFormats; - requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE); - - return GetFormatSupport(textureCaps, requiredFormats, true, false, false); -} - -// Check for GL_ANGLE_texture_compression_dxt5 -static bool DetermineSRGBTextureSupport(const TextureCapsMap &textureCaps) -{ - std::vector requiredFilterFormats; - requiredFilterFormats.push_back(GL_SRGB8); - requiredFilterFormats.push_back(GL_SRGB8_ALPHA8); - - std::vector requiredRenderFormats; - requiredRenderFormats.push_back(GL_SRGB8_ALPHA8); - - return GetFormatSupport(textureCaps, requiredFilterFormats, true, false, false) && - GetFormatSupport(textureCaps, requiredRenderFormats, false, true, false); -} - -// Check for GL_ANGLE_depth_texture -static bool DetermineDepthTextureSupport(const TextureCapsMap &textureCaps) -{ - std::vector 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, false, true); -} - -// Check for GL_EXT_color_buffer_float -static bool DetermineColorBufferFloatSupport(const TextureCapsMap &textureCaps) -{ - std::vector 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, false, true, false); -} - -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() -{ -} - -} diff --git a/gfx/angle/src/libGLESv2/Caps.h b/gfx/angle/src/libGLESv2/Caps.h deleted file mode 100644 index 04da664f911c..000000000000 --- a/gfx/angle/src/libGLESv2/Caps.h +++ /dev/null @@ -1,203 +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 -#include -#include -#include - -namespace gl -{ - -struct TextureCaps -{ - TextureCaps(); - - bool texture2D; - bool textureCubeMap; - bool texture3D; - bool texture2DArray; - bool filtering; - bool colorRendering; - bool depthRendering; - bool stencilRendering; - - std::set sampleCounts; -}; - -class TextureCapsMap -{ - public: - void insert(GLenum internalFormat, const TextureCaps &caps); - void remove(GLenum internalFormat); - - const TextureCaps &get(GLenum internalFormat) const; - - private: - typedef std::unordered_map InternalFormatToCapsMap; - InternalFormatToCapsMap mCapsMap; -}; - -struct Extensions -{ - Extensions(); - - // Generate a vector of supported extension strings - std::vector getStrings(GLuint clientVersion) 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_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; - - // 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(); - - // Texture format support - TextureCapsMap textureCaps; - - // Extension support - Extensions extensions; -}; - -} - -#endif // LIBGLESV2_CAPS_H diff --git a/gfx/angle/src/libGLESv2/constants.h b/gfx/angle/src/libGLESv2/Constants.h similarity index 100% rename from gfx/angle/src/libGLESv2/constants.h rename to gfx/angle/src/libGLESv2/Constants.h diff --git a/gfx/angle/src/libGLESv2/Context.cpp b/gfx/angle/src/libGLESv2/Context.cpp index 26451fa84804..79b47c8c1e16 100644 --- a/gfx/angle/src/libGLESv2/Context.cpp +++ b/gfx/angle/src/libGLESv2/Context.cpp @@ -16,14 +16,13 @@ #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/Texture.h" #include "libGLESv2/ResourceManager.h" -#include "libGLESv2/renderer/d3d/IndexDataManager.h" +#include "libGLESv2/renderer/IndexDataManager.h" #include "libGLESv2/renderer/RenderTarget.h" #include "libGLESv2/renderer/Renderer.h" #include "libGLESv2/VertexArray.h" @@ -38,6 +37,15 @@ namespace gl { +static const char* makeStaticString(const std::string& str) +{ + static std::set strings; + std::set::iterator it = strings.find(str); + if (it != strings.end()) + return it->c_str(); + + return strings.insert(str).first->c_str(); +} Context::Context(int clientVersion, const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess) : mRenderer(renderer) { @@ -195,6 +203,7 @@ Context::Context(int clientVersion, const gl::Context *shareContext, rx::Rendere mState.currentProgram = 0; mCurrentProgramBinary.set(NULL); + mCombinedExtensionsString = NULL; mRendererString = NULL; mInvalidEnum = false; @@ -209,6 +218,12 @@ Context::Context(int clientVersion, const gl::Context *shareContext, rx::Rendere mResetStrategy = (notifyResets ? GL_LOSE_CONTEXT_ON_RESET_EXT : GL_NO_RESET_NOTIFICATION_EXT); mRobustAccess = robustAccess; + mSupportsBGRATextures = false; + mSupportsDXT1Textures = false; + mSupportsDXT3Textures = false; + mSupportsDXT5Textures = false; + mSupportsEventQueries = false; + mSupportsOcclusionQueries = false; mNumCompressedTextureFormats = 0; } @@ -313,6 +328,8 @@ void Context::makeCurrent(egl::Surface *surface) mMajorShaderModel = mRenderer->getMajorShaderModel(); mMaximumPointSize = mRenderer->getMaxPointSize(); mSupportsVertexTexture = mRenderer->getVertexTextureSupport(); + mSupportsNonPower2Texture = mRenderer->getNonPower2TextureSupport(); + mSupportsInstancing = mRenderer->getInstancingSupport(); mMaxViewportDimension = mRenderer->getMaxViewportDimension(); mMax2DTextureDimension = std::min(std::min(mRenderer->getMaxTextureWidth(), mRenderer->getMaxTextureHeight()), @@ -326,29 +343,50 @@ void Context::makeCurrent(egl::Surface *surface) mMaxCubeTextureLevel = log2(mMaxCubeTextureDimension) + 1; mMax3DTextureLevel = log2(mMax3DTextureDimension) + 1; mMax2DArrayTextureLevel = log2(mMax2DTextureDimension) + 1; + mMaxTextureAnisotropy = mRenderer->getTextureMaxAnisotropy(); TRACE("Max2DTextureDimension=%d, MaxCubeTextureDimension=%d, Max3DTextureDimension=%d, Max2DArrayTextureLayers = %d, " "Max2DTextureLevel=%d, MaxCubeTextureLevel=%d, Max3DTextureLevel=%d, Max2DArrayTextureLevel=%d, " - "MaxRenderbufferDimension=%d", + "MaxRenderbufferDimension=%d, MaxTextureAnisotropy=%f", mMax2DTextureDimension, mMaxCubeTextureDimension, mMax3DTextureDimension, mMax2DArrayTextureLayers, mMax2DTextureLevel, mMaxCubeTextureLevel, mMax3DTextureLevel, mMax2DArrayTextureLevel, - mMaxRenderbufferDimension); + mMaxRenderbufferDimension, mMaxTextureAnisotropy); + + mSupportsEventQueries = mRenderer->getEventQuerySupport(); + mSupportsOcclusionQueries = mRenderer->getOcclusionQuerySupport(); + mSupportsBGRATextures = mRenderer->getBGRATextureSupport(); + mSupportsDXT1Textures = mRenderer->getDXT1TextureSupport(); + mSupportsDXT3Textures = mRenderer->getDXT3TextureSupport(); + mSupportsDXT5Textures = mRenderer->getDXT5TextureSupport(); + mSupportsFloat32Textures = mRenderer->getFloat32TextureSupport(); + mSupportsFloat32LinearFilter = mRenderer->getFloat32TextureFilteringSupport(); + mSupportsFloat32RenderableTextures = mRenderer->getFloat32TextureRenderingSupport(); + mSupportsFloat16Textures = mRenderer->getFloat16TextureSupport(); + mSupportsFloat16LinearFilter = mRenderer->getFloat16TextureFilteringSupport(); + mSupportsFloat16RenderableTextures = mRenderer->getFloat16TextureRenderingSupport(); + mSupportsLuminanceTextures = mRenderer->getLuminanceTextureSupport(); + mSupportsLuminanceAlphaTextures = mRenderer->getLuminanceAlphaTextureSupport(); + mSupportsRGTextures = mRenderer->getRGTextureSupport(); + mSupportsDepthTextures = mRenderer->getDepthTextureSupport(); + mSupportsTextureFilterAnisotropy = mRenderer->getTextureFilterAnisotropySupport(); + mSupports32bitIndices = mRenderer->get32BitIndexSupport(); + mSupportsPBOs = mRenderer->getPBOSupport(); mNumCompressedTextureFormats = 0; - if (getCaps().extensions.textureCompressionDXT1) + if (supportsDXT1Textures()) { mNumCompressedTextureFormats += 2; } - if (getCaps().extensions.textureCompressionDXT3) + if (supportsDXT3Textures()) { mNumCompressedTextureFormats += 1; } - if (getCaps().extensions.textureCompressionDXT5) + if (supportsDXT5Textures()) { mNumCompressedTextureFormats += 1; } + initExtensionString(); initRendererString(); - initExtensionStrings(); mState.viewport.x = 0; mState.viewport.y = 0; @@ -576,21 +614,6 @@ void Context::setStencilBackOperations(GLenum stencilBackFail, GLenum stencilBac mState.depthStencil.stencilBackPassDepthPass = stencilBackPassDepthPass; } -const gl::DepthStencilState &Context::getDepthStencilState() const -{ - return mState.depthStencil; -} - -GLint Context::getStencilRef() const -{ - return mState.stencilRef; -} - -GLint Context::getStencilBackRef() const -{ - return mState.stencilBackRef; -} - void Context::setPolygonOffsetFill(bool enabled) { mState.rasterizer.polygonOffsetFill = enabled; @@ -802,7 +825,7 @@ void Context::setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, const void *Context::getVertexAttribPointer(unsigned int attribNum) const { - return getCurrentVertexArray()->getVertexAttribute(attribNum).pointer; + return getCurrentVertexArray()->getVertexAttribute(attribNum).mPointer; } void Context::setPackAlignment(GLint alignment) @@ -889,7 +912,7 @@ GLuint Context::createVertexArray() // 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. - mVertexArrayMap[handle] = new VertexArray(mRenderer->createVertexArray(), handle, MAX_VERTEX_ATTRIBS); + mVertexArrayMap[handle] = new VertexArray(mRenderer, handle); return handle; } @@ -1134,11 +1157,6 @@ Framebuffer *Context::getDrawFramebuffer() return mBoundDrawFramebuffer; } -const Framebuffer *Context::getDrawFramebuffer() const -{ - return mBoundDrawFramebuffer; -} - VertexArray *Context::getCurrentVertexArray() const { VertexArray *vao = getVertexArray(mState.vertexArray); @@ -1231,7 +1249,7 @@ void Context::bindVertexArray(GLuint vertexArray) { if (!getVertexArray(vertexArray)) { - mVertexArrayMap[vertexArray] = new VertexArray(mRenderer->createVertexArray(), vertexArray, MAX_VERTEX_ATTRIBS); + mVertexArrayMap[vertexArray] = new VertexArray(mRenderer, vertexArray); } mState.vertexArray = vertexArray; @@ -1394,23 +1412,25 @@ void Context::setFramebufferZero(Framebuffer *buffer) void Context::setRenderbufferStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples) { - const TextureCaps &formatCaps = getCaps().textureCaps.get(internalformat); + const bool color = gl::IsColorRenderingSupported(internalformat, this); + const bool depth = gl::IsDepthRenderingSupported(internalformat, this); + const bool stencil = gl::IsStencilRenderingSupported(internalformat, this); RenderbufferStorage *renderbuffer = NULL; - if (formatCaps.colorRendering) + if (color) { renderbuffer = new gl::Colorbuffer(mRenderer,width, height, internalformat, samples); } - else if (formatCaps.depthRendering && formatCaps.stencilRendering) + else if (depth && stencil) { renderbuffer = new gl::DepthStencilbuffer(mRenderer, width, height, samples); } - else if (formatCaps.depthRendering) + else if (depth) { renderbuffer = new gl::Depthbuffer(mRenderer, width, height, samples); } - else if (formatCaps.stencilRendering) + else if (stencil) { renderbuffer = new gl::Stencilbuffer(mRenderer, width, height, samples); } @@ -1680,8 +1700,8 @@ void Context::getFloatv(GLenum pname, GLfloat *params) params[3] = mState.blendColor.alpha; break; case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: - ASSERT(getCaps().extensions.textureFilterAnisotropic); - *params = getCaps().extensions.maxTextureAnisotropy; + ASSERT(supportsTextureFilterAnisotropy()); + *params = mMaxTextureAnisotropy; break; default: UNREACHABLE(); @@ -1829,16 +1849,16 @@ void Context::getIntegerv(GLenum pname, GLint *params) break; case GL_COMPRESSED_TEXTURE_FORMATS: { - if (getCaps().extensions.textureCompressionDXT1) + if (supportsDXT1Textures()) { *params++ = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; *params++ = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; } - if (getCaps().extensions.textureCompressionDXT3) + if (supportsDXT3Textures()) { *params++ = GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE; } - if (getCaps().extensions.textureCompressionDXT5) + if (supportsDXT5Textures()) { *params++ = GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE; } @@ -1864,7 +1884,7 @@ void Context::getIntegerv(GLenum pname, GLint *params) case GL_ALPHA_BITS: { gl::Framebuffer *framebuffer = getDrawFramebuffer(); - gl::FramebufferAttachment *colorbuffer = framebuffer->getFirstColorbuffer(); + gl::Renderbuffer *colorbuffer = framebuffer->getFirstColorbuffer(); if (colorbuffer) { @@ -1885,7 +1905,7 @@ void Context::getIntegerv(GLenum pname, GLint *params) case GL_DEPTH_BITS: { gl::Framebuffer *framebuffer = getDrawFramebuffer(); - gl::FramebufferAttachment *depthbuffer = framebuffer->getDepthbuffer(); + gl::Renderbuffer *depthbuffer = framebuffer->getDepthbuffer(); if (depthbuffer) { @@ -1900,7 +1920,7 @@ void Context::getIntegerv(GLenum pname, GLint *params) case GL_STENCIL_BITS: { gl::Framebuffer *framebuffer = getDrawFramebuffer(); - gl::FramebufferAttachment *stencilbuffer = framebuffer->getStencilbuffer(); + gl::Renderbuffer *stencilbuffer = framebuffer->getStencilbuffer(); if (stencilbuffer) { @@ -1956,7 +1976,7 @@ void Context::getIntegerv(GLenum pname, GLint *params) *params = mState.unpack.pixelBuffer.id(); break; case GL_NUM_EXTENSIONS: - *params = static_cast(mExtensionStrings.size()); + *params = static_cast(getNumExtensions()); break; default: UNREACHABLE(); @@ -2160,7 +2180,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu return true; case GL_MAX_SAMPLES_ANGLE: { - if (getCaps().extensions.framebufferMultisample) + if (getMaxSupportedSamples() != 0) { *type = GL_INT; *numParams = 1; @@ -2174,7 +2194,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu case GL_PIXEL_PACK_BUFFER_BINDING: case GL_PIXEL_UNPACK_BUFFER_BINDING: { - if (getCaps().extensions.pixelBufferObject) + if (supportsPBOs()) { *type = GL_INT; *numParams = 1; @@ -2248,7 +2268,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu } return true; case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: - if (!getCaps().extensions.maxTextureAnisotropy) + if (!supportsTextureFilterAnisotropy()) { return false; } @@ -2353,7 +2373,11 @@ bool Context::getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned bool Context::applyRenderTarget(GLenum drawMode, bool ignoreViewport) { Framebuffer *framebufferObject = getDrawFramebuffer(); - ASSERT(framebufferObject && framebufferObject->completeness() == GL_FRAMEBUFFER_COMPLETE); + + if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE) + { + return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); + } mRenderer->applyRenderTarget(framebufferObject); @@ -2421,9 +2445,7 @@ void Context::applyShaders(ProgramBinary *programBinary, bool transformFeedbackA VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS]; VertexFormat::GetInputLayout(inputLayout, programBinary, vertexAttributes, mState.vertexAttribCurrentValues); - const Framebuffer *fbo = getDrawFramebuffer(); - - mRenderer->applyShaders(programBinary, inputLayout, fbo, mState.rasterizer.rasterizerDiscard, transformFeedbackActive); + mRenderer->applyShaders(programBinary, mState.rasterizer.rasterizerDiscard, transformFeedbackActive, inputLayout); programBinary->applyUniforms(); } @@ -2629,13 +2651,14 @@ void Context::clear(GLbitfield mask) return; } - if (gl::GetStencilBits(depthStencil->getActualFormat()) > 0) + if (gl::GetStencilBits(depthStencil->getActualFormat(), mClientVersion) > 0) { clearParams.clearStencil = true; } } } + if (!applyRenderTarget(GL_TRIANGLES, true)) // Clips the clear to the scissor rectangle but not the viewport { return; @@ -2838,9 +2861,9 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, { gl::Framebuffer *framebuffer = getReadFramebuffer(); - bool isSized = IsSizedInternalFormat(format); - GLenum sizedInternalFormat = (isSized ? format : GetSizedInternalFormat(format, type)); - GLuint outputPitch = GetRowPitch(sizedInternalFormat, type, width, mState.pack.alignment); + bool isSized = IsSizedInternalFormat(format, mClientVersion); + GLenum sizedInternalFormat = (isSized ? format : GetSizedInternalFormat(format, type, mClientVersion)); + GLuint outputPitch = GetRowPitch(sizedInternalFormat, type, mClientVersion, width, mState.pack.alignment); mRenderer->readPixels(framebuffer, x, y, width, height, format, type, outputPitch, mState.pack, pixels); } @@ -3108,11 +3131,6 @@ int Context::getClientVersion() const return mClientVersion; } -const Caps &Context::getCaps() const -{ - return mRenderer->getCaps(); -} - int Context::getMajorShaderModel() const { return mMajorShaderModel; @@ -3170,6 +3188,66 @@ unsigned int Context::getMaximumRenderTargets() const return mRenderer->getMaxRenderTargets(); } +bool Context::supportsEventQueries() const +{ + return mSupportsEventQueries; +} + +bool Context::supportsOcclusionQueries() const +{ + return mSupportsOcclusionQueries; +} + +bool Context::supportsBGRATextures() const +{ + return mSupportsBGRATextures; +} + +bool Context::supportsDXT1Textures() const +{ + return mSupportsDXT1Textures; +} + +bool Context::supportsDXT3Textures() const +{ + return mSupportsDXT3Textures; +} + +bool Context::supportsDXT5Textures() const +{ + return mSupportsDXT5Textures; +} + +bool Context::supportsFloat32Textures() const +{ + return mSupportsFloat32Textures; +} + +bool Context::supportsFloat32LinearFilter() const +{ + return mSupportsFloat32LinearFilter; +} + +bool Context::supportsFloat32RenderableTextures() const +{ + return mSupportsFloat32RenderableTextures; +} + +bool Context::supportsFloat16Textures() const +{ + return mSupportsFloat16Textures; +} + +bool Context::supportsFloat16LinearFilter() const +{ + return mSupportsFloat16LinearFilter; +} + +bool Context::supportsFloat16RenderableTextures() const +{ + return mSupportsFloat16RenderableTextures; +} + int Context::getMaximumRenderbufferDimension() const { return mMaxRenderbufferDimension; @@ -3215,17 +3293,67 @@ int Context::getMaximum2DArrayTextureLevel() const return mMax2DArrayTextureLevel; } +bool Context::supportsLuminanceTextures() const +{ + return mSupportsLuminanceTextures; +} + +bool Context::supportsLuminanceAlphaTextures() const +{ + return mSupportsLuminanceAlphaTextures; +} + +bool Context::supportsRGTextures() const +{ + return mSupportsRGTextures; +} + +bool Context::supportsDepthTextures() const +{ + return mSupportsDepthTextures; +} + +bool Context::supports32bitIndices() const +{ + return mSupports32bitIndices; +} + +bool Context::supportsNonPower2Texture() const +{ + return mSupportsNonPower2Texture; +} + +bool Context::supportsInstancing() const +{ + return mSupportsInstancing; +} + +bool Context::supportsTextureFilterAnisotropy() const +{ + return mSupportsTextureFilterAnisotropy; +} + +bool Context::supportsPBOs() const +{ + return mSupportsPBOs; +} + +float Context::getTextureMaxAnisotropy() const +{ + return mMaxTextureAnisotropy; +} + void Context::getCurrentReadFormatType(GLenum *internalFormat, GLenum *format, GLenum *type) { Framebuffer *framebuffer = getReadFramebuffer(); ASSERT(framebuffer && framebuffer->completeness() == GL_FRAMEBUFFER_COMPLETE); - FramebufferAttachment *attachment = framebuffer->getReadColorbuffer(); - ASSERT(attachment); + Renderbuffer *renderbuffer = framebuffer->getReadColorbuffer(); + ASSERT(renderbuffer); - *internalFormat = attachment->getActualFormat(); - *format = gl::GetFormat(attachment->getActualFormat()); - *type = gl::GetType(attachment->getActualFormat()); + *internalFormat = renderbuffer->getActualFormat(); + *format = gl::GetFormat(renderbuffer->getActualFormat(), mClientVersion); + *type = gl::GetType(renderbuffer->getActualFormat(), mClientVersion); } void Context::detachBuffer(GLuint buffer) @@ -3265,7 +3393,7 @@ void Context::detachTexture(GLuint texture) // [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 + // as if FramebufferTexture2D had been called, with a texture of 0, for each attachment point to which this // image was attached in the currently bound framebuffer. Framebuffer *readFramebuffer = getReadFramebuffer(); @@ -3564,6 +3692,175 @@ GLfloat Context::getSamplerParameterf(GLuint sampler, GLenum pname) } } +// keep list sorted in following order +// OES extensions +// EXT extensions +// Vendor extensions +void Context::initExtensionString() +{ + // Do not report extension in GLES 3 contexts for now + if (mClientVersion == 2) + { + // OES extensions + if (supports32bitIndices()) + { + mExtensionStringList.push_back("GL_OES_element_index_uint"); + } + + mExtensionStringList.push_back("GL_OES_packed_depth_stencil"); + mExtensionStringList.push_back("GL_OES_get_program_binary"); + mExtensionStringList.push_back("GL_OES_rgb8_rgba8"); + + if (supportsPBOs()) + { + mExtensionStringList.push_back("NV_pixel_buffer_object"); + mExtensionStringList.push_back("GL_OES_mapbuffer"); + mExtensionStringList.push_back("GL_EXT_map_buffer_range"); + } + + if (mRenderer->getDerivativeInstructionSupport()) + { + mExtensionStringList.push_back("GL_OES_standard_derivatives"); + } + + if (supportsFloat16Textures()) + { + mExtensionStringList.push_back("GL_OES_texture_half_float"); + } + if (supportsFloat16LinearFilter()) + { + mExtensionStringList.push_back("GL_OES_texture_half_float_linear"); + } + if (supportsFloat32Textures()) + { + mExtensionStringList.push_back("GL_OES_texture_float"); + } + if (supportsFloat32LinearFilter()) + { + mExtensionStringList.push_back("GL_OES_texture_float_linear"); + } + + if (supportsRGTextures()) + { + mExtensionStringList.push_back("GL_EXT_texture_rg"); + } + + if (supportsNonPower2Texture()) + { + mExtensionStringList.push_back("GL_OES_texture_npot"); + } + + // Multi-vendor (EXT) extensions + if (supportsOcclusionQueries()) + { + mExtensionStringList.push_back("GL_EXT_occlusion_query_boolean"); + } + + mExtensionStringList.push_back("GL_EXT_read_format_bgra"); + mExtensionStringList.push_back("GL_EXT_robustness"); + mExtensionStringList.push_back("GL_EXT_shader_texture_lod"); + + if (supportsDXT1Textures()) + { + mExtensionStringList.push_back("GL_EXT_texture_compression_dxt1"); + } + + if (supportsTextureFilterAnisotropy()) + { + mExtensionStringList.push_back("GL_EXT_texture_filter_anisotropic"); + } + + if (supportsBGRATextures()) + { + mExtensionStringList.push_back("GL_EXT_texture_format_BGRA8888"); + } + + if (mRenderer->getMaxRenderTargets() > 1) + { + mExtensionStringList.push_back("GL_EXT_draw_buffers"); + } + + mExtensionStringList.push_back("GL_EXT_texture_storage"); + mExtensionStringList.push_back("GL_EXT_frag_depth"); + mExtensionStringList.push_back("GL_EXT_blend_minmax"); + + // ANGLE-specific extensions + if (supportsDepthTextures()) + { + mExtensionStringList.push_back("GL_ANGLE_depth_texture"); + } + + mExtensionStringList.push_back("GL_ANGLE_framebuffer_blit"); + if (getMaxSupportedSamples() != 0) + { + mExtensionStringList.push_back("GL_ANGLE_framebuffer_multisample"); + } + + if (supportsInstancing()) + { + mExtensionStringList.push_back("GL_ANGLE_instanced_arrays"); + } + + mExtensionStringList.push_back("GL_ANGLE_pack_reverse_row_order"); + + if (supportsDXT3Textures()) + { + mExtensionStringList.push_back("GL_ANGLE_texture_compression_dxt3"); + } + if (supportsDXT5Textures()) + { + mExtensionStringList.push_back("GL_ANGLE_texture_compression_dxt5"); + } + + mExtensionStringList.push_back("GL_ANGLE_texture_usage"); + mExtensionStringList.push_back("GL_ANGLE_translated_shader_source"); + + // Other vendor-specific extensions + if (supportsEventQueries()) + { + mExtensionStringList.push_back("GL_NV_fence"); + } + } + + if (mClientVersion == 3) + { + mExtensionStringList.push_back("GL_EXT_color_buffer_float"); + + mExtensionStringList.push_back("GL_EXT_read_format_bgra"); + + if (supportsBGRATextures()) + { + mExtensionStringList.push_back("GL_EXT_texture_format_BGRA8888"); + } + } + + // Join the extension strings to one long string for use with GetString + std::stringstream strstr; + for (unsigned int extensionIndex = 0; extensionIndex < mExtensionStringList.size(); extensionIndex++) + { + strstr << mExtensionStringList[extensionIndex]; + strstr << " "; + } + + mCombinedExtensionsString = makeStaticString(strstr.str()); +} + +const char *Context::getCombinedExtensionsString() const +{ + return mCombinedExtensionsString; +} + +const char *Context::getExtensionString(const GLuint index) const +{ + ASSERT(index < mExtensionStringList.size()); + return mExtensionStringList[index].c_str(); +} + +unsigned int Context::getNumExtensions() const +{ + return mExtensionStringList.size(); +} + void Context::initRendererString() { std::ostringstream rendererString; @@ -3571,7 +3868,7 @@ void Context::initRendererString() rendererString << mRenderer->getRendererDescription(); rendererString << ")"; - mRendererString = MakeStaticString(rendererString.str()); + mRendererString = makeStaticString(rendererString.str()); } const char *Context::getRendererString() const @@ -3579,34 +3876,6 @@ const char *Context::getRendererString() const return mRendererString; } -void Context::initExtensionStrings() -{ - std::ostringstream combinedStringStream; - - std::vector extensions = getCaps().extensions.getStrings(mClientVersion); - for (size_t i = 0; i < extensions.size(); i++) - { - combinedStringStream << extensions[i] << " "; - mExtensionStrings.push_back(MakeStaticString(extensions[i])); - } - mExtensionString = MakeStaticString(combinedStringStream.str()); -} - -const char *Context::getExtensionString() const -{ - return mExtensionString; -} - -const char *Context::getExtensionString(size_t idx) const -{ - return mExtensionStrings[idx]; -} - -size_t Context::getExtensionStringCount() const -{ - return mExtensionStrings.size(); -} - size_t Context::getBoundFramebufferTextureSerials(FramebufferTextureSerialArray *outSerialArray) { size_t serialCount = 0; @@ -3614,17 +3883,17 @@ size_t Context::getBoundFramebufferTextureSerials(FramebufferTextureSerialArray Framebuffer *drawFramebuffer = getDrawFramebuffer(); for (unsigned int i = 0; i < IMPLEMENTATION_MAX_DRAW_BUFFERS; i++) { - FramebufferAttachment *attachment = drawFramebuffer->getColorbuffer(i); - if (attachment && attachment->isTexture()) + Renderbuffer *renderBuffer = drawFramebuffer->getColorbuffer(i); + if (renderBuffer && renderBuffer->isTexture()) { - (*outSerialArray)[serialCount++] = attachment->getTextureSerial(); + (*outSerialArray)[serialCount++] = renderBuffer->getTextureSerial(); } } - FramebufferAttachment *depthStencilAttachment = drawFramebuffer->getDepthOrStencilbuffer(); - if (depthStencilAttachment && depthStencilAttachment->isTexture()) + Renderbuffer *depthStencilBuffer = drawFramebuffer->getDepthOrStencilbuffer(); + if (depthStencilBuffer && depthStencilBuffer->isTexture()) { - (*outSerialArray)[serialCount++] = depthStencilAttachment->getTextureSerial(); + (*outSerialArray)[serialCount++] = depthStencilBuffer->getTextureSerial(); } std::sort(outSerialArray->begin(), outSerialArray->begin() + serialCount); @@ -3689,43 +3958,43 @@ void Context::invalidateFrameBuffer(GLenum target, GLsizei numAttachments, const if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15) { - gl::FramebufferAttachment *attachment = frameBuffer->getColorbuffer(attachments[i] - GL_COLOR_ATTACHMENT0); - if (attachment) + gl::Renderbuffer *renderBuffer = frameBuffer->getColorbuffer(attachments[i] - GL_COLOR_ATTACHMENT0); + if (renderBuffer) { - renderTarget = attachment->getRenderTarget(); + renderTarget = renderBuffer->getRenderTarget(); } } else if (attachments[i] == GL_COLOR) { - gl::FramebufferAttachment *attachment = frameBuffer->getColorbuffer(0); - if (attachment) + gl::Renderbuffer *renderBuffer = frameBuffer->getColorbuffer(0); + if (renderBuffer) { - renderTarget = attachment->getRenderTarget(); + renderTarget = renderBuffer->getRenderTarget(); } } else { - gl::FramebufferAttachment *attachment = NULL; + gl::Renderbuffer *renderBuffer = NULL; switch (attachments[i]) { case GL_DEPTH_ATTACHMENT: case GL_DEPTH: - attachment = frameBuffer->getDepthbuffer(); + renderBuffer = frameBuffer->getDepthbuffer(); break; case GL_STENCIL_ATTACHMENT: case GL_STENCIL: - attachment = frameBuffer->getStencilbuffer(); + renderBuffer = frameBuffer->getStencilbuffer(); break; case GL_DEPTH_STENCIL_ATTACHMENT: - attachment = frameBuffer->getDepthOrStencilbuffer(); + renderBuffer = frameBuffer->getDepthOrStencilbuffer(); break; default: UNREACHABLE(); } - if (attachment) + if (renderBuffer) { - renderTarget = attachment->getDepthStencil(); + renderTarget = renderBuffer->getDepthStencil(); } } @@ -3744,8 +4013,8 @@ bool Context::hasMappedBuffer(GLenum target) const for (unsigned int attribIndex = 0; attribIndex < gl::MAX_VERTEX_ATTRIBS; attribIndex++) { const gl::VertexAttribute &vertexAttrib = getVertexAttribState(attribIndex); - gl::Buffer *boundBuffer = vertexAttrib.buffer.get(); - if (vertexAttrib.enabled && boundBuffer && boundBuffer->isMapped()) + gl::Buffer *boundBuffer = vertexAttrib.mBoundBuffer.get(); + if (vertexAttrib.mArrayEnabled && boundBuffer && boundBuffer->mapped()) { return true; } @@ -3754,7 +4023,7 @@ bool Context::hasMappedBuffer(GLenum target) const else if (target == GL_ELEMENT_ARRAY_BUFFER) { Buffer *elementBuffer = getElementArrayBuffer(); - return (elementBuffer && elementBuffer->isMapped()); + return (elementBuffer && elementBuffer->mapped()); } else if (target == GL_TRANSFORM_FEEDBACK_BUFFER) { diff --git a/gfx/angle/src/libGLESv2/Context.h b/gfx/angle/src/libGLESv2/Context.h index 6942d5b2e4b6..b3c8a3fc2512 100644 --- a/gfx/angle/src/libGLESv2/Context.h +++ b/gfx/angle/src/libGLESv2/Context.h @@ -10,7 +10,10 @@ #ifndef LIBGLESV2_CONTEXT_H_ #define LIBGLESV2_CONTEXT_H_ -#include "angle_gl.h" +#include +#include +#include +#include #include #include @@ -21,7 +24,6 @@ #include "common/angleutils.h" #include "common/RefCountObject.h" -#include "libGLESv2/Caps.h" #include "libGLESv2/HandleAllocator.h" #include "libGLESv2/angletypes.h" #include "libGLESv2/Constants.h" @@ -59,7 +61,7 @@ class FenceSync; class Query; class ResourceManager; class Buffer; -struct VertexAttribute; +class VertexAttribute; class VertexArray; class Sampler; class TransformFeedback; @@ -179,9 +181,6 @@ class Context void setStencilBackWritemask(GLuint stencilBackWritemask); void setStencilOperations(GLenum stencilFail, GLenum stencilPassDepthFail, GLenum stencilPassDepthPass); void setStencilBackOperations(GLenum stencilBackFail, GLenum stencilBackPassDepthFail, GLenum stencilBackPassDepthPass); - const gl::DepthStencilState &getDepthStencilState() const; - GLint getStencilRef() const; - GLint getStencilBackRef() const; void setPolygonOffsetFill(bool enabled); bool isPolygonOffsetFillEnabled() const; @@ -361,7 +360,6 @@ class Context GLuint getTargetFramebufferHandle(GLenum target) const; Framebuffer *getReadFramebuffer(); Framebuffer *getDrawFramebuffer(); - const Framebuffer *getDrawFramebuffer() const; VertexArray *getCurrentVertexArray() const; TransformFeedback *getCurrentTransformFeedback() const; @@ -401,8 +399,6 @@ class Context virtual int getClientVersion() const; - const Caps &getCaps() const; - int getMajorShaderModel() const; float getMaximumPointSize() const; unsigned int getMaximumCombinedTextureImageUnits() const; @@ -423,14 +419,36 @@ class Context void getSampleCounts(GLenum internalFormat, GLsizei bufSize, GLint *params) const; unsigned int getMaxTransformFeedbackBufferBindings() const; GLintptr getUniformBufferOffsetAlignment() const; + const char *getCombinedExtensionsString() const; + const char *getExtensionString(const GLuint index) const; + unsigned int getNumExtensions() const; const char *getRendererString() const; - - const char *getExtensionString() const; - const char *getExtensionString(size_t idx) const; - size_t getExtensionStringCount() const; + bool supportsEventQueries() const; + bool supportsOcclusionQueries() const; + bool supportsBGRATextures() const; + bool supportsDXT1Textures() const; + bool supportsDXT3Textures() const; + bool supportsDXT5Textures() const; + bool supportsFloat32Textures() const; + bool supportsFloat32LinearFilter() const; + bool supportsFloat32RenderableTextures() const; + bool supportsFloat16Textures() const; + bool supportsFloat16LinearFilter() const; + bool supportsFloat16RenderableTextures() const; + bool supportsLuminanceTextures() const; + bool supportsLuminanceAlphaTextures() const; + bool supportsRGTextures() const; + bool supportsDepthTextures() const; + bool supports32bitIndices() const; + bool supportsNonPower2Texture() const; + bool supportsInstancing() const; + bool supportsTextureFilterAnisotropy() const; + bool supportsPBOs() const; void getCurrentReadFormatType(GLenum *internalFormat, GLenum *format, GLenum *type); + float getTextureMaxAnisotropy() const; + void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); @@ -472,8 +490,8 @@ class Context bool skipDraw(GLenum drawMode); + void initExtensionString(); void initRendererString(); - void initExtensionStrings(); size_t getBoundFramebufferTextureSerials(FramebufferTextureSerialArray *outSerialArray); @@ -509,10 +527,10 @@ class Context TransformFeedbackMap mTransformFeedbackMap; HandleAllocator mTransformFeedbackAllocator; + std::vector mExtensionStringList; + const char *mCombinedExtensionsString; const char *mRendererString; - const char *mExtensionString; - std::vector mExtensionStrings; - + BindingPointer mIncompleteTextures[TEXTURE_TYPE_COUNT]; // Recorded errors @@ -535,6 +553,8 @@ class Context int mMajorShaderModel; float mMaximumPointSize; bool mSupportsVertexTexture; + bool mSupportsNonPower2Texture; + bool mSupportsInstancing; int mMaxViewportDimension; int mMaxRenderbufferDimension; int mMax2DTextureDimension; @@ -545,6 +565,26 @@ class Context int mMaxCubeTextureLevel; int mMax3DTextureLevel; int mMax2DArrayTextureLevel; + float mMaxTextureAnisotropy; + bool mSupportsEventQueries; + bool mSupportsOcclusionQueries; + bool mSupportsBGRATextures; + bool mSupportsDXT1Textures; + bool mSupportsDXT3Textures; + bool mSupportsDXT5Textures; + bool mSupportsFloat32Textures; + bool mSupportsFloat32LinearFilter; + bool mSupportsFloat32RenderableTextures; + bool mSupportsFloat16Textures; + bool mSupportsFloat16LinearFilter; + bool mSupportsFloat16RenderableTextures; + bool mSupportsLuminanceTextures; + bool mSupportsLuminanceAlphaTextures; + bool mSupportsRGTextures; + bool mSupportsDepthTextures; + bool mSupports32bitIndices; + bool mSupportsTextureFilterAnisotropy; + bool mSupportsPBOs; int mNumCompressedTextureFormats; ResourceManager *mResourceManager; diff --git a/gfx/angle/src/libGLESv2/DynamicHLSL.cpp b/gfx/angle/src/libGLESv2/DynamicHLSL.cpp index c32b4073b481..20e4a2054885 100644 --- a/gfx/angle/src/libGLESv2/DynamicHLSL.cpp +++ b/gfx/angle/src/libGLESv2/DynamicHLSL.cpp @@ -69,7 +69,7 @@ std::string HLSLTypeString(GLenum type) return HLSLMatrixTypeString(type); } - return HLSLComponentTypeString(gl::VariableComponentType(type), gl::VariableComponentCount(type)); + return HLSLComponentTypeString(gl::UniformComponentType(type), gl::UniformComponentCount(type)); } } @@ -82,8 +82,7 @@ std::string ArrayString(unsigned int i) return (i == GL_INVALID_INDEX ? "" : "[" + Str(i) + "]"); } -const std::string VERTEX_ATTRIBUTE_STUB_STRING = "@@ VERTEX ATTRIBUTES @@"; -const std::string PIXEL_OUTPUT_STUB_STRING = "@@ PIXEL OUTPUT @@"; +const std::string DynamicHLSL::VERTEX_ATTRIBUTE_STUB_STRING = "@@ VERTEX ATTRIBUTES @@"; DynamicHLSL::DynamicHLSL(rx::Renderer *const renderer) : mRenderer(renderer) @@ -282,9 +281,9 @@ int DynamicHLSL::packVaryings(InfoLog &infoLog, VaryingPacking packing, Fragment return registers; } -std::string DynamicHLSL::generateVaryingHLSL(VertexShader *shader) const +std::string DynamicHLSL::generateVaryingHLSL(VertexShader *shader, const std::string &varyingSemantic, + std::vector *linkedVaryings) const { - std::string varyingSemantic = getVaryingSemantic(shader->mUsesPointSize); std::string varyingHLSL; for (unsigned int varyingIndex = 0; varyingIndex < shader->mVaryings.size(); varyingIndex++) @@ -301,9 +300,9 @@ std::string DynamicHLSL::generateVaryingHLSL(VertexShader *shader) const { switch (varying.interpolation) { - case sh::INTERPOLATION_SMOOTH: varyingHLSL += " "; break; - case sh::INTERPOLATION_FLAT: varyingHLSL += " nointerpolation "; break; - case sh::INTERPOLATION_CENTROID: varyingHLSL += " centroid "; break; + case INTERPOLATION_SMOOTH: varyingHLSL += " "; break; + case INTERPOLATION_FLAT: varyingHLSL += " nointerpolation "; break; + case INTERPOLATION_CENTROID: varyingHLSL += " centroid "; break; default: UNREACHABLE(); } @@ -320,22 +319,27 @@ std::string DynamicHLSL::generateVaryingHLSL(VertexShader *shader) const } else { - GLenum componentType = VariableComponentType(transposedType); + GLenum componentType = UniformComponentType(transposedType); int columnCount = VariableColumnCount(transposedType); typeString = gl_d3d::HLSLComponentTypeString(componentType, columnCount); } varyingHLSL += typeString + " v" + n + " : " + varyingSemantic + n + ";\n"; } } + + if (linkedVaryings) + { + linkedVaryings->push_back(LinkedVarying(varying.name, varying.type, varying.elementCount(), + varyingSemantic, varying.registerIndex, + variableRows * varying.elementCount())); + } } } return varyingHLSL; } -std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &sourceShader, - const VertexFormat inputLayout[], - const sh::Attribute shaderAttributes[]) const +std::string DynamicHLSL::generateInputLayoutHLSL(const VertexFormat inputLayout[], const Attribute shaderAttributes[]) const { std::string structHLSL, initHLSL; @@ -347,7 +351,7 @@ std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &s ASSERT(inputIndex < MAX_VERTEX_ATTRIBS); const VertexFormat &vertexFormat = inputLayout[inputIndex]; - const sh::Attribute &shaderAttribute = shaderAttributes[attributeIndex]; + const Attribute &shaderAttribute = shaderAttributes[attributeIndex]; if (!shaderAttribute.name.empty()) { @@ -360,11 +364,11 @@ std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &s else { GLenum componentType = mRenderer->getVertexComponentType(vertexFormat); - structHLSL += " " + gl_d3d::HLSLComponentTypeString(componentType, VariableComponentCount(shaderAttribute.type)); + structHLSL += " " + gl_d3d::HLSLComponentTypeString(componentType, UniformComponentCount(shaderAttribute.type)); } structHLSL += " " + decorateVariable(shaderAttribute.name) + " : TEXCOORD" + Str(semanticIndex) + ";\n"; - semanticIndex += VariableRegisterCount(shaderAttribute.type); + semanticIndex += AttributeRegisterCount(shaderAttribute.type); // HLSL code for initialization initHLSL += " " + decorateVariable(shaderAttribute.name) + " = "; @@ -388,247 +392,15 @@ std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &s } } - 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 &outputVariables, - bool usesFragDepth, const std::vector &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 i = 0; i < outputVariables.size(); i++) - { - const PixelShaderOuputVariable& outputVariable = outputVariables[i]; - ASSERT(outputLayout.size() > outputVariable.outputIndex); - - // FIXME(geofflang): Work around NVIDIA driver bug by repacking buffers - bool outputIndexEnabled = true; // outputLayout[outputVariable.outputIndex] != GL_NONE - if (outputIndexEnabled) - { - declarationHLSL += " " + gl_d3d::HLSLTypeString(outputVariable.type) + " " + outputVariable.name + - " : " + targetSemantic + Str(outputVariable.outputIndex) + ";\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 *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 VertexShader *vertexShader, - std::vector *linkedVaryings) const -{ - const std::string &varyingSemantic = getVaryingSemantic(vertexShader->mUsesPointSize); - const std::vector &varyings = vertexShader->mVaryings; - - for (unsigned int varyingIndex = 0; varyingIndex < varyings.size(); varyingIndex++) - { - const PackedVarying &varying = varyings[varyingIndex]; - if (varying.registerAssigned()) - { - 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())); - } - } + return "struct VS_INPUT\n" + "{\n" + + structHLSL + + "};\n" + "\n" + "void initAttributes(VS_INPUT input)\n" + "{\n" + + initHLSL + + "}\n"; } bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const VaryingPacking packing, @@ -636,9 +408,7 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const FragmentShader *fragmentShader, VertexShader *vertexShader, const std::vector& transformFeedbackVaryings, std::vector *linkedVaryings, - std::map *programOutputVars, - std::vector *outPixelShaderKey, - bool *outUsesFragDepth) const + std::map *programOutputVars) const { if (pixelHLSL.empty() || vertexHLSL.empty()) { @@ -648,10 +418,6 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const 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."); @@ -662,12 +428,12 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const const int shaderModel = mRenderer->getMajorShaderModel(); const int maxVaryingVectors = mRenderer->getMaxVaryingVectors(); - const int registersNeeded = registers + (usesFragCoord ? 1 : 0) + (usesPointCoord ? 1 : 0); + const int registersNeeded = registers + (fragmentShader->mUsesFragCoord ? 1 : 0) + (fragmentShader->mUsesPointCoord ? 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 = (usesFragColor && mRenderer->getCurrentClientVersion() < 3); + const bool broadcast = (fragmentShader->mUsesFragColor && mRenderer->getCurrentClientVersion() < 3); const unsigned int numRenderTargets = (broadcast || usesMRT ? mRenderer->getMaxRenderTargets() : 1); int shaderVersion = vertexShader->getShaderVersion(); @@ -675,19 +441,86 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const if (registersNeeded > 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); + std::string varyingSemantic = (vertexShader->mUsesPointSize && shaderModel == 3) ? "COLOR" : "TEXCOORD"; + std::string targetSemantic = (shaderModel >= 4) ? "SV_Target" : "COLOR"; + std::string dxPositionSemantic = (shaderModel >= 4) ? "SV_Position" : "POSITION"; + std::string depthSemantic = (shaderModel >= 4) ? "SV_Depth" : "DEPTH"; - storeUserLinkedVaryings(vertexShader, linkedVaryings); - storeBuiltinLinkedVaryings(vertexSemantics, linkedVaryings); + std::string varyingHLSL = generateVaryingHLSL(vertexShader, varyingSemantic, linkedVaryings); + + // special varyings that use reserved registers + int reservedRegisterIndex = registers; + + unsigned int glPositionSemanticIndex = reservedRegisterIndex++; + std::string glPositionSemantic = varyingSemantic; + + std::string fragCoordSemantic; + unsigned int fragCoordSemanticIndex = 0; + if (fragmentShader->mUsesFragCoord) + { + fragCoordSemanticIndex = reservedRegisterIndex++; + fragCoordSemantic = varyingSemantic; + } + + std::string pointCoordSemantic; + unsigned int pointCoordSemanticIndex = 0; + if (fragmentShader->mUsesPointCoord) + { + // Shader model 3 uses a special TEXCOORD semantic for point sprite texcoords. + // In DX11 we compute this in the GS. + if (shaderModel == 3) + { + pointCoordSemanticIndex = 0; + pointCoordSemantic = "TEXCOORD0"; + } + else if (shaderModel >= 4) + { + pointCoordSemanticIndex = reservedRegisterIndex++; + pointCoordSemantic = varyingSemantic; + } + } // 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" + vertexHLSL += "\n" + VERTEX_ATTRIBUTE_STUB_STRING + "\n"; + + vertexHLSL += "struct VS_OUTPUT\n" + "{\n"; + + if (shaderModel < 4) + { + vertexHLSL += " float4 _dx_Position : " + dxPositionSemantic + ";\n"; + vertexHLSL += " float4 gl_Position : " + glPositionSemantic + Str(glPositionSemanticIndex) + ";\n"; + linkedVaryings->push_back(LinkedVarying("gl_Position", GL_FLOAT_VEC4, 1, glPositionSemantic, glPositionSemanticIndex, 1)); + + } + + vertexHLSL += varyingHLSL; + + if (fragmentShader->mUsesFragCoord) + { + vertexHLSL += " float4 gl_FragCoord : " + fragCoordSemantic + Str(fragCoordSemanticIndex) + ";\n"; + linkedVaryings->push_back(LinkedVarying("gl_FragCoord", GL_FLOAT_VEC4, 1, fragCoordSemantic, fragCoordSemanticIndex, 1)); + } + + if (vertexShader->mUsesPointSize && shaderModel >= 3) + { + vertexHLSL += " float gl_PointSize : PSIZE;\n"; + linkedVaryings->push_back(LinkedVarying("gl_PointSize", GL_FLOAT, 1, "PSIZE", 0, 1)); + } + + if (shaderModel >= 4) + { + vertexHLSL += " float4 _dx_Position : " + dxPositionSemantic + ";\n"; + vertexHLSL += " float4 gl_Position : " + glPositionSemantic + Str(glPositionSemanticIndex) + ";\n"; + linkedVaryings->push_back(LinkedVarying("gl_Position", GL_FLOAT_VEC4, 1, glPositionSemantic, glPositionSemanticIndex, 1)); + } + + vertexHLSL += "};\n" + "\n" "VS_OUTPUT main(VS_INPUT input)\n" "{\n" " initAttributes(input);\n"; @@ -699,10 +532,10 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const "\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"; + " 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 { @@ -711,18 +544,18 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const "\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"; + " 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) + if (vertexShader->mUsesPointSize && shaderModel >= 3) { vertexHLSL += " output.gl_PointSize = gl_PointSize;\n"; } - if (usesFragCoord) + if (fragmentShader->mUsesFragCoord) { vertexHLSL += " output.gl_FragCoord = gl_Position;\n"; } @@ -793,51 +626,76 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const " return output;\n" "}\n"; - const SemanticInfo &pixelSemantics = getSemanticInfo(registers, usesFragCoord, usesPointCoord, - usesPointSize, true); + pixelHLSL += "struct PS_INPUT\n" + "{\n"; - pixelHLSL += "struct PS_INPUT\n" + generateVaryingLinkHLSL(pixelSemantics, varyingHLSL) + "\n"; + pixelHLSL += varyingHLSL; + + if (fragmentShader->mUsesFragCoord) + { + pixelHLSL += " float4 gl_FragCoord : " + fragCoordSemantic + Str(fragCoordSemanticIndex) + ";\n"; + } + + if (fragmentShader->mUsesPointCoord && shaderModel >= 3) + { + pixelHLSL += " float2 gl_PointCoord : " + pointCoordSemantic + Str(pointCoordSemanticIndex) + ";\n"; + } + + // Must consume the PSIZE element if the geometry shader is not active + // We won't know if we use a GS until we draw + if (vertexShader->mUsesPointSize && shaderModel >= 4) + { + pixelHLSL += " float gl_PointSize : PSIZE;\n"; + } + + if (fragmentShader->mUsesFragCoord) + { + if (shaderModel >= 4) + { + pixelHLSL += " float4 dx_VPos : SV_Position;\n"; + } + else if (shaderModel >= 3) + { + pixelHLSL += " float2 dx_VPos : VPOS;\n"; + } + } + + pixelHLSL += "};\n" + "\n" + "struct PS_OUTPUT\n" + "{\n"; if (shaderVersion < 300) { for (unsigned int renderTargetIndex = 0; renderTargetIndex < numRenderTargets; renderTargetIndex++) { - PixelShaderOuputVariable 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); + pixelHLSL += " float4 gl_Color" + Str(renderTargetIndex) + " : " + targetSemantic + Str(renderTargetIndex) + ";\n"; } - *outUsesFragDepth = fragmentShader->mUsesFragDepth; + if (fragmentShader->mUsesFragDepth) + { + pixelHLSL += " float gl_Depth : " + depthSemantic + ";\n"; + } } else { defineOutputVariables(fragmentShader, programOutputVars); - const std::vector &shaderOutputVars = fragmentShader->getOutputVariables(); + const std::vector &shaderOutputVars = fragmentShader->getOutputVariables(); 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 ShaderVariable &outputVariable = shaderOutputVars[outputLocation.index]; const std::string &elementString = (outputLocation.element == GL_INVALID_INDEX ? "" : Str(outputLocation.element)); - PixelShaderOuputVariable outputKeyVariable; - outputKeyVariable.type = outputVariable.type; - outputKeyVariable.name = variableName + elementString; - outputKeyVariable.source = variableName + ArrayString(outputLocation.element); - outputKeyVariable.outputIndex = locationIt->first; - - outPixelShaderKey->push_back(outputKeyVariable); + pixelHLSL += " " + gl_d3d::HLSLTypeString(outputVariable.type) + + " out_" + outputLocation.name + elementString + + " : " + targetSemantic + Str(locationIt->first) + ";\n"; } - - *outUsesFragDepth = false; } - pixelHLSL += PIXEL_OUTPUT_STUB_STRING + "\n"; + pixelHLSL += "};\n" + "\n"; if (fragmentShader->mUsesFrontFacing) { @@ -858,19 +716,19 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const "{\n"; } - if (usesFragCoord) + if (fragmentShader->mUsesFragCoord) { 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"; + pixelHLSL += " gl_FragCoord.x = input.dx_VPos.x;\n" + " gl_FragCoord.y = input.dx_VPos.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"; + pixelHLSL += " gl_FragCoord.x = input.dx_VPos.x + 0.5;\n" + " gl_FragCoord.y = input.dx_VPos.y + 0.5;\n"; } else { @@ -883,7 +741,7 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const " gl_FragCoord.w = rhw;\n"; } - if (usesPointCoord && shaderModel >= 3) + if (fragmentShader->mUsesPointCoord && shaderModel >= 3) { pixelHLSL += " gl_PointCoord.x = input.gl_PointCoord.x;\n"; pixelHLSL += " gl_PointCoord.y = 1.0 - input.gl_PointCoord.y;\n"; @@ -949,7 +807,37 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const pixelHLSL += "\n" " gl_main();\n" "\n" - " return generateOutput();\n" + " PS_OUTPUT output;\n"; + + if (shaderVersion < 300) + { + for (unsigned int renderTargetIndex = 0; renderTargetIndex < numRenderTargets; renderTargetIndex++) + { + unsigned int sourceColorIndex = broadcast ? 0 : renderTargetIndex; + + pixelHLSL += " output.gl_Color" + Str(renderTargetIndex) + " = gl_Color[" + Str(sourceColorIndex) + "];\n"; + } + + if (fragmentShader->mUsesFragDepth) + { + pixelHLSL += " output.gl_Depth = gl_Depth;\n"; + } + } + else + { + for (auto locationIt = programOutputVars->begin(); locationIt != programOutputVars->end(); locationIt++) + { + const VariableLocation &outputLocation = locationIt->second; + const std::string &variableName = "out_" + outputLocation.name; + const std::string &outVariableName = variableName + (outputLocation.element == GL_INVALID_INDEX ? "" : Str(outputLocation.element)); + const std::string &staticVariableName = variableName + ArrayString(outputLocation.element); + + pixelHLSL += " output." + outVariableName + " = " + staticVariableName + ";\n"; + } + } + + pixelHLSL += "\n" + " return output;\n" "}\n"; return true; @@ -957,11 +845,11 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const void DynamicHLSL::defineOutputVariables(FragmentShader *fragmentShader, std::map *programOutputVars) const { - const std::vector &shaderOutputVars = fragmentShader->getOutputVariables(); + const std::vector &shaderOutputVars = fragmentShader->getOutputVariables(); for (unsigned int outputVariableIndex = 0; outputVariableIndex < shaderOutputVars.size(); outputVariableIndex++) { - const sh::Attribute &outputVariable = shaderOutputVars[outputVariableIndex]; + const Attribute &outputVariable = shaderOutputVars[outputVariableIndex]; const int baseLocation = outputVariable.location == -1 ? 0 : outputVariable.location; if (outputVariable.arraySize > 0) @@ -996,20 +884,60 @@ std::string DynamicHLSL::generatePointSpriteHLSL(int registers, FragmentShader * 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 varyingSemantic = "TEXCOORD"; - std::string varyingHLSL = generateVaryingHLSL(vertexShader); - std::string inLinkHLSL = generateVaryingLinkHLSL(inSemantics, varyingHLSL); - std::string outLinkHLSL = generateVaryingLinkHLSL(outSemantics, varyingHLSL); + std::string fragCoordSemantic; + std::string pointCoordSemantic; + + int reservedRegisterIndex = registers; + + if (fragmentShader->mUsesFragCoord) + { + fragCoordSemantic = varyingSemantic + Str(reservedRegisterIndex++); + } + + if (fragmentShader->mUsesPointCoord) + { + pointCoordSemantic = varyingSemantic + Str(reservedRegisterIndex++); + } geomHLSL += "uniform float4 dx_ViewCoords : register(c1);\n" "\n" - "struct GS_INPUT\n" + inLinkHLSL + "\n" + - "struct GS_OUTPUT\n" + outLinkHLSL + "\n" + + "struct GS_INPUT\n" + "{\n"; + + std::string varyingHLSL = generateVaryingHLSL(vertexShader, varyingSemantic, NULL); + + geomHLSL += varyingHLSL; + + if (fragmentShader->mUsesFragCoord) + { + geomHLSL += " float4 gl_FragCoord : " + fragCoordSemantic + ";\n"; + } + + geomHLSL += " float gl_PointSize : PSIZE;\n" + " float4 gl_Position : SV_Position;\n" + "};\n" "\n" + "struct GS_OUTPUT\n" + "{\n"; + + geomHLSL += varyingHLSL; + + if (fragmentShader->mUsesFragCoord) + { + geomHLSL += " float4 gl_FragCoord : " + fragCoordSemantic + ";\n"; + } + + if (fragmentShader->mUsesPointCoord) + { + geomHLSL += " float2 gl_PointCoord : " + pointCoordSemantic + ";\n"; + } + + geomHLSL += " float gl_PointSize : PSIZE;\n" + " float4 gl_Position : SV_Position;\n" + "};\n" + "\n" "static float2 pointSpriteCorners[] = \n" "{\n" " float2( 0.5f, -0.5f),\n" @@ -1033,7 +961,6 @@ std::string DynamicHLSL::generatePointSpriteHLSL(int registers, FragmentShader * "void main(point GS_INPUT input[1], inout TriangleStream 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++) @@ -1048,13 +975,13 @@ std::string DynamicHLSL::generatePointSpriteHLSL(int registers, FragmentShader * 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"; + " float4 gl_Position = input[0].gl_Position;\n" + " float2 viewportScale = float2(1.0f / dx_ViewCoords.x, 1.0f / dx_ViewCoords.y) * gl_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"; + " output.gl_Position = gl_Position + float4(pointSpriteCorners[" + Str(corner) + "] * viewportScale * gl_PointSize, 0.0f, 0.0f);\n"; if (fragmentShader->mUsesPointCoord) { @@ -1074,7 +1001,7 @@ std::string DynamicHLSL::generatePointSpriteHLSL(int registers, FragmentShader * // This method needs to match OutputHLSL::decorate std::string DynamicHLSL::decorateVariable(const std::string &name) { - if (name.compare(0, 3, "gl_")) + if (name.compare(0, 3, "gl_") != 0 && name.compare(0, 3, "dx_") != 0) { return "_" + name; } @@ -1082,7 +1009,7 @@ std::string DynamicHLSL::decorateVariable(const std::string &name) return name; } -std::string DynamicHLSL::generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const sh::ShaderVariable &shaderAttrib) const +std::string DynamicHLSL::generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const ShaderVariable &shaderAttrib) const { std::string attribString = "input." + decorateVariable(shaderAttrib.name); @@ -1092,8 +1019,8 @@ std::string DynamicHLSL::generateAttributeConversionHLSL(const VertexFormat &ver return "transpose(" + attribString + ")"; } - GLenum shaderComponentType = VariableComponentType(shaderAttrib.type); - int shaderComponentCount = VariableComponentCount(shaderAttrib.type); + GLenum shaderComponentType = UniformComponentType(shaderAttrib.type); + int shaderComponentCount = UniformComponentCount(shaderAttrib.type); // Perform integer to float conversion (if necessary) bool requiresTypeConversion = (shaderComponentType == GL_FLOAT && vertexFormat.mType != GL_FLOAT); diff --git a/gfx/angle/src/libGLESv2/DynamicHLSL.h b/gfx/angle/src/libGLESv2/DynamicHLSL.h index 4309dc8ef4f3..07c2a2f2bbc5 100644 --- a/gfx/angle/src/libGLESv2/DynamicHLSL.h +++ b/gfx/angle/src/libGLESv2/DynamicHLSL.h @@ -17,12 +17,6 @@ namespace rx class Renderer; } -namespace sh -{ -struct Attribute; -struct ShaderVariable; -} - namespace gl { @@ -31,20 +25,15 @@ class FragmentShader; class VertexShader; struct VariableLocation; struct LinkedVarying; -struct VertexAttribute; +class VertexAttribute; struct VertexFormat; +struct ShaderVariable; +struct Varying; +struct Attribute; struct PackedVarying; typedef const PackedVarying *VaryingPacking[IMPLEMENTATION_MAX_VARYING_VECTORS][4]; -struct PixelShaderOuputVariable -{ - GLenum type; - std::string name; - std::string source; - size_t outputIndex; -}; - class DynamicHLSL { public: @@ -52,43 +41,33 @@ class DynamicHLSL int packVaryings(InfoLog &infoLog, VaryingPacking packing, FragmentShader *fragmentShader, VertexShader *vertexShader, const std::vector& transformFeedbackVaryings); - std::string generateVertexShaderForInputLayout(const std::string &sourceShader, const VertexFormat inputLayout[], - const sh::Attribute shaderAttributes[]) const; - std::string generatePixelShaderForOutputSignature(const std::string &sourceShader, const std::vector &outputVariables, - bool usesFragDepth, const std::vector &outputLayout) const; + std::string generateInputLayoutHLSL(const VertexFormat inputLayout[], const Attribute shaderAttributes[]) const; bool generateShaderLinkHLSL(InfoLog &infoLog, int registers, const VaryingPacking packing, std::string& pixelHLSL, std::string& vertexHLSL, FragmentShader *fragmentShader, VertexShader *vertexShader, const std::vector& transformFeedbackVaryings, std::vector *linkedVaryings, - std::map *programOutputVars, - std::vector *outPixelShaderKey, - bool *outUsesFragDepth) const; + std::map *programOutputVars) const; std::string generateGeometryShaderHLSL(int registers, FragmentShader *fragmentShader, VertexShader *vertexShader) const; void getInputLayoutSignature(const VertexFormat inputLayout[], GLenum signature[]) const; + static const std::string VERTEX_ATTRIBUTE_STUB_STRING; + private: DISALLOW_COPY_AND_ASSIGN(DynamicHLSL); rx::Renderer *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(VertexShader *shader) const; - void storeUserLinkedVaryings(const VertexShader *vertexShader, std::vector *linkedVaryings) const; - void storeBuiltinLinkedVaryings(const SemanticInfo &info, std::vector *linkedVaryings) const; + std::string generateVaryingHLSL(VertexShader *shader, const std::string &varyingSemantic, + std::vector *linkedVaryings) const; void defineOutputVariables(FragmentShader *fragmentShader, std::map *programOutputVars) const; std::string generatePointSpriteHLSL(int registers, FragmentShader *fragmentShader, VertexShader *vertexShader) const; // Prepend an underscore static std::string decorateVariable(const std::string &name); - std::string generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const sh::ShaderVariable &shaderAttrib) const; + std::string generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const ShaderVariable &shaderAttrib) const; }; // Utility method shared between ProgramBinary and DynamicHLSL diff --git a/gfx/angle/src/libGLESv2/Framebuffer.cpp b/gfx/angle/src/libGLESv2/Framebuffer.cpp index 4d5e8d4baf2b..97d37d005add 100644 --- a/gfx/angle/src/libGLESv2/Framebuffer.cpp +++ b/gfx/angle/src/libGLESv2/Framebuffer.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -17,42 +17,33 @@ #include "libGLESv2/Context.h" #include "libGLESv2/renderer/Renderer.h" #include "libGLESv2/Renderbuffer.h" -#include "libGLESv2/FramebufferAttachment.h" namespace gl { Framebuffer::Framebuffer(rx::Renderer *renderer) - : mRenderer(renderer), - mReadBufferState(GL_COLOR_ATTACHMENT0_EXT), - mDepthbuffer(NULL), - mStencilbuffer(NULL) + : mRenderer(renderer) { for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) { - mColorbuffers[colorAttachment] = NULL; mDrawBufferStates[colorAttachment] = GL_NONE; } mDrawBufferStates[0] = GL_COLOR_ATTACHMENT0_EXT; + mReadBufferState = GL_COLOR_ATTACHMENT0_EXT; } Framebuffer::~Framebuffer() { for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) { - SafeDelete(mColorbuffers[colorAttachment]); + mColorbuffers[colorAttachment].set(NULL, GL_NONE, 0, 0); } - SafeDelete(mDepthbuffer); - SafeDelete(mStencilbuffer); + mDepthbuffer.set(NULL, GL_NONE, 0, 0); + mStencilbuffer.set(NULL, GL_NONE, 0, 0); } -FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle, GLint level, GLint layer) const +Renderbuffer *Framebuffer::lookupRenderbuffer(GLenum type, GLuint handle, GLint level, GLint layer) const { - if (handle == 0) - { - return NULL; - } - gl::Context *context = gl::getContext(); switch (type) @@ -61,15 +52,14 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle, return NULL; case GL_RENDERBUFFER: - return new RenderbufferAttachment(context->getRenderbuffer(handle)); + return context->getRenderbuffer(handle); case GL_TEXTURE_2D: { Texture *texture = context->getTexture(handle); if (texture && texture->getTarget() == GL_TEXTURE_2D) { - Texture2D *tex2D = static_cast(texture); - return new Texture2DAttachment(tex2D, level); + return static_cast(texture)->getRenderbuffer(level); } else { @@ -87,8 +77,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle, Texture *texture = context->getTexture(handle); if (texture && texture->getTarget() == GL_TEXTURE_CUBE_MAP) { - TextureCubeMap *texCube = static_cast(texture); - return new TextureCubeMapAttachment(texCube, type, level); + return static_cast(texture)->getRenderbuffer(type, level); } else { @@ -101,8 +90,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle, Texture *texture = context->getTexture(handle); if (texture && texture->getTarget() == GL_TEXTURE_3D) { - Texture3D *tex3D = static_cast(texture); - return new Texture3DAttachment(tex3D, level, layer); + return static_cast(texture)->getRenderbuffer(level, layer); } else { @@ -115,8 +103,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle, Texture *texture = context->getTexture(handle); if (texture && texture->getTarget() == GL_TEXTURE_2D_ARRAY) { - Texture2DArray *tex2DArray = static_cast(texture); - return new Texture2DArrayAttachment(tex2DArray, level, layer); + return static_cast(texture)->getRenderbuffer(level, layer); } else { @@ -133,138 +120,191 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle, void Framebuffer::setColorbuffer(unsigned int colorAttachment, GLenum type, GLuint colorbuffer, GLint level, GLint layer) { ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS); - SafeDelete(mColorbuffers[colorAttachment]); - mColorbuffers[colorAttachment] = createAttachment(type, colorbuffer, level, layer); + Renderbuffer *renderBuffer = lookupRenderbuffer(type, colorbuffer, level, layer); + if (renderBuffer) + { + mColorbuffers[colorAttachment].set(renderBuffer, type, level, layer); + } + else + { + mColorbuffers[colorAttachment].set(NULL, GL_NONE, 0, 0); + } } void Framebuffer::setDepthbuffer(GLenum type, GLuint depthbuffer, GLint level, GLint layer) { - SafeDelete(mDepthbuffer); - mDepthbuffer = createAttachment(type, depthbuffer, level, layer); + Renderbuffer *renderBuffer = lookupRenderbuffer(type, depthbuffer, level, layer); + if (renderBuffer) + { + mDepthbuffer.set(renderBuffer, type, level, layer); + } + else + { + mDepthbuffer.set(NULL, GL_NONE, 0, 0); + } } void Framebuffer::setStencilbuffer(GLenum type, GLuint stencilbuffer, GLint level, GLint layer) { - SafeDelete(mStencilbuffer); - mStencilbuffer = createAttachment(type, stencilbuffer, level, layer); + Renderbuffer *renderBuffer = lookupRenderbuffer(type, stencilbuffer, level, layer); + if (renderBuffer) + { + mStencilbuffer.set(renderBuffer, type, level, layer); + } + else + { + mStencilbuffer.set(NULL, GL_NONE, 0, 0); + } } void Framebuffer::setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer, GLint level, GLint layer) { - FramebufferAttachment *attachment = createAttachment(type, depthStencilBuffer, level, layer); - - SafeDelete(mDepthbuffer); - SafeDelete(mStencilbuffer); - - // ensure this is a legitimate depth+stencil format - if (attachment && attachment->getDepthSize() > 0 && attachment->getStencilSize() > 0) + Renderbuffer *renderBuffer = lookupRenderbuffer(type, depthStencilBuffer, level, layer); + if (renderBuffer && renderBuffer->getDepthSize() > 0 && renderBuffer->getStencilSize() > 0) { - mDepthbuffer = attachment; - - // Make a new attachment object to ensure we do not double-delete - // See angle issue 686 - mStencilbuffer = createAttachment(type, depthStencilBuffer, level, layer); + mDepthbuffer.set(renderBuffer, type, level, layer); + mStencilbuffer.set(renderBuffer, type, level, layer); + } + else + { + mDepthbuffer.set(NULL, GL_NONE, 0, 0); + mStencilbuffer.set(NULL, GL_NONE, 0, 0); } } -void Framebuffer::detachTexture(GLuint textureId) +void Framebuffer::detachTexture(GLuint texture) { for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) { - FramebufferAttachment *attachment = mColorbuffers[colorAttachment]; - - if (attachment && attachment->isTextureWithId(textureId)) + if (mColorbuffers[colorAttachment].id() == texture && + IsInternalTextureTarget(mColorbuffers[colorAttachment].type(), mRenderer->getCurrentClientVersion())) { - SafeDelete(mColorbuffers[colorAttachment]); + mColorbuffers[colorAttachment].set(NULL, GL_NONE, 0, 0); } } - if (mDepthbuffer && mDepthbuffer->isTextureWithId(textureId)) + if (mDepthbuffer.id() == texture && IsInternalTextureTarget(mDepthbuffer.type(), mRenderer->getCurrentClientVersion())) { - SafeDelete(mDepthbuffer); + mDepthbuffer.set(NULL, GL_NONE, 0, 0); } - if (mStencilbuffer && mStencilbuffer->isTextureWithId(textureId)) + if (mStencilbuffer.id() == texture && IsInternalTextureTarget(mStencilbuffer.type(), mRenderer->getCurrentClientVersion())) { - SafeDelete(mStencilbuffer); + mStencilbuffer.set(NULL, GL_NONE, 0, 0); } } -void Framebuffer::detachRenderbuffer(GLuint renderbufferId) +void Framebuffer::detachRenderbuffer(GLuint renderbuffer) { for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) { - FramebufferAttachment *attachment = mColorbuffers[colorAttachment]; - - if (attachment && attachment->isRenderbufferWithId(renderbufferId)) + if (mColorbuffers[colorAttachment].id() == renderbuffer && mColorbuffers[colorAttachment].type() == GL_RENDERBUFFER) { - SafeDelete(mColorbuffers[colorAttachment]); + mColorbuffers[colorAttachment].set(NULL, GL_NONE, 0, 0); } } - if (mDepthbuffer && mDepthbuffer->isRenderbufferWithId(renderbufferId)) + if (mDepthbuffer.id() == renderbuffer && mDepthbuffer.type() == GL_RENDERBUFFER) { - SafeDelete(mDepthbuffer); + mDepthbuffer.set(NULL, GL_NONE, 0, 0); } - if (mStencilbuffer && mStencilbuffer->isRenderbufferWithId(renderbufferId)) + if (mStencilbuffer.id() == renderbuffer && mStencilbuffer.type() == GL_RENDERBUFFER) { - SafeDelete(mStencilbuffer); + mStencilbuffer.set(NULL, GL_NONE, 0, 0); } } -FramebufferAttachment *Framebuffer::getColorbuffer(unsigned int colorAttachment) const +unsigned int Framebuffer::getRenderTargetSerial(unsigned int colorAttachment) const { ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS); - return mColorbuffers[colorAttachment]; + + Renderbuffer *colorbuffer = mColorbuffers[colorAttachment].get(); + + if (colorbuffer) + { + return colorbuffer->getSerial(); + } + + return 0; } -FramebufferAttachment *Framebuffer::getDepthbuffer() const +unsigned int Framebuffer::getDepthbufferSerial() const { - return mDepthbuffer; + Renderbuffer *depthbuffer = mDepthbuffer.get(); + + if (depthbuffer) + { + return depthbuffer->getSerial(); + } + + return 0; } -FramebufferAttachment *Framebuffer::getStencilbuffer() const +unsigned int Framebuffer::getStencilbufferSerial() const { - return mStencilbuffer; + Renderbuffer *stencilbuffer = mStencilbuffer.get(); + + if (stencilbuffer) + { + return stencilbuffer->getSerial(); + } + + return 0; } -FramebufferAttachment *Framebuffer::getDepthStencilBuffer() const +Renderbuffer *Framebuffer::getColorbuffer(unsigned int colorAttachment) const { - return (hasValidDepthStencil() ? mDepthbuffer : NULL); + ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS); + return mColorbuffers[colorAttachment].get(); } -FramebufferAttachment *Framebuffer::getDepthOrStencilbuffer() const +Renderbuffer *Framebuffer::getDepthbuffer() const { - FramebufferAttachment *depthstencilbuffer = mDepthbuffer; + return mDepthbuffer.get(); +} + +Renderbuffer *Framebuffer::getStencilbuffer() const +{ + return mStencilbuffer.get(); +} + +Renderbuffer *Framebuffer::getDepthStencilBuffer() const +{ + return (mDepthbuffer.id() == mStencilbuffer.id()) ? mDepthbuffer.get() : NULL; +} + +Renderbuffer *Framebuffer::getDepthOrStencilbuffer() const +{ + Renderbuffer *depthstencilbuffer = mDepthbuffer.get(); if (!depthstencilbuffer) { - depthstencilbuffer = mStencilbuffer; + depthstencilbuffer = mStencilbuffer.get(); } return depthstencilbuffer; } -FramebufferAttachment *Framebuffer::getReadColorbuffer() const +Renderbuffer *Framebuffer::getReadColorbuffer() const { // Will require more logic if glReadBuffers is supported - return mColorbuffers[0]; + return mColorbuffers[0].get(); } GLenum Framebuffer::getReadColorbufferType() const { // Will require more logic if glReadBuffers is supported - return (mColorbuffers[0] ? mColorbuffers[0]->type() : GL_NONE); + return mColorbuffers[0].type(); } -FramebufferAttachment *Framebuffer::getFirstColorbuffer() const +Renderbuffer *Framebuffer::getFirstColorbuffer() const { for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) { - if (mColorbuffers[colorAttachment]) + if (mColorbuffers[colorAttachment].type() != GL_NONE) { - return mColorbuffers[colorAttachment]; + return mColorbuffers[colorAttachment].get(); } } @@ -274,85 +314,85 @@ FramebufferAttachment *Framebuffer::getFirstColorbuffer() const GLenum Framebuffer::getColorbufferType(unsigned int colorAttachment) const { ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS); - return (mColorbuffers[colorAttachment] ? mColorbuffers[colorAttachment]->type() : GL_NONE); + return mColorbuffers[colorAttachment].type(); } GLenum Framebuffer::getDepthbufferType() const { - return (mDepthbuffer ? mDepthbuffer->type() : GL_NONE); + return mDepthbuffer.type(); } GLenum Framebuffer::getStencilbufferType() const { - return (mStencilbuffer ? mStencilbuffer->type() : GL_NONE); + return mStencilbuffer.type(); } GLenum Framebuffer::getDepthStencilbufferType() const { - return (hasValidDepthStencil() ? mDepthbuffer->type() : GL_NONE); + return (mDepthbuffer.id() == mStencilbuffer.id()) ? mDepthbuffer.type() : GL_NONE; } GLuint Framebuffer::getColorbufferHandle(unsigned int colorAttachment) const { ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS); - return (mColorbuffers[colorAttachment] ? mColorbuffers[colorAttachment]->id() : 0); + return mColorbuffers[colorAttachment].id(); } GLuint Framebuffer::getDepthbufferHandle() const { - return (mDepthbuffer ? mDepthbuffer->id() : 0); + return mDepthbuffer.id(); } GLuint Framebuffer::getStencilbufferHandle() const { - return (mStencilbuffer ? mStencilbuffer->id() : 0); + return mStencilbuffer.id(); } -GLuint Framebuffer::getDepthStencilbufferHandle() const +GLenum Framebuffer::getDepthStencilbufferHandle() const { - return (hasValidDepthStencil() ? mDepthbuffer->id() : 0); + return (mDepthbuffer.id() == mStencilbuffer.id()) ? mDepthbuffer.id() : 0; } -GLint Framebuffer::getColorbufferMipLevel(unsigned int colorAttachment) const +GLenum Framebuffer::getColorbufferMipLevel(unsigned int colorAttachment) const { ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS); - return (mColorbuffers[colorAttachment] ? mColorbuffers[colorAttachment]->mipLevel() : 0); + return mColorbuffers[colorAttachment].mipLevel(); } -GLint Framebuffer::getDepthbufferMipLevel() const +GLenum Framebuffer::getDepthbufferMipLevel() const { - return (mDepthbuffer ? mDepthbuffer->mipLevel() : 0); + return mDepthbuffer.mipLevel(); } -GLint Framebuffer::getStencilbufferMipLevel() const +GLenum Framebuffer::getStencilbufferMipLevel() const { - return (mStencilbuffer ? mStencilbuffer->mipLevel() : 0); + return mStencilbuffer.mipLevel(); } -GLint Framebuffer::getDepthStencilbufferMipLevel() const +GLenum Framebuffer::getDepthStencilbufferMipLevel() const { - return (hasValidDepthStencil() ? mDepthbuffer->mipLevel() : 0); + return (mDepthbuffer.id() == mStencilbuffer.id()) ? mDepthbuffer.mipLevel() : 0; } -GLint Framebuffer::getColorbufferLayer(unsigned int colorAttachment) const +GLenum Framebuffer::getColorbufferLayer(unsigned int colorAttachment) const { ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS); - return (mColorbuffers[colorAttachment] ? mColorbuffers[colorAttachment]->layer() : 0); + return mColorbuffers[colorAttachment].layer(); } -GLint Framebuffer::getDepthbufferLayer() const +GLenum Framebuffer::getDepthbufferLayer() const { - return (mDepthbuffer ? mDepthbuffer->layer() : 0); + return mDepthbuffer.layer(); } -GLint Framebuffer::getStencilbufferLayer() const +GLenum Framebuffer::getStencilbufferLayer() const { - return (mStencilbuffer ? mStencilbuffer->layer() : 0); + return mStencilbuffer.layer(); } -GLint Framebuffer::getDepthStencilbufferLayer() const +GLenum Framebuffer::getDepthStencilbufferLayer() const { - return (hasValidDepthStencil() ? mDepthbuffer->layer() : 0); + return (mDepthbuffer.id() == mStencilbuffer.id()) ? mDepthbuffer.layer() : 0; } GLenum Framebuffer::getDrawBufferState(unsigned int colorAttachment) const @@ -367,7 +407,7 @@ void Framebuffer::setDrawBufferState(unsigned int colorAttachment, GLenum drawBu bool Framebuffer::isEnabledColorAttachment(unsigned int colorAttachment) const { - return (mColorbuffers[colorAttachment] && mDrawBufferStates[colorAttachment] != GL_NONE); + return (mColorbuffers[colorAttachment].type() != GL_NONE && mDrawBufferStates[colorAttachment] != GL_NONE); } bool Framebuffer::hasEnabledColorAttachment() const @@ -385,7 +425,17 @@ bool Framebuffer::hasEnabledColorAttachment() const bool Framebuffer::hasStencil() const { - return (mStencilbuffer && mStencilbuffer->getStencilSize() > 0); + if (mStencilbuffer.type() != GL_NONE) + { + const Renderbuffer *stencilbufferObject = getStencilbuffer(); + + if (stencilbufferObject) + { + return stencilbufferObject->getStencilSize() > 0; + } + } + + return false; } bool Framebuffer::usingExtendedDrawBuffers() const @@ -412,36 +462,46 @@ GLenum Framebuffer::completeness() const for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) { - const FramebufferAttachment *colorbuffer = mColorbuffers[colorAttachment]; - - if (colorbuffer) + if (mColorbuffers[colorAttachment].type() != GL_NONE) { + const Renderbuffer *colorbuffer = getColorbuffer(colorAttachment); + + if (!colorbuffer) + { + return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; + } + if (colorbuffer->getWidth() == 0 || colorbuffer->getHeight() == 0) { return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } - GLenum internalformat = colorbuffer->getInternalFormat(); - const TextureCaps &formatCaps = mRenderer->getCaps().textureCaps.get(internalformat); - if (colorbuffer->isTexture()) + if (mColorbuffers[colorAttachment].type() == GL_RENDERBUFFER) { - if (!formatCaps.colorRendering) + if (!gl::IsColorRenderingSupported(colorbuffer->getInternalFormat(), mRenderer)) + { + return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; + } + } + else if (IsInternalTextureTarget(mColorbuffers[colorAttachment].type(), mRenderer->getCurrentClientVersion())) + { + GLenum internalformat = colorbuffer->getInternalFormat(); + + if (!gl::IsColorRenderingSupported(internalformat, mRenderer)) { return GL_FRAMEBUFFER_UNSUPPORTED; } - if (gl::GetDepthBits(internalformat) > 0 || - gl::GetStencilBits(internalformat) > 0) + if (gl::GetDepthBits(internalformat, clientVersion) > 0 || + gl::GetStencilBits(internalformat, clientVersion) > 0) { return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } } else { - if (!formatCaps.colorRendering) - { - return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; - } + UNREACHABLE(); + return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } if (!missingAttachment) @@ -463,7 +523,7 @@ GLenum Framebuffer::completeness() const // in GLES 3.0, there is no such restriction if (clientVersion < 3) { - if (gl::GetPixelBytes(colorbuffer->getInternalFormat()) != colorbufferSize) + if (gl::GetPixelBytes(colorbuffer->getInternalFormat(), clientVersion) != colorbufferSize) { return GL_FRAMEBUFFER_UNSUPPORTED; } @@ -472,8 +532,7 @@ GLenum Framebuffer::completeness() const // D3D11 does not allow for overlapping RenderTargetViews, so ensure uniqueness for (unsigned int previousColorAttachment = 0; previousColorAttachment < colorAttachment; previousColorAttachment++) { - if (colorbuffer->id() == getColorbufferHandle(previousColorAttachment) && - colorbuffer->type() == getColorbufferType(previousColorAttachment)) + if (mColorbuffers[colorAttachment].get() == mColorbuffers[previousColorAttachment].get()) { return GL_FRAMEBUFFER_UNSUPPORTED; } @@ -484,116 +543,129 @@ GLenum Framebuffer::completeness() const width = colorbuffer->getWidth(); height = colorbuffer->getHeight(); samples = colorbuffer->getSamples(); - colorbufferSize = gl::GetPixelBytes(colorbuffer->getInternalFormat()); + colorbufferSize = gl::GetPixelBytes(colorbuffer->getInternalFormat(), clientVersion); missingAttachment = false; } } } - if (mDepthbuffer) + const Renderbuffer *depthbuffer = NULL; + const Renderbuffer *stencilbuffer = NULL; + + if (mDepthbuffer.type() != GL_NONE) { - if (mDepthbuffer->getWidth() == 0 || mDepthbuffer->getHeight() == 0) + depthbuffer = getDepthbuffer(); + + if (!depthbuffer) { return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } - GLenum internalformat = mDepthbuffer->getInternalFormat(); - const TextureCaps &formatCaps = mRenderer->getCaps().textureCaps.get(internalformat); - if (mDepthbuffer->isTexture()) + if (depthbuffer->getWidth() == 0 || depthbuffer->getHeight() == 0) { - GLenum internalformat = mDepthbuffer->getInternalFormat(); + return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; + } + + if (mDepthbuffer.type() == GL_RENDERBUFFER) + { + if (!gl::IsDepthRenderingSupported(depthbuffer->getInternalFormat(), mRenderer)) + { + return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; + } + } + else if (IsInternalTextureTarget(mDepthbuffer.type(), mRenderer->getCurrentClientVersion())) + { + GLenum internalformat = depthbuffer->getInternalFormat(); // depth texture attachments require OES/ANGLE_depth_texture - if (!mRenderer->getCaps().extensions.depthTextures) + if (!mRenderer->getDepthTextureSupport()) { return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } - if (!formatCaps.depthRendering) - { - return GL_FRAMEBUFFER_UNSUPPORTED; - } - - if (gl::GetDepthBits(internalformat) == 0) + if (gl::GetDepthBits(internalformat, clientVersion) == 0) { return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } } else { - if (!formatCaps.depthRendering) - { - return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; - } + UNREACHABLE(); + return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } if (missingAttachment) { - width = mDepthbuffer->getWidth(); - height = mDepthbuffer->getHeight(); - samples = mDepthbuffer->getSamples(); + width = depthbuffer->getWidth(); + height = depthbuffer->getHeight(); + samples = depthbuffer->getSamples(); missingAttachment = false; } - else if (width != mDepthbuffer->getWidth() || height != mDepthbuffer->getHeight()) + else if (width != depthbuffer->getWidth() || height != depthbuffer->getHeight()) { return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; } - else if (samples != mDepthbuffer->getSamples()) + else if (samples != depthbuffer->getSamples()) { return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE; } } - if (mStencilbuffer) + if (mStencilbuffer.type() != GL_NONE) { - if (mStencilbuffer->getWidth() == 0 || mStencilbuffer->getHeight() == 0) + stencilbuffer = getStencilbuffer(); + + if (!stencilbuffer) { return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } - GLenum internalformat = mStencilbuffer->getInternalFormat(); - const TextureCaps &formatCaps = mRenderer->getCaps().textureCaps.get(internalformat); - if (mStencilbuffer->isTexture()) + if (stencilbuffer->getWidth() == 0 || stencilbuffer->getHeight() == 0) { - GLenum internalformat = mStencilbuffer->getInternalFormat(); + return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; + } + + if (mStencilbuffer.type() == GL_RENDERBUFFER) + { + if (!gl::IsStencilRenderingSupported(stencilbuffer->getInternalFormat(), mRenderer)) + { + return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; + } + } + else if (IsInternalTextureTarget(mStencilbuffer.type(), mRenderer->getCurrentClientVersion())) + { + GLenum internalformat = stencilbuffer->getInternalFormat(); // texture stencil attachments come along as part // of OES_packed_depth_stencil + OES/ANGLE_depth_texture - if (!mRenderer->getCaps().extensions.depthTextures) + if (!mRenderer->getDepthTextureSupport()) { return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } - if (!formatCaps.stencilRendering) - { - return GL_FRAMEBUFFER_UNSUPPORTED; - } - - if (gl::GetStencilBits(internalformat) == 0) + if (gl::GetStencilBits(internalformat, clientVersion) == 0) { return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } } else { - if (!formatCaps.stencilRendering) - { - return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; - } + UNREACHABLE(); + return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } if (missingAttachment) { - width = mStencilbuffer->getWidth(); - height = mStencilbuffer->getHeight(); - samples = mStencilbuffer->getSamples(); + width = stencilbuffer->getWidth(); + height = stencilbuffer->getHeight(); + samples = stencilbuffer->getSamples(); missingAttachment = false; } - else if (width != mStencilbuffer->getWidth() || height != mStencilbuffer->getHeight()) + else if (width != stencilbuffer->getWidth() || height != stencilbuffer->getHeight()) { return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; } - else if (samples != mStencilbuffer->getSamples()) + else if (samples != stencilbuffer->getSamples()) { return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE; } @@ -601,7 +673,7 @@ GLenum Framebuffer::completeness() const // 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()) + if (depthbuffer && stencilbuffer && (depthbuffer != stencilbuffer)) { return GL_FRAMEBUFFER_UNSUPPORTED; } @@ -618,15 +690,11 @@ GLenum Framebuffer::completeness() const DefaultFramebuffer::DefaultFramebuffer(rx::Renderer *renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil) : Framebuffer(renderer) { - Renderbuffer *colorRenderbuffer = new Renderbuffer(0, colorbuffer); - mColorbuffers[0] = new RenderbufferAttachment(colorRenderbuffer); + mColorbuffers[0].set(new Renderbuffer(mRenderer, 0, colorbuffer), GL_RENDERBUFFER, 0, 0); - Renderbuffer *depthStencilBuffer = new Renderbuffer(0, depthStencil); - - // Make a new attachment objects to ensure we do not double-delete - // See angle issue 686 - mDepthbuffer = (depthStencilBuffer->getDepthSize() != 0 ? new RenderbufferAttachment(depthStencilBuffer) : NULL); - mStencilbuffer = (depthStencilBuffer->getStencilSize() != 0 ? new RenderbufferAttachment(depthStencilBuffer) : NULL); + Renderbuffer *depthStencilRenderbuffer = new Renderbuffer(mRenderer, 0, depthStencil); + mDepthbuffer.set(depthStencilRenderbuffer, (depthStencilRenderbuffer->getDepthSize() != 0) ? GL_RENDERBUFFER : GL_NONE, 0, 0); + mStencilbuffer.set(depthStencilRenderbuffer, (depthStencilRenderbuffer->getStencilSize() != 0) ? GL_RENDERBUFFER : GL_NONE, 0, 0); mDrawBufferStates[0] = GL_BACK; mReadBufferState = GL_BACK; @@ -640,9 +708,9 @@ int Framebuffer::getSamples() const // in this case return the first nonzero sample size for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) { - if (mColorbuffers[colorAttachment]) + if (mColorbuffers[colorAttachment].type() != GL_NONE) { - return mColorbuffers[colorAttachment]->getSamples(); + return getColorbuffer(colorAttachment)->getSamples(); } } } @@ -650,15 +718,6 @@ int Framebuffer::getSamples() const 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()); -} - GLenum DefaultFramebuffer::completeness() const { // The default framebuffer *must* always be complete, though it may not be diff --git a/gfx/angle/src/libGLESv2/Framebuffer.h b/gfx/angle/src/libGLESv2/Framebuffer.h index 56eb6d9196dc..c0d8ee882d7b 100644 --- a/gfx/angle/src/libGLESv2/Framebuffer.h +++ b/gfx/angle/src/libGLESv2/Framebuffer.h @@ -21,7 +21,7 @@ class Renderer; namespace gl { -class FramebufferAttachment; +class Renderbuffer; class Colorbuffer; class Depthbuffer; class Stencilbuffer; @@ -42,14 +42,18 @@ class Framebuffer 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; + unsigned int getRenderTargetSerial(unsigned int colorAttachment) const; + unsigned int getDepthbufferSerial() const; + unsigned int getStencilbufferSerial() const; + + Renderbuffer *getColorbuffer(unsigned int colorAttachment) const; + Renderbuffer *getDepthbuffer() const; + Renderbuffer *getStencilbuffer() const; + Renderbuffer *getDepthStencilBuffer() const; + Renderbuffer *getDepthOrStencilbuffer() const; + Renderbuffer *getReadColorbuffer() const; GLenum getReadColorbufferType() const; - FramebufferAttachment *getFirstColorbuffer() const; + Renderbuffer *getFirstColorbuffer() const; GLenum getColorbufferType(unsigned int colorAttachment) const; GLenum getDepthbufferType() const; @@ -59,17 +63,17 @@ class Framebuffer GLuint getColorbufferHandle(unsigned int colorAttachment) const; GLuint getDepthbufferHandle() const; GLuint getStencilbufferHandle() const; - GLuint getDepthStencilbufferHandle() const; + GLenum getDepthStencilbufferHandle() const; - GLint getColorbufferMipLevel(unsigned int colorAttachment) const; - GLint getDepthbufferMipLevel() const; - GLint getStencilbufferMipLevel() const; - GLint getDepthStencilbufferMipLevel() const; + GLenum getColorbufferMipLevel(unsigned int colorAttachment) const; + GLenum getDepthbufferMipLevel() const; + GLenum getStencilbufferMipLevel() const; + GLenum getDepthStencilbufferMipLevel() const; - GLint getColorbufferLayer(unsigned int colorAttachment) const; - GLint getDepthbufferLayer() const; - GLint getStencilbufferLayer() const; - GLint getDepthStencilbufferLayer() const; + GLenum getColorbufferLayer(unsigned int colorAttachment) const; + GLenum getDepthbufferLayer() const; + GLenum getStencilbufferLayer() const; + GLenum getDepthStencilbufferLayer() const; GLenum getDrawBufferState(unsigned int colorAttachment) const; void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer); @@ -83,21 +87,19 @@ class Framebuffer virtual GLenum completeness() const; protected: - rx::Renderer *mRenderer; - - FramebufferAttachment *mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS]; + FramebufferTextureBindingPointer mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS]; GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS]; GLenum mReadBufferState; - FramebufferAttachment *mDepthbuffer; - FramebufferAttachment *mStencilbuffer; + FramebufferTextureBindingPointer mDepthbuffer; + FramebufferTextureBindingPointer mStencilbuffer; - bool hasValidDepthStencil() const; + rx::Renderer *mRenderer; -private: + private: DISALLOW_COPY_AND_ASSIGN(Framebuffer); - FramebufferAttachment *createAttachment(GLenum type, GLuint handle, GLint level, GLint layer) const; + Renderbuffer *lookupRenderbuffer(GLenum type, GLuint handle, GLint level, GLint layer) const; }; class DefaultFramebuffer : public Framebuffer diff --git a/gfx/angle/src/libGLESv2/FramebufferAttachment.cpp b/gfx/angle/src/libGLESv2/FramebufferAttachment.cpp deleted file mode 100644 index d796fed0f3db..000000000000 --- a/gfx/angle/src/libGLESv2/FramebufferAttachment.cpp +++ /dev/null @@ -1,495 +0,0 @@ -#include "precompiled.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. -// - -// 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/renderer/RenderTarget.h" - -#include "libGLESv2/Texture.h" -#include "libGLESv2/renderer/Renderer.h" -#include "libGLESv2/renderer/TextureStorage.h" -#include "common/utilities.h" -#include "libGLESv2/formatutils.h" -#include "libGLESv2/Renderbuffer.h" - -namespace gl -{ - -////// FramebufferAttachment Implementation ////// - -FramebufferAttachment::FramebufferAttachment() -{ -} - -FramebufferAttachment::~FramebufferAttachment() -{ -} - -GLuint FramebufferAttachment::getRedSize() const -{ - return (gl::GetRedBits(getInternalFormat()) > 0) ? gl::GetRedBits(getActualFormat()) : 0; -} - -GLuint FramebufferAttachment::getGreenSize() const -{ - return (gl::GetGreenBits(getInternalFormat()) > 0) ? gl::GetGreenBits(getActualFormat()) : 0; -} - -GLuint FramebufferAttachment::getBlueSize() const -{ - return (gl::GetBlueBits(getInternalFormat()) > 0) ? gl::GetBlueBits(getActualFormat()) : 0; -} - -GLuint FramebufferAttachment::getAlphaSize() const -{ - return (gl::GetAlphaBits(getInternalFormat()) > 0) ? gl::GetAlphaBits(getActualFormat()) : 0; -} - -GLuint FramebufferAttachment::getDepthSize() const -{ - return (gl::GetDepthBits(getInternalFormat()) > 0) ? gl::GetDepthBits(getActualFormat()) : 0; -} - -GLuint FramebufferAttachment::getStencilSize() const -{ - return (gl::GetStencilBits(getInternalFormat()) > 0) ? gl::GetStencilBits(getActualFormat()) : 0; -} - -GLenum FramebufferAttachment::getComponentType() const -{ - return gl::GetComponentType(getActualFormat()); -} - -GLenum FramebufferAttachment::getColorEncoding() const -{ - return gl::GetColorEncoding(getActualFormat()); -} - -bool FramebufferAttachment::isTexture() const -{ - return (type() != GL_RENDERBUFFER); -} - -///// Texture2DAttachment Implementation //////// - -Texture2DAttachment::Texture2DAttachment(Texture2D *texture, GLint level) : mLevel(level) -{ - mTexture2D.set(texture); -} - -Texture2DAttachment::~Texture2DAttachment() -{ - mTexture2D.set(NULL); -} - -rx::RenderTarget *Texture2DAttachment::getRenderTarget() -{ - return mTexture2D->getRenderTarget(mLevel); -} - -rx::RenderTarget *Texture2DAttachment::getDepthStencil() -{ - return mTexture2D->getDepthSencil(mLevel); -} - -rx::TextureStorage *Texture2DAttachment::getTextureStorage() -{ - return mTexture2D->getNativeTexture()->getStorageInstance(); -} - -GLsizei Texture2DAttachment::getWidth() const -{ - return mTexture2D->getWidth(mLevel); -} - -GLsizei Texture2DAttachment::getHeight() const -{ - return mTexture2D->getHeight(mLevel); -} - -GLenum Texture2DAttachment::getInternalFormat() const -{ - return mTexture2D->getInternalFormat(mLevel); -} - -GLenum Texture2DAttachment::getActualFormat() const -{ - return mTexture2D->getActualFormat(mLevel); -} - -GLsizei Texture2DAttachment::getSamples() const -{ - return 0; -} - -unsigned int Texture2DAttachment::getSerial() const -{ - return mTexture2D->getRenderTargetSerial(mLevel); -} - -GLuint Texture2DAttachment::id() const -{ - return mTexture2D->id(); -} - -GLenum Texture2DAttachment::type() const -{ - return GL_TEXTURE_2D; -} - -GLint Texture2DAttachment::mipLevel() const -{ - return mLevel; -} - -GLint Texture2DAttachment::layer() const -{ - return 0; -} - -unsigned int Texture2DAttachment::getTextureSerial() const -{ - return mTexture2D->getTextureSerial(); -} - -///// TextureCubeMapAttachment Implementation //////// - -TextureCubeMapAttachment::TextureCubeMapAttachment(TextureCubeMap *texture, GLenum faceTarget, GLint level) - : mFaceTarget(faceTarget), mLevel(level) -{ - mTextureCubeMap.set(texture); -} - -TextureCubeMapAttachment::~TextureCubeMapAttachment() -{ - mTextureCubeMap.set(NULL); -} - -rx::RenderTarget *TextureCubeMapAttachment::getRenderTarget() -{ - return mTextureCubeMap->getRenderTarget(mFaceTarget, mLevel); -} - -rx::RenderTarget *TextureCubeMapAttachment::getDepthStencil() -{ - return mTextureCubeMap->getDepthStencil(mFaceTarget, mLevel); -} - -rx::TextureStorage *TextureCubeMapAttachment::getTextureStorage() -{ - return mTextureCubeMap->getNativeTexture()->getStorageInstance(); -} - -GLsizei TextureCubeMapAttachment::getWidth() const -{ - return mTextureCubeMap->getWidth(mFaceTarget, mLevel); -} - -GLsizei TextureCubeMapAttachment::getHeight() const -{ - return mTextureCubeMap->getHeight(mFaceTarget, mLevel); -} - -GLenum TextureCubeMapAttachment::getInternalFormat() const -{ - return mTextureCubeMap->getInternalFormat(mFaceTarget, mLevel); -} - -GLenum TextureCubeMapAttachment::getActualFormat() const -{ - return mTextureCubeMap->getActualFormat(mFaceTarget, mLevel); -} - -GLsizei TextureCubeMapAttachment::getSamples() const -{ - return 0; -} - -unsigned int TextureCubeMapAttachment::getSerial() const -{ - return mTextureCubeMap->getRenderTargetSerial(mFaceTarget, mLevel); -} - -GLuint TextureCubeMapAttachment::id() const -{ - return mTextureCubeMap->id(); -} - -GLenum TextureCubeMapAttachment::type() const -{ - return mFaceTarget; -} - -GLint TextureCubeMapAttachment::mipLevel() const -{ - return mLevel; -} - -GLint TextureCubeMapAttachment::layer() const -{ - return 0; -} - -unsigned int TextureCubeMapAttachment::getTextureSerial() const -{ - return mTextureCubeMap->getTextureSerial(); -} - -///// Texture3DAttachment Implementation //////// - -Texture3DAttachment::Texture3DAttachment(Texture3D *texture, GLint level, GLint layer) - : mLevel(level), mLayer(layer) -{ - mTexture3D.set(texture); -} - -Texture3DAttachment::~Texture3DAttachment() -{ - mTexture3D.set(NULL); -} - -rx::RenderTarget *Texture3DAttachment::getRenderTarget() -{ - return mTexture3D->getRenderTarget(mLevel, mLayer); -} - -rx::RenderTarget *Texture3DAttachment::getDepthStencil() -{ - return mTexture3D->getDepthStencil(mLevel, mLayer); -} - -rx::TextureStorage *Texture3DAttachment::getTextureStorage() -{ - return mTexture3D->getNativeTexture()->getStorageInstance(); -} - -GLsizei Texture3DAttachment::getWidth() const -{ - return mTexture3D->getWidth(mLevel); -} - -GLsizei Texture3DAttachment::getHeight() const -{ - return mTexture3D->getHeight(mLevel); -} - -GLenum Texture3DAttachment::getInternalFormat() const -{ - return mTexture3D->getInternalFormat(mLevel); -} - -GLenum Texture3DAttachment::getActualFormat() const -{ - return mTexture3D->getActualFormat(mLevel); -} - -GLsizei Texture3DAttachment::getSamples() const -{ - return 0; -} - -unsigned int Texture3DAttachment::getSerial() const -{ - return mTexture3D->getRenderTargetSerial(mLevel, mLayer); -} - -GLuint Texture3DAttachment::id() const -{ - return mTexture3D->id(); -} - -GLenum Texture3DAttachment::type() const -{ - return GL_TEXTURE_3D; -} - -GLint Texture3DAttachment::mipLevel() const -{ - return mLevel; -} - -GLint Texture3DAttachment::layer() const -{ - return mLayer; -} - -unsigned int Texture3DAttachment::getTextureSerial() const -{ - return mTexture3D->getTextureSerial(); -} - -////// Texture2DArrayAttachment Implementation ////// - -Texture2DArrayAttachment::Texture2DArrayAttachment(Texture2DArray *texture, GLint level, GLint layer) - : mLevel(level), mLayer(layer) -{ - mTexture2DArray.set(texture); -} - -Texture2DArrayAttachment::~Texture2DArrayAttachment() -{ - mTexture2DArray.set(NULL); -} - -rx::RenderTarget *Texture2DArrayAttachment::getRenderTarget() -{ - return mTexture2DArray->getRenderTarget(mLevel, mLayer); -} - -rx::RenderTarget *Texture2DArrayAttachment::getDepthStencil() -{ - return mTexture2DArray->getDepthStencil(mLevel, mLayer); -} - -rx::TextureStorage *Texture2DArrayAttachment::getTextureStorage() -{ - return mTexture2DArray->getNativeTexture()->getStorageInstance(); -} - -GLsizei Texture2DArrayAttachment::getWidth() const -{ - return mTexture2DArray->getWidth(mLevel); -} - -GLsizei Texture2DArrayAttachment::getHeight() const -{ - return mTexture2DArray->getHeight(mLevel); -} - -GLenum Texture2DArrayAttachment::getInternalFormat() const -{ - return mTexture2DArray->getInternalFormat(mLevel); -} - -GLenum Texture2DArrayAttachment::getActualFormat() const -{ - return mTexture2DArray->getActualFormat(mLevel); -} - -GLsizei Texture2DArrayAttachment::getSamples() const -{ - return 0; -} - -unsigned int Texture2DArrayAttachment::getSerial() const -{ - return mTexture2DArray->getRenderTargetSerial(mLevel, mLayer); -} - -GLuint Texture2DArrayAttachment::id() const -{ - return mTexture2DArray->id(); -} - -GLenum Texture2DArrayAttachment::type() const -{ - return GL_TEXTURE_2D_ARRAY; -} - -GLint Texture2DArrayAttachment::mipLevel() const -{ - return mLevel; -} - -GLint Texture2DArrayAttachment::layer() const -{ - return mLayer; -} - -unsigned int Texture2DArrayAttachment::getTextureSerial() const -{ - return mTexture2DArray->getTextureSerial(); -} - -////// RenderbufferAttachment Implementation ////// - -RenderbufferAttachment::RenderbufferAttachment(Renderbuffer *renderbuffer) -{ - ASSERT(renderbuffer); - mRenderbuffer.set(renderbuffer); -} - -RenderbufferAttachment::~RenderbufferAttachment() -{ - mRenderbuffer.set(NULL); -} - -rx::RenderTarget *RenderbufferAttachment::getRenderTarget() -{ - return mRenderbuffer->getStorage()->getRenderTarget(); -} - -rx::RenderTarget *RenderbufferAttachment::getDepthStencil() -{ - return mRenderbuffer->getStorage()->getDepthStencil(); -} - -rx::TextureStorage *RenderbufferAttachment::getTextureStorage() -{ - UNREACHABLE(); - return 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->getStorage()->getSamples(); -} - -unsigned int RenderbufferAttachment::getSerial() const -{ - return mRenderbuffer->getStorage()->getSerial(); -} - -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; -} - -unsigned int RenderbufferAttachment::getTextureSerial() const -{ - UNREACHABLE(); - return 0; -} - -} diff --git a/gfx/angle/src/libGLESv2/FramebufferAttachment.h b/gfx/angle/src/libGLESv2/FramebufferAttachment.h deleted file mode 100644 index 18768f9831f2..000000000000 --- a/gfx/angle/src/libGLESv2/FramebufferAttachment.h +++ /dev/null @@ -1,246 +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 "angle_gl.h" - -#include "common/angleutils.h" -#include "common/RefCountObject.h" - -namespace rx -{ -class Renderer; -class RenderTarget; -class TextureStorage; -} - -namespace gl -{ -class Texture2D; -class TextureCubeMap; -class Texture3D; -class Texture2DArray; -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: - FramebufferAttachment(); - 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; } - - // Child class interface - virtual rx::RenderTarget *getRenderTarget() = 0; - virtual rx::RenderTarget *getDepthStencil() = 0; - virtual rx::TextureStorage *getTextureStorage() = 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; - - virtual unsigned int getSerial() const = 0; - - virtual GLuint id() const = 0; - virtual GLenum type() const = 0; - virtual GLint mipLevel() const = 0; - virtual GLint layer() const = 0; - virtual unsigned int getTextureSerial() const = 0; - - private: - DISALLOW_COPY_AND_ASSIGN(FramebufferAttachment); -}; - -class Texture2DAttachment : public FramebufferAttachment -{ - public: - Texture2DAttachment(Texture2D *texture, GLint level); - - virtual ~Texture2DAttachment(); - - rx::RenderTarget *getRenderTarget(); - rx::RenderTarget *getDepthStencil(); - rx::TextureStorage *getTextureStorage(); - - virtual GLsizei getWidth() const; - virtual GLsizei getHeight() const; - virtual GLenum getInternalFormat() const; - virtual GLenum getActualFormat() const; - virtual GLsizei getSamples() const; - - virtual unsigned int getSerial() const; - - virtual GLuint id() const; - virtual GLenum type() const; - virtual GLint mipLevel() const; - virtual GLint layer() const; - virtual unsigned int getTextureSerial() const; - - private: - DISALLOW_COPY_AND_ASSIGN(Texture2DAttachment); - - BindingPointer mTexture2D; - const GLint mLevel; -}; - -class TextureCubeMapAttachment : public FramebufferAttachment -{ - public: - TextureCubeMapAttachment(TextureCubeMap *texture, GLenum faceTarget, GLint level); - - virtual ~TextureCubeMapAttachment(); - - rx::RenderTarget *getRenderTarget(); - rx::RenderTarget *getDepthStencil(); - rx::TextureStorage *getTextureStorage(); - - virtual GLsizei getWidth() const; - virtual GLsizei getHeight() const; - virtual GLenum getInternalFormat() const; - virtual GLenum getActualFormat() const; - virtual GLsizei getSamples() const; - - virtual unsigned int getSerial() const; - - virtual GLuint id() const; - virtual GLenum type() const; - virtual GLint mipLevel() const; - virtual GLint layer() const; - virtual unsigned int getTextureSerial() const; - - private: - DISALLOW_COPY_AND_ASSIGN(TextureCubeMapAttachment); - - BindingPointer mTextureCubeMap; - const GLint mLevel; - const GLenum mFaceTarget; -}; - -class Texture3DAttachment : public FramebufferAttachment -{ - public: - Texture3DAttachment(Texture3D *texture, GLint level, GLint layer); - - virtual ~Texture3DAttachment(); - - rx::RenderTarget *getRenderTarget(); - rx::RenderTarget *getDepthStencil(); - rx::TextureStorage *getTextureStorage(); - - virtual GLsizei getWidth() const; - virtual GLsizei getHeight() const; - virtual GLenum getInternalFormat() const; - virtual GLenum getActualFormat() const; - virtual GLsizei getSamples() const; - - virtual unsigned int getSerial() const; - - virtual GLuint id() const; - virtual GLenum type() const; - virtual GLint mipLevel() const; - virtual GLint layer() const; - virtual unsigned int getTextureSerial() const; - - private: - DISALLOW_COPY_AND_ASSIGN(Texture3DAttachment); - - BindingPointer mTexture3D; - const GLint mLevel; - const GLint mLayer; -}; - -class Texture2DArrayAttachment : public FramebufferAttachment -{ - public: - Texture2DArrayAttachment(Texture2DArray *texture, GLint level, GLint layer); - - virtual ~Texture2DArrayAttachment(); - - rx::RenderTarget *getRenderTarget(); - rx::RenderTarget *getDepthStencil(); - rx::TextureStorage *getTextureStorage(); - - virtual GLsizei getWidth() const; - virtual GLsizei getHeight() const; - virtual GLenum getInternalFormat() const; - virtual GLenum getActualFormat() const; - virtual GLsizei getSamples() const; - - virtual unsigned int getSerial() const; - - virtual GLuint id() const; - virtual GLenum type() const; - virtual GLint mipLevel() const; - virtual GLint layer() const; - virtual unsigned int getTextureSerial() const; - - private: - DISALLOW_COPY_AND_ASSIGN(Texture2DArrayAttachment); - - BindingPointer mTexture2DArray; - const GLint mLevel; - const GLint mLayer; -}; - -class RenderbufferAttachment : public FramebufferAttachment -{ - public: - RenderbufferAttachment(Renderbuffer *renderbuffer); - - virtual ~RenderbufferAttachment(); - - rx::RenderTarget *getRenderTarget(); - rx::RenderTarget *getDepthStencil(); - rx::TextureStorage *getTextureStorage(); - - virtual GLsizei getWidth() const; - virtual GLsizei getHeight() const; - virtual GLenum getInternalFormat() const; - virtual GLenum getActualFormat() const; - virtual GLsizei getSamples() const; - - virtual unsigned int getSerial() const; - - virtual GLuint id() const; - virtual GLenum type() const; - virtual GLint mipLevel() const; - virtual GLint layer() const; - virtual unsigned int getTextureSerial() const; - - private: - DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment); - - BindingPointer mRenderbuffer; -}; - -} - -#endif // LIBGLESV2_FRAMEBUFFERATTACHMENT_H_ diff --git a/gfx/angle/src/libGLESv2/HandleAllocator.h b/gfx/angle/src/libGLESv2/HandleAllocator.h index bbded02f990d..e23010d918b5 100644 --- a/gfx/angle/src/libGLESv2/HandleAllocator.h +++ b/gfx/angle/src/libGLESv2/HandleAllocator.h @@ -10,7 +10,8 @@ #ifndef LIBGLESV2_HANDLEALLOCATOR_H_ #define LIBGLESV2_HANDLEALLOCATOR_H_ -#include "angle_gl.h" +#include +#include #include diff --git a/gfx/angle/src/libGLESv2/ProgramBinary.cpp b/gfx/angle/src/libGLESv2/ProgramBinary.cpp index 9635b8e8fc99..b25b457dc178 100644 --- a/gfx/angle/src/libGLESv2/ProgramBinary.cpp +++ b/gfx/angle/src/libGLESv2/ProgramBinary.cpp @@ -10,8 +10,6 @@ #include "libGLESv2/BinaryStream.h" #include "libGLESv2/ProgramBinary.h" -#include "libGLESv2/Framebuffer.h" -#include "libGLESv2/Renderbuffer.h" #include "libGLESv2/renderer/ShaderExecutable.h" #include "common/debug.h" @@ -22,7 +20,7 @@ #include "libGLESv2/Shader.h" #include "libGLESv2/Program.h" #include "libGLESv2/renderer/Renderer.h" -#include "libGLESv2/renderer/d3d/VertexDataManager.h" +#include "libGLESv2/renderer/VertexDataManager.h" #include "libGLESv2/Context.h" #include "libGLESv2/Buffer.h" #include "libGLESv2/DynamicHLSL.h" @@ -53,14 +51,14 @@ unsigned int ParseAndStripArrayIndex(std::string* name) return subscript; } -void GetInputLayoutFromShader(const std::vector &shaderAttributes, VertexFormat inputLayout[MAX_VERTEX_ATTRIBS]) +void GetInputLayoutFromShader(const std::vector &shaderAttributes, VertexFormat inputLayout[MAX_VERTEX_ATTRIBS]) { size_t layoutIndex = 0; for (size_t attributeIndex = 0; attributeIndex < shaderAttributes.size(); attributeIndex++) { ASSERT(layoutIndex < MAX_VERTEX_ATTRIBS); - const sh::Attribute &shaderAttr = shaderAttributes[attributeIndex]; + const gl::Attribute &shaderAttr = shaderAttributes[attributeIndex]; if (shaderAttr.type != GL_NONE) { @@ -70,7 +68,7 @@ void GetInputLayoutFromShader(const std::vector &shaderAttributes { VertexFormat *defaultFormat = &inputLayout[layoutIndex]; - defaultFormat->mType = VariableComponentType(transposedType); + defaultFormat->mType = UniformComponentType(transposedType); defaultFormat->mNormalized = false; defaultFormat->mPureInteger = (defaultFormat->mType != GL_FLOAT); // note: inputs can not be bool defaultFormat->mComponents = VariableColumnCount(transposedType); @@ -86,7 +84,8 @@ VariableLocation::VariableLocation(const std::string &name, unsigned int element { } -ProgramBinary::VertexExecutable::VertexExecutable(const VertexFormat inputLayout[], +ProgramBinary::VertexExecutable::VertexExecutable(rx::Renderer *const renderer, + const VertexFormat inputLayout[], const GLenum signature[], rx::ShaderExecutable *shaderExecutable) : mShaderExecutable(shaderExecutable) @@ -100,7 +99,7 @@ ProgramBinary::VertexExecutable::VertexExecutable(const VertexFormat inputLayout ProgramBinary::VertexExecutable::~VertexExecutable() { - SafeDelete(mShaderExecutable); + delete mShaderExecutable; } bool ProgramBinary::VertexExecutable::matchesSignature(const GLenum signature[]) const @@ -116,17 +115,6 @@ bool ProgramBinary::VertexExecutable::matchesSignature(const GLenum signature[]) return true; } -ProgramBinary::PixelExecutable::PixelExecutable(const std::vector &outputSignature, rx::ShaderExecutable *shaderExecutable) - : mOutputSignature(outputSignature), - mShaderExecutable(shaderExecutable) -{ -} - -ProgramBinary::PixelExecutable::~PixelExecutable() -{ - SafeDelete(mShaderExecutable); -} - LinkedVarying::LinkedVarying() { } @@ -144,7 +132,7 @@ ProgramBinary::ProgramBinary(rx::Renderer *renderer) mRenderer(renderer), mDynamicHLSL(NULL), mVertexWorkarounds(rx::ANGLE_D3D_WORKAROUND_NONE), - mPixelWorkarounds(rx::ANGLE_D3D_WORKAROUND_NONE), + mPixelExecutable(NULL), mGeometryExecutable(NULL), mUsedVertexSamplerRange(0), mUsedPixelSamplerRange(0), @@ -175,7 +163,29 @@ ProgramBinary::ProgramBinary(rx::Renderer *renderer) ProgramBinary::~ProgramBinary() { - reset(); + while (!mVertexExecutables.empty()) + { + delete mVertexExecutables.back(); + mVertexExecutables.pop_back(); + } + + SafeDelete(mGeometryExecutable); + SafeDelete(mPixelExecutable); + + while (!mUniforms.empty()) + { + delete mUniforms.back(); + mUniforms.pop_back(); + } + + while (!mUniformBlocks.empty()) + { + delete mUniformBlocks.back(); + mUniformBlocks.pop_back(); + } + + SafeDelete(mVertexUniformStorage); + SafeDelete(mFragmentUniformStorage); SafeDelete(mDynamicHLSL); } @@ -194,57 +204,9 @@ unsigned int ProgramBinary::issueSerial() return mCurrentSerial++; } -rx::ShaderExecutable *ProgramBinary::getPixelExecutableForFramebuffer(const Framebuffer *fbo) +rx::ShaderExecutable *ProgramBinary::getPixelExecutable() const { - std::vector outputs(IMPLEMENTATION_MAX_DRAW_BUFFERS); - for (size_t outputIndex = 0; outputIndex < IMPLEMENTATION_MAX_DRAW_BUFFERS; outputIndex++) - { - if (fbo->getColorbufferType(outputIndex) != GL_NONE) - { - // Always output floats for now - outputs[outputIndex] = GL_FLOAT; - } - else - { - outputs[outputIndex] = GL_NONE; - } - } - - return getPixelExecutableForOutputLayout(outputs); -} - -rx::ShaderExecutable *ProgramBinary::getPixelExecutableForOutputLayout(const std::vector &outputSignature) -{ - for (size_t executableIndex = 0; executableIndex < mPixelExecutables.size(); executableIndex++) - { - if (mPixelExecutables[executableIndex]->matchesSignature(outputSignature)) - { - return mPixelExecutables[executableIndex]->shaderExecutable(); - } - } - - std::string finalPixelHLSL = mDynamicHLSL->generatePixelShaderForOutputSignature(mPixelHLSL, mPixelShaderKey, mUsesFragDepth, - outputSignature); - - // Generate new pixel executable - InfoLog tempInfoLog; - rx::ShaderExecutable *pixelExecutable = mRenderer->compileToExecutable(tempInfoLog, finalPixelHLSL.c_str(), rx::SHADER_PIXEL, - mTransformFeedbackLinkedVaryings, - (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS), - mPixelWorkarounds); - - if (!pixelExecutable) - { - std::vector 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)); - } - - return pixelExecutable; + return mPixelExecutable; } rx::ShaderExecutable *ProgramBinary::getVertexExecutableForInputLayout(const VertexFormat inputLayout[MAX_VERTEX_ATTRIBS]) @@ -261,11 +223,16 @@ rx::ShaderExecutable *ProgramBinary::getVertexExecutableForInputLayout(const Ver } // Generate new dynamic layout with attribute conversions - std::string finalVertexHLSL = mDynamicHLSL->generateVertexShaderForInputLayout(mVertexHLSL, inputLayout, mShaderAttributes); + const std::string &layoutHLSL = mDynamicHLSL->generateInputLayoutHLSL(inputLayout, mShaderAttributes); + + // Generate new shader source by replacing the attributes stub with the defined input layout + std::string vertexHLSL = mVertexHLSL; + size_t insertPos = vertexHLSL.find(DynamicHLSL::VERTEX_ATTRIBUTE_STUB_STRING); + vertexHLSL.replace(insertPos, DynamicHLSL::VERTEX_ATTRIBUTE_STUB_STRING.length(), layoutHLSL); // Generate new vertex executable InfoLog tempInfoLog; - rx::ShaderExecutable *vertexExecutable = mRenderer->compileToExecutable(tempInfoLog, finalVertexHLSL.c_str(), + rx::ShaderExecutable *vertexExecutable = mRenderer->compileToExecutable(tempInfoLog, vertexHLSL.c_str(), rx::SHADER_VERTEX, mTransformFeedbackLinkedVaryings, (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS), @@ -279,7 +246,7 @@ rx::ShaderExecutable *ProgramBinary::getVertexExecutableForInputLayout(const Ver } else { - mVertexExecutables.push_back(new VertexExecutable(inputLayout, signature, vertexExecutable)); + mVertexExecutables.push_back(new VertexExecutable(mRenderer, inputLayout, signature, vertexExecutable)); } return vertexExecutable; @@ -520,8 +487,8 @@ static inline void SetIfDirty(T *dest, const T& source, bool *dirtyFlag) template void ProgramBinary::setUniform(GLint location, GLsizei count, const T* v, GLenum targetUniformType) { - const int components = VariableComponentCount(targetUniformType); - const GLenum targetBoolType = VariableBoolVectorType(targetUniformType); + const int components = UniformComponentCount(targetUniformType); + const GLenum targetBoolType = UniformBoolVectorType(targetUniformType); LinkedUniform *targetUniform = getUniformByLocation(location); @@ -810,7 +777,7 @@ bool ProgramBinary::getUniformv(GLint location, GLsizei *bufSize, T *params, GLe // sized queries -- ensure the provided buffer is large enough if (bufSize) { - int requiredBytes = VariableExternalSize(targetUniform->type); + int requiredBytes = UniformExternalSize(targetUniform->type); if (*bufSize < requiredBytes) { return false; @@ -823,16 +790,16 @@ bool ProgramBinary::getUniformv(GLint location, GLsizei *bufSize, T *params, GLe const int cols = VariableColumnCount(targetUniform->type); transposeMatrix(params, (GLfloat*)targetUniform->data + mUniformIndex[location].element * 4 * rows, rows, cols, 4, rows); } - else if (uniformType == VariableComponentType(targetUniform->type)) + else if (uniformType == UniformComponentType(targetUniform->type)) { - unsigned int size = VariableComponentCount(targetUniform->type); + unsigned int size = UniformComponentCount(targetUniform->type); memcpy(params, targetUniform->data + mUniformIndex[location].element * 4 * sizeof(T), size * sizeof(T)); } else { - unsigned int size = VariableComponentCount(targetUniform->type); - switch (VariableComponentType(targetUniform->type)) + unsigned int size = UniformComponentCount(targetUniform->type); + switch (UniformComponentType(targetUniform->type)) { case GL_BOOL: { @@ -979,12 +946,12 @@ bool ProgramBinary::applyUniformBuffers(const std::vector boundBuff for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < mUniformBlocks.size(); uniformBlockIndex++) { - UniformBlock *uniformBlock = getUniformBlockByIndex(uniformBlockIndex); + gl::UniformBlock *uniformBlock = getUniformBlockByIndex(uniformBlockIndex); gl::Buffer *uniformBuffer = boundBuffers[uniformBlockIndex]; ASSERT(uniformBlock && uniformBuffer); - if (uniformBuffer->getSize() < uniformBlock->dataSize) + if (uniformBuffer->size() < uniformBlock->dataSize) { // undefined behaviour return false; @@ -1051,11 +1018,6 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, FragmentShader *fragmentShade bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length) { -#ifdef ANGLE_DISABLE_PROGRAM_BINARY_LOAD - return false; -#else - reset(); - BinaryInputStream stream(binary, length); int format = stream.readInt(); @@ -1139,7 +1101,7 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length) int matrixStride = stream.readInt(); bool isRowMajorMatrix = stream.readBool(); - const sh::BlockMemberInfo blockInfo(offset, arrayStride, matrixStride, isRowMajorMatrix); + const gl::BlockMemberInfo blockInfo(offset, arrayStride, matrixStride, isRowMajorMatrix); LinkedUniform *uniform = new LinkedUniform(type, precision, name, arraySize, blockIndex, blockInfo); @@ -1215,6 +1177,7 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length) stream.readInt(&mVertexWorkarounds); const unsigned int vertexShaderCount = stream.readInt(); + for (unsigned int vertexShaderIndex = 0; vertexShaderIndex < vertexShaderCount; vertexShaderIndex++) { VertexFormat inputLayout[MAX_VERTEX_ATTRIBS]; @@ -1229,7 +1192,9 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length) } unsigned int vertexShaderSize = stream.readInt(); - const unsigned char *vertexShaderFunction = reinterpret_cast(binary) + stream.offset(); + + const char *vertexShaderFunction = (const char*) binary + stream.offset(); + rx::ShaderExecutable *shaderExecutable = mRenderer->loadExecutable(reinterpret_cast(vertexShaderFunction), vertexShaderSize, rx::SHADER_VERTEX, mTransformFeedbackLinkedVaryings, @@ -1245,52 +1210,23 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length) mDynamicHLSL->getInputLayoutSignature(inputLayout, signature); // add new binary - mVertexExecutables.push_back(new VertexExecutable(inputLayout, signature, shaderExecutable)); + mVertexExecutables.push_back(new VertexExecutable(mRenderer, inputLayout, signature, shaderExecutable)); stream.skip(vertexShaderSize); } - stream.readString(&mPixelHLSL); - stream.readInt(&mPixelWorkarounds); - stream.readBool(&mUsesFragDepth); + unsigned int pixelShaderSize = stream.readInt(); - const size_t pixelShaderKeySize = stream.readInt(); - mPixelShaderKey.resize(pixelShaderKeySize); - for (size_t pixelShaderKeyIndex = 0; pixelShaderKeyIndex < pixelShaderKeySize; pixelShaderKeyIndex++) + const char *pixelShaderFunction = (const char*) binary + stream.offset(); + mPixelExecutable = mRenderer->loadExecutable(reinterpret_cast(pixelShaderFunction), + pixelShaderSize, rx::SHADER_PIXEL, mTransformFeedbackLinkedVaryings, + (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS)); + if (!mPixelExecutable) { - stream.readInt(&mPixelShaderKey[pixelShaderKeyIndex].type); - stream.readString(&mPixelShaderKey[pixelShaderKeyIndex].name); - stream.readString(&mPixelShaderKey[pixelShaderKeyIndex].source); - stream.readInt(&mPixelShaderKey[pixelShaderKeyIndex].outputIndex); - } - - const size_t pixelShaderCount = stream.readInt(); - for (size_t pixelShaderIndex = 0; pixelShaderIndex < pixelShaderCount; pixelShaderIndex++) - { - const size_t outputCount = stream.readInt(); - std::vector outputs(outputCount); - for (size_t outputIndex = 0; outputIndex < outputCount; outputIndex++) - { - stream.readInt(&outputs[outputIndex]); - } - - const size_t pixelShaderSize = stream.readInt(); - const unsigned char *pixelShaderFunction = reinterpret_cast(binary) + stream.offset(); - rx::ShaderExecutable *shaderExecutable = mRenderer->loadExecutable(pixelShaderFunction, pixelShaderSize, - rx::SHADER_PIXEL, - mTransformFeedbackLinkedVaryings, - (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS)); - if (!shaderExecutable) - { - infoLog.append("Could not create pixel shader."); - return false; - } - - // add new binary - mPixelExecutables.push_back(new PixelExecutable(outputs, shaderExecutable)); - - stream.skip(pixelShaderSize); + infoLog.append("Could not create pixel shader."); + return false; } + stream.skip(pixelShaderSize); unsigned int geometryShaderSize = stream.readInt(); @@ -1303,6 +1239,7 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length) if (!mGeometryExecutable) { infoLog.append("Could not create geometry shader."); + SafeDelete(mPixelExecutable); return false; } stream.skip(geometryShaderSize); @@ -1323,7 +1260,6 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length) initializeUniformStorage(); return true; -#endif // #ifdef ANGLE_DISABLE_PROGRAM_BINARY_LOAD } bool ProgramBinary::save(void* binary, GLsizei bufSize, GLsizei *length) @@ -1451,38 +1387,11 @@ bool ProgramBinary::save(void* binary, GLsizei bufSize, GLsizei *length) stream.writeBytes(vertexBlob, vertexShaderSize); } - stream.writeString(mPixelHLSL); - stream.writeInt(mPixelWorkarounds); - stream.writeInt(mUsesFragDepth); + size_t pixelShaderSize = mPixelExecutable->getLength(); + stream.writeInt(pixelShaderSize); - stream.writeInt(mPixelShaderKey.size()); - for (size_t pixelShaderKeyIndex = 0; pixelShaderKeyIndex < mPixelShaderKey.size(); pixelShaderKeyIndex++) - { - const PixelShaderOuputVariable &variable = mPixelShaderKey[pixelShaderKeyIndex]; - stream.writeInt(variable.type); - stream.writeString(variable.name); - stream.writeString(variable.source); - stream.writeInt(variable.outputIndex); - } - - stream.writeInt(mPixelExecutables.size()); - for (size_t pixelExecutableIndex = 0; pixelExecutableIndex < mPixelExecutables.size(); pixelExecutableIndex++) - { - PixelExecutable *pixelExecutable = mPixelExecutables[pixelExecutableIndex]; - - const std::vector 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); - - unsigned char *pixelBlob = static_cast(pixelExecutable->shaderExecutable()->getFunction()); - stream.writeBytes(pixelBlob, pixelShaderSize); - } + unsigned char *pixelBlob = static_cast(mPixelExecutable->getFunction()); + stream.writeBytes(pixelBlob, pixelShaderSize); size_t geometryShaderSize = (mGeometryExecutable != NULL) ? mGeometryExecutable->getLength() : 0; stream.writeInt(geometryShaderSize); @@ -1556,15 +1465,12 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin return false; } - reset(); - + mTransformFeedbackLinkedVaryings.clear(); mTransformFeedbackBufferMode = transformFeedbackBufferMode; mShaderVersion = vertexShader->getShaderVersion(); - mPixelHLSL = fragmentShader->getHLSL(); - mPixelWorkarounds = fragmentShader->getD3DWorkarounds(); - + std::string pixelHLSL = fragmentShader->getHLSL(); mVertexHLSL = vertexShader->getHLSL(); mVertexWorkarounds = vertexShader->getD3DWorkarounds(); @@ -1584,9 +1490,9 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin mUsesPointSize = vertexShader->usesPointSize(); std::vector linkedVaryings; - if (!mDynamicHLSL->generateShaderLinkHLSL(infoLog, registers, packing, mPixelHLSL, mVertexHLSL, + if (!mDynamicHLSL->generateShaderLinkHLSL(infoLog, registers, packing, pixelHLSL, mVertexHLSL, fragmentShader, vertexShader, transformFeedbackVaryings, - &linkedVaryings, &mOutputVariables, &mPixelShaderKey, &mUsesFragDepth)) + &linkedVaryings, &mOutputVariables)) { return false; } @@ -1606,9 +1512,9 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin // special case for gl_DepthRange, the only built-in uniform (also a struct) if (vertexShader->usesDepthRange() || fragmentShader->usesDepthRange()) { - mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.near", 0, -1, sh::BlockMemberInfo::getDefaultBlockInfo())); - mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.far", 0, -1, sh::BlockMemberInfo::getDefaultBlockInfo())); - mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.diff", 0, -1, sh::BlockMemberInfo::getDefaultBlockInfo())); + mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.near", 0, -1, BlockMemberInfo::getDefaultBlockInfo())); + mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.far", 0, -1, BlockMemberInfo::getDefaultBlockInfo())); + mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.diff", 0, -1, BlockMemberInfo::getDefaultBlockInfo())); } if (!linkUniformBlocks(infoLog, vertexShader->getInterfaceBlocks(), fragmentShader->getInterfaceBlocks())) @@ -1626,14 +1532,12 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin { VertexFormat defaultInputLayout[MAX_VERTEX_ATTRIBS]; GetInputLayoutFromShader(vertexShader->activeAttributes(), defaultInputLayout); - rx::ShaderExecutable *defaultVertexExecutable = getVertexExecutableForInputLayout(defaultInputLayout); - std::vector defaultPixelOutput(IMPLEMENTATION_MAX_DRAW_BUFFERS); - for (size_t i = 0; i < defaultPixelOutput.size(); i++) - { - defaultPixelOutput[i] = (i == 0) ? GL_FLOAT : GL_NONE; - } - rx::ShaderExecutable *defaultPixelExecutable = getPixelExecutableForOutputLayout(defaultPixelOutput); + rx::ShaderExecutable *defaultVertexExecutable = getVertexExecutableForInputLayout(defaultInputLayout); + mPixelExecutable = mRenderer->compileToExecutable(infoLog, pixelHLSL.c_str(), rx::SHADER_PIXEL, + mTransformFeedbackLinkedVaryings, + (mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS), + fragmentShader->getD3DWorkarounds()); if (usesGeometryShader()) { @@ -1644,11 +1548,21 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin rx::ANGLE_D3D_WORKAROUND_NONE); } - if (!defaultVertexExecutable || !defaultPixelExecutable || (usesGeometryShader() && !mGeometryExecutable)) + if (!defaultVertexExecutable || !mPixelExecutable || (usesGeometryShader() && !mGeometryExecutable)) { infoLog.append("Failed to create D3D shaders."); success = false; - reset(); + + while (!mVertexExecutables.empty()) + { + delete mVertexExecutables.back(); + mVertexExecutables.pop_back(); + } + + SafeDelete(mGeometryExecutable); + SafeDelete(mPixelExecutable); + + mTransformFeedbackLinkedVaryings.clear(); } } @@ -1659,19 +1573,19 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin bool ProgramBinary::linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, FragmentShader *fragmentShader, VertexShader *vertexShader) { unsigned int usedLocations = 0; - const std::vector &activeAttributes = vertexShader->activeAttributes(); + const std::vector &activeAttributes = vertexShader->activeAttributes(); // Link attributes that have a binding location for (unsigned int attributeIndex = 0; attributeIndex < activeAttributes.size(); attributeIndex++) { - const sh::Attribute &attribute = activeAttributes[attributeIndex]; + const gl::Attribute &attribute = activeAttributes[attributeIndex]; const int location = attribute.location == -1 ? attributeBindings.getAttributeBinding(attribute.name) : attribute.location; mShaderAttributes[attributeIndex] = attribute; if (location != -1) // Set by glBindAttribLocation or by location layout qualifier { - const int rows = VariableRegisterCount(attribute.type); + const int rows = AttributeRegisterCount(attribute.type); if (rows + location > MAX_VERTEX_ATTRIBS) { @@ -1683,7 +1597,7 @@ bool ProgramBinary::linkAttributes(InfoLog &infoLog, const AttributeBindings &at for (int row = 0; row < rows; row++) { const int rowLocation = location + row; - sh::ShaderVariable &linkedAttribute = mLinkedAttribute[rowLocation]; + gl::ShaderVariable &linkedAttribute = mLinkedAttribute[rowLocation]; // In GLSL 3.00, attribute aliasing produces a link error // In GLSL 1.00, attribute aliasing is allowed @@ -1705,12 +1619,12 @@ bool ProgramBinary::linkAttributes(InfoLog &infoLog, const AttributeBindings &at // Link attributes that don't have a binding location for (unsigned int attributeIndex = 0; attributeIndex < activeAttributes.size(); attributeIndex++) { - const sh::Attribute &attribute = activeAttributes[attributeIndex]; + const gl::Attribute &attribute = activeAttributes[attributeIndex]; 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 rows = AttributeRegisterCount(attribute.type); int availableIndex = AllocateFirstFreeBits(&usedLocations, rows, MAX_VERTEX_ATTRIBS); if (availableIndex == -1 || availableIndex + rows > MAX_VERTEX_ATTRIBS) @@ -1727,7 +1641,7 @@ bool ProgramBinary::linkAttributes(InfoLog &infoLog, const AttributeBindings &at for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; ) { int index = vertexShader->getSemanticIndex(mLinkedAttribute[attributeIndex].name); - int rows = VariableRegisterCount(mLinkedAttribute[attributeIndex].type); + int rows = AttributeRegisterCount(mLinkedAttribute[attributeIndex].type); for (int r = 0; r < rows; r++) { @@ -1740,8 +1654,7 @@ bool ProgramBinary::linkAttributes(InfoLog &infoLog, const AttributeBindings &at return true; } -bool ProgramBinary::linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const sh::ShaderVariable &vertexVariable, - const sh::ShaderVariable &fragmentVariable, bool validatePrecision) +bool ProgramBinary::linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const gl::ShaderVariable &vertexVariable, const gl::ShaderVariable &fragmentVariable, bool validatePrecision) { if (vertexVariable.type != fragmentVariable.type) { @@ -1793,14 +1706,14 @@ bool ProgramBinary::linkValidateFields(InfoLog &infoLog, const std::string &varN return true; } -bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform) +bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const gl::Uniform &vertexUniform, const gl::Uniform &fragmentUniform) { if (!linkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform, true)) { return false; } - if (!linkValidateFields(infoLog, uniformName, vertexUniform, fragmentUniform)) + if (!linkValidateFields(infoLog, uniformName, vertexUniform, fragmentUniform)) { return false; } @@ -1808,7 +1721,7 @@ bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &u return true; } -bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &varyingName, const sh::Varying &vertexVarying, const sh::Varying &fragmentVarying) +bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &varyingName, const gl::Varying &vertexVarying, const gl::Varying &fragmentVarying) { if (!linkValidateVariablesBase(infoLog, varyingName, vertexVarying, fragmentVarying, false)) { @@ -1821,7 +1734,7 @@ bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &v return false; } - if (!linkValidateFields(infoLog, varyingName, vertexVarying, fragmentVarying)) + if (!linkValidateFields(infoLog, varyingName, vertexVarying, fragmentVarying)) { return false; } @@ -1829,7 +1742,7 @@ bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &v return true; } -bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform) +bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const gl::InterfaceBlockField &vertexUniform, const gl::InterfaceBlockField &fragmentUniform) { if (!linkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform, true)) { @@ -1842,7 +1755,7 @@ bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &u return false; } - if (!linkValidateFields(infoLog, uniformName, vertexUniform, fragmentUniform)) + if (!linkValidateFields(infoLog, uniformName, vertexUniform, fragmentUniform)) { return false; } @@ -1850,25 +1763,25 @@ bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &u return true; } -bool ProgramBinary::linkUniforms(InfoLog &infoLog, const std::vector &vertexUniforms, const std::vector &fragmentUniforms) +bool ProgramBinary::linkUniforms(InfoLog &infoLog, const std::vector &vertexUniforms, const std::vector &fragmentUniforms) { // Check that uniforms defined in the vertex and fragment shaders are identical - typedef std::map UniformMap; + typedef std::map UniformMap; UniformMap linkedUniforms; for (unsigned int vertexUniformIndex = 0; vertexUniformIndex < vertexUniforms.size(); vertexUniformIndex++) { - const sh::Uniform &vertexUniform = vertexUniforms[vertexUniformIndex]; + const gl::Uniform &vertexUniform = vertexUniforms[vertexUniformIndex]; linkedUniforms[vertexUniform.name] = &vertexUniform; } for (unsigned int fragmentUniformIndex = 0; fragmentUniformIndex < fragmentUniforms.size(); fragmentUniformIndex++) { - const sh::Uniform &fragmentUniform = fragmentUniforms[fragmentUniformIndex]; + const gl::Uniform &fragmentUniform = fragmentUniforms[fragmentUniformIndex]; UniformMap::const_iterator entry = linkedUniforms.find(fragmentUniform.name); if (entry != linkedUniforms.end()) { - const sh::Uniform &vertexUniform = *entry->second; + const gl::Uniform &vertexUniform = *entry->second; const std::string &uniformName = "uniform '" + vertexUniform.name + "'"; if (!linkValidateVariables(infoLog, uniformName, vertexUniform, fragmentUniform)) { @@ -1928,7 +1841,7 @@ TextureType ProgramBinary::getTextureType(GLenum samplerType, InfoLog &infoLog) return TEXTURE_2D; } -bool ProgramBinary::defineUniform(GLenum shader, const sh::Uniform &constant, InfoLog &infoLog) +bool ProgramBinary::defineUniform(GLenum shader, const gl::Uniform &constant, InfoLog &infoLog) { if (constant.isStruct()) { @@ -1943,10 +1856,10 @@ bool ProgramBinary::defineUniform(GLenum shader, const sh::Uniform &constant, In for (size_t fieldIndex = 0; fieldIndex < constant.fields.size(); fieldIndex++) { - const sh::Uniform &field = constant.fields[fieldIndex]; + const gl::Uniform &field = constant.fields[fieldIndex]; const std::string &uniformName = constant.name + ArrayString(elementIndex) + "." + field.name; const unsigned int fieldRegisterIndex = field.registerIndex + elementRegisterOffset; - sh::Uniform fieldUniform(field.type, field.precision, uniformName.c_str(), field.arraySize, + gl::Uniform fieldUniform(field.type, field.precision, uniformName.c_str(), field.arraySize, fieldRegisterIndex, field.elementIndex); fieldUniform.fields = field.fields; @@ -1961,10 +1874,10 @@ bool ProgramBinary::defineUniform(GLenum shader, const sh::Uniform &constant, In { for (size_t fieldIndex = 0; fieldIndex < constant.fields.size(); fieldIndex++) { - const sh::Uniform &field = constant.fields[fieldIndex]; + const gl::Uniform &field = constant.fields[fieldIndex]; const std::string &uniformName = constant.name + "." + field.name; - sh::Uniform fieldUniform(field.type, field.precision, uniformName.c_str(), field.arraySize, + gl::Uniform fieldUniform(field.type, field.precision, uniformName.c_str(), field.arraySize, field.registerIndex, field.elementIndex); fieldUniform.fields = field.fields; @@ -2032,7 +1945,7 @@ bool ProgramBinary::defineUniform(GLenum shader, const sh::Uniform &constant, In else { uniform = new LinkedUniform(constant.type, constant.precision, constant.name, constant.arraySize, - -1, sh::BlockMemberInfo::getDefaultBlockInfo()); + -1, BlockMemberInfo::getDefaultBlockInfo()); uniform->registerElement = constant.elementIndex; } @@ -2085,7 +1998,7 @@ bool ProgramBinary::defineUniform(GLenum shader, const sh::Uniform &constant, In return true; } -bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::InterfaceBlock &vertexInterfaceBlock, const sh::InterfaceBlock &fragmentInterfaceBlock) +bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &infoLog, const gl::InterfaceBlock &vertexInterfaceBlock, const gl::InterfaceBlock &fragmentInterfaceBlock) { const char* blockName = vertexInterfaceBlock.name.c_str(); @@ -2111,8 +2024,8 @@ bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::Inter 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]; + const gl::InterfaceBlockField &vertexMember = vertexInterfaceBlock.fields[blockMemberIndex]; + const gl::InterfaceBlockField &fragmentMember = fragmentInterfaceBlock.fields[blockMemberIndex]; if (vertexMember.name != fragmentMember.name) { @@ -2131,26 +2044,26 @@ bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::Inter return true; } -bool ProgramBinary::linkUniformBlocks(InfoLog &infoLog, const std::vector &vertexInterfaceBlocks, - const std::vector &fragmentInterfaceBlocks) +bool ProgramBinary::linkUniformBlocks(InfoLog &infoLog, const std::vector &vertexInterfaceBlocks, + const std::vector &fragmentInterfaceBlocks) { // Check that interface blocks defined in the vertex and fragment shaders are identical - typedef std::map UniformBlockMap; + typedef std::map UniformBlockMap; UniformBlockMap linkedUniformBlocks; for (unsigned int blockIndex = 0; blockIndex < vertexInterfaceBlocks.size(); blockIndex++) { - const sh::InterfaceBlock &vertexInterfaceBlock = vertexInterfaceBlocks[blockIndex]; + const gl::InterfaceBlock &vertexInterfaceBlock = vertexInterfaceBlocks[blockIndex]; linkedUniformBlocks[vertexInterfaceBlock.name] = &vertexInterfaceBlock; } for (unsigned int blockIndex = 0; blockIndex < fragmentInterfaceBlocks.size(); blockIndex++) { - const sh::InterfaceBlock &fragmentInterfaceBlock = fragmentInterfaceBlocks[blockIndex]; + const gl::InterfaceBlock &fragmentInterfaceBlock = fragmentInterfaceBlocks[blockIndex]; UniformBlockMap::const_iterator entry = linkedUniformBlocks.find(fragmentInterfaceBlock.name); if (entry != linkedUniformBlocks.end()) { - const sh::InterfaceBlock &vertexInterfaceBlock = *entry->second; + const gl::InterfaceBlock &vertexInterfaceBlock = *entry->second; if (!areMatchingInterfaceBlocks(infoLog, vertexInterfaceBlock, fragmentInterfaceBlock)) { return false; @@ -2235,11 +2148,11 @@ bool ProgramBinary::gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, cons return true; } -void ProgramBinary::defineUniformBlockMembers(const std::vector &fields, const std::string &prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector *blockUniformIndexes) +void ProgramBinary::defineUniformBlockMembers(const std::vector &fields, const std::string &prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector *blockUniformIndexes) { for (unsigned int uniformIndex = 0; uniformIndex < fields.size(); uniformIndex++) { - const sh::InterfaceBlockField &field = fields[uniformIndex]; + const gl::InterfaceBlockField &field = fields[uniformIndex]; const std::string &fieldName = (prefix.empty() ? field.name : prefix + "." + field.name); if (!field.fields.empty()) @@ -2270,7 +2183,7 @@ void ProgramBinary::defineUniformBlockMembers(const std::vectormemberUniformIndexes = blockUniformIndexes; mUniformBlocks.push_back(newUniformBlock); } } else { - UniformBlock *newUniformBlock = new UniformBlock(interfaceBlock.name, GL_INVALID_INDEX, interfaceBlock.dataSize); + gl::UniformBlock *newUniformBlock = new UniformBlock(interfaceBlock.name, GL_INVALID_INDEX, interfaceBlock.dataSize); newUniformBlock->memberUniformIndexes = blockUniformIndexes; mUniformBlocks.push_back(newUniformBlock); } @@ -2308,7 +2221,7 @@ bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, GLenum shader, const sh for (unsigned int uniformBlockElement = 0; uniformBlockElement < elementCount; uniformBlockElement++) { - UniformBlock *uniformBlock = mUniformBlocks[blockIndex + uniformBlockElement]; + gl::UniformBlock *uniformBlock = mUniformBlocks[blockIndex + uniformBlockElement]; ASSERT(uniformBlock->name == interfaceBlock.name); if (!assignUniformBlockRegister(infoLog, uniformBlock, shader, interfaceBlock.registerIndex + uniformBlockElement)) @@ -2771,44 +2684,4 @@ void ProgramBinary::initializeUniformStorage() mFragmentUniformStorage = mRenderer->createUniformStorage(fragmentRegisters * 16u); } -void ProgramBinary::reset() -{ - mVertexHLSL.clear(); - mVertexWorkarounds = rx::ANGLE_D3D_WORKAROUND_NONE; - SafeDeleteContainer(mVertexExecutables); - - mPixelHLSL.clear(); - mPixelWorkarounds = rx::ANGLE_D3D_WORKAROUND_NONE; - mUsesFragDepth = false; - mPixelShaderKey.clear(); - SafeDeleteContainer(mPixelExecutables); - - SafeDelete(mGeometryExecutable); - - mTransformFeedbackBufferMode = GL_NONE; - mTransformFeedbackLinkedVaryings.clear(); - - for (size_t i = 0; i < ArraySize(mSamplersPS); i++) - { - mSamplersPS[i] = Sampler(); - } - for (size_t i = 0; i < ArraySize(mSamplersVS); i++) - { - mSamplersVS[i] = Sampler(); - } - mUsedVertexSamplerRange = 0; - mUsedPixelSamplerRange = 0; - mUsesPointSize = false; - mShaderVersion = 0; - - SafeDeleteContainer(mUniforms); - SafeDeleteContainer(mUniformBlocks); - mUniformIndex.clear(); - mOutputVariables.clear(); - SafeDelete(mVertexUniformStorage); - SafeDelete(mFragmentUniformStorage); - - mValidated = false; -} - } diff --git a/gfx/angle/src/libGLESv2/ProgramBinary.h b/gfx/angle/src/libGLESv2/ProgramBinary.h index aef4dad09d82..839923b68c2f 100644 --- a/gfx/angle/src/libGLESv2/ProgramBinary.h +++ b/gfx/angle/src/libGLESv2/ProgramBinary.h @@ -10,7 +10,10 @@ #ifndef LIBGLESV2_PROGRAM_BINARY_H_ #define LIBGLESV2_PROGRAM_BINARY_H_ -#include "angle_gl.h" +#include +#include +#include +#include #include #include @@ -21,8 +24,7 @@ #include "libGLESv2/Uniform.h" #include "libGLESv2/Shader.h" #include "libGLESv2/Constants.h" -#include "libGLESv2/renderer/d3d/VertexDataManager.h" -#include "libGLESv2/DynamicHLSL.h" +#include "libGLESv2/renderer/VertexDataManager.h" namespace rx { @@ -30,6 +32,7 @@ class ShaderExecutable; class Renderer; struct TranslatedAttribute; class UniformStorage; +class DynamicHLSL; } namespace gl @@ -39,7 +42,6 @@ class VertexShader; class InfoLog; class AttributeBindings; class Buffer; -class Framebuffer; // Struct used for correlating uniforms/elements of uniform arrays to handles struct VariableLocation @@ -80,8 +82,7 @@ class ProgramBinary : public RefCountObject explicit ProgramBinary(rx::Renderer *renderer); ~ProgramBinary(); - rx::ShaderExecutable *getPixelExecutableForFramebuffer(const Framebuffer *fbo); - rx::ShaderExecutable *getPixelExecutableForOutputLayout(const std::vector &outputLayout); + rx::ShaderExecutable *getPixelExecutable() const; rx::ShaderExecutable *getVertexExecutableForInputLayout(const VertexFormat inputLayout[MAX_VERTEX_ATTRIBS]); rx::ShaderExecutable *getGeometryExecutable() const; @@ -176,30 +177,28 @@ class ProgramBinary : public RefCountObject private: DISALLOW_COPY_AND_ASSIGN(ProgramBinary); - void reset(); - bool linkVaryings(InfoLog &infoLog, FragmentShader *fragmentShader, VertexShader *vertexShader); bool linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, FragmentShader *fragmentShader, VertexShader *vertexShader); - typedef std::vector::const_iterator BlockInfoItr; + typedef std::vector::const_iterator BlockInfoItr; template bool linkValidateFields(InfoLog &infoLog, const std::string &varName, const ShaderVarType &vertexVar, const ShaderVarType &fragmentVar); - bool linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const sh::ShaderVariable &vertexVariable, const sh::ShaderVariable &fragmentVariable, bool validatePrecision); + bool linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const ShaderVariable &vertexVariable, const ShaderVariable &fragmentVariable, bool validatePrecision); - bool linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform); - bool linkValidateVariables(InfoLog &infoLog, const std::string &varyingName, const sh::Varying &vertexVarying, const sh::Varying &fragmentVarying); - bool linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform); - bool linkUniforms(InfoLog &infoLog, const std::vector &vertexUniforms, const std::vector &fragmentUniforms); - bool defineUniform(GLenum shader, const sh::Uniform &constant, InfoLog &infoLog); - bool areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::InterfaceBlock &vertexInterfaceBlock, const sh::InterfaceBlock &fragmentInterfaceBlock); - bool linkUniformBlocks(InfoLog &infoLog, const std::vector &vertexUniformBlocks, const std::vector &fragmentUniformBlocks); + bool linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const Uniform &vertexUniform, const Uniform &fragmentUniform); + bool linkValidateVariables(InfoLog &infoLog, const std::string &varyingName, const Varying &vertexVarying, const Varying &fragmentVarying); + bool linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const InterfaceBlockField &vertexUniform, const InterfaceBlockField &fragmentUniform); + bool linkUniforms(InfoLog &infoLog, const std::vector &vertexUniforms, const std::vector &fragmentUniforms); + bool defineUniform(GLenum shader, const Uniform &constant, InfoLog &infoLog); + bool areMatchingInterfaceBlocks(InfoLog &infoLog, const InterfaceBlock &vertexInterfaceBlock, const InterfaceBlock &fragmentInterfaceBlock); + bool linkUniformBlocks(InfoLog &infoLog, const std::vector &vertexUniformBlocks, const std::vector &fragmentUniformBlocks); bool gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, const std::vector &linkedVaryings, const std::vector &transformFeedbackVaryingNames, GLenum transformFeedbackBufferMode, std::vector *outTransformFeedbackLinkedVaryings) const; - void defineUniformBlockMembers(const std::vector &fields, const std::string &prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector *blockUniformIndexes); - bool defineUniformBlock(InfoLog &infoLog, GLenum shader, const sh::InterfaceBlock &interfaceBlock); + void defineUniformBlockMembers(const std::vector &fields, const std::string &prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector *blockUniformIndexes); + bool defineUniformBlock(InfoLog &infoLog, GLenum shader, const InterfaceBlock &interfaceBlock); bool assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex); void defineOutputVariables(FragmentShader *fragmentShader); void initializeUniformStorage(); @@ -218,7 +217,8 @@ class ProgramBinary : public RefCountObject class VertexExecutable { public: - VertexExecutable(const VertexFormat inputLayout[MAX_VERTEX_ATTRIBS], + VertexExecutable(rx::Renderer *const renderer, + const VertexFormat inputLayout[MAX_VERTEX_ATTRIBS], const GLenum signature[MAX_VERTEX_ATTRIBS], rx::ShaderExecutable *shaderExecutable); ~VertexExecutable(); @@ -235,40 +235,17 @@ class ProgramBinary : public RefCountObject rx::ShaderExecutable *mShaderExecutable; }; - class PixelExecutable - { - public: - PixelExecutable(const std::vector &outputSignature, rx::ShaderExecutable *shaderExecutable); - ~PixelExecutable(); - - // FIXME(geofflang): Work around NVIDIA driver bug by repacking buffers - bool matchesSignature(const std::vector &signature) const { return true; /* mOutputSignature == signature; */ } - - const std::vector &outputSignature() const { return mOutputSignature; } - rx::ShaderExecutable *shaderExecutable() const { return mShaderExecutable; } - - private: - std::vector mOutputSignature; - rx::ShaderExecutable *mShaderExecutable; - }; - rx::Renderer *const mRenderer; DynamicHLSL *mDynamicHLSL; std::string mVertexHLSL; rx::D3DWorkaroundType mVertexWorkarounds; std::vector mVertexExecutables; - - std::string mPixelHLSL; - rx::D3DWorkaroundType mPixelWorkarounds; - bool mUsesFragDepth; - std::vector mPixelShaderKey; - std::vector mPixelExecutables; - rx::ShaderExecutable *mGeometryExecutable; + rx::ShaderExecutable *mPixelExecutable; - sh::Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS]; - sh::Attribute mShaderAttributes[MAX_VERTEX_ATTRIBS]; + Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS]; + Attribute mShaderAttributes[MAX_VERTEX_ATTRIBS]; int mSemanticIndex[MAX_VERTEX_ATTRIBS]; int mAttributesByLayout[MAX_VERTEX_ATTRIBS]; diff --git a/gfx/angle/src/libGLESv2/Query.h b/gfx/angle/src/libGLESv2/Query.h index a4726a8e73ed..4eb236f1041c 100644 --- a/gfx/angle/src/libGLESv2/Query.h +++ b/gfx/angle/src/libGLESv2/Query.h @@ -9,7 +9,8 @@ #ifndef LIBGLESV2_QUERY_H_ #define LIBGLESV2_QUERY_H_ -#include "angle_gl.h" +#include +#include #include "common/angleutils.h" #include "common/RefCountObject.h" diff --git a/gfx/angle/src/libGLESv2/Renderbuffer.cpp b/gfx/angle/src/libGLESv2/Renderbuffer.cpp index eee179f9692f..ea3f40bd00bf 100644 --- a/gfx/angle/src/libGLESv2/Renderbuffer.cpp +++ b/gfx/angle/src/libGLESv2/Renderbuffer.cpp @@ -17,91 +17,518 @@ #include "libGLESv2/renderer/TextureStorage.h" #include "common/utilities.h" #include "libGLESv2/formatutils.h" -#include "libGLESv2/FramebufferAttachment.h" namespace gl { unsigned int RenderbufferStorage::mCurrentSerial = 1; -Renderbuffer::Renderbuffer(GLuint id, RenderbufferStorage *newStorage) - : RefCountObject(id), - mStorage(newStorage) +RenderbufferInterface::RenderbufferInterface() { - ASSERT(mStorage); } -void Renderbuffer::setStorage(RenderbufferStorage *newStorage) +// The default case for classes inherited from RenderbufferInterface is not to +// need to do anything upon the reference count to the parent Renderbuffer incrementing +// or decrementing. +void RenderbufferInterface::addProxyRef(const Renderbuffer *proxy) { - ASSERT(newStorage); - - SafeDelete(mStorage); - mStorage = newStorage; } -RenderbufferStorage *Renderbuffer::getStorage() +void RenderbufferInterface::releaseProxy(const Renderbuffer *proxy) { - ASSERT(mStorage); - return mStorage; +} + +///// RenderbufferTexture2D Implementation //////// + +RenderbufferTexture2D::RenderbufferTexture2D(Texture2D *texture, GLint level) : mLevel(level) +{ + mTexture2D.set(texture); +} + +RenderbufferTexture2D::~RenderbufferTexture2D() +{ + mTexture2D.set(NULL); +} + +// Textures need to maintain their own reference count for references via +// Renderbuffers acting as proxies. Here, we notify the texture of a reference. +void RenderbufferTexture2D::addProxyRef(const Renderbuffer *proxy) +{ + mTexture2D->addProxyRef(proxy); +} + +void RenderbufferTexture2D::releaseProxy(const Renderbuffer *proxy) +{ + mTexture2D->releaseProxy(proxy); +} + +rx::RenderTarget *RenderbufferTexture2D::getRenderTarget() +{ + return mTexture2D->getRenderTarget(mLevel); +} + +rx::RenderTarget *RenderbufferTexture2D::getDepthStencil() +{ + return mTexture2D->getDepthSencil(mLevel); +} + +rx::TextureStorage *RenderbufferTexture2D::getTextureStorage() +{ + return mTexture2D->getNativeTexture()->getStorageInstance(); +} + +GLsizei RenderbufferTexture2D::getWidth() const +{ + return mTexture2D->getWidth(mLevel); +} + +GLsizei RenderbufferTexture2D::getHeight() const +{ + return mTexture2D->getHeight(mLevel); +} + +GLenum RenderbufferTexture2D::getInternalFormat() const +{ + return mTexture2D->getInternalFormat(mLevel); +} + +GLenum RenderbufferTexture2D::getActualFormat() const +{ + return mTexture2D->getActualFormat(mLevel); +} + +GLsizei RenderbufferTexture2D::getSamples() const +{ + return 0; +} + +unsigned int RenderbufferTexture2D::getSerial() const +{ + return mTexture2D->getRenderTargetSerial(mLevel); +} + +bool RenderbufferTexture2D::isTexture() const +{ + return true; +} + +unsigned int RenderbufferTexture2D::getTextureSerial() const +{ + return mTexture2D->getTextureSerial(); +} + +///// RenderbufferTextureCubeMap Implementation //////// + +RenderbufferTextureCubeMap::RenderbufferTextureCubeMap(TextureCubeMap *texture, GLenum faceTarget, GLint level) + : mFaceTarget(faceTarget), mLevel(level) +{ + mTextureCubeMap.set(texture); +} + +RenderbufferTextureCubeMap::~RenderbufferTextureCubeMap() +{ + mTextureCubeMap.set(NULL); +} + +// Textures need to maintain their own reference count for references via +// Renderbuffers acting as proxies. Here, we notify the texture of a reference. +void RenderbufferTextureCubeMap::addProxyRef(const Renderbuffer *proxy) +{ + mTextureCubeMap->addProxyRef(proxy); +} + +void RenderbufferTextureCubeMap::releaseProxy(const Renderbuffer *proxy) +{ + mTextureCubeMap->releaseProxy(proxy); +} + +rx::RenderTarget *RenderbufferTextureCubeMap::getRenderTarget() +{ + return mTextureCubeMap->getRenderTarget(mFaceTarget, mLevel); +} + +rx::RenderTarget *RenderbufferTextureCubeMap::getDepthStencil() +{ + return mTextureCubeMap->getDepthStencil(mFaceTarget, mLevel); +} + +rx::TextureStorage *RenderbufferTextureCubeMap::getTextureStorage() +{ + return mTextureCubeMap->getNativeTexture()->getStorageInstance(); +} + +GLsizei RenderbufferTextureCubeMap::getWidth() const +{ + return mTextureCubeMap->getWidth(mFaceTarget, mLevel); +} + +GLsizei RenderbufferTextureCubeMap::getHeight() const +{ + return mTextureCubeMap->getHeight(mFaceTarget, mLevel); +} + +GLenum RenderbufferTextureCubeMap::getInternalFormat() const +{ + return mTextureCubeMap->getInternalFormat(mFaceTarget, mLevel); +} + +GLenum RenderbufferTextureCubeMap::getActualFormat() const +{ + return mTextureCubeMap->getActualFormat(mFaceTarget, mLevel); +} + +GLsizei RenderbufferTextureCubeMap::getSamples() const +{ + return 0; +} + +unsigned int RenderbufferTextureCubeMap::getSerial() const +{ + return mTextureCubeMap->getRenderTargetSerial(mFaceTarget, mLevel); +} + +bool RenderbufferTextureCubeMap::isTexture() const +{ + return true; +} + +unsigned int RenderbufferTextureCubeMap::getTextureSerial() const +{ + return mTextureCubeMap->getTextureSerial(); +} + +///// RenderbufferTexture3DLayer Implementation //////// + +RenderbufferTexture3DLayer::RenderbufferTexture3DLayer(Texture3D *texture, GLint level, GLint layer) + : mLevel(level), mLayer(layer) +{ + mTexture3D.set(texture); +} + +RenderbufferTexture3DLayer::~RenderbufferTexture3DLayer() +{ + mTexture3D.set(NULL); +} + +// Textures need to maintain their own reference count for references via +// Renderbuffers acting as proxies. Here, we notify the texture of a reference. +void RenderbufferTexture3DLayer::addProxyRef(const Renderbuffer *proxy) +{ + mTexture3D->addProxyRef(proxy); +} + +void RenderbufferTexture3DLayer::releaseProxy(const Renderbuffer *proxy) +{ + mTexture3D->releaseProxy(proxy); +} + +rx::RenderTarget *RenderbufferTexture3DLayer::getRenderTarget() +{ + return mTexture3D->getRenderTarget(mLevel, mLayer); +} + +rx::RenderTarget *RenderbufferTexture3DLayer::getDepthStencil() +{ + return mTexture3D->getDepthStencil(mLevel, mLayer); +} + +rx::TextureStorage *RenderbufferTexture3DLayer::getTextureStorage() +{ + return mTexture3D->getNativeTexture()->getStorageInstance(); +} + +GLsizei RenderbufferTexture3DLayer::getWidth() const +{ + return mTexture3D->getWidth(mLevel); +} + +GLsizei RenderbufferTexture3DLayer::getHeight() const +{ + return mTexture3D->getHeight(mLevel); +} + +GLenum RenderbufferTexture3DLayer::getInternalFormat() const +{ + return mTexture3D->getInternalFormat(mLevel); +} + +GLenum RenderbufferTexture3DLayer::getActualFormat() const +{ + return mTexture3D->getActualFormat(mLevel); +} + +GLsizei RenderbufferTexture3DLayer::getSamples() const +{ + return 0; +} + +unsigned int RenderbufferTexture3DLayer::getSerial() const +{ + return mTexture3D->getRenderTargetSerial(mLevel, mLayer); +} + +bool RenderbufferTexture3DLayer::isTexture() const +{ + return true; +} + +unsigned int RenderbufferTexture3DLayer::getTextureSerial() const +{ + return mTexture3D->getTextureSerial(); +} + +////// RenderbufferTexture2DArrayLayer Implementation ////// + +RenderbufferTexture2DArrayLayer::RenderbufferTexture2DArrayLayer(Texture2DArray *texture, GLint level, GLint layer) + : mLevel(level), mLayer(layer) +{ + mTexture2DArray.set(texture); +} + +RenderbufferTexture2DArrayLayer::~RenderbufferTexture2DArrayLayer() +{ + mTexture2DArray.set(NULL); +} + +void RenderbufferTexture2DArrayLayer::addProxyRef(const Renderbuffer *proxy) +{ + mTexture2DArray->addProxyRef(proxy); +} + +void RenderbufferTexture2DArrayLayer::releaseProxy(const Renderbuffer *proxy) +{ + mTexture2DArray->releaseProxy(proxy); +} + +rx::RenderTarget *RenderbufferTexture2DArrayLayer::getRenderTarget() +{ + return mTexture2DArray->getRenderTarget(mLevel, mLayer); +} + +rx::RenderTarget *RenderbufferTexture2DArrayLayer::getDepthStencil() +{ + return mTexture2DArray->getDepthStencil(mLevel, mLayer); +} + +rx::TextureStorage *RenderbufferTexture2DArrayLayer::getTextureStorage() +{ + return mTexture2DArray->getNativeTexture()->getStorageInstance(); +} + +GLsizei RenderbufferTexture2DArrayLayer::getWidth() const +{ + return mTexture2DArray->getWidth(mLevel); +} + +GLsizei RenderbufferTexture2DArrayLayer::getHeight() const +{ + return mTexture2DArray->getHeight(mLevel); +} + +GLenum RenderbufferTexture2DArrayLayer::getInternalFormat() const +{ + return mTexture2DArray->getInternalFormat(mLevel); +} + +GLenum RenderbufferTexture2DArrayLayer::getActualFormat() const +{ + return mTexture2DArray->getActualFormat(mLevel); +} + +GLsizei RenderbufferTexture2DArrayLayer::getSamples() const +{ + return 0; +} + +unsigned int RenderbufferTexture2DArrayLayer::getSerial() const +{ + return mTexture2DArray->getRenderTargetSerial(mLevel, mLayer); +} + +bool RenderbufferTexture2DArrayLayer::isTexture() const +{ + return true; +} + +unsigned int RenderbufferTexture2DArrayLayer::getTextureSerial() const +{ + return mTexture2DArray->getTextureSerial(); +} + +////// Renderbuffer Implementation ////// + +Renderbuffer::Renderbuffer(rx::Renderer *renderer, GLuint id, RenderbufferInterface *instance) : RefCountObject(id) +{ + ASSERT(instance != NULL); + mInstance = instance; + + ASSERT(renderer != NULL); + mRenderer = renderer; +} + +Renderbuffer::~Renderbuffer() +{ + delete mInstance; +} + +// The RenderbufferInterface contained in this Renderbuffer may need to maintain +// its own reference count, so we pass it on here. +void Renderbuffer::addRef() const +{ + mInstance->addProxyRef(this); + + RefCountObject::addRef(); +} + +void Renderbuffer::release() const +{ + mInstance->releaseProxy(this); + + RefCountObject::release(); +} + +rx::RenderTarget *Renderbuffer::getRenderTarget() +{ + return mInstance->getRenderTarget(); +} + +rx::RenderTarget *Renderbuffer::getDepthStencil() +{ + return mInstance->getDepthStencil(); +} + +rx::TextureStorage *Renderbuffer::getTextureStorage() +{ + return mInstance->getTextureStorage(); } GLsizei Renderbuffer::getWidth() const { - ASSERT(mStorage); - return mStorage->getWidth(); + return mInstance->getWidth(); } GLsizei Renderbuffer::getHeight() const { - ASSERT(mStorage); - return mStorage->getHeight(); + return mInstance->getHeight(); } GLenum Renderbuffer::getInternalFormat() const { - ASSERT(mStorage); - return mStorage->getInternalFormat(); + return mInstance->getInternalFormat(); } GLenum Renderbuffer::getActualFormat() const { - ASSERT(mStorage); - return mStorage->getActualFormat(); -} - -GLsizei Renderbuffer::getSamples() const -{ - ASSERT(mStorage); - return mStorage->getSamples(); + return mInstance->getActualFormat(); } GLuint Renderbuffer::getRedSize() const { - return gl::GetRedBits(getActualFormat()); + if (gl::GetRedBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0) + { + return gl::GetRedBits(getActualFormat(), mRenderer->getCurrentClientVersion()); + } + else + { + return 0; + } } GLuint Renderbuffer::getGreenSize() const { - return gl::GetGreenBits(getActualFormat()); + if (gl::GetGreenBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0) + { + return gl::GetGreenBits(getActualFormat(), mRenderer->getCurrentClientVersion()); + } + else + { + return 0; + } } GLuint Renderbuffer::getBlueSize() const { - return gl::GetBlueBits(getActualFormat()); + if (gl::GetBlueBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0) + { + return gl::GetBlueBits(getActualFormat(), mRenderer->getCurrentClientVersion()); + } + else + { + return 0; + } } GLuint Renderbuffer::getAlphaSize() const { - return gl::GetAlphaBits(getActualFormat()); + if (gl::GetAlphaBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0) + { + return gl::GetAlphaBits(getActualFormat(), mRenderer->getCurrentClientVersion()); + } + else + { + return 0; + } } GLuint Renderbuffer::getDepthSize() const { - return gl::GetDepthBits(getActualFormat()); + if (gl::GetDepthBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0) + { + return gl::GetDepthBits(getActualFormat(), mRenderer->getCurrentClientVersion()); + } + else + { + return 0; + } } GLuint Renderbuffer::getStencilSize() const { - return gl::GetStencilBits(getActualFormat()); + if (gl::GetStencilBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0) + { + return gl::GetStencilBits(getActualFormat(), mRenderer->getCurrentClientVersion()); + } + else + { + return 0; + } +} + +GLenum Renderbuffer::getComponentType() const +{ + return gl::GetComponentType(getActualFormat(), mRenderer->getCurrentClientVersion()); +} + +GLenum Renderbuffer::getColorEncoding() const +{ + return gl::GetColorEncoding(getActualFormat(), mRenderer->getCurrentClientVersion()); +} + +GLsizei Renderbuffer::getSamples() const +{ + return mInstance->getSamples(); +} + +unsigned int Renderbuffer::getSerial() const +{ + return mInstance->getSerial(); +} + +bool Renderbuffer::isTexture() const +{ + return mInstance->isTexture(); +} + +unsigned int Renderbuffer::getTextureSerial() const +{ + return mInstance->getTextureSerial(); +} + +void Renderbuffer::setStorage(RenderbufferStorage *newStorage) +{ + ASSERT(newStorage != NULL); + + delete mInstance; + mInstance = newStorage; } RenderbufferStorage::RenderbufferStorage() : mSerial(issueSerials(1)) diff --git a/gfx/angle/src/libGLESv2/Renderbuffer.h b/gfx/angle/src/libGLESv2/Renderbuffer.h index a85c3e239857..969232b164a9 100644 --- a/gfx/angle/src/libGLESv2/Renderbuffer.h +++ b/gfx/angle/src/libGLESv2/Renderbuffer.h @@ -12,7 +12,8 @@ #ifndef LIBGLESV2_RENDERBUFFER_H_ #define LIBGLESV2_RENDERBUFFER_H_ -#include "angle_gl.h" +#include +#include #include "common/angleutils.h" #include "common/RefCountObject.h" @@ -27,42 +28,178 @@ class TextureStorage; namespace gl { -class RenderbufferStorage; -class FramebufferAttachment; +class Texture2D; +class TextureCubeMap; +class Texture3D; +class Texture2DArray; +class Renderbuffer; +class Colorbuffer; +class DepthStencilbuffer; -// 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 +class RenderbufferInterface { public: - Renderbuffer(GLuint id, RenderbufferStorage *newStorage); + RenderbufferInterface(); - void setStorage(RenderbufferStorage *newStorage); - RenderbufferStorage *getStorage(); + virtual ~RenderbufferInterface() {}; - 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; + virtual void addProxyRef(const Renderbuffer *proxy); + virtual void releaseProxy(const Renderbuffer *proxy); + + virtual rx::RenderTarget *getRenderTarget() = 0; + virtual rx::RenderTarget *getDepthStencil() = 0; + virtual rx::TextureStorage *getTextureStorage() = 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; + + virtual unsigned int getSerial() const = 0; + + virtual bool isTexture() const = 0; + virtual unsigned int getTextureSerial() const = 0; private: - RenderbufferStorage *mStorage; + DISALLOW_COPY_AND_ASSIGN(RenderbufferInterface); +}; + +class RenderbufferTexture2D : public RenderbufferInterface +{ + public: + RenderbufferTexture2D(Texture2D *texture, GLint level); + + virtual ~RenderbufferTexture2D(); + + void addProxyRef(const Renderbuffer *proxy); + void releaseProxy(const Renderbuffer *proxy); + + rx::RenderTarget *getRenderTarget(); + rx::RenderTarget *getDepthStencil(); + rx::TextureStorage *getTextureStorage(); + + virtual GLsizei getWidth() const; + virtual GLsizei getHeight() const; + virtual GLenum getInternalFormat() const; + virtual GLenum getActualFormat() const; + virtual GLsizei getSamples() const; + + virtual unsigned int getSerial() const; + + virtual bool isTexture() const; + virtual unsigned int getTextureSerial() const; + + private: + DISALLOW_COPY_AND_ASSIGN(RenderbufferTexture2D); + + BindingPointer mTexture2D; + const GLint mLevel; +}; + +class RenderbufferTextureCubeMap : public RenderbufferInterface +{ + public: + RenderbufferTextureCubeMap(TextureCubeMap *texture, GLenum faceTarget, GLint level); + + virtual ~RenderbufferTextureCubeMap(); + + void addProxyRef(const Renderbuffer *proxy); + void releaseProxy(const Renderbuffer *proxy); + + rx::RenderTarget *getRenderTarget(); + rx::RenderTarget *getDepthStencil(); + rx::TextureStorage *getTextureStorage(); + + virtual GLsizei getWidth() const; + virtual GLsizei getHeight() const; + virtual GLenum getInternalFormat() const; + virtual GLenum getActualFormat() const; + virtual GLsizei getSamples() const; + + virtual unsigned int getSerial() const; + + virtual bool isTexture() const; + virtual unsigned int getTextureSerial() const; + + private: + DISALLOW_COPY_AND_ASSIGN(RenderbufferTextureCubeMap); + + BindingPointer mTextureCubeMap; + const GLint mLevel; + const GLenum mFaceTarget; +}; + +class RenderbufferTexture3DLayer : public RenderbufferInterface +{ +public: + RenderbufferTexture3DLayer(Texture3D *texture, GLint level, GLint layer); + + virtual ~RenderbufferTexture3DLayer(); + + void addProxyRef(const Renderbuffer *proxy); + void releaseProxy(const Renderbuffer *proxy); + + rx::RenderTarget *getRenderTarget(); + rx::RenderTarget *getDepthStencil(); + rx::TextureStorage *getTextureStorage(); + + virtual GLsizei getWidth() const; + virtual GLsizei getHeight() const; + virtual GLenum getInternalFormat() const; + virtual GLenum getActualFormat() const; + virtual GLsizei getSamples() const; + + virtual unsigned int getSerial() const; + + virtual bool isTexture() const; + virtual unsigned int getTextureSerial() const; + +private: + DISALLOW_COPY_AND_ASSIGN(RenderbufferTexture3DLayer); + + BindingPointer mTexture3D; + const GLint mLevel; + const GLint mLayer; +}; + +class RenderbufferTexture2DArrayLayer : public RenderbufferInterface +{ +public: + RenderbufferTexture2DArrayLayer(Texture2DArray *texture, GLint level, GLint layer); + + virtual ~RenderbufferTexture2DArrayLayer(); + + void addProxyRef(const Renderbuffer *proxy); + void releaseProxy(const Renderbuffer *proxy); + + rx::RenderTarget *getRenderTarget(); + rx::RenderTarget *getDepthStencil(); + rx::TextureStorage *getTextureStorage(); + + virtual GLsizei getWidth() const; + virtual GLsizei getHeight() const; + virtual GLenum getInternalFormat() const; + virtual GLenum getActualFormat() const; + virtual GLsizei getSamples() const; + + virtual unsigned int getSerial() const; + + virtual bool isTexture() const; + virtual unsigned int getTextureSerial() const; + +private: + DISALLOW_COPY_AND_ASSIGN(RenderbufferTexture2DArrayLayer); + + BindingPointer mTexture2DArray; + const GLint mLevel; + const GLint mLayer; }; // A class derived from RenderbufferStorage is created whenever glRenderbufferStorage // is called. The specific concrete type depends on whether the internal format is // colour depth, stencil or packed depth/stencil. -class RenderbufferStorage +class RenderbufferStorage : public RenderbufferInterface { public: RenderbufferStorage(); @@ -101,6 +238,55 @@ class RenderbufferStorage static unsigned int mCurrentSerial; }; +// Renderbuffer implements the GL renderbuffer object. +// It's only a proxy for a RenderbufferInterface instance; the internal object +// can change whenever glRenderbufferStorage is called. +class Renderbuffer : public RefCountObject +{ + public: + Renderbuffer(rx::Renderer *renderer, GLuint id, RenderbufferInterface *storage); + + virtual ~Renderbuffer(); + + // These functions from RefCountObject are overloaded here because + // Textures need to maintain their own count of references to them via + // Renderbuffers/RenderbufferTextures. These functions invoke those + // reference counting functions on the RenderbufferInterface. + void addRef() const; + void release() const; + + rx::RenderTarget *getRenderTarget(); + rx::RenderTarget *getDepthStencil(); + rx::TextureStorage *getTextureStorage(); + + GLsizei getWidth() const; + GLsizei getHeight() const; + GLenum getInternalFormat() const; + GLenum getActualFormat() const; + GLuint getRedSize() const; + GLuint getGreenSize() const; + GLuint getBlueSize() const; + GLuint getAlphaSize() const; + GLuint getDepthSize() const; + GLuint getStencilSize() const; + GLenum getComponentType() const; + GLenum getColorEncoding() const; + GLsizei getSamples() const; + + unsigned int getSerial() const; + + bool isTexture() const; + unsigned int getTextureSerial() const; + + void setStorage(RenderbufferStorage *newStorage); + + private: + DISALLOW_COPY_AND_ASSIGN(Renderbuffer); + + rx::Renderer const *mRenderer; + RenderbufferInterface *mInstance; +}; + class Colorbuffer : public RenderbufferStorage { public: @@ -155,7 +341,6 @@ class Stencilbuffer : public DepthStencilbuffer private: DISALLOW_COPY_AND_ASSIGN(Stencilbuffer); }; - } #endif // LIBGLESV2_RENDERBUFFER_H_ diff --git a/gfx/angle/src/libGLESv2/RenderbufferProxySet.cpp b/gfx/angle/src/libGLESv2/RenderbufferProxySet.cpp new file mode 100644 index 000000000000..009c7a6b7348 --- /dev/null +++ b/gfx/angle/src/libGLESv2/RenderbufferProxySet.cpp @@ -0,0 +1,87 @@ +#include "precompiled.h" +// +// 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. +// + +// RenderbufferProxySet.cpp: Implements the gl::RenderbufferProxySet, a class for +// maintaining a Texture's weak references to the Renderbuffers that represent it. + +#include "libGLESv2/RenderbufferProxySet.h" +#include "common/debug.h" + +namespace gl +{ + +void RenderbufferProxySet::addRef(const Renderbuffer *proxy) +{ + RefCountMap::iterator i = mRefCountMap.find(proxy); + if (i != mRefCountMap.end()) + { + i->second++; + } +} + +void RenderbufferProxySet::release(const Renderbuffer *proxy) +{ + RefCountMap::iterator i = mRefCountMap.find(proxy); + if (i != mRefCountMap.end()) + { + if (i->second > 0) + { + i->second--; + } + + if (i->second == 0) + { + // Clear the buffer map of references to this Renderbuffer + BufferMap::iterator j = mBufferMap.begin(); + while (j != mBufferMap.end()) + { + if (j->second == proxy) + { + j = mBufferMap.erase(j); + } + else + { + ++j; + } + } + + mRefCountMap.erase(i); + } + } +} + +void RenderbufferProxySet::add(unsigned int mipLevel, unsigned int layer, Renderbuffer *renderBuffer) +{ + if (mRefCountMap.find(renderBuffer) == mRefCountMap.end()) + { + mRefCountMap.insert(std::make_pair(renderBuffer, 0)); + } + + RenderbufferKey key; + key.mipLevel = mipLevel; + key.layer = layer; + if (mBufferMap.find(key) == mBufferMap.end()) + { + mBufferMap.insert(std::make_pair(key, renderBuffer)); + } +} + +Renderbuffer *RenderbufferProxySet::get(unsigned int mipLevel, unsigned int layer) const +{ + RenderbufferKey key; + key.mipLevel = mipLevel; + key.layer = layer; + BufferMap::const_iterator i = mBufferMap.find(key); + return (i != mBufferMap.end()) ? i->second : NULL; +} + +bool RenderbufferProxySet::RenderbufferKey::operator<(const RenderbufferKey &other) const +{ + return (mipLevel != other.mipLevel) ? mipLevel < other.mipLevel : layer < other.layer; +} + +} diff --git a/gfx/angle/src/libGLESv2/RenderbufferProxySet.h b/gfx/angle/src/libGLESv2/RenderbufferProxySet.h new file mode 100644 index 000000000000..ae5bf944f07e --- /dev/null +++ b/gfx/angle/src/libGLESv2/RenderbufferProxySet.h @@ -0,0 +1,46 @@ +// +// 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. +// + +// RenderbufferProxySet.h: Defines the gl::RenderbufferProxySet, a class for +// maintaining a Texture's weak references to the Renderbuffers that represent it. + +#ifndef LIBGLESV2_RENDERBUFFERPROXYSET_H_ +#define LIBGLESV2_RENDERBUFFERPROXYSET_H_ + +#include + +namespace gl +{ +class Renderbuffer; + +class RenderbufferProxySet +{ + public: + void addRef(const Renderbuffer *proxy); + void release(const Renderbuffer *proxy); + + void add(unsigned int mipLevel, unsigned int layer, Renderbuffer *renderBuffer); + Renderbuffer *get(unsigned int mipLevel, unsigned int layer) const; + + private: + struct RenderbufferKey + { + unsigned int mipLevel; + unsigned int layer; + + bool operator<(const RenderbufferKey &other) const; + }; + + typedef std::map BufferMap; + BufferMap mBufferMap; + + typedef std::map RefCountMap; + RefCountMap mRefCountMap; +}; + +} + +#endif // LIBGLESV2_RENDERBUFFERPROXYSET_H_ diff --git a/gfx/angle/src/libGLESv2/ResourceManager.cpp b/gfx/angle/src/libGLESv2/ResourceManager.cpp index 660ba6b44925..97c28cb99134 100644 --- a/gfx/angle/src/libGLESv2/ResourceManager.cpp +++ b/gfx/angle/src/libGLESv2/ResourceManager.cpp @@ -17,7 +17,6 @@ #include "libGLESv2/Texture.h" #include "libGLESv2/Sampler.h" #include "libGLESv2/Fence.h" -#include "libGLESv2/renderer/Renderer.h" namespace gl { @@ -363,7 +362,7 @@ void ResourceManager::checkBufferAllocation(unsigned int buffer) { if (buffer != 0 && !getBuffer(buffer)) { - Buffer *bufferObject = new Buffer(mRenderer->createBuffer(), buffer); + Buffer *bufferObject = new Buffer(mRenderer, buffer); mBufferMap[buffer] = bufferObject; bufferObject->addRef(); } @@ -406,7 +405,7 @@ void ResourceManager::checkRenderbufferAllocation(GLuint renderbuffer) { if (renderbuffer != 0 && !getRenderbuffer(renderbuffer)) { - Renderbuffer *renderbufferObject = new Renderbuffer(renderbuffer, new Colorbuffer(mRenderer, 0, 0, GL_RGBA4, 0)); + Renderbuffer *renderbufferObject = new Renderbuffer(mRenderer, renderbuffer, new Colorbuffer(mRenderer, 0, 0, GL_RGBA4, 0)); mRenderbufferMap[renderbuffer] = renderbufferObject; renderbufferObject->addRef(); } diff --git a/gfx/angle/src/libGLESv2/ResourceManager.h b/gfx/angle/src/libGLESv2/ResourceManager.h index d646c0d3cf4c..85e6b4bc22bf 100644 --- a/gfx/angle/src/libGLESv2/ResourceManager.h +++ b/gfx/angle/src/libGLESv2/ResourceManager.h @@ -10,7 +10,8 @@ #ifndef LIBGLESV2_RESOURCEMANAGER_H_ #define LIBGLESV2_RESOURCEMANAGER_H_ -#include "angle_gl.h" +#include +#include #include diff --git a/gfx/angle/src/libGLESv2/Shader.cpp b/gfx/angle/src/libGLESv2/Shader.cpp index 5b0f3ff7dde4..7d0d781093e4 100644 --- a/gfx/angle/src/libGLESv2/Shader.cpp +++ b/gfx/angle/src/libGLESv2/Shader.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -115,12 +115,12 @@ void Shader::getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer) getSourceImpl(mHlsl, bufSize, length, buffer); } -const std::vector &Shader::getUniforms() const +const std::vector &Shader::getUniforms() const { return mActiveUniforms; } -const std::vector &Shader::getInterfaceBlocks() const +const std::vector &Shader::getInterfaceBlocks() const { return mActiveInterfaceBlocks; } @@ -184,8 +184,6 @@ void Shader::initializeCompiler() ShBuiltInResources resources; ShInitBuiltInResources(&resources); - const gl::Caps &caps = mRenderer->getCaps(); - resources.MaxVertexAttribs = MAX_VERTEX_ATTRIBS; resources.MaxVertexUniformVectors = mRenderer->getMaxVertexUniformVectors(); resources.MaxVaryingVectors = mRenderer->getMaxVaryingVectors(); @@ -194,8 +192,8 @@ void Shader::initializeCompiler() resources.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS; resources.MaxFragmentUniformVectors = mRenderer->getMaxFragmentUniformVectors(); resources.MaxDrawBuffers = mRenderer->getMaxRenderTargets(); - resources.OES_standard_derivatives = caps.extensions.standardDerivatives; - resources.EXT_draw_buffers = caps.extensions.drawBuffers; + resources.OES_standard_derivatives = mRenderer->getDerivativeInstructionSupport(); + resources.EXT_draw_buffers = mRenderer->getMaxRenderTargets() > 1; 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 @@ -227,7 +225,7 @@ void Shader::parseVaryings(void *compiler) { if (!mHlsl.empty()) { - std::vector *activeVaryings; + std::vector *activeVaryings; ShGetInfoPointer(compiler, SH_ACTIVE_VARYINGS_ARRAY, reinterpret_cast(&activeVaryings)); for (size_t varyingIndex = 0; varyingIndex < activeVaryings->size(); varyingIndex++) @@ -363,11 +361,11 @@ void Shader::compileToHLSL(void *compiler) void *activeUniforms; ShGetInfoPointer(compiler, SH_ACTIVE_UNIFORMS_ARRAY, &activeUniforms); - mActiveUniforms = *(std::vector*)activeUniforms; + mActiveUniforms = *(std::vector*)activeUniforms; void *activeInterfaceBlocks; ShGetInfoPointer(compiler, SH_ACTIVE_INTERFACE_BLOCKS_ARRAY, &activeInterfaceBlocks); - mActiveInterfaceBlocks = *(std::vector*)activeInterfaceBlocks; + mActiveInterfaceBlocks = *(std::vector*)activeInterfaceBlocks; } else { @@ -517,14 +515,14 @@ int VertexShader::getSemanticIndex(const std::string &attributeName) int semanticIndex = 0; for (unsigned int attributeIndex = 0; attributeIndex < mActiveAttributes.size(); attributeIndex++) { - const sh::ShaderVariable &attribute = mActiveAttributes[attributeIndex]; + const ShaderVariable &attribute = mActiveAttributes[attributeIndex]; if (attribute.name == attributeName) { return semanticIndex; } - semanticIndex += VariableRegisterCount(attribute.type); + semanticIndex += AttributeRegisterCount(attribute.type); } } @@ -538,7 +536,7 @@ void VertexShader::parseAttributes() { void *activeAttributes; ShGetInfoPointer(mVertexCompiler, SH_ACTIVE_ATTRIBUTES_ARRAY, &activeAttributes); - mActiveAttributes = *(std::vector*)activeAttributes; + mActiveAttributes = *(std::vector*)activeAttributes; } } @@ -569,7 +567,7 @@ void FragmentShader::compile() { void *activeOutputVariables; ShGetInfoPointer(mFragmentCompiler, SH_ACTIVE_OUTPUT_VARIABLES_ARRAY, &activeOutputVariables); - mActiveOutputVariables = *(std::vector*)activeOutputVariables; + mActiveOutputVariables = *(std::vector*)activeOutputVariables; } } @@ -580,7 +578,7 @@ void FragmentShader::uncompile() mActiveOutputVariables.clear(); } -const std::vector &FragmentShader::getOutputVariables() const +const std::vector &FragmentShader::getOutputVariables() const { return mActiveOutputVariables; } diff --git a/gfx/angle/src/libGLESv2/Shader.h b/gfx/angle/src/libGLESv2/Shader.h index 6b41bb7be393..a41894994063 100644 --- a/gfx/angle/src/libGLESv2/Shader.h +++ b/gfx/angle/src/libGLESv2/Shader.h @@ -12,7 +12,8 @@ #ifndef LIBGLESV2_SHADER_H_ #define LIBGLESV2_SHADER_H_ -#include "angle_gl.h" +#include +#include #include #include #include @@ -31,12 +32,12 @@ namespace gl { class ResourceManager; -struct PackedVarying : public sh::Varying +struct PackedVarying : public Varying { unsigned int registerIndex; // Assigned during link - PackedVarying(const sh::Varying &varying) - : sh::Varying(varying), + PackedVarying(const Varying &varying) + : Varying(varying), registerIndex(GL_INVALID_INDEX) {} @@ -68,8 +69,8 @@ class Shader void getSource(GLsizei bufSize, GLsizei *length, char *buffer) const; int getTranslatedSourceLength() const; void getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer) const; - const std::vector &getUniforms() const; - const std::vector &getInterfaceBlocks() const; + const std::vector &getUniforms() const; + const std::vector &getInterfaceBlocks() const; std::vector &getVaryings(); virtual void compile() = 0; @@ -133,8 +134,8 @@ class Shader std::string mSource; std::string mHlsl; std::string mInfoLog; - std::vector mActiveUniforms; - std::vector mActiveInterfaceBlocks; + std::vector mActiveUniforms; + std::vector mActiveInterfaceBlocks; ResourceManager *mResourceManager; }; @@ -153,14 +154,14 @@ class VertexShader : public Shader virtual void uncompile(); int getSemanticIndex(const std::string &attributeName); - const std::vector &activeAttributes() const { return mActiveAttributes; } + const std::vector &activeAttributes() const { return mActiveAttributes; } private: DISALLOW_COPY_AND_ASSIGN(VertexShader); void parseAttributes(); - std::vector mActiveAttributes; + std::vector mActiveAttributes; }; class FragmentShader : public Shader @@ -173,12 +174,12 @@ class FragmentShader : public Shader virtual GLenum getType(); virtual void compile(); virtual void uncompile(); - const std::vector &getOutputVariables() const; + const std::vector &getOutputVariables() const; private: DISALLOW_COPY_AND_ASSIGN(FragmentShader); - std::vector mActiveOutputVariables; + std::vector mActiveOutputVariables; }; } diff --git a/gfx/angle/src/libGLESv2/Texture.cpp b/gfx/angle/src/libGLESv2/Texture.cpp index bac52171ab1f..68d368b67184 100644 --- a/gfx/angle/src/libGLESv2/Texture.cpp +++ b/gfx/angle/src/libGLESv2/Texture.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -21,7 +21,7 @@ #include "libGLESv2/renderer/TextureStorage.h" #include "libEGL/Surface.h" #include "libGLESv2/Buffer.h" -#include "libGLESv2/renderer/BufferImpl.h" +#include "libGLESv2/renderer/BufferStorage.h" #include "libGLESv2/renderer/RenderTarget.h" namespace gl @@ -87,6 +87,16 @@ GLenum Texture::getTarget() const return mTarget; } +void Texture::addProxyRef(const Renderbuffer *proxy) +{ + mRenderbufferProxies.addRef(proxy); +} + +void Texture::releaseProxy(const Renderbuffer *proxy) +{ + mRenderbufferProxies.release(proxy); +} + void Texture::setMinFilter(GLenum filter) { mSamplerState.minFilter = filter; @@ -309,9 +319,7 @@ void Texture::setImage(const PixelUnpackState &unpack, GLenum type, const void * // Do a CPU readback here, if we have an unpack buffer bound and the fast GPU path is not supported Buffer *pixelBuffer = unpack.pixelBuffer.get(); ptrdiff_t offset = reinterpret_cast(pixels); - // TODO: setImage/subImage 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. - const void *bufferData = pixelBuffer->getImplementation()->getData(); + const void *bufferData = pixelBuffer->getStorage()->getData(); pixelData = static_cast(bufferData) + offset; } @@ -363,9 +371,7 @@ bool Texture::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt { Buffer *pixelBuffer = unpack.pixelBuffer.get(); unsigned int offset = reinterpret_cast(pixels); - // TODO: setImage/subImage 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. - const void *bufferData = pixelBuffer->getImplementation()->getData(); + const void *bufferData = pixelBuffer->getStorage()->getData(); pixelData = static_cast(bufferData) + offset; } @@ -432,7 +438,7 @@ int Texture::immutableLevelCount() GLint Texture::creationLevels(GLsizei width, GLsizei height, GLsizei depth) const { - if ((isPow2(width) && isPow2(height) && isPow2(depth)) || mRenderer->getCaps().extensions.textureNPOT) + if ((isPow2(width) && isPow2(height) && isPow2(depth)) || mRenderer->getNonPower2TextureSupport()) { // Maximum number of levels return log2(std::max(std::max(width, height), depth)) + 1; @@ -543,8 +549,9 @@ void Texture2D::redefineImage(GLint level, GLenum internalformat, GLsizei width, void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) { - GLenum sizedInternalFormat = IsSizedInternalFormat(internalFormat) ? internalFormat - : GetSizedInternalFormat(format, type); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + GLenum sizedInternalFormat = IsSizedInternalFormat(internalFormat, clientVersion) ? internalFormat + : GetSizedInternalFormat(format, type, clientVersion); redefineImage(level, sizedInternalFormat, width, height); bool fastUnpacked = false; @@ -661,8 +668,9 @@ void Texture2D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GL void Texture2D::copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) { - GLenum sizedInternalFormat = IsSizedInternalFormat(format) ? format - : GetSizedInternalFormat(format, GL_UNSIGNED_BYTE); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + GLenum sizedInternalFormat = IsSizedInternalFormat(format, clientVersion) ? format + : GetSizedInternalFormat(format, GL_UNSIGNED_BYTE, clientVersion); redefineImage(level, sizedInternalFormat, width, height); if (!mImageArray[level]->isRenderableFormat()) @@ -690,6 +698,11 @@ void Texture2D::copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) { + if (xoffset + width > mImageArray[level]->getWidth() || yoffset + height > mImageArray[level]->getHeight() || zoffset != 0) + { + return gl::error(GL_INVALID_VALUE); + } + // 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) bool canCreateRenderTarget = isLevelComplete(level) && isLevelComplete(0); @@ -707,6 +720,8 @@ void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yo { updateStorageLevel(level); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + gl::Rectangle sourceRect; sourceRect.x = x; sourceRect.width = width; @@ -714,7 +729,7 @@ void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yo sourceRect.height = height; mRenderer->copyImage(source, sourceRect, - gl::GetFormat(getBaseLevelInternalFormat()), + gl::GetFormat(getBaseLevelInternalFormat(), clientVersion), xoffset, yoffset, mTexStorage, level); } } @@ -766,7 +781,7 @@ bool Texture2D::isSamplerComplete(const SamplerState &samplerState) const return false; } - if (!mRenderer->getCaps().textureCaps.get(getInternalFormat(0)).filtering) + if (!IsTextureFilteringSupported(getInternalFormat(0), mRenderer)) { if (samplerState.magFilter != GL_NEAREST || (samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST)) @@ -775,7 +790,7 @@ bool Texture2D::isSamplerComplete(const SamplerState &samplerState) const } } - bool npotSupport = mRenderer->getCaps().extensions.textureNPOT; + bool npotSupport = mRenderer->getNonPower2TextureSupport(); if (!npotSupport) { @@ -807,7 +822,8 @@ bool Texture2D::isSamplerComplete(const SamplerState &samplerState) const // 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. - if (gl::GetDepthBits(getInternalFormat(0)) > 0 && mRenderer->getCurrentClientVersion() > 2) + if (gl::GetDepthBits(getInternalFormat(0), mRenderer->getCurrentClientVersion()) > 0 && + mRenderer->getCurrentClientVersion() > 2) { if (mSamplerState.compareMode == GL_NONE) { @@ -884,12 +900,12 @@ bool Texture2D::isLevelComplete(int level) const bool Texture2D::isCompressed(GLint level) const { - return IsFormatCompressed(getInternalFormat(level)); + return IsFormatCompressed(getInternalFormat(level), mRenderer->getCurrentClientVersion()); } bool Texture2D::isDepth(GLint level) const { - return GetDepthBits(getInternalFormat(level)) > 0; + return GetDepthBits(getInternalFormat(level), mRenderer->getCurrentClientVersion()) > 0; } // Constructs a native texture resource from the texture images @@ -1016,6 +1032,18 @@ rx::TextureStorageInterface *Texture2D::getBaseLevelStorage() return mTexStorage; } +Renderbuffer *Texture2D::getRenderbuffer(GLint level) +{ + Renderbuffer *renderBuffer = mRenderbufferProxies.get(level, 0); + if (!renderBuffer) + { + renderBuffer = new Renderbuffer(mRenderer, id(), new RenderbufferTexture2D(this, level)); + mRenderbufferProxies.add(level, 0, renderBuffer); + } + + return renderBuffer; +} + unsigned int Texture2D::getRenderTargetSerial(GLint level) { return (ensureRenderTarget() ? mTexStorage->getRenderTargetSerial(level) : 0); @@ -1196,7 +1224,7 @@ bool TextureCubeMap::isSamplerComplete(const SamplerState &samplerState) const bool mipmapping = IsMipmapFiltered(samplerState); - if (!mRenderer->getCaps().textureCaps.get(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0)).filtering) + if (!IsTextureFilteringSupported(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0), mRenderer)) { if (samplerState.magFilter != GL_NEAREST || (samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST)) @@ -1205,7 +1233,7 @@ bool TextureCubeMap::isSamplerComplete(const SamplerState &samplerState) const } } - if (!isPow2(size) && !mRenderer->getCaps().extensions.textureNPOT) + if (!isPow2(size) && !mRenderer->getNonPower2TextureSupport()) { if (samplerState.wrapS != GL_CLAMP_TO_EDGE || samplerState.wrapT != GL_CLAMP_TO_EDGE || mipmapping) { @@ -1328,12 +1356,12 @@ bool TextureCubeMap::isFaceLevelComplete(int faceIndex, int level) const bool TextureCubeMap::isCompressed(GLenum target, GLint level) const { - return IsFormatCompressed(getInternalFormat(target, level)); + return IsFormatCompressed(getInternalFormat(target, level), mRenderer->getCurrentClientVersion()); } bool TextureCubeMap::isDepth(GLenum target, GLint level) const { - return GetDepthBits(getInternalFormat(target, level)) > 0; + return GetDepthBits(getInternalFormat(target, level), mRenderer->getCurrentClientVersion()) > 0; } void TextureCubeMap::initializeStorage(bool renderTarget) @@ -1443,8 +1471,9 @@ bool TextureCubeMap::ensureRenderTarget() void TextureCubeMap::setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) { - GLenum sizedInternalFormat = IsSizedInternalFormat(internalFormat) ? internalFormat - : GetSizedInternalFormat(format, type); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + GLenum sizedInternalFormat = IsSizedInternalFormat(internalFormat, clientVersion) ? internalFormat + : GetSizedInternalFormat(format, type, clientVersion); redefineImage(faceIndex, level, sizedInternalFormat, width, height); @@ -1499,8 +1528,9 @@ void TextureCubeMap::redefineImage(int faceIndex, GLint level, GLenum internalfo void TextureCubeMap::copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) { int faceIndex = targetToIndex(target); - GLenum sizedInternalFormat = IsSizedInternalFormat(format) ? format - : GetSizedInternalFormat(format, GL_UNSIGNED_BYTE); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + GLenum sizedInternalFormat = IsSizedInternalFormat(format, clientVersion) ? format + : GetSizedInternalFormat(format, GL_UNSIGNED_BYTE, clientVersion); redefineImage(faceIndex, level, sizedInternalFormat, width, height); if (!mImageArray[faceIndex][level]->isRenderableFormat()) @@ -1532,6 +1562,13 @@ void TextureCubeMap::copySubImage(GLenum target, GLint level, GLint xoffset, GLi { int faceIndex = targetToIndex(target); + GLsizei size = mImageArray[faceIndex][level]->getWidth(); + + if (xoffset + width > size || yoffset + height > size || zoffset != 0) + { + return gl::error(GL_INVALID_VALUE); + } + // We can only make our texture storage to a render target if the level we're copying *to* is complete // and the base level is cube-complete. The base level must be cube complete (common case) because we cannot // rely on the "getBaseLevel*" methods reliably otherwise. @@ -1550,13 +1587,15 @@ void TextureCubeMap::copySubImage(GLenum target, GLint level, GLint xoffset, GLi { updateStorageFaceLevel(faceIndex, level); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + gl::Rectangle sourceRect; sourceRect.x = x; sourceRect.width = width; sourceRect.y = y; sourceRect.height = height; - mRenderer->copyImage(source, sourceRect, gl::GetFormat(getBaseLevelInternalFormat()), + mRenderer->copyImage(source, sourceRect, gl::GetFormat(getBaseLevelInternalFormat(), clientVersion), xoffset, yoffset, mTexStorage, target, level); } } @@ -1635,6 +1674,25 @@ rx::TextureStorageInterface *TextureCubeMap::getBaseLevelStorage() return mTexStorage; } +Renderbuffer *TextureCubeMap::getRenderbuffer(GLenum target, GLint level) +{ + if (!IsCubemapTextureTarget(target)) + { + return gl::error(GL_INVALID_OPERATION, (Renderbuffer *)NULL); + } + + int faceIndex = targetToIndex(target); + + Renderbuffer *renderBuffer = mRenderbufferProxies.get(level, faceIndex); + if (!renderBuffer) + { + renderBuffer = new Renderbuffer(mRenderer, id(), new RenderbufferTextureCubeMap(this, target, level)); + mRenderbufferProxies.add(level, faceIndex, renderBuffer); + } + + return renderBuffer; +} + unsigned int TextureCubeMap::getRenderTargetSerial(GLenum target, GLint level) { return (ensureRenderTarget() ? mTexStorage->getRenderTargetSerial(target, level) : 0); @@ -1735,18 +1793,19 @@ GLenum Texture3D::getActualFormat(GLint level) const bool Texture3D::isCompressed(GLint level) const { - return IsFormatCompressed(getInternalFormat(level)); + return IsFormatCompressed(getInternalFormat(level), mRenderer->getCurrentClientVersion()); } bool Texture3D::isDepth(GLint level) const { - return GetDepthBits(getInternalFormat(level)) > 0; + return GetDepthBits(getInternalFormat(level), mRenderer->getCurrentClientVersion()) > 0; } void Texture3D::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) { - GLenum sizedInternalFormat = IsSizedInternalFormat(internalFormat) ? internalFormat - : GetSizedInternalFormat(format, type); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + GLenum sizedInternalFormat = IsSizedInternalFormat(internalFormat, clientVersion) ? internalFormat + : GetSizedInternalFormat(format, type, clientVersion); redefineImage(level, sizedInternalFormat, width, height, depth); bool fastUnpacked = false; @@ -1876,6 +1935,11 @@ rx::TextureStorageInterface *Texture3D::getBaseLevelStorage() void Texture3D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) { + if (xoffset + width > mImageArray[level]->getWidth() || yoffset + height > mImageArray[level]->getHeight() || zoffset >= mImageArray[level]->getDepth()) + { + return gl::error(GL_INVALID_VALUE); + } + // 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) bool canCreateRenderTarget = isLevelComplete(level) && isLevelComplete(0); @@ -1899,8 +1963,10 @@ void Texture3D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yo sourceRect.y = y; sourceRect.height = height; + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + mRenderer->copyImage(source, sourceRect, - gl::GetFormat(getBaseLevelInternalFormat()), + gl::GetFormat(getBaseLevelInternalFormat(), clientVersion), xoffset, yoffset, zoffset, mTexStorage, level); } } @@ -1917,7 +1983,7 @@ bool Texture3D::isSamplerComplete(const SamplerState &samplerState) const return false; } - if (!mRenderer->getCaps().textureCaps.get(getInternalFormat(0)).filtering) + if (!IsTextureFilteringSupported(getInternalFormat(0), mRenderer)) { if (samplerState.magFilter != GL_NEAREST || (samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST)) @@ -1997,6 +2063,18 @@ bool Texture3D::isLevelComplete(int level) const return true; } +Renderbuffer *Texture3D::getRenderbuffer(GLint level, GLint layer) +{ + Renderbuffer *renderBuffer = mRenderbufferProxies.get(level, layer); + if (!renderBuffer) + { + renderBuffer = new Renderbuffer(mRenderer, id(), new RenderbufferTexture3DLayer(this, level, layer)); + mRenderbufferProxies.add(level, 0, renderBuffer); + } + + return renderBuffer; +} + unsigned int Texture3D::getRenderTargetSerial(GLint level, GLint layer) { return (ensureRenderTarget() ? mTexStorage->getRenderTargetSerial(level, layer) : 0); @@ -2263,21 +2341,22 @@ GLenum Texture2DArray::getActualFormat(GLint level) const bool Texture2DArray::isCompressed(GLint level) const { - return IsFormatCompressed(getInternalFormat(level)); + return IsFormatCompressed(getInternalFormat(level), mRenderer->getCurrentClientVersion()); } bool Texture2DArray::isDepth(GLint level) const { - return GetDepthBits(getInternalFormat(level)) > 0; + return GetDepthBits(getInternalFormat(level), mRenderer->getCurrentClientVersion()) > 0; } void Texture2DArray::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) { - GLenum sizedInternalFormat = IsSizedInternalFormat(internalFormat) ? internalFormat - : GetSizedInternalFormat(format, type); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + GLenum sizedInternalFormat = IsSizedInternalFormat(internalFormat, clientVersion) ? internalFormat + : GetSizedInternalFormat(format, type, clientVersion); redefineImage(level, sizedInternalFormat, width, height, depth); - GLsizei inputDepthPitch = gl::GetDepthPitch(sizedInternalFormat, type, width, height, unpack.alignment); + GLsizei inputDepthPitch = gl::GetDepthPitch(sizedInternalFormat, type, clientVersion, width, height, unpack.alignment); for (int i = 0; i < depth; i++) { @@ -2291,7 +2370,8 @@ void Texture2DArray::setCompressedImage(GLint level, GLenum format, GLsizei widt // compressed formats don't have separate sized internal formats-- we can just use the compressed format directly redefineImage(level, format, width, height, depth); - GLsizei inputDepthPitch = gl::GetDepthPitch(format, GL_UNSIGNED_BYTE, width, height, 1); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + GLsizei inputDepthPitch = gl::GetDepthPitch(format, GL_UNSIGNED_BYTE, clientVersion, width, height, 1); for (int i = 0; i < depth; i++) { @@ -2303,7 +2383,8 @@ void Texture2DArray::setCompressedImage(GLint level, GLenum format, GLsizei widt void 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) { GLenum internalformat = getInternalFormat(level); - GLsizei inputDepthPitch = gl::GetDepthPitch(internalformat, type, width, height, unpack.alignment); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + GLsizei inputDepthPitch = gl::GetDepthPitch(internalformat, type, clientVersion, width, height, unpack.alignment); for (int i = 0; i < depth; i++) { @@ -2319,7 +2400,8 @@ void Texture2DArray::subImage(GLint level, GLint xoffset, GLint yoffset, GLint z void Texture2DArray::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels) { - GLsizei inputDepthPitch = gl::GetDepthPitch(format, GL_UNSIGNED_BYTE, width, height, 1); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + GLsizei inputDepthPitch = gl::GetDepthPitch(format, GL_UNSIGNED_BYTE, clientVersion, width, height, 1); for (int i = 0; i < depth; i++) { @@ -2412,6 +2494,11 @@ rx::TextureStorageInterface *Texture2DArray::getBaseLevelStorage() void Texture2DArray::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) { + if (xoffset + width > getWidth(level) || yoffset + height > getHeight(level) || zoffset >= getLayers(level) || getLayers(level) == 0) + { + return gl::error(GL_INVALID_VALUE); + } + // 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) bool canCreateRenderTarget = isLevelComplete(level) && isLevelComplete(0); @@ -2429,13 +2516,15 @@ void Texture2DArray::copySubImage(GLenum target, GLint level, GLint xoffset, GLi { updateStorageLevel(level); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + gl::Rectangle sourceRect; sourceRect.x = x; sourceRect.width = width; sourceRect.y = y; sourceRect.height = height; - mRenderer->copyImage(source, sourceRect, gl::GetFormat(getInternalFormat(0)), + mRenderer->copyImage(source, sourceRect, gl::GetFormat(getInternalFormat(0), clientVersion), xoffset, yoffset, zoffset, mTexStorage, level); } } @@ -2452,7 +2541,7 @@ bool Texture2DArray::isSamplerComplete(const SamplerState &samplerState) const return false; } - if (!mRenderer->getCaps().textureCaps.get(getBaseLevelInternalFormat()).filtering) + if (!IsTextureFilteringSupported(getBaseLevelInternalFormat(), mRenderer)) { if (samplerState.magFilter != GL_NEAREST || (samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST)) @@ -2530,6 +2619,18 @@ bool Texture2DArray::isLevelComplete(int level) const return true; } +Renderbuffer *Texture2DArray::getRenderbuffer(GLint level, GLint layer) +{ + Renderbuffer *renderBuffer = mRenderbufferProxies.get(level, layer); + if (!renderBuffer) + { + renderBuffer = new Renderbuffer(mRenderer, id(), new RenderbufferTexture2DArrayLayer(this, level, layer)); + mRenderbufferProxies.add(level, 0, renderBuffer); + } + + return renderBuffer; +} + unsigned int Texture2DArray::getRenderTargetSerial(GLint level, GLint layer) { return (ensureRenderTarget() ? mTexStorage->getRenderTargetSerial(level, layer) : 0); diff --git a/gfx/angle/src/libGLESv2/Texture.h b/gfx/angle/src/libGLESv2/Texture.h index 8efa7b250cac..a44a70193200 100644 --- a/gfx/angle/src/libGLESv2/Texture.h +++ b/gfx/angle/src/libGLESv2/Texture.h @@ -13,11 +13,13 @@ #include -#include "angle_gl.h" +#include +#include #include "common/debug.h" #include "common/RefCountObject.h" #include "libGLESv2/angletypes.h" +#include "libGLESv2/RenderbufferProxySet.h" namespace egl { @@ -39,7 +41,7 @@ class Image; namespace gl { class Framebuffer; -class FramebufferAttachment; +class Renderbuffer; enum { @@ -63,6 +65,9 @@ class Texture : public RefCountObject virtual ~Texture(); + void addProxyRef(const Renderbuffer *proxy); + void releaseProxy(const Renderbuffer *proxy); + GLenum getTarget() const; void setMinFilter(GLenum filter); @@ -152,6 +157,13 @@ class Texture : public RefCountObject GLenum mTarget; + // A specific internal reference count is kept for colorbuffer proxy references, + // because, as the renderbuffer acting as proxy will maintain a binding pointer + // back to this texture, there would be a circular reference if we used a binding + // pointer here. This reference count will cause the pointer to be set to NULL if + // the count drops to zero, but will not cause deletion of the Renderbuffer. + RenderbufferProxySet mRenderbufferProxies; + private: DISALLOW_COPY_AND_ASSIGN(Texture); @@ -187,10 +199,11 @@ class Texture2D : public Texture virtual void generateMipmaps(); + Renderbuffer *getRenderbuffer(GLint level); unsigned int getRenderTargetSerial(GLint level); protected: - friend class Texture2DAttachment; + friend class RenderbufferTexture2D; rx::RenderTarget *getRenderTarget(GLint level); rx::RenderTarget *getDepthSencil(GLint level); @@ -254,12 +267,13 @@ class TextureCubeMap : public Texture virtual void generateMipmaps(); + Renderbuffer *getRenderbuffer(GLenum target, GLint level); unsigned int getRenderTargetSerial(GLenum target, GLint level); static int targetToIndex(GLenum target); protected: - friend class TextureCubeMapAttachment; + friend class RenderbufferTextureCubeMap; rx::RenderTarget *getRenderTarget(GLenum target, GLint level); rx::RenderTarget *getDepthStencil(GLenum target, GLint level); @@ -316,10 +330,11 @@ class Texture3D : public Texture virtual bool isSamplerComplete(const SamplerState &samplerState) const; virtual bool isMipmapComplete() const; + Renderbuffer *getRenderbuffer(GLint level, GLint layer); unsigned int getRenderTargetSerial(GLint level, GLint layer); protected: - friend class Texture3DAttachment; + friend class RenderbufferTexture3DLayer; rx::RenderTarget *getRenderTarget(GLint level); rx::RenderTarget *getRenderTarget(GLint level, GLint layer); rx::RenderTarget *getDepthStencil(GLint level, GLint layer); @@ -376,10 +391,11 @@ class Texture2DArray : public Texture virtual bool isSamplerComplete(const SamplerState &samplerState) const; virtual bool isMipmapComplete() const; + Renderbuffer *getRenderbuffer(GLint level, GLint layer); unsigned int getRenderTargetSerial(GLint level, GLint layer); protected: - friend class Texture2DArrayAttachment; + friend class RenderbufferTexture2DArrayLayer; rx::RenderTarget *getRenderTarget(GLint level, GLint layer); rx::RenderTarget *getDepthStencil(GLint level, GLint layer); diff --git a/gfx/angle/src/libGLESv2/TransformFeedback.h b/gfx/angle/src/libGLESv2/TransformFeedback.h index d6f4522e2a1d..183873c82ff9 100644 --- a/gfx/angle/src/libGLESv2/TransformFeedback.h +++ b/gfx/angle/src/libGLESv2/TransformFeedback.h @@ -10,7 +10,8 @@ #include "common/angleutils.h" #include "common/RefCountObject.h" -#include "angle_gl.h" +#include +#include namespace gl { diff --git a/gfx/angle/src/libGLESv2/Uniform.cpp b/gfx/angle/src/libGLESv2/Uniform.cpp index cddc7ec7d04f..a5ab7cb517d9 100644 --- a/gfx/angle/src/libGLESv2/Uniform.cpp +++ b/gfx/angle/src/libGLESv2/Uniform.cpp @@ -13,7 +13,7 @@ namespace gl { LinkedUniform::LinkedUniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize, - const int blockIndex, const sh::BlockMemberInfo &blockInfo) + const int blockIndex, const BlockMemberInfo &blockInfo) : type(type), precision(precision), name(name), @@ -71,7 +71,7 @@ bool LinkedUniform::isInDefaultBlock() const size_t LinkedUniform::dataSize() const { ASSERT(type != GL_STRUCT_ANGLEX); - return VariableInternalSize(type) * elementCount(); + return UniformInternalSize(type) * elementCount(); } bool LinkedUniform::isSampler() const diff --git a/gfx/angle/src/libGLESv2/Uniform.h b/gfx/angle/src/libGLESv2/Uniform.h index 9adfeac7a6ca..221ba48f9497 100644 --- a/gfx/angle/src/libGLESv2/Uniform.h +++ b/gfx/angle/src/libGLESv2/Uniform.h @@ -10,7 +10,8 @@ #include #include -#include "angle_gl.h" +#include +#include #include "common/debug.h" #include "angletypes.h" @@ -22,7 +23,7 @@ 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(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize, const int blockIndex, const BlockMemberInfo &blockInfo); ~LinkedUniform(); @@ -39,7 +40,7 @@ struct LinkedUniform const std::string name; const unsigned int arraySize; const int blockIndex; - const sh::BlockMemberInfo blockInfo; + const BlockMemberInfo blockInfo; unsigned char *data; bool dirty; diff --git a/gfx/angle/src/libGLESv2/VertexArray.cpp b/gfx/angle/src/libGLESv2/VertexArray.cpp index 16f75d6f19b3..bd2df391695a 100644 --- a/gfx/angle/src/libGLESv2/VertexArray.cpp +++ b/gfx/angle/src/libGLESv2/VertexArray.cpp @@ -9,37 +9,31 @@ #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) - : RefCountObject(id), - mVertexArray(impl), - mVertexAttributes(maxAttribs) +VertexArray::VertexArray(rx::Renderer *renderer, GLuint id) + : RefCountObject(id) { - ASSERT(impl != NULL); } VertexArray::~VertexArray() { - SafeDelete(mVertexArray); - - for (size_t i = 0; i < getMaxAttribs(); i++) + for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) { - mVertexAttributes[i].buffer.set(NULL); + mVertexAttributes[i].mBoundBuffer.set(NULL); } mElementArrayBuffer.set(NULL); } void VertexArray::detachBuffer(GLuint bufferName) { - for (size_t attribute = 0; attribute < getMaxAttribs(); attribute++) + for (int attribute = 0; attribute < MAX_VERTEX_ATTRIBS; attribute++) { - if (mVertexAttributes[attribute].buffer.id() == bufferName) + if (mVertexAttributes[attribute].mBoundBuffer.id() == bufferName) { - mVertexAttributes[attribute].buffer.set(NULL); + mVertexAttributes[attribute].mBoundBuffer.set(NULL); } } @@ -49,44 +43,29 @@ void VertexArray::detachBuffer(GLuint bufferName) } } -const VertexAttribute& VertexArray::getVertexAttribute(size_t attributeIndex) const +const VertexAttribute& VertexArray::getVertexAttribute(unsigned int attributeIndex) const { - ASSERT(attributeIndex < getMaxAttribs()); + ASSERT(attributeIndex < MAX_VERTEX_ATTRIBS); return mVertexAttributes[attributeIndex]; } void VertexArray::setVertexAttribDivisor(GLuint index, GLuint divisor) { - ASSERT(index < getMaxAttribs()); - mVertexAttributes[index].divisor = divisor; - mVertexArray->setAttributeDivisor(index, divisor); + ASSERT(index < gl::MAX_VERTEX_ATTRIBS); + mVertexAttributes[index].mDivisor = divisor; } void VertexArray::enableAttribute(unsigned int attributeIndex, bool enabledState) { - ASSERT(attributeIndex < getMaxAttribs()); - mVertexAttributes[attributeIndex].enabled = enabledState; - mVertexArray->enableAttribute(attributeIndex, enabledState); + ASSERT(attributeIndex < gl::MAX_VERTEX_ATTRIBS); + mVertexAttributes[attributeIndex].mArrayEnabled = 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); + ASSERT(attributeIndex < gl::MAX_VERTEX_ATTRIBS); + mVertexAttributes[attributeIndex].setState(boundBuffer, size, type, normalized, pureInteger, stride, pointer); } } \ No newline at end of file diff --git a/gfx/angle/src/libGLESv2/VertexArray.h b/gfx/angle/src/libGLESv2/VertexArray.h index 1ea3c38806d0..ecfe7ad8f91e 100644 --- a/gfx/angle/src/libGLESv2/VertexArray.h +++ b/gfx/angle/src/libGLESv2/VertexArray.h @@ -20,7 +20,6 @@ namespace rx { class Renderer; -class VertexArrayImpl; } namespace gl @@ -30,25 +29,23 @@ class Buffer; class VertexArray : public RefCountObject { public: - VertexArray(rx::VertexArrayImpl *impl, GLuint id, size_t maxAttribs); + VertexArray(rx::Renderer *renderer, GLuint id); ~VertexArray(); - const VertexAttribute& getVertexAttribute(size_t attributeIndex) const; + const VertexAttribute& getVertexAttribute(unsigned int 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.data(); } + const VertexAttribute* getVertexAttributes() const { return mVertexAttributes; } Buffer *getElementArrayBuffer() const { return mElementArrayBuffer.get(); } - void setElementArrayBuffer(Buffer *buffer); + void setElementArrayBuffer(Buffer *elementArrayBuffer) { mElementArrayBuffer.set(elementArrayBuffer); } GLuint getElementArrayBufferId() const { return mElementArrayBuffer.id(); } - size_t getMaxAttribs() const { return mVertexAttributes.size(); } private: - rx::VertexArrayImpl *mVertexArray; - std::vector mVertexAttributes; + VertexAttribute mVertexAttributes[MAX_VERTEX_ATTRIBS]; BindingPointer mElementArrayBuffer; }; diff --git a/gfx/angle/src/libGLESv2/VertexAttribute.cpp b/gfx/angle/src/libGLESv2/VertexAttribute.cpp deleted file mode 100644 index 7d011ef75864..000000000000 --- a/gfx/angle/src/libGLESv2/VertexAttribute.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "precompiled.h" -// -// 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/gfx/angle/src/libGLESv2/VertexAttribute.h b/gfx/angle/src/libGLESv2/VertexAttribute.h index e9757b618b41..e9364d66e831 100644 --- a/gfx/angle/src/libGLESv2/VertexAttribute.h +++ b/gfx/angle/src/libGLESv2/VertexAttribute.h @@ -14,58 +14,95 @@ namespace gl { -struct VertexAttribute +class VertexAttribute { - bool enabled; // From glEnable/DisableVertexAttribArray + public: + VertexAttribute() : mType(GL_FLOAT), mSize(4), mNormalized(false), mPureInteger(false), + mStride(0), mPointer(NULL), mArrayEnabled(false), mDivisor(0) + { + } - GLenum type; - GLuint size; - bool normalized; - bool pureInteger; - GLuint stride; // 0 means natural stride + int typeSize() const + { + switch (mType) + { + case GL_BYTE: return mSize * sizeof(GLbyte); + case GL_UNSIGNED_BYTE: return mSize * sizeof(GLubyte); + case GL_SHORT: return mSize * sizeof(GLshort); + case GL_UNSIGNED_SHORT: return mSize * sizeof(GLushort); + case GL_INT: return mSize * sizeof(GLint); + case GL_UNSIGNED_INT: return mSize * 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 mSize * sizeof(GLfixed); + case GL_HALF_FLOAT: return mSize * sizeof(GLhalf); + case GL_FLOAT: return mSize * sizeof(GLfloat); + default: UNREACHABLE(); return mSize * sizeof(GLfloat); + } + } + + GLsizei stride() const + { + return (mArrayEnabled ? (mStride ? mStride : typeSize()) : 16); + } + + void setState(gl::Buffer *boundBuffer, GLint size, GLenum type, bool normalized, + bool pureInteger, GLsizei stride, const void *pointer) + { + mBoundBuffer.set(boundBuffer); + mSize = size; + mType = type; + mNormalized = normalized; + mPureInteger = pureInteger; + mStride = stride; + mPointer = pointer; + } + + template + T querySingleParameter(GLenum pname) const + { + switch (pname) + { + case GL_VERTEX_ATTRIB_ARRAY_ENABLED: + return static_cast(mArrayEnabled ? GL_TRUE : GL_FALSE); + case GL_VERTEX_ATTRIB_ARRAY_SIZE: + return static_cast(mSize); + case GL_VERTEX_ATTRIB_ARRAY_STRIDE: + return static_cast(mStride); + case GL_VERTEX_ATTRIB_ARRAY_TYPE: + return static_cast(mType); + case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: + return static_cast(mNormalized ? GL_TRUE : GL_FALSE); + case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: + return static_cast(mBoundBuffer.id()); + case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: + return static_cast(mDivisor); + case GL_VERTEX_ATTRIB_ARRAY_INTEGER: + return static_cast(mPureInteger ? GL_TRUE : GL_FALSE); + default: + UNREACHABLE(); + return static_cast(0); + } + } + + // From glVertexAttribPointer + GLenum mType; + GLint mSize; + bool mNormalized; + bool mPureInteger; + GLsizei mStride; // 0 means natural stride union { - const GLvoid *pointer; - GLintptr offset; + const void *mPointer; + intptr_t mOffset; }; - BindingPointer buffer; // Captured when glVertexAttribPointer is called. - GLuint divisor; - - VertexAttribute(); + BindingPointer mBoundBuffer; // Captured when glVertexAttribPointer is called. + bool mArrayEnabled; // From glEnable/DisableVertexAttribArray + unsigned int mDivisor; }; -template -T QuerySingleVertexAttributeParameter(const VertexAttribute& attrib, GLenum pname) -{ - switch (pname) - { - case GL_VERTEX_ATTRIB_ARRAY_ENABLED: - return static_cast(attrib.enabled ? GL_TRUE : GL_FALSE); - case GL_VERTEX_ATTRIB_ARRAY_SIZE: - return static_cast(attrib.size); - case GL_VERTEX_ATTRIB_ARRAY_STRIDE: - return static_cast(attrib.stride); - case GL_VERTEX_ATTRIB_ARRAY_TYPE: - return static_cast(attrib.type); - case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: - return static_cast(attrib.normalized ? GL_TRUE : GL_FALSE); - case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: - return static_cast(attrib.buffer.id()); - case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: - return static_cast(attrib.divisor); - case GL_VERTEX_ATTRIB_ARRAY_INTEGER: - return static_cast(attrib.pureInteger ? GL_TRUE : GL_FALSE); - default: - UNREACHABLE(); - return static_cast(0); - } -} - -size_t ComputeVertexAttributeTypeSize(const VertexAttribute& attrib); -size_t ComputeVertexAttributeStride(const VertexAttribute& attrib); - struct VertexAttribCurrentValueData { union diff --git a/gfx/angle/src/libGLESv2/angletypes.cpp b/gfx/angle/src/libGLESv2/angletypes.cpp index d86f19a07fa6..acb3da8999d5 100644 --- a/gfx/angle/src/libGLESv2/angletypes.cpp +++ b/gfx/angle/src/libGLESv2/angletypes.cpp @@ -90,15 +90,15 @@ VertexFormat::VertexFormat(GLenum type, GLboolean normalized, GLuint components, } } -VertexFormat::VertexFormat(const VertexAttribute &attrib) - : mType(attrib.type), - mNormalized(attrib.normalized ? GL_TRUE : GL_FALSE), - mComponents(attrib.size), - mPureInteger(attrib.pureInteger) +VertexFormat::VertexFormat(const VertexAttribute &attribute) + : mType(attribute.mType), + mNormalized(attribute.mNormalized ? GL_TRUE : GL_FALSE), + mComponents(attribute.mSize), + mPureInteger(attribute.mPureInteger) { // Ensure we aren't initializing a vertex format which should be using // the current-value type - ASSERT(attrib.enabled); + ASSERT(attribute.mArrayEnabled); // Float data can not be normalized, so ignore the user setting if (mType == GL_FLOAT || mType == GL_HALF_FLOAT || mType == GL_FIXED) @@ -107,13 +107,13 @@ VertexFormat::VertexFormat(const VertexAttribute &attrib) } } -VertexFormat::VertexFormat(const VertexAttribute &attrib, GLenum currentValueType) - : mType(attrib.type), - mNormalized(attrib.normalized ? GL_TRUE : GL_FALSE), - mComponents(attrib.size), - mPureInteger(attrib.pureInteger) +VertexFormat::VertexFormat(const VertexAttribute &attribute, GLenum currentValueType) + : mType(attribute.mType), + mNormalized(attribute.mNormalized ? GL_TRUE : GL_FALSE), + mComponents(attribute.mSize), + mPureInteger(attribute.mPureInteger) { - if (!attrib.enabled) + if (!attribute.mArrayEnabled) { mType = currentValueType; mNormalized = GL_FALSE; diff --git a/gfx/angle/src/libGLESv2/angletypes.h b/gfx/angle/src/libGLESv2/angletypes.h index 314472a5af55..0e91279d2418 100644 --- a/gfx/angle/src/libGLESv2/angletypes.h +++ b/gfx/angle/src/libGLESv2/angletypes.h @@ -16,7 +16,7 @@ namespace gl { class Buffer; class ProgramBinary; -struct VertexAttribute; +class VertexAttribute; struct VertexAttribCurrentValueData; enum TextureType diff --git a/gfx/angle/src/libGLESv2/formatutils.cpp b/gfx/angle/src/libGLESv2/formatutils.cpp index 82fced549362..3aac25efadd0 100644 --- a/gfx/angle/src/libGLESv2/formatutils.cpp +++ b/gfx/angle/src/libGLESv2/formatutils.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" // -// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -42,7 +42,62 @@ static inline void InsertFormatMapping(FormatMap *map, GLenum format, GLenum typ map->insert(FormatPair(FormatTypePair(format, type), FormatTypeInfo(internalFormat, writeFunc))); } -FormatMap BuildFormatMap() +FormatMap BuildES2FormatMap() +{ + FormatMap map; + + using namespace rx; + + // | Format | Type | Internal format | Color write function | + InsertFormatMapping(&map, GL_ALPHA, GL_UNSIGNED_BYTE, GL_ALPHA8_EXT, WriteColor ); + InsertFormatMapping(&map, GL_ALPHA, GL_FLOAT, GL_ALPHA32F_EXT, WriteColor ); + InsertFormatMapping(&map, GL_ALPHA, GL_HALF_FLOAT_OES, GL_ALPHA16F_EXT, WriteColor ); + + InsertFormatMapping(&map, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LUMINANCE8_EXT, WriteColor ); + InsertFormatMapping(&map, GL_LUMINANCE, GL_FLOAT, GL_LUMINANCE32F_EXT, WriteColor ); + InsertFormatMapping(&map, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_LUMINANCE16F_EXT, WriteColor ); + + InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_LUMINANCE8_ALPHA8_EXT, WriteColor ); + InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_LUMINANCE_ALPHA32F_EXT, WriteColor ); + InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_LUMINANCE_ALPHA16F_EXT, WriteColor ); + + InsertFormatMapping(&map, GL_RED, GL_UNSIGNED_BYTE, GL_R8_EXT, WriteColor ); + InsertFormatMapping(&map, GL_RED, GL_FLOAT, GL_R32F_EXT, WriteColor ); + InsertFormatMapping(&map, GL_RED, GL_HALF_FLOAT_OES, GL_R16F_EXT, WriteColor ); + + InsertFormatMapping(&map, GL_RG, GL_UNSIGNED_BYTE, GL_RG8_EXT, WriteColor ); + InsertFormatMapping(&map, GL_RG, GL_FLOAT, GL_RG32F_EXT, WriteColor ); + InsertFormatMapping(&map, GL_RG, GL_HALF_FLOAT_OES, GL_RG16F_EXT, WriteColor ); + + InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_BYTE, GL_RGB8_OES, WriteColor ); + InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_RGB565, WriteColor ); + InsertFormatMapping(&map, GL_RGB, GL_FLOAT, GL_RGB32F_EXT, WriteColor ); + InsertFormatMapping(&map, GL_RGB, GL_HALF_FLOAT_OES, GL_RGB16F_EXT, WriteColor ); + + InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_BYTE, GL_RGBA8_OES, WriteColor ); + InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_RGBA4, WriteColor ); + InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_RGB5_A1, WriteColor ); + InsertFormatMapping(&map, GL_RGBA, GL_FLOAT, GL_RGBA32F_EXT, WriteColor); + InsertFormatMapping(&map, GL_RGBA, GL_HALF_FLOAT_OES, GL_RGBA16F_EXT, WriteColor); + + InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_BGRA8_EXT, WriteColor ); + InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_BGRA4_ANGLEX, WriteColor ); + InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_BGR5_A1_ANGLEX, WriteColor ); + + 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_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, GL_DEPTH24_STENCIL8_OES, NULL ); + + return map; +} + +FormatMap BuildES3FormatMap() { FormatMap map; @@ -56,7 +111,6 @@ FormatMap BuildFormatMap() InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_RGB10_A2, WriteColor ); InsertFormatMapping(&map, GL_RGBA, GL_FLOAT, GL_RGBA32F, WriteColor); InsertFormatMapping(&map, GL_RGBA, GL_HALF_FLOAT, GL_RGBA16F, WriteColor); - InsertFormatMapping(&map, GL_RGBA, GL_HALF_FLOAT_OES, GL_RGBA16F, WriteColor); InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_RGBA8UI, WriteColor ); InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_BYTE, GL_RGBA8I, WriteColor ); @@ -73,7 +127,6 @@ FormatMap BuildFormatMap() InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_RGB9_E5, WriteColor ); InsertFormatMapping(&map, GL_RGB, GL_FLOAT, GL_RGB32F, WriteColor ); InsertFormatMapping(&map, GL_RGB, GL_HALF_FLOAT, GL_RGB16F, WriteColor ); - InsertFormatMapping(&map, GL_RGB, GL_HALF_FLOAT_OES, GL_RGB16F, WriteColor ); InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_RGB8UI, WriteColor ); InsertFormatMapping(&map, GL_RGB_INTEGER, GL_BYTE, GL_RGB8I, WriteColor ); @@ -86,7 +139,6 @@ FormatMap BuildFormatMap() InsertFormatMapping(&map, GL_RG, GL_BYTE, GL_RG8_SNORM, WriteColor ); InsertFormatMapping(&map, GL_RG, GL_FLOAT, GL_RG32F, WriteColor ); InsertFormatMapping(&map, GL_RG, GL_HALF_FLOAT, GL_RG16F, WriteColor ); - InsertFormatMapping(&map, GL_RG, GL_HALF_FLOAT_OES, GL_RG16F, WriteColor ); InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_RG8UI, WriteColor ); InsertFormatMapping(&map, GL_RG_INTEGER, GL_BYTE, GL_RG8I, WriteColor ); @@ -99,7 +151,6 @@ FormatMap BuildFormatMap() InsertFormatMapping(&map, GL_RED, GL_BYTE, GL_R8_SNORM, WriteColor ); InsertFormatMapping(&map, GL_RED, GL_FLOAT, GL_R32F, WriteColor ); InsertFormatMapping(&map, GL_RED, GL_HALF_FLOAT, GL_R16F, WriteColor ); - InsertFormatMapping(&map, GL_RED, GL_HALF_FLOAT_OES, GL_R16F, WriteColor ); InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_R8UI, WriteColor ); InsertFormatMapping(&map, GL_RED_INTEGER, GL_BYTE, GL_R8I, WriteColor ); @@ -115,40 +166,41 @@ FormatMap BuildFormatMap() InsertFormatMapping(&map, GL_LUMINANCE, GL_FLOAT, GL_LUMINANCE32F_EXT, WriteColor ); InsertFormatMapping(&map, GL_ALPHA, GL_FLOAT, GL_ALPHA32F_EXT, WriteColor ); InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, GL_LUMINANCE_ALPHA16F_EXT, WriteColor ); - InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_LUMINANCE_ALPHA16F_EXT, WriteColor ); InsertFormatMapping(&map, GL_LUMINANCE, GL_HALF_FLOAT, GL_LUMINANCE16F_EXT, WriteColor ); - InsertFormatMapping(&map, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_LUMINANCE16F_EXT, WriteColor ); InsertFormatMapping(&map, GL_ALPHA, GL_HALF_FLOAT, GL_ALPHA16F_EXT, WriteColor ); - InsertFormatMapping(&map, GL_ALPHA, GL_HALF_FLOAT_OES, GL_ALPHA16F_EXT, WriteColor ); InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_BGRA8_EXT, WriteColor ); InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_BGRA4_ANGLEX, WriteColor ); InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_BGR5_A1_ANGLEX, WriteColor ); - InsertFormatMapping(&map, GL_SRGB_EXT, GL_UNSIGNED_BYTE, GL_SRGB8, WriteColor ); - InsertFormatMapping(&map, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, GL_SRGB8_ALPHA8, WriteColor ); - - 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_UNSIGNED_INT, GL_DEPTH_COMPONENT24, 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; } -static const FormatMap &GetFormatMap() +static const FormatMap &GetFormatMap(GLuint clientVersion) { - static const FormatMap formatMap = BuildFormatMap(); - return formatMap; + if (clientVersion == 2) + { + static const FormatMap formats = BuildES2FormatMap(); + return formats; + } + else if (clientVersion == 3) + { + static const FormatMap formats = BuildES3FormatMap(); + return formats; + } + else + { + UNREACHABLE(); + static FormatMap emptyMap; + return emptyMap; + } } struct FormatInfo @@ -187,7 +239,6 @@ ES3FormatSet BuildES3FormatSet() set.insert(FormatInfo(GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV )); set.insert(FormatInfo(GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 )); set.insert(FormatInfo(GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT )); - set.insert(FormatInfo(GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT_OES )); set.insert(FormatInfo(GL_RGBA32F, GL_RGBA, GL_FLOAT )); set.insert(FormatInfo(GL_RGBA16F, GL_RGBA, GL_FLOAT )); set.insert(FormatInfo(GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE )); @@ -205,11 +256,8 @@ ES3FormatSet BuildES3FormatSet() set.insert(FormatInfo(GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV )); set.insert(FormatInfo(GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV )); set.insert(FormatInfo(GL_RGB16F, GL_RGB, GL_HALF_FLOAT )); - set.insert(FormatInfo(GL_RGB16F, GL_RGB, GL_HALF_FLOAT_OES )); set.insert(FormatInfo(GL_R11F_G11F_B10F, GL_RGB, GL_HALF_FLOAT )); - set.insert(FormatInfo(GL_R11F_G11F_B10F, GL_RGB, GL_HALF_FLOAT_OES )); set.insert(FormatInfo(GL_RGB9_E5, GL_RGB, GL_HALF_FLOAT )); - set.insert(FormatInfo(GL_RGB9_E5, GL_RGB, GL_HALF_FLOAT_OES )); set.insert(FormatInfo(GL_RGB32F, GL_RGB, GL_FLOAT )); set.insert(FormatInfo(GL_RGB16F, GL_RGB, GL_FLOAT )); set.insert(FormatInfo(GL_R11F_G11F_B10F, GL_RGB, GL_FLOAT )); @@ -223,7 +271,6 @@ ES3FormatSet BuildES3FormatSet() set.insert(FormatInfo(GL_RG8, GL_RG, GL_UNSIGNED_BYTE )); set.insert(FormatInfo(GL_RG8_SNORM, GL_RG, GL_BYTE )); set.insert(FormatInfo(GL_RG16F, GL_RG, GL_HALF_FLOAT )); - set.insert(FormatInfo(GL_RG16F, GL_RG, GL_HALF_FLOAT_OES )); set.insert(FormatInfo(GL_RG32F, GL_RG, GL_FLOAT )); set.insert(FormatInfo(GL_RG16F, GL_RG, GL_FLOAT )); set.insert(FormatInfo(GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE )); @@ -235,7 +282,6 @@ ES3FormatSet BuildES3FormatSet() set.insert(FormatInfo(GL_R8, GL_RED, GL_UNSIGNED_BYTE )); set.insert(FormatInfo(GL_R8_SNORM, GL_RED, GL_BYTE )); set.insert(FormatInfo(GL_R16F, GL_RED, GL_HALF_FLOAT )); - set.insert(FormatInfo(GL_R16F, GL_RED, GL_HALF_FLOAT_OES )); set.insert(FormatInfo(GL_R32F, GL_RED, GL_FLOAT )); set.insert(FormatInfo(GL_R16F, GL_RED, GL_FLOAT )); set.insert(FormatInfo(GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE )); @@ -254,8 +300,6 @@ ES3FormatSet BuildES3FormatSet() set.insert(FormatInfo(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE )); set.insert(FormatInfo(GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE )); set.insert(FormatInfo(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE )); - set.insert(FormatInfo(GL_SRGB_ALPHA_EXT, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE )); - set.insert(FormatInfo(GL_SRGB_EXT, GL_SRGB_EXT, GL_UNSIGNED_BYTE )); // Depth stencil formats set.insert(FormatInfo(GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT )); @@ -265,10 +309,6 @@ ES3FormatSet BuildES3FormatSet() set.insert(FormatInfo(GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8 )); set.insert(FormatInfo(GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV)); - // From GL_EXT_sRGB - set.insert(FormatInfo(GL_SRGB8_ALPHA8_EXT, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE )); - set.insert(FormatInfo(GL_SRGB8, GL_SRGB_EXT, GL_UNSIGNED_BYTE )); - // From GL_OES_texture_float set.insert(FormatInfo(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_FLOAT )); set.insert(FormatInfo(GL_LUMINANCE, GL_LUMINANCE, GL_FLOAT )); @@ -276,11 +316,8 @@ ES3FormatSet BuildES3FormatSet() // From GL_OES_texture_half_float set.insert(FormatInfo(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT )); - set.insert(FormatInfo(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES )); set.insert(FormatInfo(GL_LUMINANCE, GL_LUMINANCE, GL_HALF_FLOAT )); - set.insert(FormatInfo(GL_LUMINANCE, GL_LUMINANCE, GL_HALF_FLOAT_OES )); set.insert(FormatInfo(GL_ALPHA, GL_ALPHA, GL_HALF_FLOAT )); - set.insert(FormatInfo(GL_ALPHA, GL_ALPHA, GL_HALF_FLOAT_OES )); // From GL_EXT_texture_format_BGRA8888 set.insert(FormatInfo(GL_BGRA_EXT, GL_BGRA_EXT, GL_UNSIGNED_BYTE )); @@ -295,11 +332,8 @@ ES3FormatSet BuildES3FormatSet() set.insert(FormatInfo(GL_LUMINANCE32F_EXT, GL_LUMINANCE, GL_FLOAT )); set.insert(FormatInfo(GL_LUMINANCE_ALPHA32F_EXT, GL_LUMINANCE_ALPHA, GL_FLOAT )); set.insert(FormatInfo(GL_ALPHA16F_EXT, GL_ALPHA, GL_HALF_FLOAT )); - set.insert(FormatInfo(GL_ALPHA16F_EXT, GL_ALPHA, GL_HALF_FLOAT_OES )); set.insert(FormatInfo(GL_LUMINANCE16F_EXT, GL_LUMINANCE, GL_HALF_FLOAT )); - set.insert(FormatInfo(GL_LUMINANCE16F_EXT, GL_LUMINANCE, GL_HALF_FLOAT_OES )); set.insert(FormatInfo(GL_LUMINANCE_ALPHA16F_EXT, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT )); - set.insert(FormatInfo(GL_LUMINANCE_ALPHA16F_EXT, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES )); // From GL_EXT_texture_storage and GL_EXT_texture_format_BGRA8888 set.insert(FormatInfo(GL_BGRA8_EXT, GL_BGRA_EXT, GL_UNSIGNED_BYTE )); @@ -415,56 +449,74 @@ static bool GetTypeInfo(GLenum type, TypeInfo *outTypeInfo) } // Information about internal formats -typedef bool(*SupportCheckFunction)(GLuint, const Extensions &); +typedef bool ((Context::*ContextSupportCheckMemberFunction)(void) const); +typedef bool (*ContextSupportCheckFunction)(const Context *context); -static bool UnimplementedSupport(GLuint clientVersion, const Extensions &) +typedef bool ((rx::Renderer::*RendererSupportCheckMemberFunction)(void) const); +typedef bool (*ContextRendererSupportCheckFunction)(const Context *context, const rx::Renderer *renderer); + +template +bool CheckSupport(const Context *context) +{ + return (context->*func)(); +} + +template +bool CheckSupport(const Context *context, const rx::Renderer *renderer) +{ + if (context) + { + return (context->*contextFunc)(); + } + else if (renderer) + { + return (renderer->*rendererFunc)(); + } + else + { + UNREACHABLE(); + return false; + } +} + +template +bool AlwaysSupported(const objectType*) +{ + return true; +} + +template +bool AlwaysSupported(const objectTypeA*, const objectTypeB*) +{ + return true; +} + +template +bool NeverSupported(const objectType*) +{ + return false; +} + +template +bool NeverSupported(const objectTypeA *, const objectTypeB *) +{ + return false; +} + +template +bool UnimplementedSupport(const objectType*) { UNIMPLEMENTED(); return false; } -static bool NeverSupported(GLuint clientVersion, const Extensions &) +template +bool UnimplementedSupport(const objectTypeA*, const objectTypeB*) { + UNIMPLEMENTED(); return false; } -template -static bool RequireESVersion(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 -static bool RequireExtension(GLuint, const Extensions & extensions) -{ - return extensions.*bool1; -} - -// Check for a minimum client version or a single extension -template -static bool RequireESVersionOrExtension(GLuint clientVersion, const Extensions &extensions) -{ - return clientVersion >= minCoreGLVersion || extensions.*bool1; -} - -// Check for a minimum client version or two extensions -template -static bool RequireESVersionOrExtensions(GLuint clientVersion, const Extensions &extensions) -{ - return clientVersion >= minCoreGLVersion || (extensions.*bool1 || extensions.*bool2); -} - -// Check support for two extensions -template -static bool RequireExtensions(GLuint, const Extensions &extensions) -{ - return extensions.*bool1 || extensions.*bool2; -} - struct InternalFormatInfo { GLuint mRedBits; @@ -494,25 +546,38 @@ struct InternalFormatInfo bool mIsCompressed; - SupportCheckFunction mSupportFunction; + ContextRendererSupportCheckFunction mIsColorRenderable; + ContextRendererSupportCheckFunction mIsDepthRenderable; + ContextRendererSupportCheckFunction mIsStencilRenderable; + ContextRendererSupportCheckFunction mIsTextureFilterable; + + ContextSupportCheckFunction mSupportFunction; InternalFormatInfo() : mRedBits(0), mGreenBits(0), mBlueBits(0), mLuminanceBits(0), mAlphaBits(0), mSharedBits(0), mDepthBits(0), mStencilBits(0), mPixelBits(0), mComponentCount(0), mCompressedBlockWidth(0), mCompressedBlockHeight(0), mFormat(GL_NONE), mType(GL_NONE), - mComponentType(GL_NONE), mColorEncoding(GL_NONE), mIsCompressed(false), mSupportFunction(NeverSupported) + mComponentType(GL_NONE), mColorEncoding(GL_NONE), mIsCompressed(false), mIsColorRenderable(NeverSupported), + mIsDepthRenderable(NeverSupported), mIsStencilRenderable(NeverSupported), mIsTextureFilterable(NeverSupported), + mSupportFunction(NeverSupported) { } - static InternalFormatInfo UnsizedFormat(GLenum format, SupportCheckFunction supportFunction) + static InternalFormatInfo UnsizedFormat(GLenum format, ContextSupportCheckFunction supportFunction) { InternalFormatInfo formatInfo; formatInfo.mFormat = format; formatInfo.mSupportFunction = supportFunction; + + if (format == GL_RGB || format == GL_RGBA) + formatInfo.mIsColorRenderable = AlwaysSupported; + return formatInfo; } static InternalFormatInfo RGBAFormat(GLuint red, GLuint green, GLuint blue, GLuint alpha, GLuint shared, GLenum format, GLenum type, GLenum componentType, bool srgb, - SupportCheckFunction supportFunction) + ContextRendererSupportCheckFunction colorRenderable, + ContextRendererSupportCheckFunction textureFilterable, + ContextSupportCheckFunction supportFunction) { InternalFormatInfo formatInfo; formatInfo.mRedBits = red; @@ -526,12 +591,14 @@ struct InternalFormatInfo formatInfo.mType = type; formatInfo.mComponentType = componentType; formatInfo.mColorEncoding = (srgb ? GL_SRGB : GL_LINEAR); + formatInfo.mIsColorRenderable = colorRenderable; + formatInfo.mIsTextureFilterable = textureFilterable; formatInfo.mSupportFunction = supportFunction; return formatInfo; } static InternalFormatInfo LUMAFormat(GLuint luminance, GLuint alpha, GLenum format, GLenum type, GLenum componentType, - SupportCheckFunction supportFunction) + ContextSupportCheckFunction supportFunction) { InternalFormatInfo formatInfo; formatInfo.mLuminanceBits = luminance; @@ -542,12 +609,16 @@ struct InternalFormatInfo formatInfo.mType = type; formatInfo.mComponentType = componentType; formatInfo.mColorEncoding = GL_LINEAR; + formatInfo.mIsTextureFilterable = AlwaysSupported; formatInfo.mSupportFunction = supportFunction; return formatInfo; } static InternalFormatInfo DepthStencilFormat(GLuint depthBits, GLuint stencilBits, GLuint unusedBits, GLenum format, - GLenum type, GLenum componentType, SupportCheckFunction supportFunction) + GLenum type, GLenum componentType, + ContextRendererSupportCheckFunction depthRenderable, + ContextRendererSupportCheckFunction stencilRenderable, + ContextSupportCheckFunction supportFunction) { InternalFormatInfo formatInfo; formatInfo.mDepthBits = depthBits; @@ -558,13 +629,16 @@ struct InternalFormatInfo formatInfo.mType = type; formatInfo.mComponentType = componentType; formatInfo.mColorEncoding = GL_LINEAR; + formatInfo.mIsDepthRenderable = depthRenderable; + formatInfo.mIsStencilRenderable = stencilRenderable; + formatInfo.mIsTextureFilterable = AlwaysSupported; formatInfo.mSupportFunction = supportFunction; return formatInfo; } static InternalFormatInfo CompressedFormat(GLuint compressedBlockWidth, GLuint compressedBlockHeight, GLuint compressedBlockSize, GLuint componentCount, GLenum format, GLenum type, bool srgb, - SupportCheckFunction supportFunction) + ContextSupportCheckFunction supportFunction) { InternalFormatInfo formatInfo; formatInfo.mCompressedBlockWidth = compressedBlockWidth; @@ -576,6 +650,7 @@ struct InternalFormatInfo formatInfo.mComponentType = GL_UNSIGNED_NORMALIZED; formatInfo.mColorEncoding = (srgb ? GL_SRGB : GL_LINEAR); formatInfo.mIsCompressed = true; + formatInfo.mIsTextureFilterable = AlwaysSupported; formatInfo.mSupportFunction = supportFunction; return formatInfo; } @@ -584,112 +659,110 @@ struct InternalFormatInfo typedef std::pair InternalFormatInfoPair; typedef std::map InternalFormatInfoMap; -static InternalFormatInfoMap BuildInternalFormatInfoMap() +static InternalFormatInfoMap BuildES3InternalFormatInfoMap() { InternalFormatInfoMap map; // From ES 3.0.1 spec, table 3.12 map.insert(InternalFormatInfoPair(GL_NONE, InternalFormatInfo())); - // | Internal format | | R | G | B | A |S | Format | Type | Component type | SRGB | Supported | - map.insert(InternalFormatInfoPair(GL_R8, InternalFormatInfo::RGBAFormat( 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESVersionOrExtension<3, &Extensions::textureRG>))); - map.insert(InternalFormatInfoPair(GL_R8_SNORM, InternalFormatInfo::RGBAFormat( 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RG8, InternalFormatInfo::RGBAFormat( 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESVersionOrExtension<3, &Extensions::textureRG>))); - map.insert(InternalFormatInfoPair(GL_RG8_SNORM, InternalFormatInfo::RGBAFormat( 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGB8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESVersionOrExtension<3, &Extensions::rgb8rgba8>))); - map.insert(InternalFormatInfoPair(GL_RGB8_SNORM, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGB565, InternalFormatInfo::RGBAFormat( 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, RequireESVersion<2> ))); - map.insert(InternalFormatInfoPair(GL_RGBA4, InternalFormatInfo::RGBAFormat( 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, RequireESVersion<2> ))); - map.insert(InternalFormatInfoPair(GL_RGB5_A1, InternalFormatInfo::RGBAFormat( 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, RequireESVersion<2> ))); - map.insert(InternalFormatInfoPair(GL_RGBA8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESVersionOrExtension<3, &Extensions::rgb8rgba8>))); - map.insert(InternalFormatInfoPair(GL_RGBA8_SNORM, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGB10_A2, InternalFormatInfo::RGBAFormat(10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGB10_A2UI, InternalFormatInfo::RGBAFormat(10, 10, 10, 2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_SRGB8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESVersionOrExtension<3, &Extensions::sRGB>))); - map.insert(InternalFormatInfoPair(GL_SRGB8_ALPHA8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESVersionOrExtension<3, &Extensions::sRGB>))); - map.insert(InternalFormatInfoPair(GL_R11F_G11F_B10F, InternalFormatInfo::RGBAFormat(11, 11, 10, 0, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FLOAT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGB9_E5, InternalFormatInfo::RGBAFormat( 9, 9, 9, 0, 5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_R8I, InternalFormatInfo::RGBAFormat( 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, GL_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_R8UI, InternalFormatInfo::RGBAFormat( 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_R16I, InternalFormatInfo::RGBAFormat(16, 0, 0, 0, 0, GL_RED_INTEGER, GL_SHORT, GL_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_R16UI, InternalFormatInfo::RGBAFormat(16, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_R32I, InternalFormatInfo::RGBAFormat(32, 0, 0, 0, 0, GL_RED_INTEGER, GL_INT, GL_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_R32UI, InternalFormatInfo::RGBAFormat(32, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RG8I, InternalFormatInfo::RGBAFormat( 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_BYTE, GL_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RG8UI, InternalFormatInfo::RGBAFormat( 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RG16I, InternalFormatInfo::RGBAFormat(16, 16, 0, 0, 0, GL_RG_INTEGER, GL_SHORT, GL_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RG16UI, InternalFormatInfo::RGBAFormat(16, 16, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RG32I, InternalFormatInfo::RGBAFormat(32, 32, 0, 0, 0, GL_RG_INTEGER, GL_INT, GL_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RG32UI, InternalFormatInfo::RGBAFormat(32, 32, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGB8I, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_BYTE, GL_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGB8UI, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGB16I, InternalFormatInfo::RGBAFormat(16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_SHORT, GL_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGB16UI, InternalFormatInfo::RGBAFormat(16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGB32I, InternalFormatInfo::RGBAFormat(32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_INT, GL_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGB32UI, InternalFormatInfo::RGBAFormat(32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGBA8I, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_BYTE, GL_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGBA8UI, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGBA16I, InternalFormatInfo::RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_SHORT, GL_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGBA16UI, InternalFormatInfo::RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGBA32I, InternalFormatInfo::RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, GL_INT, false, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGBA32UI, InternalFormatInfo::RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireESVersion<3> ))); + // | Internal format | | R | G | B | A |S | Format | Type | Component type | SRGB | Color | Texture | Supported | + // | | | | | | | | | | | | renderable | filterable | | + map.insert(InternalFormatInfoPair(GL_R8, InternalFormatInfo::RGBAFormat( 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_R8_SNORM, InternalFormatInfo::RGBAFormat( 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RG8, InternalFormatInfo::RGBAFormat( 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RG8_SNORM, InternalFormatInfo::RGBAFormat( 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGB8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGB8_SNORM, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGB565, InternalFormatInfo::RGBAFormat( 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGBA4, InternalFormatInfo::RGBAFormat( 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGB5_A1, InternalFormatInfo::RGBAFormat( 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGBA8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGBA8_SNORM, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGB10_A2, InternalFormatInfo::RGBAFormat(10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGB10_A2UI, InternalFormatInfo::RGBAFormat(10, 10, 10, 2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_SRGB8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, NeverSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_SRGB8_ALPHA8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_R11F_G11F_B10F, InternalFormatInfo::RGBAFormat(11, 11, 10, 0, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FLOAT, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGB9_E5, InternalFormatInfo::RGBAFormat( 9, 9, 9, 0, 5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT, false, NeverSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_R8I, InternalFormatInfo::RGBAFormat( 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_R8UI, InternalFormatInfo::RGBAFormat( 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_R16I, InternalFormatInfo::RGBAFormat(16, 0, 0, 0, 0, GL_RED_INTEGER, GL_SHORT, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_R16UI, InternalFormatInfo::RGBAFormat(16, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_R32I, InternalFormatInfo::RGBAFormat(32, 0, 0, 0, 0, GL_RED_INTEGER, GL_INT, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_R32UI, InternalFormatInfo::RGBAFormat(32, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RG8I, InternalFormatInfo::RGBAFormat( 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_BYTE, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RG8UI, InternalFormatInfo::RGBAFormat( 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RG16I, InternalFormatInfo::RGBAFormat(16, 16, 0, 0, 0, GL_RG_INTEGER, GL_SHORT, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RG16UI, InternalFormatInfo::RGBAFormat(16, 16, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RG32I, InternalFormatInfo::RGBAFormat(32, 32, 0, 0, 0, GL_RG_INTEGER, GL_INT, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RG32UI, InternalFormatInfo::RGBAFormat(32, 32, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGB8I, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_BYTE, GL_INT, false, NeverSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGB8UI, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, NeverSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGB16I, InternalFormatInfo::RGBAFormat(16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_SHORT, GL_INT, false, NeverSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGB16UI, InternalFormatInfo::RGBAFormat(16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, NeverSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGB32I, InternalFormatInfo::RGBAFormat(32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_INT, GL_INT, false, NeverSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGB32UI, InternalFormatInfo::RGBAFormat(32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, NeverSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGBA8I, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_BYTE, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGBA8UI, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGBA16I, InternalFormatInfo::RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_SHORT, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGBA16UI, InternalFormatInfo::RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGBA32I, InternalFormatInfo::RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGBA32UI, InternalFormatInfo::RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); - map.insert(InternalFormatInfoPair(GL_BGRA8_EXT, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExtension<&Extensions::textureFormatBGRA8888>))); - map.insert(InternalFormatInfoPair(GL_BGRA4_ANGLEX, InternalFormatInfo::RGBAFormat( 4, 4, 4, 4, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_UNSIGNED_NORMALIZED, false, RequireExtension<&Extensions::textureFormatBGRA8888>))); - map.insert(InternalFormatInfoPair(GL_BGR5_A1_ANGLEX, InternalFormatInfo::RGBAFormat( 5, 5, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_UNSIGNED_NORMALIZED, false, RequireExtension<&Extensions::textureFormatBGRA8888>))); + map.insert(InternalFormatInfoPair(GL_BGRA8_EXT, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_BGRA4_ANGLEX, InternalFormatInfo::RGBAFormat( 4, 4, 4, 4, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_BGR5_A1_ANGLEX, InternalFormatInfo::RGBAFormat( 5, 5, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, 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 | Supported | - // | | | | | | | type | | | - map.insert(InternalFormatInfoPair(GL_R16F, InternalFormatInfo::RGBAFormat(16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT, GL_FLOAT, false, RequireESVersionOrExtensions<3, &Extensions::textureHalfFloat, &Extensions::textureRG>))); - map.insert(InternalFormatInfoPair(GL_RG16F, InternalFormatInfo::RGBAFormat(16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT, GL_FLOAT, false, RequireESVersionOrExtensions<3, &Extensions::textureHalfFloat, &Extensions::textureRG>))); - map.insert(InternalFormatInfoPair(GL_RGB16F, InternalFormatInfo::RGBAFormat(16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT, GL_FLOAT, false, RequireESVersionOrExtension<3, &Extensions::textureHalfFloat> ))); - map.insert(InternalFormatInfoPair(GL_RGBA16F, InternalFormatInfo::RGBAFormat(16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT, GL_FLOAT, false, RequireESVersionOrExtension<3, &Extensions::textureHalfFloat> ))); - map.insert(InternalFormatInfoPair(GL_R32F, InternalFormatInfo::RGBAFormat(32, 0, 0, 0, 0, GL_RED, GL_FLOAT, GL_FLOAT, false, RequireESVersionOrExtensions<3, &Extensions::textureFloat, &Extensions::textureRG> ))); - map.insert(InternalFormatInfoPair(GL_RG32F, InternalFormatInfo::RGBAFormat(32, 32, 0, 0, 0, GL_RG, GL_FLOAT, GL_FLOAT, false, RequireESVersionOrExtensions<3, &Extensions::textureFloat, &Extensions::textureRG> ))); - map.insert(InternalFormatInfoPair(GL_RGB32F, InternalFormatInfo::RGBAFormat(32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, RequireESVersionOrExtension<3, &Extensions::textureFloat> ))); - map.insert(InternalFormatInfoPair(GL_RGBA32F, InternalFormatInfo::RGBAFormat(32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, RequireESVersionOrExtension<3, &Extensions::textureFloat> ))); + // | Internal format | | D |S | Format | Type | Comp | SRGB | Color renderable | Texture filterable | Supported | + // | | | | | | | type | | | | | + map.insert(InternalFormatInfoPair(GL_R16F, InternalFormatInfo::RGBAFormat(16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RG16F, InternalFormatInfo::RGBAFormat(16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGB16F, InternalFormatInfo::RGBAFormat(16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGBA16F, InternalFormatInfo::RGBAFormat(16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_R32F, InternalFormatInfo::RGBAFormat(32, 0, 0, 0, 0, GL_RED, GL_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat32RenderableTextures, &rx::Renderer::getFloat32TextureRenderingSupport>, CheckSupport<&Context::supportsFloat32LinearFilter, &rx::Renderer::getFloat32TextureFilteringSupport>, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RG32F, InternalFormatInfo::RGBAFormat(32, 32, 0, 0, 0, GL_RG, GL_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat32RenderableTextures, &rx::Renderer::getFloat32TextureRenderingSupport>, CheckSupport<&Context::supportsFloat32LinearFilter, &rx::Renderer::getFloat32TextureFilteringSupport>, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGB32F, InternalFormatInfo::RGBAFormat(32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat32RenderableTextures, &rx::Renderer::getFloat32TextureRenderingSupport>, CheckSupport<&Context::supportsFloat32LinearFilter, &rx::Renderer::getFloat32TextureFilteringSupport>, AlwaysSupported ))); + map.insert(InternalFormatInfoPair(GL_RGBA32F, InternalFormatInfo::RGBAFormat(32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat32RenderableTextures, &rx::Renderer::getFloat32TextureRenderingSupport>, CheckSupport<&Context::supportsFloat32LinearFilter, &rx::Renderer::getFloat32TextureFilteringSupport>, AlwaysSupported ))); // Depth stencil formats - // | Internal format | | D |S | X | Format | Type | Component type | Supported | - map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT16, InternalFormatInfo::DepthStencilFormat(16, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, RequireESVersion<2> ))); - map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT24, InternalFormatInfo::DepthStencilFormat(24, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32F, InternalFormatInfo::DepthStencilFormat(32, 0, 0, GL_DEPTH_COMPONENT, GL_FLOAT, GL_FLOAT, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32_OES, InternalFormatInfo::DepthStencilFormat(32, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireExtension<&Extensions::depthTextures>))); - map.insert(InternalFormatInfoPair(GL_DEPTH24_STENCIL8, InternalFormatInfo::DepthStencilFormat(24, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_NORMALIZED, RequireESVersionOrExtension<2, &Extensions::depthTextures>))); - map.insert(InternalFormatInfoPair(GL_DEPTH32F_STENCIL8, InternalFormatInfo::DepthStencilFormat(32, 8, 24, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_FLOAT, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_STENCIL_INDEX8, InternalFormatInfo::DepthStencilFormat( 0, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, RequireESVersion<2> ))); + // | Internal format | | D |S | X | Format | Type | Component type | Depth | Stencil | Supported | + // | | | | | | | | | renderable | renderable | | + map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT16, InternalFormatInfo::DepthStencilFormat(16, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, AlwaysSupported, NeverSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT24, InternalFormatInfo::DepthStencilFormat(24, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, AlwaysSupported, NeverSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32F, InternalFormatInfo::DepthStencilFormat(32, 0, 0, GL_DEPTH_COMPONENT, GL_FLOAT, GL_FLOAT, AlwaysSupported, NeverSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32_OES, InternalFormatInfo::DepthStencilFormat(32, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, AlwaysSupported, NeverSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_DEPTH24_STENCIL8, InternalFormatInfo::DepthStencilFormat(24, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_NORMALIZED, AlwaysSupported, AlwaysSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_DEPTH32F_STENCIL8, InternalFormatInfo::DepthStencilFormat(32, 8, 24, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_FLOAT, AlwaysSupported, AlwaysSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_STENCIL_INDEX8, InternalFormatInfo::DepthStencilFormat( 0, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, NeverSupported, AlwaysSupported, AlwaysSupported))); // Luminance alpha formats - // | Internal format | | L | A | Format | Type | Component type | Supported | - map.insert(InternalFormatInfoPair(GL_ALPHA8_EXT, InternalFormatInfo::LUMAFormat( 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExtension<&Extensions::textureStorage> ))); - map.insert(InternalFormatInfoPair(GL_LUMINANCE8_EXT, InternalFormatInfo::LUMAFormat( 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExtension<&Extensions::textureStorage> ))); - map.insert(InternalFormatInfoPair(GL_ALPHA32F_EXT, InternalFormatInfo::LUMAFormat( 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtensions<&Extensions::textureStorage, &Extensions::textureFloat> ))); - map.insert(InternalFormatInfoPair(GL_LUMINANCE32F_EXT, InternalFormatInfo::LUMAFormat(32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, RequireExtensions<&Extensions::textureStorage, &Extensions::textureFloat> ))); - map.insert(InternalFormatInfoPair(GL_ALPHA16F_EXT, InternalFormatInfo::LUMAFormat( 0, 16, GL_ALPHA, GL_HALF_FLOAT, GL_FLOAT, RequireExtensions<&Extensions::textureStorage, &Extensions::textureHalfFloat>))); - map.insert(InternalFormatInfoPair(GL_LUMINANCE16F_EXT, InternalFormatInfo::LUMAFormat(16, 0, GL_LUMINANCE, GL_HALF_FLOAT, GL_FLOAT, RequireExtensions<&Extensions::textureStorage, &Extensions::textureHalfFloat>))); - map.insert(InternalFormatInfoPair(GL_LUMINANCE8_ALPHA8_EXT, InternalFormatInfo::LUMAFormat( 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExtension<&Extensions::textureStorage> ))); - map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA32F_EXT, InternalFormatInfo::LUMAFormat(32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtensions<&Extensions::textureStorage, &Extensions::textureFloat> ))); - map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA16F_EXT, InternalFormatInfo::LUMAFormat(16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, GL_FLOAT, RequireExtensions<&Extensions::textureStorage, &Extensions::textureHalfFloat>))); + // | Internal format | | L | A | Format | Type | Component type | Supported | + map.insert(InternalFormatInfoPair(GL_ALPHA8_EXT, InternalFormatInfo::LUMAFormat( 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_LUMINANCE8_EXT, InternalFormatInfo::LUMAFormat( 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_ALPHA32F_EXT, InternalFormatInfo::LUMAFormat( 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_LUMINANCE32F_EXT, InternalFormatInfo::LUMAFormat(32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_ALPHA16F_EXT, InternalFormatInfo::LUMAFormat( 0, 16, GL_ALPHA, GL_HALF_FLOAT, GL_FLOAT, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_LUMINANCE16F_EXT, InternalFormatInfo::LUMAFormat(16, 0, GL_LUMINANCE, GL_HALF_FLOAT, GL_FLOAT, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_LUMINANCE8_ALPHA8_EXT, InternalFormatInfo::LUMAFormat( 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA32F_EXT, InternalFormatInfo::LUMAFormat(32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_FLOAT, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA16F_EXT, InternalFormatInfo::LUMAFormat(16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, GL_FLOAT, AlwaysSupported))); // Unsized formats - // | Internal format | | Format | Supported | - map.insert(InternalFormatInfoPair(GL_ALPHA, InternalFormatInfo::UnsizedFormat(GL_ALPHA, RequireESVersion<2> ))); - map.insert(InternalFormatInfoPair(GL_LUMINANCE, InternalFormatInfo::UnsizedFormat(GL_LUMINANCE, RequireESVersion<2> ))); - map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA, InternalFormatInfo::UnsizedFormat(GL_LUMINANCE_ALPHA, RequireESVersion<2> ))); - map.insert(InternalFormatInfoPair(GL_RED, InternalFormatInfo::UnsizedFormat(GL_RED, RequireESVersionOrExtension<3, &Extensions::textureRG> ))); - map.insert(InternalFormatInfoPair(GL_RG, InternalFormatInfo::UnsizedFormat(GL_RG, RequireESVersionOrExtension<3, &Extensions::textureRG> ))); - map.insert(InternalFormatInfoPair(GL_RGB, InternalFormatInfo::UnsizedFormat(GL_RGB, RequireESVersion<2> ))); - map.insert(InternalFormatInfoPair(GL_RGBA, InternalFormatInfo::UnsizedFormat(GL_RGBA, RequireESVersion<2> ))); - map.insert(InternalFormatInfoPair(GL_RED_INTEGER, InternalFormatInfo::UnsizedFormat(GL_RED_INTEGER, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RG_INTEGER, InternalFormatInfo::UnsizedFormat(GL_RG_INTEGER, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGB_INTEGER, InternalFormatInfo::UnsizedFormat(GL_RGB_INTEGER, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_RGBA_INTEGER, InternalFormatInfo::UnsizedFormat(GL_RGBA_INTEGER, RequireESVersion<3> ))); - map.insert(InternalFormatInfoPair(GL_BGRA_EXT, InternalFormatInfo::UnsizedFormat(GL_BGRA_EXT, RequireExtension<&Extensions::textureFormatBGRA8888> ))); - map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT, InternalFormatInfo::UnsizedFormat(GL_DEPTH_COMPONENT, RequireESVersion<2> ))); - map.insert(InternalFormatInfoPair(GL_DEPTH_STENCIL, InternalFormatInfo::UnsizedFormat(GL_DEPTH_STENCIL, RequireESVersionOrExtension<3, &Extensions::packedDepthStencil>))); - map.insert(InternalFormatInfoPair(GL_SRGB_EXT, InternalFormatInfo::UnsizedFormat(GL_RGB, RequireESVersionOrExtension<3, &Extensions::sRGB> ))); - map.insert(InternalFormatInfoPair(GL_SRGB_ALPHA_EXT, InternalFormatInfo::UnsizedFormat(GL_RGBA, RequireESVersionOrExtension<3, &Extensions::sRGB> ))); + // | Internal format | | Format | Supported | + map.insert(InternalFormatInfoPair(GL_ALPHA, InternalFormatInfo::UnsizedFormat(GL_ALPHA, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_LUMINANCE, InternalFormatInfo::UnsizedFormat(GL_LUMINANCE, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA, InternalFormatInfo::UnsizedFormat(GL_LUMINANCE_ALPHA, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_RED, InternalFormatInfo::UnsizedFormat(GL_RED, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_RG, InternalFormatInfo::UnsizedFormat(GL_RG, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_RGB, InternalFormatInfo::UnsizedFormat(GL_RGB, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_RGBA, InternalFormatInfo::UnsizedFormat(GL_RGBA, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_RED_INTEGER, InternalFormatInfo::UnsizedFormat(GL_RED_INTEGER, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_RG_INTEGER, InternalFormatInfo::UnsizedFormat(GL_RG_INTEGER, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_RGB_INTEGER, InternalFormatInfo::UnsizedFormat(GL_RGB_INTEGER, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_RGBA_INTEGER, InternalFormatInfo::UnsizedFormat(GL_RGBA_INTEGER, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_BGRA_EXT, InternalFormatInfo::UnsizedFormat(GL_BGRA_EXT, AlwaysSupported))); // Compressed formats, From ES 3.0.1 spec, table 3.16 // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | @@ -705,30 +778,121 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap() map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_UNSIGNED_BYTE, true, UnimplementedSupport))); // From GL_EXT_texture_compression_dxt1 - // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | - map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, InternalFormatInfo::CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, RequireExtension<&Extensions::textureCompressionDXT1>))); - map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, InternalFormatInfo::CompressedFormat(4, 4, 64, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, RequireExtension<&Extensions::textureCompressionDXT1>))); + // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | + map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, InternalFormatInfo::CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, InternalFormatInfo::CompressedFormat(4, 4, 64, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, AlwaysSupported))); // From GL_ANGLE_texture_compression_dxt3 - map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, false, RequireExtension<&Extensions::textureCompressionDXT5>))); + map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, false, AlwaysSupported))); // From GL_ANGLE_texture_compression_dxt5 - map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, false, RequireExtension<&Extensions::textureCompressionDXT5>))); + map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, false, AlwaysSupported))); return map; } -static const InternalFormatInfoMap &GetInternalFormatMap() +static InternalFormatInfoMap BuildES2InternalFormatInfoMap() { - static const InternalFormatInfoMap formatMap = BuildInternalFormatInfoMap(); - return formatMap; + InternalFormatInfoMap map; + + // From ES 2.0.25 table 4.5 + map.insert(InternalFormatInfoPair(GL_NONE, InternalFormatInfo())); + + // | Internal format | | R | G | B | A |S | Format | Type | Component type | SRGB | Color | Texture | Supported | + // | | | | | | | | | | | | renderable | filterable | | + map.insert(InternalFormatInfoPair(GL_RGBA4, InternalFormatInfo::RGBAFormat( 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_RGB5_A1, InternalFormatInfo::RGBAFormat( 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_RGB565, InternalFormatInfo::RGBAFormat( 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported))); + + // Extension formats + map.insert(InternalFormatInfoPair(GL_R8_EXT, InternalFormatInfo::RGBAFormat( 8, 0, 0, 0, 0, GL_RED_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, CheckSupport<&Context::supportsRGTextures, &rx::Renderer::getRGTextureSupport>, CheckSupport<&Context::supportsRGTextures, &rx::Renderer::getRGTextureSupport>, CheckSupport<&Context::supportsRGTextures>))); + map.insert(InternalFormatInfoPair(GL_RG8_EXT, InternalFormatInfo::RGBAFormat( 8, 8, 0, 0, 0, GL_RG_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, CheckSupport<&Context::supportsRGTextures, &rx::Renderer::getRGTextureSupport>, CheckSupport<&Context::supportsRGTextures, &rx::Renderer::getRGTextureSupport>, CheckSupport<&Context::supportsRGTextures>))); + map.insert(InternalFormatInfoPair(GL_RGB8_OES, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_RGBA8_OES, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_BGRA8_EXT, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_BGRA4_ANGLEX, InternalFormatInfo::RGBAFormat( 4, 4, 4, 4, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, NeverSupported, AlwaysSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_BGR5_A1_ANGLEX, InternalFormatInfo::RGBAFormat( 5, 5, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, NeverSupported, AlwaysSupported, AlwaysSupported))); + + // Floating point formats have to query the renderer for support + // | Internal format | | R | G | B | A |S | Format | Type | Comp | SRGB | Color renderable | Texture filterable | Supported | + // | | | | | | | | | | type | | | | | + map.insert(InternalFormatInfoPair(GL_R16F_EXT, InternalFormatInfo::RGBAFormat(16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT_OES, GL_FLOAT, false, CheckSupport<&Context::supportsRGTextures, &rx::Renderer::getRGTextureSupport>, CheckSupport<&Context::supportsRGTextures, &rx::Renderer::getRGTextureSupport>, CheckSupport<&Context::supportsRGTextures> ))); + map.insert(InternalFormatInfoPair(GL_R32F_EXT, InternalFormatInfo::RGBAFormat(32, 0, 0, 0, 0, GL_RED, GL_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsRGTextures, &rx::Renderer::getRGTextureSupport>, CheckSupport<&Context::supportsRGTextures, &rx::Renderer::getRGTextureSupport>, CheckSupport<&Context::supportsRGTextures> ))); + map.insert(InternalFormatInfoPair(GL_RG16F_EXT, InternalFormatInfo::RGBAFormat(16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT_OES, GL_FLOAT, false, CheckSupport<&Context::supportsRGTextures, &rx::Renderer::getRGTextureSupport>, CheckSupport<&Context::supportsRGTextures, &rx::Renderer::getRGTextureSupport>, CheckSupport<&Context::supportsRGTextures> ))); + map.insert(InternalFormatInfoPair(GL_RG32F_EXT, InternalFormatInfo::RGBAFormat(32, 32, 0, 0, 0, GL_RG, GL_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsRGTextures, &rx::Renderer::getRGTextureSupport>, CheckSupport<&Context::supportsRGTextures, &rx::Renderer::getRGTextureSupport>, CheckSupport<&Context::supportsRGTextures> ))); + map.insert(InternalFormatInfoPair(GL_RGB16F_EXT, InternalFormatInfo::RGBAFormat(16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT_OES, GL_FLOAT, false, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, CheckSupport<&Context::supportsFloat16Textures>))); + map.insert(InternalFormatInfoPair(GL_RGB32F_EXT, InternalFormatInfo::RGBAFormat(32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat32RenderableTextures, &rx::Renderer::getFloat32TextureRenderingSupport>, CheckSupport<&Context::supportsFloat32LinearFilter, &rx::Renderer::getFloat32TextureFilteringSupport>, CheckSupport<&Context::supportsFloat32Textures>))); + map.insert(InternalFormatInfoPair(GL_RGBA16F_EXT, InternalFormatInfo::RGBAFormat(16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT_OES, GL_FLOAT, false, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, CheckSupport<&Context::supportsFloat16Textures>))); + map.insert(InternalFormatInfoPair(GL_RGBA32F_EXT, InternalFormatInfo::RGBAFormat(32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat32RenderableTextures, &rx::Renderer::getFloat32TextureRenderingSupport>, CheckSupport<&Context::supportsFloat32LinearFilter, &rx::Renderer::getFloat32TextureFilteringSupport>, CheckSupport<&Context::supportsFloat32Textures>))); + + // Depth and stencil formats + // | Internal format | | D |S |X | Format | Type | Internal format | Depth | Stencil | Supported | + // | | | | | | | | type | renderable | renderable | | + map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32_OES,InternalFormatInfo::DepthStencilFormat(32, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, AlwaysSupported, NeverSupported, CheckSupport<&Context::supportsDepthTextures>))); + map.insert(InternalFormatInfoPair(GL_DEPTH24_STENCIL8_OES, InternalFormatInfo::DepthStencilFormat(24, 8, 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, GL_UNSIGNED_NORMALIZED, AlwaysSupported, AlwaysSupported, CheckSupport<&Context::supportsDepthTextures>))); + map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT16, InternalFormatInfo::DepthStencilFormat(16, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, AlwaysSupported, NeverSupported, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_STENCIL_INDEX8, InternalFormatInfo::DepthStencilFormat( 0, 8, 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, NeverSupported, AlwaysSupported, AlwaysSupported))); + + // Unsized formats + // | Internal format | | Format | Supported | + map.insert(InternalFormatInfoPair(GL_ALPHA, InternalFormatInfo::UnsizedFormat(GL_ALPHA, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_LUMINANCE, InternalFormatInfo::UnsizedFormat(GL_LUMINANCE, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA, InternalFormatInfo::UnsizedFormat(GL_LUMINANCE_ALPHA, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_RED_EXT, InternalFormatInfo::UnsizedFormat(GL_RED_EXT, CheckSupport<&Context::supportsRGTextures>))); + map.insert(InternalFormatInfoPair(GL_RG_EXT, InternalFormatInfo::UnsizedFormat(GL_RG_EXT, CheckSupport<&Context::supportsRGTextures>))); + map.insert(InternalFormatInfoPair(GL_RGB, InternalFormatInfo::UnsizedFormat(GL_RGB, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_RGBA, InternalFormatInfo::UnsizedFormat(GL_RGBA, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_BGRA_EXT, InternalFormatInfo::UnsizedFormat(GL_BGRA_EXT, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT, InternalFormatInfo::UnsizedFormat(GL_DEPTH_COMPONENT, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_DEPTH_STENCIL_OES, InternalFormatInfo::UnsizedFormat(GL_DEPTH_STENCIL_OES, AlwaysSupported))); + + // Luminance alpha formats from GL_EXT_texture_storage + // | Internal format | | L | A | Format | Type | Component type | Supported | + map.insert(InternalFormatInfoPair(GL_ALPHA8_EXT, InternalFormatInfo::LUMAFormat( 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_LUMINANCE8_EXT, InternalFormatInfo::LUMAFormat( 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_ALPHA32F_EXT, InternalFormatInfo::LUMAFormat( 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_LUMINANCE32F_EXT, InternalFormatInfo::LUMAFormat(32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_ALPHA16F_EXT, InternalFormatInfo::LUMAFormat( 0, 16, GL_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_LUMINANCE16F_EXT, InternalFormatInfo::LUMAFormat(16, 0, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_FLOAT, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_LUMINANCE8_ALPHA8_EXT, InternalFormatInfo::LUMAFormat( 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA32F_EXT, InternalFormatInfo::LUMAFormat(32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_FLOAT, AlwaysSupported))); + map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA16F_EXT, InternalFormatInfo::LUMAFormat(16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT, AlwaysSupported))); + + // From GL_EXT_texture_compression_dxt1 + // | Internal format | |W |H | BS |CC|Format | Type | SRGB | Supported | + map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, InternalFormatInfo::CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, CheckSupport<&Context::supportsDXT1Textures>))); + map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, InternalFormatInfo::CompressedFormat(4, 4, 64, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, CheckSupport<&Context::supportsDXT1Textures>))); + + // From GL_ANGLE_texture_compression_dxt3 + map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, false, CheckSupport<&Context::supportsDXT3Textures>))); + + // From GL_ANGLE_texture_compression_dxt5 + map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, false, CheckSupport<&Context::supportsDXT5Textures>))); + + return map; } -static bool GetInternalFormatInfo(GLenum internalFormat, InternalFormatInfo *outFormatInfo) +static bool GetInternalFormatInfo(GLenum internalFormat, GLuint clientVersion, InternalFormatInfo *outFormatInfo) { - const InternalFormatInfoMap &map = GetInternalFormatMap(); - InternalFormatInfoMap::const_iterator iter = map.find(internalFormat); - if (iter != map.end()) + const InternalFormatInfoMap* map = NULL; + + if (clientVersion == 2) + { + static const InternalFormatInfoMap formatMap = BuildES2InternalFormatInfoMap(); + map = &formatMap; + } + else if (clientVersion == 3) + { + static const InternalFormatInfoMap formatMap = BuildES3InternalFormatInfoMap(); + map = &formatMap; + } + else + { + UNREACHABLE(); + } + + InternalFormatInfoMap::const_iterator iter = map->find(internalFormat); + if (iter != map->end()) { if (outFormatInfo) { @@ -742,24 +906,70 @@ static bool GetInternalFormatInfo(GLenum internalFormat, InternalFormatInfo *out } } -static FormatSet BuildAllSizedInternalFormatSet() -{ - FormatSet result; +typedef std::set FormatSet; - const InternalFormatInfoMap &formats = GetInternalFormatMap(); - for (InternalFormatInfoMap::const_iterator i = formats.begin(); i != formats.end(); i++) +static FormatSet BuildES2ValidFormatSet() +{ + static const FormatMap &formatMap = GetFormatMap(2); + + FormatSet set; + + for (FormatMap::const_iterator i = formatMap.begin(); i != formatMap.end(); i++) { - if (i->second.mPixelBits > 0) - { - result.insert(i->first); - } + const FormatTypePair& formatPair = i->first; + set.insert(formatPair.first); } - return result; + return set; +} + +static FormatSet BuildES3ValidFormatSet() +{ + static const ES3FormatSet &formatSet = GetES3FormatSet(); + + FormatSet set; + + for (ES3FormatSet::const_iterator i = formatSet.begin(); i != formatSet.end(); i++) + { + const FormatInfo& formatInfo = *i; + set.insert(formatInfo.mFormat); + } + + return set; } typedef std::set TypeSet; +static TypeSet BuildES2ValidTypeSet() +{ + static const FormatMap &formatMap = GetFormatMap(2); + + TypeSet set; + + for (FormatMap::const_iterator i = formatMap.begin(); i != formatMap.end(); i++) + { + const FormatTypePair& formatPair = i->first; + set.insert(formatPair.second); + } + + return set; +} + +static TypeSet BuildES3ValidTypeSet() +{ + static const ES3FormatSet &formatSet = GetES3FormatSet(); + + TypeSet set; + + for (ES3FormatSet::const_iterator i = formatSet.begin(); i != formatSet.end(); i++) + { + const FormatInfo& formatInfo = *i; + set.insert(formatInfo.mType); + } + + return set; +} + struct EffectiveInternalFormatInfo { GLenum mEffectiveFormat; @@ -827,12 +1037,12 @@ static EffectiveInternalFormatList BuildUnsizedEffectiveInternalFormatList() } static bool GetEffectiveInternalFormat(const InternalFormatInfo &srcFormat, const InternalFormatInfo &destFormat, - GLenum *outEffectiveFormat) + GLuint clientVersion, GLenum *outEffectiveFormat) { const EffectiveInternalFormatList *list = NULL; GLenum targetFormat = GL_NONE; - if (gl::IsSizedInternalFormat(destFormat.mFormat)) + if (gl::IsSizedInternalFormat(destFormat.mFormat, clientVersion)) { static const EffectiveInternalFormatList sizedList = BuildSizedEffectiveInternalFormatList(); list = &sizedList; @@ -922,13 +1132,18 @@ static CopyConversionSet BuildValidES3CopyTexImageCombinations() return set; } -bool IsValidInternalFormat(GLenum internalFormat, const Extensions &extensions, GLuint clientVersion) +bool IsValidInternalFormat(GLenum internalFormat, const Context *context) { + if (!context) + { + return false; + } + InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, context->getClientVersion(), &internalFormatInfo)) { ASSERT(internalFormatInfo.mSupportFunction != NULL); - return internalFormatInfo.mSupportFunction(clientVersion, extensions); + return internalFormatInfo.mSupportFunction(context); } else { @@ -936,54 +1151,51 @@ bool IsValidInternalFormat(GLenum internalFormat, const Extensions &extensions, } } -bool IsValidFormat(GLenum format, const Extensions &extensions, GLuint clientVersion) +bool IsValidFormat(GLenum format, GLuint clientVersion) { - const InternalFormatInfoMap &internalFormats = GetInternalFormatMap(); - for (InternalFormatInfoMap::const_iterator i = internalFormats.begin(); i != internalFormats.end(); i++) + if (clientVersion == 2) { - if (i->second.mFormat == format && i->second.mSupportFunction(clientVersion, extensions)) - { - return true; - } + static const FormatSet formatSet = BuildES2ValidFormatSet(); + return formatSet.find(format) != formatSet.end(); } - - return false; -} - -bool IsValidType(GLenum type, const Extensions &extensions, GLuint clientVersion) -{ - const InternalFormatInfoMap &internalFormats = GetInternalFormatMap(); - for (InternalFormatInfoMap::const_iterator i = internalFormats.begin(); i != internalFormats.end(); i++) + else if (clientVersion == 3) { - if (i->second.mType == type && i->second.mSupportFunction(clientVersion, extensions)) - { - return true; - } - } - - return false; -} - -bool IsValidFormatCombination(GLenum internalFormat, GLenum format, GLenum type, const Extensions &extensions, GLuint clientVersion) -{ - InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) - { - if (!internalFormatInfo.mSupportFunction(clientVersion, extensions)) - { - return false; - } + static const FormatSet formatSet = BuildES3ValidFormatSet(); + return formatSet.find(format) != formatSet.end(); } else { UNREACHABLE(); return false; } +} +bool IsValidType(GLenum type, GLuint clientVersion) +{ if (clientVersion == 2) { - static const FormatMap &formats = GetFormatMap(); + static const TypeSet typeSet = BuildES2ValidTypeSet(); + return typeSet.find(type) != typeSet.end(); + } + else if (clientVersion == 3) + { + static const TypeSet typeSet = BuildES3ValidTypeSet(); + return typeSet.find(type) != typeSet.end(); + } + else + { + UNREACHABLE(); + return false; + } +} + +bool IsValidFormatCombination(GLenum internalFormat, GLenum format, GLenum type, GLuint clientVersion) +{ + if (clientVersion == 2) + { + static const FormatMap &formats = GetFormatMap(clientVersion); FormatMap::const_iterator iter = formats.find(FormatTypePair(format, type)); + return (iter != formats.end()) && ((internalFormat == (GLint)type) || (internalFormat == iter->second.mInternalFormat)); } else if (clientVersion == 3) @@ -1002,8 +1214,8 @@ bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBu { InternalFormatInfo textureInternalFormatInfo; InternalFormatInfo framebufferInternalFormatInfo; - if (GetInternalFormatInfo(textureInternalFormat, &textureInternalFormatInfo) && - GetInternalFormatInfo(frameBufferInternalFormat, &framebufferInternalFormatInfo)) + if (GetInternalFormatInfo(textureInternalFormat, clientVersion, &textureInternalFormatInfo) && + GetInternalFormatInfo(frameBufferInternalFormat, clientVersion, &framebufferInternalFormatInfo)) { if (clientVersion == 2) { @@ -1056,7 +1268,7 @@ bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBu if (readBufferHandle != 0) { // Not the default framebuffer, therefore the read buffer must be a user-created texture or renderbuffer - if (gl::IsSizedInternalFormat(framebufferInternalFormatInfo.mFormat)) + if (gl::IsSizedInternalFormat(framebufferInternalFormatInfo.mFormat, clientVersion)) { sourceEffectiveFormat = framebufferInternalFormatInfo; } @@ -1065,8 +1277,8 @@ bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBu // 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. GLenum effectiveFormat = gl::GetSizedInternalFormat(framebufferInternalFormatInfo.mFormat, - framebufferInternalFormatInfo.mType); - gl::GetInternalFormatInfo(effectiveFormat, &sourceEffectiveFormat); + framebufferInternalFormatInfo.mType, clientVersion); + gl::GetInternalFormatInfo(effectiveFormat, clientVersion, &sourceEffectiveFormat); } } else @@ -1076,9 +1288,9 @@ bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBu if (framebufferInternalFormatInfo.mColorEncoding == GL_LINEAR) { GLenum effectiveFormat; - if (GetEffectiveInternalFormat(framebufferInternalFormatInfo, textureInternalFormatInfo, &effectiveFormat)) + if (GetEffectiveInternalFormat(framebufferInternalFormatInfo, textureInternalFormatInfo, clientVersion, &effectiveFormat)) { - gl::GetInternalFormatInfo(effectiveFormat, &sourceEffectiveFormat); + gl::GetInternalFormatInfo(effectiveFormat, clientVersion, &sourceEffectiveFormat); } else { @@ -1088,13 +1300,13 @@ bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBu else if (framebufferInternalFormatInfo.mColorEncoding == GL_SRGB) { // SRGB buffers can only be copied to sized format destinations according to table 3.18 - if (gl::IsSizedInternalFormat(textureInternalFormat) && + if (gl::IsSizedInternalFormat(textureInternalFormat, clientVersion) && (framebufferInternalFormatInfo.mRedBits >= 1 && framebufferInternalFormatInfo.mRedBits <= 8) && (framebufferInternalFormatInfo.mGreenBits >= 1 && framebufferInternalFormatInfo.mGreenBits <= 8) && (framebufferInternalFormatInfo.mBlueBits >= 1 && framebufferInternalFormatInfo.mBlueBits <= 8) && (framebufferInternalFormatInfo.mAlphaBits >= 1 && framebufferInternalFormatInfo.mAlphaBits <= 8)) { - gl::GetInternalFormatInfo(GL_SRGB8_ALPHA8, &sourceEffectiveFormat); + gl::GetInternalFormatInfo(GL_SRGB8_ALPHA8, clientVersion, &sourceEffectiveFormat); } else { @@ -1107,7 +1319,7 @@ bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBu } } - if (gl::IsSizedInternalFormat(textureInternalFormatInfo.mFormat)) + if (gl::IsSizedInternalFormat(textureInternalFormatInfo.mFormat, clientVersion)) { // 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 @@ -1140,10 +1352,10 @@ bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBu } } -bool IsSizedInternalFormat(GLenum internalFormat) +bool IsSizedInternalFormat(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mPixelBits > 0; } @@ -1154,17 +1366,17 @@ bool IsSizedInternalFormat(GLenum internalFormat) } } -GLenum GetSizedInternalFormat(GLenum format, GLenum type) +GLenum GetSizedInternalFormat(GLenum format, GLenum type, GLuint clientVersion) { - const FormatMap &formats = GetFormatMap(); + const FormatMap &formats = GetFormatMap(clientVersion); FormatMap::const_iterator iter = formats.find(FormatTypePair(format, type)); return (iter != formats.end()) ? iter->second.mInternalFormat : GL_NONE; } -GLuint GetPixelBytes(GLenum internalFormat) +GLuint GetPixelBytes(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mPixelBits / 8; } @@ -1175,10 +1387,10 @@ GLuint GetPixelBytes(GLenum internalFormat) } } -GLuint GetAlphaBits(GLenum internalFormat) +GLuint GetAlphaBits(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mAlphaBits; } @@ -1189,10 +1401,10 @@ GLuint GetAlphaBits(GLenum internalFormat) } } -GLuint GetRedBits(GLenum internalFormat) +GLuint GetRedBits(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mRedBits; } @@ -1203,10 +1415,10 @@ GLuint GetRedBits(GLenum internalFormat) } } -GLuint GetGreenBits(GLenum internalFormat) +GLuint GetGreenBits(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mGreenBits; } @@ -1217,10 +1429,10 @@ GLuint GetGreenBits(GLenum internalFormat) } } -GLuint GetBlueBits(GLenum internalFormat) +GLuint GetBlueBits(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mBlueBits; } @@ -1231,10 +1443,10 @@ GLuint GetBlueBits(GLenum internalFormat) } } -GLuint GetLuminanceBits(GLenum internalFormat) +GLuint GetLuminanceBits(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mLuminanceBits; } @@ -1245,10 +1457,10 @@ GLuint GetLuminanceBits(GLenum internalFormat) } } -GLuint GetDepthBits(GLenum internalFormat) +GLuint GetDepthBits(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mDepthBits; } @@ -1259,10 +1471,10 @@ GLuint GetDepthBits(GLenum internalFormat) } } -GLuint GetStencilBits(GLenum internalFormat) +GLuint GetStencilBits(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mStencilBits; } @@ -1315,10 +1527,10 @@ bool IsFloatOrFixedComponentType(GLenum type) } } -GLenum GetFormat(GLenum internalFormat) +GLenum GetFormat(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mFormat; } @@ -1329,10 +1541,10 @@ GLenum GetFormat(GLenum internalFormat) } } -GLenum GetType(GLenum internalFormat) +GLenum GetType(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mType; } @@ -1343,10 +1555,10 @@ GLenum GetType(GLenum internalFormat) } } -GLenum GetComponentType(GLenum internalFormat) +GLenum GetComponentType(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mComponentType; } @@ -1357,10 +1569,10 @@ GLenum GetComponentType(GLenum internalFormat) } } -GLuint GetComponentCount(GLenum internalFormat) +GLuint GetComponentCount(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mComponentCount; } @@ -1371,10 +1583,10 @@ GLuint GetComponentCount(GLenum internalFormat) } } -GLenum GetColorEncoding(GLenum internalFormat) +GLenum GetColorEncoding(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mColorEncoding; } @@ -1385,21 +1597,133 @@ GLenum GetColorEncoding(GLenum internalFormat) } } -GLuint GetRowPitch(GLenum internalFormat, GLenum type, GLsizei width, GLint alignment) -{ - ASSERT(alignment > 0 && isPow2(alignment)); - return rx::roundUp(GetBlockSize(internalFormat, type, width, 1), static_cast(alignment)); -} - -GLuint GetDepthPitch(GLenum internalFormat, GLenum type, GLsizei width, GLsizei height, GLint alignment) -{ - return GetRowPitch(internalFormat, type, width, alignment) * height; -} - -GLuint GetBlockSize(GLenum internalFormat, GLenum type, GLsizei width, GLsizei height) +bool IsColorRenderingSupported(GLenum internalFormat, const rx::Renderer *renderer) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (renderer && GetInternalFormatInfo(internalFormat, renderer->getCurrentClientVersion(), &internalFormatInfo)) + { + return internalFormatInfo.mIsColorRenderable(NULL, renderer); + } + else + { + UNREACHABLE(); + return false; + } +} + +bool IsColorRenderingSupported(GLenum internalFormat, const Context *context) +{ + InternalFormatInfo internalFormatInfo; + if (context && GetInternalFormatInfo(internalFormat, context->getClientVersion(), &internalFormatInfo)) + { + return internalFormatInfo.mIsColorRenderable(context, NULL); + } + else + { + UNREACHABLE(); + return false; + } +} + +bool IsTextureFilteringSupported(GLenum internalFormat, const rx::Renderer *renderer) +{ + InternalFormatInfo internalFormatInfo; + if (renderer && GetInternalFormatInfo(internalFormat, renderer->getCurrentClientVersion(), &internalFormatInfo)) + { + return internalFormatInfo.mIsTextureFilterable(NULL, renderer); + } + else + { + UNREACHABLE(); + return false; + } +} + +bool IsTextureFilteringSupported(GLenum internalFormat, const Context *context) +{ + InternalFormatInfo internalFormatInfo; + if (context && GetInternalFormatInfo(internalFormat, context->getClientVersion(), &internalFormatInfo)) + { + return internalFormatInfo.mIsTextureFilterable(context, NULL); + } + else + { + UNREACHABLE(); + return false; + } +} + +bool IsDepthRenderingSupported(GLenum internalFormat, const rx::Renderer *renderer) +{ + InternalFormatInfo internalFormatInfo; + if (renderer && GetInternalFormatInfo(internalFormat, renderer->getCurrentClientVersion(), &internalFormatInfo)) + { + return internalFormatInfo.mIsDepthRenderable(NULL, renderer); + } + else + { + UNREACHABLE(); + return false; + } +} + +bool IsDepthRenderingSupported(GLenum internalFormat, const Context *context) +{ + InternalFormatInfo internalFormatInfo; + if (context && GetInternalFormatInfo(internalFormat, context->getClientVersion(), &internalFormatInfo)) + { + return internalFormatInfo.mIsDepthRenderable(context, NULL); + } + else + { + UNREACHABLE(); + return false; + } +} + +bool IsStencilRenderingSupported(GLenum internalFormat, const rx::Renderer *renderer) +{ + InternalFormatInfo internalFormatInfo; + if (renderer && GetInternalFormatInfo(internalFormat, renderer->getCurrentClientVersion(), &internalFormatInfo)) + { + return internalFormatInfo.mIsStencilRenderable(NULL, renderer); + } + else + { + UNREACHABLE(); + return false; + } +} + +bool IsStencilRenderingSupported(GLenum internalFormat, const Context *context) +{ + InternalFormatInfo internalFormatInfo; + if (context && GetInternalFormatInfo(internalFormat, context->getClientVersion(), &internalFormatInfo)) + { + return internalFormatInfo.mIsStencilRenderable(context, NULL); + } + else + { + UNREACHABLE(); + return false; + } +} + +GLuint GetRowPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLint alignment) +{ + ASSERT(alignment > 0 && isPow2(alignment)); + return rx::roundUp(GetBlockSize(internalFormat, type, clientVersion, width, 1), static_cast(alignment)); +} + +GLuint GetDepthPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height, GLint alignment) +{ + return GetRowPitch(internalFormat, type, clientVersion, width, alignment) * height; +} + +GLuint GetBlockSize(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height) +{ + InternalFormatInfo internalFormatInfo; + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { if (internalFormatInfo.mIsCompressed) { @@ -1436,10 +1760,10 @@ GLuint GetBlockSize(GLenum internalFormat, GLenum type, GLsizei width, GLsizei h } } -bool IsFormatCompressed(GLenum internalFormat) +bool IsFormatCompressed(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mIsCompressed; } @@ -1450,10 +1774,10 @@ bool IsFormatCompressed(GLenum internalFormat) } } -GLuint GetCompressedBlockWidth(GLenum internalFormat) +GLuint GetCompressedBlockWidth(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mCompressedBlockWidth; } @@ -1464,10 +1788,10 @@ GLuint GetCompressedBlockWidth(GLenum internalFormat) } } -GLuint GetCompressedBlockHeight(GLenum internalFormat) +GLuint GetCompressedBlockHeight(GLenum internalFormat, GLuint clientVersion) { InternalFormatInfo internalFormatInfo; - if (GetInternalFormatInfo(internalFormat, &internalFormatInfo)) + if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) { return internalFormatInfo.mCompressedBlockHeight; } @@ -1478,15 +1802,9 @@ GLuint GetCompressedBlockHeight(GLenum internalFormat) } } -const FormatSet &GetAllSizedInternalFormats() +ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type, GLuint clientVersion) { - static FormatSet formatSet = BuildAllSizedInternalFormatSet(); - return formatSet; -} - -ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type) -{ - static const FormatMap &formats = GetFormatMap(); + static const FormatMap &formats = GetFormatMap(clientVersion); FormatMap::const_iterator iter = formats.find(FormatTypePair(format, type)); return (iter != formats.end()) ? iter->second.mColorWriteFunction : NULL; } diff --git a/gfx/angle/src/libGLESv2/formatutils.h b/gfx/angle/src/libGLESv2/formatutils.h index 692ab884c372..004c8eda83bb 100644 --- a/gfx/angle/src/libGLESv2/formatutils.h +++ b/gfx/angle/src/libGLESv2/formatutils.h @@ -9,9 +9,10 @@ #ifndef LIBGLESV2_FORMATUTILS_H_ #define LIBGLESV2_FORMATUTILS_H_ -#include "angle_gl.h" +#include +#include +#include -#include "libGLESv2/Caps.h" #include "libGLESv2/angletypes.h" typedef void (*MipGenerationFunction)(unsigned int sourceWidth, unsigned int sourceHeight, unsigned int sourceDepth, @@ -31,52 +32,66 @@ typedef void (*ColorCopyFunction)(const void *source, void *dest); typedef void (*VertexCopyFunction)(const void *input, size_t stride, size_t count, void *output); +namespace rx +{ + +class Renderer; + +} + namespace gl { -typedef std::set FormatSet; +class Context; -bool IsValidInternalFormat(GLenum internalFormat, const Extensions &extensions, GLuint clientVersion); -bool IsValidFormat(GLenum format, const Extensions &extensions, GLuint clientVersion); -bool IsValidType(GLenum type, const Extensions &extensions, GLuint clientVersion); +bool IsValidInternalFormat(GLenum internalFormat, const Context *context); +bool IsValidFormat(GLenum format, GLuint clientVersion); +bool IsValidType(GLenum type, GLuint clientVersion); -bool IsValidFormatCombination(GLenum internalFormat, GLenum format, GLenum type, const Extensions &extensions, GLuint clientVersion); +bool IsValidFormatCombination(GLenum internalFormat, GLenum format, GLenum type, GLuint clientVersion); bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBufferInternalFormat, GLuint readBufferHandle, GLuint clientVersion); -bool IsSizedInternalFormat(GLenum internalFormat); -GLenum GetSizedInternalFormat(GLenum format, GLenum type); +bool IsSizedInternalFormat(GLenum internalFormat, GLuint clientVersion); +GLenum GetSizedInternalFormat(GLenum format, GLenum type, GLuint clientVersion); -GLuint GetPixelBytes(GLenum internalFormat); -GLuint GetAlphaBits(GLenum internalFormat); -GLuint GetRedBits(GLenum internalFormat); -GLuint GetGreenBits(GLenum internalFormat); -GLuint GetBlueBits(GLenum internalFormat); -GLuint GetLuminanceBits(GLenum internalFormat); -GLuint GetDepthBits(GLenum internalFormat); -GLuint GetStencilBits(GLenum internalFormat); +GLuint GetPixelBytes(GLenum internalFormat, GLuint clientVersion); +GLuint GetAlphaBits(GLenum internalFormat, GLuint clientVersion); +GLuint GetRedBits(GLenum internalFormat, GLuint clientVersion); +GLuint GetGreenBits(GLenum internalFormat, GLuint clientVersion); +GLuint GetBlueBits(GLenum internalFormat, GLuint clientVersion); +GLuint GetLuminanceBits(GLenum internalFormat, GLuint clientVersion); +GLuint GetDepthBits(GLenum internalFormat, GLuint clientVersion); +GLuint GetStencilBits(GLenum internalFormat, GLuint clientVersion); GLuint GetTypeBytes(GLenum type); bool IsSpecialInterpretationType(GLenum type); bool IsFloatOrFixedComponentType(GLenum type); -GLenum GetFormat(GLenum internalFormat); -GLenum GetType(GLenum internalFormat); +GLenum GetFormat(GLenum internalFormat, GLuint clientVersion); +GLenum GetType(GLenum internalFormat, GLuint clientVersion); -GLenum GetComponentType(GLenum internalFormat); -GLuint GetComponentCount(GLenum internalFormat); -GLenum GetColorEncoding(GLenum internalFormat); +GLenum GetComponentType(GLenum internalFormat, GLuint clientVersion); +GLuint GetComponentCount(GLenum internalFormat, GLuint clientVersion); +GLenum GetColorEncoding(GLenum internalFormat, GLuint clientVersion); -GLuint GetRowPitch(GLenum internalFormat, GLenum type, GLsizei width, GLint alignment); -GLuint GetDepthPitch(GLenum internalFormat, GLenum type, GLsizei width, GLsizei height, GLint alignment); -GLuint GetBlockSize(GLenum internalFormat, GLenum type, GLsizei width, GLsizei height); +bool IsColorRenderingSupported(GLenum internalFormat, const rx::Renderer *renderer); +bool IsColorRenderingSupported(GLenum internalFormat, const Context *context); +bool IsTextureFilteringSupported(GLenum internalFormat, const rx::Renderer *renderer); +bool IsTextureFilteringSupported(GLenum internalFormat, const Context *context); +bool IsDepthRenderingSupported(GLenum internalFormat, const rx::Renderer *renderer); +bool IsDepthRenderingSupported(GLenum internalFormat, const Context *context); +bool IsStencilRenderingSupported(GLenum internalFormat, const rx::Renderer *renderer); +bool IsStencilRenderingSupported(GLenum internalFormat, const Context *context); -bool IsFormatCompressed(GLenum internalFormat); -GLuint GetCompressedBlockWidth(GLenum internalFormat); -GLuint GetCompressedBlockHeight(GLenum internalFormat); +GLuint GetRowPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLint alignment); +GLuint GetDepthPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height, GLint alignment); +GLuint GetBlockSize(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height); -const FormatSet &GetAllSizedInternalFormats(); +bool IsFormatCompressed(GLenum internalFormat, GLuint clientVersion); +GLuint GetCompressedBlockWidth(GLenum internalFormat, GLuint clientVersion); +GLuint GetCompressedBlockHeight(GLenum internalFormat, GLuint clientVersion); -ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type); +ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type, GLuint clientVersion); } diff --git a/gfx/angle/src/libGLESv2/libGLESv2.cpp b/gfx/angle/src/libGLESv2/libGLESv2.cpp index d58d17180f70..cb9326302ab2 100644 --- a/gfx/angle/src/libGLESv2/libGLESv2.cpp +++ b/gfx/angle/src/libGLESv2/libGLESv2.cpp @@ -22,9 +22,7 @@ #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" @@ -636,7 +634,7 @@ void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, return gl::error(GL_INVALID_OPERATION); } - if (buffer->isMapped()) + if (buffer->mapped()) { return gl::error(GL_INVALID_OPERATION); } @@ -647,7 +645,7 @@ void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, return gl::error(GL_OUT_OF_MEMORY); } - if (size + offset > buffer->getSize()) + if (size + offset > buffer->size()) { return gl::error(GL_INVALID_VALUE); } @@ -846,19 +844,19 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna { if (context->getClientVersion() < 3 && !ValidateES2TexImageParameters(context, target, level, internalformat, true, false, - 0, 0, width, height, border, GL_NONE, GL_NONE, data)) + 0, 0, width, height, 0, 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)) + 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE, data)) { return; } - if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, width, height)) + if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height)) { return gl::error(GL_INVALID_VALUE); } @@ -923,7 +921,7 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs return; } - if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, width, height)) + if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height)) { return gl::error(GL_INVALID_VALUE); } @@ -1579,13 +1577,29 @@ void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count) ANGLE_TRY { + if (count < 0 || first < 0) + { + return gl::error(GL_INVALID_VALUE); + } + gl::Context *context = gl::getNonLostContext(); + // Check for mapped buffers + if (context->hasMappedBuffer(GL_ARRAY_BUFFER)) + { + return gl::error(GL_INVALID_OPERATION); + } + if (context) { - if (!ValidateDrawArrays(context, mode, first, count)) + gl::TransformFeedback *curTransformFeedback = context->getCurrentTransformFeedback(); + if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused() && + curTransformFeedback->getDrawMode() != mode) { - return; + // 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) + return gl::error(GL_INVALID_OPERATION); } context->drawArrays(mode, first, count, 0); @@ -1603,16 +1617,35 @@ void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei coun ANGLE_TRY { - gl::Context *context = gl::getNonLostContext(); - - if (context) + if (count < 0 || first < 0 || primcount < 0) { - if (!ValidateDrawArraysInstanced(context, mode, first, count, primcount)) + return gl::error(GL_INVALID_VALUE); + } + + if (primcount > 0) + { + gl::Context *context = gl::getNonLostContext(); + + // Check for mapped buffers + if (context->hasMappedBuffer(GL_ARRAY_BUFFER)) { - return; + return gl::error(GL_INVALID_OPERATION); } - context->drawArrays(mode, first, count, primcount); + if (context) + { + gl::TransformFeedback *curTransformFeedback = context->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) + return gl::error(GL_INVALID_OPERATION); + } + + context->drawArrays(mode, first, count, primcount); + } } } ANGLE_CATCH_ALL @@ -1628,13 +1661,42 @@ void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLv ANGLE_TRY { + if (count < 0) + { + return gl::error(GL_INVALID_VALUE); + } + gl::Context *context = gl::getNonLostContext(); if (context) { - if (!ValidateDrawElements(context, mode, count, type, indices)) + switch (type) { - return; + case GL_UNSIGNED_BYTE: + case GL_UNSIGNED_SHORT: + break; + case GL_UNSIGNED_INT: + if (!context->supports32bitIndices()) + { + return gl::error(GL_INVALID_ENUM); + } + break; + default: + return gl::error(GL_INVALID_ENUM); + } + + gl::TransformFeedback *curTransformFeedback = context->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) + return gl::error(GL_INVALID_OPERATION); + } + + // Check for mapped buffers + if (context->hasMappedBuffer(GL_ARRAY_BUFFER) || context->hasMappedBuffer(GL_ELEMENT_ARRAY_BUFFER)) + { + return gl::error(GL_INVALID_OPERATION); } context->drawElements(mode, count, type, indices, 0); @@ -1653,16 +1715,48 @@ void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum t ANGLE_TRY { - gl::Context *context = gl::getNonLostContext(); - - if (context) + if (count < 0 || primcount < 0) { - if (!ValidateDrawElementsInstanced(context, mode, count, type, indices, primcount)) - { - return; - } + return gl::error(GL_INVALID_VALUE); + } - context->drawElements(mode, count, type, indices, primcount); + if (primcount > 0) + { + gl::Context *context = gl::getNonLostContext(); + + if (context) + { + switch (type) + { + case GL_UNSIGNED_BYTE: + case GL_UNSIGNED_SHORT: + break; + case GL_UNSIGNED_INT: + if (!context->supports32bitIndices()) + { + return gl::error(GL_INVALID_ENUM); + } + break; + default: + return gl::error(GL_INVALID_ENUM); + } + + gl::TransformFeedback *curTransformFeedback = context->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) + return gl::error(GL_INVALID_OPERATION); + } + + // Check for mapped buffers + if (context->hasMappedBuffer(GL_ARRAY_BUFFER) || context->hasMappedBuffer(GL_ELEMENT_ARRAY_BUFFER)) + { + return gl::error(GL_INVALID_OPERATION); + } + + context->drawElements(mode, count, type, indices, primcount); + } } } ANGLE_CATCH_ALL @@ -1997,34 +2091,23 @@ void __stdcall glGenerateMipmap(GLenum target) } GLenum internalFormat = texture->getBaseLevelInternalFormat(); - const gl::TextureCaps &formatCaps = context->getCaps().textureCaps.get(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; + // Internally, all texture formats are sized so checking if the format + // is color renderable and filterable will not fail. - if (formatCaps.depthRendering || !formatCaps.filtering || (!formatCaps.colorRendering && !isLUMA) || - gl::IsFormatCompressed(internalFormat)) - { - return gl::error(GL_INVALID_OPERATION); - } + bool validRenderable = (gl::IsColorRenderingSupported(internalFormat, context) || + gl::IsSizedInternalFormat(internalFormat, context->getClientVersion())); - // GL_EXT_sRGB does not support mipmap generation on sRGB textures - if (context->getClientVersion() == 2 && gl::GetColorEncoding(internalFormat) == GL_SRGB) + if (gl::IsDepthRenderingSupported(internalFormat, context) || + gl::IsFormatCompressed(internalFormat, context->getClientVersion()) || + !gl::IsTextureFilteringSupported(internalFormat, context) || + !validRenderable) { return gl::error(GL_INVALID_OPERATION); } // Non-power of 2 ES2 check - if (!context->getCaps().extensions.textureNPOT && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight()))) + if (!context->supportsNonPower2Texture() && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight()))) { ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP)); return gl::error(GL_INVALID_OPERATION); @@ -2419,22 +2502,22 @@ void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params switch (pname) { case GL_BUFFER_USAGE: - *params = static_cast(buffer->getUsage()); + *params = static_cast(buffer->usage()); break; case GL_BUFFER_SIZE: - *params = gl::clampCast(buffer->getSize()); + *params = gl::clampCast(buffer->size()); break; case GL_BUFFER_ACCESS_FLAGS: - *params = buffer->getAccessFlags(); + *params = buffer->accessFlags(); break; case GL_BUFFER_MAPPED: - *params = static_cast(buffer->isMapped()); + *params = static_cast(buffer->mapped()); break; case GL_BUFFER_MAP_OFFSET: - *params = gl::clampCast(buffer->getMapOffset()); + *params = gl::clampCast(buffer->mapOffset()); break; case GL_BUFFER_MAP_LENGTH: - *params = gl::clampCast(buffer->getMapLength()); + *params = gl::clampCast(buffer->mapLength()); break; default: UNREACHABLE(); break; } @@ -2550,8 +2633,6 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac return gl::error(GL_INVALID_ENUM); } - int clientVersion = context->getClientVersion(); - switch (pname) { case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: @@ -2559,12 +2640,6 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac 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->getCaps().extensions.sRGB) - { - return gl::error(GL_INVALID_ENUM); - } - break; case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: @@ -2572,12 +2647,12 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: + case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: - if (clientVersion < 3) + if (context->getClientVersion() >= 3) { - return gl::error(GL_INVALID_ENUM); + break; } - break; default: return gl::error(GL_INVALID_ENUM); } @@ -2590,7 +2665,7 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac case GL_DEPTH: case GL_STENCIL: case GL_DEPTH_STENCIL_ATTACHMENT: - if (clientVersion < 3) + if (context->getClientVersion() < 3) { return gl::error(GL_INVALID_ENUM); } @@ -2617,11 +2692,11 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac GLuint attachmentHandle; GLuint attachmentLevel; GLuint attachmentLayer; - const gl::FramebufferAttachment *attachmentObject; + gl::Renderbuffer *renderbuffer; - if (framebufferHandle == 0) + if(framebufferHandle == 0) { - if (clientVersion < 3) + if(context->getClientVersion() < 3) { return gl::error(GL_INVALID_OPERATION); } @@ -2633,21 +2708,21 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac attachmentHandle = framebuffer->getColorbufferHandle(0); attachmentLevel = framebuffer->getColorbufferMipLevel(0); attachmentLayer = framebuffer->getColorbufferLayer(0); - attachmentObject = framebuffer->getColorbuffer(0); + renderbuffer = framebuffer->getColorbuffer(0); break; case GL_DEPTH: attachmentType = framebuffer->getDepthbufferType(); attachmentHandle = framebuffer->getDepthbufferHandle(); attachmentLevel = framebuffer->getDepthbufferMipLevel(); attachmentLayer = framebuffer->getDepthbufferLayer(); - attachmentObject = framebuffer->getDepthbuffer(); + renderbuffer = framebuffer->getDepthbuffer(); break; case GL_STENCIL: attachmentType = framebuffer->getStencilbufferType(); attachmentHandle = framebuffer->getStencilbufferHandle(); attachmentLevel = framebuffer->getStencilbufferMipLevel(); attachmentLayer = framebuffer->getStencilbufferLayer(); - attachmentObject = framebuffer->getStencilbuffer(); + renderbuffer = framebuffer->getStencilbuffer(); break; default: return gl::error(GL_INVALID_OPERATION); @@ -2662,7 +2737,7 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment); attachmentLevel = framebuffer->getColorbufferMipLevel(colorAttachment); attachmentLayer = framebuffer->getColorbufferLayer(colorAttachment); - attachmentObject = framebuffer->getColorbuffer(colorAttachment); + renderbuffer = framebuffer->getColorbuffer(colorAttachment); } else { @@ -2673,14 +2748,14 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac attachmentHandle = framebuffer->getDepthbufferHandle(); attachmentLevel = framebuffer->getDepthbufferMipLevel(); attachmentLayer = framebuffer->getDepthbufferLayer(); - attachmentObject = framebuffer->getDepthbuffer(); + renderbuffer = framebuffer->getDepthbuffer(); break; case GL_STENCIL_ATTACHMENT: attachmentType = framebuffer->getStencilbufferType(); attachmentHandle = framebuffer->getStencilbufferHandle(); attachmentLevel = framebuffer->getStencilbufferMipLevel(); attachmentLayer = framebuffer->getStencilbufferLayer(); - attachmentObject = framebuffer->getStencilbuffer(); + renderbuffer = framebuffer->getStencilbuffer(); break; case GL_DEPTH_STENCIL_ATTACHMENT: if (framebuffer->getDepthbufferHandle() != framebuffer->getStencilbufferHandle()) @@ -2691,7 +2766,7 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac attachmentHandle = framebuffer->getDepthStencilbufferHandle(); attachmentLevel = framebuffer->getDepthStencilbufferMipLevel(); attachmentLayer = framebuffer->getDepthStencilbufferLayer(); - attachmentObject = framebuffer->getDepthStencilBuffer(); + renderbuffer = framebuffer->getDepthStencilBuffer(); break; default: return gl::error(GL_INVALID_OPERATION); @@ -2708,7 +2783,7 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac { attachmentObjectType = attachmentType; } - else if (gl::ValidTexture2DDestinationTarget(context, attachmentType)) + else if (gl::IsInternalTextureTarget(attachmentType, context->getClientVersion())) { attachmentObjectType = GL_TEXTURE; } @@ -2734,7 +2809,7 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac break; case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: - if (clientVersion < 3) + if (context->getClientVersion() < 3) { return gl::error(GL_INVALID_ENUM); } @@ -2742,7 +2817,7 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac break; default: - if (clientVersion < 3) + if (context->getClientVersion() < 3) { return gl::error(GL_INVALID_ENUM); } @@ -2756,7 +2831,7 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac { ASSERT(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE || attachmentObjectType == GL_FRAMEBUFFER_DEFAULT); - ASSERT(attachmentObject != NULL); + ASSERT(renderbuffer != NULL); switch (pname) { @@ -2789,27 +2864,27 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac break; case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: - *params = attachmentObject->getRedSize(); + *params = renderbuffer->getRedSize(); break; case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: - *params = attachmentObject->getGreenSize(); + *params = renderbuffer->getGreenSize(); break; case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: - *params = attachmentObject->getBlueSize(); + *params = renderbuffer->getBlueSize(); break; case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: - *params = attachmentObject->getAlphaSize(); + *params = renderbuffer->getAlphaSize(); break; case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: - *params = attachmentObject->getDepthSize(); + *params = renderbuffer->getDepthSize(); break; case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: - *params = attachmentObject->getStencilSize(); + *params = renderbuffer->getStencilSize(); break; case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: @@ -2817,11 +2892,11 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac { gl::error(GL_INVALID_OPERATION); } - *params = attachmentObject->getComponentType(); + *params = renderbuffer->getComponentType(); break; case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: - *params = attachmentObject->getColorEncoding(); + *params = renderbuffer->getColorEncoding(); break; case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: @@ -3127,11 +3202,14 @@ void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* 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->getCaps().extensions.framebufferMultisample) + if (context->getMaxSupportedSamples() != 0) + { + *params = renderbuffer->getSamples(); + } + else { return gl::error(GL_INVALID_ENUM); } - *params = renderbuffer->getSamples(); break; default: return gl::error(GL_INVALID_ENUM); @@ -3366,7 +3444,7 @@ const GLubyte* __stdcall glGetString(GLenum name) return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")"; } case GL_EXTENSIONS: - return (GLubyte*)((context != NULL) ? context->getExtensionString() : ""); + return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : ""); default: return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL); } @@ -3430,7 +3508,7 @@ void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) *params = (GLfloat)texture->getUsage(); break; case GL_TEXTURE_MAX_ANISOTROPY_EXT: - if (!context->getCaps().extensions.textureFilterAnisotropic) + if (!context->supportsTextureFilterAnisotropy()) { return gl::error(GL_INVALID_ENUM); } @@ -3556,7 +3634,7 @@ void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) *params = texture->getUsage(); break; case GL_TEXTURE_MAX_ANISOTROPY_EXT: - if (!context->getCaps().extensions.textureFilterAnisotropic) + if (!context->supportsTextureFilterAnisotropy()) { return gl::error(GL_INVALID_ENUM); } @@ -3879,7 +3957,7 @@ void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) } else { - *params = gl::QuerySingleVertexAttributeParameter(attribState, pname); + *params = attribState.querySingleParameter(pname); } } } @@ -3922,7 +4000,7 @@ void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) } else { - *params = gl::QuerySingleVertexAttributeParameter(attribState, pname); + *params = attribState.querySingleParameter(pname); } } } @@ -4936,7 +5014,7 @@ void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) case GL_TEXTURE_MIN_FILTER: texture->setMinFilter(gl::uiround(param)); break; case GL_TEXTURE_MAG_FILTER: texture->setMagFilter(gl::uiround(param)); break; case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround(param)); break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy(param, context->getCaps().extensions.maxTextureAnisotropy); break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy(param, context->getTextureMaxAnisotropy()); break; case GL_TEXTURE_COMPARE_MODE: texture->setCompareMode(gl::uiround(param)); break; case GL_TEXTURE_COMPARE_FUNC: texture->setCompareFunc(gl::uiround(param)); break; case GL_TEXTURE_SWIZZLE_R: texture->setSwizzleRed(gl::uiround(param)); break; @@ -4992,7 +5070,7 @@ void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) case GL_TEXTURE_MIN_FILTER: texture->setMinFilter((GLenum)param); break; case GL_TEXTURE_MAG_FILTER: texture->setMagFilter((GLenum)param); break; case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy((float)param, context->getCaps().extensions.maxTextureAnisotropy); break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()); break; case GL_TEXTURE_COMPARE_MODE: texture->setCompareMode((GLenum)param); break; case GL_TEXTURE_COMPARE_FUNC: texture->setCompareFunc((GLenum)param); break; case GL_TEXTURE_SWIZZLE_R: texture->setSwizzleRed((GLenum)param); break; @@ -5029,11 +5107,6 @@ void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalf if (context) { - if (!context->getCaps().extensions.textureStorage) - { - return gl::error(GL_INVALID_OPERATION); - } - if (context->getClientVersion() < 3 && !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height)) { @@ -6045,12 +6118,18 @@ void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GL return gl::error(GL_INVALID_OPERATION); } - if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset, + if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset, x, y, width, height, 0)) { return; } + // Zero sized copies are valid but no-ops + if (width == 0 || height == 0) + { + return; + } + gl::Framebuffer *framebuffer = context->getReadFramebuffer(); gl::Texture *texture = NULL; switch (target) @@ -6094,7 +6173,7 @@ void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum interna return gl::error(GL_INVALID_OPERATION); } - if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, width, height)) + if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height)) { return gl::error(GL_INVALID_VALUE); } @@ -6151,7 +6230,7 @@ void __stdcall glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffs return gl::error(GL_INVALID_OPERATION); } - if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, width, height)) + if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height)) { return gl::error(GL_INVALID_VALUE); } @@ -7456,7 +7535,7 @@ void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) } else { - *params = gl::QuerySingleVertexAttributeParameter(attribState, pname); + *params = attribState.querySingleParameter(pname); } } } @@ -7504,7 +7583,7 @@ void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) } else { - *params = gl::QuerySingleVertexAttributeParameter(attribState, pname); + *params = attribState.querySingleParameter(pname); } } } @@ -7863,9 +7942,9 @@ void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* val if (context) { - if (!ValidateClearBuffer(context)) + if (context->getClientVersion() < 3) { - return; + return gl::error(GL_INVALID_OPERATION); } switch (buffer) @@ -7906,9 +7985,9 @@ void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* v if (context) { - if (!ValidateClearBuffer(context)) + if (context->getClientVersion() < 3) { - return; + return gl::error(GL_INVALID_OPERATION); } switch (buffer) @@ -7943,9 +8022,9 @@ void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* v if (context) { - if (!ValidateClearBuffer(context)) + if (context->getClientVersion() < 3) { - return; + return gl::error(GL_INVALID_OPERATION); } switch (buffer) @@ -7986,9 +8065,9 @@ void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, G if (context) { - if (!ValidateClearBuffer(context)) + if (context->getClientVersion() < 3) { - return; + return gl::error(GL_INVALID_OPERATION); } switch (buffer) @@ -8032,11 +8111,11 @@ const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) return gl::error(GL_INVALID_ENUM, reinterpret_cast(NULL)); } - if (index >= context->getExtensionStringCount()) + if (index >= context->getNumExtensions()) { return gl::error(GL_INVALID_VALUE, reinterpret_cast(NULL)); } - + return reinterpret_cast(context->getExtensionString(index)); } } @@ -8077,14 +8156,14 @@ void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintp return gl::error(GL_INVALID_OPERATION); } - if (readBuffer->isMapped() || writeBuffer->isMapped()) + if (readBuffer->mapped() || writeBuffer->mapped()) { return gl::error(GL_INVALID_OPERATION); } if (readOffset < 0 || writeOffset < 0 || size < 0 || - static_cast(readOffset + size) > readBuffer->getSize() || - static_cast(writeOffset + size) > writeBuffer->getSize()) + static_cast(readOffset + size) > readBuffer->size() || + static_cast(writeOffset + size) > writeBuffer->size()) { return gl::error(GL_INVALID_VALUE); } @@ -8869,22 +8948,22 @@ void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* pa switch (pname) { case GL_BUFFER_USAGE: - *params = static_cast(buffer->getUsage()); + *params = static_cast(buffer->usage()); break; case GL_BUFFER_SIZE: - *params = buffer->getSize(); + *params = buffer->size(); break; case GL_BUFFER_ACCESS_FLAGS: - *params = static_cast(buffer->getAccessFlags()); + *params = static_cast(buffer->accessFlags()); break; case GL_BUFFER_MAPPED: - *params = static_cast(buffer->isMapped()); + *params = static_cast(buffer->mapped()); break; case GL_BUFFER_MAP_OFFSET: - *params = buffer->getMapOffset(); + *params = buffer->mapOffset(); break; case GL_BUFFER_MAP_LENGTH: - *params = buffer->getMapLength(); + *params = buffer->mapLength(); break; default: UNREACHABLE(); break; } @@ -9652,8 +9731,9 @@ void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenu return gl::error(GL_INVALID_OPERATION); } - const gl::TextureCaps &formatCaps = context->getCaps().textureCaps.get(internalformat); - if (!formatCaps.colorRendering && !formatCaps.depthRendering && !formatCaps.stencilRendering) + if (!gl::IsColorRenderingSupported(internalformat, context) && + !gl::IsDepthRenderingSupported(internalformat, context) && + !gl::IsStencilRenderingSupported(internalformat, context)) { return gl::error(GL_INVALID_ENUM); } @@ -9880,6 +9960,11 @@ void __stdcall glGetBufferPointervOES(GLenum target, GLenum pname, void** params if (context) { + if (!context->supportsPBOs()) + { + return gl::error(GL_INVALID_OPERATION); + } + if (!gl::ValidBufferTarget(context, target)) { return gl::error(GL_INVALID_ENUM); @@ -9892,14 +9977,12 @@ void __stdcall glGetBufferPointervOES(GLenum target, GLenum pname, void** params gl::Buffer *buffer = context->getTargetBuffer(target); - if (!buffer || !buffer->isMapped()) + if (!buffer || !buffer->mapped()) { *params = NULL; } - else - { - *params = buffer->getMapPointer(); - } + + *params = buffer->mapPointer(); } } ANGLE_CATCH_ALL @@ -9935,12 +10018,12 @@ void * __stdcall glMapBufferOES(GLenum target, GLenum access) return gl::error(GL_INVALID_ENUM, reinterpret_cast(NULL)); } - if (buffer->isMapped()) + if (buffer->mapped()) { return gl::error(GL_INVALID_OPERATION, reinterpret_cast(NULL)); } - return buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT); + return buffer->mapRange(0, buffer->size(), GL_MAP_WRITE_BIT); } } ANGLE_CATCH_ALL @@ -9968,7 +10051,7 @@ GLboolean __stdcall glUnmapBufferOES(GLenum target) gl::Buffer *buffer = context->getTargetBuffer(target); - if (buffer == NULL || !buffer->isMapped()) + if (buffer == NULL || !buffer->mapped()) { return gl::error(GL_INVALID_OPERATION, GL_FALSE); } @@ -10021,7 +10104,7 @@ void* __stdcall glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr size_t lengthSize = static_cast(length); if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) || - offsetSize + lengthSize > static_cast(buffer->getSize())) + offsetSize + lengthSize > static_cast(buffer->size())) { return gl::error(GL_INVALID_VALUE, reinterpret_cast(NULL)); } @@ -10039,7 +10122,7 @@ void* __stdcall glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr return gl::error(GL_INVALID_VALUE, reinterpret_cast(NULL)); } - if (length == 0 || buffer->isMapped()) + if (length == 0 || buffer->mapped()) { return gl::error(GL_INVALID_OPERATION, reinterpret_cast(NULL)); } @@ -10102,7 +10185,7 @@ void __stdcall glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsi return gl::error(GL_INVALID_OPERATION); } - if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0) + if (!buffer->mapped() || (buffer->accessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0) { return gl::error(GL_INVALID_OPERATION); } @@ -10112,7 +10195,7 @@ void __stdcall glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsi size_t lengthSize = static_cast(length); if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) || - offsetSize + lengthSize > static_cast(buffer->getMapLength())) + offsetSize + lengthSize > static_cast(buffer->mapLength())) { return gl::error(GL_INVALID_VALUE); } diff --git a/gfx/angle/src/libGLESv2/main.cpp b/gfx/angle/src/libGLESv2/main.cpp index 81e70a4286a9..50e2593328d1 100644 --- a/gfx/angle/src/libGLESv2/main.cpp +++ b/gfx/angle/src/libGLESv2/main.cpp @@ -8,41 +8,41 @@ // 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_OUT_OF_INDEXES; +static DWORD currentTLS = TLS_OUT_OF_INDEXES; namespace gl { Current *AllocateCurrent() { - ASSERT(currentTLS != TLS_OUT_OF_INDEXES); - if (currentTLS == TLS_OUT_OF_INDEXES) + Current *current = (Current*)LocalAlloc(LPTR, sizeof(Current)); + + if (!current) { + ERR("Could not allocate thread local storage."); return NULL; } - Current *current = new Current(); + ASSERT(currentTLS != TLS_OUT_OF_INDEXES); + TlsSetValue(currentTLS, current); + current->context = NULL; current->display = NULL; - if (!SetTLSValue(currentTLS, current)) - { - ERR("Could not set thread local storage."); - return NULL; - } - return current; } void DeallocateCurrent() { - Current *current = reinterpret_cast(GetTLSValue(currentTLS)); - SafeDelete(current); - SetTLSValue(currentTLS, NULL); + void *current = TlsGetValue(currentTLS); + + if (current) + { + LocalFree((HLOCAL)current); + } } } @@ -53,13 +53,14 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved { case DLL_PROCESS_ATTACH: { - currentTLS = CreateTLSIndex(); + currentTLS = TlsAlloc(); + if (currentTLS == TLS_OUT_OF_INDEXES) { return FALSE; } } - // Fall through to initialize index + // Fall throught to initialize index case DLL_THREAD_ATTACH: { gl::AllocateCurrent(); @@ -73,7 +74,7 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved case DLL_PROCESS_DETACH: { gl::DeallocateCurrent(); - DestroyTLSIndex(currentTLS); + TlsFree(currentTLS); } break; default: @@ -88,7 +89,7 @@ namespace gl Current *GetCurrentData() { - Current *current = reinterpret_cast(GetTLSValue(currentTLS)); + Current *current = (Current*)TlsGetValue(currentTLS); // ANGLE issue 488: when the dll is loaded after thread initialization, // thread local storage (current) might not exist yet. @@ -118,7 +119,7 @@ Context *getContext() Context *getNonLostContext() { Context *context = getContext(); - + if (context) { if (context->isContextLost()) diff --git a/gfx/angle/src/libGLESv2/moz.build b/gfx/angle/src/libGLESv2/moz.build index 0cda1c8eb9d2..997d0562362a 100644 --- a/gfx/angle/src/libGLESv2/moz.build +++ b/gfx/angle/src/libGLESv2/moz.build @@ -7,7 +7,6 @@ UNIFIED_SOURCES += [ '../common/event_tracer.cpp', '../common/mathutil.cpp', '../common/RefCountObject.cpp', - '../common/tls.cpp', '../common/utilities.cpp', '../compiler/preprocessor/DiagnosticsBase.cpp', '../compiler/preprocessor/DirectiveHandlerBase.cpp', @@ -43,6 +42,7 @@ UNIFIED_SOURCES += [ '../compiler/translator/intermOut.cpp', '../compiler/translator/IntermTraverse.cpp', '../compiler/translator/LoopInfo.cpp', + '../compiler/translator/ossource_win.cpp', '../compiler/translator/OutputESSL.cpp', '../compiler/translator/OutputGLSL.cpp', '../compiler/translator/OutputGLSLBase.cpp', @@ -55,7 +55,6 @@ UNIFIED_SOURCES += [ '../compiler/translator/RewriteElseBlocks.cpp', '../compiler/translator/SearchSymbol.cpp', '../compiler/translator/ShaderLang.cpp', - '../compiler/translator/StructureHLSL.cpp', '../compiler/translator/SymbolTable.cpp', '../compiler/translator/timing/RestrictFragmentShaderTiming.cpp', '../compiler/translator/timing/RestrictVertexShaderTiming.cpp', @@ -65,9 +64,7 @@ UNIFIED_SOURCES += [ '../compiler/translator/Types.cpp', '../compiler/translator/UnfoldShortCircuit.cpp', '../compiler/translator/UnfoldShortCircuitAST.cpp', - '../compiler/translator/UniformHLSL.cpp', '../compiler/translator/util.cpp', - '../compiler/translator/UtilsHLSL.cpp', '../compiler/translator/ValidateLimitations.cpp', '../compiler/translator/ValidateOutputs.cpp', '../compiler/translator/VariableInfo.cpp', @@ -78,14 +75,12 @@ UNIFIED_SOURCES += [ '../third_party/systeminfo/SystemInfo.cpp', 'angletypes.cpp', 'Buffer.cpp', - 'Caps.cpp', 'Context.cpp', 'DynamicHLSL.cpp', 'Fence.cpp', 'Float16ToFloat32.cpp', 'formatutils.cpp', 'Framebuffer.cpp', - 'FramebufferAttachment.cpp', 'HandleAllocator.cpp', 'libGLESv2.cpp', 'main.cpp', @@ -95,33 +90,34 @@ UNIFIED_SOURCES += [ 'Query.cpp', 'queryconversions.cpp', 'Renderbuffer.cpp', + 'RenderbufferProxySet.cpp', + 'renderer/BufferStorage.cpp', 'renderer/copyimage.cpp', - 'renderer/d3d/BufferD3D.cpp', - 'renderer/d3d/d3d9/Blit9.cpp', - 'renderer/d3d/d3d9/Buffer9.cpp', - 'renderer/d3d/d3d9/Fence9.cpp', - 'renderer/d3d/d3d9/formatutils9.cpp', - 'renderer/d3d/d3d9/Image9.cpp', - 'renderer/d3d/d3d9/IndexBuffer9.cpp', - 'renderer/d3d/d3d9/Query9.cpp', - 'renderer/d3d/d3d9/Renderer9.cpp', - 'renderer/d3d/d3d9/renderer9_utils.cpp', - 'renderer/d3d/d3d9/RenderTarget9.cpp', - 'renderer/d3d/d3d9/ShaderExecutable9.cpp', - 'renderer/d3d/d3d9/SwapChain9.cpp', - 'renderer/d3d/d3d9/TextureStorage9.cpp', - 'renderer/d3d/d3d9/VertexBuffer9.cpp', - 'renderer/d3d/d3d9/VertexDeclarationCache.cpp', 'renderer/d3d/HLSLCompiler.cpp', - 'renderer/d3d/IndexBuffer.cpp', - 'renderer/d3d/IndexDataManager.cpp', - 'renderer/d3d/VertexBuffer.cpp', - 'renderer/d3d/VertexDataManager.cpp', + 'renderer/d3d9/Blit9.cpp', + 'renderer/d3d9/BufferStorage9.cpp', + 'renderer/d3d9/Fence9.cpp', + 'renderer/d3d9/formatutils9.cpp', + 'renderer/d3d9/Image9.cpp', + 'renderer/d3d9/IndexBuffer9.cpp', + 'renderer/d3d9/Query9.cpp', + 'renderer/d3d9/Renderer9.cpp', + 'renderer/d3d9/renderer9_utils.cpp', + 'renderer/d3d9/RenderTarget9.cpp', + 'renderer/d3d9/ShaderExecutable9.cpp', + 'renderer/d3d9/SwapChain9.cpp', + 'renderer/d3d9/TextureStorage9.cpp', + 'renderer/d3d9/VertexBuffer9.cpp', + 'renderer/d3d9/VertexDeclarationCache.cpp', 'renderer/Image.cpp', + 'renderer/IndexBuffer.cpp', + 'renderer/IndexDataManager.cpp', 'renderer/IndexRangeCache.cpp', 'renderer/loadimage.cpp', 'renderer/Renderer.cpp', 'renderer/TextureStorage.cpp', + 'renderer/VertexBuffer.cpp', + 'renderer/VertexDataManager.cpp', 'ResourceManager.cpp', 'Sampler.cpp', 'Shader.cpp', @@ -132,7 +128,6 @@ UNIFIED_SOURCES += [ 'validationES2.cpp', 'validationES3.cpp', 'VertexArray.cpp', - 'VertexAttribute.cpp', ] SOURCES += [ '../compiler/translator/glslang_lex.cpp', @@ -142,24 +137,24 @@ SOURCES += [ SOURCES['renderer/loadimageSSE2.cpp'].flags += CONFIG['SSE2_FLAGS'] if CONFIG['MOZ_HAS_WINSDK_WITH_D3D']: UNIFIED_SOURCES += [ - 'renderer/d3d/d3d11/Blit11.cpp', - 'renderer/d3d/d3d11/Buffer11.cpp', - 'renderer/d3d/d3d11/Clear11.cpp', - 'renderer/d3d/d3d11/Fence11.cpp', - 'renderer/d3d/d3d11/formatutils11.cpp', - 'renderer/d3d/d3d11/Image11.cpp', - 'renderer/d3d/d3d11/IndexBuffer11.cpp', - 'renderer/d3d/d3d11/InputLayoutCache.cpp', - 'renderer/d3d/d3d11/PixelTransfer11.cpp', - 'renderer/d3d/d3d11/Query11.cpp', - 'renderer/d3d/d3d11/Renderer11.cpp', - 'renderer/d3d/d3d11/renderer11_utils.cpp', - 'renderer/d3d/d3d11/RenderStateCache.cpp', - 'renderer/d3d/d3d11/RenderTarget11.cpp', - 'renderer/d3d/d3d11/ShaderExecutable11.cpp', - 'renderer/d3d/d3d11/SwapChain11.cpp', - 'renderer/d3d/d3d11/TextureStorage11.cpp', - 'renderer/d3d/d3d11/VertexBuffer11.cpp', + 'renderer/d3d11/Blit11.cpp', + 'renderer/d3d11/BufferStorage11.cpp', + 'renderer/d3d11/Clear11.cpp', + 'renderer/d3d11/Fence11.cpp', + 'renderer/d3d11/formatutils11.cpp', + 'renderer/d3d11/Image11.cpp', + 'renderer/d3d11/IndexBuffer11.cpp', + 'renderer/d3d11/InputLayoutCache.cpp', + 'renderer/d3d11/PixelTransfer11.cpp', + 'renderer/d3d11/Query11.cpp', + 'renderer/d3d11/Renderer11.cpp', + 'renderer/d3d11/renderer11_utils.cpp', + 'renderer/d3d11/RenderStateCache.cpp', + 'renderer/d3d11/RenderTarget11.cpp', + 'renderer/d3d11/ShaderExecutable11.cpp', + 'renderer/d3d11/SwapChain11.cpp', + 'renderer/d3d11/TextureStorage11.cpp', + 'renderer/d3d11/VertexBuffer11.cpp', ] diff --git a/gfx/angle/src/libGLESv2/precompiled.h b/gfx/angle/src/libGLESv2/precompiled.h index 51a13ccdd4fa..3bc66a1d41e1 100644 --- a/gfx/angle/src/libGLESv2/precompiled.h +++ b/gfx/angle/src/libGLESv2/precompiled.h @@ -6,7 +6,12 @@ // precompiled.h: Precompiled header file for libGLESv2. -#include "angle_gl.h" +#include +#include +#include + +#include + #include #include @@ -28,3 +33,16 @@ #include #include #include + +#if defined(ANGLE_ENABLE_D3D9) +#include +#include +#endif // ANGLE_ENABLE_D3D9 + +#if defined(ANGLE_ENABLE_D3D11) +#include +#include +#include +#include +#include +#endif // ANGLE_ENABLE_D3D11 diff --git a/gfx/angle/src/libGLESv2/renderer/BufferImpl.h b/gfx/angle/src/libGLESv2/renderer/BufferImpl.h deleted file mode 100644 index 125341483f02..000000000000 --- a/gfx/angle/src/libGLESv2/renderer/BufferImpl.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. -// - -// 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" - -namespace rx -{ - -class BufferImpl -{ - public: - virtual void setData(const void* data, size_t size, GLenum usage) = 0; - virtual void *getData() = 0; - virtual void setSubData(const void* data, size_t size, size_t offset) = 0; - virtual void copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) = 0; - virtual GLvoid* map(size_t offset, size_t length, GLbitfield access) = 0; - virtual void unmap() = 0; - virtual void markTransformFeedbackUsage() = 0; -}; - -} - -#endif // LIBGLESV2_RENDERER_BUFFERIMPL_H_ diff --git a/gfx/angle/src/libGLESv2/renderer/BufferStorage.cpp b/gfx/angle/src/libGLESv2/renderer/BufferStorage.cpp new file mode 100644 index 000000000000..4d245f89daa6 --- /dev/null +++ b/gfx/angle/src/libGLESv2/renderer/BufferStorage.cpp @@ -0,0 +1,36 @@ +#include "precompiled.h" +// +// 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. +// + +// BufferStorage.cpp Defines the abstract BufferStorage class. + +#include "libGLESv2/renderer/BufferStorage.h" + +namespace rx +{ + +unsigned int BufferStorage::mNextSerial = 1; + +BufferStorage::BufferStorage() +{ + updateSerial(); +} + +BufferStorage::~BufferStorage() +{ +} + +unsigned int BufferStorage::getSerial() const +{ + return mSerial; +} + +void BufferStorage::updateSerial() +{ + mSerial = mNextSerial++; +} + +} diff --git a/gfx/angle/src/libGLESv2/renderer/BufferStorage.h b/gfx/angle/src/libGLESv2/renderer/BufferStorage.h new file mode 100644 index 000000000000..a5f95d1eb79d --- /dev/null +++ b/gfx/angle/src/libGLESv2/renderer/BufferStorage.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. +// + +// BufferStorage.h Defines the abstract BufferStorage class. + +#ifndef LIBGLESV2_RENDERER_BUFFERSTORAGE_H_ +#define LIBGLESV2_RENDERER_BUFFERSTORAGE_H_ + +#include "common/angleutils.h" + +namespace rx +{ + +class BufferStorage +{ + public: + BufferStorage(); + virtual ~BufferStorage(); + + // The data returned is only guaranteed valid until next non-const method. + virtual void *getData() = 0; + virtual void setData(const void* data, size_t size, size_t offset) = 0; + virtual void copyData(BufferStorage* sourceStorage, size_t size, size_t sourceOffset, size_t destOffset) = 0; + virtual void clear() = 0; + virtual void markTransformFeedbackUsage() = 0; + virtual size_t getSize() const = 0; + virtual bool supportsDirectBinding() const = 0; + unsigned int getSerial() const; + + virtual bool isMapped() const = 0; + virtual void *map(GLbitfield access) = 0; + virtual void unmap() = 0; + + protected: + void updateSerial(); + + private: + DISALLOW_COPY_AND_ASSIGN(BufferStorage); + + unsigned int mSerial; + static unsigned int mNextSerial; +}; + +} + +#endif // LIBGLESV2_RENDERER_BUFFERSTORAGE_H_ diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/IndexBuffer.cpp b/gfx/angle/src/libGLESv2/renderer/IndexBuffer.cpp similarity index 98% rename from gfx/angle/src/libGLESv2/renderer/d3d/IndexBuffer.cpp rename to gfx/angle/src/libGLESv2/renderer/IndexBuffer.cpp index 13e35e09ec46..7fe2a3abe7ca 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/IndexBuffer.cpp +++ b/gfx/angle/src/libGLESv2/renderer/IndexBuffer.cpp @@ -8,7 +8,7 @@ // 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/IndexBuffer.h" #include "libGLESv2/renderer/Renderer.h" namespace rx diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/IndexBuffer.h b/gfx/angle/src/libGLESv2/renderer/IndexBuffer.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/IndexBuffer.h rename to gfx/angle/src/libGLESv2/renderer/IndexBuffer.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/IndexDataManager.cpp b/gfx/angle/src/libGLESv2/renderer/IndexDataManager.cpp similarity index 94% rename from gfx/angle/src/libGLESv2/renderer/d3d/IndexDataManager.cpp rename to gfx/angle/src/libGLESv2/renderer/IndexDataManager.cpp index 932524c1321a..b8c7fa977c08 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/IndexDataManager.cpp +++ b/gfx/angle/src/libGLESv2/renderer/IndexDataManager.cpp @@ -8,13 +8,13 @@ // 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/IndexDataManager.h" +#include "libGLESv2/renderer/BufferStorage.h" #include "libGLESv2/Buffer.h" #include "libGLESv2/main.h" #include "libGLESv2/formatutils.h" -#include "libGLESv2/renderer/d3d/IndexBuffer.h" +#include "libGLESv2/renderer/IndexBuffer.h" namespace rx { @@ -118,7 +118,7 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer unsigned int offset = 0; bool alignedOffset = false; - BufferD3D *storage = NULL; + BufferStorage *storage = NULL; if (buffer != NULL) { @@ -128,7 +128,7 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer } offset = static_cast(reinterpret_cast(indices)); - storage = BufferD3D::makeBufferD3D(buffer->getImplementation()); + storage = buffer->getStorage(); switch (type) { @@ -157,7 +157,7 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer StreamingIndexBufferInterface *streamingBuffer = (type == GL_UNSIGNED_INT) ? mStreamingBufferInt : mStreamingBufferShort; - StaticIndexBufferInterface *staticBuffer = storage ? storage->getStaticIndexBuffer() : NULL; + StaticIndexBufferInterface *staticBuffer = buffer ? buffer->getStaticIndexBuffer() : NULL; IndexBufferInterface *indexBuffer = streamingBuffer; bool directStorage = alignedOffset && storage && storage->supportsDirectBinding() && destinationIndexType == type; @@ -168,11 +168,11 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer indexBuffer = streamingBuffer; streamOffset = offset; - if (!storage->getIndexRangeCache()->findRange(type, offset, count, &translated->minIndex, + if (!buffer->getIndexRangeCache()->findRange(type, offset, count, &translated->minIndex, &translated->maxIndex, NULL)) { computeRange(type, indices, count, &translated->minIndex, &translated->maxIndex); - storage->getIndexRangeCache()->addRange(type, offset, count, translated->minIndex, + buffer->getIndexRangeCache()->addRange(type, offset, count, translated->minIndex, translated->maxIndex, offset); } } @@ -202,7 +202,7 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer } else { - storage->invalidateStaticData(); + buffer->invalidateStaticData(); staticBuffer = NULL; } } @@ -258,9 +258,9 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer translated->startIndex = streamOffset / gl::GetTypeBytes(destinationIndexType); translated->startOffset = streamOffset; - if (storage) + if (buffer) { - storage->promoteStaticUsage(count * gl::GetTypeBytes(type)); + buffer->promoteStaticUsage(count * gl::GetTypeBytes(type)); } return GL_NO_ERROR; diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/IndexDataManager.h b/gfx/angle/src/libGLESv2/renderer/IndexDataManager.h similarity index 96% rename from gfx/angle/src/libGLESv2/renderer/d3d/IndexDataManager.h rename to gfx/angle/src/libGLESv2/renderer/IndexDataManager.h index 8f981936eadf..0e77c81d1bba 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/IndexDataManager.h +++ b/gfx/angle/src/libGLESv2/renderer/IndexDataManager.h @@ -27,7 +27,7 @@ namespace rx class StaticIndexBufferInterface; class StreamingIndexBufferInterface; class IndexBuffer; -class BufferD3D; +class BufferStorage; class Renderer; struct TranslatedIndexData @@ -38,7 +38,7 @@ struct TranslatedIndexData unsigned int startOffset; // In bytes IndexBuffer *indexBuffer; - BufferD3D *storage; + BufferStorage *storage; unsigned int serial; }; diff --git a/gfx/angle/src/libGLESv2/renderer/Renderer.cpp b/gfx/angle/src/libGLESv2/renderer/Renderer.cpp index eb5e2fe3ad0c..92594a4d5664 100644 --- a/gfx/angle/src/libGLESv2/renderer/Renderer.cpp +++ b/gfx/angle/src/libGLESv2/renderer/Renderer.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" // -// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -16,11 +16,11 @@ #include "libGLESv2/Shader.h" #if defined (ANGLE_ENABLE_D3D9) -#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h" +#include "libGLESv2/renderer/d3d9/Renderer9.h" #endif // ANGLE_ENABLE_D3D9 #if defined (ANGLE_ENABLE_D3D11) -#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h" +#include "libGLESv2/renderer/d3d11/Renderer11.h" #endif // ANGLE_ENABLE_D3D11 #if !defined(ANGLE_DEFAULT_D3D11) @@ -31,11 +31,9 @@ namespace rx { -Renderer::Renderer(egl::Display *display) - : mDisplay(display), - mCapsInitialized(false), - mCurrentClientVersion(2) +Renderer::Renderer(egl::Display *display) : mDisplay(display) { + mCurrentClientVersion = 2; } Renderer::~Renderer() @@ -43,17 +41,6 @@ Renderer::~Renderer() gl::Shader::releaseCompiler(); } -const gl::Caps &Renderer::getCaps() const -{ - if (!mCapsInitialized) - { - mCaps = generateCaps(); - mCapsInitialized = true; - } - - return mCaps; -} - } extern "C" diff --git a/gfx/angle/src/libGLESv2/renderer/Renderer.h b/gfx/angle/src/libGLESv2/renderer/Renderer.h index 818fddd7defd..b2a05d92d2c2 100644 --- a/gfx/angle/src/libGLESv2/renderer/Renderer.h +++ b/gfx/angle/src/libGLESv2/renderer/Renderer.h @@ -12,7 +12,6 @@ #include "libGLESv2/Uniform.h" #include "libGLESv2/angletypes.h" -#include "libGLESv2/Caps.h" #if !defined(ANGLE_COMPILE_OPTIMIZATION_LEVEL) // WARNING: D3DCOMPILE_OPTIMIZATION_LEVEL3 may lead to a DX9 shader compiler hang. @@ -30,7 +29,7 @@ namespace gl class InfoLog; class ProgramBinary; struct LinkedVarying; -struct VertexAttribute; +class VertexAttribute; class Buffer; class Texture; class Framebuffer; @@ -47,8 +46,6 @@ class VertexBuffer; class IndexBuffer; class QueryImpl; class FenceImpl; -class BufferImpl; -class VertexArrayImpl; class BufferStorage; struct TranslatedIndexData; class ShaderExecutable; @@ -120,8 +117,7 @@ class Renderer bool ignoreViewport) = 0; virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer) = 0; - virtual void applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer, - bool rasterizerDiscard, bool transformFeedbackActive) = 0; + virtual void applyShaders(gl::ProgramBinary *programBinary, bool rasterizerDiscard, bool transformFeedbackActive, const gl::VertexFormat inputLayout[]) = 0; virtual void applyUniforms(const gl::ProgramBinary &programBinary) = 0; virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount) = 0; virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], gl::VertexAttribCurrentValueData currentValues[], @@ -143,13 +139,26 @@ class Renderer virtual bool testDeviceLost(bool notify) = 0; virtual bool testDeviceResettable() = 0; - // Renderer capabilities (virtual because it is used by egl::Display, do not override) - virtual const gl::Caps &getCaps() const; - + // Renderer capabilities virtual DWORD getAdapterVendor() const = 0; virtual std::string getRendererDescription() const = 0; virtual GUID getAdapterIdentifier() const = 0; + virtual bool getBGRATextureSupport() const = 0; + virtual bool getDXT1TextureSupport() const = 0; + virtual bool getDXT3TextureSupport() const = 0; + virtual bool getDXT5TextureSupport() const = 0; + virtual bool getEventQuerySupport() const = 0; + virtual bool getFloat32TextureSupport() const = 0; + virtual bool getFloat32TextureFilteringSupport() const= 0; + virtual bool getFloat32TextureRenderingSupport() const= 0; + virtual bool getFloat16TextureSupport() const= 0; + virtual bool getFloat16TextureFilteringSupport() const= 0; + virtual bool getFloat16TextureRenderingSupport() const = 0; + virtual bool getRGB565TextureSupport() const = 0; + virtual bool getLuminanceTextureSupport() const = 0; + virtual bool getLuminanceAlphaTextureSupport() const = 0; + virtual bool getRGTextureSupport() const = 0; bool getVertexTextureSupport() const { return getMaxVertexTextureImageUnits() > 0; } virtual unsigned int getMaxVertexTextureImageUnits() const = 0; virtual unsigned int getMaxCombinedTextureImageUnits() const = 0; @@ -166,11 +175,18 @@ class Renderer virtual unsigned int getMaxTransformFeedbackSeparateComponents() const = 0; virtual unsigned int getMaxTransformFeedbackInterleavedComponents() const = 0; virtual unsigned int getMaxUniformBufferSize() const = 0; + virtual bool getNonPower2TextureSupport() const = 0; + virtual bool getDepthTextureSupport() const = 0; + virtual bool getOcclusionQuerySupport() const = 0; + virtual bool getInstancingSupport() const = 0; + virtual bool getTextureFilterAnisotropySupport() const = 0; + virtual bool getPBOSupport() const = 0; + virtual float getTextureMaxAnisotropy() const = 0; virtual bool getShareHandleSupport() const = 0; + virtual bool getDerivativeInstructionSupport() const = 0; virtual bool getPostSubBufferSupport() const = 0; virtual int getMaxRecommendedElementsIndices() const = 0; virtual int getMaxRecommendedElementsVertices() const = 0; - virtual bool getSRGBTextureSupport() const = 0; virtual int getMajorShaderModel() const = 0; virtual float getMaxPointSize() const = 0; @@ -179,6 +195,7 @@ class Renderer virtual int getMaxTextureHeight() const = 0; virtual int getMaxTextureDepth() const = 0; virtual int getMaxTextureArrayLayers() const = 0; + virtual bool get32BitIndexSupport() const = 0; virtual int getMinSwapInterval() const = 0; virtual int getMaxSwapInterval() const = 0; @@ -232,12 +249,9 @@ class Renderer virtual TextureStorage *createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels) = 0; // Buffer creation - virtual BufferImpl *createBuffer() = 0; virtual VertexBuffer *createVertexBuffer() = 0; virtual IndexBuffer *createIndexBuffer() = 0; - - // Vertex Array creation - virtual VertexArrayImpl *createVertexArray() = 0; + virtual BufferStorage *createBufferStorage() = 0; // Query and Fence creation virtual QueryImpl *createQuery(GLenum type) = 0; @@ -263,11 +277,6 @@ class Renderer private: DISALLOW_COPY_AND_ASSIGN(Renderer); - virtual gl::Caps generateCaps() const = 0; - - mutable bool mCapsInitialized; - mutable gl::Caps mCaps; - int mCurrentClientVersion; }; diff --git a/gfx/angle/src/libGLESv2/renderer/VertexArrayImpl.h b/gfx/angle/src/libGLESv2/renderer/VertexArrayImpl.h deleted file mode 100644 index 93f34e41ecd7..000000000000 --- a/gfx/angle/src/libGLESv2/renderer/VertexArrayImpl.h +++ /dev/null @@ -1,30 +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 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/gfx/angle/src/libGLESv2/renderer/d3d/VertexBuffer.cpp b/gfx/angle/src/libGLESv2/renderer/VertexBuffer.cpp similarity index 82% rename from gfx/angle/src/libGLESv2/renderer/d3d/VertexBuffer.cpp rename to gfx/angle/src/libGLESv2/renderer/VertexBuffer.cpp index 901ca196a8ed..8adfb5bfa745 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/VertexBuffer.cpp +++ b/gfx/angle/src/libGLESv2/renderer/VertexBuffer.cpp @@ -8,10 +8,10 @@ // 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/VertexBuffer.h" #include "libGLESv2/renderer/Renderer.h" #include "libGLESv2/VertexAttribute.h" -#include "libGLESv2/renderer/d3d/BufferD3D.h" +#include "libGLESv2/renderer/BufferStorage.h" #include "common/mathutil.h" namespace rx @@ -127,10 +127,10 @@ bool VertexBufferInterface::storeVertexAttributes(const gl::VertexAttribute &att return true; } -bool VertexBufferInterface::reserveVertexSpace(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances) +bool VertexBufferInterface::reserveVertexSpace(const gl::VertexAttribute &attribute, GLsizei count, GLsizei instances) { unsigned int requiredSpace; - if (!mVertexBuffer->getSpaceRequired(attrib, count, instances, &requiredSpace)) + if (!mVertexBuffer->getSpaceRequired(attribute, count, instances, &requiredSpace)) { return false; } @@ -157,8 +157,8 @@ VertexBuffer* VertexBufferInterface::getVertexBuffer() const bool VertexBufferInterface::directStoragePossible(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData ¤tValue) const { - gl::Buffer *buffer = attrib.buffer.get(); - BufferD3D *storage = buffer ? BufferD3D::makeBufferD3D(buffer->getImplementation()) : NULL; + gl::Buffer *buffer = attrib.mBoundBuffer.get(); + BufferStorage *storage = buffer ? buffer->getStorage() : NULL; if (!storage || !storage->supportsDirectBinding()) { @@ -171,7 +171,7 @@ bool VertexBufferInterface::directStoragePossible(const gl::VertexAttribute &att size_t alignment = 4; bool requiresConversion = false; - if (attrib.type != GL_FLOAT) + if (attrib.mType != GL_FLOAT) { gl::VertexFormat vertexFormat(attrib, currentValue.Type); @@ -182,8 +182,8 @@ bool VertexBufferInterface::directStoragePossible(const gl::VertexAttribute &att requiresConversion = (mRenderer->getVertexConversionType(vertexFormat) & VERTEX_CONVERT_CPU) != 0; } - bool isAligned = (static_cast(ComputeVertexAttributeStride(attrib)) % alignment == 0) && - (static_cast(attrib.offset) % alignment == 0); + bool isAligned = (static_cast(attrib.stride()) % alignment == 0) && + (static_cast(attrib.mOffset) % alignment == 0); return !requiresConversion && isAligned; } @@ -226,18 +226,17 @@ StaticVertexBufferInterface::~StaticVertexBufferInterface() { } -bool StaticVertexBufferInterface::lookupAttribute(const gl::VertexAttribute &attrib, unsigned int *outStreamOffset) +bool StaticVertexBufferInterface::lookupAttribute(const gl::VertexAttribute &attribute, 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) + if (mCache[element].type == attribute.mType && + mCache[element].size == attribute.mSize && + mCache[element].stride == attribute.stride() && + mCache[element].normalized == attribute.mNormalized && + mCache[element].pureInteger == attribute.mPureInteger) { - size_t offset = (static_cast(attrib.offset) % ComputeVertexAttributeStride(attrib)); - if (mCache[element].attributeOffset == offset) + if (mCache[element].attributeOffset == attribute.mOffset % attribute.stride()) { if (outStreamOffset) { @@ -276,8 +275,8 @@ bool StaticVertexBufferInterface::storeVertexAttributes(const gl::VertexAttribut unsigned int streamOffset; if (VertexBufferInterface::storeVertexAttributes(attrib, currentValue, start, count, instances, &streamOffset)) { - size_t attributeOffset = static_cast(attrib.offset) % ComputeVertexAttributeStride(attrib); - VertexElement element = { attrib.type, attrib.size, ComputeVertexAttributeStride(attrib), attrib.normalized, attrib.pureInteger, attributeOffset, streamOffset }; + int attributeOffset = attrib.mOffset % attrib.stride(); + VertexElement element = { attrib.mType, attrib.mSize, attrib.stride(), attrib.mNormalized, attrib.mPureInteger, attributeOffset, streamOffset }; mCache.push_back(element); if (outStreamOffset) diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/VertexBuffer.h b/gfx/angle/src/libGLESv2/renderer/VertexBuffer.h similarity index 93% rename from gfx/angle/src/libGLESv2/renderer/d3d/VertexBuffer.h rename to gfx/angle/src/libGLESv2/renderer/VertexBuffer.h index c5022d8c9c6a..d4cdf9ee8522 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/VertexBuffer.h +++ b/gfx/angle/src/libGLESv2/renderer/VertexBuffer.h @@ -14,7 +14,7 @@ namespace gl { -struct VertexAttribute; +class VertexAttribute; struct VertexAttribCurrentValueData; } @@ -110,7 +110,7 @@ class StaticVertexBufferInterface : public VertexBufferInterface ~StaticVertexBufferInterface(); bool storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData ¤tValue, - GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset); + GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset); bool lookupAttribute(const gl::VertexAttribute &attribute, unsigned int* outStreamFffset); @@ -121,11 +121,11 @@ class StaticVertexBufferInterface : public VertexBufferInterface struct VertexElement { GLenum type; - GLuint size; - GLuint stride; + GLint size; + GLsizei stride; bool normalized; bool pureInteger; - size_t attributeOffset; + int attributeOffset; unsigned int streamOffset; }; diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/VertexDataManager.cpp b/gfx/angle/src/libGLESv2/renderer/VertexDataManager.cpp similarity index 68% rename from gfx/angle/src/libGLESv2/renderer/d3d/VertexDataManager.cpp rename to gfx/angle/src/libGLESv2/renderer/VertexDataManager.cpp index 9ba12d12392a..6aad5ebb826a 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/VertexDataManager.cpp +++ b/gfx/angle/src/libGLESv2/renderer/VertexDataManager.cpp @@ -8,13 +8,13 @@ // 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/VertexDataManager.h" +#include "libGLESv2/renderer/BufferStorage.h" #include "libGLESv2/Buffer.h" #include "libGLESv2/ProgramBinary.h" #include "libGLESv2/VertexAttribute.h" -#include "libGLESv2/renderer/d3d/VertexBuffer.h" +#include "libGLESv2/renderer/VertexBuffer.h" #include "libGLESv2/renderer/Renderer.h" namespace @@ -27,7 +27,7 @@ namespace namespace rx { -static int ElementsInBuffer(const gl::VertexAttribute &attrib, unsigned int size) +static int ElementsInBuffer(const gl::VertexAttribute &attribute, unsigned int size) { // Size cannot be larger than a GLsizei if (size > static_cast(std::numeric_limits::max())) @@ -35,19 +35,19 @@ static int ElementsInBuffer(const gl::VertexAttribute &attrib, unsigned int size size = static_cast(std::numeric_limits::max()); } - GLsizei stride = ComputeVertexAttributeStride(attrib); - return (size - attrib.offset % stride + (stride - ComputeVertexAttributeTypeSize(attrib))) / stride; + GLsizei stride = attribute.stride(); + return (size - attribute.mOffset % stride + (stride - attribute.typeSize())) / stride; } -static int StreamingBufferElementCount(const gl::VertexAttribute &attrib, int vertexDrawCount, int instanceDrawCount) +static int StreamingBufferElementCount(const gl::VertexAttribute &attribute, 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) + if (instanceDrawCount > 0 && attribute.mDivisor > 0) { - return instanceDrawCount / attrib.divisor; + return instanceDrawCount / attribute.mDivisor; } return vertexDrawCount; @@ -100,20 +100,15 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[], // Invalidate static buffers that don't contain matching attributes for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++) { - if (translated[i].active && attribs[i].enabled) + if (translated[i].active && attribs[i].mArrayEnabled) { - gl::Buffer *buffer = attribs[i].buffer.get(); + gl::Buffer *buffer = attribs[i].mBoundBuffer.get(); + StaticVertexBufferInterface *staticBuffer = buffer ? buffer->getStaticVertexBuffer() : NULL; - if (buffer) + if (staticBuffer && staticBuffer->getBufferSize() > 0 && !staticBuffer->lookupAttribute(attribs[i], NULL) && + !staticBuffer->directStoragePossible(attribs[i], currentValues[i])) { - BufferD3D *bufferImpl = BufferD3D::makeBufferD3D(buffer->getImplementation()); - StaticVertexBufferInterface *staticBuffer = bufferImpl->getStaticVertexBuffer(); - - if (staticBuffer && staticBuffer->getBufferSize() > 0 && !staticBuffer->lookupAttribute(attribs[i], NULL) && - !staticBuffer->directStoragePossible(attribs[i], currentValues[i])) - { - bufferImpl->invalidateStaticData(); - } + buffer->invalidateStaticData(); } } } @@ -121,45 +116,41 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[], // Reserve the required space in the buffers for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++) { - if (translated[i].active && attribs[i].enabled) + if (translated[i].active && attribs[i].mArrayEnabled) { - gl::Buffer *buffer = attribs[i].buffer.get(); - if (buffer) + gl::Buffer *buffer = attribs[i].mBoundBuffer.get(); + StaticVertexBufferInterface *staticBuffer = buffer ? buffer->getStaticVertexBuffer() : NULL; + VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast(mStreamingBuffer); + + if (!vertexBuffer->directStoragePossible(attribs[i], currentValues[i])) { - BufferD3D *bufferImpl = BufferD3D::makeBufferD3D(buffer->getImplementation()); - StaticVertexBufferInterface *staticBuffer = bufferImpl->getStaticVertexBuffer(); - VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast(mStreamingBuffer); - - if (!vertexBuffer->directStoragePossible(attribs[i], currentValues[i])) + if (staticBuffer) { - if (staticBuffer) + if (staticBuffer->getBufferSize() == 0) { - if (staticBuffer->getBufferSize() == 0) - { - int totalCount = ElementsInBuffer(attribs[i], bufferImpl->getSize()); - if (!staticBuffer->reserveVertexSpace(attribs[i], totalCount, 0)) - { - return GL_OUT_OF_MEMORY; - } - } - } - else - { - int totalCount = StreamingBufferElementCount(attribs[i], count, instances); - - // [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 (bufferImpl && ElementsInBuffer(attribs[i], bufferImpl->getSize()) < totalCount) - { - return GL_INVALID_OPERATION; - } - - if (!mStreamingBuffer->reserveVertexSpace(attribs[i], totalCount, instances)) + int totalCount = ElementsInBuffer(attribs[i], buffer->size()); + if (!staticBuffer->reserveVertexSpace(attribs[i], totalCount, 0)) { return GL_OUT_OF_MEMORY; } } } + else + { + int totalCount = StreamingBufferElementCount(attribs[i], count, instances); + + // [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 (buffer && ElementsInBuffer(attribs[i], buffer->size()) < totalCount) + { + return GL_INVALID_OPERATION; + } + + if (!mStreamingBuffer->reserveVertexSpace(attribs[i], totalCount, instances)) + { + return GL_OUT_OF_MEMORY; + } + } } } } @@ -169,20 +160,21 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[], { if (translated[i].active) { - if (attribs[i].enabled) + if (attribs[i].mArrayEnabled) { - gl::Buffer *buffer = attribs[i].buffer.get(); + gl::Buffer *buffer = attribs[i].mBoundBuffer.get(); - if (!buffer && attribs[i].pointer == NULL) + if (!buffer && attribs[i].mPointer == NULL) { // This is an application error that would normally result in a crash, but we catch it and return an error ERR("An enabled vertex array has no buffer and no pointer."); return GL_INVALID_OPERATION; } - BufferD3D *storage = buffer ? BufferD3D::makeBufferD3D(buffer->getImplementation()) : NULL; - StaticVertexBufferInterface *staticBuffer = storage ? storage->getStaticVertexBuffer() : NULL; + StaticVertexBufferInterface *staticBuffer = buffer ? buffer->getStaticVertexBuffer() : NULL; VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast(mStreamingBuffer); + + BufferStorage *storage = buffer ? buffer->getStorage() : NULL; bool directStorage = vertexBuffer->directStoragePossible(attribs[i], currentValues[i]); unsigned int streamOffset = 0; @@ -190,8 +182,8 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[], if (directStorage) { - outputElementSize = ComputeVertexAttributeStride(attribs[i]); - streamOffset = attribs[i].offset + outputElementSize * start; + outputElementSize = attribs[i].stride(); + streamOffset = attribs[i].mOffset + outputElementSize * start; } else if (staticBuffer) { @@ -204,7 +196,7 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[], { // Convert the entire buffer int totalCount = ElementsInBuffer(attribs[i], storage->getSize()); - int startIndex = attribs[i].offset / ComputeVertexAttributeStride(attribs[i]); + int startIndex = attribs[i].mOffset / attribs[i].stride(); if (!staticBuffer->storeVertexAttributes(attribs[i], currentValues[i], -startIndex, totalCount, 0, &streamOffset)) @@ -213,8 +205,8 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[], } } - unsigned int firstElementOffset = (attribs[i].offset / ComputeVertexAttributeStride(attribs[i])) * outputElementSize; - unsigned int startOffset = (instances == 0 || attribs[i].divisor == 0) ? start * outputElementSize : 0; + unsigned int firstElementOffset = (attribs[i].mOffset / attribs[i].stride()) * outputElementSize; + unsigned int startOffset = (instances == 0 || attribs[i].mDivisor == 0) ? start * outputElementSize : 0; if (streamOffset + firstElementOffset + startOffset < streamOffset) { return GL_OUT_OF_MEMORY; @@ -236,7 +228,7 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[], translated[i].storage = directStorage ? storage : NULL; translated[i].vertexBuffer = vertexBuffer->getVertexBuffer(); translated[i].serial = directStorage ? storage->getSerial() : vertexBuffer->getSerial(); - translated[i].divisor = attribs[i].divisor; + translated[i].divisor = attribs[i].mDivisor; translated[i].attribute = &attribs[i]; translated[i].currentValueType = currentValues[i].Type; @@ -284,14 +276,13 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[], for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++) { - if (translated[i].active && attribs[i].enabled) + if (translated[i].active && attribs[i].mArrayEnabled) { - gl::Buffer *buffer = attribs[i].buffer.get(); + gl::Buffer *buffer = attribs[i].mBoundBuffer.get(); if (buffer) { - BufferD3D *bufferImpl = BufferD3D::makeBufferD3D(buffer->getImplementation()); - bufferImpl->promoteStaticUsage(count * ComputeVertexAttributeTypeSize(attribs[i])); + buffer->promoteStaticUsage(count * attribs[i].typeSize()); } } } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/VertexDataManager.h b/gfx/angle/src/libGLESv2/renderer/VertexDataManager.h similarity index 96% rename from gfx/angle/src/libGLESv2/renderer/d3d/VertexDataManager.h rename to gfx/angle/src/libGLESv2/renderer/VertexDataManager.h index 4164fbecbb6c..1a69245b9454 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/VertexDataManager.h +++ b/gfx/angle/src/libGLESv2/renderer/VertexDataManager.h @@ -16,14 +16,14 @@ namespace gl { -struct VertexAttribute; +class VertexAttribute; class ProgramBinary; struct VertexAttribCurrentValueData; } namespace rx { -class BufferD3D; +class BufferStorage; class StreamingVertexBufferInterface; class VertexBuffer; class Renderer; @@ -38,7 +38,7 @@ struct TranslatedAttribute unsigned int stride; // 0 means not to advance the read pointer at all VertexBuffer *vertexBuffer; - BufferD3D *storage; + BufferStorage *storage; unsigned int serial; unsigned int divisor; }; diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/BufferD3D.cpp b/gfx/angle/src/libGLESv2/renderer/d3d/BufferD3D.cpp deleted file mode 100644 index 08457af76dfe..000000000000 --- a/gfx/angle/src/libGLESv2/renderer/d3d/BufferD3D.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "precompiled.h" -// -// 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/Renderer.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(buffer); -} - -void BufferD3D::updateSerial() -{ - mSerial = mNextSerial++; -} - -void BufferD3D::initializeStaticData() -{ - if (!mStaticVertexBuffer) - { - mStaticVertexBuffer = new rx::StaticVertexBufferInterface(getRenderer()); - } - if (!mStaticIndexBuffer) - { - mStaticIndexBuffer = new rx::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/gfx/angle/src/libGLESv2/renderer/d3d/BufferD3D.h b/gfx/angle/src/libGLESv2/renderer/d3d/BufferD3D.h deleted file mode 100644 index 8e204b913944..000000000000 --- a/gfx/angle/src/libGLESv2/renderer/d3d/BufferD3D.h +++ /dev/null @@ -1,60 +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 "libGLESv2/renderer/IndexRangeCache.h" - -namespace rx -{ - -class Renderer; -class StaticIndexBufferInterface; -class StaticVertexBufferInterface; - -class BufferD3D : public BufferImpl -{ - public: - BufferD3D(); - virtual ~BufferD3D(); - - static BufferD3D *makeBufferD3D(BufferImpl *buffer); - - unsigned int getSerial() const { return mSerial; } - - virtual size_t getSize() const = 0; - virtual void clear() = 0; - virtual bool supportsDirectBinding() const = 0; - virtual Renderer* getRenderer() = 0; - - rx::StaticVertexBufferInterface *getStaticVertexBuffer() { return mStaticVertexBuffer; } - rx::StaticIndexBufferInterface *getStaticIndexBuffer() { return mStaticIndexBuffer; } - rx::IndexRangeCache *getIndexRangeCache() { return &mIndexRangeCache; } - - void initializeStaticData(); - void invalidateStaticData(); - void promoteStaticUsage(int dataSize); - - protected: - unsigned int mSerial; - static unsigned int mNextSerial; - - void updateSerial(); - - rx::StaticVertexBufferInterface *mStaticVertexBuffer; - rx::StaticIndexBufferInterface *mStaticIndexBuffer; - rx::IndexRangeCache mIndexRangeCache; - unsigned int mUnmodifiedDataUse; -}; - -} - -#endif // LIBGLESV2_RENDERER_BUFFERIMPLD3D_H_ diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/HLSLCompiler.h b/gfx/angle/src/libGLESv2/renderer/d3d/HLSLCompiler.h index 0ce9e44be54d..ab685f1f44a3 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/HLSLCompiler.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d/HLSLCompiler.h @@ -3,6 +3,8 @@ #include "common/angleutils.h" +#include + namespace gl { class InfoLog; diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/VertexArray11.h b/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/VertexArray11.h deleted file mode 100644 index 590cb9f05a4f..000000000000 --- a/gfx/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(rx::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); - - rx::Renderer11 *mRenderer; -}; - -} - -#endif // LIBGLESV2_RENDERER_VERTEXARRAY11_H_ diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Buffer9.cpp b/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Buffer9.cpp deleted file mode 100644 index c86fe13662ff..000000000000 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Buffer9.cpp +++ /dev/null @@ -1,120 +0,0 @@ -#include "precompiled.h" -// -// 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/main.h" -#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h" - -namespace rx -{ - -Buffer9::Buffer9(rx::Renderer9 *renderer) - : BufferD3D(), - mRenderer(renderer), - mSize(0) -{ - -} - -Buffer9::~Buffer9() -{ - -} - -Buffer9 *Buffer9::makeBuffer9(BufferImpl *buffer) -{ - ASSERT(HAS_DYNAMIC_TYPE(Buffer9*, buffer)); - return static_cast(buffer); -} - -void Buffer9::clear() -{ - mSize = 0; -} - -void Buffer9::setData(const void* data, size_t size, GLenum usage) -{ - if (size > mMemory.size()) - { - mMemory.resize(size); - } - - mSize = size; - if (data) - { - memcpy(mMemory.data(), data, size); - } - - mIndexRangeCache.clear(); - - invalidateStaticData(); - - if (usage == GL_STATIC_DRAW) - { - initializeStaticData(); - } -} - -void *Buffer9::getData() -{ - return mMemory.data(); -} - -void Buffer9::setSubData(const void* data, size_t size, size_t offset) -{ - if (offset + size > mMemory.size()) - { - mMemory.resize(offset + size); - } - - mSize = std::max(mSize, offset + size); - if (data) - { - memcpy(mMemory.data() + offset, data, size); - } - - mIndexRangeCache.invalidateRange(offset, size); - - invalidateStaticData(); -} - -void Buffer9::copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) -{ - Buffer9* sourceBuffer = makeBuffer9(source); - if (sourceBuffer) - { - memcpy(mMemory.data() + destOffset, sourceBuffer->mMemory.data() + sourceOffset, size); - } - - invalidateStaticData(); -} - -// We do not suppot buffer mapping in D3D9 -GLvoid* Buffer9::map(size_t offset, size_t length, GLbitfield access) -{ - UNREACHABLE(); - return NULL; -} - -void Buffer9::unmap() -{ - UNREACHABLE(); -} - -void Buffer9::markTransformFeedbackUsage() -{ - UNREACHABLE(); -} - -Renderer* Buffer9::getRenderer() -{ - return mRenderer; -} - -} diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Buffer9.h b/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Buffer9.h deleted file mode 100644 index 0f80d074d88e..000000000000 --- a/gfx/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/angletypes.h" - -namespace rx -{ -class Renderer9; - -class Buffer9 : public BufferD3D -{ - public: - Buffer9(rx::Renderer9 *renderer); - virtual ~Buffer9(); - - static Buffer9 *makeBuffer9(BufferImpl *buffer); - - // BufferD3D implementation - virtual size_t getSize() const { return mSize; } - virtual void clear(); - virtual bool supportsDirectBinding() const { return false; } - virtual Renderer* getRenderer(); - - // BufferImpl implementation - virtual void setData(const void* data, size_t size, GLenum usage); - virtual void *getData(); - virtual void setSubData(const void* data, size_t size, size_t offset); - virtual void copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size); - virtual GLvoid* map(size_t offset, size_t length, GLbitfield access); - virtual void unmap(); - virtual void markTransformFeedbackUsage(); - - private: - DISALLOW_COPY_AND_ASSIGN(Buffer9); - - rx::Renderer9 *mRenderer; - std::vector mMemory; - size_t mSize; -}; - -} - -#endif // LIBGLESV2_RENDERER_BUFFER9_H_ diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/VertexArray9.h b/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/VertexArray9.h deleted file mode 100644 index 66a6c64d81c4..000000000000 --- a/gfx/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(rx::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); - - rx::Renderer9 *mRenderer; -}; - -} - -#endif // LIBGLESV2_RENDERER_VERTEXARRAY9_H_ diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/Blit11.cpp similarity index 92% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/Blit11.cpp index 2199dd82d7df..9a4171393017 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/Blit11.cpp @@ -9,54 +9,54 @@ #include "libGLESv2/main.h" #include "libGLESv2/formatutils.h" -#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/renderer/d3d11/Blit11.h" +#include "libGLESv2/renderer/d3d11/Renderer11.h" +#include "libGLESv2/renderer/d3d11/renderer11_utils.h" +#include "libGLESv2/renderer/d3d11/formatutils11.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough2d11vs.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughdepth2d11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2d11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2dui11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2di11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb2d11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb2dui11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb2di11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg2d11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg2dui11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg2di11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr2d11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr2dui11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr2di11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughlum2d11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughlumalpha2d11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthrough2d11vs.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughdepth2d11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2d11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2dui11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2di11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2d11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2dui11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2di11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2d11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2dui11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2di11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2d11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2dui11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2di11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum2d11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha2d11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough3d11vs.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough3d11gs.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba3d11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba3dui11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba3di11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb3d11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb3dui11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb3di11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg3d11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg3dui11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg3di11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr3d11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr3dui11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr3di11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughlum3d11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughlumalpha3d11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthrough3d11vs.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthrough3d11gs.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3d11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3dui11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3di11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3d11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3dui11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3di11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3d11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3dui11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3di11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3d11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3dui11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3di11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum3d11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha3d11ps.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" +#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzlef2dps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzlei2dps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzleui2dps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzlef3dps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzlei3dps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzleui3dps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzlef2darrayps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzlei2darrayps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzleui2darrayps.h" namespace rx { @@ -377,10 +377,10 @@ bool Blit11::swizzleTexture(ID3D11ShaderResourceView *source, ID3D11RenderTarget D3D11_SHADER_RESOURCE_VIEW_DESC sourceSRVDesc; source->GetDesc(&sourceSRVDesc); - GLenum sourceInternalFormat = d3d11_gl::GetInternalFormat(sourceSRVDesc.Format); + GLenum sourceInternalFormat = d3d11_gl::GetInternalFormat(sourceSRVDesc.Format, mRenderer->getCurrentClientVersion()); GLenum shaderType = GL_NONE; - switch (gl::GetComponentType(sourceInternalFormat)) + switch (gl::GetComponentType(sourceInternalFormat, mRenderer->getCurrentClientVersion())) { case GL_UNSIGNED_NORMALIZED: case GL_SIGNED_NORMALIZED: @@ -516,11 +516,11 @@ bool Blit11::copyTexture(ID3D11ShaderResourceView *source, const gl::Box &source // 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); - GLenum sourceInternalFormat = d3d11_gl::GetInternalFormat(sourceSRVDesc.Format); + GLenum sourceInternalFormat = d3d11_gl::GetInternalFormat(sourceSRVDesc.Format, mRenderer->getCurrentClientVersion()); BlitParameters parameters = { 0 }; parameters.mDestinationFormat = destFormat; - parameters.mSignedInteger = gl::GetComponentType(sourceInternalFormat) == GL_INT; + parameters.mSignedInteger = gl::GetComponentType(sourceInternalFormat, mRenderer->getCurrentClientVersion()) == GL_INT; parameters.m3DBlit = sourceArea.depth > 1; BlitShaderMap::const_iterator i = mBlitShaderMap.find(parameters); diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.h b/gfx/angle/src/libGLESv2/renderer/d3d11/Blit11.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Blit11.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/Blit11.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/BufferStorage11.cpp similarity index 75% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/BufferStorage11.cpp index facd7098f8c5..c0f8e00d83aa 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/BufferStorage11.cpp @@ -1,16 +1,17 @@ #include "precompiled.h" // -// Copyright 2014 The ANGLE Project Authors. All rights reserved. +// 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. // -// Buffer11.cpp Defines the Buffer11 class. +// BufferStorage11.cpp Defines the BufferStorage11 class. -#include "libGLESv2/renderer/d3d/d3d11/Buffer11.h" +#include "libGLESv2/renderer/d3d11/BufferStorage11.h" #include "libGLESv2/main.h" -#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h" -#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h" +#include "libGLESv2/renderer/d3d11/Renderer11.h" +#include "libGLESv2/renderer/d3d11/formatutils11.h" +#include "libGLESv2/Buffer.h" namespace rx { @@ -68,15 +69,15 @@ D3D11_MAP GetD3DMapTypeFromBits(GLbitfield access) } -// Each instance of Buffer11::BufferStorage11 is specialized for a class of D3D binding points +// Each instance of BufferStorageD3DBuffer11 is specialized for a class of D3D binding points // - vertex/transform feedback buffers // - index buffers // - pixel unpack buffers // - uniform buffers -class Buffer11::BufferStorage11 +class BufferStorage11::TypedBufferStorage11 { public: - virtual ~BufferStorage11() {} + virtual ~TypedBufferStorage11() {} DataRevision getDataRevision() const { return mRevision; } BufferUsage getUsage() const { return mUsage; } @@ -85,15 +86,15 @@ class Buffer11::BufferStorage11 void setDataRevision(DataRevision rev) { mRevision = rev; } - virtual bool copyFromStorage(BufferStorage11 *source, size_t sourceOffset, + virtual bool copyFromStorage(TypedBufferStorage11 *source, size_t sourceOffset, size_t size, size_t destOffset) = 0; virtual bool resize(size_t size, bool preserveData) = 0; - virtual void *map(size_t offset, size_t length, GLbitfield access) = 0; + virtual void *map(GLbitfield access) = 0; virtual void unmap() = 0; protected: - BufferStorage11(Renderer11 *renderer, BufferUsage usage); + TypedBufferStorage11(Renderer11 *renderer, BufferUsage usage); Renderer11 *mRenderer; DataRevision mRevision; @@ -103,7 +104,7 @@ class Buffer11::BufferStorage11 // A native buffer storage represents an underlying D3D11 buffer for a particular // type of storage. -class Buffer11::NativeBuffer11 : public Buffer11::BufferStorage11 +class BufferStorage11::NativeBuffer11 : public BufferStorage11::TypedBufferStorage11 { public: NativeBuffer11(Renderer11 *renderer, BufferUsage usage); @@ -111,11 +112,11 @@ class Buffer11::NativeBuffer11 : public Buffer11::BufferStorage11 ID3D11Buffer *getNativeBuffer() const { return mNativeBuffer; } - virtual bool copyFromStorage(BufferStorage11 *source, size_t sourceOffset, + virtual bool copyFromStorage(TypedBufferStorage11 *source, size_t sourceOffset, size_t size, size_t destOffset); virtual bool resize(size_t size, bool preserveData); - virtual void *map(size_t offset, size_t length, GLbitfield access); + virtual void *map(GLbitfield access); virtual void unmap(); private: @@ -126,17 +127,17 @@ class Buffer11::NativeBuffer11 : public Buffer11::BufferStorage11 // 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 +class BufferStorage11::PackStorage11 : public BufferStorage11::TypedBufferStorage11 { public: PackStorage11(Renderer11 *renderer); ~PackStorage11(); - virtual bool copyFromStorage(BufferStorage11 *source, size_t sourceOffset, + virtual bool copyFromStorage(TypedBufferStorage11 *source, size_t sourceOffset, size_t size, size_t destOffset); virtual bool resize(size_t size, bool preserveData); - virtual void *map(size_t offset, size_t length, GLbitfield access); + virtual void *map(GLbitfield access); virtual void unmap(); void packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams ¶ms); @@ -154,54 +155,30 @@ class Buffer11::PackStorage11 : public Buffer11::BufferStorage11 bool mDataModified; }; - -Buffer11::Buffer11(Renderer11 *renderer) - : BufferD3D(), - mRenderer(renderer), - mSize(0), +BufferStorage11::BufferStorage11(Renderer11 *renderer) + : mRenderer(renderer), mMappedStorage(NULL), mResolvedDataRevision(0), - mReadUsageCount(0) + mReadUsageCount(0), + mSize(0) { } -Buffer11::~Buffer11() +BufferStorage11::~BufferStorage11() { - clear(); -} - -Buffer11 *Buffer11::makeBuffer11(BufferImpl *buffer) -{ - ASSERT(HAS_DYNAMIC_TYPE(Buffer11*, buffer)); - return static_cast(buffer); -} - -void Buffer11::clear() -{ - for (auto it = mBufferStorages.begin(); it != mBufferStorages.end(); it++) + for (auto it = mTypedBuffers.begin(); it != mTypedBuffers.end(); it++) { SafeDelete(it->second); } - - mBufferStorages.clear(); - - mSize = 0; - mResolvedDataRevision = 0; } -void Buffer11::setData(const void* data, size_t size, GLenum usage) +BufferStorage11 *BufferStorage11::makeBufferStorage11(BufferStorage *bufferStorage) { - mIndexRangeCache.clear(); - - setSubData(data, size, 0); - - if (usage == GL_STATIC_DRAW) - { - initializeStaticData(); - } + ASSERT(HAS_DYNAMIC_TYPE(BufferStorage11*, bufferStorage)); + return static_cast(bufferStorage); } -void *Buffer11::getData() +void *BufferStorage11::getData() { NativeBuffer11 *stagingBuffer = getStagingBuffer(); @@ -239,15 +216,12 @@ void *Buffer11::getData() return mResolvedData.data(); } -void Buffer11::setSubData(const void* data, size_t size, size_t offset) +void BufferStorage11::setData(const void* data, size_t size, size_t offset) { size_t requiredSize = size + offset; mSize = std::max(mSize, requiredSize); - mIndexRangeCache.invalidateRange(offset, size); - invalidateStaticData(); - - if (data && size > 0) + if (data) { NativeBuffer11 *stagingBuffer = getStagingBuffer(); @@ -287,25 +261,25 @@ void Buffer11::setSubData(const void* data, size_t size, size_t offset) } } -void Buffer11::copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) +void BufferStorage11::copyData(BufferStorage* sourceStorage, size_t size, size_t sourceOffset, size_t destOffset) { - Buffer11 *sourceBuffer = makeBuffer11(source); - if (sourceBuffer) + BufferStorage11* sourceStorage11 = makeBufferStorage11(sourceStorage); + if (sourceStorage11) { - BufferStorage11 *dest = getLatestBufferStorage(); + TypedBufferStorage11 *dest = getLatestStorage(); if (!dest) { dest = getStagingBuffer(); } - BufferStorage11 *source = sourceBuffer->getLatestBufferStorage(); + TypedBufferStorage11 *source = sourceStorage11->getLatestStorage(); if (source && dest) { // 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 (dest->getUsage() == BUFFER_USAGE_PIXEL_PACK && !source->isMappable()) { - source = sourceBuffer->getStagingBuffer(); + source = sourceStorage11->getStagingBuffer(); } else if (source->getUsage() == BUFFER_USAGE_PIXEL_PACK && !dest->isMappable()) { @@ -318,64 +292,35 @@ void Buffer11::copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr d mSize = std::max(mSize, destOffset + size); } - - invalidateStaticData(); } -GLvoid *Buffer11::map(size_t offset, size_t length, GLbitfield access) +void BufferStorage11::clear() { - 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) - { - // Out-of-memory - return NULL; - } - - 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); - } - - return mMappedStorage->map(offset, length, access); + mSize = 0; + mResolvedDataRevision = 0; } -void Buffer11::unmap() +void BufferStorage11::markTransformFeedbackUsage() { - ASSERT(mMappedStorage); - mMappedStorage->unmap(); - mMappedStorage = NULL; -} - -void Buffer11::markTransformFeedbackUsage() -{ - BufferStorage11 *transformFeedbackStorage = getBufferStorage(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK); + TypedBufferStorage11 *transformFeedbackStorage = getStorage(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK); if (transformFeedbackStorage) { transformFeedbackStorage->setDataRevision(transformFeedbackStorage->getDataRevision() + 1); } - - invalidateStaticData(); } -void Buffer11::markBufferUsage() +size_t BufferStorage11::getSize() const +{ + return mSize; +} + +bool BufferStorage11::supportsDirectBinding() const +{ + return true; +} + +void BufferStorage11::markBufferUsage() { mReadUsageCount++; @@ -388,31 +333,26 @@ void Buffer11::markBufferUsage() } } -Renderer* Buffer11::getRenderer() -{ - return mRenderer; -} - -ID3D11Buffer *Buffer11::getBuffer(BufferUsage usage) +ID3D11Buffer *BufferStorage11::getBuffer(BufferUsage usage) { markBufferUsage(); - BufferStorage11 *bufferStorage = getBufferStorage(usage); + TypedBufferStorage11 *typedBuffer = getStorage(usage); - if (!bufferStorage) + if (!typedBuffer) { // Storage out-of-memory return NULL; } - ASSERT(HAS_DYNAMIC_TYPE(NativeBuffer11*, bufferStorage)); + ASSERT(HAS_DYNAMIC_TYPE(NativeBuffer11*, typedBuffer)); - return static_cast(bufferStorage)->getNativeBuffer(); + return static_cast(typedBuffer)->getNativeBuffer(); } -ID3D11ShaderResourceView *Buffer11::getSRV(DXGI_FORMAT srvFormat) +ID3D11ShaderResourceView *BufferStorage11::getSRV(DXGI_FORMAT srvFormat) { - BufferStorage11 *storage = getBufferStorage(BUFFER_USAGE_PIXEL_UNPACK); + TypedBufferStorage11 *storage = getStorage(BUFFER_USAGE_PIXEL_UNPACK); if (!storage) { @@ -456,11 +396,11 @@ ID3D11ShaderResourceView *Buffer11::getSRV(DXGI_FORMAT srvFormat) return bufferSRV; } -void Buffer11::packPixels(ID3D11Texture2D *srcTexture, UINT srcSubresource, const PackPixelsParams ¶ms) +void BufferStorage11::packPixels(ID3D11Texture2D *srcTexture, UINT srcSubresource, const PackPixelsParams ¶ms) { PackStorage11 *packStorage = getPackStorage(); - BufferStorage11 *latestStorage = getLatestBufferStorage(); + TypedBufferStorage11 *latestStorage = getLatestStorage(); if (packStorage) { @@ -469,11 +409,11 @@ void Buffer11::packPixels(ID3D11Texture2D *srcTexture, UINT srcSubresource, cons } } -Buffer11::BufferStorage11 *Buffer11::getBufferStorage(BufferUsage usage) +BufferStorage11::TypedBufferStorage11 *BufferStorage11::getStorage(BufferUsage usage) { - BufferStorage11 *directBuffer = NULL; - auto directBufferIt = mBufferStorages.find(usage); - if (directBufferIt != mBufferStorages.end()) + TypedBufferStorage11 *directBuffer = NULL; + auto directBufferIt = mTypedBuffers.find(usage); + if (directBufferIt != mTypedBuffers.end()) { directBuffer = directBufferIt->second; } @@ -490,7 +430,7 @@ Buffer11::BufferStorage11 *Buffer11::getBufferStorage(BufferUsage usage) directBuffer = new NativeBuffer11(mRenderer, usage); } - mBufferStorages.insert(std::make_pair(usage, directBuffer)); + mTypedBuffers.insert(std::make_pair(usage, directBuffer)); } // resize buffer @@ -503,7 +443,7 @@ Buffer11::BufferStorage11 *Buffer11::getBufferStorage(BufferUsage usage) } } - BufferStorage11 *latestBuffer = getLatestBufferStorage(); + TypedBufferStorage11 *latestBuffer = getLatestStorage(); if (latestBuffer && latestBuffer->getDataRevision() > directBuffer->getDataRevision()) { // if copying from a pack buffer to a non-staging native buffer, we must first @@ -530,15 +470,15 @@ Buffer11::BufferStorage11 *Buffer11::getBufferStorage(BufferUsage usage) return directBuffer; } -Buffer11::BufferStorage11 *Buffer11::getLatestBufferStorage() const +BufferStorage11::TypedBufferStorage11 *BufferStorage11::getLatestStorage() const { // Even though we iterate over all the direct buffers, it is expected that only // 1 or 2 will be present. - BufferStorage11 *latestStorage = NULL; + TypedBufferStorage11 *latestStorage = NULL; DataRevision latestRevision = 0; - for (auto it = mBufferStorages.begin(); it != mBufferStorages.end(); it++) + for (auto it = mTypedBuffers.begin(); it != mTypedBuffers.end(); it++) { - BufferStorage11 *storage = it->second; + TypedBufferStorage11 *storage = it->second; if (!latestStorage || storage->getDataRevision() > latestRevision) { latestStorage = storage; @@ -549,9 +489,47 @@ Buffer11::BufferStorage11 *Buffer11::getLatestBufferStorage() const return latestStorage; } -Buffer11::NativeBuffer11 *Buffer11::getStagingBuffer() +bool BufferStorage11::isMapped() const { - BufferStorage11 *stagingStorage = getBufferStorage(BUFFER_USAGE_STAGING); + return mMappedStorage != NULL; +} + +void *BufferStorage11::map(GLbitfield access) +{ + ASSERT(!mMappedStorage); + + TypedBufferStorage11 *latestStorage = getLatestStorage(); + ASSERT(latestStorage); + + if (latestStorage->getUsage() == BUFFER_USAGE_PIXEL_PACK || + latestStorage->getUsage() == BUFFER_USAGE_STAGING) + { + mMappedStorage = latestStorage; + } + else + { + mMappedStorage = getStagingBuffer(); + } + + if (!mMappedStorage) + { + // Out-of-memory + return NULL; + } + + return mMappedStorage->map(access); +} + +void BufferStorage11::unmap() +{ + ASSERT(mMappedStorage); + mMappedStorage->unmap(); + mMappedStorage = NULL; +} + +BufferStorage11::NativeBuffer11 *BufferStorage11::getStagingBuffer() +{ + TypedBufferStorage11 *stagingStorage = getStorage(BUFFER_USAGE_STAGING); if (!stagingStorage) { @@ -563,9 +541,9 @@ Buffer11::NativeBuffer11 *Buffer11::getStagingBuffer() return static_cast(stagingStorage); } -Buffer11::PackStorage11 *Buffer11::getPackStorage() +BufferStorage11::PackStorage11 *BufferStorage11::getPackStorage() { - BufferStorage11 *packStorage = getBufferStorage(BUFFER_USAGE_PIXEL_PACK); + TypedBufferStorage11 *packStorage = getStorage(BUFFER_USAGE_PIXEL_PACK); if (!packStorage) { @@ -577,7 +555,7 @@ Buffer11::PackStorage11 *Buffer11::getPackStorage() return static_cast(packStorage); } -Buffer11::BufferStorage11::BufferStorage11(Renderer11 *renderer, BufferUsage usage) +BufferStorage11::TypedBufferStorage11::TypedBufferStorage11(Renderer11 *renderer, BufferUsage usage) : mRenderer(renderer), mUsage(usage), mRevision(0), @@ -585,19 +563,19 @@ Buffer11::BufferStorage11::BufferStorage11(Renderer11 *renderer, BufferUsage usa { } -Buffer11::NativeBuffer11::NativeBuffer11(Renderer11 *renderer, BufferUsage usage) - : BufferStorage11(renderer, usage), +BufferStorage11::NativeBuffer11::NativeBuffer11(Renderer11 *renderer, BufferUsage usage) + : TypedBufferStorage11(renderer, usage), mNativeBuffer(NULL) { } -Buffer11::NativeBuffer11::~NativeBuffer11() +BufferStorage11::NativeBuffer11::~NativeBuffer11() { SafeRelease(mNativeBuffer); } // Returns true if it recreates the direct buffer -bool Buffer11::NativeBuffer11::copyFromStorage(BufferStorage11 *source, size_t sourceOffset, +bool BufferStorage11::NativeBuffer11::copyFromStorage(TypedBufferStorage11 *source, size_t sourceOffset, size_t size, size_t destOffset) { ID3D11DeviceContext *context = mRenderer->getDeviceContext(); @@ -616,7 +594,7 @@ bool Buffer11::NativeBuffer11::copyFromStorage(BufferStorage11 *source, size_t s { ASSERT(HAS_DYNAMIC_TYPE(PackStorage11*, source)); - void *sourcePointer = source->map(sourceOffset, size, GL_MAP_READ_BIT); + unsigned char *sourcePointer = static_cast(source->map(GL_MAP_READ_BIT)) + sourceOffset; D3D11_MAPPED_SUBRESOURCE mappedResource; HRESULT hr = context->Map(mNativeBuffer, 0, D3D11_MAP_WRITE, 0, &mappedResource); @@ -650,7 +628,7 @@ bool Buffer11::NativeBuffer11::copyFromStorage(BufferStorage11 *source, size_t s return createBuffer; } -bool Buffer11::NativeBuffer11::resize(size_t size, bool preserveData) +bool BufferStorage11::NativeBuffer11::resize(size_t size, bool preserveData) { ID3D11Device *device = mRenderer->getDevice(); ID3D11DeviceContext *context = mRenderer->getDeviceContext(); @@ -668,12 +646,9 @@ bool Buffer11::NativeBuffer11::resize(size_t size, bool preserveData) 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.right = size; srcBox.top = 0; srcBox.bottom = 1; srcBox.front = 0; @@ -691,7 +666,7 @@ bool Buffer11::NativeBuffer11::resize(size_t size, bool preserveData) return true; } -void Buffer11::NativeBuffer11::fillBufferDesc(D3D11_BUFFER_DESC* bufferDesc, Renderer *renderer, +void BufferStorage11::NativeBuffer11::fillBufferDesc(D3D11_BUFFER_DESC* bufferDesc, Renderer *renderer, BufferUsage usage, unsigned int bufferSize) { bufferDesc->ByteWidth = bufferSize; @@ -740,7 +715,7 @@ void Buffer11::NativeBuffer11::fillBufferDesc(D3D11_BUFFER_DESC* bufferDesc, Ren } } -void *Buffer11::NativeBuffer11::map(size_t offset, size_t length, GLbitfield access) +void *BufferStorage11::NativeBuffer11::map(GLbitfield access) { ASSERT(mUsage == BUFFER_USAGE_STAGING); @@ -753,18 +728,18 @@ void *Buffer11::NativeBuffer11::map(size_t offset, size_t length, GLbitfield acc UNUSED_ASSERTION_VARIABLE(result); ASSERT(SUCCEEDED(result)); - return static_cast(mappedResource.pData) + offset; + return mappedResource.pData; } -void Buffer11::NativeBuffer11::unmap() +void BufferStorage11::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), +BufferStorage11::PackStorage11::PackStorage11(Renderer11 *renderer) + : TypedBufferStorage11(renderer, BUFFER_USAGE_PIXEL_PACK), mStagingTexture(NULL), mTextureFormat(DXGI_FORMAT_UNKNOWN), mQueuedPackCommand(NULL), @@ -772,20 +747,20 @@ Buffer11::PackStorage11::PackStorage11(Renderer11 *renderer) { } -Buffer11::PackStorage11::~PackStorage11() +BufferStorage11::PackStorage11::~PackStorage11() { SafeRelease(mStagingTexture); SafeDelete(mQueuedPackCommand); } -bool Buffer11::PackStorage11::copyFromStorage(BufferStorage11 *source, size_t sourceOffset, +bool BufferStorage11::PackStorage11::copyFromStorage(TypedBufferStorage11 *source, size_t sourceOffset, size_t size, size_t destOffset) { UNIMPLEMENTED(); return false; } -bool Buffer11::PackStorage11::resize(size_t size, bool preserveData) +bool BufferStorage11::PackStorage11::resize(size_t size, bool preserveData) { if (size != mBufferSize) { @@ -796,9 +771,8 @@ bool Buffer11::PackStorage11::resize(size_t size, bool preserveData) return true; } -void *Buffer11::PackStorage11::map(size_t offset, size_t length, GLbitfield access) +void *BufferStorage11::PackStorage11::map(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 @@ -807,15 +781,15 @@ void *Buffer11::PackStorage11::map(size_t offset, size_t length, GLbitfield acce flushQueuedPackCommand(); mDataModified = (mDataModified || (access & GL_MAP_WRITE_BIT) != 0); - return &mMemoryBuffer[0] + offset; + return &mMemoryBuffer[0]; } -void Buffer11::PackStorage11::unmap() +void BufferStorage11::PackStorage11::unmap() { // No-op } -void Buffer11::PackStorage11::packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams ¶ms) +void BufferStorage11::PackStorage11::packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams ¶ms) { flushQueuedPackCommand(); mQueuedPackCommand = new PackPixelsParams(params); @@ -878,7 +852,7 @@ void Buffer11::PackStorage11::packPixels(ID3D11Texture2D *srcTexure, UINT srcSub immediateContext->CopySubresourceRegion(mStagingTexture, 0, 0, 0, 0, srcTexure, srcSubresource, &srcBox); } -void Buffer11::PackStorage11::flushQueuedPackCommand() +void BufferStorage11::PackStorage11::flushQueuedPackCommand() { ASSERT(!mMemoryBuffer.empty()); diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.h b/gfx/angle/src/libGLESv2/renderer/d3d11/BufferStorage11.h similarity index 53% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/BufferStorage11.h index 43f95c342c09..7934de192c1b 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Buffer11.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/BufferStorage11.h @@ -1,19 +1,20 @@ // -// Copyright 2014 The ANGLE Project Authors. All rights reserved. +// 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. // -// Buffer11.h: Defines the rx::Buffer11 class which implements rx::BufferImpl via rx::BufferD3D. +// BufferStorage11.h Defines the BufferStorage11 class. -#ifndef LIBGLESV2_RENDERER_BUFFER11_H_ -#define LIBGLESV2_RENDERER_BUFFER11_H_ +#ifndef LIBGLESV2_RENDERER_BUFFERSTORAGE11_H_ +#define LIBGLESV2_RENDERER_BUFFERSTORAGE11_H_ -#include "libGLESv2/renderer/d3d/BufferD3D.h" +#include "libGLESv2/renderer/BufferStorage.h" #include "libGLESv2/angletypes.h" namespace rx { +class Renderer; class Renderer11; enum BufferUsage @@ -43,47 +44,39 @@ struct PackPixelsParams typedef size_t DataRevision; -class Buffer11 : public BufferD3D +class BufferStorage11 : public BufferStorage { public: - Buffer11(rx::Renderer11 *renderer); - virtual ~Buffer11(); + explicit BufferStorage11(Renderer11 *renderer); + virtual ~BufferStorage11(); - static Buffer11 *makeBuffer11(BufferImpl *buffer); + static BufferStorage11 *makeBufferStorage11(BufferStorage *bufferStorage); + + virtual void *getData(); + virtual void setData(const void* data, size_t size, size_t offset); + virtual void copyData(BufferStorage* sourceStorage, size_t size, size_t sourceOffset, size_t destOffset); + virtual void clear(); + virtual void markTransformFeedbackUsage(); + virtual size_t getSize() const; + virtual bool supportsDirectBinding() const; ID3D11Buffer *getBuffer(BufferUsage usage); ID3D11ShaderResourceView *getSRV(DXGI_FORMAT srvFormat); - bool isMapped() const { return mMappedStorage != NULL; } void packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams ¶ms); - // BufferD3D implementation - virtual size_t getSize() const { return mSize; } - virtual void clear(); - virtual bool supportsDirectBinding() const { return true; } - virtual Renderer* getRenderer(); - - // BufferImpl implementation - virtual void setData(const void* data, size_t size, GLenum usage); - virtual void *getData(); - virtual void setSubData(const void* data, size_t size, size_t offset); - virtual void copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size); - virtual GLvoid* map(size_t offset, size_t length, GLbitfield access); + virtual bool isMapped() const; + virtual void *map(GLbitfield access); virtual void unmap(); - virtual void markTransformFeedbackUsage(); private: - DISALLOW_COPY_AND_ASSIGN(Buffer11); - - class BufferStorage11; + class TypedBufferStorage11; class NativeBuffer11; class PackStorage11; - rx::Renderer11 *mRenderer; - size_t mSize; + Renderer11 *mRenderer; + TypedBufferStorage11 *mMappedStorage; - BufferStorage11 *mMappedStorage; - - std::map mBufferStorages; + std::map mTypedBuffers; typedef std::pair BufferSRVPair; std::map mBufferResourceViews; @@ -92,14 +85,16 @@ class Buffer11 : public BufferD3D DataRevision mResolvedDataRevision; unsigned int mReadUsageCount; + size_t mSize; + void markBufferUsage(); NativeBuffer11 *getStagingBuffer(); PackStorage11 *getPackStorage(); - BufferStorage11 *getBufferStorage(BufferUsage usage); - BufferStorage11 *getLatestBufferStorage() const; + TypedBufferStorage11 *getStorage(BufferUsage usage); + TypedBufferStorage11 *getLatestStorage() const; }; } -#endif // LIBGLESV2_RENDERER_BUFFER11_H_ +#endif // LIBGLESV2_RENDERER_BUFFERSTORAGE11_H_ diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/Clear11.cpp similarity index 91% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/Clear11.cpp index 2f241f9d029a..c02cd9ed2554 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/Clear11.cpp @@ -7,23 +7,23 @@ // 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/renderer/d3d11/Clear11.h" +#include "libGLESv2/renderer/d3d11/Renderer11.h" +#include "libGLESv2/renderer/d3d11/renderer11_utils.h" +#include "libGLESv2/renderer/d3d11/RenderTarget11.h" #include "libGLESv2/formatutils.h" #include "libGLESv2/Framebuffer.h" -#include "libGLESv2/FramebufferAttachment.h" +#include "libGLESv2/Renderbuffer.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearfloat11vs.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearfloat11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/clearfloat11vs.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/clearfloat11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearuint11vs.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearuint11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/clearuint11vs.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/clearuint11ps.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearsint11vs.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearsint11ps.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/clearsint11vs.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/clearsint11ps.h" namespace rx { @@ -169,16 +169,16 @@ void Clear11::clearFramebuffer(const gl::ClearParameters &clearParams, gl::Frame gl::Extents framebufferSize; if (frameBuffer->getFirstColorbuffer() != NULL) { - gl::FramebufferAttachment *attachment = frameBuffer->getFirstColorbuffer(); - framebufferSize.width = attachment->getWidth(); - framebufferSize.height = attachment->getHeight(); + gl::Renderbuffer *renderBuffer = frameBuffer->getFirstColorbuffer(); + framebufferSize.width = renderBuffer->getWidth(); + framebufferSize.height = renderBuffer->getHeight(); framebufferSize.depth = 1; } else if (frameBuffer->getDepthOrStencilbuffer() != NULL) { - gl::FramebufferAttachment *attachment = frameBuffer->getDepthOrStencilbuffer(); - framebufferSize.width = attachment->getWidth(); - framebufferSize.height = attachment->getHeight(); + gl::Renderbuffer *renderBuffer = frameBuffer->getDepthOrStencilbuffer(); + framebufferSize.width = renderBuffer->getWidth(); + framebufferSize.height = renderBuffer->getHeight(); framebufferSize.depth = 1; } else @@ -200,6 +200,8 @@ void Clear11::clearFramebuffer(const gl::ClearParameters &clearParams, gl::Frame clearParams.scissor.x + clearParams.scissor.width < framebufferSize.width || clearParams.scissor.y + clearParams.scissor.height < framebufferSize.height); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + std::vector maskedClearRenderTargets; RenderTarget11* maskedClearDepthStencil = NULL; @@ -209,19 +211,19 @@ void Clear11::clearFramebuffer(const gl::ClearParameters &clearParams, gl::Frame { if (clearParams.clearColor[colorAttachment] && frameBuffer->isEnabledColorAttachment(colorAttachment)) { - gl::FramebufferAttachment *attachment = frameBuffer->getColorbuffer(colorAttachment); - if (attachment) + gl::Renderbuffer *renderbuffer = frameBuffer->getColorbuffer(colorAttachment); + if (renderbuffer) { - RenderTarget11 *renderTarget = RenderTarget11::makeRenderTarget11(attachment->getRenderTarget()); + RenderTarget11 *renderTarget = RenderTarget11::makeRenderTarget11(renderbuffer->getRenderTarget()); if (!renderTarget) { ERR("Render target pointer unexpectedly null."); return; } - GLenum internalFormat = attachment->getInternalFormat(); - GLenum actualFormat = attachment->getActualFormat(); - GLenum componentType = gl::GetComponentType(internalFormat); + GLenum internalFormat = renderbuffer->getInternalFormat(); + GLenum actualFormat = renderbuffer->getActualFormat(); + GLenum componentType = gl::GetComponentType(internalFormat, clientVersion); if (clearParams.colorClearType == GL_FLOAT && !(componentType == GL_FLOAT || componentType == GL_UNSIGNED_NORMALIZED || componentType == GL_SIGNED_NORMALIZED)) { @@ -229,10 +231,10 @@ void Clear11::clearFramebuffer(const gl::ClearParameters &clearParams, gl::Frame "point to floating point values (color attachment %u has internal format 0x%X).", colorAttachment, internalFormat); } - GLuint internalRedBits = gl::GetRedBits(internalFormat); - GLuint internalGreenBits = gl::GetGreenBits(internalFormat); - GLuint internalBlueBits = gl::GetBlueBits(internalFormat); - GLuint internalAlphaBits = gl::GetAlphaBits(internalFormat); + GLuint internalRedBits = gl::GetRedBits(internalFormat, clientVersion); + GLuint internalGreenBits = gl::GetGreenBits(internalFormat, clientVersion); + GLuint internalBlueBits = gl::GetBlueBits(internalFormat, clientVersion); + GLuint internalAlphaBits = gl::GetAlphaBits(internalFormat, clientVersion); if ((internalRedBits == 0 || !clearParams.colorMaskRed) && (internalGreenBits == 0 || !clearParams.colorMaskGreen) && @@ -264,10 +266,10 @@ void Clear11::clearFramebuffer(const gl::ClearParameters &clearParams, gl::Frame // Check if the actual format has a channel that the internal format does not and set them to the // default values - GLuint actualRedBits = gl::GetRedBits(actualFormat); - GLuint actualGreenBits = gl::GetGreenBits(actualFormat); - GLuint actualBlueBits = gl::GetBlueBits(actualFormat); - GLuint actualAlphaBits = gl::GetAlphaBits(actualFormat); + GLuint actualRedBits = gl::GetRedBits(actualFormat, clientVersion); + GLuint actualGreenBits = gl::GetGreenBits(actualFormat, clientVersion); + GLuint actualBlueBits = gl::GetBlueBits(actualFormat, clientVersion); + GLuint actualAlphaBits = gl::GetAlphaBits(actualFormat, clientVersion); const float clearValues[4] = { @@ -285,19 +287,19 @@ void Clear11::clearFramebuffer(const gl::ClearParameters &clearParams, gl::Frame if (clearParams.clearDepth || clearParams.clearStencil) { - gl::FramebufferAttachment *attachment = frameBuffer->getDepthOrStencilbuffer(); - if (attachment) + gl::Renderbuffer *renderbuffer = frameBuffer->getDepthOrStencilbuffer(); + if (renderbuffer) { - RenderTarget11 *renderTarget = RenderTarget11::makeRenderTarget11(attachment->getDepthStencil()); + RenderTarget11 *renderTarget = RenderTarget11::makeRenderTarget11(renderbuffer->getDepthStencil()); if (!renderTarget) { ERR("Depth stencil render target pointer unexpectedly null."); return; } - GLenum actualFormat = attachment->getActualFormat(); + GLenum actualFormat = renderbuffer->getActualFormat(); - unsigned int stencilUnmasked = frameBuffer->hasStencil() ? (1 << gl::GetStencilBits(actualFormat)) - 1 : 0; + unsigned int stencilUnmasked = frameBuffer->hasStencil() ? (1 << gl::GetStencilBits(actualFormat, clientVersion)) - 1 : 0; bool needMaskedStencilClear = clearParams.clearStencil && (clearParams.stencilWriteMask & stencilUnmasked) != stencilUnmasked; if (needScissoredClear || needMaskedStencilClear) @@ -449,6 +451,8 @@ void Clear11::clearFramebuffer(const gl::ClearParameters &clearParams, gl::Frame ID3D11BlendState *Clear11::getBlendState(const gl::ClearParameters &clearParams, const std::vector& rts) { + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + ClearBlendInfo blendKey = { 0 }; for (unsigned int i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++) { @@ -456,10 +460,10 @@ ID3D11BlendState *Clear11::getBlendState(const gl::ClearParameters &clearParams, { GLint internalFormat = rts[i]->getInternalFormat(); - blendKey.maskChannels[i][0] = clearParams.clearColor ? (clearParams.colorMaskRed && gl::GetRedBits(internalFormat) > 0) : false; - blendKey.maskChannels[i][1] = clearParams.clearColor ? (clearParams.colorMaskGreen && gl::GetGreenBits(internalFormat) > 0) : false; - blendKey.maskChannels[i][2] = clearParams.clearColor ? (clearParams.colorMaskBlue && gl::GetBlueBits(internalFormat) > 0) : false; - blendKey.maskChannels[i][3] = clearParams.clearColor ? (clearParams.colorMaskAlpha && gl::GetAlphaBits(internalFormat) > 0) : false; + blendKey.maskChannels[i][0] = clearParams.clearColor ? (clearParams.colorMaskRed && gl::GetRedBits(internalFormat, clientVersion) > 0) : false; + blendKey.maskChannels[i][1] = clearParams.clearColor ? (clearParams.colorMaskGreen && gl::GetGreenBits(internalFormat, clientVersion) > 0) : false; + blendKey.maskChannels[i][2] = clearParams.clearColor ? (clearParams.colorMaskBlue && gl::GetBlueBits(internalFormat, clientVersion) > 0) : false; + blendKey.maskChannels[i][3] = clearParams.clearColor ? (clearParams.colorMaskAlpha && gl::GetAlphaBits(internalFormat, clientVersion) > 0) : false; } else { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.h b/gfx/angle/src/libGLESv2/renderer/d3d11/Clear11.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Clear11.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/Clear11.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Fence11.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/Fence11.cpp similarity index 93% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Fence11.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/Fence11.cpp index 869877665060..f2a75438fbab 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Fence11.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/Fence11.cpp @@ -7,9 +7,9 @@ // Fence11.cpp: Defines the rx::Fence11 class which implements rx::FenceImpl. -#include "libGLESv2/renderer/d3d/d3d11/Fence11.h" +#include "libGLESv2/renderer/d3d11/Fence11.h" #include "libGLESv2/main.h" -#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h" +#include "libGLESv2/renderer/d3d11/Renderer11.h" namespace rx { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Fence11.h b/gfx/angle/src/libGLESv2/renderer/d3d11/Fence11.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Fence11.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/Fence11.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Image11.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/Image11.cpp similarity index 89% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Image11.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/Image11.cpp index 4cc5ba7189e9..85484f9676f0 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Image11.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/Image11.cpp @@ -8,16 +8,16 @@ // 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/TextureStorage11.h" +#include "libGLESv2/renderer/d3d11/Renderer11.h" +#include "libGLESv2/renderer/d3d11/Image11.h" +#include "libGLESv2/renderer/d3d11/TextureStorage11.h" #include "libGLESv2/Framebuffer.h" -#include "libGLESv2/FramebufferAttachment.h" +#include "libGLESv2/Renderbuffer.h" #include "libGLESv2/main.h" #include "common/utilities.h" -#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h" -#include "libGLESv2/renderer/d3d/d3d11/renderer11_utils.h" +#include "libGLESv2/renderer/d3d11/formatutils11.h" +#include "libGLESv2/renderer/d3d11/renderer11_utils.h" namespace rx { @@ -40,7 +40,7 @@ Image11 *Image11::makeImage11(Image *img) return static_cast(img); } -void Image11::generateMipmap(Image11 *dest, Image11 *src) +void Image11::generateMipmap(GLuint clientVersion, Image11 *dest, Image11 *src) { ASSERT(src->getDXGIFormat() == dest->getDXGIFormat()); ASSERT(src->getWidth() == 1 || src->getWidth() / 2 == dest->getWidth()); @@ -118,6 +118,7 @@ bool Image11::redefine(Renderer *renderer, GLenum target, GLenum internalformat, forceRelease) { mRenderer = Renderer11::makeRenderer11(renderer); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); mWidth = width; mHeight = height; @@ -126,9 +127,9 @@ bool Image11::redefine(Renderer *renderer, GLenum target, GLenum internalformat, mTarget = target; // compute the d3d format that will be used - mDXGIFormat = gl_d3d11::GetTexFormat(internalformat); - mActualFormat = d3d11_gl::GetInternalFormat(mDXGIFormat); - mRenderable = gl_d3d11::GetRTVFormat(internalformat) != DXGI_FORMAT_UNKNOWN; + mDXGIFormat = gl_d3d11::GetTexFormat(internalformat, clientVersion); + mActualFormat = d3d11_gl::GetInternalFormat(mDXGIFormat, clientVersion); + mRenderable = gl_d3d11::GetRTVFormat(internalformat, clientVersion) != DXGI_FORMAT_UNKNOWN; SafeRelease(mStagingTexture); mDirty = gl_d3d11::RequiresTextureDataInitialization(mInternalFormat); @@ -153,11 +154,12 @@ DXGI_FORMAT Image11::getDXGIFormat() const void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLint unpackAlignment, GLenum type, const void *input) { - GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, type, width, unpackAlignment); - GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, type, width, height, unpackAlignment); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, type, clientVersion, width, unpackAlignment); + GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, type, clientVersion, width, height, unpackAlignment); GLuint outputPixelSize = d3d11::GetFormatPixelBytes(mDXGIFormat); - LoadImageFunction loadFunction = d3d11::GetImageLoadFunction(mInternalFormat, type); + LoadImageFunction loadFunction = d3d11::GetImageLoadFunction(mInternalFormat, type, clientVersion); ASSERT(loadFunction != NULL); D3D11_MAPPED_SUBRESOURCE mappedImage; @@ -177,8 +179,9 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, const void *input) { - GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, GL_UNSIGNED_BYTE, width, 1); - GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, GL_UNSIGNED_BYTE, width, height, 1); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, 1); + GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, height, 1); GLuint outputPixelSize = d3d11::GetFormatPixelBytes(mDXGIFormat); GLuint outputBlockWidth = d3d11::GetBlockWidth(mDXGIFormat); @@ -187,7 +190,7 @@ void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GL ASSERT(xoffset % outputBlockWidth == 0); ASSERT(yoffset % outputBlockHeight == 0); - LoadImageFunction loadFunction = d3d11::GetImageLoadFunction(mInternalFormat, GL_UNSIGNED_BYTE); + LoadImageFunction loadFunction = d3d11::GetImageLoadFunction(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion); ASSERT(loadFunction != NULL); D3D11_MAPPED_SUBRESOURCE mappedImage; @@ -210,7 +213,7 @@ void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GL void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) { - gl::FramebufferAttachment *colorbuffer = source->getReadColorbuffer(); + gl::Renderbuffer *colorbuffer = source->getReadColorbuffer(); if (colorbuffer && colorbuffer->getActualFormat() == mActualFormat) { @@ -284,11 +287,12 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y } // determine the offset coordinate into the destination buffer - GLsizei rowOffset = gl::GetPixelBytes(mActualFormat) * xoffset; + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + GLsizei rowOffset = gl::GetPixelBytes(mActualFormat, clientVersion) * xoffset; void *dataOffset = static_cast(mappedImage.pData) + mappedImage.RowPitch * yoffset + rowOffset + zoffset * mappedImage.DepthPitch; - GLenum format = gl::GetFormat(mInternalFormat); - GLenum type = gl::GetType(mInternalFormat); + GLenum format = gl::GetFormat(mInternalFormat, clientVersion); + GLenum type = gl::GetType(mInternalFormat, clientVersion); mRenderer->readPixels(source, x, y, width, height, format, type, mappedImage.RowPitch, gl::PixelPackState(), dataOffset); @@ -350,8 +354,8 @@ void Image11::createStagingTexture() { std::vector initialData; std::vector< std::vector > textureData; - d3d11::GenerateInitialTextureData(mInternalFormat, width, height, mDepth, - lodOffset + 1, &initialData, &textureData); + d3d11::GenerateInitialTextureData(mInternalFormat, mRenderer->getCurrentClientVersion(), width, height, + mDepth, lodOffset + 1, &initialData, &textureData); result = device->CreateTexture3D(&desc, initialData.data(), &newTexture); } @@ -391,8 +395,8 @@ void Image11::createStagingTexture() { std::vector initialData; std::vector< std::vector > textureData; - d3d11::GenerateInitialTextureData(mInternalFormat, width, height, 1, - lodOffset + 1, &initialData, &textureData); + d3d11::GenerateInitialTextureData(mInternalFormat, mRenderer->getCurrentClientVersion(), width, height, + 1, lodOffset + 1, &initialData, &textureData); result = device->CreateTexture2D(&desc, initialData.data(), &newTexture); } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Image11.h b/gfx/angle/src/libGLESv2/renderer/d3d11/Image11.h similarity index 96% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Image11.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/Image11.h index 0ac7ac03d693..300774cf2313 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Image11.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/Image11.h @@ -34,7 +34,7 @@ class Image11 : public Image static Image11 *makeImage11(Image *img); - static void generateMipmap(Image11 *dest, Image11 *src); + static void generateMipmap(GLuint clientVersion, Image11 *dest, Image11 *src); virtual bool isDirty() const; diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/IndexBuffer11.cpp similarity index 97% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/IndexBuffer11.cpp index 03e4e6611b0f..afceac7012b4 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/IndexBuffer11.cpp @@ -7,8 +7,8 @@ // IndexBuffer11.cpp: Defines the D3D11 IndexBuffer implementation. -#include "libGLESv2/renderer/d3d/d3d11/IndexBuffer11.h" -#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h" +#include "libGLESv2/renderer/d3d11/IndexBuffer11.h" +#include "libGLESv2/renderer/d3d11/Renderer11.h" namespace rx { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.h b/gfx/angle/src/libGLESv2/renderer/d3d11/IndexBuffer11.h similarity index 93% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/IndexBuffer11.h index e821b7f3d1f2..39a61946ad6e 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/IndexBuffer11.h @@ -9,7 +9,7 @@ #ifndef LIBGLESV2_RENDERER_INDEXBUFFER11_H_ #define LIBGLESV2_RENDERER_INDEXBUFFER11_H_ -#include "libGLESv2/renderer/d3d/IndexBuffer.h" +#include "libGLESv2/renderer/IndexBuffer.h" namespace rx { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/InputLayoutCache.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/InputLayoutCache.cpp similarity index 94% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/InputLayoutCache.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/InputLayoutCache.cpp index a10f64e4ec32..7092dc5ddd43 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/InputLayoutCache.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/InputLayoutCache.cpp @@ -8,14 +8,14 @@ // 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/d3d11/InputLayoutCache.h" +#include "libGLESv2/renderer/d3d11/VertexBuffer11.h" +#include "libGLESv2/renderer/d3d11/BufferStorage11.h" +#include "libGLESv2/renderer/d3d11/ShaderExecutable11.h" #include "libGLESv2/ProgramBinary.h" #include "libGLESv2/VertexAttribute.h" -#include "libGLESv2/renderer/d3d/VertexDataManager.h" -#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h" +#include "libGLESv2/renderer/VertexDataManager.h" +#include "libGLESv2/renderer/d3d11/formatutils11.h" #include "third_party/murmurhash/MurmurHash3.h" @@ -194,7 +194,7 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M if (attributes[i].active) { VertexBuffer11 *vertexBuffer = VertexBuffer11::makeVertexBuffer11(attributes[i].vertexBuffer); - Buffer11 *bufferStorage = attributes[i].storage ? Buffer11::makeBuffer11(attributes[i].storage) : NULL; + BufferStorage11 *bufferStorage = attributes[i].storage ? BufferStorage11::makeBufferStorage11(attributes[i].storage) : NULL; buffer = bufferStorage ? bufferStorage->getBuffer(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK) : vertexBuffer->getBuffer(); diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/InputLayoutCache.h b/gfx/angle/src/libGLESv2/renderer/d3d11/InputLayoutCache.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/InputLayoutCache.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/InputLayoutCache.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/PixelTransfer11.cpp similarity index 88% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/PixelTransfer11.cpp index 1ca456c345eb..dcd1f99ab95c 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/PixelTransfer11.cpp @@ -10,24 +10,24 @@ // Used to implement pixel transfers from unpack and to pack buffers. // -#include "libGLESv2/renderer/d3d/d3d11/PixelTransfer11.h" +#include "libGLESv2/renderer/d3d11/PixelTransfer11.h" #include "libGLESv2/formatutils.h" #include "libGLESv2/Texture.h" #include "libGLESv2/Buffer.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/renderer/d3d11/Renderer11.h" +#include "libGLESv2/renderer/d3d11/renderer11_utils.h" +#include "libGLESv2/renderer/d3d11/formatutils11.h" +#include "libGLESv2/renderer/d3d11/BufferStorage11.h" +#include "libGLESv2/renderer/d3d11/TextureStorage11.h" +#include "libGLESv2/renderer/d3d11/RenderTarget11.h" #include "libGLESv2/Context.h" // Precompiled shaders -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture11_vs.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture11_gs.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture11_ps_4f.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture11_ps_4i.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture11_ps_4ui.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_vs.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_gs.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4f.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4i.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4ui.h" namespace rx { @@ -122,7 +122,7 @@ void PixelTransfer11::setBufferToTextureCopyParams(const gl::Box &destArea, cons float texelCenterX = 0.5f / static_cast(destSize.width - 1); float texelCenterY = 0.5f / static_cast(destSize.height - 1); - unsigned int bytesPerPixel = gl::GetPixelBytes(internalFormat); + unsigned int bytesPerPixel = gl::GetPixelBytes(internalFormat, 3); unsigned int alignmentBytes = static_cast(unpack.alignment); unsigned int alignmentPixels = (alignmentBytes <= bytesPerPixel ? 1 : alignmentBytes / bytesPerPixel); @@ -148,6 +148,7 @@ bool PixelTransfer11::copyBufferToTexture(const gl::PixelUnpackState &unpack, un return false; } + int clientVersion = mRenderer->getCurrentClientVersion(); const gl::Buffer &sourceBuffer = *unpack.pixelBuffer.get(); ASSERT(mRenderer->supportsFastCopyBufferToTexture(destinationFormat)); @@ -157,12 +158,12 @@ bool PixelTransfer11::copyBufferToTexture(const gl::PixelUnpackState &unpack, un // 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::GetFormat(destinationFormat); - GLenum sourceFormat = gl::GetSizedInternalFormat(unsizedFormat, sourcePixelsType); + GLenum unsizedFormat = gl::GetFormat(destinationFormat, clientVersion); + GLenum sourceFormat = gl::GetSizedInternalFormat(unsizedFormat, sourcePixelsType, clientVersion); - DXGI_FORMAT srvFormat = gl_d3d11::GetSRVFormat(sourceFormat); + DXGI_FORMAT srvFormat = gl_d3d11::GetSRVFormat(sourceFormat, clientVersion); ASSERT(srvFormat != DXGI_FORMAT_UNKNOWN); - Buffer11 *bufferStorage11 = Buffer11::makeBuffer11(sourceBuffer.getImplementation()); + BufferStorage11 *bufferStorage11 = BufferStorage11::makeBufferStorage11(sourceBuffer.getStorage()); ID3D11ShaderResourceView *bufferSRV = bufferStorage11->getSRV(srvFormat); ASSERT(bufferSRV != NULL); @@ -236,7 +237,8 @@ void PixelTransfer11::buildShaderMap() ID3D11PixelShader *PixelTransfer11::findBufferToTexturePS(GLenum internalFormat) const { - GLenum componentType = gl::GetComponentType(internalFormat); + int clientVersion = mRenderer->getCurrentClientVersion(); + GLenum componentType = gl::GetComponentType(internalFormat, clientVersion); if (componentType == GL_SIGNED_NORMALIZED || componentType == GL_UNSIGNED_NORMALIZED) { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.h b/gfx/angle/src/libGLESv2/renderer/d3d11/PixelTransfer11.h similarity index 98% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/PixelTransfer11.h index 2e2fee8f501b..574140d1984e 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/PixelTransfer11.h @@ -11,8 +11,6 @@ #ifndef LIBGLESV2_PIXELTRANSFER11_H_ #define LIBGLESV2_PIXELTRANSFER11_H_ -#include "common/platform.h" - namespace gl { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Query11.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/Query11.cpp similarity index 95% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Query11.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/Query11.cpp index 17cf5cad47a6..203f61f9f0ab 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Query11.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/Query11.cpp @@ -7,9 +7,9 @@ // 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/renderer/d3d11/Query11.h" +#include "libGLESv2/renderer/d3d11/Renderer11.h" +#include "libGLESv2/renderer/d3d11/renderer11_utils.h" #include "libGLESv2/main.h" namespace rx diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Query11.h b/gfx/angle/src/libGLESv2/renderer/d3d11/Query11.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Query11.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/Query11.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/RenderStateCache.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp similarity index 96% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/RenderStateCache.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp index 78a7357b2ba0..d0bfd6c8b9f5 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/RenderStateCache.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/RenderStateCache.cpp @@ -8,11 +8,11 @@ // 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/renderer/d3d11/RenderStateCache.h" +#include "libGLESv2/renderer/d3d11/renderer11_utils.h" +#include "libGLESv2/renderer/Renderer.h" #include "libGLESv2/Framebuffer.h" -#include "libGLESv2/FramebufferAttachment.h" +#include "libGLESv2/Renderbuffer.h" #include "common/debug.h" #include "third_party/murmurhash/MurmurHash3.h" @@ -93,18 +93,18 @@ ID3D11BlendState *RenderStateCache::getBlendState(const gl::Framebuffer *framebu key.blendState = blendState; for (unsigned int i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++) { - const gl::FramebufferAttachment *attachment = framebuffer->getColorbuffer(i); - if (attachment) + gl::Renderbuffer *renderBuffer = framebuffer->getColorbuffer(i); + if (renderBuffer) { if (i > 0) { mrt = true; } - key.rtChannels[i][0] = attachment->getRedSize() > 0; - key.rtChannels[i][1] = attachment->getGreenSize() > 0; - key.rtChannels[i][2] = attachment->getBlueSize() > 0; - key.rtChannels[i][3] = attachment->getAlphaSize() > 0; + key.rtChannels[i][0] = renderBuffer->getRedSize() > 0; + key.rtChannels[i][1] = renderBuffer->getGreenSize() > 0; + key.rtChannels[i][2] = renderBuffer->getBlueSize() > 0; + key.rtChannels[i][3] = renderBuffer->getAlphaSize() > 0; } else { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/RenderStateCache.h b/gfx/angle/src/libGLESv2/renderer/d3d11/RenderStateCache.h similarity index 98% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/RenderStateCache.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/RenderStateCache.h index e6380fbd8277..7f3349627ae5 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/RenderStateCache.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/RenderStateCache.h @@ -20,7 +20,6 @@ class Framebuffer; namespace rx { -class Renderer11; class RenderStateCache { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/RenderTarget11.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/RenderTarget11.cpp similarity index 89% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/RenderTarget11.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/RenderTarget11.cpp index 6aa75ae5bd99..a5c3340eb9bd 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/RenderTarget11.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/RenderTarget11.cpp @@ -8,11 +8,11 @@ // 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/d3d11/RenderTarget11.h" +#include "libGLESv2/renderer/d3d11/Renderer11.h" -#include "libGLESv2/renderer/d3d/d3d11/renderer11_utils.h" -#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h" +#include "libGLESv2/renderer/d3d11/renderer11_utils.h" +#include "libGLESv2/renderer/d3d11/formatutils11.h" #include "libGLESv2/main.h" namespace rx @@ -219,8 +219,8 @@ RenderTarget11::RenderTarget11(Renderer *renderer, ID3D11RenderTargetView *rtv, mDepth = depth; mSamples = samples; - mInternalFormat = d3d11_gl::GetInternalFormat(desc.Format); - mActualFormat = d3d11_gl::GetInternalFormat(desc.Format); + mInternalFormat = d3d11_gl::GetInternalFormat(desc.Format, renderer->getCurrentClientVersion()); + mActualFormat = d3d11_gl::GetInternalFormat(desc.Format, renderer->getCurrentClientVersion()); } } @@ -265,8 +265,8 @@ RenderTarget11::RenderTarget11(Renderer *renderer, ID3D11DepthStencilView *dsv, mDepth = depth; mSamples = samples; - mInternalFormat = d3d11_gl::GetInternalFormat(desc.Format); - mActualFormat = d3d11_gl::GetInternalFormat(desc.Format); + mInternalFormat = d3d11_gl::GetInternalFormat(desc.Format, renderer->getCurrentClientVersion()); + mActualFormat = d3d11_gl::GetInternalFormat(desc.Format, renderer->getCurrentClientVersion()); } } @@ -278,10 +278,12 @@ RenderTarget11::RenderTarget11(Renderer *renderer, GLsizei width, GLsizei height mDepthStencil = NULL; mShaderResource = NULL; - DXGI_FORMAT texFormat = gl_d3d11::GetTexFormat(internalFormat); - DXGI_FORMAT srvFormat = gl_d3d11::GetSRVFormat(internalFormat); - DXGI_FORMAT rtvFormat = gl_d3d11::GetRTVFormat(internalFormat); - DXGI_FORMAT dsvFormat = gl_d3d11::GetDSVFormat(internalFormat); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + + DXGI_FORMAT texFormat = gl_d3d11::GetTexFormat(internalFormat, clientVersion); + DXGI_FORMAT srvFormat = gl_d3d11::GetSRVFormat(internalFormat, clientVersion); + DXGI_FORMAT rtvFormat = gl_d3d11::GetRTVFormat(internalFormat, clientVersion); + DXGI_FORMAT dsvFormat = gl_d3d11::GetDSVFormat(internalFormat, clientVersion); DXGI_FORMAT multisampleFormat = (dsvFormat != DXGI_FORMAT_UNKNOWN ? dsvFormat : rtvFormat); int supportedSamples = mRenderer->getNearestSupportedSamples(multisampleFormat, samples); @@ -305,24 +307,9 @@ RenderTarget11::RenderTarget11(Renderer *renderer, GLsizei width, GLsizei height 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 = (rtvFormat != DXGI_FORMAT_UNKNOWN); - bindDSV = (dsvFormat != DXGI_FORMAT_UNKNOWN); - if (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 = !(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); + desc.BindFlags = ((srvFormat != DXGI_FORMAT_UNKNOWN) ? D3D11_BIND_SHADER_RESOURCE : 0) | + ((dsvFormat != DXGI_FORMAT_UNKNOWN) ? D3D11_BIND_DEPTH_STENCIL : 0) | + ((rtvFormat != DXGI_FORMAT_UNKNOWN) ? D3D11_BIND_RENDER_TARGET : 0); ID3D11Device *device = mRenderer->getDevice(); ID3D11Texture2D *texture = NULL; @@ -336,7 +323,7 @@ RenderTarget11::RenderTarget11(Renderer *renderer, GLsizei width, GLsizei height } ASSERT(SUCCEEDED(result)); - if (bindSRV) + if (srvFormat != DXGI_FORMAT_UNKNOWN) { D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; srvDesc.Format = srvFormat; @@ -354,7 +341,7 @@ RenderTarget11::RenderTarget11(Renderer *renderer, GLsizei width, GLsizei height ASSERT(SUCCEEDED(result)); } - if (bindDSV) + if (dsvFormat != DXGI_FORMAT_UNKNOWN) { D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc; dsvDesc.Format = dsvFormat; @@ -373,7 +360,7 @@ RenderTarget11::RenderTarget11(Renderer *renderer, GLsizei width, GLsizei height ASSERT(SUCCEEDED(result)); } - if (bindRTV) + if (rtvFormat != DXGI_FORMAT_UNKNOWN) { D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; rtvDesc.Format = rtvFormat; @@ -406,7 +393,7 @@ RenderTarget11::RenderTarget11(Renderer *renderer, GLsizei width, GLsizei height mDepth = 1; mInternalFormat = internalFormat; mSamples = supportedSamples; - mActualFormat = d3d11_gl::GetInternalFormat(texFormat); + mActualFormat = d3d11_gl::GetInternalFormat(texFormat, renderer->getCurrentClientVersion()); mSubresourceIndex = D3D11CalcSubresource(0, 0, 1); } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/RenderTarget11.h b/gfx/angle/src/libGLESv2/renderer/d3d11/RenderTarget11.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/RenderTarget11.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/RenderTarget11.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/Renderer11.cpp similarity index 88% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/Renderer11.cpp index ddb623633d34..143799ab83e5 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/Renderer11.cpp @@ -10,29 +10,27 @@ #include "libGLESv2/main.h" #include "common/utilities.h" #include "libGLESv2/Buffer.h" -#include "libGLESv2/FramebufferAttachment.h" #include "libGLESv2/ProgramBinary.h" #include "libGLESv2/Framebuffer.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/RenderBuffer.h" +#include "libGLESv2/renderer/d3d11/Renderer11.h" +#include "libGLESv2/renderer/d3d11/RenderTarget11.h" +#include "libGLESv2/renderer/d3d11/renderer11_utils.h" +#include "libGLESv2/renderer/d3d11/formatutils11.h" +#include "libGLESv2/renderer/d3d11/ShaderExecutable11.h" +#include "libGLESv2/renderer/d3d11/SwapChain11.h" +#include "libGLESv2/renderer/d3d11/Image11.h" +#include "libGLESv2/renderer/d3d11/VertexBuffer11.h" +#include "libGLESv2/renderer/d3d11/IndexBuffer11.h" +#include "libGLESv2/renderer/d3d11/BufferStorage11.h" +#include "libGLESv2/renderer/VertexDataManager.h" +#include "libGLESv2/renderer/IndexDataManager.h" +#include "libGLESv2/renderer/d3d11/TextureStorage11.h" +#include "libGLESv2/renderer/d3d11/Query11.h" +#include "libGLESv2/renderer/d3d11/Fence11.h" +#include "libGLESv2/renderer/d3d11/Blit11.h" +#include "libGLESv2/renderer/d3d11/Clear11.h" +#include "libGLESv2/renderer/d3d11/PixelTransfer11.h" #include "libEGL/Display.h" // Enable ANGLE_SKIP_DXGI_1_2_CHECK if there is not a possibility of using cross-process @@ -97,6 +95,8 @@ Renderer11::Renderer11(egl::Display *display, HDC hDc) : Renderer(display), mDc( mDriverConstantBufferVS = NULL; mDriverConstantBufferPS = NULL; + mBGRATextureSupport = false; + mAppliedVertexShader = NULL; mAppliedGeometryShader = NULL; mCurPointGeometryShader = NULL; @@ -285,6 +285,154 @@ EGLint Renderer11::initialize() initializeDevice(); + // BGRA texture support is optional in feature levels 10 and 10_1 + UINT formatSupport; + result = mDevice->CheckFormatSupport(DXGI_FORMAT_B8G8R8A8_UNORM, &formatSupport); + if (FAILED(result)) + { + ERR("Error checking BGRA format support: 0x%08X", result); + } + else + { + const int flags = (D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_RENDER_TARGET); + mBGRATextureSupport = (formatSupport & flags) == flags; + } + + // Check floating point texture support + static const unsigned int requiredTextureFlags = D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_TEXTURECUBE; + static const unsigned int requiredRenderableFlags = D3D11_FORMAT_SUPPORT_RENDER_TARGET; + static const unsigned int requiredFilterFlags = D3D11_FORMAT_SUPPORT_SHADER_SAMPLE; + + DXGI_FORMAT float16Formats[] = + { + DXGI_FORMAT_R16_FLOAT, + DXGI_FORMAT_R16G16_FLOAT, + DXGI_FORMAT_R16G16B16A16_FLOAT, + }; + + DXGI_FORMAT float32Formats[] = + { + DXGI_FORMAT_R32_FLOAT, + DXGI_FORMAT_R32G32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT, + }; + + mFloat16TextureSupport = true; + mFloat16FilterSupport = true; + mFloat16RenderSupport = true; + for (unsigned int i = 0; i < ArraySize(float16Formats); i++) + { + if (SUCCEEDED(mDevice->CheckFormatSupport(float16Formats[i], &formatSupport))) + { + mFloat16TextureSupport = mFloat16TextureSupport && (formatSupport & requiredTextureFlags) == requiredTextureFlags; + mFloat16FilterSupport = mFloat16FilterSupport && (formatSupport & requiredFilterFlags) == requiredFilterFlags; + mFloat16RenderSupport = mFloat16RenderSupport && (formatSupport & requiredRenderableFlags) == requiredRenderableFlags; + } + else + { + mFloat16TextureSupport = false; + mFloat16RenderSupport = false; + mFloat16FilterSupport = false; + } + } + + mFloat32TextureSupport = true; + mFloat32FilterSupport = true; + mFloat32RenderSupport = true; + for (unsigned int i = 0; i < ArraySize(float32Formats); i++) + { + if (SUCCEEDED(mDevice->CheckFormatSupport(float32Formats[i], &formatSupport))) + { + mFloat32TextureSupport = mFloat32TextureSupport && (formatSupport & requiredTextureFlags) == requiredTextureFlags; + mFloat32FilterSupport = mFloat32FilterSupport && (formatSupport & requiredFilterFlags) == requiredFilterFlags; + mFloat32RenderSupport = mFloat32RenderSupport && (formatSupport & requiredRenderableFlags) == requiredRenderableFlags; + } + else + { + mFloat32TextureSupport = false; + mFloat32FilterSupport = false; + mFloat32RenderSupport = false; + } + } + + DXGI_FORMAT rgTextureFormats[] = + { + DXGI_FORMAT_R8_UNORM, + DXGI_FORMAT_R8G8_UNORM, + DXGI_FORMAT_R16_FLOAT, + DXGI_FORMAT_R16G16_FLOAT, + DXGI_FORMAT_R32_FLOAT, + DXGI_FORMAT_R32G32_FLOAT, + }; + + mRGTextureSupport = true; + for (unsigned int i = 0; i < ArraySize(rgTextureFormats); i++) + { + if (SUCCEEDED(mDevice->CheckFormatSupport(rgTextureFormats[i], &formatSupport))) + { + mRGTextureSupport = mRGTextureSupport && (formatSupport & requiredTextureFlags) == requiredTextureFlags; + mRGTextureSupport = mRGTextureSupport && (formatSupport & requiredFilterFlags) == requiredFilterFlags; + mRGTextureSupport = mRGTextureSupport && (formatSupport & requiredRenderableFlags) == requiredRenderableFlags; + } + else + { + mRGTextureSupport = false; + } + } + + // Check compressed texture support + const unsigned int requiredCompressedTextureFlags = D3D11_FORMAT_SUPPORT_TEXTURE2D; + + if (SUCCEEDED(mDevice->CheckFormatSupport(DXGI_FORMAT_BC1_UNORM, &formatSupport))) + { + mDXT1TextureSupport = (formatSupport & requiredCompressedTextureFlags) == requiredCompressedTextureFlags; + } + else + { + mDXT1TextureSupport = false; + } + + if (SUCCEEDED(mDevice->CheckFormatSupport(DXGI_FORMAT_BC3_UNORM, &formatSupport))) + { + mDXT3TextureSupport = (formatSupport & requiredCompressedTextureFlags) == requiredCompressedTextureFlags; + } + else + { + mDXT3TextureSupport = false; + } + + if (SUCCEEDED(mDevice->CheckFormatSupport(DXGI_FORMAT_BC5_UNORM, &formatSupport))) + { + mDXT5TextureSupport = (formatSupport & requiredCompressedTextureFlags) == requiredCompressedTextureFlags; + } + else + { + mDXT5TextureSupport = false; + } + + // Check depth texture support + DXGI_FORMAT depthTextureFormats[] = + { + DXGI_FORMAT_D16_UNORM, + DXGI_FORMAT_D24_UNORM_S8_UINT, + }; + + static const unsigned int requiredDepthTextureFlags = D3D11_FORMAT_SUPPORT_DEPTH_STENCIL | + D3D11_FORMAT_SUPPORT_TEXTURE2D; + + mDepthTextureSupport = true; + for (unsigned int i = 0; i < ArraySize(depthTextureFormats); i++) + { + if (SUCCEEDED(mDevice->CheckFormatSupport(depthTextureFormats[i], &formatSupport))) + { + mDepthTextureSupport = mDepthTextureSupport && ((formatSupport & requiredDepthTextureFlags) == requiredDepthTextureFlags); + } + else + { + mDepthTextureSupport = false; + } + } + return EGL_SUCCESS; } @@ -343,9 +491,13 @@ int Renderer11::generateConfigs(ConfigDesc **configDescList) if (depthStencilFormatOK) { + // FIXME: parse types from context version + ASSERT(d3d11_gl::GetInternalFormat(renderTargetFormat, 2) == d3d11_gl::GetInternalFormat(renderTargetFormat, 3)); + ASSERT(d3d11_gl::GetInternalFormat(depthStencilFormat, 2) == d3d11_gl::GetInternalFormat(depthStencilFormat, 3)); + ConfigDesc newConfig; - newConfig.renderTargetFormat = d3d11_gl::GetInternalFormat(renderTargetFormat); - newConfig.depthStencilFormat = d3d11_gl::GetInternalFormat(depthStencilFormat); + newConfig.renderTargetFormat = d3d11_gl::GetInternalFormat(renderTargetFormat, getCurrentClientVersion()); + newConfig.depthStencilFormat = d3d11_gl::GetInternalFormat(depthStencilFormat, getCurrentClientVersion()); newConfig.multiSample = 0; // FIXME: enumerate multi-sampling newConfig.fastConfig = true; // Assume all DX11 format conversions to be fast newConfig.es3Capable = true; @@ -541,7 +693,7 @@ bool Renderer11::setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], con const gl::Buffer *uniformBuffer = vertexUniformBuffers[uniformBufferIndex]; if (uniformBuffer) { - Buffer11 *bufferStorage = Buffer11::makeBuffer11(uniformBuffer->getImplementation()); + BufferStorage11 *bufferStorage = BufferStorage11::makeBufferStorage11(uniformBuffer->getStorage()); ID3D11Buffer *constantBuffer = bufferStorage->getBuffer(BUFFER_USAGE_UNIFORM); if (!constantBuffer) @@ -563,7 +715,7 @@ bool Renderer11::setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], con const gl::Buffer *uniformBuffer = fragmentUniformBuffers[uniformBufferIndex]; if (uniformBuffer) { - Buffer11 *bufferStorage = Buffer11::makeBuffer11(uniformBuffer->getImplementation()); + BufferStorage11 *bufferStorage = BufferStorage11::makeBufferStorage11(uniformBuffer->getStorage()); ID3D11Buffer *constantBuffer = bufferStorage->getBuffer(BUFFER_USAGE_UNIFORM); if (!constantBuffer) @@ -651,9 +803,14 @@ void Renderer11::setDepthStencilState(const gl::DepthStencilState &depthStencilS memcmp(&depthStencilState, &mCurDepthStencilState, sizeof(gl::DepthStencilState)) != 0 || stencilRef != mCurStencilRef || stencilBackRef != mCurStencilBackRef) { - ASSERT(depthStencilState.stencilWritemask == depthStencilState.stencilBackWritemask); - ASSERT(stencilRef == stencilBackRef); - ASSERT(depthStencilState.stencilMask == depthStencilState.stencilBackMask); + if (depthStencilState.stencilWritemask != depthStencilState.stencilBackWritemask || + stencilRef != stencilBackRef || + depthStencilState.stencilMask != depthStencilState.stencilBackMask) + { + ERR("Separate front/back stencil writemasks, reference values, or stencil mask values are " + "invalid under WebGL."); + return gl::error(GL_INVALID_OPERATION); + } ID3D11DepthStencilState *dxDepthStencilState = mStateCache.getDepthStencilState(depthStencilState); if (!dxDepthStencilState) @@ -790,8 +947,7 @@ bool Renderer11::applyPrimitiveType(GLenum mode, GLsizei count) // emulate fans via rewriting index buffer case GL_TRIANGLE_FAN: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; minCount = 3; break; default: - UNREACHABLE(); - return false; + return gl::error(GL_INVALID_ENUM, false); } if (primitiveTopology != mCurrentPrimitiveTopology) @@ -823,7 +979,7 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) // the draw buffer must be either "none", "back" for the default buffer or the same index as this color (in order) ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + colorAttachment)); - gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(colorAttachment); + gl::Renderbuffer *colorbuffer = framebuffer->getColorbuffer(colorAttachment); if (!colorbuffer) { @@ -870,7 +1026,7 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) } // Get the depth stencil render buffer and serials - gl::FramebufferAttachment *depthStencil = NULL; + gl::Renderbuffer *depthStencil = NULL; unsigned int depthbufferSerial = 0; unsigned int stencilbufferSerial = 0; if (framebuffer->getDepthbufferType() != GL_NONE) @@ -988,7 +1144,7 @@ GLenum Renderer11::applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementAr if (indexInfo->storage) { - Buffer11 *storage = Buffer11::makeBuffer11(indexInfo->storage); + BufferStorage11 *storage = BufferStorage11::makeBufferStorage11(indexInfo->storage); buffer = storage->getBuffer(BUFFER_USAGE_INDEX); } else @@ -1018,7 +1174,7 @@ void Renderer11::applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuff { if (transformFeedbackBuffers[i]) { - Buffer11 *storage = Buffer11::makeBuffer11(transformFeedbackBuffers[i]->getImplementation()); + BufferStorage11 *storage = BufferStorage11::makeBufferStorage11(transformFeedbackBuffers[i]->getStorage()); ID3D11Buffer *buffer = storage->getBuffer(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK); d3dBuffers[i] = buffer; @@ -1126,7 +1282,7 @@ void Renderer11::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, if (type != GL_NONE && elementArrayBuffer) { gl::Buffer *indexBuffer = elementArrayBuffer; - BufferImpl *storage = indexBuffer->getImplementation(); + BufferStorage *storage = indexBuffer->getStorage(); intptr_t offset = reinterpret_cast(indices); indices = static_cast(storage->getData()) + offset; } @@ -1231,7 +1387,7 @@ void Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indic if (type != GL_NONE && elementArrayBuffer) { gl::Buffer *indexBuffer = elementArrayBuffer; - BufferImpl *storage = indexBuffer->getImplementation(); + BufferStorage *storage = indexBuffer->getStorage(); intptr_t offset = reinterpret_cast(indices); indices = static_cast(storage->getData()) + offset; } @@ -1343,11 +1499,10 @@ void Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indic } } -void Renderer11::applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer, - bool rasterizerDiscard, bool transformFeedbackActive) +void Renderer11::applyShaders(gl::ProgramBinary *programBinary, bool rasterizerDiscard, bool transformFeedbackActive, const gl::VertexFormat inputLayout[]) { ShaderExecutable *vertexExe = programBinary->getVertexExecutableForInputLayout(inputLayout); - ShaderExecutable *pixelExe = programBinary->getPixelExecutableForFramebuffer(framebuffer); + ShaderExecutable *pixelExe = programBinary->getPixelExecutable(); ShaderExecutable *geometryExe = programBinary->getGeometryExecutable(); ID3D11VertexShader *vertexShader = (vertexExe ? ShaderExecutable11::makeShaderExecutable11(vertexExe)->getVertexShader() : NULL); @@ -1814,6 +1969,110 @@ GUID Renderer11::getAdapterIdentifier() const return adapterId; } +bool Renderer11::getBGRATextureSupport() const +{ + return mBGRATextureSupport; +} + +bool Renderer11::getDXT1TextureSupport() const +{ + return mDXT1TextureSupport; +} + +bool Renderer11::getDXT3TextureSupport() const +{ + return mDXT3TextureSupport; +} + +bool Renderer11::getDXT5TextureSupport() const +{ + return mDXT5TextureSupport; +} + +bool Renderer11::getDepthTextureSupport() const +{ + return mDepthTextureSupport; +} + +bool Renderer11::getFloat32TextureSupport() const +{ + return mFloat32TextureSupport; +} + +bool Renderer11::getFloat32TextureFilteringSupport() const +{ + return mFloat32FilterSupport; +} + +bool Renderer11::getFloat32TextureRenderingSupport() const +{ + return mFloat32RenderSupport; +} + +bool Renderer11::getFloat16TextureSupport() const +{ + return mFloat16TextureSupport; +} + +bool Renderer11::getFloat16TextureFilteringSupport() const +{ + return mFloat16FilterSupport; +} + +bool Renderer11::getFloat16TextureRenderingSupport() const +{ + return mFloat16RenderSupport; +} + +bool Renderer11::getRGB565TextureSupport() const +{ + return false; +} + +bool Renderer11::getLuminanceTextureSupport() const +{ + return false; +} + +bool Renderer11::getLuminanceAlphaTextureSupport() const +{ + return false; +} + +bool Renderer11::getRGTextureSupport() const +{ + return mRGTextureSupport; +} + +bool Renderer11::getTextureFilterAnisotropySupport() const +{ + return true; +} + +bool Renderer11::getPBOSupport() const +{ + return true; +} + +float Renderer11::getTextureMaxAnisotropy() const +{ + switch (mFeatureLevel) + { + 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; + default: UNREACHABLE(); + return 0; + } +} + +bool Renderer11::getEventQuerySupport() const +{ + return true; +} + Range Renderer11::getViewportBounds() const { switch (mFeatureLevel) @@ -1937,7 +2196,7 @@ unsigned int Renderer11::getReservedFragmentUniformBuffers() const unsigned int Renderer11::getReservedVaryings() const { - // We potentially reserve varyings for gl_Position, dx_Position, gl_FragCoord and gl_PointSize + // We potentially reserve varyings for gl_Position, _dx_Position, gl_FragCoord and gl_PointSize return 4; } @@ -1998,12 +2257,64 @@ unsigned int Renderer11::getMaxUniformBufferSize() const } } +bool Renderer11::getNonPower2TextureSupport() const +{ + switch (mFeatureLevel) + { + case D3D_FEATURE_LEVEL_11_0: + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: + return true; + default: UNREACHABLE(); + return false; + } +} + +bool Renderer11::getOcclusionQuerySupport() const +{ + switch (mFeatureLevel) + { + case D3D_FEATURE_LEVEL_11_0: + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: + return true; + default: UNREACHABLE(); + return false; + } +} + +bool Renderer11::getInstancingSupport() const +{ + switch (mFeatureLevel) + { + case D3D_FEATURE_LEVEL_11_0: + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: + return true; + default: UNREACHABLE(); + return false; + } +} + 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 getCaps().extensions.textureFormatBGRA8888 && !gl::perfActive(); + return getBGRATextureSupport() && !gl::perfActive(); +} + +bool Renderer11::getDerivativeInstructionSupport() const +{ + switch (mFeatureLevel) + { + case D3D_FEATURE_LEVEL_11_0: + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: + return true; + default: UNREACHABLE(); + return false; + } } bool Renderer11::getPostSubBufferSupport() const @@ -2030,11 +2341,6 @@ int Renderer11::getMaxRecommendedElementsVertices() const return std::numeric_limits::max(); } -bool Renderer11::getSRGBTextureSupport() const -{ - return true; -} - int Renderer11::getMajorShaderModel() const { switch (mFeatureLevel) @@ -2127,6 +2433,17 @@ int Renderer11::getMaxTextureArrayLayers() const } } +bool Renderer11::get32BitIndexSupport() const +{ + switch (mFeatureLevel) + { + case D3D_FEATURE_LEVEL_11_0: + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: return D3D10_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP >= 32; // true + default: UNREACHABLE(); return false; + } +} + int Renderer11::getMinSwapInterval() const { return 0; @@ -2144,7 +2461,7 @@ int Renderer11::getMaxSupportedSamples() const GLsizei Renderer11::getMaxSupportedFormatSamples(GLenum internalFormat) const { - DXGI_FORMAT format = gl_d3d11::GetRenderableFormat(internalFormat); + DXGI_FORMAT format = gl_d3d11::GetRenderableFormat(internalFormat, getCurrentClientVersion()); MultisampleSupportMap::const_iterator iter = mMultisampleSupportMap.find(format); return (iter != mMultisampleSupportMap.end()) ? iter->second.maxSupportedSamples : 0; } @@ -2154,10 +2471,10 @@ GLsizei Renderer11::getNumSampleCounts(GLenum internalFormat) const unsigned int numCounts = 0; // D3D11 supports multisampling for signed and unsigned format, but ES 3.0 does not - GLenum componentType = gl::GetComponentType(internalFormat); + GLenum componentType = gl::GetComponentType(internalFormat, getCurrentClientVersion()); if (componentType != GL_INT && componentType != GL_UNSIGNED_INT) { - DXGI_FORMAT format = gl_d3d11::GetRenderableFormat(internalFormat); + DXGI_FORMAT format = gl_d3d11::GetRenderableFormat(internalFormat, getCurrentClientVersion()); MultisampleSupportMap::const_iterator iter = mMultisampleSupportMap.find(format); if (iter != mMultisampleSupportMap.end()) @@ -2179,13 +2496,13 @@ GLsizei Renderer11::getNumSampleCounts(GLenum internalFormat) const void Renderer11::getSampleCounts(GLenum internalFormat, GLsizei bufSize, GLint *params) const { // D3D11 supports multisampling for signed and unsigned format, but ES 3.0 does not - GLenum componentType = gl::GetComponentType(internalFormat); + GLenum componentType = gl::GetComponentType(internalFormat, getCurrentClientVersion()); if (componentType == GL_INT || componentType == GL_UNSIGNED_INT) { return; } - DXGI_FORMAT format = gl_d3d11::GetRenderableFormat(internalFormat); + DXGI_FORMAT format = gl_d3d11::GetRenderableFormat(internalFormat, getCurrentClientVersion()); MultisampleSupportMap::const_iterator iter = mMultisampleSupportMap.find(format); if (iter != mMultisampleSupportMap.end()) @@ -2227,7 +2544,23 @@ int Renderer11::getNearestSupportedSamples(DXGI_FORMAT format, unsigned int requ unsigned int Renderer11::getMaxRenderTargets() const { - return d3d11::GetMaximumSimultaneousRenderTargets(mFeatureLevel); + META_ASSERT(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT <= gl::IMPLEMENTATION_MAX_DRAW_BUFFERS); + META_ASSERT(D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT <= gl::IMPLEMENTATION_MAX_DRAW_BUFFERS); + + switch (mFeatureLevel) + { + case D3D_FEATURE_LEVEL_11_0: + return D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; // 8 + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: + // Feature level 10.0 and 10.1 cards perform very poorly when the pixel shader + // outputs to multiple RTs that are not bound. + // TODO: Remove pixel shader outputs for render targets that are not bound. + return 1; + default: + UNREACHABLE(); + return 1; + } } bool Renderer11::copyToRenderTarget(TextureStorageInterface2D *dest, TextureStorageInterface2D *source) @@ -2301,7 +2634,7 @@ bool Renderer11::copyToRenderTarget(TextureStorageInterface2DArray *dest, Textur bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorageInterface2D *storage, GLint level) { - gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer(); + gl::Renderbuffer *colorbuffer = framebuffer->getReadColorbuffer(); if (!colorbuffer) { ERR("Failed to retrieve the color buffer from the frame buffer."); @@ -2362,7 +2695,7 @@ bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &so bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorageInterfaceCube *storage, GLenum target, GLint level) { - gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer(); + gl::Renderbuffer *colorbuffer = framebuffer->getReadColorbuffer(); if (!colorbuffer) { ERR("Failed to retrieve the color buffer from the frame buffer."); @@ -2423,7 +2756,7 @@ bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &so bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface3D *storage, GLint level) { - gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer(); + gl::Renderbuffer *colorbuffer = framebuffer->getReadColorbuffer(); if (!colorbuffer) { ERR("Failed to retrieve the color buffer from the frame buffer."); @@ -2484,7 +2817,7 @@ bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &so bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface2DArray *storage, GLint level) { - gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer(); + gl::Renderbuffer *colorbuffer = framebuffer->getReadColorbuffer(); if (!colorbuffer) { ERR("Failed to retrieve the color buffer from the frame buffer."); @@ -2617,8 +2950,6 @@ ShaderExecutable *Renderer11::loadExecutable(const void *function, size_t length 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 }; @@ -2626,7 +2957,7 @@ ShaderExecutable *Renderer11::loadExecutable(const void *function, size_t length entry.SemanticName = varying.semanticName.c_str(); entry.SemanticIndex = varying.semanticIndex + j; entry.StartComponent = 0; - entry.ComponentCount = gl::VariableColumnCount(transposedType); + entry.ComponentCount = gl::VariableRowCount(type); entry.OutputSlot = (separatedOutputBuffers ? i : 0); soDeclaration.push_back(entry); } @@ -2779,14 +3110,9 @@ IndexBuffer *Renderer11::createIndexBuffer() return new IndexBuffer11(this); } -BufferImpl *Renderer11::createBuffer() +BufferStorage *Renderer11::createBufferStorage() { - return new Buffer11(this); -} - -VertexArrayImpl *Renderer11::createVertexArray() -{ - return new VertexArray11(this); + return new BufferStorage11(this); } QueryImpl *Renderer11::createQuery(GLenum type) @@ -2801,22 +3127,28 @@ FenceImpl *Renderer11::createFence() bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const { - ASSERT(getCaps().extensions.pixelBufferObject); + int clientVersion = getCurrentClientVersion(); + + // We only support buffer to texture copies in ES3 + if (clientVersion <= 2) + { + return false; + } // sRGB formats do not work with D3D11 buffer SRVs - if (gl::GetColorEncoding(internalFormat) == GL_SRGB) + if (gl::GetColorEncoding(internalFormat, clientVersion) == GL_SRGB) { return false; } // We cannot support direct copies to non-color-renderable formats - if (!getCaps().textureCaps.get(internalFormat).colorRendering) + if (!gl::IsColorRenderingSupported(internalFormat, this)) { return false; } // We skip all 3-channel formats since sometimes format support is missing - if (gl::GetComponentCount(internalFormat) == 3) + if (gl::GetComponentCount(internalFormat, clientVersion) == 3) { return false; } @@ -2837,7 +3169,7 @@ bool Renderer11::fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, uns return mPixelTransfer->copyBufferToTexture(unpack, offset, destRenderTarget, destinationFormat, sourcePixelsType, destArea); } -bool Renderer11::getRenderTargetResource(gl::FramebufferAttachment *colorbuffer, unsigned int *subresourceIndex, ID3D11Texture2D **resource) +bool Renderer11::getRenderTargetResource(gl::Renderbuffer *colorbuffer, unsigned int *subresourceIndex, ID3D11Texture2D **resource) { ASSERT(colorbuffer != NULL); @@ -2878,7 +3210,7 @@ bool Renderer11::blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &read { if (blitRenderTarget) { - gl::FramebufferAttachment *readBuffer = readTarget->getReadColorbuffer(); + gl::Renderbuffer *readBuffer = readTarget->getReadColorbuffer(); if (!readBuffer) { @@ -2892,7 +3224,7 @@ bool Renderer11::blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &read { if (drawTarget->isEnabledColorAttachment(colorAttachment)) { - gl::FramebufferAttachment *drawBuffer = drawTarget->getColorbuffer(colorAttachment); + gl::Renderbuffer *drawBuffer = drawTarget->getColorbuffer(colorAttachment); if (!drawBuffer) { @@ -2913,8 +3245,8 @@ bool Renderer11::blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &read if (blitDepth || blitStencil) { - gl::FramebufferAttachment *readBuffer = readTarget->getDepthOrStencilbuffer(); - gl::FramebufferAttachment *drawBuffer = drawTarget->getDepthOrStencilbuffer(); + gl::Renderbuffer *readBuffer = readTarget->getDepthOrStencilbuffer(); + gl::Renderbuffer *drawBuffer = drawTarget->getDepthOrStencilbuffer(); if (!readBuffer) { @@ -2949,7 +3281,7 @@ void Renderer11::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsi ID3D11Texture2D *colorBufferTexture = NULL; unsigned int subresourceIndex = 0; - gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer(); + gl::Renderbuffer *colorbuffer = framebuffer->getReadColorbuffer(); if (colorbuffer && getRenderTargetResource(colorbuffer, &subresourceIndex, &colorBufferTexture)) { @@ -2961,7 +3293,7 @@ void Renderer11::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsi if (pack.pixelBuffer.get() != NULL) { - rx::Buffer11 *packBufferStorage = Buffer11::makeBuffer11(pack.pixelBuffer.get()->getImplementation()); + rx::BufferStorage11 *packBufferStorage = BufferStorage11::makeBufferStorage11(pack.pixelBuffer.get()->getStorage()); PackPixelsParams packParams(area, format, type, outputPitch, pack, reinterpret_cast(pixels)); packBufferStorage->packPixels(colorBufferTexture, subresourceIndex, packParams); } @@ -2983,7 +3315,7 @@ void Renderer11::generateMipmap(Image *dest, Image *src) { Image11 *dest11 = Image11::makeImage11(dest); Image11 *src11 = Image11::makeImage11(src); - Image11::generateMipmap(dest11, src11); + Image11::generateMipmap(getCurrentClientVersion(), dest11, src11); } TextureStorage *Renderer11::createTextureStorage2D(SwapChain *swapChain) @@ -3136,11 +3468,13 @@ void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams inputPitch = static_cast(mapping.RowPitch); } - GLenum sourceInternalFormat = d3d11_gl::GetInternalFormat(textureDesc.Format); - GLenum sourceFormat = gl::GetFormat(sourceInternalFormat); - GLenum sourceType = gl::GetType(sourceInternalFormat); + GLuint clientVersion = getCurrentClientVersion(); - GLuint sourcePixelSize = gl::GetPixelBytes(sourceInternalFormat); + GLenum sourceInternalFormat = d3d11_gl::GetInternalFormat(textureDesc.Format, clientVersion); + GLenum sourceFormat = gl::GetFormat(sourceInternalFormat, clientVersion); + GLenum sourceType = gl::GetType(sourceInternalFormat, clientVersion); + + GLuint sourcePixelSize = gl::GetPixelBytes(sourceInternalFormat, clientVersion); if (sourceFormat == params.format && sourceType == params.type) { @@ -3152,8 +3486,8 @@ void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams } else { - GLenum destInternalFormat = gl::GetSizedInternalFormat(params.format, params.type); - GLuint destPixelSize = gl::GetPixelBytes(destInternalFormat); + GLenum destInternalFormat = gl::GetSizedInternalFormat(params.format, params.type, clientVersion); + GLuint destPixelSize = gl::GetPixelBytes(destInternalFormat, clientVersion); ColorCopyFunction fastCopyFunc = d3d11::GetFastCopyFunction(textureDesc.Format, params.format, params.type); if (fastCopyFunc) @@ -3173,7 +3507,7 @@ void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams else { ColorReadFunction readFunc = d3d11::GetColorReadFunction(textureDesc.Format); - ColorWriteFunction writeFunc = gl::GetColorWriteFunction(params.format, params.type); + ColorWriteFunction writeFunc = gl::GetColorWriteFunction(params.format, params.type, clientVersion); unsigned char temp[16]; // Maximum size of any Color type used. META_ASSERT(sizeof(temp) >= sizeof(gl::ColorF) && @@ -3289,8 +3623,8 @@ bool Renderer11::blitRenderbufferRect(const gl::Rectangle &readRect, const gl::R drawRect.x < 0 || drawRect.x + drawRect.width > drawSize.width || drawRect.y < 0 || drawRect.y + drawRect.height > drawSize.height; - bool hasDepth = gl::GetDepthBits(drawRenderTarget11->getActualFormat()) > 0; - bool hasStencil = gl::GetStencilBits(drawRenderTarget11->getActualFormat()) > 0; + bool hasDepth = gl::GetDepthBits(drawRenderTarget11->getActualFormat(), getCurrentClientVersion()) > 0; + bool hasStencil = gl::GetStencilBits(drawRenderTarget11->getActualFormat(), getCurrentClientVersion()) > 0; bool partialDSBlit = (hasDepth && depthBlit) != (hasStencil && stencilBlit); if (readRenderTarget11->getActualFormat() == drawRenderTarget->getActualFormat() && @@ -3365,7 +3699,7 @@ bool Renderer11::blitRenderbufferRect(const gl::Rectangle &readRect, const gl::R } else { - GLenum format = gl::GetFormat(drawRenderTarget->getInternalFormat()); + GLenum format = gl::GetFormat(drawRenderTarget->getInternalFormat(), getCurrentClientVersion()); result = mBlit->copyTexture(readSRV, readArea, readSize, drawRTV, drawArea, drawSize, scissor, format, filter); } @@ -3415,10 +3749,9 @@ ID3D11Texture2D *Renderer11::resolveMultisampledTexture(ID3D11Texture2D *source, } } -void Renderer11::invalidateFBOAttachmentSwizzles(gl::FramebufferAttachment *attachment, int mipLevel) +void Renderer11::invalidateRenderbufferSwizzles(gl::Renderbuffer *renderBuffer, int mipLevel) { - ASSERT(attachment->isTexture()); - TextureStorage *texStorage = attachment->getTextureStorage(); + TextureStorage *texStorage = renderBuffer->getTextureStorage(); if (texStorage) { TextureStorage11 *texStorage11 = TextureStorage11::makeTextureStorage11(texStorage); @@ -3436,23 +3769,23 @@ void Renderer11::invalidateFramebufferSwizzles(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()) + gl::Renderbuffer *colorbuffer = framebuffer->getColorbuffer(colorAttachment); + if (colorbuffer) { - invalidateFBOAttachmentSwizzles(attachment, framebuffer->getColorbufferMipLevel(colorAttachment)); + invalidateRenderbufferSwizzles(colorbuffer, framebuffer->getColorbufferMipLevel(colorAttachment)); } } - gl::FramebufferAttachment *depthAttachment = framebuffer->getDepthbuffer(); - if (depthAttachment && depthAttachment->isTexture()) + gl::Renderbuffer *depthBuffer = framebuffer->getDepthbuffer(); + if (depthBuffer) { - invalidateFBOAttachmentSwizzles(depthAttachment, framebuffer->getDepthbufferMipLevel()); + invalidateRenderbufferSwizzles(depthBuffer, framebuffer->getDepthbufferMipLevel()); } - gl::FramebufferAttachment *stencilAttachment = framebuffer->getStencilbuffer(); - if (stencilAttachment && stencilAttachment->isTexture()) + gl::Renderbuffer *stencilBuffer = framebuffer->getStencilbuffer(); + if (stencilBuffer) { - invalidateFBOAttachmentSwizzles(stencilAttachment, framebuffer->getStencilbufferMipLevel()); + invalidateRenderbufferSwizzles(stencilBuffer, framebuffer->getStencilbufferMipLevel()); } } @@ -3478,7 +3811,8 @@ bool Renderer11::getLUID(LUID *adapterLuid) const GLenum Renderer11::getNativeTextureFormat(GLenum internalFormat) const { - return d3d11_gl::GetInternalFormat(gl_d3d11::GetTexFormat(internalFormat)); + int clientVersion = getCurrentClientVersion(); + return d3d11_gl::GetInternalFormat(gl_d3d11::GetTexFormat(internalFormat, clientVersion), clientVersion); } rx::VertexConversionType Renderer11::getVertexConversionType(const gl::VertexFormat &vertexFormat) const @@ -3518,9 +3852,4 @@ Renderer11::MultisampleSupportInfo Renderer11::getMultisampleSupportInfo(DXGI_FO return supportInfo; } -gl::Caps Renderer11::generateCaps() const -{ - return d3d11_gl::GenerateCaps(mDevice); -} - } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h b/gfx/angle/src/libGLESv2/renderer/d3d11/Renderer11.h similarity index 88% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/Renderer11.h index b490d14e3d86..3e6a54a2af8b 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/Renderer11.h @@ -15,13 +15,13 @@ #include "libGLESv2/renderer/Renderer.h" #include "libGLESv2/renderer/d3d/HLSLCompiler.h" -#include "libGLESv2/renderer/d3d/d3d11/RenderStateCache.h" -#include "libGLESv2/renderer/d3d/d3d11/InputLayoutCache.h" +#include "libGLESv2/renderer/d3d11/RenderStateCache.h" +#include "libGLESv2/renderer/d3d11/InputLayoutCache.h" #include "libGLESv2/renderer/RenderTarget.h" namespace gl { -class FramebufferAttachment; +class Renderbuffer; } namespace rx @@ -77,8 +77,7 @@ class Renderer11 : public Renderer virtual bool applyPrimitiveType(GLenum mode, GLsizei count); virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer); - virtual void applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer, - bool rasterizerDiscard, bool transformFeedbackActive); + virtual void applyShaders(gl::ProgramBinary *programBinary, bool rasterizerDiscard, bool transformFeedbackActive, const gl::VertexFormat inputLayout[]); virtual void applyUniforms(const gl::ProgramBinary &programBinary); virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], gl::VertexAttribCurrentValueData currentValues[], GLint first, GLsizei count, GLsizei instances); @@ -99,10 +98,26 @@ class Renderer11 : public Renderer virtual bool testDeviceLost(bool notify); virtual bool testDeviceResettable(); + // Renderer capabilities virtual DWORD getAdapterVendor() const; virtual std::string getRendererDescription() const; virtual GUID getAdapterIdentifier() const; + virtual bool getBGRATextureSupport() const; + virtual bool getDXT1TextureSupport() const; + virtual bool getDXT3TextureSupport() const; + virtual bool getDXT5TextureSupport() const; + virtual bool getEventQuerySupport() const; + virtual bool getFloat32TextureSupport() const; + virtual bool getFloat32TextureFilteringSupport() const; + virtual bool getFloat32TextureRenderingSupport() const; + virtual bool getFloat16TextureSupport() const; + virtual bool getFloat16TextureFilteringSupport() const; + virtual bool getFloat16TextureRenderingSupport() const; + virtual bool getRGB565TextureSupport() const; + virtual bool getLuminanceTextureSupport() const; + virtual bool getLuminanceAlphaTextureSupport() const; + virtual bool getRGTextureSupport() const; virtual unsigned int getMaxVertexTextureImageUnits() const; virtual unsigned int getMaxCombinedTextureImageUnits() const; virtual unsigned int getReservedVertexUniformVectors() const; @@ -119,11 +134,18 @@ class Renderer11 : public Renderer virtual unsigned int getMaxTransformFeedbackSeparateComponents() const; virtual unsigned int getMaxTransformFeedbackInterleavedComponents() const; virtual unsigned int getMaxUniformBufferSize() const; + virtual bool getNonPower2TextureSupport() const; + virtual bool getDepthTextureSupport() const; + virtual bool getOcclusionQuerySupport() const; + virtual bool getInstancingSupport() const; + virtual bool getTextureFilterAnisotropySupport() const; + virtual bool getPBOSupport() const; + virtual float getTextureMaxAnisotropy() const; virtual bool getShareHandleSupport() const; + virtual bool getDerivativeInstructionSupport() const; virtual bool getPostSubBufferSupport() const; virtual int getMaxRecommendedElementsIndices() const; virtual int getMaxRecommendedElementsVertices() const; - virtual bool getSRGBTextureSupport() const; virtual int getMajorShaderModel() const; virtual float getMaxPointSize() const; @@ -132,6 +154,7 @@ class Renderer11 : public Renderer virtual int getMaxTextureHeight() const; virtual int getMaxTextureDepth() const; virtual int getMaxTextureArrayLayers() const; + virtual bool get32BitIndexSupport() const; virtual int getMinSwapInterval() const; virtual int getMaxSwapInterval() const; @@ -186,12 +209,9 @@ class Renderer11 : public Renderer virtual TextureStorage *createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels); // Buffer creation - virtual BufferImpl *createBuffer(); virtual VertexBuffer *createVertexBuffer(); virtual IndexBuffer *createIndexBuffer(); - - // Vertex Array creation - virtual VertexArrayImpl *createVertexArray(); + virtual BufferStorage *createBufferStorage(); // Query and Fence creation virtual QueryImpl *createQuery(GLenum type); @@ -209,7 +229,7 @@ class Renderer11 : public Renderer virtual bool fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget, GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea); - bool getRenderTargetResource(gl::FramebufferAttachment *colorbuffer, unsigned int *subresourceIndex, ID3D11Texture2D **resource); + bool getRenderTargetResource(gl::Renderbuffer *colorbuffer, unsigned int *subresourceIndex, ID3D11Texture2D **resource); void unapplyRenderTargets(); void setOneTimeRenderTarget(ID3D11RenderTargetView *renderTargetView); void packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams ¶ms, void *pixelsOut); @@ -222,8 +242,6 @@ class Renderer11 : public Renderer private: DISALLOW_COPY_AND_ASSIGN(Renderer11); - virtual gl::Caps generateCaps() const; - void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer); void drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances); @@ -237,7 +255,7 @@ class Renderer11 : public Renderer bool colorBlit, bool depthBlit, bool stencilBlit); ID3D11Texture2D *resolveMultisampledTexture(ID3D11Texture2D *source, unsigned int subresource); - static void invalidateFBOAttachmentSwizzles(gl::FramebufferAttachment *attachment, int mipLevel); + static void invalidateRenderbufferSwizzles(gl::Renderbuffer *renderBuffer, int mipLevel); static void invalidateFramebufferSwizzles(gl::Framebuffer *framebuffer); HMODULE mD3d11Module; @@ -255,6 +273,23 @@ class Renderer11 : public Renderer RenderStateCache mStateCache; + // Support flags + bool mFloat16TextureSupport; + bool mFloat16FilterSupport; + bool mFloat16RenderSupport; + + bool mFloat32TextureSupport; + bool mFloat32FilterSupport; + bool mFloat32RenderSupport; + + bool mDXT1TextureSupport; + bool mDXT3TextureSupport; + bool mDXT5TextureSupport; + + bool mRGTextureSupport; + + bool mDepthTextureSupport; + // Multisample format support struct MultisampleSupportInfo { @@ -371,6 +406,9 @@ class Renderer11 : public Renderer DXGI_ADAPTER_DESC mAdapterDescription; char mDescription[128]; IDXGIFactory *mDxgiFactory; + + // Cached device caps + bool mBGRATextureSupport; }; } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/ShaderExecutable11.cpp similarity index 96% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/ShaderExecutable11.cpp index 5a7c98749441..de2eeda4fc86 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/ShaderExecutable11.cpp @@ -8,9 +8,9 @@ // ShaderExecutable11.cpp: Implements a D3D11-specific class to contain shader // executable implementation details. -#include "libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.h" +#include "libGLESv2/renderer/d3d11/ShaderExecutable11.h" -#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h" +#include "libGLESv2/renderer/d3d11/Renderer11.h" namespace rx { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.h b/gfx/angle/src/libGLESv2/renderer/d3d11/ShaderExecutable11.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/ShaderExecutable11.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/SwapChain11.cpp similarity index 96% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/SwapChain11.cpp index ed0c4aea13a4..a15d061feaf4 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/SwapChain11.cpp @@ -7,13 +7,13 @@ // SwapChain11.cpp: Implements a back-end specific class for the D3D11 swap chain. -#include "libGLESv2/renderer/d3d/d3d11/SwapChain11.h" +#include "libGLESv2/renderer/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" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough2d11vs.h" -#include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2d11ps.h" +#include "libGLESv2/renderer/d3d11/renderer11_utils.h" +#include "libGLESv2/renderer/d3d11/formatutils11.h" +#include "libGLESv2/renderer/d3d11/Renderer11.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthrough2d11vs.h" +#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2d11ps.h" namespace rx { @@ -132,7 +132,7 @@ EGLint SwapChain11::resetOffscreenTexture(int backbufferWidth, int backbufferHei if (offscreenTextureDesc.Width != (UINT)backbufferWidth || offscreenTextureDesc.Height != (UINT)backbufferHeight - || offscreenTextureDesc.Format != gl_d3d11::GetTexFormat(mBackBufferFormat) + || offscreenTextureDesc.Format != gl_d3d11::GetTexFormat(mBackBufferFormat, mRenderer->getCurrentClientVersion()) || offscreenTextureDesc.MipLevels != 1 || offscreenTextureDesc.ArraySize != 1) { @@ -148,7 +148,7 @@ EGLint SwapChain11::resetOffscreenTexture(int backbufferWidth, int backbufferHei D3D11_TEXTURE2D_DESC offscreenTextureDesc = {0}; offscreenTextureDesc.Width = backbufferWidth; offscreenTextureDesc.Height = backbufferHeight; - offscreenTextureDesc.Format = gl_d3d11::GetTexFormat(mBackBufferFormat); + offscreenTextureDesc.Format = gl_d3d11::GetTexFormat(mBackBufferFormat, mRenderer->getCurrentClientVersion()); offscreenTextureDesc.MipLevels = 1; offscreenTextureDesc.ArraySize = 1; offscreenTextureDesc.SampleDesc.Count = 1; @@ -204,7 +204,7 @@ EGLint SwapChain11::resetOffscreenTexture(int backbufferWidth, int backbufferHei D3D11_RENDER_TARGET_VIEW_DESC offscreenRTVDesc; - offscreenRTVDesc.Format = gl_d3d11::GetRTVFormat(mBackBufferFormat); + offscreenRTVDesc.Format = gl_d3d11::GetRTVFormat(mBackBufferFormat, mRenderer->getCurrentClientVersion()); offscreenRTVDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; offscreenRTVDesc.Texture2D.MipSlice = 0; @@ -213,7 +213,7 @@ EGLint SwapChain11::resetOffscreenTexture(int backbufferWidth, int backbufferHei d3d11::SetDebugName(mOffscreenRTView, "Offscreen back buffer render target"); D3D11_SHADER_RESOURCE_VIEW_DESC offscreenSRVDesc; - offscreenSRVDesc.Format = gl_d3d11::GetSRVFormat(mBackBufferFormat); + offscreenSRVDesc.Format = gl_d3d11::GetSRVFormat(mBackBufferFormat, mRenderer->getCurrentClientVersion()); offscreenSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; offscreenSRVDesc.Texture2D.MostDetailedMip = 0; offscreenSRVDesc.Texture2D.MipLevels = -1; @@ -227,7 +227,7 @@ EGLint SwapChain11::resetOffscreenTexture(int backbufferWidth, int backbufferHei D3D11_TEXTURE2D_DESC depthStencilTextureDesc; depthStencilTextureDesc.Width = backbufferWidth; depthStencilTextureDesc.Height = backbufferHeight; - depthStencilTextureDesc.Format = gl_d3d11::GetTexFormat(mDepthBufferFormat); + depthStencilTextureDesc.Format = gl_d3d11::GetTexFormat(mDepthBufferFormat, mRenderer->getCurrentClientVersion()); depthStencilTextureDesc.MipLevels = 1; depthStencilTextureDesc.ArraySize = 1; depthStencilTextureDesc.SampleDesc.Count = 1; @@ -255,7 +255,7 @@ EGLint SwapChain11::resetOffscreenTexture(int backbufferWidth, int backbufferHei d3d11::SetDebugName(mDepthStencilTexture, "Offscreen depth stencil texture"); D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilDesc; - depthStencilDesc.Format = gl_d3d11::GetDSVFormat(mDepthBufferFormat); + depthStencilDesc.Format = gl_d3d11::GetDSVFormat(mDepthBufferFormat, mRenderer->getCurrentClientVersion()); depthStencilDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; depthStencilDesc.Flags = 0; depthStencilDesc.Texture2D.MipSlice = 0; @@ -265,7 +265,7 @@ EGLint SwapChain11::resetOffscreenTexture(int backbufferWidth, int backbufferHei d3d11::SetDebugName(mDepthStencilDSView, "Offscreen depth stencil view"); D3D11_SHADER_RESOURCE_VIEW_DESC depthStencilSRVDesc; - depthStencilSRVDesc.Format = gl_d3d11::GetSRVFormat(mDepthBufferFormat); + depthStencilSRVDesc.Format = gl_d3d11::GetSRVFormat(mDepthBufferFormat, mRenderer->getCurrentClientVersion()); depthStencilSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; depthStencilSRVDesc.Texture2D.MostDetailedMip = 0; depthStencilSRVDesc.Texture2D.MipLevels = -1; @@ -325,7 +325,7 @@ EGLint SwapChain11::resize(EGLint backbufferWidth, EGLint backbufferHeight) SafeRelease(mBackBufferRTView); // Resize swap chain - DXGI_FORMAT backbufferDXGIFormat = gl_d3d11::GetTexFormat(mBackBufferFormat); + DXGI_FORMAT backbufferDXGIFormat = gl_d3d11::GetTexFormat(mBackBufferFormat, mRenderer->getCurrentClientVersion()); HRESULT result = mSwapChain->ResizeBuffers(1, backbufferWidth, backbufferHeight, backbufferDXGIFormat, 0); if (FAILED(result)) @@ -398,7 +398,7 @@ EGLint SwapChain11::reset(int backbufferWidth, int backbufferHeight, EGLint swap swapChainDesc.BufferDesc.Height = backbufferHeight; swapChainDesc.BufferDesc.RefreshRate.Numerator = 0; swapChainDesc.BufferDesc.RefreshRate.Denominator = 1; - swapChainDesc.BufferDesc.Format = gl_d3d11::GetTexFormat(mBackBufferFormat); + swapChainDesc.BufferDesc.Format = gl_d3d11::GetTexFormat(mBackBufferFormat, mRenderer->getCurrentClientVersion()); swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; swapChainDesc.SampleDesc.Count = 1; @@ -584,7 +584,7 @@ EGLint SwapChain11::swapRect(EGLint x, EGLint y, EGLint width, EGLint height) // Draw deviceContext->Draw(4, 0); -#ifdef ANGLE_FORCE_VSYNC_OFF +#if ANGLE_FORCE_VSYNC_OFF result = mSwapChain->Present(0, 0); #else result = mSwapChain->Present(mSwapInterval, 0); @@ -593,7 +593,7 @@ EGLint SwapChain11::swapRect(EGLint x, EGLint y, EGLint width, EGLint height) if (result == DXGI_ERROR_DEVICE_REMOVED) { HRESULT removedReason = device->GetDeviceRemovedReason(); - UNUSED_TRACE_VARIABLE(removedReason); + UNUSED_ASSERTION_VARIABLE(removedReason); ERR("Present failed: the D3D11 device was removed: 0x%08X", removedReason); return EGL_CONTEXT_LOST; } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.h b/gfx/angle/src/libGLESv2/renderer/d3d11/SwapChain11.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/SwapChain11.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/TextureStorage11.cpp similarity index 94% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/TextureStorage11.cpp index 8f324684f5cc..7e024accb806 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/TextureStorage11.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" // -// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -8,14 +8,14 @@ // 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 "libGLESv2/renderer/d3d11/TextureStorage11.h" -#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/d3d11/Renderer11.h" +#include "libGLESv2/renderer/d3d11/RenderTarget11.h" +#include "libGLESv2/renderer/d3d11/SwapChain11.h" +#include "libGLESv2/renderer/d3d11/renderer11_utils.h" +#include "libGLESv2/renderer/d3d11/Blit11.h" +#include "libGLESv2/renderer/d3d11/formatutils11.h" #include "common/utilities.h" #include "libGLESv2/main.h" @@ -121,19 +121,19 @@ TextureStorage11 *TextureStorage11::makeTextureStorage11(TextureStorage *storage return static_cast(storage); } -DWORD TextureStorage11::GetTextureBindFlags(GLenum internalFormat, bool renderTarget) +DWORD TextureStorage11::GetTextureBindFlags(GLenum internalFormat, GLuint clientVersion, bool renderTarget) { UINT bindFlags = 0; - if (gl_d3d11::GetSRVFormat(internalFormat) != DXGI_FORMAT_UNKNOWN) + if (gl_d3d11::GetSRVFormat(internalFormat, clientVersion) != DXGI_FORMAT_UNKNOWN) { bindFlags |= D3D11_BIND_SHADER_RESOURCE; } - if (gl_d3d11::GetDSVFormat(internalFormat) != DXGI_FORMAT_UNKNOWN) + if (gl_d3d11::GetDSVFormat(internalFormat, clientVersion) != DXGI_FORMAT_UNKNOWN) { bindFlags |= D3D11_BIND_DEPTH_STENCIL; } - if (gl_d3d11::GetRTVFormat(internalFormat) != DXGI_FORMAT_UNKNOWN && renderTarget) + if (gl_d3d11::GetRTVFormat(internalFormat, clientVersion) != DXGI_FORMAT_UNKNOWN && renderTarget) { bindFlags |= D3D11_BIND_RENDER_TARGET; } @@ -355,7 +355,8 @@ void TextureStorage11::generateMipmapLayer(RenderTarget11 *source, RenderTarget1 Blit11 *blitter = mRenderer->getBlitter(); blitter->copyTexture(sourceSRV, sourceArea, sourceSize, destRTV, destArea, destSize, NULL, - gl::GetFormat(source->getInternalFormat()), GL_LINEAR); + gl::GetFormat(source->getInternalFormat(), mRenderer->getCurrentClientVersion()), + GL_LINEAR); } } } @@ -400,16 +401,16 @@ TextureStorage11_2D::TextureStorage11_2D(Renderer *renderer, SwapChain11 *swapch offscreenRTV->GetDesc(&rtvDesc); mRenderTargetFormat = rtvDesc.Format; - GLenum internalFormat = d3d11_gl::GetInternalFormat(mTextureFormat); - mSwizzleTextureFormat = gl_d3d11::GetSwizzleTexFormat(internalFormat); - mSwizzleShaderResourceFormat = gl_d3d11::GetSwizzleSRVFormat(internalFormat); - mSwizzleRenderTargetFormat = gl_d3d11::GetSwizzleRTVFormat(internalFormat); + GLint internalFormat = d3d11_gl::GetInternalFormat(mTextureFormat, renderer->getCurrentClientVersion()); + mSwizzleTextureFormat = gl_d3d11::GetSwizzleTexFormat(internalFormat, renderer); + mSwizzleShaderResourceFormat = gl_d3d11::GetSwizzleSRVFormat(internalFormat, renderer); + mSwizzleRenderTargetFormat = gl_d3d11::GetSwizzleRTVFormat(internalFormat, renderer); mDepthStencilFormat = DXGI_FORMAT_UNKNOWN; } TextureStorage11_2D::TextureStorage11_2D(Renderer *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels) - : TextureStorage11(renderer, GetTextureBindFlags(internalformat, renderTarget)) + : TextureStorage11(renderer, GetTextureBindFlags(internalformat, renderer->getCurrentClientVersion(), renderTarget)) { mTexture = NULL; mSwizzleTexture = NULL; @@ -420,13 +421,15 @@ TextureStorage11_2D::TextureStorage11_2D(Renderer *renderer, GLenum internalform mSwizzleRenderTargets[i] = NULL; } - mTextureFormat = gl_d3d11::GetTexFormat(internalformat); - mShaderResourceFormat = gl_d3d11::GetSRVFormat(internalformat); - mDepthStencilFormat = gl_d3d11::GetDSVFormat(internalformat); - mRenderTargetFormat = gl_d3d11::GetRTVFormat(internalformat); - mSwizzleTextureFormat = gl_d3d11::GetSwizzleTexFormat(internalformat); - mSwizzleShaderResourceFormat = gl_d3d11::GetSwizzleSRVFormat(internalformat); - mSwizzleRenderTargetFormat = gl_d3d11::GetSwizzleRTVFormat(internalformat); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + + mTextureFormat = gl_d3d11::GetTexFormat(internalformat, clientVersion); + mShaderResourceFormat = gl_d3d11::GetSRVFormat(internalformat, clientVersion); + mDepthStencilFormat = gl_d3d11::GetDSVFormat(internalformat, clientVersion); + mRenderTargetFormat = gl_d3d11::GetRTVFormat(internalformat, clientVersion); + mSwizzleTextureFormat = gl_d3d11::GetSwizzleTexFormat(internalformat, renderer); + mSwizzleShaderResourceFormat = gl_d3d11::GetSwizzleSRVFormat(internalformat, renderer); + mSwizzleRenderTargetFormat = gl_d3d11::GetSwizzleRTVFormat(internalformat, renderer); // 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 @@ -676,7 +679,7 @@ unsigned int TextureStorage11_2D::getTextureLevelDepth(int mipLevel) const } TextureStorage11_Cube::TextureStorage11_Cube(Renderer *renderer, GLenum internalformat, bool renderTarget, int size, int levels) - : TextureStorage11(renderer, GetTextureBindFlags(internalformat, renderTarget)) + : TextureStorage11(renderer, GetTextureBindFlags(internalformat, renderer->getCurrentClientVersion(), renderTarget)) { mTexture = NULL; mSwizzleTexture = NULL; @@ -690,13 +693,15 @@ TextureStorage11_Cube::TextureStorage11_Cube(Renderer *renderer, GLenum internal } } - mTextureFormat = gl_d3d11::GetTexFormat(internalformat); - mShaderResourceFormat = gl_d3d11::GetSRVFormat(internalformat); - mDepthStencilFormat = gl_d3d11::GetDSVFormat(internalformat); - mRenderTargetFormat = gl_d3d11::GetRTVFormat(internalformat); - mSwizzleTextureFormat = gl_d3d11::GetSwizzleTexFormat(internalformat); - mSwizzleShaderResourceFormat = gl_d3d11::GetSwizzleSRVFormat(internalformat); - mSwizzleRenderTargetFormat = gl_d3d11::GetSwizzleRTVFormat(internalformat); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + + mTextureFormat = gl_d3d11::GetTexFormat(internalformat, clientVersion); + mShaderResourceFormat = gl_d3d11::GetSRVFormat(internalformat, clientVersion); + mDepthStencilFormat = gl_d3d11::GetDSVFormat(internalformat, clientVersion); + mRenderTargetFormat = gl_d3d11::GetRTVFormat(internalformat, clientVersion); + mSwizzleTextureFormat = gl_d3d11::GetSwizzleTexFormat(internalformat, renderer); + mSwizzleShaderResourceFormat = gl_d3d11::GetSwizzleSRVFormat(internalformat, renderer); + mSwizzleRenderTargetFormat = gl_d3d11::GetSwizzleRTVFormat(internalformat, renderer); // if the size is not positive this should be treated as an incomplete texture // we handle that here by skipping the d3d texture creation @@ -982,7 +987,7 @@ unsigned int TextureStorage11_Cube::getTextureLevelDepth(int mipLevel) const TextureStorage11_3D::TextureStorage11_3D(Renderer *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels) - : TextureStorage11(renderer, GetTextureBindFlags(internalformat, renderTarget)) + : TextureStorage11(renderer, GetTextureBindFlags(internalformat, renderer->getCurrentClientVersion(), renderTarget)) { mTexture = NULL; mSwizzleTexture = NULL; @@ -993,13 +998,15 @@ TextureStorage11_3D::TextureStorage11_3D(Renderer *renderer, GLenum internalform mSwizzleRenderTargets[i] = NULL; } - mTextureFormat = gl_d3d11::GetTexFormat(internalformat); - mShaderResourceFormat = gl_d3d11::GetSRVFormat(internalformat); - mDepthStencilFormat = gl_d3d11::GetDSVFormat(internalformat); - mRenderTargetFormat = gl_d3d11::GetRTVFormat(internalformat); - mSwizzleTextureFormat = gl_d3d11::GetSwizzleTexFormat(internalformat); - mSwizzleShaderResourceFormat = gl_d3d11::GetSwizzleSRVFormat(internalformat); - mSwizzleRenderTargetFormat = gl_d3d11::GetSwizzleRTVFormat(internalformat); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + + mTextureFormat = gl_d3d11::GetTexFormat(internalformat, clientVersion); + mShaderResourceFormat = gl_d3d11::GetSRVFormat(internalformat, clientVersion); + mDepthStencilFormat = gl_d3d11::GetDSVFormat(internalformat, clientVersion); + mRenderTargetFormat = gl_d3d11::GetRTVFormat(internalformat, clientVersion); + mSwizzleTextureFormat = gl_d3d11::GetSwizzleTexFormat(internalformat, renderer); + mSwizzleShaderResourceFormat = gl_d3d11::GetSwizzleSRVFormat(internalformat, renderer); + mSwizzleRenderTargetFormat = gl_d3d11::GetSwizzleRTVFormat(internalformat, renderer); // 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 @@ -1286,7 +1293,7 @@ unsigned int TextureStorage11_3D::getTextureLevelDepth(int mipLevel) const TextureStorage11_2DArray::TextureStorage11_2DArray(Renderer *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels) - : TextureStorage11(renderer, GetTextureBindFlags(internalformat, renderTarget)) + : TextureStorage11(renderer, GetTextureBindFlags(internalformat, renderer->getCurrentClientVersion(), renderTarget)) { mTexture = NULL; mSwizzleTexture = NULL; @@ -1296,13 +1303,15 @@ TextureStorage11_2DArray::TextureStorage11_2DArray(Renderer *renderer, GLenum in mSwizzleRenderTargets[level] = NULL; } - mTextureFormat = gl_d3d11::GetTexFormat(internalformat); - mShaderResourceFormat = gl_d3d11::GetSRVFormat(internalformat); - mDepthStencilFormat = gl_d3d11::GetDSVFormat(internalformat); - mRenderTargetFormat = gl_d3d11::GetRTVFormat(internalformat); - mSwizzleTextureFormat = gl_d3d11::GetSwizzleTexFormat(internalformat); - mSwizzleShaderResourceFormat = gl_d3d11::GetSwizzleSRVFormat(internalformat); - mSwizzleRenderTargetFormat = gl_d3d11::GetSwizzleRTVFormat(internalformat); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + + mTextureFormat = gl_d3d11::GetTexFormat(internalformat, clientVersion); + mShaderResourceFormat = gl_d3d11::GetSRVFormat(internalformat, clientVersion); + mDepthStencilFormat = gl_d3d11::GetDSVFormat(internalformat, clientVersion); + mRenderTargetFormat = gl_d3d11::GetRTVFormat(internalformat, clientVersion); + mSwizzleTextureFormat = gl_d3d11::GetSwizzleTexFormat(internalformat, renderer); + mSwizzleShaderResourceFormat = gl_d3d11::GetSwizzleSRVFormat(internalformat, renderer); + mSwizzleRenderTargetFormat = gl_d3d11::GetSwizzleRTVFormat(internalformat, renderer); // 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 diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.h b/gfx/angle/src/libGLESv2/renderer/d3d11/TextureStorage11.h similarity index 98% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/TextureStorage11.h index 52977d2a7fdb..8a612bdd110b 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/TextureStorage11.h @@ -28,7 +28,7 @@ class TextureStorage11 : public TextureStorage static TextureStorage11 *makeTextureStorage11(TextureStorage *storage); - static DWORD GetTextureBindFlags(GLenum internalFormat, bool renderTarget); + static DWORD GetTextureBindFlags(GLenum internalFormat, GLuint clientVersion, bool renderTarget); UINT getBindFlags() const; diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/VertexBuffer11.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/VertexBuffer11.cpp similarity index 86% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/VertexBuffer11.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/VertexBuffer11.cpp index 2f47ec0a671f..d69668d8a37e 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/VertexBuffer11.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/VertexBuffer11.cpp @@ -7,13 +7,13 @@ // VertexBuffer11.cpp: Defines the D3D11 VertexBuffer implementation. -#include "libGLESv2/renderer/d3d/d3d11/VertexBuffer11.h" -#include "libGLESv2/renderer/d3d/d3d11/Buffer11.h" +#include "libGLESv2/renderer/d3d11/VertexBuffer11.h" +#include "libGLESv2/renderer/BufferStorage.h" #include "libGLESv2/Buffer.h" -#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h" +#include "libGLESv2/renderer/d3d11/Renderer11.h" #include "libGLESv2/VertexAttribute.h" -#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h" +#include "libGLESv2/renderer/d3d11/formatutils11.h" namespace rx { @@ -71,8 +71,8 @@ bool VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attrib, co { if (mBuffer) { - gl::Buffer *buffer = attrib.buffer.get(); - int inputStride = ComputeVertexAttributeStride(attrib); + gl::Buffer *buffer = attrib.mBoundBuffer.get(); + int inputStride = attrib.stride(); ID3D11DeviceContext *dxContext = mRenderer->getDeviceContext(); D3D11_MAPPED_SUBRESOURCE mappedResource; @@ -86,16 +86,16 @@ bool VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attrib, co char* output = reinterpret_cast(mappedResource.pData) + offset; const char *input = NULL; - if (attrib.enabled) + if (attrib.mArrayEnabled) { if (buffer) { - Buffer11 *storage = Buffer11::makeBuffer11(buffer->getImplementation()); - input = static_cast(storage->getData()) + static_cast(attrib.offset); + BufferStorage *storage = buffer->getStorage(); + input = static_cast(storage->getData()) + static_cast(attrib.mOffset); } else { - input = static_cast(attrib.pointer); + input = static_cast(attrib.mPointer); } } else @@ -103,7 +103,7 @@ bool VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attrib, co input = reinterpret_cast(currentValue.FloatValues); } - if (instances == 0 || attrib.divisor == 0) + if (instances == 0 || attrib.mDivisor == 0) { input += inputStride * start; } @@ -128,22 +128,22 @@ bool VertexBuffer11::getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei GLsizei instances, unsigned int *outSpaceRequired) const { unsigned int elementCount = 0; - if (attrib.enabled) + if (attrib.mArrayEnabled) { - if (instances == 0 || attrib.divisor == 0) + if (instances == 0 || attrib.mDivisor == 0) { elementCount = count; } else { - if (static_cast(instances) < std::numeric_limits::max() - (attrib.divisor - 1)) + if (static_cast(instances) < std::numeric_limits::max() - (attrib.mDivisor - 1)) { // Round up - elementCount = rx::roundUp(static_cast(instances), attrib.divisor); + elementCount = rx::roundUp(static_cast(instances), attrib.mDivisor); } else { - elementCount = instances / attrib.divisor; + elementCount = instances / attrib.mDivisor; } } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/VertexBuffer11.h b/gfx/angle/src/libGLESv2/renderer/d3d11/VertexBuffer11.h similarity index 96% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/VertexBuffer11.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/VertexBuffer11.h index c2a5aa7afdbb..191791af3c4f 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/VertexBuffer11.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/VertexBuffer11.h @@ -9,7 +9,7 @@ #ifndef LIBGLESV2_RENDERER_VERTEXBUFFER11_H_ #define LIBGLESV2_RENDERER_VERTEXBUFFER11_H_ -#include "libGLESv2/renderer/d3d/VertexBuffer.h" +#include "libGLESv2/renderer/VertexBuffer.h" namespace rx { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/formatutils11.cpp similarity index 67% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/formatutils11.cpp index 9bb5620ae593..695e168478f1 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/formatutils11.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" // -// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -8,7 +8,7 @@ // formatutils11.cpp: Queries for GL image formats and their translations to D3D11 // formats. -#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h" +#include "libGLESv2/renderer/d3d11/formatutils11.h" #include "libGLESv2/renderer/generatemip.h" #include "libGLESv2/renderer/loadimage.h" #include "libGLESv2/renderer/copyimage.h" @@ -18,18 +18,18 @@ namespace rx { -struct D3D11FormatInfo +struct D3D11ES3FormatInfo { DXGI_FORMAT mTexFormat; DXGI_FORMAT mSRVFormat; DXGI_FORMAT mRTVFormat; DXGI_FORMAT mDSVFormat; - D3D11FormatInfo() + D3D11ES3FormatInfo() : mTexFormat(DXGI_FORMAT_UNKNOWN), mDSVFormat(DXGI_FORMAT_UNKNOWN), mRTVFormat(DXGI_FORMAT_UNKNOWN), mSRVFormat(DXGI_FORMAT_UNKNOWN) { } - D3D11FormatInfo(DXGI_FORMAT texFormat, DXGI_FORMAT srvFormat, DXGI_FORMAT rtvFormat, DXGI_FORMAT dsvFormat) + D3D11ES3FormatInfo(DXGI_FORMAT texFormat, DXGI_FORMAT srvFormat, DXGI_FORMAT rtvFormat, DXGI_FORMAT dsvFormat) : mTexFormat(texFormat), mDSVFormat(dsvFormat), mRTVFormat(rtvFormat), mSRVFormat(srvFormat) { } }; @@ -37,129 +37,128 @@ struct D3D11FormatInfo // 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::pair D3D11ES3FormatPair; -typedef std::map D3D11ES3FormatMap; +typedef std::pair D3D11ES3FormatPair; +typedef std::map D3D11ES3FormatMap; -static D3D11ES3FormatMap BuildD3D11FormatMap() +static D3D11ES3FormatMap BuildD3D11ES3FormatMap() { D3D11ES3FormatMap map; - // | GL internal format | | D3D11 texture format | D3D11 SRV format | D3D11 RTV format | D3D11 DSV format | - map.insert(D3D11ES3FormatPair(GL_NONE, D3D11FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_R8, D3D11FormatInfo(DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_R8_SNORM, D3D11FormatInfo(DXGI_FORMAT_R8_SNORM, DXGI_FORMAT_R8_SNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RG8, D3D11FormatInfo(DXGI_FORMAT_R8G8_UNORM, DXGI_FORMAT_R8G8_UNORM, DXGI_FORMAT_R8G8_UNORM, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RG8_SNORM, D3D11FormatInfo(DXGI_FORMAT_R8G8_SNORM, DXGI_FORMAT_R8G8_SNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGB8, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGB8_SNORM, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_SNORM, DXGI_FORMAT_R8G8B8A8_SNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGB565, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGBA4, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGB5_A1, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGBA8, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGBA8_SNORM, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_SNORM, DXGI_FORMAT_R8G8B8A8_SNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGB10_A2, D3D11FormatInfo(DXGI_FORMAT_R10G10B10A2_UNORM, DXGI_FORMAT_R10G10B10A2_UNORM, DXGI_FORMAT_R10G10B10A2_UNORM, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGB10_A2UI, D3D11FormatInfo(DXGI_FORMAT_R10G10B10A2_UINT, DXGI_FORMAT_R10G10B10A2_UINT, DXGI_FORMAT_R10G10B10A2_UINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_SRGB8, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_SRGB8_ALPHA8, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_R16F, D3D11FormatInfo(DXGI_FORMAT_R16_FLOAT, DXGI_FORMAT_R16_FLOAT, DXGI_FORMAT_R16_FLOAT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RG16F, D3D11FormatInfo(DXGI_FORMAT_R16G16_FLOAT, DXGI_FORMAT_R16G16_FLOAT, DXGI_FORMAT_R16G16_FLOAT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGB16F, D3D11FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGBA16F, D3D11FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_R32F, D3D11FormatInfo(DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RG32F, D3D11FormatInfo(DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGB32F, D3D11FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGBA32F, D3D11FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_R11F_G11F_B10F, D3D11FormatInfo(DXGI_FORMAT_R11G11B10_FLOAT, DXGI_FORMAT_R11G11B10_FLOAT, DXGI_FORMAT_R11G11B10_FLOAT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGB9_E5, D3D11FormatInfo(DXGI_FORMAT_R9G9B9E5_SHAREDEXP, DXGI_FORMAT_R9G9B9E5_SHAREDEXP, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_R8I, D3D11FormatInfo(DXGI_FORMAT_R8_SINT, DXGI_FORMAT_R8_SINT, DXGI_FORMAT_R8_SINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_R8UI, D3D11FormatInfo(DXGI_FORMAT_R8_UINT, DXGI_FORMAT_R8_UINT, DXGI_FORMAT_R8_UINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_R16I, D3D11FormatInfo(DXGI_FORMAT_R16_SINT, DXGI_FORMAT_R16_SINT, DXGI_FORMAT_R16_SINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_R16UI, D3D11FormatInfo(DXGI_FORMAT_R16_UINT, DXGI_FORMAT_R16_UINT, DXGI_FORMAT_R16_UINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_R32I, D3D11FormatInfo(DXGI_FORMAT_R32_SINT, DXGI_FORMAT_R32_SINT, DXGI_FORMAT_R32_SINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_R32UI, D3D11FormatInfo(DXGI_FORMAT_R32_UINT, DXGI_FORMAT_R32_UINT, DXGI_FORMAT_R32_UINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RG8I, D3D11FormatInfo(DXGI_FORMAT_R8G8_SINT, DXGI_FORMAT_R8G8_SINT, DXGI_FORMAT_R8G8_SINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RG8UI, D3D11FormatInfo(DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RG16I, D3D11FormatInfo(DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RG16UI, D3D11FormatInfo(DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RG32I, D3D11FormatInfo(DXGI_FORMAT_R32G32_SINT, DXGI_FORMAT_R32G32_SINT, DXGI_FORMAT_R32G32_SINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RG32UI, D3D11FormatInfo(DXGI_FORMAT_R32G32_UINT, DXGI_FORMAT_R32G32_UINT, DXGI_FORMAT_R32G32_UINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGB8I, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGB8UI, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGB16I, D3D11FormatInfo(DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGB16UI, D3D11FormatInfo(DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGB32I, D3D11FormatInfo(DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGB32UI, D3D11FormatInfo(DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGBA8I, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGBA8UI, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGBA16I, D3D11FormatInfo(DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGBA16UI, D3D11FormatInfo(DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGBA32I, D3D11FormatInfo(DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGBA32UI, D3D11FormatInfo(DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_UNKNOWN))); + // | GL internal format | | D3D11 texture format | D3D11 SRV format | D3D11 RTV format | D3D11 DSV format | + map.insert(D3D11ES3FormatPair(GL_NONE, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_R8, D3D11ES3FormatInfo(DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_R8_SNORM, D3D11ES3FormatInfo(DXGI_FORMAT_R8_SNORM, DXGI_FORMAT_R8_SNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RG8, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8_UNORM, DXGI_FORMAT_R8G8_UNORM, DXGI_FORMAT_R8G8_UNORM, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RG8_SNORM, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8_SNORM, DXGI_FORMAT_R8G8_SNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGB8, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGB8_SNORM, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_SNORM, DXGI_FORMAT_R8G8B8A8_SNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGB565, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGBA4, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGB5_A1, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGBA8, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGBA8_SNORM, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_SNORM, DXGI_FORMAT_R8G8B8A8_SNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGB10_A2, D3D11ES3FormatInfo(DXGI_FORMAT_R10G10B10A2_UNORM, DXGI_FORMAT_R10G10B10A2_UNORM, DXGI_FORMAT_R10G10B10A2_UNORM, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGB10_A2UI, D3D11ES3FormatInfo(DXGI_FORMAT_R10G10B10A2_UINT, DXGI_FORMAT_R10G10B10A2_UINT, DXGI_FORMAT_R10G10B10A2_UINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_SRGB8, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_SRGB8_ALPHA8, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_R16F, D3D11ES3FormatInfo(DXGI_FORMAT_R16_FLOAT, DXGI_FORMAT_R16_FLOAT, DXGI_FORMAT_R16_FLOAT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RG16F, D3D11ES3FormatInfo(DXGI_FORMAT_R16G16_FLOAT, DXGI_FORMAT_R16G16_FLOAT, DXGI_FORMAT_R16G16_FLOAT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGB16F, D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGBA16F, D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_R32F, D3D11ES3FormatInfo(DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RG32F, D3D11ES3FormatInfo(DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGB32F, D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGBA32F, D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_R11F_G11F_B10F, D3D11ES3FormatInfo(DXGI_FORMAT_R11G11B10_FLOAT, DXGI_FORMAT_R11G11B10_FLOAT, DXGI_FORMAT_R11G11B10_FLOAT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGB9_E5, D3D11ES3FormatInfo(DXGI_FORMAT_R9G9B9E5_SHAREDEXP, DXGI_FORMAT_R9G9B9E5_SHAREDEXP, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_R8I, D3D11ES3FormatInfo(DXGI_FORMAT_R8_SINT, DXGI_FORMAT_R8_SINT, DXGI_FORMAT_R8_SINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_R8UI, D3D11ES3FormatInfo(DXGI_FORMAT_R8_UINT, DXGI_FORMAT_R8_UINT, DXGI_FORMAT_R8_UINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_R16I, D3D11ES3FormatInfo(DXGI_FORMAT_R16_SINT, DXGI_FORMAT_R16_SINT, DXGI_FORMAT_R16_SINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_R16UI, D3D11ES3FormatInfo(DXGI_FORMAT_R16_UINT, DXGI_FORMAT_R16_UINT, DXGI_FORMAT_R16_UINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_R32I, D3D11ES3FormatInfo(DXGI_FORMAT_R32_SINT, DXGI_FORMAT_R32_SINT, DXGI_FORMAT_R32_SINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_R32UI, D3D11ES3FormatInfo(DXGI_FORMAT_R32_UINT, DXGI_FORMAT_R32_UINT, DXGI_FORMAT_R32_UINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RG8I, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8_SINT, DXGI_FORMAT_R8G8_SINT, DXGI_FORMAT_R8G8_SINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RG8UI, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RG16I, D3D11ES3FormatInfo(DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RG16UI, D3D11ES3FormatInfo(DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RG32I, D3D11ES3FormatInfo(DXGI_FORMAT_R32G32_SINT, DXGI_FORMAT_R32G32_SINT, DXGI_FORMAT_R32G32_SINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RG32UI, D3D11ES3FormatInfo(DXGI_FORMAT_R32G32_UINT, DXGI_FORMAT_R32G32_UINT, DXGI_FORMAT_R32G32_UINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGB8I, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGB8UI, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGB16I, D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGB16UI, D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGB32I, D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGB32UI, D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_R32G32B32A32_UINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGBA8I, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_R8G8B8A8_SINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGBA8UI, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGBA16I, D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGBA16UI, D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGBA32I, D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_R32G32B32A32_SINT, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGBA32UI, D3D11ES3FormatInfo(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? - map.insert(D3D11ES3FormatPair(GL_ALPHA, D3D11FormatInfo(DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_LUMINANCE, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_LUMINANCE_ALPHA, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGB, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_RGBA, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_BGRA_EXT, D3D11FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_ALPHA, D3D11ES3FormatInfo(DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_LUMINANCE, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_LUMINANCE_ALPHA, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGB, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_RGBA, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_BGRA_EXT, D3D11ES3FormatInfo(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 | - map.insert(D3D11ES3FormatPair(GL_ALPHA8_EXT, D3D11FormatInfo(DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_UNKNOWN ))); - map.insert(D3D11ES3FormatPair(GL_LUMINANCE8_EXT, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN ))); - map.insert(D3D11ES3FormatPair(GL_ALPHA32F_EXT, D3D11FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN ))); - map.insert(D3D11ES3FormatPair(GL_LUMINANCE32F_EXT, D3D11FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN ))); - map.insert(D3D11ES3FormatPair(GL_ALPHA16F_EXT, D3D11FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN ))); - map.insert(D3D11ES3FormatPair(GL_LUMINANCE16F_EXT, D3D11FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN ))); - map.insert(D3D11ES3FormatPair(GL_LUMINANCE8_ALPHA8_EXT, D3D11FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN ))); - map.insert(D3D11ES3FormatPair(GL_LUMINANCE_ALPHA32F_EXT, D3D11FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN ))); - map.insert(D3D11ES3FormatPair(GL_LUMINANCE_ALPHA16F_EXT, D3D11FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN ))); - map.insert(D3D11ES3FormatPair(GL_BGRA8_EXT, D3D11FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN ))); - map.insert(D3D11ES3FormatPair(GL_BGRA4_ANGLEX, D3D11FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN ))); - map.insert(D3D11ES3FormatPair(GL_BGR5_A1_ANGLEX, D3D11FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN ))); + // | GL internal format | | D3D11 texture format | D3D11 SRV format | D3D11 RTV format | D3D11 DSV format | + map.insert(D3D11ES3FormatPair(GL_ALPHA8_EXT, D3D11ES3FormatInfo(DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_UNKNOWN ))); + map.insert(D3D11ES3FormatPair(GL_LUMINANCE8_EXT, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN ))); + map.insert(D3D11ES3FormatPair(GL_ALPHA32F_EXT, D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN ))); + map.insert(D3D11ES3FormatPair(GL_LUMINANCE32F_EXT, D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN ))); + map.insert(D3D11ES3FormatPair(GL_ALPHA16F_EXT, D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN ))); + map.insert(D3D11ES3FormatPair(GL_LUMINANCE16F_EXT, D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN ))); + map.insert(D3D11ES3FormatPair(GL_LUMINANCE8_ALPHA8_EXT, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN ))); + map.insert(D3D11ES3FormatPair(GL_LUMINANCE_ALPHA32F_EXT, D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN ))); + map.insert(D3D11ES3FormatPair(GL_LUMINANCE_ALPHA16F_EXT, D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN ))); + map.insert(D3D11ES3FormatPair(GL_BGRA8_EXT, D3D11ES3FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN ))); + map.insert(D3D11ES3FormatPair(GL_BGRA4_ANGLEX, D3D11ES3FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN ))); + map.insert(D3D11ES3FormatPair(GL_BGR5_A1_ANGLEX, D3D11ES3FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN ))); // Depth stencil formats - map.insert(D3D11ES3FormatPair(GL_DEPTH_COMPONENT16, D3D11FormatInfo(DXGI_FORMAT_R16_TYPELESS, DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D16_UNORM ))); - map.insert(D3D11ES3FormatPair(GL_DEPTH_COMPONENT24, D3D11FormatInfo(DXGI_FORMAT_R24G8_TYPELESS, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT ))); - map.insert(D3D11ES3FormatPair(GL_DEPTH_COMPONENT32F, D3D11FormatInfo(DXGI_FORMAT_R32_TYPELESS, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D32_FLOAT ))); - map.insert(D3D11ES3FormatPair(GL_DEPTH24_STENCIL8, D3D11FormatInfo(DXGI_FORMAT_R24G8_TYPELESS, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT ))); - map.insert(D3D11ES3FormatPair(GL_DEPTH32F_STENCIL8, D3D11FormatInfo(DXGI_FORMAT_R32G8X24_TYPELESS, DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D32_FLOAT_S8X24_UINT))); - map.insert(D3D11ES3FormatPair(GL_STENCIL_INDEX8, D3D11FormatInfo(DXGI_FORMAT_R24G8_TYPELESS, DXGI_FORMAT_X24_TYPELESS_G8_UINT, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT ))); + map.insert(D3D11ES3FormatPair(GL_DEPTH_COMPONENT16, D3D11ES3FormatInfo(DXGI_FORMAT_R16_TYPELESS, DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D16_UNORM ))); + map.insert(D3D11ES3FormatPair(GL_DEPTH_COMPONENT24, D3D11ES3FormatInfo(DXGI_FORMAT_R24G8_TYPELESS, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT ))); + map.insert(D3D11ES3FormatPair(GL_DEPTH_COMPONENT32F, D3D11ES3FormatInfo(DXGI_FORMAT_R32_TYPELESS, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D32_FLOAT ))); + map.insert(D3D11ES3FormatPair(GL_DEPTH24_STENCIL8, D3D11ES3FormatInfo(DXGI_FORMAT_R24G8_TYPELESS, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT ))); + map.insert(D3D11ES3FormatPair(GL_DEPTH32F_STENCIL8, D3D11ES3FormatInfo(DXGI_FORMAT_R32G8X24_TYPELESS, DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D32_FLOAT_S8X24_UINT))); + map.insert(D3D11ES3FormatPair(GL_STENCIL_INDEX8, D3D11ES3FormatInfo(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. - map.insert(D3D11ES3FormatPair(GL_DEPTH_COMPONENT32_OES, D3D11FormatInfo(DXGI_FORMAT_R24G8_TYPELESS, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT ))); + map.insert(D3D11ES3FormatPair(GL_DEPTH_COMPONENT32_OES, D3D11ES3FormatInfo(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 | - map.insert(D3D11ES3FormatPair(GL_COMPRESSED_R11_EAC, D3D11FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_COMPRESSED_SIGNED_R11_EAC, D3D11FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RG11_EAC, D3D11FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_COMPRESSED_SIGNED_RG11_EAC, D3D11FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGB8_ETC2, D3D11FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_COMPRESSED_SRGB8_ETC2, D3D11FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, D3D11FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, D3D11FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGBA8_ETC2_EAC, D3D11FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, D3D11FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + // | GL internal format | | D3D11 texture format | D3D11 SRV format | D3D11 RTV format | D3D11 DSV format | + map.insert(D3D11ES3FormatPair(GL_COMPRESSED_R11_EAC, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_COMPRESSED_SIGNED_R11_EAC, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RG11_EAC, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_COMPRESSED_SIGNED_RG11_EAC, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGB8_ETC2, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_COMPRESSED_SRGB8_ETC2, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGBA8_ETC2_EAC, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); // From GL_EXT_texture_compression_dxt1 - map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, D3D11FormatInfo(DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); - map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, D3D11FormatInfo(DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, D3D11ES3FormatInfo(DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, D3D11ES3FormatInfo(DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); // From GL_ANGLE_texture_compression_dxt3 - map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, D3D11FormatInfo(DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, D3D11ES3FormatInfo(DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); // From GL_ANGLE_texture_compression_dxt5 - map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, D3D11FormatInfo(DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); + map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, D3D11ES3FormatInfo(DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); return map; } -static bool GetD3D11FormatInfo(GLenum internalFormat, D3D11FormatInfo *outFormatInfo) +static bool GetD3D11ES3FormatInfo(GLenum internalFormat, GLuint clientVersion, D3D11ES3FormatInfo *outFormatInfo) { - static const D3D11ES3FormatMap formatMap = BuildD3D11FormatMap(); + static const D3D11ES3FormatMap formatMap = BuildD3D11ES3FormatMap(); D3D11ES3FormatMap::const_iterator iter = formatMap.find(internalFormat); if (iter != formatMap.end()) { @@ -219,7 +218,6 @@ D3D11LoadFunctionMap buildD3D11LoadFunctionMap() insertLoadFunction(&map, GL_RGB5_A1, GL_UNSIGNED_SHORT_5_5_5_1, loadRGBA5551DataToRGBA ); insertLoadFunction(&map, GL_RGB5_A1, GL_UNSIGNED_INT_2_10_10_10_REV, loadRGBA2101010ToRGBA ); insertLoadFunction(&map, GL_RGBA16F, GL_HALF_FLOAT, loadToNative ); - insertLoadFunction(&map, GL_RGBA16F, GL_HALF_FLOAT_OES, loadToNative ); insertLoadFunction(&map, GL_RGBA32F, GL_FLOAT, loadToNative ); insertLoadFunction(&map, GL_RGBA16F, GL_FLOAT, loadFloatDataToHalfFloat<4> ); insertLoadFunction(&map, GL_RGBA8UI, GL_UNSIGNED_BYTE, loadToNative ); @@ -237,11 +235,8 @@ D3D11LoadFunctionMap buildD3D11LoadFunctionMap() insertLoadFunction(&map, GL_R11F_G11F_B10F, GL_UNSIGNED_INT_10F_11F_11F_REV, loadToNative ); insertLoadFunction(&map, GL_RGB9_E5, GL_UNSIGNED_INT_5_9_9_9_REV, loadToNative ); insertLoadFunction(&map, GL_RGB16F, GL_HALF_FLOAT, loadToNative3To4); - insertLoadFunction(&map, GL_RGB16F, GL_HALF_FLOAT_OES, loadToNative3To4); insertLoadFunction(&map, GL_R11F_G11F_B10F, GL_HALF_FLOAT, loadRGBHalfFloatDataTo111110Float ); - insertLoadFunction(&map, GL_R11F_G11F_B10F, GL_HALF_FLOAT_OES, loadRGBHalfFloatDataTo111110Float ); insertLoadFunction(&map, GL_RGB9_E5, GL_HALF_FLOAT, loadRGBHalfFloatDataTo999E5 ); - insertLoadFunction(&map, GL_RGB9_E5, GL_HALF_FLOAT_OES, loadRGBHalfFloatDataTo999E5 ); insertLoadFunction(&map, GL_RGB32F, GL_FLOAT, loadToNative3To4); insertLoadFunction(&map, GL_RGB16F, GL_FLOAT, loadFloatRGBDataToHalfFloatRGBA ); insertLoadFunction(&map, GL_R11F_G11F_B10F, GL_FLOAT, loadRGBFloatDataTo111110Float ); @@ -255,7 +250,6 @@ D3D11LoadFunctionMap buildD3D11LoadFunctionMap() insertLoadFunction(&map, GL_RG8, GL_UNSIGNED_BYTE, loadToNative ); insertLoadFunction(&map, GL_RG8_SNORM, GL_BYTE, loadToNative ); insertLoadFunction(&map, GL_RG16F, GL_HALF_FLOAT, loadToNative ); - insertLoadFunction(&map, GL_RG16F, GL_HALF_FLOAT_OES, loadToNative ); insertLoadFunction(&map, GL_RG32F, GL_FLOAT, loadToNative ); insertLoadFunction(&map, GL_RG16F, GL_FLOAT, loadFloatDataToHalfFloat<2> ); insertLoadFunction(&map, GL_RG8UI, GL_UNSIGNED_BYTE, loadToNative ); @@ -267,7 +261,6 @@ D3D11LoadFunctionMap buildD3D11LoadFunctionMap() insertLoadFunction(&map, GL_R8, GL_UNSIGNED_BYTE, loadToNative ); insertLoadFunction(&map, GL_R8_SNORM, GL_BYTE, loadToNative ); insertLoadFunction(&map, GL_R16F, GL_HALF_FLOAT, loadToNative ); - insertLoadFunction(&map, GL_R16F, GL_HALF_FLOAT_OES, loadToNative ); insertLoadFunction(&map, GL_R32F, GL_FLOAT, loadToNative ); insertLoadFunction(&map, GL_R16F, GL_FLOAT, loadFloatDataToHalfFloat<1> ); insertLoadFunction(&map, GL_R8UI, GL_UNSIGNED_BYTE, loadToNative ); @@ -297,35 +290,25 @@ D3D11LoadFunctionMap buildD3D11LoadFunctionMap() // From GL_OES_texture_float insertLoadFunction(&map, GL_LUMINANCE_ALPHA, GL_FLOAT, loadLuminanceAlphaFloatDataToRGBA ); - insertLoadFunction(&map, GL_LUMINANCE, GL_FLOAT, loadLuminanceFloatDataToRGBA ); + insertLoadFunction(&map, GL_LUMINANCE, GL_FLOAT, loadLuminanceFloatDataToRGB ); insertLoadFunction(&map, GL_ALPHA, GL_FLOAT, loadAlphaFloatDataToRGBA ); // From GL_OES_texture_half_float insertLoadFunction(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, loadLuminanceAlphaHalfFloatDataToRGBA); - insertLoadFunction(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, loadLuminanceAlphaHalfFloatDataToRGBA); insertLoadFunction(&map, GL_LUMINANCE, GL_HALF_FLOAT, loadLuminanceHalfFloatDataToRGBA ); - insertLoadFunction(&map, GL_LUMINANCE, GL_HALF_FLOAT_OES, loadLuminanceHalfFloatDataToRGBA ); insertLoadFunction(&map, GL_ALPHA, GL_HALF_FLOAT, loadAlphaHalfFloatDataToRGBA ); - insertLoadFunction(&map, GL_ALPHA, GL_HALF_FLOAT_OES, loadAlphaHalfFloatDataToRGBA ); // From GL_EXT_texture_storage insertLoadFunction(&map, GL_ALPHA8_EXT, GL_UNSIGNED_BYTE, loadToNative ); insertLoadFunction(&map, GL_LUMINANCE8_EXT, GL_UNSIGNED_BYTE, loadLuminanceDataToBGRA ); insertLoadFunction(&map, GL_LUMINANCE8_ALPHA8_EXT, GL_UNSIGNED_BYTE, loadLuminanceAlphaDataToBGRA ); insertLoadFunction(&map, GL_ALPHA32F_EXT, GL_FLOAT, loadAlphaFloatDataToRGBA ); - insertLoadFunction(&map, GL_LUMINANCE32F_EXT, GL_FLOAT, loadLuminanceFloatDataToRGBA ); + insertLoadFunction(&map, GL_LUMINANCE32F_EXT, GL_FLOAT, loadLuminanceFloatDataToRGB ); insertLoadFunction(&map, GL_LUMINANCE_ALPHA32F_EXT, GL_FLOAT, loadLuminanceAlphaFloatDataToRGBA ); insertLoadFunction(&map, GL_ALPHA16F_EXT, GL_HALF_FLOAT, loadAlphaHalfFloatDataToRGBA ); - insertLoadFunction(&map, GL_ALPHA16F_EXT, GL_HALF_FLOAT_OES, loadAlphaHalfFloatDataToRGBA ); insertLoadFunction(&map, GL_LUMINANCE16F_EXT, GL_HALF_FLOAT, loadLuminanceHalfFloatDataToRGBA ); - insertLoadFunction(&map, GL_LUMINANCE16F_EXT, GL_HALF_FLOAT_OES, loadLuminanceHalfFloatDataToRGBA ); insertLoadFunction(&map, GL_LUMINANCE_ALPHA16F_EXT, GL_HALF_FLOAT, loadLuminanceAlphaHalfFloatDataToRGBA); - insertLoadFunction(&map, GL_LUMINANCE_ALPHA16F_EXT, GL_HALF_FLOAT_OES, loadLuminanceAlphaHalfFloatDataToRGBA); - // From GL_ANGLE_depth_texture - insertLoadFunction(&map, GL_DEPTH_COMPONENT32_OES, GL_UNSIGNED_INT, loadUintDataToUint24X8 ); - - // From GL_EXT_texture_format_BGRA8888 insertLoadFunction(&map, GL_BGRA8_EXT, GL_UNSIGNED_BYTE, loadToNative ); insertLoadFunction(&map, GL_BGRA4_ANGLEX, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, loadRGBA4444DataToRGBA ); insertLoadFunction(&map, GL_BGRA4_ANGLEX, GL_UNSIGNED_BYTE, loadToNative ); @@ -360,6 +343,101 @@ D3D11LoadFunctionMap buildD3D11LoadFunctionMap() return map; } +struct D3D11ES2FormatInfo +{ + DXGI_FORMAT mTexFormat; + DXGI_FORMAT mSRVFormat; + DXGI_FORMAT mRTVFormat; + DXGI_FORMAT mDSVFormat; + + LoadImageFunction mLoadImageFunction; + + D3D11ES2FormatInfo() + : mTexFormat(DXGI_FORMAT_UNKNOWN), mDSVFormat(DXGI_FORMAT_UNKNOWN), mRTVFormat(DXGI_FORMAT_UNKNOWN), + mSRVFormat(DXGI_FORMAT_UNKNOWN), mLoadImageFunction(NULL) + { } + + D3D11ES2FormatInfo(DXGI_FORMAT texFormat, DXGI_FORMAT srvFormat, DXGI_FORMAT rtvFormat, DXGI_FORMAT dsvFormat, + LoadImageFunction loadFunc) + : mTexFormat(texFormat), mDSVFormat(dsvFormat), mRTVFormat(rtvFormat), mSRVFormat(srvFormat), + mLoadImageFunction(loadFunc) + { } +}; + +// ES2 internal formats can map to DXGI formats and loading functions +typedef std::pair D3D11ES2FormatPair; +typedef std::map D3D11ES2FormatMap; + +static D3D11ES2FormatMap BuildD3D11ES2FormatMap() +{ + D3D11ES2FormatMap map; + + // | Internal format | | Texture format | SRV format | RTV format | DSV format | Load function | + map.insert(D3D11ES2FormatPair(GL_NONE, D3D11ES2FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, UnreachableLoadFunction ))); + map.insert(D3D11ES2FormatPair(GL_DEPTH_COMPONENT16, D3D11ES2FormatInfo(DXGI_FORMAT_R16_TYPELESS, DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D16_UNORM, UnreachableLoadFunction ))); + map.insert(D3D11ES2FormatPair(GL_DEPTH_COMPONENT32_OES, D3D11ES2FormatInfo(DXGI_FORMAT_R32_TYPELESS, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D32_FLOAT, UnreachableLoadFunction ))); + map.insert(D3D11ES2FormatPair(GL_DEPTH24_STENCIL8_OES, D3D11ES2FormatInfo(DXGI_FORMAT_R24G8_TYPELESS, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT, UnreachableLoadFunction ))); + map.insert(D3D11ES2FormatPair(GL_STENCIL_INDEX8, D3D11ES2FormatInfo(DXGI_FORMAT_R24G8_TYPELESS, DXGI_FORMAT_X24_TYPELESS_G8_UINT, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT, UnreachableLoadFunction ))); + + map.insert(D3D11ES2FormatPair(GL_RGBA32F_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN, loadRGBAFloatDataToRGBA ))); + map.insert(D3D11ES2FormatPair(GL_RGB32F_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN, loadRGBFloatDataToRGBA ))); + map.insert(D3D11ES2FormatPair(GL_ALPHA32F_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN, loadAlphaFloatDataToRGBA ))); + map.insert(D3D11ES2FormatPair(GL_LUMINANCE32F_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN, loadLuminanceFloatDataToRGBA ))); + map.insert(D3D11ES2FormatPair(GL_LUMINANCE_ALPHA32F_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN, loadLuminanceAlphaFloatDataToRGBA ))); + + map.insert(D3D11ES2FormatPair(GL_RGBA16F_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN, loadRGBAHalfFloatDataToRGBA ))); + map.insert(D3D11ES2FormatPair(GL_RGB16F_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN, loadRGBHalfFloatDataToRGBA ))); + map.insert(D3D11ES2FormatPair(GL_ALPHA16F_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN, loadAlphaHalfFloatDataToRGBA ))); + map.insert(D3D11ES2FormatPair(GL_LUMINANCE16F_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN, loadLuminanceHalfFloatDataToRGBA ))); + map.insert(D3D11ES2FormatPair(GL_LUMINANCE_ALPHA16F_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN, loadLuminanceAlphaHalfFloatDataToRGBA ))); + + map.insert(D3D11ES2FormatPair(GL_ALPHA8_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_UNKNOWN, loadAlphaDataToNative ))); + map.insert(D3D11ES2FormatPair(GL_LUMINANCE8_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN, loadLuminanceDataToBGRA ))); + map.insert(D3D11ES2FormatPair(GL_LUMINANCE8_ALPHA8_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN, loadLuminanceAlphaDataToBGRA ))); + + map.insert(D3D11ES2FormatPair(GL_RGB8_OES, D3D11ES2FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN, loadRGBUByteDataToRGBA ))); + map.insert(D3D11ES2FormatPair(GL_RGB565, D3D11ES2FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN, loadRGB565DataToRGBA ))); + map.insert(D3D11ES2FormatPair(GL_RGBA8_OES, D3D11ES2FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN, loadRGBAUByteDataToNative ))); + map.insert(D3D11ES2FormatPair(GL_RGBA4, D3D11ES2FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN, loadRGBA4444DataToRGBA ))); + map.insert(D3D11ES2FormatPair(GL_RGB5_A1, D3D11ES2FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN, loadRGBA5551DataToRGBA ))); + map.insert(D3D11ES2FormatPair(GL_BGRA8_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN, loadBGRADataToBGRA ))); + map.insert(D3D11ES2FormatPair(GL_BGRA4_ANGLEX, D3D11ES2FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN, loadRGBA4444DataToRGBA ))); + map.insert(D3D11ES2FormatPair(GL_BGR5_A1_ANGLEX, D3D11ES2FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN, loadRGBA5551DataToRGBA ))); + + // From GL_EXT_texture_rg + map.insert(D3D11ES2FormatPair(GL_R8_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_UNKNOWN, loadToNative ))); + map.insert(D3D11ES2FormatPair(GL_R32F_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_UNKNOWN, loadToNative ))); + map.insert(D3D11ES2FormatPair(GL_R16F_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R16_FLOAT, DXGI_FORMAT_R16_FLOAT, DXGI_FORMAT_R16_FLOAT, DXGI_FORMAT_UNKNOWN, loadToNative ))); + map.insert(D3D11ES2FormatPair(GL_RG8_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R8G8_UNORM, DXGI_FORMAT_R8G8_UNORM, DXGI_FORMAT_R8G8_UNORM, DXGI_FORMAT_UNKNOWN, loadToNative ))); + map.insert(D3D11ES2FormatPair(GL_RG32F_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_UNKNOWN, loadToNative ))); + map.insert(D3D11ES2FormatPair(GL_RG16F_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_R16G16_FLOAT, DXGI_FORMAT_R16G16_FLOAT, DXGI_FORMAT_R16G16_FLOAT, DXGI_FORMAT_UNKNOWN, loadToNative ))); + + map.insert(D3D11ES2FormatPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, loadCompressedBlockDataToNative<4, 4, 8>))); + map.insert(D3D11ES2FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, D3D11ES2FormatInfo(DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, loadCompressedBlockDataToNative<4, 4, 8>))); + map.insert(D3D11ES2FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, D3D11ES2FormatInfo(DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, loadCompressedBlockDataToNative<4, 4, 16>))); + map.insert(D3D11ES2FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, D3D11ES2FormatInfo(DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, loadCompressedBlockDataToNative<4, 4, 16>))); + + return map; +} + +static bool GetD3D11ES2FormatInfo(GLenum internalFormat, GLuint clientVersion, D3D11ES2FormatInfo *outFormatInfo) +{ + static const D3D11ES2FormatMap formatMap = BuildD3D11ES2FormatMap(); + D3D11ES2FormatMap::const_iterator iter = formatMap.find(internalFormat); + if (iter != formatMap.end()) + { + if (outFormatInfo) + { + *outFormatInfo = iter->second; + } + return true; + } + else + { + return false; + } +} + // A map to determine the pixel size and mipmap generation function of a given DXGI format struct DXGIFormatInfo { @@ -480,7 +558,7 @@ inline void AddDXGIToESEntry(DXGIToESFormatMap *map, DXGI_FORMAT key, GLenum val map->insert(std::make_pair(key, value)); } -static DXGIToESFormatMap BuildDXGIToESFormatMap() +static DXGIToESFormatMap BuildCommonDXGIToESFormatMap() { DXGIToESFormatMap map; @@ -543,8 +621,6 @@ static DXGIToESFormatMap BuildDXGIToESFormatMap() 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); @@ -553,9 +629,23 @@ static DXGIToESFormatMap BuildDXGIToESFormatMap() return map; } -static const DXGIToESFormatMap &GetDXGIToESFormatMap() +static DXGIToESFormatMap BuildDXGIToES2FormatMap() { - static const DXGIToESFormatMap map = BuildDXGIToESFormatMap(); + DXGIToESFormatMap map = BuildCommonDXGIToESFormatMap(); + + AddDXGIToESEntry(&map, DXGI_FORMAT_R32_TYPELESS, GL_DEPTH_COMPONENT32_OES); + AddDXGIToESEntry(&map, DXGI_FORMAT_D32_FLOAT, GL_DEPTH_COMPONENT32_OES); + + return map; +} + +static DXGIToESFormatMap BuildDXGIToES3FormatMap() +{ + DXGIToESFormatMap map = BuildCommonDXGIToESFormatMap(); + + AddDXGIToESEntry(&map, DXGI_FORMAT_R32_TYPELESS, GL_DEPTH_COMPONENT32F); + AddDXGIToESEntry(&map, DXGI_FORMAT_D32_FLOAT, GL_DEPTH_COMPONENT32F); + return map; } @@ -615,7 +705,7 @@ struct D3D11FastCopyFormat typedef std::map D3D11FastCopyMap; typedef std::pair D3D11FastCopyPair; -static D3D11FastCopyMap BuildFastCopyMap11() +static D3D11FastCopyMap BuildFastCopyMap() { D3D11FastCopyMap map; @@ -780,31 +870,31 @@ static const SwizzleInfoMap &GetSwizzleInfoMap() return map; } -static const SwizzleFormatInfo GetSwizzleFormatInfo(GLenum internalFormat) +static const SwizzleFormatInfo GetSwizzleFormatInfo(GLint internalFormat, GLuint clientVersion) { // Get the maximum sized component unsigned int maxBits = 1; - if (gl::IsFormatCompressed(internalFormat)) + if (gl::IsFormatCompressed(internalFormat, clientVersion)) { - unsigned int compressedBitsPerBlock = gl::GetPixelBytes(internalFormat) * 8; - unsigned int blockSize = gl::GetCompressedBlockWidth(internalFormat) * - gl::GetCompressedBlockHeight(internalFormat); + unsigned int compressedBitsPerBlock = gl::GetPixelBytes(internalFormat, clientVersion) * 8; + unsigned int blockSize = gl::GetCompressedBlockWidth(internalFormat, clientVersion) * + gl::GetCompressedBlockHeight(internalFormat, clientVersion); maxBits = std::max(compressedBitsPerBlock / blockSize, maxBits); } else { - maxBits = std::max(maxBits, gl::GetAlphaBits( internalFormat)); - maxBits = std::max(maxBits, gl::GetRedBits( internalFormat)); - maxBits = std::max(maxBits, gl::GetGreenBits( internalFormat)); - maxBits = std::max(maxBits, gl::GetBlueBits( internalFormat)); - maxBits = std::max(maxBits, gl::GetLuminanceBits(internalFormat)); - maxBits = std::max(maxBits, gl::GetDepthBits( internalFormat)); + maxBits = std::max(maxBits, gl::GetAlphaBits( internalFormat, clientVersion)); + maxBits = std::max(maxBits, gl::GetRedBits( internalFormat, clientVersion)); + maxBits = std::max(maxBits, gl::GetGreenBits( internalFormat, clientVersion)); + maxBits = std::max(maxBits, gl::GetBlueBits( internalFormat, clientVersion)); + maxBits = std::max(maxBits, gl::GetLuminanceBits(internalFormat, clientVersion)); + maxBits = std::max(maxBits, gl::GetDepthBits( internalFormat, clientVersion)); } maxBits = roundUp(maxBits, 8U); - GLenum componentType = gl::GetComponentType(internalFormat); + GLenum componentType = gl::GetComponentType(internalFormat, clientVersion); const SwizzleInfoMap &map = GetSwizzleInfoMap(); SwizzleInfoMap::const_iterator iter = map.find(SwizzleSizeType(maxBits, componentType)); @@ -844,13 +934,34 @@ MipGenerationFunction GetMipGenerationFunction(DXGI_FORMAT format) } } -LoadImageFunction GetImageLoadFunction(GLenum internalFormat, GLenum type) +LoadImageFunction GetImageLoadFunction(GLenum internalFormat, GLenum type, GLuint clientVersion) { - static const D3D11LoadFunctionMap loadImageMap = buildD3D11LoadFunctionMap(); - D3D11LoadFunctionMap::const_iterator iter = loadImageMap.find(InternalFormatTypePair(internalFormat, type)); - if (iter != loadImageMap.end()) + if (clientVersion == 2) { - return iter->second; + D3D11ES2FormatInfo d3d11FormatInfo; + if (GetD3D11ES2FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo)) + { + return d3d11FormatInfo.mLoadImageFunction; + } + else + { + UNREACHABLE(); + return NULL; + } + } + else if (clientVersion == 3) + { + static const D3D11LoadFunctionMap loadImageMap = buildD3D11LoadFunctionMap(); + D3D11LoadFunctionMap::const_iterator iter = loadImageMap.find(InternalFormatTypePair(internalFormat, type)); + if (iter != loadImageMap.end()) + { + return iter->second; + } + else + { + UNREACHABLE(); + return NULL; + } } else { @@ -1025,7 +1136,7 @@ ColorReadFunction GetColorReadFunction(DXGI_FORMAT format) ColorCopyFunction GetFastCopyFunction(DXGI_FORMAT sourceFormat, GLenum destFormat, GLenum destType) { - static const D3D11FastCopyMap fastCopyMap = BuildFastCopyMap11(); + static const D3D11FastCopyMap fastCopyMap = BuildFastCopyMap(); D3D11FastCopyMap::const_iterator iter = fastCopyMap.find(D3D11FastCopyFormat(sourceFormat, destFormat, destType)); return (iter != fastCopyMap.end()) ? iter->second : NULL; } @@ -1035,12 +1146,33 @@ ColorCopyFunction GetFastCopyFunction(DXGI_FORMAT sourceFormat, GLenum destForma namespace gl_d3d11 { -DXGI_FORMAT GetTexFormat(GLenum internalFormat) +DXGI_FORMAT GetTexFormat(GLenum internalFormat, GLuint clientVersion) { - D3D11FormatInfo d3d11FormatInfo; - if (GetD3D11FormatInfo(internalFormat, &d3d11FormatInfo)) + if (clientVersion == 2) { - return d3d11FormatInfo.mTexFormat; + D3D11ES2FormatInfo d3d11FormatInfo; + if (GetD3D11ES2FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo)) + { + return d3d11FormatInfo.mTexFormat; + } + else + { + UNREACHABLE(); + return DXGI_FORMAT_UNKNOWN; + } + } + else if (clientVersion == 3) + { + D3D11ES3FormatInfo d3d11FormatInfo; + if (GetD3D11ES3FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo)) + { + return d3d11FormatInfo.mTexFormat; + } + else + { + UNREACHABLE(); + return DXGI_FORMAT_UNKNOWN; + } } else { @@ -1049,12 +1181,33 @@ DXGI_FORMAT GetTexFormat(GLenum internalFormat) } } -DXGI_FORMAT GetSRVFormat(GLenum internalFormat) +DXGI_FORMAT GetSRVFormat(GLenum internalFormat, GLuint clientVersion) { - D3D11FormatInfo d3d11FormatInfo; - if (GetD3D11FormatInfo(internalFormat, &d3d11FormatInfo)) + if (clientVersion == 2) { - return d3d11FormatInfo.mSRVFormat; + D3D11ES2FormatInfo d3d11FormatInfo; + if (GetD3D11ES2FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo)) + { + return d3d11FormatInfo.mSRVFormat; + } + else + { + UNREACHABLE(); + return DXGI_FORMAT_UNKNOWN; + } + } + else if (clientVersion == 3) + { + D3D11ES3FormatInfo d3d11FormatInfo; + if (GetD3D11ES3FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo)) + { + return d3d11FormatInfo.mSRVFormat; + } + else + { + UNREACHABLE(); + return DXGI_FORMAT_UNKNOWN; + } } else { @@ -1063,12 +1216,33 @@ DXGI_FORMAT GetSRVFormat(GLenum internalFormat) } } -DXGI_FORMAT GetRTVFormat(GLenum internalFormat) +DXGI_FORMAT GetRTVFormat(GLenum internalFormat, GLuint clientVersion) { - D3D11FormatInfo d3d11FormatInfo; - if (GetD3D11FormatInfo(internalFormat, &d3d11FormatInfo)) + if (clientVersion == 2) { - return d3d11FormatInfo.mRTVFormat; + D3D11ES2FormatInfo d3d11FormatInfo; + if (GetD3D11ES2FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo)) + { + return d3d11FormatInfo.mRTVFormat; + } + else + { + UNREACHABLE(); + return DXGI_FORMAT_UNKNOWN; + } + } + else if (clientVersion == 3) + { + D3D11ES3FormatInfo d3d11FormatInfo; + if (GetD3D11ES3FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo)) + { + return d3d11FormatInfo.mRTVFormat; + } + else + { + UNREACHABLE(); + return DXGI_FORMAT_UNKNOWN; + } } else { @@ -1077,68 +1251,91 @@ DXGI_FORMAT GetRTVFormat(GLenum internalFormat) } } -DXGI_FORMAT GetDSVFormat(GLenum internalFormat) +DXGI_FORMAT GetDSVFormat(GLenum internalFormat, GLuint clientVersion) { - D3D11FormatInfo d3d11FormatInfo; - if (GetD3D11FormatInfo(internalFormat, &d3d11FormatInfo)) + if (clientVersion == 2) { - return d3d11FormatInfo.mDSVFormat; + D3D11ES2FormatInfo d3d11FormatInfo; + if (GetD3D11ES2FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo)) + { + return d3d11FormatInfo.mDSVFormat; + } + else + { + return DXGI_FORMAT_UNKNOWN; + } + } + else if (clientVersion == 3) + { + D3D11ES3FormatInfo d3d11FormatInfo; + if (GetD3D11ES3FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo)) + { + return d3d11FormatInfo.mDSVFormat; + } + else + { + return DXGI_FORMAT_UNKNOWN; + } } else { + UNREACHABLE(); return DXGI_FORMAT_UNKNOWN; } } // Given a GL internal format, this function returns the DSV format if it is depth- or stencil-renderable, // the RTV format if it is color-renderable, and the (nonrenderable) texture format otherwise. -DXGI_FORMAT GetRenderableFormat(GLenum internalFormat) +DXGI_FORMAT GetRenderableFormat(GLenum internalFormat, GLuint clientVersion) { - DXGI_FORMAT targetFormat = GetDSVFormat(internalFormat); + DXGI_FORMAT targetFormat = GetDSVFormat(internalFormat, clientVersion); if (targetFormat == DXGI_FORMAT_UNKNOWN) - targetFormat = GetRTVFormat(internalFormat); + targetFormat = GetRTVFormat(internalFormat, clientVersion); if (targetFormat == DXGI_FORMAT_UNKNOWN) - targetFormat = GetTexFormat(internalFormat); + targetFormat = GetTexFormat(internalFormat, clientVersion); return targetFormat; } -DXGI_FORMAT GetSwizzleTexFormat(GLint internalFormat) +DXGI_FORMAT GetSwizzleTexFormat(GLint internalFormat, const Renderer *renderer) { - if (GetRTVFormat(internalFormat) == DXGI_FORMAT_UNKNOWN || gl::GetComponentCount(internalFormat) != 4) + GLuint clientVersion = renderer->getCurrentClientVersion(); + if (gl::GetComponentCount(internalFormat, clientVersion) != 4 || !gl::IsColorRenderingSupported(internalFormat, renderer)) { - const SwizzleFormatInfo &swizzleInfo = GetSwizzleFormatInfo(internalFormat); + const SwizzleFormatInfo &swizzleInfo = GetSwizzleFormatInfo(internalFormat, clientVersion); return swizzleInfo.mTexFormat; } else { - return GetTexFormat(internalFormat); + return GetTexFormat(internalFormat, clientVersion); } } -DXGI_FORMAT GetSwizzleSRVFormat(GLint internalFormat) +DXGI_FORMAT GetSwizzleSRVFormat(GLint internalFormat, const Renderer *renderer) { - if (GetRTVFormat(internalFormat) == DXGI_FORMAT_UNKNOWN || gl::GetComponentCount(internalFormat) != 4) + GLuint clientVersion = renderer->getCurrentClientVersion(); + if (gl::GetComponentCount(internalFormat, clientVersion) != 4 || !gl::IsColorRenderingSupported(internalFormat, renderer)) { - const SwizzleFormatInfo &swizzleInfo = GetSwizzleFormatInfo(internalFormat); + const SwizzleFormatInfo &swizzleInfo = GetSwizzleFormatInfo(internalFormat, clientVersion); return swizzleInfo.mSRVFormat; } else { - return GetSRVFormat(internalFormat); + return GetTexFormat(internalFormat, clientVersion); } } -DXGI_FORMAT GetSwizzleRTVFormat(GLint internalFormat) +DXGI_FORMAT GetSwizzleRTVFormat(GLint internalFormat, const Renderer *renderer) { - if (GetRTVFormat(internalFormat) == DXGI_FORMAT_UNKNOWN || gl::GetComponentCount(internalFormat) != 4) + GLuint clientVersion = renderer->getCurrentClientVersion(); + if (gl::GetComponentCount(internalFormat, clientVersion) != 4 || !gl::IsColorRenderingSupported(internalFormat, renderer)) { - const SwizzleFormatInfo &swizzleInfo = GetSwizzleFormatInfo(internalFormat); + const SwizzleFormatInfo &swizzleInfo = GetSwizzleFormatInfo(internalFormat, clientVersion); return swizzleInfo.mRTVFormat; } else { - return GetRTVFormat(internalFormat); + return GetTexFormat(internalFormat, clientVersion); } } @@ -1438,19 +1635,29 @@ DXGI_FORMAT GetNativeVertexFormat(const gl::VertexFormat &vertexFormat) namespace d3d11_gl { -GLenum GetInternalFormat(DXGI_FORMAT format) +GLenum GetInternalFormat(DXGI_FORMAT format, GLuint clientVersion) { - const DXGIToESFormatMap &formatMap = GetDXGIToESFormatMap(); - DXGIToESFormatMap::const_iterator iter = formatMap.find(format); - if (iter != formatMap.end()) + if (clientVersion == 2) { - return iter->second; + static DXGIToESFormatMap es2FormatMap = BuildDXGIToES2FormatMap(); + auto formatIt = es2FormatMap.find(format); + if (formatIt != es2FormatMap.end()) + { + return formatIt->second; + } } - else + else if (clientVersion == 3) { - UNREACHABLE(); - return GL_NONE; + static DXGIToESFormatMap es3FormatMap = BuildDXGIToES3FormatMap(); + auto formatIt = es3FormatMap.find(format); + if (formatIt != es3FormatMap.end()) + { + return formatIt->second; + } } + + UNREACHABLE(); + return GL_NONE; } } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.h b/gfx/angle/src/libGLESv2/renderer/d3d11/formatutils11.h similarity index 69% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/formatutils11.h index d77fccfe9c31..d7ae4e0b9d9f 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/formatutils11.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/formatutils11.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -23,7 +23,7 @@ namespace d3d11 typedef std::set DXGIFormatSet; MipGenerationFunction GetMipGenerationFunction(DXGI_FORMAT format); -LoadImageFunction GetImageLoadFunction(GLenum internalFormat, GLenum type); +LoadImageFunction GetImageLoadFunction(GLenum internalFormat, GLenum type, GLuint clientVersion); GLuint GetFormatPixelBytes(DXGI_FORMAT format); GLuint GetBlockWidth(DXGI_FORMAT format); @@ -47,15 +47,15 @@ ColorCopyFunction GetFastCopyFunction(DXGI_FORMAT sourceFormat, GLenum destForma namespace gl_d3d11 { -DXGI_FORMAT GetTexFormat(GLenum internalFormat); -DXGI_FORMAT GetSRVFormat(GLenum internalFormat); -DXGI_FORMAT GetRTVFormat(GLenum internalFormat); -DXGI_FORMAT GetDSVFormat(GLenum internalFormat); -DXGI_FORMAT GetRenderableFormat(GLenum internalFormat); +DXGI_FORMAT GetTexFormat(GLenum internalFormat, GLuint clientVersion); +DXGI_FORMAT GetSRVFormat(GLenum internalFormat, GLuint clientVersion); +DXGI_FORMAT GetRTVFormat(GLenum internalFormat, GLuint clientVersion); +DXGI_FORMAT GetDSVFormat(GLenum internalFormat, GLuint clientVersion); +DXGI_FORMAT GetRenderableFormat(GLenum internalFormat, GLuint clientVersion); -DXGI_FORMAT GetSwizzleTexFormat(GLint internalFormat); -DXGI_FORMAT GetSwizzleSRVFormat(GLint internalFormat); -DXGI_FORMAT GetSwizzleRTVFormat(GLint internalFormat); +DXGI_FORMAT GetSwizzleTexFormat(GLint internalFormat, const Renderer *renderer); +DXGI_FORMAT GetSwizzleSRVFormat(GLint internalFormat, const Renderer *renderer); +DXGI_FORMAT GetSwizzleRTVFormat(GLint internalFormat, const Renderer *renderer); bool RequiresTextureDataInitialization(GLint internalFormat); InitializeTextureDataFunction GetTextureDataInitializationFunction(GLint internalFormat); @@ -70,7 +70,7 @@ DXGI_FORMAT GetNativeVertexFormat(const gl::VertexFormat &vertexFormat); namespace d3d11_gl { -GLenum GetInternalFormat(DXGI_FORMAT format); +GLenum GetInternalFormat(DXGI_FORMAT format, GLuint clientVersion); } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.cpp b/gfx/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.cpp similarity index 51% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.cpp index fe1ac3924db7..327d2f04f61f 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" // -// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -8,8 +8,8 @@ // 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/d3d11/renderer11_utils.h" +#include "libGLESv2/renderer/d3d11/formatutils11.h" #include "common/debug.h" namespace rx @@ -216,119 +216,15 @@ D3D11_QUERY ConvertQueryType(GLenum queryType) } - -namespace d3d11_gl -{ - -static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, ID3D11Device *device) -{ - gl::TextureCaps textureCaps; - - DXGI_FORMAT textureFormat = gl_d3d11::GetTexFormat(internalFormat); - DXGI_FORMAT srvFormat = gl_d3d11::GetSRVFormat(internalFormat); - DXGI_FORMAT rtvFormat = gl_d3d11::GetRTVFormat(internalFormat); - DXGI_FORMAT dsvFormat = gl_d3d11::GetDSVFormat(internalFormat); - DXGI_FORMAT renderFormat = gl_d3d11::GetRenderableFormat(internalFormat); - - UINT formatSupport; - if (SUCCEEDED(device->CheckFormatSupport(textureFormat, &formatSupport))) - { - textureCaps.texture2D = (formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE2D) != 0; - textureCaps.textureCubeMap = (formatSupport & D3D11_FORMAT_SUPPORT_TEXTURECUBE) != 0; - textureCaps.texture3D = (formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE3D) != 0; - textureCaps.texture2DArray = (formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE2D) != 0; - } - - if (SUCCEEDED(device->CheckFormatSupport(renderFormat, &formatSupport)) && - (formatSupport & D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET)) - { - for (size_t sampleCount = 1; sampleCount <= D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT; sampleCount++) - { - UINT qualityCount = 0; - if (SUCCEEDED(device->CheckMultisampleQualityLevels(renderFormat, sampleCount, &qualityCount)) && - qualityCount > 0) - { - textureCaps.sampleCounts.insert(sampleCount); - } - } - } - - if (SUCCEEDED(device->CheckFormatSupport(srvFormat, &formatSupport))) - { - textureCaps.filtering = (formatSupport & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE) != 0; - } - - if (SUCCEEDED(device->CheckFormatSupport(rtvFormat, &formatSupport))) - { - textureCaps.colorRendering = (formatSupport & D3D11_FORMAT_SUPPORT_RENDER_TARGET) != 0; - } - - if (SUCCEEDED(device->CheckFormatSupport(dsvFormat, &formatSupport))) - { - textureCaps.depthRendering = gl::GetDepthBits(internalFormat) > 0 && - (formatSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL) != 0; - textureCaps.stencilRendering = gl::GetStencilBits(internalFormat) > 0 && - (formatSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL) != 0; - } - - return textureCaps; -} - -gl::Caps GenerateCaps(ID3D11Device *device) -{ - gl::Caps caps; - - const gl::FormatSet &allFormats = gl::GetAllSizedInternalFormats(); - for (gl::FormatSet::const_iterator internalFormat = allFormats.begin(); internalFormat != allFormats.end(); ++internalFormat) - { - caps.textureCaps.insert(*internalFormat, GenerateTextureFormatCaps(*internalFormat, device)); - } - - D3D_FEATURE_LEVEL featureLevel = device->GetFeatureLevel(); - - caps.extensions.setTextureExtensionSupport(caps.textureCaps); - caps.extensions.elementIndexUint = true; - caps.extensions.packedDepthStencil = true; - caps.extensions.getProgramBinary = true; - caps.extensions.rgb8rgba8 = true; - caps.extensions.readFormatBGRA = true; - caps.extensions.pixelBufferObject = true; - caps.extensions.mapBuffer = true; - caps.extensions.mapBufferRange = true; - caps.extensions.textureNPOT = d3d11::GetNPOTTextureSupport(featureLevel); - caps.extensions.drawBuffers = d3d11::GetMaximumSimultaneousRenderTargets(featureLevel) > 1; - caps.extensions.textureStorage = true; - caps.extensions.textureFilterAnisotropic = true; - caps.extensions.maxTextureAnisotropy = d3d11::GetMaximumAnisotropy(featureLevel); - caps.extensions.occlusionQueryBoolean = d3d11::GetOcclusionQuerySupport(featureLevel); - caps.extensions.fence = d3d11::GetEventQuerySupport(featureLevel); - caps.extensions.timerQuery = false; // Unimplemented - caps.extensions.robustness = true; - caps.extensions.blendMinMax = true; - caps.extensions.framebufferBlit = true; - caps.extensions.framebufferMultisample = true; - caps.extensions.instancedArrays = d3d11::GetInstancingSupport(featureLevel); - caps.extensions.packReverseRowOrder = true; - caps.extensions.standardDerivatives = d3d11::GetDerivativeInstructionSupport(featureLevel); - caps.extensions.shaderTextureLOD = true; - caps.extensions.fragDepth = true; - caps.extensions.textureUsage = true; // This could be false since it has no effect in D3D11 - caps.extensions.translatedShaderSource = true; - - return caps; -} - -} - namespace d3d11 { -void GenerateInitialTextureData(GLint internalFormat, GLuint width, GLuint height, GLuint depth, +void GenerateInitialTextureData(GLint internalFormat, GLuint clientVersion, GLuint width, GLuint height, GLuint depth, GLuint mipLevels, std::vector *outSubresourceData, std::vector< std::vector > *outData) { InitializeTextureDataFunction initializeFunc = gl_d3d11::GetTextureDataInitializationFunction(internalFormat); - DXGI_FORMAT dxgiFormat = gl_d3d11::GetTexFormat(internalFormat); + DXGI_FORMAT dxgiFormat = gl_d3d11::GetTexFormat(internalFormat, clientVersion); outSubresourceData->resize(mipLevels); outData->resize(mipLevels); @@ -379,142 +275,6 @@ HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name) #endif } -bool GetNPOTTextureSupport(D3D_FEATURE_LEVEL featureLevel) -{ - switch (featureLevel) - { - case D3D_FEATURE_LEVEL_11_1: - 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 false; - - default: UNREACHABLE(); return false; - } -} - -float GetMaximumAnisotropy(D3D_FEATURE_LEVEL featureLevel) -{ - switch (featureLevel) - { - case D3D_FEATURE_LEVEL_11_1: - 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; - } -} - -bool GetOcclusionQuerySupport(D3D_FEATURE_LEVEL featureLevel) -{ - switch (featureLevel) - { - case D3D_FEATURE_LEVEL_11_1: - 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; - } -} - -bool GetEventQuerySupport(D3D_FEATURE_LEVEL featureLevel) -{ - // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476150.aspx ID3D11Device::CreateQuery - - switch (featureLevel) - { - case D3D_FEATURE_LEVEL_11_1: - 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; - } -} - -bool GetInstancingSupport(D3D_FEATURE_LEVEL featureLevel) -{ - // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476150.aspx ID3D11Device::CreateInputLayout - - switch (featureLevel) - { - case D3D_FEATURE_LEVEL_11_1: - 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; - } -} - -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) - { - case D3D_FEATURE_LEVEL_11_1: - 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; - } -} - -size_t GetMaximumSimultaneousRenderTargets(D3D_FEATURE_LEVEL featureLevel) -{ - // From http://msdn.microsoft.com/en-us/library/windows/desktop/ff476150.aspx ID3D11Device::CreateInputLayout - - switch (featureLevel) - { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: return D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; - - // FIXME(geofflang): Work around NVIDIA driver bug by repacking buffers - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: return 1; /* 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; - } -} - } } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.h b/gfx/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.h similarity index 86% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.h index 81efefa0bf6a..94bb8f88fe29 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/renderer11_utils.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -11,7 +11,6 @@ #define LIBGLESV2_RENDERER_RENDERER11_UTILS_H #include "libGLESv2/angletypes.h" -#include "libGLESv2/Caps.h" namespace rx { @@ -37,17 +36,10 @@ D3D11_QUERY ConvertQueryType(GLenum queryType); } -namespace d3d11_gl -{ - -gl::Caps GenerateCaps(ID3D11Device *device); - -} - namespace d3d11 { -void GenerateInitialTextureData(GLint internalFormat, GLuint width, GLuint height, GLuint depth, +void GenerateInitialTextureData(GLint internalFormat, GLuint clientVersion, GLuint width, GLuint height, GLuint depth, GLuint mipLevels, std::vector *outSubresourceData, std::vector< std::vector > *outData); @@ -166,14 +158,6 @@ inline void SetBufferData(ID3D11DeviceContext *context, ID3D11Buffer *constantBu context->Unmap(constantBuffer, 0); } -bool GetNPOTTextureSupport(D3D_FEATURE_LEVEL featureLevel); -float GetMaximumAnisotropy(D3D_FEATURE_LEVEL featureLevel); -bool GetOcclusionQuerySupport(D3D_FEATURE_LEVEL featureLevel); -bool GetEventQuerySupport(D3D_FEATURE_LEVEL featureLevel); -bool GetInstancingSupport(D3D_FEATURE_LEVEL featureLevel); -bool GetDerivativeInstructionSupport(D3D_FEATURE_LEVEL featureLevel); -size_t GetMaximumSimultaneousRenderTargets(D3D_FEATURE_LEVEL featureLevel); - } } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/BufferToTexture11.hlsl b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/BufferToTexture11.hlsl similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/BufferToTexture11.hlsl rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/BufferToTexture11.hlsl diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Clear11.hlsl b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/Clear11.hlsl similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Clear11.hlsl rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/Clear11.hlsl diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Passthrough2D11.hlsl b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/Passthrough2D11.hlsl similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Passthrough2D11.hlsl rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/Passthrough2D11.hlsl diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Passthrough3D11.hlsl b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/Passthrough3D11.hlsl similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Passthrough3D11.hlsl rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/Passthrough3D11.hlsl diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Swizzle11.hlsl b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/Swizzle11.hlsl similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/Swizzle11.hlsl rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/Swizzle11.hlsl diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture11_gs.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_gs.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture11_gs.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_gs.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture11_ps_4f.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4f.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture11_ps_4f.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4f.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture11_ps_4i.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4i.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture11_ps_4i.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4i.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture11_ps_4ui.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4ui.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture11_ps_4ui.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4ui.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture11_vs.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_vs.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/buffertotexture11_vs.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_vs.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearfloat11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/clearfloat11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearfloat11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/clearfloat11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearfloat11vs.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/clearfloat11vs.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearfloat11vs.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/clearfloat11vs.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearsint11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/clearsint11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearsint11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/clearsint11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearsint11vs.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/clearsint11vs.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearsint11vs.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/clearsint11vs.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearuint11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/clearuint11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearuint11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/clearuint11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearuint11vs.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/clearuint11vs.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/clearuint11vs.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/clearuint11vs.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough2d11vs.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough2d11vs.h similarity index 95% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough2d11vs.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough2d11vs.h index 87a3bea18b1e..6e6452200a2e 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough2d11vs.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough2d11vs.h @@ -32,9 +32,6 @@ ret // Approximately 4 instruction slots used #endif -#ifndef g_VS_Passthrough2D_H_ -#define g_VS_Passthrough2D_H_ - const BYTE g_VS_Passthrough2D[] = { 68, 88, 66, 67, 197, 214, @@ -135,5 +132,3 @@ const BYTE g_VS_Passthrough2D[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - -#endif diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough3d11gs.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough3d11gs.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough3d11gs.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough3d11gs.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough3d11vs.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough3d11vs.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough3d11vs.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough3d11vs.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughdepth2d11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughdepth2d11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughdepth2d11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughdepth2d11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughlum2d11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum2d11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughlum2d11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum2d11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughlum3d11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum3d11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughlum3d11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum3d11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughlumalpha2d11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha2d11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughlumalpha2d11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha2d11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughlumalpha3d11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha3d11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughlumalpha3d11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha3d11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr2d11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2d11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr2d11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2d11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr2di11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2di11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr2di11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2di11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr2dui11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2dui11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr2dui11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2dui11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr3d11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3d11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr3d11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3d11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr3di11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3di11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr3di11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3di11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr3dui11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3dui11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughr3dui11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3dui11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg2d11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2d11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg2d11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2d11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg2di11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2di11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg2di11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2di11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg2dui11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2dui11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg2dui11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2dui11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg3d11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3d11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg3d11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3d11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg3di11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3di11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg3di11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3di11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg3dui11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3dui11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrg3dui11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3dui11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb2d11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2d11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb2d11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2d11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb2di11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2di11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb2di11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2di11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb2dui11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2dui11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb2dui11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2dui11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb3d11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3d11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb3d11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3d11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb3di11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3di11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb3di11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3di11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb3dui11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3dui11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgb3dui11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3dui11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2d11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2d11ps.h similarity index 95% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2d11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2d11ps.h index 01c0b7e12bbf..b89ce7ae752e 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2d11ps.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2d11ps.h @@ -37,9 +37,6 @@ ret // Approximately 2 instruction slots used #endif -#ifndef g_PS_PassthroughRGBA2D_H_ -#define g_PS_PassthroughRGBA2D_H_ - const BYTE g_PS_PassthroughRGBA2D[] = { 68, 88, 66, 67, 185, 246, @@ -142,5 +139,3 @@ const BYTE g_PS_PassthroughRGBA2D[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - -#endif diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2di11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2di11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2di11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2di11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2dui11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2dui11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2dui11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2dui11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba3d11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3d11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba3d11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3d11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba3di11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3di11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba3di11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3di11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba3dui11ps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3dui11ps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba3dui11ps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3dui11ps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlef2darrayps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlef2darrayps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlef2darrayps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlef2darrayps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlef2dps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlef2dps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlef2dps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlef2dps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlef3dps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlef3dps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlef3dps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlef3dps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlei2darrayps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlei2darrayps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlei2darrayps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlei2darrayps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlei2dps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlei2dps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlei2dps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlei2dps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlei3dps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlei3dps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzlei3dps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlei3dps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzleui2darrayps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzleui2darrayps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzleui2darrayps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzleui2darrayps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzleui2dps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzleui2dps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzleui2dps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzleui2dps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzleui3dps.h b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzleui3dps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/swizzleui3dps.h rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzleui3dps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/generate_shaders.bat b/gfx/angle/src/libGLESv2/renderer/d3d11/shaders/generate_shaders.bat similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d11/shaders/generate_shaders.bat rename to gfx/angle/src/libGLESv2/renderer/d3d11/shaders/generate_shaders.bat diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Blit9.cpp b/gfx/angle/src/libGLESv2/renderer/d3d9/Blit9.cpp similarity index 94% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Blit9.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d9/Blit9.cpp index 2d72729c36e2..a8485bd78d21 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Blit9.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/Blit9.cpp @@ -7,24 +7,24 @@ // Blit9.cpp: Surface copy utility class. -#include "libGLESv2/renderer/d3d/d3d9/Blit9.h" +#include "libGLESv2/renderer/d3d9/Blit9.h" #include "libGLESv2/main.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/renderer/d3d9/renderer9_utils.h" +#include "libGLESv2/renderer/d3d9/formatutils9.h" +#include "libGLESv2/renderer/d3d9/TextureStorage9.h" +#include "libGLESv2/renderer/d3d9/RenderTarget9.h" +#include "libGLESv2/renderer/d3d9/Renderer9.h" #include "libGLESv2/Framebuffer.h" -#include "libGLESv2/FramebufferAttachment.h" +#include "libGLESv2/Renderbuffer.h" namespace { -#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" +#include "libGLESv2/renderer/d3d9/shaders/compiled/standardvs.h" +#include "libGLESv2/renderer/d3d9/shaders/compiled/flipyvs.h" +#include "libGLESv2/renderer/d3d9/shaders/compiled/passthroughps.h" +#include "libGLESv2/renderer/d3d9/shaders/compiled/luminanceps.h" +#include "libGLESv2/renderer/d3d9/shaders/compiled/componentmaskps.h" const BYTE* const g_shaderCode[] = { @@ -213,7 +213,7 @@ bool Blit9::copy(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum de { RenderTarget9 *renderTarget = NULL; IDirect3DSurface9 *source = NULL; - gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(0); + gl::Renderbuffer *colorbuffer = framebuffer->getColorbuffer(0); if (colorbuffer) { @@ -249,7 +249,7 @@ bool Blit9::copy(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum de { RenderTarget9 *renderTarget = NULL; IDirect3DSurface9 *source = NULL; - gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(0); + gl::Renderbuffer *colorbuffer = framebuffer->getColorbuffer(0); if (colorbuffer) { @@ -296,7 +296,7 @@ bool Blit9::copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destF dest->GetDesc(&destDesc); if (sourceDesc.Format == destDesc.Format && destDesc.Usage & D3DUSAGE_RENDERTARGET && - d3d9_gl::IsFormatChannelEquivalent(destDesc.Format, destFormat)) // Can use StretchRect + d3d9_gl::IsFormatChannelEquivalent(destDesc.Format, destFormat, mRenderer->getCurrentClientVersion())) // 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); diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Blit9.h b/gfx/angle/src/libGLESv2/renderer/d3d9/Blit9.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Blit9.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/Blit9.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d9/BufferStorage9.cpp b/gfx/angle/src/libGLESv2/renderer/d3d9/BufferStorage9.cpp new file mode 100644 index 000000000000..489a0401cb6a --- /dev/null +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/BufferStorage9.cpp @@ -0,0 +1,98 @@ +#include "precompiled.h" +// +// 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. +// + +// BufferStorage9.cpp Defines the BufferStorage9 class. + +#include "libGLESv2/renderer/d3d9/BufferStorage9.h" +#include "common/debug.h" +#include "libGLESv2/main.h" + +namespace rx +{ + +BufferStorage9::BufferStorage9() + : mSize(0) +{ +} + +BufferStorage9::~BufferStorage9() +{ +} + +BufferStorage9 *BufferStorage9::makeBufferStorage9(BufferStorage *bufferStorage) +{ + ASSERT(HAS_DYNAMIC_TYPE(BufferStorage9*, bufferStorage)); + return static_cast(bufferStorage); +} + +void *BufferStorage9::getData() +{ + return mMemory.data(); +} + +void BufferStorage9::setData(const void* data, size_t size, size_t offset) +{ + if (offset + size > mMemory.size()) + { + mMemory.resize(offset + size); + } + + mSize = std::max(mSize, offset + size); + if (data) + { + memcpy(mMemory.data() + offset, data, size); + } +} + +void BufferStorage9::copyData(BufferStorage* sourceStorage, size_t size, size_t sourceOffset, size_t destOffset) +{ + BufferStorage9* source = makeBufferStorage9(sourceStorage); + if (source) + { + memcpy(mMemory.data() + destOffset, source->mMemory.data() + sourceOffset, size); + } +} + +void BufferStorage9::clear() +{ + mSize = 0; +} + +void BufferStorage9::markTransformFeedbackUsage() +{ + UNREACHABLE(); +} + +size_t BufferStorage9::getSize() const +{ + return mSize; +} + +bool BufferStorage9::supportsDirectBinding() const +{ + return false; +} + +// We do not suppot buffer mapping facility in D3D9 +bool BufferStorage9::isMapped() const +{ + UNREACHABLE(); + return false; +} + +void *BufferStorage9::map(GLbitfield access) +{ + UNREACHABLE(); + return NULL; +} + +void BufferStorage9::unmap() +{ + UNREACHABLE(); +} + +} diff --git a/gfx/angle/src/libGLESv2/renderer/d3d9/BufferStorage9.h b/gfx/angle/src/libGLESv2/renderer/d3d9/BufferStorage9.h new file mode 100644 index 000000000000..dd61624c2859 --- /dev/null +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/BufferStorage9.h @@ -0,0 +1,46 @@ +// +// 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. +// + +// BufferStorage9.h Defines the BufferStorage9 class. + +#ifndef LIBGLESV2_RENDERER_BUFFERSTORAGE9_H_ +#define LIBGLESV2_RENDERER_BUFFERSTORAGE9_H_ + +#include "libGLESv2/renderer/BufferStorage.h" + +namespace rx +{ + +class BufferStorage9 : public BufferStorage +{ + public: + BufferStorage9(); + virtual ~BufferStorage9(); + + static BufferStorage9 *makeBufferStorage9(BufferStorage *bufferStorage); + + virtual void *getData(); + virtual void setData(const void* data, size_t size, size_t offset); + virtual void copyData(BufferStorage* sourceStorage, size_t size, size_t sourceOffset, size_t destOffset); + virtual void clear(); + virtual void markTransformFeedbackUsage(); + virtual size_t getSize() const; + virtual bool supportsDirectBinding() const; + + virtual bool isMapped() const; + virtual void *map(GLbitfield access); + virtual void unmap(); + + private: + DISALLOW_COPY_AND_ASSIGN(BufferStorage9); + + std::vector mMemory; + size_t mSize; +}; + +} + +#endif // LIBGLESV2_RENDERER_BUFFERSTORAGE9_H_ diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Fence9.cpp b/gfx/angle/src/libGLESv2/renderer/d3d9/Fence9.cpp similarity index 89% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Fence9.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d9/Fence9.cpp index d2437cadf300..372a8a45a5eb 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Fence9.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/Fence9.cpp @@ -7,10 +7,10 @@ // Fence9.cpp: Defines the rx::Fence9 class. -#include "libGLESv2/renderer/d3d/d3d9/Fence9.h" +#include "libGLESv2/renderer/d3d9/Fence9.h" #include "libGLESv2/main.h" -#include "libGLESv2/renderer/d3d/d3d9/renderer9_utils.h" -#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h" +#include "libGLESv2/renderer/d3d9/renderer9_utils.h" +#include "libGLESv2/renderer/d3d9/Renderer9.h" namespace rx { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Fence9.h b/gfx/angle/src/libGLESv2/renderer/d3d9/Fence9.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Fence9.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/Fence9.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Image9.cpp b/gfx/angle/src/libGLESv2/renderer/d3d9/Image9.cpp similarity index 96% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Image9.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d9/Image9.cpp index 29b5ef529174..7ddf957c2539 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Image9.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/Image9.cpp @@ -1,4 +1,3 @@ - #include "precompiled.h" // // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. @@ -9,18 +8,17 @@ // 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/d3d9/Image9.h" #include "libGLESv2/main.h" #include "libGLESv2/Framebuffer.h" -#include "libGLESv2/FramebufferAttachment.h" #include "libGLESv2/Renderbuffer.h" -#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h" -#include "libGLESv2/renderer/d3d/d3d9/RenderTarget9.h" -#include "libGLESv2/renderer/d3d/d3d9/TextureStorage9.h" +#include "libGLESv2/renderer/d3d9/Renderer9.h" +#include "libGLESv2/renderer/d3d9/RenderTarget9.h" +#include "libGLESv2/renderer/d3d9/TextureStorage9.h" -#include "libGLESv2/renderer/d3d/d3d9/renderer9_utils.h" -#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h" +#include "libGLESv2/renderer/d3d9/renderer9_utils.h" +#include "libGLESv2/renderer/d3d9/formatutils9.h" namespace rx { @@ -147,9 +145,9 @@ bool Image9::redefine(rx::Renderer *renderer, GLenum target, GLenum internalform mInternalFormat = internalformat; // compute the d3d format that will be used - mD3DFormat = gl_d3d9::GetTextureFormat(internalformat); + mD3DFormat = gl_d3d9::GetTextureFormat(internalformat, mRenderer); mActualFormat = d3d9_gl::GetInternalFormat(mD3DFormat); - mRenderable = gl_d3d9::GetRenderFormat(internalformat) != D3DFMT_UNKNOWN; + mRenderable = gl_d3d9::GetRenderFormat(internalformat, mRenderer) != D3DFMT_UNKNOWN; SafeRelease(mSurface); mDirty = gl_d3d9::RequiresTextureDataInitialization(mInternalFormat); @@ -387,9 +385,10 @@ void Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width // 3D textures are not supported by the D3D9 backend. ASSERT(zoffset == 0 && depth == 1); - GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, type, width, unpackAlignment); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, type, clientVersion, width, unpackAlignment); - LoadImageFunction loadFunction = d3d9::GetImageLoadFunction(mInternalFormat); + LoadImageFunction loadFunction = d3d9::GetImageLoadFunction(mInternalFormat, mRenderer); ASSERT(loadFunction != NULL); RECT lockRect = @@ -416,13 +415,14 @@ void Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLs // 3D textures are not supported by the D3D9 backend. ASSERT(zoffset == 0 && depth == 1); - GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, GL_UNSIGNED_BYTE, width, 1); - GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, GL_UNSIGNED_BYTE, width, height, 1); + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, 1); + GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, height, 1); ASSERT(xoffset % d3d9::GetBlockWidth(mD3DFormat) == 0); ASSERT(yoffset % d3d9::GetBlockHeight(mD3DFormat) == 0); - LoadImageFunction loadFunction = d3d9::GetImageLoadFunction(mInternalFormat); + LoadImageFunction loadFunction = d3d9::GetImageLoadFunction(mInternalFormat, mRenderer); ASSERT(loadFunction != NULL); RECT lockRect = @@ -452,7 +452,7 @@ void Image9::copy(GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, RenderTarget9 *renderTarget = NULL; IDirect3DSurface9 *surface = NULL; - gl::FramebufferAttachment *colorbuffer = source->getColorbuffer(0); + gl::Renderbuffer *colorbuffer = source->getColorbuffer(0); if (colorbuffer) { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Image9.h b/gfx/angle/src/libGLESv2/renderer/d3d9/Image9.h similarity index 97% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Image9.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/Image9.h index 00117061a404..8b5ba89ff24c 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Image9.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/Image9.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.cpp b/gfx/angle/src/libGLESv2/renderer/d3d9/IndexBuffer9.cpp similarity index 94% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d9/IndexBuffer9.cpp index 428b2088a553..bc2e6a8002c7 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/IndexBuffer9.cpp @@ -1,14 +1,14 @@ #include "precompiled.h" // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // Indexffer9.cpp: Defines the D3D9 IndexBuffer implementation. -#include "libGLESv2/renderer/d3d/d3d9/IndexBuffer9.h" -#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h" +#include "libGLESv2/renderer/d3d9/IndexBuffer9.h" +#include "libGLESv2/renderer/d3d9/Renderer9.h" namespace rx { @@ -41,7 +41,7 @@ bool IndexBuffer9::initialize(unsigned int bufferSize, GLenum indexType, bool dy } else if (indexType == GL_UNSIGNED_INT) { - if (mRenderer->getCaps().extensions.elementIndexUint) + if (mRenderer->get32BitIndexSupport()) { format = D3DFMT_INDEX32; } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.h b/gfx/angle/src/libGLESv2/renderer/d3d9/IndexBuffer9.h similarity index 96% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/IndexBuffer9.h index cfc20e1c64f4..680186753245 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/IndexBuffer9.h @@ -9,7 +9,7 @@ #ifndef LIBGLESV2_RENDERER_INDEXBUFFER9_H_ #define LIBGLESV2_RENDERER_INDEXBUFFER9_H_ -#include "libGLESv2/renderer/d3d/IndexBuffer.h" +#include "libGLESv2/renderer/IndexBuffer.h" namespace rx { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Query9.cpp b/gfx/angle/src/libGLESv2/renderer/d3d9/Query9.cpp similarity index 94% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Query9.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d9/Query9.cpp index 3c6f1d0d43b7..bc3f58fb7bde 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Query9.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/Query9.cpp @@ -8,10 +8,10 @@ // Query9.cpp: Defines the rx::Query9 class which implements rx::QueryImpl. -#include "libGLESv2/renderer/d3d/d3d9/Query9.h" +#include "libGLESv2/renderer/d3d9/Query9.h" #include "libGLESv2/main.h" -#include "libGLESv2/renderer/d3d/d3d9/renderer9_utils.h" -#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h" +#include "libGLESv2/renderer/d3d9/renderer9_utils.h" +#include "libGLESv2/renderer/d3d9/Renderer9.h" namespace rx { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Query9.h b/gfx/angle/src/libGLESv2/renderer/d3d9/Query9.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Query9.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/Query9.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.cpp b/gfx/angle/src/libGLESv2/renderer/d3d9/RenderTarget9.cpp similarity index 89% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d9/RenderTarget9.cpp index 83409095ca98..9456e482a165 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/RenderTarget9.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" // -// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -8,11 +8,11 @@ // 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/d3d9/RenderTarget9.h" +#include "libGLESv2/renderer/d3d9/Renderer9.h" -#include "libGLESv2/renderer/d3d/d3d9/renderer9_utils.h" -#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h" +#include "libGLESv2/renderer/d3d9/renderer9_utils.h" +#include "libGLESv2/renderer/d3d9/formatutils9.h" #include "libGLESv2/main.h" namespace rx @@ -44,7 +44,7 @@ RenderTarget9::RenderTarget9(Renderer *renderer, GLsizei width, GLsizei height, mRenderer = Renderer9::makeRenderer9(renderer); mRenderTarget = NULL; - D3DFORMAT renderFormat = gl_d3d9::GetRenderFormat(internalFormat); + D3DFORMAT renderFormat = gl_d3d9::GetRenderFormat(internalFormat, mRenderer); int supportedSamples = mRenderer->getNearestSupportedSamples(renderFormat, samples); if (supportedSamples == -1) @@ -56,14 +56,16 @@ RenderTarget9::RenderTarget9(Renderer *renderer, GLsizei width, GLsizei height, HRESULT result = D3DERR_INVALIDCALL; + GLuint clientVersion = mRenderer->getCurrentClientVersion(); + if (width > 0 && height > 0) { IDirect3DDevice9 *device = mRenderer->getDevice(); bool requiresInitialization = false; - if (gl::GetDepthBits(internalFormat) > 0 || - gl::GetStencilBits(internalFormat) > 0) + if (gl::GetDepthBits(internalFormat, clientVersion) > 0 || + gl::GetStencilBits(internalFormat, clientVersion) > 0) { result = device->CreateDepthStencilSurface(width, height, renderFormat, gl_d3d9::GetMultisampleType(supportedSamples), diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.h b/gfx/angle/src/libGLESv2/renderer/d3d9/RenderTarget9.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/RenderTarget9.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/RenderTarget9.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp b/gfx/angle/src/libGLESv2/renderer/d3d9/Renderer9.cpp similarity index 87% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d9/Renderer9.cpp index 3a6ee2f53e2d..7ddd98b1675f 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/Renderer9.cpp @@ -13,30 +13,29 @@ #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/renderer/d3d/IndexDataManager.h" -#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/IndexDataManager.h" +#include "libGLESv2/renderer/d3d9/Renderer9.h" +#include "libGLESv2/renderer/d3d9/renderer9_utils.h" +#include "libGLESv2/renderer/d3d9/formatutils9.h" +#include "libGLESv2/renderer/d3d9/ShaderExecutable9.h" +#include "libGLESv2/renderer/d3d9/SwapChain9.h" +#include "libGLESv2/renderer/d3d9/TextureStorage9.h" +#include "libGLESv2/renderer/d3d9/Image9.h" +#include "libGLESv2/renderer/d3d9/Blit9.h" +#include "libGLESv2/renderer/d3d9/RenderTarget9.h" +#include "libGLESv2/renderer/d3d9/VertexBuffer9.h" +#include "libGLESv2/renderer/d3d9/IndexBuffer9.h" +#include "libGLESv2/renderer/d3d9/BufferStorage9.h" +#include "libGLESv2/renderer/d3d9/Query9.h" +#include "libGLESv2/renderer/d3d9/Fence9.h" #include "libGLESv2/angletypes.h" #include "libEGL/Display.h" #include "third_party/trace_event/trace_event.h" +#include "third_party/systeminfo/SystemInfo.h" // Can also be enabled by defining FORCE_REF_RAST in the project's predefined macros #define REF_RAST 0 @@ -147,10 +146,10 @@ Renderer9::~Renderer9() } } - release(); + deinitialize(); } -void Renderer9::release() +void Renderer9::deinitialize() { releaseDeviceResources(); @@ -265,6 +264,15 @@ EGLint Renderer9::initialize() mD3d9->GetAdapterIdentifier(mAdapter, 0, &mAdapterIdentifier); } + // ATI cards on XP have problems with non-power-of-two textures. + mSupportsNonPower2Textures = !(mDeviceCaps.TextureCaps & D3DPTEXTURECAPS_POW2) && + !(mDeviceCaps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP_POW2) && + !(mDeviceCaps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) && + !(!isWindowsVistaOrGreater() && mAdapterIdentifier.VendorId == VENDOR_ID_AMD); + + // Must support a minimum of 2:1 anisotropy for max anisotropy to be considered supported, per the spec + mSupportsTextureFilterAnisotropy = ((mDeviceCaps.RasterCaps & D3DPRASTERCAPS_ANISOTROPY) && (mDeviceCaps.MaxAnisotropy >= 2)); + mMinSwapInterval = 4; mMaxSwapInterval = 0; @@ -350,6 +358,36 @@ EGLint Renderer9::initialize() mPixelShaderCache.initialize(mDevice); } + // Check occlusion query support + IDirect3DQuery9 *occlusionQuery = NULL; + { + TRACE_EVENT0("gpu", "device_CreateQuery"); + if (SUCCEEDED(mDevice->CreateQuery(D3DQUERYTYPE_OCCLUSION, &occlusionQuery)) && occlusionQuery) + { + SafeRelease(occlusionQuery); + mOcclusionQuerySupport = true; + } + else + { + mOcclusionQuerySupport = false; + } + } + + // Check event query support + IDirect3DQuery9 *eventQuery = NULL; + { + TRACE_EVENT0("gpu", "device_CreateQuery2"); + if (SUCCEEDED(mDevice->CreateQuery(D3DQUERYTYPE_EVENT, &eventQuery)) && eventQuery) + { + SafeRelease(eventQuery); + mEventQuerySupport = true; + } + else + { + mEventQuerySupport = false; + } + } + D3DDISPLAYMODE currentDisplayMode; mD3d9->GetAdapterDisplayMode(mAdapter, ¤tDisplayMode); @@ -360,6 +398,93 @@ EGLint Renderer9::initialize() SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_VERTEXTEXTURE, D3DRTYPE_TEXTURE, D3DFMT_R16F)); + // Check RGB565 texture support + mRGB565TextureSupport = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, + D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, D3DFMT_R5G6B5)); + + // Check depth texture support + // we use INTZ for depth textures in Direct3D9 + // we also want NULL texture support to ensure the we can make depth-only FBOs + // see http://aras-p.info/texts/D3D9GPUHacks.html + mDepthTextureSupport = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, + D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_INTZ)) && + SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, + D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, D3DFMT_NULL)); + + // Check 32 bit floating point texture support + mFloat32FilterSupport = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_FILTER, + D3DRTYPE_TEXTURE, D3DFMT_A32B32G32R32F)) && + SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_FILTER, + D3DRTYPE_CUBETEXTURE, D3DFMT_A32B32G32R32F)); + + mFloat32RenderSupport = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, + D3DRTYPE_TEXTURE, D3DFMT_A32B32G32R32F)) && + SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, + D3DRTYPE_CUBETEXTURE, D3DFMT_A32B32G32R32F)); + + if (!mFloat32FilterSupport && !mFloat32RenderSupport) + { + mFloat32TextureSupport = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, + D3DRTYPE_TEXTURE, D3DFMT_A32B32G32R32F)) && + SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, + D3DRTYPE_CUBETEXTURE, D3DFMT_A32B32G32R32F)); + } + else + { + mFloat32TextureSupport = true; + } + + // Check 16 bit floating point texture support + mFloat16FilterSupport = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_FILTER, + D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16F)) && + SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_FILTER, + D3DRTYPE_CUBETEXTURE, D3DFMT_A16B16G16R16F)); + + mFloat16RenderSupport = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, + D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16F)) && + SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, + D3DRTYPE_CUBETEXTURE, D3DFMT_A16B16G16R16F)); + + if (!mFloat16FilterSupport && !mFloat16RenderSupport) + { + mFloat16TextureSupport = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, + D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16F)) && + SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, + D3DRTYPE_CUBETEXTURE, D3DFMT_A16B16G16R16F)); + } + else + { + mFloat16TextureSupport = true; + } + + D3DFORMAT rgTextureFormats[] = + { + D3DFMT_R16F, + D3DFMT_G16R16F, + D3DFMT_R32F, + D3DFMT_G32R32F, + }; + + mRGTextureSupport = true; + for (unsigned int i = 0; i < ArraySize(rgTextureFormats); i++) + { + D3DFORMAT fmt = rgTextureFormats[i]; + mRGTextureSupport = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, fmt)) && + SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, fmt)) && + SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_FILTER, D3DRTYPE_CUBETEXTURE, fmt)) && + SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_CUBETEXTURE, fmt)); + } + + + // Check DXT texture support + mDXT1TextureSupport = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT1)); + mDXT3TextureSupport = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT3)); + mDXT5TextureSupport = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT5)); + + // Check luminance[alpha] texture support + mLuminanceTextureSupport = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_L8)); + mLuminanceAlphaTextureSupport = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_A8L8)); + initializeDevice(); d3d9::InitializeVertexTranslations(this); @@ -608,14 +733,9 @@ IndexBuffer *Renderer9::createIndexBuffer() return new IndexBuffer9(this); } -BufferImpl *Renderer9::createBuffer() +BufferStorage *Renderer9::createBufferStorage() { - return new Buffer9(this); -} - -VertexArrayImpl *Renderer9::createVertexArray() -{ - return new VertexArray9(this); + return new BufferStorage9(); } QueryImpl *Renderer9::createQuery(GLenum type) @@ -667,7 +787,7 @@ void Renderer9::setSamplerState(gl::SamplerType type, int index, const gl::Sampl mDevice->SetSamplerState(d3dSampler, D3DSAMP_MINFILTER, d3dMinFilter); mDevice->SetSamplerState(d3dSampler, D3DSAMP_MIPFILTER, d3dMipFilter); mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAXMIPLEVEL, samplerState.baseLevel); - if (getCaps().extensions.textureFilterAnisotropic) + if (mSupportsTextureFilterAnisotropy) { mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAXANISOTROPY, (DWORD)samplerState.maxAnisotropy); } @@ -810,8 +930,9 @@ void Renderer9::setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState FIXME("Sample alpha to coverage is unimplemented."); } - gl::FramebufferAttachment *attachment = framebuffer->getFirstColorbuffer(); - GLenum internalFormat = attachment ? attachment->getInternalFormat() : GL_NONE; + gl::Renderbuffer *renderBuffer = framebuffer->getFirstColorbuffer(); + GLenum internalFormat = renderBuffer ? renderBuffer->getInternalFormat() : GL_NONE; + GLuint clientVersion = getCurrentClientVersion(); // Set the color mask bool zeroColorMaskAllowed = getAdapterVendor() != VENDOR_ID_AMD; @@ -821,10 +942,10 @@ void Renderer9::setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState // drawing is done. // http://code.google.com/p/angleproject/issues/detail?id=169 - DWORD colorMask = gl_d3d9::ConvertColorMask(gl::GetRedBits(internalFormat) > 0 && blendState.colorMaskRed, - gl::GetGreenBits(internalFormat) > 0 && blendState.colorMaskGreen, - gl::GetBlueBits(internalFormat) > 0 && blendState.colorMaskBlue, - gl::GetAlphaBits(internalFormat) > 0 && blendState.colorMaskAlpha); + DWORD colorMask = gl_d3d9::ConvertColorMask(gl::GetRedBits(internalFormat, clientVersion) > 0 && blendState.colorMaskRed, + gl::GetGreenBits(internalFormat, clientVersion) > 0 && blendState.colorMaskGreen, + gl::GetBlueBits(internalFormat, clientVersion) > 0 && blendState.colorMaskBlue, + gl::GetAlphaBits(internalFormat, clientVersion) > 0 && blendState.colorMaskAlpha); if (colorMask == 0 && !zeroColorMaskAllowed) { // Enable green channel, but set blending so nothing will be drawn. @@ -893,10 +1014,13 @@ void Renderer9::setDepthStencilState(const gl::DepthStencilState &depthStencilSt 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); + if (depthStencilState.stencilWritemask != depthStencilState.stencilBackWritemask || + stencilRef != stencilBackRef || + depthStencilState.stencilMask != depthStencilState.stencilBackMask) + { + ERR("Separate front/back stencil writemasks, reference values, or stencil mask values are invalid under WebGL."); + return gl::error(GL_INVALID_OPERATION); + } // get the maximum size of the stencil ref unsigned int maxStencil = (1 << mCurStencilSize) - 1; @@ -1094,15 +1218,14 @@ bool Renderer9::applyPrimitiveType(GLenum mode, GLsizei count) mPrimitiveCount = count - 2; break; default: - UNREACHABLE(); - return false; + return gl::error(GL_INVALID_ENUM, false); } return mPrimitiveCount > 0; } -gl::FramebufferAttachment *Renderer9::getNullColorbuffer(gl::FramebufferAttachment *depthbuffer) +gl::Renderbuffer *Renderer9::getNullColorbuffer(gl::Renderbuffer *depthbuffer) { if (!depthbuffer) { @@ -1125,8 +1248,7 @@ gl::FramebufferAttachment *Renderer9::getNullColorbuffer(gl::FramebufferAttachme } } - gl::Renderbuffer *nullRenderbuffer = new gl::Renderbuffer(0, new gl::Colorbuffer(this, width, height, GL_NONE, 0)); - gl::RenderbufferAttachment *nullbuffer = new gl::RenderbufferAttachment(nullRenderbuffer); + gl::Renderbuffer *nullbuffer = new gl::Renderbuffer(this, 0, new gl::Colorbuffer(this, width, height, GL_NONE, 0)); // add nullbuffer to the cache NullColorbufferCacheEntry *oldest = &mNullColorbufferCache[0]; @@ -1151,7 +1273,7 @@ bool Renderer9::applyRenderTarget(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 *renderbufferObject = NULL; + gl::Renderbuffer *renderbufferObject = NULL; if (framebuffer->getColorbufferType(0) != GL_NONE) { renderbufferObject = framebuffer->getColorbuffer(0); @@ -1192,7 +1314,7 @@ bool Renderer9::applyRenderTarget(gl::Framebuffer *framebuffer) renderTargetChanged = true; } - gl::FramebufferAttachment *depthStencil = NULL; + gl::Renderbuffer *depthStencil = NULL; unsigned int depthbufferSerial = 0; unsigned int stencilbufferSerial = 0; if (framebuffer->getDepthbufferType() != GL_NONE) @@ -1394,14 +1516,14 @@ void Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, if (type != GL_NONE && elementArrayBuffer) { gl::Buffer *indexBuffer = elementArrayBuffer; - BufferImpl *storage = indexBuffer->getImplementation(); + BufferStorage *storage = indexBuffer->getStorage(); intptr_t offset = reinterpret_cast(indices); indices = static_cast(storage->getData()) + offset; } unsigned int startIndex = 0; - if (getCaps().extensions.elementIndexUint) + if (get32BitIndexSupport()) { if (!mLineLoopIB) { @@ -1592,7 +1714,7 @@ void Renderer9::drawIndexedPoints(GLsizei count, GLenum type, const GLvoid *indi if (elementArrayBuffer) { - BufferImpl *storage = elementArrayBuffer->getImplementation(); + BufferStorage *storage = elementArrayBuffer->getStorage(); intptr_t offset = reinterpret_cast(indices); indices = static_cast(storage->getData()) + offset; } @@ -1606,14 +1728,13 @@ void Renderer9::drawIndexedPoints(GLsizei count, GLenum type, const GLvoid *indi } } -void Renderer9::applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer, - bool rasterizerDiscard, bool transformFeedbackActive) +void Renderer9::applyShaders(gl::ProgramBinary *programBinary, bool rasterizerDiscard, bool transformFeedbackActive, const gl::VertexFormat inputLayout[]) { ASSERT(!transformFeedbackActive); ASSERT(!rasterizerDiscard); ShaderExecutable *vertexExe = programBinary->getVertexExecutableForInputLayout(inputLayout); - ShaderExecutable *pixelExe = programBinary->getPixelExecutableForFramebuffer(framebuffer); + ShaderExecutable *pixelExe = programBinary->getPixelExecutable(); IDirect3DVertexShader9 *vertexShader = (vertexExe ? ShaderExecutable9::makeShaderExecutable9(vertexExe)->getVertexShader() : NULL); IDirect3DPixelShader9 *pixelShader = (pixelExe ? ShaderExecutable9::makeShaderExecutable9(pixelExe)->getPixelShader() : NULL); @@ -1769,7 +1890,8 @@ void Renderer9::clear(const gl::ClearParameters &clearParams, gl::Framebuffer *f unsigned int stencilUnmasked = 0x0; if (clearParams.clearStencil && frameBuffer->hasStencil()) { - unsigned int stencilSize = gl::GetStencilBits(frameBuffer->getStencilbuffer()->getActualFormat()); + unsigned int stencilSize = gl::GetStencilBits(frameBuffer->getStencilbuffer()->getActualFormat(), + getCurrentClientVersion()); stencilUnmasked = (0x1 << stencilSize) - 1; } @@ -1780,19 +1902,20 @@ void Renderer9::clear(const gl::ClearParameters &clearParams, gl::Framebuffer *f D3DCOLOR color = D3DCOLOR_ARGB(255, 0, 0, 0); if (clearColor) { - gl::FramebufferAttachment *attachment = frameBuffer->getFirstColorbuffer(); - GLenum internalFormat = attachment->getInternalFormat(); - GLenum actualFormat = attachment->getActualFormat(); + gl::Renderbuffer *renderbuffer = frameBuffer->getFirstColorbuffer(); + GLenum internalFormat = renderbuffer->getInternalFormat(); + GLenum actualFormat = renderbuffer->getActualFormat(); - GLuint internalRedBits = gl::GetRedBits(internalFormat); - GLuint internalGreenBits = gl::GetGreenBits(internalFormat); - GLuint internalBlueBits = gl::GetBlueBits(internalFormat); - GLuint internalAlphaBits = gl::GetAlphaBits(internalFormat); + GLuint clientVersion = getCurrentClientVersion(); + GLuint internalRedBits = gl::GetRedBits(internalFormat, clientVersion); + GLuint internalGreenBits = gl::GetGreenBits(internalFormat, clientVersion); + GLuint internalBlueBits = gl::GetBlueBits(internalFormat, clientVersion); + GLuint internalAlphaBits = gl::GetAlphaBits(internalFormat, clientVersion); - GLuint actualRedBits = gl::GetRedBits(actualFormat); - GLuint actualGreenBits = gl::GetGreenBits(actualFormat); - GLuint actualBlueBits = gl::GetBlueBits(actualFormat); - GLuint actualAlphaBits = gl::GetAlphaBits(actualFormat); + GLuint actualRedBits = gl::GetRedBits(actualFormat, clientVersion); + GLuint actualGreenBits = gl::GetGreenBits(actualFormat, clientVersion); + GLuint actualBlueBits = gl::GetBlueBits(actualFormat, clientVersion); + GLuint actualAlphaBits = gl::GetAlphaBits(actualFormat, clientVersion); color = D3DCOLOR_ARGB(gl::unorm<8>((internalAlphaBits == 0 && actualAlphaBits > 0) ? 1.0f : clearParams.colorFClearValue.alpha), gl::unorm<8>((internalRedBits == 0 && actualRedBits > 0) ? 0.0f : clearParams.colorFClearValue.red), @@ -2195,7 +2318,7 @@ bool Renderer9::resetRemovedDevice() // 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(); + deinitialize(); return (initialize() == EGL_SUCCESS); } @@ -2255,6 +2378,107 @@ Renderer9::MultisampleSupportInfo Renderer9::getMultiSampleSupport(D3DFORMAT for return support; } +bool Renderer9::getBGRATextureSupport() const +{ + // DirectX 9 always supports BGRA + return true; +} + +bool Renderer9::getDXT1TextureSupport() const +{ + return mDXT1TextureSupport; +} + +bool Renderer9::getDXT3TextureSupport() const +{ + return mDXT3TextureSupport; +} + +bool Renderer9::getDXT5TextureSupport() const +{ + return mDXT5TextureSupport; +} + +bool Renderer9::getDepthTextureSupport() const +{ + return mDepthTextureSupport; +} + +bool Renderer9::getFloat32TextureSupport() const +{ + return mFloat32TextureSupport; +} + +bool Renderer9::getFloat32TextureFilteringSupport() const +{ + return mFloat32FilterSupport; +} + +bool Renderer9::getFloat32TextureRenderingSupport() const +{ + return mFloat32RenderSupport; +} + +bool Renderer9::getFloat16TextureSupport() const +{ + return mFloat16TextureSupport; +} + +bool Renderer9::getFloat16TextureFilteringSupport() const +{ + return mFloat16FilterSupport; +} + +bool Renderer9::getFloat16TextureRenderingSupport() const +{ + return mFloat16RenderSupport; +} + +bool Renderer9::getRGB565TextureSupport() const +{ + return mRGB565TextureSupport; +} + +bool Renderer9::getLuminanceTextureSupport() const +{ + return mLuminanceTextureSupport; +} + +bool Renderer9::getLuminanceAlphaTextureSupport() const +{ + return mLuminanceAlphaTextureSupport; +} + +bool Renderer9::getRGTextureSupport() const +{ + return mRGTextureSupport; +} + +bool Renderer9::getTextureFilterAnisotropySupport() const +{ + return mSupportsTextureFilterAnisotropy; +} + +bool Renderer9::getPBOSupport() const +{ + // D3D9 cannot support PBOs + return false; +} + +float Renderer9::getTextureMaxAnisotropy() const +{ + if (mSupportsTextureFilterAnisotropy) + { + return static_cast(mDeviceCaps.MaxAnisotropy); + } + return 1.0f; +} + +bool Renderer9::getEventQuerySupport() const +{ + return mEventQuerySupport; +} + unsigned int Renderer9::getMaxVertexTextureImageUnits() const { META_ASSERT(MAX_TEXTURE_IMAGE_UNITS_VTF_SM3 <= gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS); @@ -2333,12 +2557,32 @@ unsigned int Renderer9::getMaxUniformBufferSize() const return 0; } +bool Renderer9::getNonPower2TextureSupport() const +{ + return mSupportsNonPower2Textures; +} + +bool Renderer9::getOcclusionQuerySupport() const +{ + return mOcclusionQuerySupport; +} + +bool Renderer9::getInstancingSupport() const +{ + return mDeviceCaps.PixelShaderVersion >= D3DPS_VERSION(3, 0); +} + bool Renderer9::getShareHandleSupport() const { // PIX doesn't seem to support using share handles, so disable them. return (mD3d9Ex != NULL) && !gl::perfActive(); } +bool Renderer9::getDerivativeInstructionSupport() const +{ + return (mDeviceCaps.PS20Caps.Caps & D3DPS20CAPS_GRADIENTINSTRUCTIONS) != 0; +} + bool Renderer9::getPostSubBufferSupport() const { return true; @@ -2358,11 +2602,6 @@ int Renderer9::getMaxRecommendedElementsVertices() const return 0; } -bool Renderer9::getSRGBTextureSupport() const -{ - return false; -} - int Renderer9::getMajorShaderModel() const { return D3DSHADER_VERSION_MAJOR(mDeviceCaps.PixelShaderVersion); @@ -2403,6 +2642,11 @@ int Renderer9::getMaxTextureArrayLayers() const return 1; } +bool Renderer9::get32BitIndexSupport() const +{ + return mDeviceCaps.MaxVertexIndex >= (1 << 16); +} + DWORD Renderer9::getCapsDeclTypes() const { return mDeviceCaps.DeclTypes; @@ -2425,14 +2669,14 @@ int Renderer9::getMaxSupportedSamples() const GLsizei Renderer9::getMaxSupportedFormatSamples(GLenum internalFormat) const { - D3DFORMAT format = gl_d3d9::GetTextureFormat(internalFormat); + D3DFORMAT format = gl_d3d9::GetTextureFormat(internalFormat, this); MultisampleSupportMap::const_iterator itr = mMultiSampleSupport.find(format); return (itr != mMultiSampleSupport.end()) ? mMaxSupportedSamples : 0; } GLsizei Renderer9::getNumSampleCounts(GLenum internalFormat) const { - D3DFORMAT format = gl_d3d9::GetTextureFormat(internalFormat); + D3DFORMAT format = gl_d3d9::GetTextureFormat(internalFormat, this); MultisampleSupportMap::const_iterator iter = mMultiSampleSupport.find(format); unsigned int numCounts = 0; @@ -2453,7 +2697,7 @@ GLsizei Renderer9::getNumSampleCounts(GLenum internalFormat) const void Renderer9::getSampleCounts(GLenum internalFormat, GLsizei bufSize, GLint *params) const { - D3DFORMAT format = gl_d3d9::GetTextureFormat(internalFormat); + D3DFORMAT format = gl_d3d9::GetTextureFormat(internalFormat, this); MultisampleSupportMap::const_iterator iter = mMultiSampleSupport.find(format); if (iter != mMultiSampleSupport.end()) @@ -2502,6 +2746,53 @@ unsigned int Renderer9::getMaxRenderTargets() const return 1; } +D3DFORMAT Renderer9::ConvertTextureInternalFormat(GLenum internalformat) +{ + switch (internalformat) + { + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT32_OES: + case GL_DEPTH24_STENCIL8_OES: + return D3DFMT_INTZ; + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + return D3DFMT_DXT1; + case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: + return D3DFMT_DXT3; + case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: + return D3DFMT_DXT5; + case GL_RGBA32F_EXT: + case GL_RGB32F_EXT: + case GL_ALPHA32F_EXT: + case GL_LUMINANCE32F_EXT: + case GL_LUMINANCE_ALPHA32F_EXT: + return D3DFMT_A32B32G32R32F; + case GL_RGBA16F_EXT: + case GL_RGB16F_EXT: + case GL_ALPHA16F_EXT: + case GL_LUMINANCE16F_EXT: + case GL_LUMINANCE_ALPHA16F_EXT: + return D3DFMT_A16B16G16R16F; + case GL_LUMINANCE8_EXT: + if (getLuminanceTextureSupport()) + { + return D3DFMT_L8; + } + break; + case GL_LUMINANCE8_ALPHA8_EXT: + if (getLuminanceAlphaTextureSupport()) + { + return D3DFMT_A8L8; + } + break; + case GL_RGB8_OES: + case GL_RGB565: + return D3DFMT_X8R8G8B8; + } + + return D3DFMT_A8R8G8B8; +} + bool Renderer9::copyToRenderTarget(TextureStorageInterface2D *dest, TextureStorageInterface2D *source) { bool result = false; @@ -2644,8 +2935,8 @@ bool Renderer9::blitRect(gl::Framebuffer *readFramebuffer, const gl::Rectangle & if (blitRenderTarget) { - gl::FramebufferAttachment *readBuffer = readFramebuffer->getColorbuffer(0); - gl::FramebufferAttachment *drawBuffer = drawFramebuffer->getColorbuffer(0); + gl::Renderbuffer *readBuffer = readFramebuffer->getColorbuffer(0); + gl::Renderbuffer *drawBuffer = drawFramebuffer->getColorbuffer(0); RenderTarget9 *readRenderTarget = NULL; RenderTarget9 *drawRenderTarget = NULL; IDirect3DSurface9* readSurface = NULL; @@ -2773,8 +3064,8 @@ bool Renderer9::blitRect(gl::Framebuffer *readFramebuffer, const gl::Rectangle & if (blitDepth || blitStencil) { - gl::FramebufferAttachment *readBuffer = readFramebuffer->getDepthOrStencilbuffer(); - gl::FramebufferAttachment *drawBuffer = drawFramebuffer->getDepthOrStencilbuffer(); + gl::Renderbuffer *readBuffer = readFramebuffer->getDepthOrStencilbuffer(); + gl::Renderbuffer *drawBuffer = drawFramebuffer->getDepthOrStencilbuffer(); RenderTarget9 *readDepthStencil = NULL; RenderTarget9 *drawDepthStencil = NULL; IDirect3DSurface9* readSurface = NULL; @@ -2826,7 +3117,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz RenderTarget9 *renderTarget = NULL; IDirect3DSurface9 *surface = NULL; - gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(0); + gl::Renderbuffer *colorbuffer = framebuffer->getColorbuffer(0); if (colorbuffer) { @@ -2941,11 +3232,13 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz inputPitch = lock.Pitch; } - GLenum sourceInternalFormat = d3d9_gl::GetInternalFormat(desc.Format); - GLenum sourceFormat = gl::GetFormat(sourceInternalFormat); - GLenum sourceType = gl::GetType(sourceInternalFormat); + GLuint clientVersion = getCurrentClientVersion(); - GLuint sourcePixelSize = gl::GetPixelBytes(sourceInternalFormat); + GLenum sourceInternalFormat = d3d9_gl::GetInternalFormat(desc.Format); + GLenum sourceFormat = gl::GetFormat(sourceInternalFormat, clientVersion); + GLenum sourceType = gl::GetType(sourceInternalFormat, clientVersion); + + GLuint sourcePixelSize = gl::GetPixelBytes(sourceInternalFormat, clientVersion); if (sourceFormat == format && sourceType == type) { @@ -2958,11 +3251,11 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz } else { - GLenum destInternalFormat = gl::GetSizedInternalFormat(format, type); - GLuint destPixelSize = gl::GetPixelBytes(destInternalFormat); - GLuint sourcePixelSize = gl::GetPixelBytes(sourceInternalFormat); + GLenum destInternalFormat = gl::GetSizedInternalFormat(format, type, clientVersion); + GLuint destPixelSize = gl::GetPixelBytes(destInternalFormat, clientVersion); + GLuint sourcePixelSize = gl::GetPixelBytes(sourceInternalFormat, clientVersion); - ColorCopyFunction fastCopyFunc = d3d9::GetFastCopyFunction(desc.Format, format, type); + ColorCopyFunction fastCopyFunc = d3d9::GetFastCopyFunction(desc.Format, format, type, getCurrentClientVersion()); if (fastCopyFunc) { // Fast copy is possible through some special function @@ -2980,7 +3273,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz else { ColorReadFunction readFunc = d3d9::GetColorReadFunction(desc.Format); - ColorWriteFunction writeFunc = gl::GetColorWriteFunction(format, type); + ColorWriteFunction writeFunc = gl::GetColorWriteFunction(format, type, clientVersion); gl::ColorF temp; @@ -3261,7 +3554,7 @@ bool Renderer9::getLUID(LUID *adapterLuid) const GLenum Renderer9::getNativeTextureFormat(GLenum internalFormat) const { - return d3d9_gl::GetInternalFormat(gl_d3d9::GetTextureFormat(internalFormat)); + return d3d9_gl::GetInternalFormat(gl_d3d9::GetTextureFormat(internalFormat, this)); } rx::VertexConversionType Renderer9::getVertexConversionType(const gl::VertexFormat &vertexFormat) const @@ -3275,9 +3568,4 @@ GLenum Renderer9::getVertexComponentType(const gl::VertexFormat &vertexFormat) c return d3d9::GetDeclTypeComponentType(declType); } -gl::Caps Renderer9::generateCaps() const -{ - return d3d9_gl::GenerateCaps(mD3d9, mDevice, mDeviceType, mAdapter); -} - } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Renderer9.h b/gfx/angle/src/libGLESv2/renderer/d3d9/Renderer9.h similarity index 87% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Renderer9.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/Renderer9.h index c7b001803af6..8f723e3c6c99 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/Renderer9.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/Renderer9.h @@ -12,14 +12,14 @@ #include "common/angleutils.h" #include "common/mathutil.h" #include "libGLESv2/renderer/d3d/HLSLCompiler.h" -#include "libGLESv2/renderer/d3d/d3d9/ShaderCache.h" -#include "libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.h" +#include "libGLESv2/renderer/d3d9/ShaderCache.h" +#include "libGLESv2/renderer/d3d9/VertexDeclarationCache.h" #include "libGLESv2/renderer/Renderer.h" #include "libGLESv2/renderer/RenderTarget.h" namespace gl { -class FramebufferAttachment; +class Renderbuffer; } namespace rx @@ -76,8 +76,7 @@ class Renderer9 : public Renderer bool ignoreViewport); virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer); - virtual void applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer, - bool rasterizerDiscard, bool transformFeedbackActive); + virtual void applyShaders(gl::ProgramBinary *programBinary, bool rasterizerDiscard, bool transformFeedbackActive, const gl::VertexFormat inputLayout[]); virtual void applyUniforms(const gl::ProgramBinary &programBinary); virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount); virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], gl::VertexAttribCurrentValueData currentValues[], @@ -100,11 +99,27 @@ class Renderer9 : public Renderer virtual bool testDeviceLost(bool notify); virtual bool testDeviceResettable(); + // Renderer capabilities IDirect3DDevice9 *getDevice() { return mDevice; } virtual DWORD getAdapterVendor() const; virtual std::string getRendererDescription() const; virtual GUID getAdapterIdentifier() const; + virtual bool getBGRATextureSupport() const; + virtual bool getDXT1TextureSupport() const; + virtual bool getDXT3TextureSupport() const; + virtual bool getDXT5TextureSupport() const; + virtual bool getEventQuerySupport() const; + virtual bool getFloat32TextureSupport() const; + virtual bool getFloat32TextureFilteringSupport() const; + virtual bool getFloat32TextureRenderingSupport() const; + virtual bool getFloat16TextureSupport() const; + virtual bool getFloat16TextureFilteringSupport() const; + virtual bool getFloat16TextureRenderingSupport() const; + virtual bool getRGB565TextureSupport() const; + virtual bool getLuminanceTextureSupport() const; + virtual bool getLuminanceAlphaTextureSupport() const; + virtual bool getRGTextureSupport() const; virtual unsigned int getMaxVertexTextureImageUnits() const; virtual unsigned int getMaxCombinedTextureImageUnits() const; virtual unsigned int getReservedVertexUniformVectors() const; @@ -120,11 +135,18 @@ class Renderer9 : public Renderer virtual unsigned int getMaxTransformFeedbackSeparateComponents() const; virtual unsigned int getMaxTransformFeedbackInterleavedComponents() const; virtual unsigned int getMaxUniformBufferSize() const; + virtual bool getNonPower2TextureSupport() const; + virtual bool getDepthTextureSupport() const; + virtual bool getOcclusionQuerySupport() const; + virtual bool getInstancingSupport() const; + virtual bool getTextureFilterAnisotropySupport() const; + virtual bool getPBOSupport() const; + virtual float getTextureMaxAnisotropy() const; virtual bool getShareHandleSupport() const; + virtual bool getDerivativeInstructionSupport() const; virtual bool getPostSubBufferSupport() const; virtual int getMaxRecommendedElementsIndices() const; virtual int getMaxRecommendedElementsVertices() const; - virtual bool getSRGBTextureSupport() const; virtual int getMajorShaderModel() const; virtual float getMaxPointSize() const; @@ -133,6 +155,7 @@ class Renderer9 : public Renderer virtual int getMaxTextureHeight() const; virtual int getMaxTextureDepth() const; virtual int getMaxTextureArrayLayers() const; + virtual bool get32BitIndexSupport() const; DWORD getCapsDeclTypes() const; virtual int getMinSwapInterval() const; virtual int getMaxSwapInterval() const; @@ -142,9 +165,11 @@ class Renderer9 : public Renderer virtual GLsizei getNumSampleCounts(GLenum internalFormat) const; virtual void getSampleCounts(GLenum internalFormat, GLsizei bufSize, GLint *params) const; int getNearestSupportedSamples(D3DFORMAT format, int requested) const; - + virtual unsigned int getMaxRenderTargets() const; + D3DFORMAT ConvertTextureInternalFormat(GLenum internalformat); + // Pixel operations virtual bool copyToRenderTarget(TextureStorageInterface2D *dest, TextureStorageInterface2D *source); virtual bool copyToRenderTarget(TextureStorageInterfaceCube *dest, TextureStorageInterfaceCube *source); @@ -188,12 +213,9 @@ class Renderer9 : public Renderer virtual TextureStorage *createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels); // Buffer creation - virtual BufferImpl *createBuffer(); virtual VertexBuffer *createVertexBuffer(); virtual IndexBuffer *createIndexBuffer(); - - // Vertex Array creation - virtual VertexArrayImpl *createVertexArray(); + virtual BufferStorage *createBufferStorage(); // Query and Fence creation virtual QueryImpl *createQuery(GLenum type); @@ -217,9 +239,7 @@ class Renderer9 : public Renderer private: DISALLOW_COPY_AND_ASSIGN(Renderer9); - virtual gl::Caps generateCaps() const; - - void release(); + void deinitialize(); void applyUniformnfv(gl::LinkedUniform *targetUniform, const GLfloat *v); void applyUniformniv(gl::LinkedUniform *targetUniform, const GLint *v); @@ -229,7 +249,7 @@ class Renderer9 : public Renderer void drawIndexedPoints(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer); bool copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *source, bool fromManaged); - gl::FramebufferAttachment *getNullColorbuffer(gl::FramebufferAttachment *depthbuffer); + gl::Renderbuffer *getNullColorbuffer(gl::Renderbuffer *depthbuffer); D3DPOOL getBufferPool(DWORD usage) const; @@ -266,11 +286,36 @@ class Renderer9 : public Renderer GLsizei mRepeatDraw; bool mSceneStarted; + bool mSupportsNonPower2Textures; + bool mSupportsTextureFilterAnisotropy; int mMinSwapInterval; int mMaxSwapInterval; + bool mOcclusionQuerySupport; + bool mEventQuerySupport; bool mVertexTextureSupport; + bool mDepthTextureSupport; + + bool mRGB565TextureSupport; + + bool mFloat32TextureSupport; + bool mFloat32FilterSupport; + bool mFloat32RenderSupport; + + bool mFloat16TextureSupport; + bool mFloat16FilterSupport; + bool mFloat16RenderSupport; + + bool mDXT1TextureSupport; + bool mDXT3TextureSupport; + bool mDXT5TextureSupport; + + bool mLuminanceTextureSupport; + bool mLuminanceAlphaTextureSupport; + + bool mRGTextureSupport; + struct MultisampleSupportInfo { bool supportedSamples[D3DMULTISAMPLE_16_SAMPLES + 1]; @@ -356,7 +401,7 @@ class Renderer9 : public Renderer UINT lruCount; int width; int height; - gl::FramebufferAttachment *buffer; + gl::Renderbuffer *buffer; } mNullColorbufferCache[NUM_NULL_COLORBUFFER_CACHE_ENTRIES]; UINT mMaxNullColorbufferLRU; diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderCache.h b/gfx/angle/src/libGLESv2/renderer/d3d9/ShaderCache.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderCache.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/ShaderCache.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderExecutable9.cpp b/gfx/angle/src/libGLESv2/renderer/d3d9/ShaderExecutable9.cpp similarity index 95% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderExecutable9.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d9/ShaderExecutable9.cpp index c10ddbf6ce4c..115ed0823c7f 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderExecutable9.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/ShaderExecutable9.cpp @@ -8,7 +8,7 @@ // ShaderExecutable9.cpp: Implements a D3D9-specific class to contain shader // executable implementation details. -#include "libGLESv2/renderer/d3d/d3d9/ShaderExecutable9.h" +#include "libGLESv2/renderer/d3d9/ShaderExecutable9.h" #include "common/debug.h" diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderExecutable9.h b/gfx/angle/src/libGLESv2/renderer/d3d9/ShaderExecutable9.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/ShaderExecutable9.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/ShaderExecutable9.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.cpp b/gfx/angle/src/libGLESv2/renderer/d3d9/SwapChain9.cpp similarity index 96% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d9/SwapChain9.cpp index aef80a731833..bfb34594c52a 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/SwapChain9.cpp @@ -1,16 +1,16 @@ #include "precompiled.h" // -// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved. +// 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. // // 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 "libGLESv2/renderer/d3d9/SwapChain9.h" +#include "libGLESv2/renderer/d3d9/renderer9_utils.h" +#include "libGLESv2/renderer/d3d9/formatutils9.h" +#include "libGLESv2/renderer/d3d9/Renderer9.h" namespace rx { @@ -50,7 +50,7 @@ void SwapChain9::release() static DWORD convertInterval(EGLint interval) { -#ifdef ANGLE_FORCE_VSYNC_OFF +#if ANGLE_FORCE_VSYNC_OFF return D3DPRESENT_INTERVAL_IMMEDIATE; #else switch(interval) @@ -102,7 +102,7 @@ EGLint SwapChain9::reset(int backbufferWidth, int backbufferHeight, EGLint swapI } result = device->CreateTexture(backbufferWidth, backbufferHeight, 1, D3DUSAGE_RENDERTARGET, - gl_d3d9::GetTextureFormat(mBackBufferFormat), + gl_d3d9::GetTextureFormat(mBackBufferFormat, mRenderer), D3DPOOL_DEFAULT, &mOffscreenTexture, pShareHandle); if (FAILED(result)) { @@ -153,9 +153,9 @@ EGLint SwapChain9::reset(int backbufferWidth, int backbufferHeight, EGLint swapI if (mWindow) { D3DPRESENT_PARAMETERS presentParameters = {0}; - presentParameters.AutoDepthStencilFormat = gl_d3d9::GetRenderFormat(mDepthBufferFormat); + presentParameters.AutoDepthStencilFormat = gl_d3d9::GetRenderFormat(mDepthBufferFormat, mRenderer); presentParameters.BackBufferCount = 1; - presentParameters.BackBufferFormat = gl_d3d9::GetRenderFormat(mBackBufferFormat); + presentParameters.BackBufferFormat = gl_d3d9::GetRenderFormat(mBackBufferFormat, mRenderer); presentParameters.EnableAutoDepthStencil = FALSE; presentParameters.Flags = 0; presentParameters.hDeviceWindow = mWindow; @@ -207,7 +207,7 @@ EGLint SwapChain9::reset(int backbufferWidth, int backbufferHeight, EGLint swapI if (mDepthBufferFormat != GL_NONE) { result = device->CreateDepthStencilSurface(backbufferWidth, backbufferHeight, - gl_d3d9::GetRenderFormat(mDepthBufferFormat), + gl_d3d9::GetRenderFormat(mDepthBufferFormat, mRenderer), D3DMULTISAMPLE_NONE, 0, FALSE, &mDepthStencil, NULL); if (FAILED(result)) diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.h b/gfx/angle/src/libGLESv2/renderer/d3d9/SwapChain9.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/SwapChain9.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.cpp b/gfx/angle/src/libGLESv2/renderer/d3d9/TextureStorage9.cpp similarity index 90% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d9/TextureStorage9.cpp index 0a44d7648617..a8efca7fb4ba 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/TextureStorage9.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" // -// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -10,12 +10,12 @@ // D3D9 texture. #include "libGLESv2/main.h" -#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h" -#include "libGLESv2/renderer/d3d/d3d9/TextureStorage9.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/d3d9/Renderer9.h" +#include "libGLESv2/renderer/d3d9/TextureStorage9.h" +#include "libGLESv2/renderer/d3d9/SwapChain9.h" +#include "libGLESv2/renderer/d3d9/RenderTarget9.h" +#include "libGLESv2/renderer/d3d9/renderer9_utils.h" +#include "libGLESv2/renderer/d3d9/formatutils9.h" #include "libGLESv2/Texture.h" namespace rx @@ -38,16 +38,18 @@ TextureStorage9 *TextureStorage9::makeTextureStorage9(TextureStorage *storage) return static_cast(storage); } -DWORD TextureStorage9::GetTextureUsage(GLenum internalformat, bool renderTarget) +DWORD TextureStorage9::GetTextureUsage(GLenum internalformat, Renderer9 *renderer, bool renderTarget) { + GLuint clientVersion = renderer->getCurrentClientVersion(); + DWORD d3dusage = 0; - if (gl::GetDepthBits(internalformat) > 0 || - gl::GetStencilBits(internalformat) > 0) + if (gl::GetDepthBits(internalformat, clientVersion) > 0 || + gl::GetStencilBits(internalformat, clientVersion) > 0) { d3dusage |= D3DUSAGE_DEPTHSTENCIL; } - else if (renderTarget && (gl_d3d9::GetRenderFormat(internalformat) != D3DFMT_UNKNOWN)) + else if (renderTarget && (gl_d3d9::GetRenderFormat(internalformat, renderer) != D3DFMT_UNKNOWN)) { d3dusage |= D3DUSAGE_RENDERTARGET; } @@ -97,7 +99,7 @@ TextureStorage9_2D::TextureStorage9_2D(Renderer *renderer, SwapChain9 *swapchain } TextureStorage9_2D::TextureStorage9_2D(Renderer *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels) - : TextureStorage9(renderer, GetTextureUsage(internalformat, renderTarget)) + : TextureStorage9(renderer, GetTextureUsage(internalformat, Renderer9::makeRenderer9(renderer), renderTarget)) { mTexture = NULL; mRenderTarget = NULL; @@ -106,7 +108,7 @@ TextureStorage9_2D::TextureStorage9_2D(Renderer *renderer, GLenum internalformat if (width > 0 && height > 0) { IDirect3DDevice9 *device = mRenderer->getDevice(); - D3DFORMAT format = gl_d3d9::GetTextureFormat(internalformat); + D3DFORMAT format = gl_d3d9::GetTextureFormat(internalformat, mRenderer); d3d9::MakeValidSize(false, format, &width, &height, &mTopLevel); UINT creationLevels = (levels == 0) ? 0 : mTopLevel + levels; @@ -193,7 +195,7 @@ void TextureStorage9_2D::initializeRenderTarget() } TextureStorage9_Cube::TextureStorage9_Cube(Renderer *renderer, GLenum internalformat, bool renderTarget, int size, int levels) - : TextureStorage9(renderer, GetTextureUsage(internalformat, renderTarget)) + : TextureStorage9(renderer, GetTextureUsage(internalformat, Renderer9::makeRenderer9(renderer), renderTarget)) { mTexture = NULL; for (int i = 0; i < 6; ++i) @@ -207,7 +209,7 @@ TextureStorage9_Cube::TextureStorage9_Cube(Renderer *renderer, GLenum internalfo { IDirect3DDevice9 *device = mRenderer->getDevice(); int height = size; - D3DFORMAT format = gl_d3d9::GetTextureFormat(internalformat); + D3DFORMAT format = gl_d3d9::GetTextureFormat(internalformat, mRenderer); d3d9::MakeValidSize(false, format, &size, &height, &mTopLevel); UINT creationLevels = (levels == 0) ? 0 : mTopLevel + levels; diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.h b/gfx/angle/src/libGLESv2/renderer/d3d9/TextureStorage9.h similarity index 97% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/TextureStorage9.h index 5a09f897949a..1f4975f48e5e 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/TextureStorage9.h @@ -28,7 +28,7 @@ class TextureStorage9 : public TextureStorage static TextureStorage9 *makeTextureStorage9(TextureStorage *storage); - static DWORD GetTextureUsage(GLenum internalformat, bool renderTarget); + static DWORD GetTextureUsage(GLenum internalformat, Renderer9 *renderer, bool renderTarget); D3DPOOL getPool() const; DWORD getUsage() const; diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/VertexBuffer9.cpp b/gfx/angle/src/libGLESv2/renderer/d3d9/VertexBuffer9.cpp similarity index 87% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/VertexBuffer9.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d9/VertexBuffer9.cpp index d260640dbe43..42ddfcae1cb9 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/VertexBuffer9.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/VertexBuffer9.cpp @@ -7,12 +7,12 @@ // VertexBuffer9.cpp: Defines the D3D9 VertexBuffer implementation. -#include "libGLESv2/renderer/d3d/d3d9/VertexBuffer9.h" +#include "libGLESv2/renderer/d3d9/VertexBuffer9.h" #include "libGLESv2/renderer/vertexconversion.h" -#include "libGLESv2/renderer/BufferImpl.h" +#include "libGLESv2/renderer/BufferStorage.h" #include "libGLESv2/VertexAttribute.h" -#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h" -#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h" +#include "libGLESv2/renderer/d3d9/Renderer9.h" +#include "libGLESv2/renderer/d3d9/formatutils9.h" #include "libGLESv2/Buffer.h" @@ -70,10 +70,10 @@ bool VertexBuffer9::storeVertexAttributes(const gl::VertexAttribute &attrib, con { if (mVertexBuffer) { - gl::Buffer *buffer = attrib.buffer.get(); + gl::Buffer *buffer = attrib.mBoundBuffer.get(); - int inputStride = gl::ComputeVertexAttributeStride(attrib); - int elementSize = gl::ComputeVertexAttributeTypeSize(attrib); + int inputStride = attrib.stride(); + int elementSize = attrib.typeSize(); DWORD lockFlags = mDynamicUsage ? D3DLOCK_NOOVERWRITE : 0; @@ -94,16 +94,16 @@ bool VertexBuffer9::storeVertexAttributes(const gl::VertexAttribute &attrib, con } const char *input = NULL; - if (attrib.enabled) + if (attrib.mArrayEnabled) { if (buffer) { - BufferImpl *storage = buffer->getImplementation(); - input = static_cast(storage->getData()) + static_cast(attrib.offset); + BufferStorage *storage = buffer->getStorage(); + input = static_cast(storage->getData()) + static_cast(attrib.mOffset); } else { - input = static_cast(attrib.pointer); + input = static_cast(attrib.mPointer); } } else @@ -111,7 +111,7 @@ bool VertexBuffer9::storeVertexAttributes(const gl::VertexAttribute &attrib, con input = reinterpret_cast(currentValue.FloatValues); } - if (instances == 0 || attrib.divisor == 0) + if (instances == 0 || attrib.mDivisor == 0) { input += inputStride * start; } @@ -205,23 +205,23 @@ bool VertexBuffer9::spaceRequired(const gl::VertexAttribute &attrib, std::size_t gl::VertexFormat vertexFormat(attrib, GL_FLOAT); unsigned int elementSize = d3d9::GetVertexElementSize(vertexFormat); - if (attrib.enabled) + if (attrib.mArrayEnabled) { unsigned int elementCount = 0; - if (instances == 0 || attrib.divisor == 0) + if (instances == 0 || attrib.mDivisor == 0) { elementCount = count; } else { - if (static_cast(instances) < std::numeric_limits::max() - (attrib.divisor - 1)) + if (static_cast(instances) < std::numeric_limits::max() - (attrib.mDivisor - 1)) { // Round up - elementCount = (static_cast(instances) + (attrib.divisor - 1)) / attrib.divisor; + elementCount = (static_cast(instances) + (attrib.mDivisor - 1)) / attrib.mDivisor; } else { - elementCount = static_cast(instances) / attrib.divisor; + elementCount = static_cast(instances) / attrib.mDivisor; } } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/VertexBuffer9.h b/gfx/angle/src/libGLESv2/renderer/d3d9/VertexBuffer9.h similarity index 97% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/VertexBuffer9.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/VertexBuffer9.h index fc4b6b6d2692..2fb5a36b37bf 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/VertexBuffer9.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/VertexBuffer9.h @@ -9,7 +9,7 @@ #ifndef LIBGLESV2_RENDERER_VERTEXBUFFER9_H_ #define LIBGLESV2_RENDERER_VERTEXBUFFER9_H_ -#include "libGLESv2/renderer/d3d/VertexBuffer.h" +#include "libGLESv2/renderer/VertexBuffer.h" namespace rx { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.cpp b/gfx/angle/src/libGLESv2/renderer/d3d9/VertexDeclarationCache.cpp similarity index 97% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d9/VertexDeclarationCache.cpp index 303d8ad299b6..30c023378a1c 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/VertexDeclarationCache.cpp @@ -9,9 +9,9 @@ #include "libGLESv2/ProgramBinary.h" #include "libGLESv2/VertexAttribute.h" -#include "libGLESv2/renderer/d3d/d3d9/VertexBuffer9.h" -#include "libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.h" -#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h" +#include "libGLESv2/renderer/d3d9/VertexBuffer9.h" +#include "libGLESv2/renderer/d3d9/VertexDeclarationCache.h" +#include "libGLESv2/renderer/d3d9/formatutils9.h" namespace rx { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.h b/gfx/angle/src/libGLESv2/renderer/d3d9/VertexDeclarationCache.h similarity index 96% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/VertexDeclarationCache.h index 004e28df4fb8..3fc024a9bab4 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/VertexDeclarationCache.h @@ -9,7 +9,7 @@ #ifndef LIBGLESV2_RENDERER_VERTEXDECLARATIONCACHE_H_ #define LIBGLESV2_RENDERER_VERTEXDECLARATIONCACHE_H_ -#include "libGLESv2/renderer/d3d/VertexDataManager.h" +#include "libGLESv2/renderer/VertexDataManager.h" namespace gl { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/formatutils9.cpp b/gfx/angle/src/libGLESv2/renderer/d3d9/formatutils9.cpp similarity index 79% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/formatutils9.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d9/formatutils9.cpp index bd1163bd7a15..141bcc7c958c 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/formatutils9.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/formatutils9.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" // -// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -8,8 +8,8 @@ // 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/d3d9/formatutils9.h" +#include "libGLESv2/renderer/d3d9/Renderer9.h" #include "libGLESv2/renderer/generatemip.h" #include "libGLESv2/renderer/loadimage.h" #include "libGLESv2/renderer/copyimage.h" @@ -23,48 +23,67 @@ namespace rx // in templates that perform format support queries on a Renderer9 object which is supplied // when requesting the function or format. -typedef bool(*FallbackPredicateFunction)(); +typedef bool ((Renderer9::*Renderer9FormatCheckFunction)(void) const); +typedef LoadImageFunction (*RendererCheckLoadFunction)(const Renderer9 *renderer); -template -static void FallbackLoad(int width, int height, int depth, - const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch, - void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch) +template +LoadImageFunction RendererCheckLoad(const Renderer9 *renderer) { - if (pred()) - { - prefered(width, height, depth, input, inputRowPitch, inputDepthPitch, output, outputRowPitch, outputDepthPitch); - } - else - { - fallback(width, height, depth, input, inputRowPitch, inputDepthPitch, output, outputRowPitch, outputDepthPitch); - } + return ((renderer->*pred)()) ? prefered : fallback; } -static void UnreachableLoad(int width, int height, int depth, - const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch, - void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch) +template +LoadImageFunction SimpleLoad(const Renderer9 *renderer) +{ + return loadFunc; +} + +LoadImageFunction UnreachableLoad(const Renderer9 *renderer) { UNREACHABLE(); + return NULL; } -const D3DFORMAT D3DFMT_INTZ = ((D3DFORMAT)(MAKEFOURCC('I', 'N', 'T', 'Z'))); -const D3DFORMAT D3DFMT_NULL = ((D3DFORMAT)(MAKEFOURCC('N', 'U', 'L', 'L'))); +typedef bool (*FallbackPredicateFunction)(void); + +template +LoadImageFunction FallbackLoadFunction(const Renderer9 *renderer) +{ + return pred() ? prefered : fallback; +} + +typedef D3DFORMAT (*FormatQueryFunction)(const rx::Renderer9 *renderer); + +template +D3DFORMAT CheckFormatSupport(const rx::Renderer9 *renderer) +{ + return (renderer->*pred)() ? prefered : fallback; +} + +template +D3DFORMAT D3D9Format(const rx::Renderer9 *renderer) +{ + return format; +} struct D3D9FormatInfo { - D3DFORMAT mTexFormat; - D3DFORMAT mRenderFormat; - LoadImageFunction mLoadFunction; + FormatQueryFunction mTexFormat; + FormatQueryFunction mRenderFormat; + RendererCheckLoadFunction mLoadFunction; D3D9FormatInfo() - : mTexFormat(D3DFMT_NULL), mRenderFormat(D3DFMT_NULL), mLoadFunction(NULL) + : mTexFormat(NULL), mRenderFormat(NULL), mLoadFunction(NULL) { } - D3D9FormatInfo(D3DFORMAT textureFormat, D3DFORMAT renderFormat, LoadImageFunction loadFunc) + D3D9FormatInfo(FormatQueryFunction textureFormat, FormatQueryFunction renderFormat, RendererCheckLoadFunction loadFunc) : mTexFormat(textureFormat), mRenderFormat(renderFormat), mLoadFunction(loadFunc) { } }; +const D3DFORMAT D3DFMT_INTZ = ((D3DFORMAT)(MAKEFOURCC('I','N','T','Z'))); +const D3DFORMAT D3DFMT_NULL = ((D3DFORMAT)(MAKEFOURCC('N','U','L','L'))); + typedef std::pair D3D9FormatPair; typedef std::map D3D9FormatMap; @@ -72,53 +91,53 @@ static D3D9FormatMap BuildD3D9FormatMap() { D3D9FormatMap map; - // | Internal format | Texture format | Render format | Load function | - map.insert(D3D9FormatPair(GL_NONE, D3D9FormatInfo(D3DFMT_NULL, D3DFMT_NULL, UnreachableLoad ))); + // | Internal format | Texture format | Render format | Load function | + map.insert(D3D9FormatPair(GL_NONE, D3D9FormatInfo(D3D9Format, D3D9Format, UnreachableLoad ))); - map.insert(D3D9FormatPair(GL_DEPTH_COMPONENT16, D3D9FormatInfo(D3DFMT_INTZ, D3DFMT_D24S8, UnreachableLoad ))); - map.insert(D3D9FormatPair(GL_DEPTH_COMPONENT32_OES, D3D9FormatInfo(D3DFMT_INTZ, D3DFMT_D32, UnreachableLoad ))); - map.insert(D3D9FormatPair(GL_DEPTH24_STENCIL8_OES, D3D9FormatInfo(D3DFMT_INTZ, D3DFMT_D24S8, UnreachableLoad ))); - map.insert(D3D9FormatPair(GL_STENCIL_INDEX8, D3D9FormatInfo(D3DFMT_UNKNOWN, D3DFMT_D24S8, UnreachableLoad ))); // TODO: What's the texture format? + map.insert(D3D9FormatPair(GL_DEPTH_COMPONENT16, D3D9FormatInfo(D3D9Format, D3D9Format, UnreachableLoad ))); + map.insert(D3D9FormatPair(GL_DEPTH_COMPONENT32_OES, D3D9FormatInfo(D3D9Format, D3D9Format, UnreachableLoad ))); + map.insert(D3D9FormatPair(GL_DEPTH24_STENCIL8_OES, D3D9FormatInfo(D3D9Format, D3D9Format, UnreachableLoad ))); + map.insert(D3D9FormatPair(GL_STENCIL_INDEX8, D3D9FormatInfo(D3D9Format, D3D9Format, UnreachableLoad ))); // TODO: What's the texture format? - map.insert(D3D9FormatPair(GL_RGBA32F_EXT, D3D9FormatInfo(D3DFMT_A32B32G32R32F, D3DFMT_A32B32G32R32F, loadToNative ))); - map.insert(D3D9FormatPair(GL_RGB32F_EXT, D3D9FormatInfo(D3DFMT_A32B32G32R32F, D3DFMT_A32B32G32R32F, loadToNative3To4))); - map.insert(D3D9FormatPair(GL_RG32F_EXT, D3D9FormatInfo(D3DFMT_G32R32F, D3DFMT_G32R32F, loadToNative ))); - map.insert(D3D9FormatPair(GL_R32F_EXT, D3D9FormatInfo(D3DFMT_R32F, D3DFMT_R32F, loadToNative ))); - map.insert(D3D9FormatPair(GL_ALPHA32F_EXT, D3D9FormatInfo(D3DFMT_A32B32G32R32F, D3DFMT_UNKNOWN, loadAlphaFloatDataToRGBA ))); - map.insert(D3D9FormatPair(GL_LUMINANCE32F_EXT, D3D9FormatInfo(D3DFMT_A32B32G32R32F, D3DFMT_UNKNOWN, loadLuminanceFloatDataToRGBA ))); - map.insert(D3D9FormatPair(GL_LUMINANCE_ALPHA32F_EXT, D3D9FormatInfo(D3DFMT_A32B32G32R32F, D3DFMT_UNKNOWN, loadLuminanceAlphaFloatDataToRGBA ))); + map.insert(D3D9FormatPair(GL_RGBA32F_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad > ))); + map.insert(D3D9FormatPair(GL_RGB32F_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad >))); + map.insert(D3D9FormatPair(GL_RG32F_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad > ))); + map.insert(D3D9FormatPair(GL_R32F_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad > ))); + map.insert(D3D9FormatPair(GL_ALPHA32F_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad ))); + map.insert(D3D9FormatPair(GL_LUMINANCE32F_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad ))); + map.insert(D3D9FormatPair(GL_LUMINANCE_ALPHA32F_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad ))); - map.insert(D3D9FormatPair(GL_RGBA16F_EXT, D3D9FormatInfo(D3DFMT_A16B16G16R16F, D3DFMT_A16B16G16R16F, loadToNative ))); - map.insert(D3D9FormatPair(GL_RGB16F_EXT, D3D9FormatInfo(D3DFMT_A16B16G16R16F, D3DFMT_A16B16G16R16F, loadToNative3To4 ))); - map.insert(D3D9FormatPair(GL_RG16F_EXT, D3D9FormatInfo(D3DFMT_G16R16F, D3DFMT_G16R16F, loadToNative ))); - map.insert(D3D9FormatPair(GL_R16F_EXT, D3D9FormatInfo(D3DFMT_R16F, D3DFMT_R16F, loadToNative ))); - map.insert(D3D9FormatPair(GL_ALPHA16F_EXT, D3D9FormatInfo(D3DFMT_A16B16G16R16F, D3DFMT_UNKNOWN, loadAlphaHalfFloatDataToRGBA ))); - map.insert(D3D9FormatPair(GL_LUMINANCE16F_EXT, D3D9FormatInfo(D3DFMT_A16B16G16R16F, D3DFMT_UNKNOWN, loadLuminanceHalfFloatDataToRGBA ))); - map.insert(D3D9FormatPair(GL_LUMINANCE_ALPHA16F_EXT, D3D9FormatInfo(D3DFMT_A16B16G16R16F, D3DFMT_UNKNOWN, loadLuminanceAlphaHalfFloatDataToRGBA ))); + map.insert(D3D9FormatPair(GL_RGBA16F_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad > ))); + map.insert(D3D9FormatPair(GL_RGB16F_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad >))); + map.insert(D3D9FormatPair(GL_RG16F_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad > ))); + map.insert(D3D9FormatPair(GL_R16F_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad > ))); + map.insert(D3D9FormatPair(GL_ALPHA16F_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad ))); + map.insert(D3D9FormatPair(GL_LUMINANCE16F_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad ))); + map.insert(D3D9FormatPair(GL_LUMINANCE_ALPHA16F_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad))); - map.insert(D3D9FormatPair(GL_ALPHA8_EXT, D3D9FormatInfo(D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, FallbackLoad))); + map.insert(D3D9FormatPair(GL_ALPHA8_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, FallbackLoadFunction))); - map.insert(D3D9FormatPair(GL_RGB8_OES, D3D9FormatInfo(D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, loadRGBUByteDataToBGRX ))); - map.insert(D3D9FormatPair(GL_RGB565, D3D9FormatInfo(D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, loadRGB565DataToBGRA ))); - map.insert(D3D9FormatPair(GL_RGBA8_OES, D3D9FormatInfo(D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, FallbackLoad))); - map.insert(D3D9FormatPair(GL_RGBA4, D3D9FormatInfo(D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, loadRGBA4444DataToBGRA ))); - map.insert(D3D9FormatPair(GL_RGB5_A1, D3D9FormatInfo(D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, loadRGBA5551DataToBGRA ))); - map.insert(D3D9FormatPair(GL_R8_EXT, D3D9FormatInfo(D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, loadRUByteDataToBGRX ))); - map.insert(D3D9FormatPair(GL_RG8_EXT, D3D9FormatInfo(D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, loadRGUByteDataToBGRX ))); + map.insert(D3D9FormatPair(GL_RGB8_OES, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad ))); + map.insert(D3D9FormatPair(GL_RGB565, D3D9FormatInfo(CheckFormatSupport<&Renderer9::getRGB565TextureSupport, D3DFMT_R5G6B5, D3DFMT_X8R8G8B8>, CheckFormatSupport<&Renderer9::getRGB565TextureSupport, D3DFMT_R5G6B5, D3DFMT_X8R8G8B8>, RendererCheckLoad<&Renderer9::getRGB565TextureSupport, loadToNative, loadRGB565DataToBGRA>))); + map.insert(D3D9FormatPair(GL_RGBA8_OES, D3D9FormatInfo(D3D9Format, D3D9Format, FallbackLoadFunction))); + map.insert(D3D9FormatPair(GL_RGBA4, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad ))); + map.insert(D3D9FormatPair(GL_RGB5_A1, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad ))); + map.insert(D3D9FormatPair(GL_R8_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad ))); + map.insert(D3D9FormatPair(GL_RG8_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad ))); - map.insert(D3D9FormatPair(GL_BGRA8_EXT, D3D9FormatInfo(D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, loadToNative ))); - map.insert(D3D9FormatPair(GL_BGRA4_ANGLEX, D3D9FormatInfo(D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, loadRGBA4444DataToRGBA ))); - map.insert(D3D9FormatPair(GL_BGR5_A1_ANGLEX, D3D9FormatInfo(D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, loadRGBA5551DataToRGBA ))); + map.insert(D3D9FormatPair(GL_BGRA8_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad > ))); + map.insert(D3D9FormatPair(GL_BGRA4_ANGLEX, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad ))); + map.insert(D3D9FormatPair(GL_BGR5_A1_ANGLEX, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad ))); - map.insert(D3D9FormatPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, D3D9FormatInfo(D3DFMT_DXT1, D3DFMT_UNKNOWN, loadCompressedBlockDataToNative<4, 4, 8> ))); - map.insert(D3D9FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, D3D9FormatInfo(D3DFMT_DXT1, D3DFMT_UNKNOWN, loadCompressedBlockDataToNative<4, 4, 8> ))); - map.insert(D3D9FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, D3D9FormatInfo(D3DFMT_DXT3, D3DFMT_UNKNOWN, loadCompressedBlockDataToNative<4, 4, 16> ))); - map.insert(D3D9FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, D3D9FormatInfo(D3DFMT_DXT5, D3DFMT_UNKNOWN, loadCompressedBlockDataToNative<4, 4, 16> ))); + map.insert(D3D9FormatPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad >))); + map.insert(D3D9FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad >))); + map.insert(D3D9FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad >))); + map.insert(D3D9FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, D3D9FormatInfo(D3D9Format, D3D9Format, SimpleLoad >))); // These formats require checking if the renderer supports D3DFMT_L8 or D3DFMT_A8L8 and // then changing the format and loading function appropriately. - map.insert(D3D9FormatPair(GL_LUMINANCE8_EXT, D3D9FormatInfo(D3DFMT_L8, D3DFMT_L8, loadToNative ))); - map.insert(D3D9FormatPair(GL_LUMINANCE8_ALPHA8_EXT, D3D9FormatInfo(D3DFMT_A8L8, D3DFMT_A8L8, loadToNative ))); + map.insert(D3D9FormatPair(GL_LUMINANCE8_EXT, D3D9FormatInfo(CheckFormatSupport<&Renderer9::getLuminanceTextureSupport, D3DFMT_L8, D3DFMT_A8R8G8B8>, D3D9Format, RendererCheckLoad<&Renderer9::getLuminanceTextureSupport, loadToNative, loadLuminanceDataToBGRA>))); + map.insert(D3D9FormatPair(GL_LUMINANCE8_ALPHA8_EXT, D3D9FormatInfo(CheckFormatSupport<&Renderer9::getLuminanceAlphaTextureSupport, D3DFMT_A8L8, D3DFMT_A8R8G8B8>, D3D9Format, RendererCheckLoad<&Renderer9::getLuminanceTextureSupport, loadToNative, loadLuminanceAlphaDataToBGRA>))); return map; } @@ -259,7 +278,7 @@ struct D3D9FastCopyFormat typedef std::map D3D9FastCopyMap; typedef std::pair D3D9FastCopyPair; -static D3D9FastCopyMap BuildFastCopyMap9() +static D3D9FastCopyMap BuildFastCopyMap() { D3D9FastCopyMap map; @@ -304,12 +323,19 @@ MipGenerationFunction GetMipGenerationFunction(D3DFORMAT format) } } -LoadImageFunction GetImageLoadFunction(GLenum internalFormat) +LoadImageFunction GetImageLoadFunction(GLenum internalFormat, const Renderer9 *renderer) { + if (!renderer) + { + return NULL; + } + + ASSERT(renderer->getCurrentClientVersion() == 2); + D3D9FormatInfo d3d9FormatInfo; if (GetD3D9FormatInfo(internalFormat, &d3d9FormatInfo)) { - return d3d9FormatInfo.mLoadFunction; + return d3d9FormatInfo.mLoadFunction(renderer); } else { @@ -421,9 +447,9 @@ ColorReadFunction GetColorReadFunction(D3DFORMAT format) } } -ColorCopyFunction GetFastCopyFunction(D3DFORMAT sourceFormat, GLenum destFormat, GLenum destType) +ColorCopyFunction GetFastCopyFunction(D3DFORMAT sourceFormat, GLenum destFormat, GLenum destType, GLuint clientVersion) { - static const D3D9FastCopyMap fastCopyMap = BuildFastCopyMap9(); + static const D3D9FastCopyMap fastCopyMap = BuildFastCopyMap(); D3D9FastCopyMap::const_iterator iter = fastCopyMap.find(D3D9FastCopyFormat(sourceFormat, destFormat, destType)); return (iter != fastCopyMap.end()) ? iter->second : NULL; } @@ -731,28 +757,46 @@ D3DDECLTYPE GetNativeVertexFormat(const gl::VertexFormat &vertexFormat) namespace gl_d3d9 { -D3DFORMAT GetTextureFormat(GLenum internalFormat) +D3DFORMAT GetTextureFormat(GLenum internalFormat, const Renderer9 *renderer) { + if (!renderer) + { + UNREACHABLE(); + return D3DFMT_UNKNOWN; + } + + ASSERT(renderer->getCurrentClientVersion() == 2); + D3D9FormatInfo d3d9FormatInfo; if (GetD3D9FormatInfo(internalFormat, &d3d9FormatInfo)) { - return d3d9FormatInfo.mTexFormat; + return d3d9FormatInfo.mTexFormat(renderer); } else { + UNREACHABLE(); return D3DFMT_UNKNOWN; } } -D3DFORMAT GetRenderFormat(GLenum internalFormat) +D3DFORMAT GetRenderFormat(GLenum internalFormat, const Renderer9 *renderer) { + if (!renderer) + { + UNREACHABLE(); + return D3DFMT_UNKNOWN; + } + + ASSERT(renderer->getCurrentClientVersion() == 2); + D3D9FormatInfo d3d9FormatInfo; if (GetD3D9FormatInfo(internalFormat, &d3d9FormatInfo)) { - return d3d9FormatInfo.mRenderFormat; + return d3d9FormatInfo.mRenderFormat(renderer); } else { + UNREACHABLE(); return D3DFMT_UNKNOWN; } } @@ -808,10 +852,10 @@ GLsizei GetSamplesCount(D3DMULTISAMPLE_TYPE type) return (type != D3DMULTISAMPLE_NONMASKABLE) ? type : 0; } -bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format) +bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format, GLuint clientVersion) { GLenum internalFormat = d3d9_gl::GetInternalFormat(d3dformat); - GLenum convertedFormat = gl::GetFormat(internalFormat); + GLenum convertedFormat = gl::GetFormat(internalFormat, clientVersion); return convertedFormat == format; } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/formatutils9.h b/gfx/angle/src/libGLESv2/renderer/d3d9/formatutils9.h similarity index 83% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/formatutils9.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/formatutils9.h index 26388794e03a..5b40c1054437 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/formatutils9.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/formatutils9.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -23,7 +23,7 @@ namespace d3d9 typedef std::set D3DFormatSet; MipGenerationFunction GetMipGenerationFunction(D3DFORMAT format); -LoadImageFunction GetImageLoadFunction(GLenum internalFormat); +LoadImageFunction GetImageLoadFunction(GLenum internalFormat, const Renderer9 *renderer); GLuint GetFormatPixelBytes(D3DFORMAT format); GLuint GetBlockWidth(D3DFORMAT format); @@ -35,7 +35,7 @@ void MakeValidSize(bool isImage, D3DFORMAT format, GLsizei *requestWidth, GLsize const D3DFormatSet &GetAllUsedD3DFormats(); ColorReadFunction GetColorReadFunction(D3DFORMAT format); -ColorCopyFunction GetFastCopyFunction(D3DFORMAT sourceFormat, GLenum destFormat, GLenum destType); +ColorCopyFunction GetFastCopyFunction(D3DFORMAT sourceFormat, GLenum destFormat, GLenum destType, GLuint clientVersion); VertexCopyFunction GetVertexCopyFunction(const gl::VertexFormat &vertexFormat); size_t GetVertexElementSize(const gl::VertexFormat &vertexFormat); @@ -53,8 +53,8 @@ void InitializeVertexTranslations(const rx::Renderer9 *renderer); namespace gl_d3d9 { -D3DFORMAT GetTextureFormat(GLenum internalForma); -D3DFORMAT GetRenderFormat(GLenum internalFormat); +D3DFORMAT GetTextureFormat(GLenum internalFormat, const Renderer9 *renderer); +D3DFORMAT GetRenderFormat(GLenum internalFormat, const Renderer9 *renderer); D3DMULTISAMPLE_TYPE GetMultisampleType(GLsizei samples); @@ -68,7 +68,7 @@ namespace d3d9_gl GLenum GetInternalFormat(D3DFORMAT format); GLsizei GetSamplesCount(D3DMULTISAMPLE_TYPE type); -bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format); +bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format, GLuint clientVersion); } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/renderer9_utils.cpp b/gfx/angle/src/libGLESv2/renderer/d3d9/renderer9_utils.cpp similarity index 50% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/renderer9_utils.cpp rename to gfx/angle/src/libGLESv2/renderer/d3d9/renderer9_utils.cpp index 8c3a333816a7..48c378838d6f 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/renderer9_utils.cpp +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/renderer9_utils.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -8,16 +8,12 @@ // 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/formatutils.h" +#include "libGLESv2/renderer/d3d9/renderer9_utils.h" #include "common/mathutil.h" #include "libGLESv2/Context.h" #include "common/debug.h" -#include "third_party/systeminfo/SystemInfo.h" - namespace rx { @@ -248,145 +244,4 @@ void ConvertMinFilter(GLenum minFilter, D3DTEXTUREFILTERTYPE *d3dMinFilter, D3DT } -namespace d3d9_gl -{ - -static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, IDirect3D9 *d3d9, D3DDEVTYPE deviceType, - UINT adapter, D3DFORMAT adapterFormat) -{ - gl::TextureCaps textureCaps; - - D3DFORMAT textureFormat = gl_d3d9::GetTextureFormat(internalFormat); - D3DFORMAT renderFormat = gl_d3d9::GetRenderFormat(internalFormat); - - textureCaps.texture2D = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, - 0, D3DRTYPE_TEXTURE, textureFormat)); - - textureCaps.textureCubeMap = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, - 0, D3DRTYPE_CUBETEXTURE, textureFormat)); - - // D3D9 Renderer doesn't support 3D textures - //textureCaps.setTexture3DSupport(SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, currentDisplayMode.Format, - // 0, D3DRTYPE_VOLUMETEXTURE, textureFormat))); - textureCaps.texture3D = false; - - // D3D9 doesn't support 2D array textures - textureCaps.texture2DArray = false; - - textureCaps.filtering = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, - D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, textureFormat)); - - textureCaps.colorRendering = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, - D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, textureFormat)) || - SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, - D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, renderFormat)); - - textureCaps.depthRendering = gl::GetDepthBits(internalFormat) > 0 && - (SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, - D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, textureFormat)) || - SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, - D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, renderFormat))); - - textureCaps.stencilRendering = gl::GetStencilBits(internalFormat) > 0 && - (SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, - D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, textureFormat)) || - SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, - D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, 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, renderFormat, TRUE, multisampleType, NULL); - if (SUCCEEDED(result)) - { - textureCaps.sampleCounts.insert(i); - } - } - - return textureCaps; -} - -gl::Caps GenerateCaps(IDirect3D9 *d3d9, IDirect3DDevice9 *device, D3DDEVTYPE deviceType, UINT adapter) -{ - gl::Caps caps; - - D3DCAPS9 deviceCaps; - if (FAILED(d3d9->GetDeviceCaps(adapter, deviceType, &deviceCaps))) - { - // Can't continue with out device caps - return caps; - } - - D3DDISPLAYMODE currentDisplayMode; - d3d9->GetAdapterDisplayMode(adapter, ¤tDisplayMode); - - const gl::FormatSet &allFormats = gl::GetAllSizedInternalFormats(); - for (gl::FormatSet::const_iterator internalFormat = allFormats.begin(); internalFormat != allFormats.end(); ++internalFormat) - { - caps.textureCaps.insert(*internalFormat, GenerateTextureFormatCaps(*internalFormat, d3d9, deviceType, adapter, - currentDisplayMode.Format)); - } - - caps.extensions.setTextureExtensionSupport(caps.textureCaps); - caps.extensions.elementIndexUint = deviceCaps.MaxVertexIndex >= (1 << 16); - caps.extensions.packedDepthStencil = true; - caps.extensions.getProgramBinary = true; - caps.extensions.rgb8rgba8 = true; - caps.extensions.readFormatBGRA = true; - caps.extensions.pixelBufferObject = false; - caps.extensions.mapBuffer = false; - caps.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))) - { - caps.extensions.textureNPOT = !(deviceCaps.TextureCaps & D3DPTEXTURECAPS_POW2) && - !(deviceCaps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP_POW2) && - !(deviceCaps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) && - !(isWindowsVistaOrGreater() && adapterId.VendorId == VENDOR_ID_AMD); - } - else - { - caps.extensions.textureNPOT = false; - } - - caps.extensions.drawBuffers = false; - caps.extensions.textureStorage = true; - - // Must support a minimum of 2:1 anisotropy for max anisotropy to be considered supported, per the spec - caps.extensions.textureFilterAnisotropic = (deviceCaps.RasterCaps & D3DPRASTERCAPS_ANISOTROPY) != 0 && deviceCaps.MaxAnisotropy >= 2; - caps.extensions.maxTextureAnisotropy = static_cast(deviceCaps.MaxAnisotropy); - - // Check occlusion query support by trying to create one - IDirect3DQuery9 *occlusionQuery = NULL; - caps.extensions.occlusionQueryBoolean = SUCCEEDED(device->CreateQuery(D3DQUERYTYPE_OCCLUSION, &occlusionQuery)) && occlusionQuery; - SafeRelease(occlusionQuery); - - // Check event query support by trying to create one - IDirect3DQuery9 *eventQuery = NULL; - caps.extensions.fence = SUCCEEDED(device->CreateQuery(D3DQUERYTYPE_EVENT, &eventQuery)) && eventQuery; - SafeRelease(eventQuery); - - caps.extensions.timerQuery = false; // Unimplemented - caps.extensions.robustness = true; - caps.extensions.blendMinMax = true; - caps.extensions.framebufferBlit = true; - caps.extensions.framebufferMultisample = true; - caps.extensions.instancedArrays = deviceCaps.PixelShaderVersion >= D3DPS_VERSION(3, 0); - caps.extensions.packReverseRowOrder = true; - caps.extensions.standardDerivatives = (deviceCaps.PS20Caps.Caps & D3DPS20CAPS_GRADIENTINSTRUCTIONS) != 0; - caps.extensions.shaderTextureLOD = true; - caps.extensions.fragDepth = true; - caps.extensions.textureUsage = true; - caps.extensions.translatedShaderSource = true; - caps.extensions.colorBufferFloat = false; - - return caps; -} - -} - } diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/renderer9_utils.h b/gfx/angle/src/libGLESv2/renderer/d3d9/renderer9_utils.h similarity index 86% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/renderer9_utils.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/renderer9_utils.h index 01fb723174c7..a115f9e3b9cb 100644 --- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/renderer9_utils.h +++ b/gfx/angle/src/libGLESv2/renderer/d3d9/renderer9_utils.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. +// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -11,7 +11,6 @@ #define LIBGLESV2_RENDERER_RENDERER9_UTILS_H #include "libGLESv2/angletypes.h" -#include "libGLESv2/Caps.h" namespace rx { @@ -33,13 +32,6 @@ void ConvertMinFilter(GLenum minFilter, D3DTEXTUREFILTERTYPE *d3dMinFilter, D3DT } -namespace d3d9_gl -{ - -gl::Caps GenerateCaps(IDirect3D9 *d3d9, IDirect3DDevice9 *device, D3DDEVTYPE deviceType, UINT adapter); - -} - namespace d3d9 { diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/Blit.ps b/gfx/angle/src/libGLESv2/renderer/d3d9/shaders/Blit.ps similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/Blit.ps rename to gfx/angle/src/libGLESv2/renderer/d3d9/shaders/Blit.ps diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/Blit.vs b/gfx/angle/src/libGLESv2/renderer/d3d9/shaders/Blit.vs similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/Blit.vs rename to gfx/angle/src/libGLESv2/renderer/d3d9/shaders/Blit.vs diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/compiled/componentmaskps.h b/gfx/angle/src/libGLESv2/renderer/d3d9/shaders/compiled/componentmaskps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/compiled/componentmaskps.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/shaders/compiled/componentmaskps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/compiled/flipyvs.h b/gfx/angle/src/libGLESv2/renderer/d3d9/shaders/compiled/flipyvs.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/compiled/flipyvs.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/shaders/compiled/flipyvs.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/compiled/luminanceps.h b/gfx/angle/src/libGLESv2/renderer/d3d9/shaders/compiled/luminanceps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/compiled/luminanceps.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/shaders/compiled/luminanceps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/compiled/passthroughps.h b/gfx/angle/src/libGLESv2/renderer/d3d9/shaders/compiled/passthroughps.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/compiled/passthroughps.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/shaders/compiled/passthroughps.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/compiled/standardvs.h b/gfx/angle/src/libGLESv2/renderer/d3d9/shaders/compiled/standardvs.h similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/compiled/standardvs.h rename to gfx/angle/src/libGLESv2/renderer/d3d9/shaders/compiled/standardvs.h diff --git a/gfx/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/generate_shaders.bat b/gfx/angle/src/libGLESv2/renderer/d3d9/shaders/generate_shaders.bat similarity index 100% rename from gfx/angle/src/libGLESv2/renderer/d3d/d3d9/shaders/generate_shaders.bat rename to gfx/angle/src/libGLESv2/renderer/d3d9/shaders/generate_shaders.bat diff --git a/gfx/angle/src/libGLESv2/renderer/loadimage.cpp b/gfx/angle/src/libGLESv2/renderer/loadimage.cpp index 62870c531cea..6e2d2460a52b 100644 --- a/gfx/angle/src/libGLESv2/renderer/loadimage.cpp +++ b/gfx/angle/src/libGLESv2/renderer/loadimage.cpp @@ -948,26 +948,4 @@ void loadUintDataToUshort(int width, int height, int depth, } } -void loadUintDataToUint24X8(int width, int height, int depth, - const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch, - void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch) -{ - const unsigned int *source = NULL; - unsigned int *dest = NULL; - - for (int z = 0; z < depth; z++) - { - for (int y = 0; y < height; y++) - { - source = offsetDataPointer(input, y, z, inputRowPitch, inputDepthPitch); - dest = offsetDataPointer(output, y, z, outputRowPitch, outputDepthPitch); - - for (int x = 0; x < width; x++) - { - dest[x] = source[x] >> 8; - } - } - } -} - } diff --git a/gfx/angle/src/libGLESv2/renderer/loadimage.h b/gfx/angle/src/libGLESv2/renderer/loadimage.h index 8b1066aa8828..537a5e4c1706 100644 --- a/gfx/angle/src/libGLESv2/renderer/loadimage.h +++ b/gfx/angle/src/libGLESv2/renderer/loadimage.h @@ -338,10 +338,6 @@ void initialize4ComponentData(int width, int height, int depth, } } -void loadUintDataToUint24X8(int width, int height, int depth, - const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch, - void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch); - } #endif // LIBGLESV2_RENDERER_LOADIMAGE_H_ diff --git a/gfx/angle/src/libGLESv2/validationES.cpp b/gfx/angle/src/libGLESv2/validationES.cpp index ec2a6b682ae2..a6ae90a28197 100644 --- a/gfx/angle/src/libGLESv2/validationES.cpp +++ b/gfx/angle/src/libGLESv2/validationES.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" // -// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -13,12 +13,11 @@ #include "libGLESv2/Context.h" #include "libGLESv2/Texture.h" #include "libGLESv2/Framebuffer.h" -#include "libGLESv2/FramebufferAttachment.h" +#include "libGLESv2/Renderbuffer.h" #include "libGLESv2/formatutils.h" #include "libGLESv2/main.h" #include "libGLESv2/Query.h" #include "libGLESv2/ProgramBinary.h" -#include "libGLESv2/TransformFeedback.h" #include "common/mathutil.h" #include "common/utilities.h" @@ -68,7 +67,6 @@ bool ValidTextureTarget(const Context *context, GLenum target) // 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) @@ -112,7 +110,7 @@ bool ValidBufferTarget(const Context *context, GLenum target) case GL_PIXEL_PACK_BUFFER: case GL_PIXEL_UNPACK_BUFFER: - return context->getCaps().extensions.pixelBufferObject; + return context->supportsPBOs(); case GL_COPY_READ_BUFFER: case GL_COPY_WRITE_BUFFER: @@ -167,16 +165,14 @@ bool ValidMipLevel(const Context *context, GLenum target, GLint level) return level < maxLevel; } -bool ValidImageSize(const gl::Context *context, GLenum target, GLint level, - GLsizei width, GLsizei height, GLsizei depth) +bool ValidImageSize(const gl::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->getCaps().extensions.textureNPOT && - (level != 0 && (!gl::isPow2(width) || !gl::isPow2(height) || !gl::isPow2(depth)))) + if (!context->supportsNonPower2Texture() && (level != 0 || !gl::isPow2(width) || !gl::isPow2(height) || !gl::isPow2(depth))) { return false; } @@ -191,13 +187,14 @@ bool ValidImageSize(const gl::Context *context, GLenum target, GLint level, bool ValidCompressedImageSize(const gl::Context *context, GLenum internalFormat, GLsizei width, GLsizei height) { - if (!IsFormatCompressed(internalFormat)) + GLuint clientVersion = context->getClientVersion(); + if (!IsFormatCompressed(internalFormat, clientVersion)) { return false; } - GLint blockWidth = GetCompressedBlockWidth(internalFormat); - GLint blockHeight = GetCompressedBlockHeight(internalFormat); + GLint blockWidth = GetCompressedBlockWidth(internalFormat, clientVersion); + GLint blockHeight = GetCompressedBlockHeight(internalFormat, clientVersion); if (width < 0 || (width > blockWidth && width % blockWidth != 0) || height < 0 || (height > blockHeight && height % blockHeight != 0)) { @@ -263,8 +260,7 @@ bool ValidateRenderbufferStorageParameters(const gl::Context *context, GLenum ta return gl::error(GL_INVALID_VALUE, false); } - const gl::Caps &caps = context->getCaps(); - if (!gl::IsValidInternalFormat(internalformat, caps.extensions, context->getClientVersion())) + if (!gl::IsValidInternalFormat(internalformat, context)) { return gl::error(GL_INVALID_ENUM, false); } @@ -273,19 +269,20 @@ bool ValidateRenderbufferStorageParameters(const gl::Context *context, GLenum ta // 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. - if (!gl::IsSizedInternalFormat(internalformat)) + if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion())) { return gl::error(GL_INVALID_ENUM, false); } - GLenum componentType = gl::GetComponentType(internalformat); + GLenum componentType = gl::GetComponentType(internalformat, context->getClientVersion()); if ((componentType == GL_UNSIGNED_INT || componentType == GL_INT) && samples > 0) { return gl::error(GL_INVALID_OPERATION, false); } - const TextureCaps &formatCaps = caps.textureCaps.get(internalformat); - if (!formatCaps.colorRendering && !formatCaps.depthRendering && !formatCaps.stencilRendering) + if (!gl::IsColorRenderingSupported(internalformat, context) && + !gl::IsDepthRenderingSupported(internalformat, context) && + !gl::IsStencilRenderingSupported(internalformat, context)) { return gl::error(GL_INVALID_ENUM, false); } @@ -377,7 +374,7 @@ bool ValidateFramebufferRenderbufferParameters(gl::Context *context, GLenum targ return true; } -static bool IsPartialBlit(gl::Context *context, gl::FramebufferAttachment *readBuffer, gl::FramebufferAttachment *writeBuffer, +static bool IsPartialBlit(gl::Context *context, gl::Renderbuffer *readBuffer, gl::Renderbuffer *writeBuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1) { @@ -470,22 +467,24 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint bool sameBounds = srcX0 == dstX0 && srcY0 == dstY0 && srcX1 == dstX1 && srcY1 == dstY1; + GLuint clientVersion = context->getClientVersion(); + if (mask & GL_COLOR_BUFFER_BIT) { - gl::FramebufferAttachment *readColorBuffer = readFramebuffer->getReadColorbuffer(); - gl::FramebufferAttachment *drawColorBuffer = drawFramebuffer->getFirstColorbuffer(); + gl::Renderbuffer *readColorBuffer = readFramebuffer->getReadColorbuffer(); + gl::Renderbuffer *drawColorBuffer = drawFramebuffer->getFirstColorbuffer(); if (readColorBuffer && drawColorBuffer) { GLenum readInternalFormat = readColorBuffer->getActualFormat(); - GLenum readComponentType = gl::GetComponentType(readInternalFormat); + GLenum readComponentType = gl::GetComponentType(readInternalFormat, clientVersion); for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; i++) { if (drawFramebuffer->isEnabledColorAttachment(i)) { GLenum drawInternalFormat = drawFramebuffer->getColorbuffer(i)->getActualFormat(); - GLenum drawComponentType = gl::GetComponentType(drawInternalFormat); + GLenum drawComponentType = gl::GetComponentType(drawInternalFormat, clientVersion); // 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 @@ -555,8 +554,8 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint if (mask & GL_DEPTH_BUFFER_BIT) { - gl::FramebufferAttachment *readDepthBuffer = readFramebuffer->getDepthbuffer(); - gl::FramebufferAttachment *drawDepthBuffer = drawFramebuffer->getDepthbuffer(); + gl::Renderbuffer *readDepthBuffer = readFramebuffer->getDepthbuffer(); + gl::Renderbuffer *drawDepthBuffer = drawFramebuffer->getDepthbuffer(); if (readDepthBuffer && drawDepthBuffer) { @@ -589,8 +588,8 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint if (mask & GL_STENCIL_BUFFER_BIT) { - gl::FramebufferAttachment *readStencilBuffer = readFramebuffer->getStencilbuffer(); - gl::FramebufferAttachment *drawStencilBuffer = drawFramebuffer->getStencilbuffer(); + gl::Renderbuffer *readStencilBuffer = readFramebuffer->getStencilbuffer(); + gl::Renderbuffer *drawStencilBuffer = drawFramebuffer->getStencilbuffer(); if (readStencilBuffer && drawStencilBuffer) { @@ -728,7 +727,7 @@ bool ValidateTexParamParameters(gl::Context *context, GLenum pname, GLint param) break; case GL_TEXTURE_MAX_ANISOTROPY_EXT: - if (!context->getCaps().extensions.textureFilterAnisotropic) + if (!context->supportsTextureFilterAnisotropy()) { return gl::error(GL_INVALID_ENUM, false); } @@ -848,7 +847,7 @@ bool ValidateReadPixelsParameters(gl::Context *context, GLint x, GLint y, GLsize } GLenum currentInternalFormat, currentFormat, currentType; - GLuint clientVersion = context->getClientVersion(); + int clientVersion = context->getClientVersion(); context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType); @@ -860,10 +859,10 @@ bool ValidateReadPixelsParameters(gl::Context *context, GLint x, GLint y, GLsize return gl::error(GL_INVALID_OPERATION, false); } - GLenum sizedInternalFormat = IsSizedInternalFormat(format) ? format - : GetSizedInternalFormat(format, type); + GLenum sizedInternalFormat = IsSizedInternalFormat(format, clientVersion) ? format : + GetSizedInternalFormat(format, type, clientVersion); - GLsizei outputPitch = GetRowPitch(sizedInternalFormat, type, width, context->getPackAlignment()); + GLsizei outputPitch = GetRowPitch(sizedInternalFormat, type, clientVersion, width, context->getPackAlignment()); // sized query sanity check if (bufSize) { @@ -988,7 +987,7 @@ static bool ValidateUniformCommonBase(gl::Context *context, GLenum targetUniform 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) + if (UniformComponentType(uniformType) == GL_UNSIGNED_INT && context->getClientVersion() < 3) { return gl::error(GL_INVALID_OPERATION, false); } @@ -999,7 +998,7 @@ bool ValidateUniform(gl::Context *context, GLenum uniformType, GLint location, G return false; } - GLenum targetBoolType = VariableBoolVectorType(uniformType); + GLenum targetBoolType = UniformBoolVectorType(uniformType); bool samplerUniformCheck = (IsSampler(uniform->type) && uniformType == GL_INT); if (!samplerUniformCheck && uniformType != uniform->type && targetBoolType != uniform->type) { @@ -1078,8 +1077,8 @@ bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType, return gl::error(GL_INVALID_OPERATION, false); } - FramebufferAttachment *attachment = framebuffer->getReadColorbuffer(); - if (!attachment) + Renderbuffer *renderbuffer = framebuffer->getReadColorbuffer(); + if (!renderbuffer) { return gl::error(GL_INVALID_OPERATION, false); } @@ -1099,338 +1098,4 @@ bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType, 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)) - { - return gl::error(GL_INVALID_ENUM, false); - } - - if (level < 0 || xoffset < 0 || yoffset < 0 || zoffset < 0 || width < 0 || height < 0) - { - return gl::error(GL_INVALID_VALUE, false); - } - - if (std::numeric_limits::max() - xoffset < width || std::numeric_limits::max() - yoffset < height) - { - return gl::error(GL_INVALID_VALUE, false); - } - - if (border != 0) - { - return gl::error(GL_INVALID_VALUE, false); - } - - if (!ValidMipLevel(context, target, level)) - { - return gl::error(GL_INVALID_VALUE, false); - } - - gl::Framebuffer *framebuffer = context->getReadFramebuffer(); - if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) - { - return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); - } - - if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0) - { - return gl::error(GL_INVALID_OPERATION, false); - } - - gl::Texture *texture = NULL; - GLenum textureInternalFormat = GL_NONE; - bool textureCompressed = false; - bool textureIsDepth = false; - GLint textureLevelWidth = 0; - GLint textureLevelHeight = 0; - GLint textureLevelDepth = 0; - int maxDimension = 0; - - switch (target) - { - case GL_TEXTURE_2D: - { - gl::Texture2D *texture2d = context->getTexture2D(); - if (texture2d) - { - textureInternalFormat = texture2d->getInternalFormat(level); - textureCompressed = texture2d->isCompressed(level); - textureIsDepth = texture2d->isDepth(level); - textureLevelWidth = texture2d->getWidth(level); - textureLevelHeight = texture2d->getHeight(level); - textureLevelDepth = 1; - texture = texture2d; - maxDimension = context->getMaximum2DTextureDimension(); - } - } - 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); - textureCompressed = textureCube->isCompressed(target, level); - textureIsDepth = false; - textureLevelWidth = textureCube->getWidth(target, level); - textureLevelHeight = textureCube->getHeight(target, level); - textureLevelDepth = 1; - texture = textureCube; - maxDimension = context->getMaximumCubeTextureDimension(); - } - } - break; - - case GL_TEXTURE_2D_ARRAY: - { - gl::Texture2DArray *texture2dArray = context->getTexture2DArray(); - if (texture2dArray) - { - textureInternalFormat = texture2dArray->getInternalFormat(level); - textureCompressed = texture2dArray->isCompressed(level); - textureIsDepth = texture2dArray->isDepth(level); - textureLevelWidth = texture2dArray->getWidth(level); - textureLevelHeight = texture2dArray->getHeight(level); - textureLevelDepth = texture2dArray->getLayers(level); - texture = texture2dArray; - maxDimension = context->getMaximum2DTextureDimension(); - } - } - break; - - case GL_TEXTURE_3D: - { - gl::Texture3D *texture3d = context->getTexture3D(); - if (texture3d) - { - textureInternalFormat = texture3d->getInternalFormat(level); - textureCompressed = texture3d->isCompressed(level); - textureIsDepth = texture3d->isDepth(level); - textureLevelWidth = texture3d->getWidth(level); - textureLevelHeight = texture3d->getHeight(level); - textureLevelDepth = texture3d->getDepth(level); - texture = texture3d; - maxDimension = context->getMaximum3DTextureDimension(); - } - } - break; - - default: - return gl::error(GL_INVALID_ENUM, false); - } - - if (!texture) - { - return gl::error(GL_INVALID_OPERATION, false); - } - - if (texture->isImmutable() && !isSubImage) - { - return gl::error(GL_INVALID_OPERATION, false); - } - - if (textureIsDepth) - { - return gl::error(GL_INVALID_OPERATION, false); - } - - if (textureCompressed) - { - GLint blockWidth = GetCompressedBlockWidth(textureInternalFormat); - GLint blockHeight = GetCompressedBlockHeight(textureInternalFormat); - - if (((width % blockWidth) != 0 && width != textureLevelWidth) || - ((height % blockHeight) != 0 && height != textureLevelHeight)) - { - return gl::error(GL_INVALID_OPERATION, false); - } - } - - if (isSubImage) - { - if (xoffset + width > textureLevelWidth || - yoffset + height > textureLevelHeight || - zoffset >= textureLevelDepth) - { - return gl::error(GL_INVALID_VALUE, false); - } - } - else - { - if (IsCubemapTextureTarget(target) && width != height) - { - return gl::error(GL_INVALID_VALUE, false); - } - - if (!IsValidInternalFormat(internalformat, context->getCaps().extensions, context->getClientVersion())) - { - return gl::error(GL_INVALID_ENUM, false); - } - - int maxLevelDimension = (maxDimension >> level); - if (static_cast(width) > maxLevelDimension || static_cast(height) > maxLevelDimension) - { - return gl::error(GL_INVALID_VALUE, false); - } - } - - *textureFormatOut = textureInternalFormat; - return true; -} - -static bool ValidateDrawBase(const gl::Context *context, GLenum mode, GLsizei count) -{ - 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: - return gl::error(GL_INVALID_ENUM, false); - } - - if (count < 0) - { - return gl::error(GL_INVALID_VALUE, false); - } - - // Check for mapped buffers - if (context->hasMappedBuffer(GL_ARRAY_BUFFER)) - { - return gl::error(GL_INVALID_OPERATION, false); - } - - const gl::DepthStencilState &depthStencilState = context->getDepthStencilState(); - if (depthStencilState.stencilWritemask != depthStencilState.stencilBackWritemask || - context->getStencilRef() != context->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."); - return gl::error(GL_INVALID_OPERATION, false); - } - - const gl::Framebuffer *fbo = context->getDrawFramebuffer(); - if (!fbo || fbo->completeness() != GL_FRAMEBUFFER_COMPLETE) - { - return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); - } - - // No-op if zero count - return (count > 0); -} - -bool ValidateDrawArrays(const gl::Context *context, GLenum mode, GLint first, GLsizei count) -{ - if (first < 0) - { - return gl::error(GL_INVALID_VALUE, false); - } - - gl::TransformFeedback *curTransformFeedback = context->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) - return gl::error(GL_INVALID_OPERATION, false); - } - - if (!ValidateDrawBase(context, mode, count)) - { - return false; - } - - return true; -} - -bool ValidateDrawArraysInstanced(const gl::Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount) -{ - if (primcount < 0) - { - return gl::error(GL_INVALID_VALUE, false); - } - - if (!ValidateDrawArrays(context, mode, first, count)) - { - return false; - } - - // No-op if zero primitive count - return (primcount > 0); -} - -bool ValidateDrawElements(const gl::Context *context, GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) -{ - switch (type) - { - case GL_UNSIGNED_BYTE: - case GL_UNSIGNED_SHORT: - break; - case GL_UNSIGNED_INT: - if (!context->getCaps().extensions.elementIndexUint) - { - return gl::error(GL_INVALID_ENUM, false); - } - break; - default: - return gl::error(GL_INVALID_ENUM, false); - } - - gl::TransformFeedback *curTransformFeedback = context->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) - return gl::error(GL_INVALID_OPERATION, false); - } - - // Check for mapped buffers - if (context->hasMappedBuffer(GL_ELEMENT_ARRAY_BUFFER)) - { - return gl::error(GL_INVALID_OPERATION, false); - } - - if (!ValidateDrawBase(context, mode, count)) - { - return false; - } - - return true; -} - -bool ValidateDrawElementsInstanced(const gl::Context *context, GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices, GLsizei primcount) -{ - if (primcount < 0) - { - return gl::error(GL_INVALID_VALUE, false); - } - - if (!ValidateDrawElements(context, mode, count, type, indices)) - { - return false; - } - - // No-op zero primitive count - return (primcount > 0); -} - } diff --git a/gfx/angle/src/libGLESv2/validationES.h b/gfx/angle/src/libGLESv2/validationES.h index 43ab4a95580b..a61313ee65b7 100644 --- a/gfx/angle/src/libGLESv2/validationES.h +++ b/gfx/angle/src/libGLESv2/validationES.h @@ -54,16 +54,6 @@ bool ValidateUniformMatrix(gl::Context *context, GLenum matrixType, GLint locati bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType, unsigned int *numParams); -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 *textureInternalFormatOut); - -bool ValidateDrawArrays(const gl::Context *context, GLenum mode, GLint first, GLsizei count); -bool ValidateDrawArraysInstanced(const gl::Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount); -bool ValidateDrawElements(const gl::Context *context, GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); -bool ValidateDrawElementsInstanced(const gl::Context *context, GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices, GLsizei primcount); - } #endif // LIBGLESV2_VALIDATION_ES_H diff --git a/gfx/angle/src/libGLESv2/validationES2.cpp b/gfx/angle/src/libGLESv2/validationES2.cpp index 0d07f0f15aa0..428d1385afb7 100644 --- a/gfx/angle/src/libGLESv2/validationES2.cpp +++ b/gfx/angle/src/libGLESv2/validationES2.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" // -// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -15,7 +15,6 @@ #include "libGLESv2/Renderbuffer.h" #include "libGLESv2/formatutils.h" #include "libGLESv2/main.h" -#include "libGLESv2/FramebufferAttachment.h" #include "common/mathutil.h" #include "common/utilities.h" @@ -39,7 +38,7 @@ static bool validateSubImageParams2D(bool compressed, GLsizei width, GLsizei hei if (format != GL_NONE) { - GLenum internalformat = gl::GetSizedInternalFormat(format, type); + GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2); if (internalformat != texture->getInternalFormat(level)) { return gl::error(GL_INVALID_OPERATION, false); @@ -80,7 +79,7 @@ static bool validateSubImageParamsCube(bool compressed, GLsizei width, GLsizei h if (format != GL_NONE) { - GLenum internalformat = gl::GetSizedInternalFormat(format, type); + GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2); if (internalformat != texture->getInternalFormat(target, level)) { return gl::error(GL_INVALID_OPERATION, false); @@ -109,11 +108,6 @@ bool ValidateES2TexImageParameters(gl::Context *context, GLenum target, GLint le GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) { - if (!ValidTexture2DDestinationTarget(context, target)) - { - return gl::error(GL_INVALID_ENUM, false); - } - if (!ValidImageSize(context, target, level, width, height, 1)) { return gl::error(GL_INVALID_VALUE, false); @@ -234,19 +228,19 @@ bool ValidateES2TexImageParameters(gl::Context *context, GLenum target, GLint le { case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - if (!context->getCaps().extensions.textureCompressionDXT1) + if (!context->supportsDXT1Textures()) { return gl::error(GL_INVALID_ENUM, false); } break; case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: - if (!context->getCaps().extensions.textureCompressionDXT1) + if (!context->supportsDXT3Textures()) { return gl::error(GL_INVALID_ENUM, false); } break; case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: - if (!context->getCaps().extensions.textureCompressionDXT5) + if (!context->supportsDXT5Textures()) { return gl::error(GL_INVALID_ENUM, false); } @@ -293,8 +287,7 @@ bool ValidateES2TexImageParameters(gl::Context *context, GLenum target, GLint le } break; case GL_RED: - case GL_RG: - if (!context->getCaps().extensions.textureRG) + if (!context->supportsRGTextures()) { return gl::error(GL_INVALID_ENUM, false); } @@ -308,6 +301,21 @@ bool ValidateES2TexImageParameters(gl::Context *context, GLenum target, GLint le return gl::error(GL_INVALID_OPERATION, false); } break; + case GL_RG: + if (!context->supportsRGTextures()) + { + return gl::error(GL_INVALID_ENUM, false); + } + switch (type) + { + case GL_UNSIGNED_BYTE: + case GL_FLOAT: + case GL_HALF_FLOAT_OES: + break; + default: + return gl::error(GL_INVALID_OPERATION, false); + } + break; case GL_RGB: switch (type) { @@ -342,20 +350,6 @@ bool ValidateES2TexImageParameters(gl::Context *context, GLenum target, GLint le return gl::error(GL_INVALID_OPERATION, false); } break; - case GL_SRGB_EXT: - case GL_SRGB_ALPHA_EXT: - if (!context->getCaps().extensions.sRGB) - { - return gl::error(GL_INVALID_ENUM, false); - } - switch (type) - { - case GL_UNSIGNED_BYTE: - break; - default: - return gl::error(GL_INVALID_OPERATION, 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: @@ -388,7 +382,7 @@ bool ValidateES2TexImageParameters(gl::Context *context, GLenum target, GLint le { case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - if (context->getCaps().extensions.textureCompressionDXT1) + if (context->supportsDXT1Textures()) { return gl::error(GL_INVALID_OPERATION, false); } @@ -398,7 +392,7 @@ bool ValidateES2TexImageParameters(gl::Context *context, GLenum target, GLint le } break; case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: - if (context->getCaps().extensions.textureCompressionDXT3) + if (context->supportsDXT3Textures()) { return gl::error(GL_INVALID_OPERATION, false); } @@ -408,7 +402,7 @@ bool ValidateES2TexImageParameters(gl::Context *context, GLenum target, GLint le } break; case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: - if (context->getCaps().extensions.textureCompressionDXT5) + if (context->supportsDXT5Textures()) { return gl::error(GL_INVALID_OPERATION, false); } @@ -419,7 +413,7 @@ bool ValidateES2TexImageParameters(gl::Context *context, GLenum target, GLint le break; case GL_DEPTH_COMPONENT: case GL_DEPTH_STENCIL_OES: - if (!context->getCaps().extensions.depthTextures) + if (!context->supportsDepthTextures()) { return gl::error(GL_INVALID_VALUE, false); } @@ -440,14 +434,14 @@ bool ValidateES2TexImageParameters(gl::Context *context, GLenum target, GLint le if (type == GL_FLOAT) { - if (!context->getCaps().extensions.textureFloat) + if (!context->supportsFloat32Textures()) { return gl::error(GL_INVALID_ENUM, false); } } else if (type == GL_HALF_FLOAT_OES) { - if (!context->getCaps().extensions.textureHalfFloat) + if (!context->supportsFloat16Textures()) { return gl::error(GL_INVALID_ENUM, false); } @@ -463,17 +457,122 @@ bool ValidateES2CopyTexImageParameters(gl::Context* context, GLenum target, GLin 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)) + if (!ValidTexture2DDestinationTarget(context, target)) { - return false; + return gl::error(GL_INVALID_ENUM, false); + } + + if (!gl::IsInternalTextureTarget(target, context->getClientVersion())) + { + return gl::error(GL_INVALID_ENUM, false); + } + + if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0) + { + return gl::error(GL_INVALID_VALUE, false); + } + + if (std::numeric_limits::max() - xoffset < width || std::numeric_limits::max() - yoffset < height) + { + return gl::error(GL_INVALID_VALUE, false); + } + + // Verify zero border + if (border != 0) + { + return gl::error(GL_INVALID_VALUE, false); + } + + // Validate dimensions based on Context limits and validate the texture + if (!ValidMipLevel(context, target, level)) + { + return gl::error(GL_INVALID_VALUE, false); } gl::Framebuffer *framebuffer = context->getReadFramebuffer(); + + if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) + { + return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); + } + + if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0) + { + return gl::error(GL_INVALID_OPERATION, false); + } + GLenum colorbufferFormat = framebuffer->getReadColorbuffer()->getInternalFormat(); - GLenum textureFormat = gl::GetFormat(textureInternalFormat); + gl::Texture *texture = NULL; + GLenum textureFormat = GL_RGBA; + + switch (target) + { + case GL_TEXTURE_2D: + { + if (width > (context->getMaximum2DTextureDimension() >> level) || + height > (context->getMaximum2DTextureDimension() >> level)) + { + return gl::error(GL_INVALID_VALUE, false); + } + + gl::Texture2D *tex2d = context->getTexture2D(); + if (tex2d) + { + if (isSubImage && !validateSubImageParams2D(false, width, height, xoffset, yoffset, level, GL_NONE, GL_NONE, tex2d)) + { + return false; // error already registered by validateSubImageParams + } + texture = tex2d; + textureFormat = gl::GetFormat(tex2d->getInternalFormat(level), context->getClientVersion()); + } + } + 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) + { + return gl::error(GL_INVALID_VALUE, false); + } + + if (width > (context->getMaximumCubeTextureDimension() >> level) || + height > (context->getMaximumCubeTextureDimension() >> level)) + { + return gl::error(GL_INVALID_VALUE, false); + } + + gl::TextureCubeMap *texcube = context->getTextureCubeMap(); + if (texcube) + { + if (isSubImage && !validateSubImageParamsCube(false, width, height, xoffset, yoffset, target, level, GL_NONE, GL_NONE, texcube)) + { + return false; // error already registered by validateSubImageParams + } + texture = texcube; + textureFormat = gl::GetFormat(texcube->getInternalFormat(target, level), context->getClientVersion()); + } + } + break; + + default: + return gl::error(GL_INVALID_ENUM, false); + } + + if (!texture) + { + return gl::error(GL_INVALID_OPERATION, false); + } + + if (texture->isImmutable() && !isSubImage) + { + return gl::error(GL_INVALID_OPERATION, false); + } + // [OpenGL ES 2.0.24] table 3.9 if (isSubImage) @@ -630,7 +729,7 @@ bool ValidateES2CopyTexImageParameters(gl::Context* context, GLenum target, GLin break; case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - if (context->getCaps().extensions.textureCompressionDXT1) + if (context->supportsDXT1Textures()) { return gl::error(GL_INVALID_OPERATION, false); } @@ -640,7 +739,7 @@ bool ValidateES2CopyTexImageParameters(gl::Context* context, GLenum target, GLin } break; case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: - if (context->getCaps().extensions.textureCompressionDXT3) + if (context->supportsDXT3Textures()) { return gl::error(GL_INVALID_OPERATION, false); } @@ -650,7 +749,7 @@ bool ValidateES2CopyTexImageParameters(gl::Context* context, GLenum target, GLin } break; case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: - if (context->getCaps().extensions.textureCompressionDXT5) + if (context->supportsDXT5Textures()) { return gl::error(GL_INVALID_OPERATION, false); } @@ -664,7 +763,7 @@ bool ValidateES2CopyTexImageParameters(gl::Context* context, GLenum target, GLin case GL_DEPTH_COMPONENT32_OES: case GL_DEPTH_STENCIL_OES: case GL_DEPTH24_STENCIL8_OES: - if (context->getCaps().extensions.depthTextures) + if (context->supportsDepthTextures()) { return gl::error(GL_INVALID_OPERATION, false); } @@ -704,8 +803,8 @@ bool ValidateES2TexStorageParameters(gl::Context *context, GLenum target, GLsize return gl::error(GL_INVALID_OPERATION, false); } - GLenum format = gl::GetFormat(internalformat); - GLenum type = gl::GetType(internalformat); + GLenum format = gl::GetFormat(internalformat, context->getClientVersion()); + GLenum type = gl::GetType(internalformat, context->getClientVersion()); if (format == GL_NONE || type == GL_NONE) { @@ -732,7 +831,7 @@ bool ValidateES2TexStorageParameters(gl::Context *context, GLenum target, GLsize return gl::error(GL_INVALID_ENUM, false); } - if (levels != 1 && !context->getCaps().extensions.textureNPOT) + if (levels != 1 && !context->supportsNonPower2Texture()) { if (!gl::isPow2(width) || !gl::isPow2(height)) { @@ -744,19 +843,19 @@ bool ValidateES2TexStorageParameters(gl::Context *context, GLenum target, GLsize { case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - if (!context->getCaps().extensions.textureCompressionDXT1) + if (!context->supportsDXT1Textures()) { return gl::error(GL_INVALID_ENUM, false); } break; case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: - if (!context->getCaps().extensions.textureCompressionDXT3) + if (!context->supportsDXT3Textures()) { return gl::error(GL_INVALID_ENUM, false); } break; case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: - if (!context->getCaps().extensions.textureCompressionDXT5) + if (!context->supportsDXT5Textures()) { return gl::error(GL_INVALID_ENUM, false); } @@ -766,7 +865,7 @@ bool ValidateES2TexStorageParameters(gl::Context *context, GLenum target, GLsize case GL_ALPHA32F_EXT: case GL_LUMINANCE32F_EXT: case GL_LUMINANCE_ALPHA32F_EXT: - if (!context->getCaps().extensions.textureFloat) + if (!context->supportsFloat32Textures()) { return gl::error(GL_INVALID_ENUM, false); } @@ -776,7 +875,7 @@ bool ValidateES2TexStorageParameters(gl::Context *context, GLenum target, GLsize case GL_ALPHA16F_EXT: case GL_LUMINANCE16F_EXT: case GL_LUMINANCE_ALPHA16F_EXT: - if (!context->getCaps().extensions.textureHalfFloat) + if (!context->supportsFloat16Textures()) { return gl::error(GL_INVALID_ENUM, false); } @@ -787,7 +886,7 @@ bool ValidateES2TexStorageParameters(gl::Context *context, GLenum target, GLsize case GL_RG16F_EXT: case GL_R32F_EXT: case GL_RG32F_EXT: - if (!context->getCaps().extensions.textureRG) + if (!context->supportsRGTextures()) { return gl::error(GL_INVALID_ENUM, false); } @@ -795,7 +894,7 @@ bool ValidateES2TexStorageParameters(gl::Context *context, GLenum target, GLsize case GL_DEPTH_COMPONENT16: case GL_DEPTH_COMPONENT32_OES: case GL_DEPTH24_STENCIL8_OES: - if (!context->getCaps().extensions.depthTextures) + if (!context->supportsDepthTextures()) { return gl::error(GL_INVALID_ENUM, false); } @@ -971,7 +1070,7 @@ bool ValidES2ReadFormatType(gl::Context *context, GLenum format, GLenum type) break; case GL_RG_EXT: case GL_RED_EXT: - if (!context->getCaps().extensions.textureRG) + if (!context->supportsRGTextures()) { return false; } diff --git a/gfx/angle/src/libGLESv2/validationES3.cpp b/gfx/angle/src/libGLESv2/validationES3.cpp index e16c9a2ddf05..ad1bde78de91 100644 --- a/gfx/angle/src/libGLESv2/validationES3.cpp +++ b/gfx/angle/src/libGLESv2/validationES3.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" // -// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved. +// 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. // @@ -15,7 +15,6 @@ #include "libGLESv2/Renderbuffer.h" #include "libGLESv2/formatutils.h" #include "libGLESv2/main.h" -#include "libGLESv2/FramebufferAttachment.h" #include "common/mathutil.h" @@ -26,11 +25,6 @@ bool ValidateES3TexImageParameters(gl::Context *context, GLenum target, GLint le 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)) - { - return gl::error(GL_INVALID_ENUM, false); - } - // Validate image size if (!ValidImageSize(context, target, level, width, height, depth)) { @@ -43,14 +37,6 @@ bool ValidateES3TexImageParameters(gl::Context *context, GLenum target, GLint le return gl::error(GL_INVALID_VALUE, false); } - if (xoffset < 0 || yoffset < 0 || zoffset < 0 || - std::numeric_limits::max() - xoffset < width || - std::numeric_limits::max() - yoffset < height || - std::numeric_limits::max() - zoffset < depth) - { - return gl::error(GL_INVALID_VALUE, false); - } - gl::Texture *texture = NULL; bool textureCompressed = false; GLenum textureInternalFormat = GL_NONE; @@ -177,7 +163,7 @@ bool ValidateES3TexImageParameters(gl::Context *context, GLenum target, GLint le return gl::error(GL_INVALID_OPERATION, false); } - if (!gl::IsFormatCompressed(actualInternalFormat)) + if (!gl::IsFormatCompressed(actualInternalFormat, context->getClientVersion())) { return gl::error(GL_INVALID_ENUM, false); } @@ -189,16 +175,14 @@ bool ValidateES3TexImageParameters(gl::Context *context, GLenum target, GLint le } else { - // Note: dEQP 2013.4 expects an INVALID_VALUE error for TexImage3D with an invalid - // internal format. (dEQP-GLES3.functional.negative_api.texture.teximage3d) - if (!gl::IsValidInternalFormat(actualInternalFormat, context->getCaps().extensions, context->getClientVersion()) || - !gl::IsValidFormat(format, context->getCaps().extensions, context->getClientVersion()) || - !gl::IsValidType(type, context->getCaps().extensions, context->getClientVersion())) + if (!gl::IsValidInternalFormat(actualInternalFormat, context) || + !gl::IsValidFormat(format, context->getClientVersion()) || + !gl::IsValidType(type, context->getClientVersion())) { return gl::error(GL_INVALID_ENUM, false); } - if (!gl::IsValidFormatCombination(actualInternalFormat, format, type, context->getCaps().extensions, context->getClientVersion())) + if (!gl::IsValidFormatCombination(actualInternalFormat, format, type, context->getClientVersion())) { return gl::error(GL_INVALID_OPERATION, false); } @@ -260,10 +244,7 @@ bool ValidateES3TexImageParameters(gl::Context *context, GLenum target, GLint le size_t widthSize = static_cast(width); size_t heightSize = static_cast(height); size_t depthSize = static_cast(depth); - GLenum sizedFormat = gl::IsSizedInternalFormat(actualInternalFormat) ? actualInternalFormat - : gl::GetSizedInternalFormat(actualInternalFormat, type); - - size_t pixelBytes = static_cast(gl::GetPixelBytes(sizedFormat)); + size_t pixelBytes = static_cast(gl::GetPixelBytes(actualInternalFormat, context->getClientVersion())); if (!rx::IsUnsignedMultiplicationSafe(widthSize, heightSize) || !rx::IsUnsignedMultiplicationSafe(widthSize * heightSize, depthSize) || @@ -276,8 +257,7 @@ bool ValidateES3TexImageParameters(gl::Context *context, GLenum target, GLint le size_t copyBytes = widthSize * heightSize * depthSize * pixelBytes; size_t offset = reinterpret_cast(pixels); - if (!rx::IsUnsignedAdditionSafe(offset, copyBytes) || - ((offset + copyBytes) > static_cast(pixelUnpackBuffer->getSize()))) + if (!rx::IsUnsignedAdditionSafe(offset, copyBytes) || ((offset + copyBytes) > static_cast(pixelUnpackBuffer->size()))) { // Overflow past the end of the buffer return gl::error(GL_INVALID_OPERATION, false); @@ -293,7 +273,7 @@ bool ValidateES3TexImageParameters(gl::Context *context, GLenum target, GLint le } // ...the buffer object's data store is currently mapped. - if (pixelUnpackBuffer->isMapped()) + if (pixelUnpackBuffer->mapped()) { return gl::error(GL_INVALID_OPERATION, false); } @@ -303,15 +283,32 @@ bool ValidateES3TexImageParameters(gl::Context *context, GLenum target, GLint le } bool ValidateES3CopyTexImageParameters(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) + 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)) + if (!ValidTexture2DDestinationTarget(context, target)) { - return false; + return gl::error(GL_INVALID_ENUM, false); + } + + if (level < 0 || xoffset < 0 || yoffset < 0 || zoffset < 0 || width < 0 || height < 0) + { + return gl::error(GL_INVALID_VALUE, false); + } + + if (std::numeric_limits::max() - xoffset < width || std::numeric_limits::max() - yoffset < height) + { + return gl::error(GL_INVALID_VALUE, false); + } + + if (border != 0) + { + return gl::error(GL_INVALID_VALUE, false); + } + + if (!ValidMipLevel(context, target, level)) + { + return gl::error(GL_INVALID_VALUE, false); } gl::Framebuffer *framebuffer = context->getReadFramebuffer(); @@ -326,13 +323,124 @@ bool ValidateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin return gl::error(GL_INVALID_OPERATION, false); } - gl::FramebufferAttachment *source = framebuffer->getReadColorbuffer(); + gl::Renderbuffer *source = framebuffer->getReadColorbuffer(); GLenum colorbufferInternalFormat = source->getInternalFormat(); + gl::Texture *texture = NULL; + GLenum textureInternalFormat = GL_NONE; + bool textureCompressed = false; + bool textureIsDepth = false; + GLint textureLevelWidth = 0; + GLint textureLevelHeight = 0; + GLint textureLevelDepth = 0; + switch (target) + { + case GL_TEXTURE_2D: + { + gl::Texture2D *texture2d = context->getTexture2D(); + if (texture2d) + { + textureInternalFormat = texture2d->getInternalFormat(level); + textureCompressed = texture2d->isCompressed(level); + textureIsDepth = texture2d->isDepth(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: + { + gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); + if (textureCube) + { + textureInternalFormat = textureCube->getInternalFormat(target, level); + textureCompressed = textureCube->isCompressed(target, level); + textureIsDepth = false; + textureLevelWidth = textureCube->getWidth(target, level); + textureLevelHeight = textureCube->getHeight(target, level); + textureLevelDepth = 1; + texture = textureCube; + } + } + break; + + case GL_TEXTURE_2D_ARRAY: + { + gl::Texture2DArray *texture2dArray = context->getTexture2DArray(); + if (texture2dArray) + { + textureInternalFormat = texture2dArray->getInternalFormat(level); + textureCompressed = texture2dArray->isCompressed(level); + textureIsDepth = texture2dArray->isDepth(level); + textureLevelWidth = texture2dArray->getWidth(level); + textureLevelHeight = texture2dArray->getHeight(level); + textureLevelDepth = texture2dArray->getLayers(level); + texture = texture2dArray; + } + } + break; + + case GL_TEXTURE_3D: + { + gl::Texture3D *texture3d = context->getTexture3D(); + if (texture3d) + { + textureInternalFormat = texture3d->getInternalFormat(level); + textureCompressed = texture3d->isCompressed(level); + textureIsDepth = texture3d->isDepth(level); + textureLevelWidth = texture3d->getWidth(level); + textureLevelHeight = texture3d->getHeight(level); + textureLevelDepth = texture3d->getDepth(level); + texture = texture3d; + } + } + break; + + default: + return gl::error(GL_INVALID_ENUM, false); + } + + if (!texture) + { + return gl::error(GL_INVALID_OPERATION, false); + } + + if (texture->isImmutable() && !isSubImage) + { + return gl::error(GL_INVALID_OPERATION, false); + } + + if (textureIsDepth) + { + return gl::error(GL_INVALID_OPERATION, false); + } + + if (textureCompressed) + { + if ((width % 4 != 0 && width != textureLevelWidth) || + (height % 4 != 0 && height != textureLevelHeight)) + { + return gl::error(GL_INVALID_OPERATION, false); + } + } if (isSubImage) { - if (!gl::IsValidCopyTexImageCombination(textureInternalFormat, colorbufferInternalFormat, - context->getReadFramebufferHandle(), + if (xoffset + width > textureLevelWidth || + yoffset + height > textureLevelHeight || + zoffset >= textureLevelDepth) + { + return gl::error(GL_INVALID_VALUE, false); + } + + if (!gl::IsValidCopyTexImageCombination(textureInternalFormat, colorbufferInternalFormat, context->getReadFramebufferHandle(), context->getClientVersion())) { return gl::error(GL_INVALID_OPERATION, false); @@ -340,14 +448,15 @@ bool ValidateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin } else { - if (!gl::IsValidCopyTexImageCombination(internalformat, colorbufferInternalFormat, - context->getReadFramebufferHandle(), + if (!gl::IsValidCopyTexImageCombination(internalformat, colorbufferInternalFormat, context->getReadFramebufferHandle(), context->getClientVersion())) { return gl::error(GL_INVALID_OPERATION, false); } } + + // If width or height is zero, it is a no-op. Return false without setting an error. return (width > 0 && height > 0); } @@ -436,12 +545,12 @@ bool ValidateES3TexStorageParameters(gl::Context *context, GLenum target, GLsize return gl::error(GL_INVALID_OPERATION, false); } - if (!gl::IsValidInternalFormat(internalformat, context->getCaps().extensions, context->getClientVersion())) + if (!gl::IsValidInternalFormat(internalformat, context)) { return gl::error(GL_INVALID_ENUM, false); } - if (!gl::IsSizedInternalFormat(internalformat)) + if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion())) { return gl::error(GL_INVALID_ENUM, false); } @@ -636,7 +745,7 @@ bool ValidES3ReadFormatType(gl::Context *context, GLenum internalFormat, GLenum } break; case GL_FLOAT: - if (gl::GetComponentType(internalFormat) != GL_FLOAT) + if (gl::GetComponentType(internalFormat, 3) != GL_FLOAT) { return false; } @@ -649,13 +758,13 @@ bool ValidES3ReadFormatType(gl::Context *context, GLenum internalFormat, GLenum switch (type) { case GL_INT: - if (gl::GetComponentType(internalFormat) != GL_INT) + if (gl::GetComponentType(internalFormat, 3) != GL_INT) { return false; } break; case GL_UNSIGNED_INT: - if (gl::GetComponentType(internalFormat) != GL_UNSIGNED_INT) + if (gl::GetComponentType(internalFormat, 3) != GL_UNSIGNED_INT) { return false; } @@ -677,7 +786,7 @@ bool ValidES3ReadFormatType(gl::Context *context, GLenum internalFormat, GLenum break; case GL_RG_EXT: case GL_RED_EXT: - if (!context->getCaps().extensions.textureRG) + if (!context->supportsRGTextures()) { return false; } @@ -756,20 +865,4 @@ bool ValidateInvalidateFramebufferParameters(gl::Context *context, GLenum target return true; } -bool ValidateClearBuffer(const gl::Context *context) -{ - if (context->getClientVersion() < 3) - { - return gl::error(GL_INVALID_OPERATION, false); - } - - const gl::Framebuffer *fbo = context->getDrawFramebuffer(); - if (!fbo || fbo->completeness() != GL_FRAMEBUFFER_COMPLETE) - { - return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); - } - - return true; -} - } diff --git a/gfx/angle/src/libGLESv2/validationES3.h b/gfx/angle/src/libGLESv2/validationES3.h index 11c143d35eea..93917c26bae2 100644 --- a/gfx/angle/src/libGLESv2/validationES3.h +++ b/gfx/angle/src/libGLESv2/validationES3.h @@ -34,8 +34,6 @@ bool ValidES3ReadFormatType(gl::Context *context, GLenum internalFormat, GLenum bool ValidateInvalidateFramebufferParameters(gl::Context *context, GLenum target, GLsizei numAttachments, const GLenum* attachments); -bool ValidateClearBuffer(const gl::Context *context); - } #endif // LIBGLESV2_VALIDATION_ES3_H