Bug 1036068 - Update ANGLE to chromium/2084. r=jgilbert,kamidphish

This commit is contained in:
Walter Litwinczyk 2014-09-09 14:47:31 -07:00
Родитель c69a596dda
Коммит a8b2fc07ec
285 изменённых файлов: 9973 добавлений и 9803 удалений

638
gfx/angle/BUILD.gn Normal file
Просмотреть файл

@ -0,0 +1,638 @@
# 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

Просмотреть файл

@ -17,8 +17,11 @@ 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.
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:
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
@ -33,3 +36,13 @@ 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.

Просмотреть файл

@ -1,11 +1,12 @@
/* -*- 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) $
*/
#ifndef __egl_h_
#define __egl_h_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2007-2009 The Khronos Group Inc.
** Copyright (c) 2013-2014 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
@ -26,304 +27,272 @@
** 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 <EGL/eglplatform.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Generated on date 20140610 */
/* EGL Types */
/* EGLint is defined in eglplatform.h */
/* Generated C header for:
* API: egl
* Versions considered: .*
* Versions emitted: .*
* Default extensions included: None
* Additional extensions included: _nomatch_^
* Extensions removed: _nomatch_^
*/
#ifndef EGL_VERSION_1_0
#define EGL_VERSION_1_0 1
typedef unsigned int EGLBoolean;
typedef unsigned int EGLenum;
typedef void *EGLConfig;
typedef void *EGLContext;
typedef void *EGLDisplay;
#include <KHR/khrplatform.h>
#include <EGL/eglplatform.h>
typedef void *EGLConfig;
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.
*/
/* 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 *EGLContext;
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 */
/* Now, define eglGetProcAddress using the generic function ptr. type */
EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY
eglGetProcAddress(const char *procname);
#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 */
#ifdef __cplusplus
}
#endif
#endif /* __egl_h_ */
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -2,7 +2,7 @@
#define __eglplatform_h_
/*
** Copyright (c) 2007-2009 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
@ -25,7 +25,7 @@
*/
/* Platform-specific types and definitions for egl.h
* $Revision: 12306 $ on $Date: 2010-08-25 12:51:28 -0400 (Wed, 25 Aug 2010) $
* $Revision: 23432 $ on $Date: 2013-10-09 00:57:24 -0700 (Wed, 09 Oct 2013) $
*
* 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,6 +83,16 @@ typedef int EGLNativeDisplayType;
typedef void *EGLNativeWindowType;
typedef void *EGLNativePixmapType;
#elif defined(__ANDROID__) || defined(ANDROID)
#include <android/native_window.h>
struct egl_native_pixmap_t;
typedef struct ANativeWindow* EGLNativeWindowType;
typedef struct egl_native_pixmap_t* EGLNativePixmapType;
typedef void* EGLNativeDisplayType;
#elif defined(__unix__)
/* X11 (tentative) */

0
gfx/angle/include/KHR/khrplatform.h Normal file → Executable file
Просмотреть файл

Просмотреть файл

@ -0,0 +1,23 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// 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_

Просмотреть файл

@ -7,6 +7,7 @@ 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',
@ -54,6 +55,7 @@ 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',
@ -63,7 +65,9 @@ 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',
@ -75,26 +79,6 @@ 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']:

Просмотреть файл

@ -7,6 +7,12 @@
{
'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%': '<!(python <(angle_id_script_base) check ..)',
},
'includes':
[
@ -23,57 +29,71 @@
'copies':
[
{
'destination': '<(SHARED_INTERMEDIATE_DIR)',
'files': [ 'commit_id.bat', 'copy_compiler_dll.bat', 'commit_id.py' ],
'destination': '<(angle_gen_path)',
'files': [ 'copy_compiler_dll.bat', '<(angle_id_script_base)' ],
},
],
},
{
'target_name': 'commit_id',
'type': 'none',
'includes': [ '../build/common_defines.gypi', ],
'dependencies': [ 'copy_scripts', ],
'conditions':
[
['OS=="win"',
{
'actions':
[
{
'action_name': 'Generate Commit ID Header',
'message': 'Generating commit ID header...',
'msvs_cygwin_shell': 0,
'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/commit_id.bat', '<(angle_path)/.git/index' ],
'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/commit.h' ],
'action': [ '<(SHARED_INTERMEDIATE_DIR)/commit_id.bat', '<(SHARED_INTERMEDIATE_DIR)' ],
},
],
},
{ # OS != win
'actions':
[
{
'action_name': 'Generate Commit ID Header',
'message': 'Generating commit ID header...',
'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/commit_id.py', '<(angle_path)/.git/index' ],
'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/commit.h' ],
'action': [ 'python', '<(SHARED_INTERMEDIATE_DIR)/commit_id.py', '<(SHARED_INTERMEDIATE_DIR)/commit.h' ],
},
],
}],
],
'direct_dependent_settings':
{
'include_dirs':
[
'<(SHARED_INTERMEDIATE_DIR)',
],
},
},
],
'conditions':
[
['angle_use_commit_id!=0',
{
'targets':
[
{
'target_name': 'commit_id',
'type': 'none',
'includes': [ '../build/common_defines.gypi', ],
'dependencies': [ 'copy_scripts', ],
'actions':
[
{
'action_name': 'Generate ANGLE Commit ID Header',
'message': 'Generating ANGLE Commit ID',
# reference the git index as an input, so we rebuild on changes to the index
'inputs': [ '<(angle_id_script)', '<(angle_path)/.git/index' ],
'outputs': [ '<(angle_id_header)' ],
'msvs_cygwin_shell': 0,
'action':
[
'python', '<(angle_id_script)', 'gen', '<(angle_path)', '<(angle_id_header)'
],
},
],
'direct_dependent_settings':
{
'include_dirs':
[
'<(angle_gen_path)',
],
},
}
]
},
{ # angle_use_commit_id==0
'targets':
[
{
'target_name': 'commit_id',
'type': 'none',
'copies':
[
{
'destination': '<(angle_gen_path)/id',
'files': [ '<(angle_id_header_base)' ]
}
],
'direct_dependent_settings':
{
'include_dirs':
[
'<(angle_gen_path)',
],
},
}
]
}],
['OS=="win"',
{
'targets':
@ -90,10 +110,10 @@
'message': 'Copying D3D Compiler DLL...',
'msvs_cygwin_shell': 0,
'inputs': [ 'copy_compiler_dll.bat' ],
'outputs': [ '<(PRODUCT_DIR)/D3DCompiler_46.dll' ],
'outputs': [ '<(PRODUCT_DIR)/d3dcompiler_46.dll' ],
'action':
[
"<(SHARED_INTERMEDIATE_DIR)/copy_compiler_dll.bat",
"<(angle_gen_path)/copy_compiler_dll.bat",
"$(PlatformName)",
"<(windows_sdk_path)",
"<(PRODUCT_DIR)"

Просмотреть файл

@ -1,3 +1,3 @@
#define ANGLE_COMMIT_HASH "f2c46459366d"
#define ANGLE_COMMIT_HASH_SIZE 12
#define ANGLE_COMMIT_DATE "2014-07-04 09:58:21 -0400"
#define ANGLE_COMMIT_HASH "1adcf82f4713"
#define ANGLE_COMMIT_HASH_SIZE 12
#define ANGLE_COMMIT_DATE "2014-09-09 10:32:27 -0700"

Просмотреть файл

@ -1,15 +0,0 @@
@echo off
REM commit hash
(FOR /F "delims=" %%i IN ('call git rev-parse --short^=12 HEAD') DO set _Str=%%i) || (set _Str=badf00dbad00)
set _Str=#define ANGLE_COMMIT_HASH "%_Str%"
echo %_Str% > %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

Просмотреть файл

@ -1,19 +1,35 @@
import subprocess as sp
import sys
import os
def grab_output(*command):
return sp.Popen(command, stdout=sp.PIPE).communicate()[0].strip()
# Usage: commit_id.py check <angle_dir> (checks if git is present)
# Usage: commit_id.py gen <angle_dir> <file_to_write> (generates commit id)
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' % commit_id_size, 'HEAD')
commit_date = grab_output('git', 'show', '-s', '--format=%ci', 'HEAD')
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)
except:
commit_id = 'invalid-hash'
commit_date = 'invalid-date'
hfile = open(sys.argv[1], 'w')
hfile = open(output_file, 'w')
hfile.write('#define ANGLE_COMMIT_HASH "%s"\n' % commit_id)
hfile.write('#define ANGLE_COMMIT_HASH_SIZE %d\n' % commit_id_size)

Просмотреть файл

@ -14,8 +14,7 @@
#include <cstddef>
#include <GLES3/gl3.h>
#include <GLES2/gl2.h>
#include "angle_gl.h"
#include "common/debug.h"
@ -62,33 +61,6 @@ class BindingPointer : public RefCountObjectBindingPointer
ObjectType *operator->() const { return get(); }
};
template <class ObjectType>
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<ObjectType*>(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 ObjectType>
class OffsetBindingPointer : public RefCountObjectBindingPointer
{

Просмотреть файл

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@ -9,7 +9,11 @@
#ifndef COMMON_ANGLEUTILS_H_
#define COMMON_ANGLEUTILS_H_
#include "common/platform.h"
#include <stddef.h>
#include <string>
#include <set>
// A macro to disallow the copy constructor and operator= functions
// This must be used in the private: declarations for a class
@ -60,6 +64,16 @@ void SafeDelete(T*& resource)
resource = NULL;
}
template <typename T>
void SafeDeleteContainer(T& resource)
{
for (typename T::iterator i = resource.begin(); i != resource.end(); i++)
{
SafeDelete(*i);
}
resource.clear();
}
template <typename T>
void SafeDeleteArray(T*& resource)
{
@ -89,6 +103,18 @@ inline void StructZero(T *obj)
memset(obj, 0, sizeof(T));
}
inline const char* MakeStaticString(const std::string &str)
{
static std::set<std::string> strings;
std::set<std::string>::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

Просмотреть файл

@ -12,7 +12,7 @@
#include "common/mathutil.h"
#include "common/utilities.h"
namespace gl
namespace sh
{
BlockLayoutEncoder::BlockLayoutEncoder(std::vector<BlockMemberInfo> *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::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent);
ASSERT(gl::VariableComponentSize(gl::VariableComponentType(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::UniformComponentCount(type);
const int numComponents = gl::VariableComponentCount(type);
baseAlignment = (numComponents == 3 ? 4u : static_cast<size_t>(numComponents));
}
@ -151,7 +151,7 @@ void Std140BlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool
}
else
{
mCurrentOffset += gl::UniformComponentCount(type);
mCurrentOffset += gl::VariableComponentCount(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::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent);
ASSERT(gl::VariableComponentSize(gl::VariableComponentType(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::UniformComponentCount(type);
int numComponents = gl::VariableComponentCount(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::UniformComponentCount(type);
mCurrentOffset += gl::VariableComponentCount(type);
}
else
{
@ -245,8 +245,8 @@ void HLSLBlockEncoder::skipRegisters(unsigned int numRegisters)
mCurrentOffset += (numRegisters * ComponentsPerRegister);
}
void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, gl::Uniform *variable, HLSLBlockEncoder *encoder,
const std::vector<gl::BlockMemberInfo> &blockInfo, ShShaderOutput outputType)
void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable, HLSLBlockEncoder *encoder,
const std::vector<BlockMemberInfo> &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, gl::Uniform *va
}
}
void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, gl::Uniform *variable, ShShaderOutput outputType)
void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable, ShShaderOutput outputType)
{
std::vector<BlockMemberInfo> blockInfo;
HLSLBlockEncoder encoder(&blockInfo,

Просмотреть файл

@ -11,14 +11,12 @@
#define COMMON_BLOCKLAYOUT_H_
#include <vector>
#include <GLES3/gl3.h>
#include <GLES2/gl2.h>
#include "angle_gl.h"
#include <GLSLANG/ShaderLang.h>
#include <cstddef>
namespace gl
namespace sh
{
struct ShaderVariable;
struct InterfaceBlockField;
struct BlockMemberInfo;
@ -69,7 +67,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 constnat blocks, and ENCODE_PACKED
// The strategy should be ENCODE_LOOSE for D3D9 constant blocks, and ENCODE_PACKED
// for everything else (D3D10+ constant blocks and all attributes/varyings).
class HLSLBlockEncoder : public BlockLayoutEncoder

Просмотреть файл

@ -7,15 +7,13 @@
// debug.cpp: Debugging utilities.
#include "common/debug.h"
#include "common/platform.h"
#include <stdarg.h>
#include <vector>
#include <fstream>
#include <cstdio>
#if defined(ANGLE_ENABLE_PERF)
#include <d3d9.h>
#endif
namespace gl
{
#if defined(ANGLE_ENABLE_PERF)

Просмотреть файл

@ -83,6 +83,12 @@ 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

Просмотреть файл

@ -5,12 +5,14 @@
#ifndef COMMON_EVENT_TRACER_H_
#define COMMON_EVENT_TRACER_H_
#include "common/platform.h"
#if !defined(TRACE_ENTRY)
#if defined(_WIN32)
#define TRACE_ENTRY __stdcall
#else
#define TRACE_ENTRY
#endif // // _WIN32
# ifdef ANGLE_PLATFORM_WINDOWS
# define TRACE_ENTRY __stdcall
# else
# define TRACE_ENTRY
# endif // ANGLE_PLATFORM_WINDOWS
#endif //TRACE_ENTRY
extern "C" {

Просмотреть файл

@ -10,10 +10,7 @@
#define LIBGLESV2_MATHUTIL_H_
#include "common/debug.h"
#if defined(_WIN32)
#include <intrin.h>
#endif
#include "common/platform.h"
#include <limits>
#include <algorithm>
@ -112,7 +109,7 @@ inline unsigned int unorm(float x)
inline bool supportsSSE2()
{
#if defined(_WIN32)
#ifdef ANGLE_PLATFORM_WINDOWS
static bool checked = false;
static bool supports = false;

Просмотреть файл

@ -0,0 +1,67 @@
//
// 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 <windows.h>
# include <intrin.h>
# if defined(ANGLE_ENABLE_D3D9) || defined(ANGLE_ENABLE_PERF)
# include <d3d9.h>
# include <d3dcompiler.h>
# endif
# if defined(ANGLE_ENABLE_D3D11)
# include <d3d10_1.h>
# include <d3d11.h>
# include <dxgi.h>
# include <dxgi1_2.h>
# include <d3dcompiler.h>
# endif
# undef near
# undef far
#endif
#endif // COMMON_PLATFORM_H_

Просмотреть файл

@ -13,13 +13,14 @@
#include <string>
#include <vector>
#include <algorithm>
#include "GLSLANG/ShaderLang.h"
#include <GLES3/gl3.h>
#include <GLES2/gl2.h>
namespace gl
namespace sh
{
// GLenum alias
typedef unsigned int GLenum;
// Varying interpolation qualifier, see section 4.3.9 of the ESSL 3.00.4 spec
enum InterpolationType
{
@ -39,105 +40,115 @@ enum BlockLayoutType
// Base class for all variables defined in shaders, including Varyings, Uniforms, etc
struct ShaderVariable
{
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)
: 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;
};
// 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<Uniform> 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<Uniform> 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(GL_NONE, GL_NONE, "", 0),
location(-1)
: ShaderVariable((GLenum)0, (GLenum)0, "", 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<InterfaceBlockField> 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<InterfaceBlockField> fields;
};
struct Varying : public ShaderVariable
{
InterpolationType interpolation;
std::vector<Varying> fields;
std::string structName;
Varying(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, InterpolationType interpolationIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
interpolation(interpolationIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
interpolation(interpolationIn)
{}
bool isStruct() const { return !fields.empty(); }
InterpolationType interpolation;
std::vector<Varying> fields;
std::string structName;
};
struct BlockMemberInfo
{
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)
{}
static BlockMemberInfo getDefaultBlockInfo()
{
return BlockMemberInfo(-1, -1, -1, false);
}
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;
};
typedef std::vector<BlockMemberInfo> 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;
@ -146,15 +157,8 @@ struct InterfaceBlock
std::vector<InterfaceBlockField> fields;
std::vector<BlockMemberInfo> 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)
{}
};
}

Просмотреть файл

@ -0,0 +1,74 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// tls.cpp: Simple cross-platform interface for thread local storage.
#include "common/tls.h"
#include <assert.h>
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
}

Просмотреть файл

@ -0,0 +1,33 @@
//
// 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 <pthread.h>
# include <semaphore.h>
# include <errno.h>
typedef pthread_key_t TLSIndex;
# define TLS_INVALID_INDEX (static_cast<TLSIndex>(-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_

Просмотреть файл

@ -8,17 +8,14 @@
#include "common/utilities.h"
#include "common/mathutil.h"
#if defined(_WIN32)
#include <windows.h>
#endif
#include "common/platform.h"
#include <set>
namespace gl
{
int UniformComponentCount(GLenum type)
int VariableComponentCount(GLenum type)
{
switch (type)
{
@ -78,7 +75,7 @@ int UniformComponentCount(GLenum type)
return 0;
}
GLenum UniformComponentType(GLenum type)
GLenum VariableComponentType(GLenum type)
{
switch(type)
{
@ -133,7 +130,7 @@ GLenum UniformComponentType(GLenum type)
return GL_NONE;
}
size_t UniformComponentSize(GLenum type)
size_t VariableComponentSize(GLenum type)
{
switch(type)
{
@ -147,18 +144,18 @@ size_t UniformComponentSize(GLenum type)
return 0;
}
size_t UniformInternalSize(GLenum type)
size_t VariableInternalSize(GLenum type)
{
// Expanded to 4-element vectors
return UniformComponentSize(UniformComponentType(type)) * VariableRowCount(type) * 4;
return VariableComponentSize(VariableComponentType(type)) * VariableRowCount(type) * 4;
}
size_t UniformExternalSize(GLenum type)
size_t VariableExternalSize(GLenum type)
{
return UniformComponentSize(UniformComponentType(type)) * UniformComponentCount(type);
return VariableComponentSize(VariableComponentType(type)) * VariableComponentCount(type);
}
GLenum UniformBoolVectorType(GLenum type)
GLenum VariableBoolVectorType(GLenum type)
{
switch (type)
{
@ -365,7 +362,7 @@ int MatrixComponentCount(GLenum type, bool isRowMajorMatrix)
return isRowMajorMatrix ? VariableColumnCount(type) : VariableRowCount(type);
}
int AttributeRegisterCount(GLenum type)
int VariableRegisterCount(GLenum type)
{
return IsMatrixType(type) ? VariableColumnCount(type) : 1;
}
@ -395,24 +392,6 @@ 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)
@ -436,7 +415,7 @@ bool IsTriangleMode(GLenum drawMode)
std::string getTempPath()
{
#if defined (_WIN32)
#ifdef ANGLE_PLATFORM_WINDOWS
char path[MAX_PATH];
DWORD pathLen = GetTempPathA(sizeof(path) / sizeof(path[0]), path);
if (pathLen == 0)

Просмотреть файл

@ -9,36 +9,31 @@
#ifndef LIBGLESV2_UTILITIES_H
#define LIBGLESV2_UTILITIES_H
#include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include "angle_gl.h"
#include <string>
#include <math.h>
namespace gl
{
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 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 VariableRowCount(GLenum type);
int VariableColumnCount(GLenum type);
bool IsSampler(GLenum type);
bool IsMatrixType(GLenum type);
GLenum TransposeMatrixType(GLenum type);
int AttributeRegisterCount(GLenum type);
int VariableRegisterCount(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);

Просмотреть файл

@ -28,18 +28,6 @@
-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':

0
gfx/angle/src/compiler/preprocessor/generate_parser.sh Normal file → Executable file
Просмотреть файл

Просмотреть файл

@ -5,6 +5,7 @@
//
#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"
@ -12,7 +13,6 @@
#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"

Просмотреть файл

@ -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.
//

Просмотреть файл

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@ -18,6 +18,67 @@ public:
type = EbtVoid;
}
bool cast(TBasicType newType, const ConstantUnion &constant)
{
switch (newType)
{
case EbtFloat:
switch (constant.type)
{
case EbtInt: setFConst(static_cast<float>(constant.getIConst())); break;
case EbtUInt: setFConst(static_cast<float>(constant.getUConst())); break;
case EbtBool: setFConst(static_cast<float>(constant.getBConst())); break;
case EbtFloat: setFConst(static_cast<float>(constant.getFConst())); break;
default: return false;
}
break;
case EbtInt:
switch (constant.type)
{
case EbtInt: setIConst(static_cast<int>(constant.getIConst())); break;
case EbtUInt: setIConst(static_cast<int>(constant.getUConst())); break;
case EbtBool: setIConst(static_cast<int>(constant.getBConst())); break;
case EbtFloat: setIConst(static_cast<int>(constant.getFConst())); break;
default: return false;
}
break;
case EbtUInt:
switch (constant.type)
{
case EbtInt: setUConst(static_cast<unsigned int>(constant.getIConst())); break;
case EbtUInt: setUConst(static_cast<unsigned int>(constant.getUConst())); break;
case EbtBool: setUConst(static_cast<unsigned int>(constant.getBConst())); break;
case EbtFloat: setUConst(static_cast<unsigned int>(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; }

Просмотреть файл

@ -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;

Просмотреть файл

@ -8,7 +8,7 @@
#define _INITIALIZE_INCLUDED_
#include "compiler/translator/Common.h"
#include "compiler/translator/ShHandle.h"
#include "compiler/translator/Compiler.h"
#include "compiler/translator/SymbolTable.h"
void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &table);

Просмотреть файл

@ -5,10 +5,12 @@
//
#include "compiler/translator/InitializeDll.h"
#include "compiler/translator/InitializeGlobals.h"
#include "compiler/translator/InitializeParseContext.h"
#include "compiler/translator/osinclude.h"
#include "common/platform.h"
#include <assert.h>
bool InitProcess()
{

Просмотреть файл

@ -6,35 +6,37 @@
#include "compiler/translator/InitializeParseContext.h"
#include "compiler/translator/osinclude.h"
#include "common/tls.h"
OS_TLSIndex GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
#include <assert.h>
TLSIndex GlobalParseContextIndex = TLS_INVALID_INDEX;
bool InitializeParseContextIndex()
{
assert(GlobalParseContextIndex == OS_INVALID_TLS_INDEX);
assert(GlobalParseContextIndex == TLS_INVALID_INDEX);
GlobalParseContextIndex = OS_AllocTLSIndex();
return GlobalParseContextIndex != OS_INVALID_TLS_INDEX;
GlobalParseContextIndex = CreateTLSIndex();
return GlobalParseContextIndex != TLS_INVALID_INDEX;
}
void FreeParseContextIndex()
{
assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX);
assert(GlobalParseContextIndex != TLS_INVALID_INDEX);
OS_FreeTLSIndex(GlobalParseContextIndex);
GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
DestroyTLSIndex(GlobalParseContextIndex);
GlobalParseContextIndex = TLS_INVALID_INDEX;
}
void SetGlobalParseContext(TParseContext* context)
{
assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX);
OS_SetTLSValue(GlobalParseContextIndex, context);
assert(GlobalParseContextIndex != TLS_INVALID_INDEX);
SetTLSValue(GlobalParseContextIndex, context);
}
TParseContext* GetGlobalParseContext()
{
assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX);
return static_cast<TParseContext*>(OS_GetTLSValue(GlobalParseContextIndex));
assert(GlobalParseContextIndex != TLS_INVALID_INDEX);
return static_cast<TParseContext*>(GetTLSValue(GlobalParseContextIndex));
}

Просмотреть файл

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@ -78,26 +78,6 @@ 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";
@ -188,23 +168,9 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
default: break;
}
//
// 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;
}
if (left->getBasicType() != right->getBasicType())
{
return 0;
}
//
@ -241,19 +207,19 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
//
TIntermTyped* TIntermediate::addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc& line)
{
//
// Like adding binary math, except the conversion can only go
// from right to left.
//
if (left->getType().getStruct() || right->getType().getStruct())
{
if (left->getType() != right->getType())
{
return 0;
}
}
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(child);
node->setRight(right);
if (! node->promote(infoSink))
return 0;
@ -311,42 +277,6 @@ 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();
@ -409,140 +339,6 @@ 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.
@ -640,18 +436,9 @@ TIntermTyped* TIntermediate::addComma(TIntermTyped* left, TIntermTyped* right, c
//
TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc& line)
{
//
// 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;
if (trueBlock->getType() != falseBlock->getType())
{
return 0;
}
//
@ -1043,7 +830,9 @@ 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
@ -1724,104 +1513,6 @@ 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<float>(node->getIConst(i)));
break;
case EbtUInt:
leftUnionArray[i].setFConst(static_cast<float>(node->getUConst(i)));
break;
case EbtBool:
leftUnionArray[i].setFConst(static_cast<float>(node->getBConst(i)));
break;
case EbtFloat:
leftUnionArray[i].setFConst(static_cast<float>(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<int>(node->getIConst(i)));
break;
case EbtUInt:
leftUnionArray[i].setIConst(static_cast<int>(node->getUConst(i)));
break;
case EbtBool:
leftUnionArray[i].setIConst(static_cast<int>(node->getBConst(i)));
break;
case EbtFloat:
leftUnionArray[i].setIConst(static_cast<int>(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<unsigned int>(node->getIConst(i)));
break;
case EbtUInt:
leftUnionArray[i].setUConst(static_cast<unsigned int>(node->getUConst(i)));
break;
case EbtBool:
leftUnionArray[i].setUConst(static_cast<unsigned int>(node->getBConst(i)));
break;
case EbtFloat:
leftUnionArray[i].setUConst(static_cast<unsigned int>(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)
{

Просмотреть файл

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@ -55,8 +55,6 @@ TOutputGLSLBase::TOutputGLSLBase(TInfoSinkBase &objSink,
mSymbolTable(symbolTable),
mShaderVersion(shaderVersion)
{
// Set up global scope.
mDeclaredStructs.push_back(ScopedDeclaredStructs());
}
void TOutputGLSLBase::writeTriplet(
@ -89,8 +87,14 @@ void TOutputGLSLBase::writeVariableType(const TType &type)
// Declare the struct if we have not done so already.
if (type.getBasicType() == EbtStruct && !structDeclared(type.getStruct()))
{
declareStruct(type.getStruct());
mDeclaredStructs[mDeclaredStructs.size() - 1].push_back(type.getStruct());
TStructure *structure = type.getStruct();
declareStruct(structure);
if (!structure->name().empty())
{
mDeclaredStructs.insert(structure->uniqueId());
}
}
else
{
@ -398,67 +402,6 @@ 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;
@ -604,7 +547,6 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node)
if (depth > 0)
{
out << "{\n";
pushDeclaredStructsScope();
}
incrementDepth(node);
@ -623,7 +565,6 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node)
// Scope the sequences except when at the global scope.
if (depth > 0)
{
popDeclaredStructsScope();
out << "}\n";
}
visitChildren = false;
@ -1035,17 +976,12 @@ TString TOutputGLSLBase::hashFunctionName(const TString &mangled_name)
bool TOutputGLSLBase::structDeclared(const TStructure *structure) const
{
ASSERT(structure);
ASSERT(mDeclaredStructs.size() > 0);
for (size_t ii = mDeclaredStructs.size(); ii > 0; --ii)
if (structure->name().empty())
{
const ScopedDeclaredStructs &scope = mDeclaredStructs[ii - 1];
for (size_t jj = 0; jj < scope.size(); ++jj)
{
if (scope[jj]->equals(*structure))
return true;
}
return false;
}
return false;
return (mDeclaredStructs.count(structure->uniqueId()) > 0);
}
void TOutputGLSLBase::declareStruct(const TStructure *structure)
@ -1067,14 +1003,3 @@ 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();
}

Просмотреть файл

@ -7,7 +7,7 @@
#ifndef CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_
#define CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_
#include <vector>
#include <set>
#include "compiler/translator/intermediate.h"
#include "compiler/translator/LoopInfo.h"
@ -56,22 +56,14 @@ 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;
// 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<TStructure *> 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<ScopedDeclaredStructs> DeclaredStructs;
DeclaredStructs mDeclaredStructs;
// This set contains all the ids of the structs from every scope.
std::set<int> mDeclaredStructs;
// Stack of loops that need to be unrolled.
TLoopStack mLoopUnrollStack;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -11,9 +11,7 @@
#include <set>
#include <map>
#include <GLES3/gl3.h>
#include <GLES2/gl2.h>
#include "angle_gl.h"
#include "compiler/translator/intermediate.h"
#include "compiler/translator/ParseContext.h"
#include "common/shadervars.h"
@ -21,6 +19,10 @@
namespace sh
{
class UnfoldShortCircuit;
class StructureHLSL;
class UniformHLSL;
typedef std::map<TString, TIntermSymbol*> ReferencedSymbols;
class OutputHLSL : public TIntermTraverser
{
@ -31,24 +33,13 @@ class OutputHLSL : public TIntermTraverser
void output();
TInfoSinkBase &getBodyStream();
const std::vector<gl::Uniform> &getUniforms();
const std::vector<gl::InterfaceBlock> &getInterfaceBlocks() const;
const std::vector<gl::Attribute> &getOutputVariables() const;
const std::vector<gl::Attribute> &getAttributes() const;
const std::vector<gl::Varying> &getVaryings() const;
const std::vector<sh::Uniform> &getUniforms();
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const;
const std::vector<sh::Attribute> &getOutputVariables() const;
const std::vector<sh::Attribute> &getAttributes() const;
const std::vector<sh::Varying> &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();
@ -71,13 +62,9 @@ class OutputHLSL : public TIntermTraverser
TString argumentString(const TIntermSymbol *symbol);
int vectorSize(const TType &type) const;
void addConstructor(const TType &type, const TString &name, const TIntermSequence *parameters);
void outputConstructor(Visit visit, 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;
@ -88,13 +75,15 @@ class OutputHLSL : public TIntermTraverser
TInfoSinkBase mBody;
TInfoSinkBase mFooter;
typedef std::map<TString, TIntermSymbol*> ReferencedSymbols;
ReferencedSymbols mReferencedUniforms;
ReferencedSymbols mReferencedInterfaceBlocks;
ReferencedSymbols mReferencedAttributes;
ReferencedSymbols mReferencedVaryings;
ReferencedSymbols mReferencedOutputVariables;
StructureHLSL *mStructureHLSL;
UniformHLSL *mUniformHLSL;
struct TextureFunction
{
enum Method
@ -153,19 +142,6 @@ class OutputHLSL : public TIntermTraverser
int mNumRenderTargets;
typedef std::set<TString> Constructors;
Constructors mConstructors;
typedef std::set<TString> StructNames;
StructNames mStructNames;
typedef std::list<TString> StructDeclarations;
StructDeclarations mStructDeclarations;
typedef std::vector<int> ScopeBracket;
ScopeBracket mScopeBracket;
unsigned int mScopeDepth;
int mUniqueIndex; // For creating unique names
bool mContainsLoopDiscontinuity;
@ -175,51 +151,19 @@ class OutputHLSL : public TIntermTraverser
TIntermSymbol *mExcessiveLoopIndex;
int mUniformRegister;
int mInterfaceBlockRegister;
int mSamplerRegister;
int mPaddingCounter;
void declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector<sh::Varying>& fieldsOut);
TString registerString(TIntermSymbol *operand);
int samplerRegister(TIntermSymbol *sampler);
int uniformRegister(TIntermSymbol *uniform);
void declareInterfaceBlockField(const TType &type, const TString &name, std::vector<gl::InterfaceBlockField>& output);
gl::Uniform declareUniformToList(const TType &type, const TString &name, int registerIndex, std::vector<gl::Uniform>& output);
void declareUniform(const TType &type, const TString &name, int index);
void declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector<gl::Varying>& 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<gl::Uniform> mActiveUniforms;
std::vector<gl::InterfaceBlock> mActiveInterfaceBlocks;
std::vector<gl::Attribute> mActiveOutputVariables;
std::vector<gl::Attribute> mActiveAttributes;
std::vector<gl::Varying> mActiveVaryings;
std::map<TString, int> mStd140StructElementIndexes;
std::vector<sh::Attribute> mActiveOutputVariables;
std::vector<sh::Attribute> mActiveAttributes;
std::vector<sh::Varying> mActiveVaryings;
std::map<TIntermTyped*, TString> mFlaggedStructMappedNames;
std::map<TIntermTyped*, TString> mFlaggedStructOriginalNames;
void makeFlaggedStructMaps(const std::vector<TIntermTyped *> &flaggedStructs);
};
}
#endif // COMPILER_OUTPUTHLSL_H_

Просмотреть файл

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@ -701,28 +701,44 @@ bool TParseContext::arraySizeErrorCheck(const TSourceLoc& line, TIntermTyped* ex
return true;
}
unsigned int unsignedSize = 0;
if (constant->getBasicType() == EbtUInt)
{
unsigned int uintSize = constant->getUConst(0);
if (uintSize > static_cast<unsigned int>(std::numeric_limits<int>::max()))
{
error(line, "array size too large", "");
size = 1;
return true;
}
size = static_cast<int>(uintSize);
unsignedSize = constant->getUConst(0);
size = static_cast<int>(unsignedSize);
}
else
{
size = constant->getIConst(0);
if (size <= 0)
if (size < 0)
{
error(line, "array size must be a positive integer", "");
error(line, "array size must be non-negative", "");
size = 1;
return true;
}
unsignedSize = static_cast<unsigned int>(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;
@ -788,7 +804,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;
@ -868,7 +884,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;
@ -1050,7 +1066,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
@ -1515,81 +1531,40 @@ TFunction *TParseContext::addConstructorFunc(TPublicType publicType)
//
// Returns 0 for an error or the constructed node (aggregate or typed) for no error.
//
TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type, TOperator op, TFunction* fnCall, const TSourceLoc& line)
TIntermTyped *TParseContext::addConstructor(TIntermNode *arguments, const TType *type, TOperator op, TFunction *fnCall, const TSourceLoc &line)
{
if (node == 0)
return 0;
TIntermAggregate *aggregateArguments = arguments->getAsAggregate();
if (!aggregateArguments)
{
aggregateArguments = new TIntermAggregate;
aggregateArguments->getSequence().push_back(arguments);
}
TIntermAggregate* aggrNode = node->getAsAggregate();
TFieldList::const_iterator memberTypes;
if (op == EOpConstructStruct)
memberTypes = type->getStruct()->fields().begin();
TType elementType = *type;
if (type->isArray())
elementType.clearArrayness();
{
const TFieldList &fields = type->getStruct()->fields();
TIntermSequence &args = aggregateArguments->getSequence();
bool singleArg;
if (aggrNode) {
if (aggrNode->getOp() != EOpNull || aggrNode->getSequence().size() == 1)
singleArg = true;
else
singleArg = false;
} else
singleArg = true;
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();
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;
return 0;
}
}
}
TIntermTyped* constructor = intermediate.setAggregateOperator(aggrNode, op, line);
TIntermTyped* constConstructor = foldConstConstructor(constructor->getAsAggregate(), *type);
// Turn the argument list itself into a constructor
TIntermTyped *constructor = intermediate.setAggregateOperator(aggregateArguments, op, line);
TIntermTyped *constConstructor = foldConstConstructor(constructor->getAsAggregate(), *type);
if (constConstructor)
{
return constConstructor;
}
return constructor;
}
@ -1616,102 +1591,6 @@ 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
@ -1895,7 +1774,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();
}
@ -1975,7 +1854,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();
}
@ -1987,7 +1866,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();
}
@ -2567,6 +2446,8 @@ 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))
@ -2574,7 +2455,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();
}

Просмотреть файл

@ -1,15 +1,15 @@
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#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,8 +133,6 @@ 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);

Просмотреть файл

@ -6,43 +6,44 @@
#include "compiler/translator/PoolAlloc.h"
#ifndef _MSC_VER
#include <stdint.h>
#endif
#include <stdio.h>
#include "common/angleutils.h"
#include "compiler/translator/InitializeGlobals.h"
#include "compiler/translator/osinclude.h"
OS_TLSIndex PoolIndex = OS_INVALID_TLS_INDEX;
#include "common/platform.h"
#include "common/angleutils.h"
#include "common/tls.h"
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
TLSIndex PoolIndex = TLS_INVALID_INDEX;
bool InitializePoolIndex()
{
assert(PoolIndex == OS_INVALID_TLS_INDEX);
assert(PoolIndex == TLS_INVALID_INDEX);
PoolIndex = OS_AllocTLSIndex();
return PoolIndex != OS_INVALID_TLS_INDEX;
PoolIndex = CreateTLSIndex();
return PoolIndex != TLS_INVALID_INDEX;
}
void FreePoolIndex()
{
assert(PoolIndex != OS_INVALID_TLS_INDEX);
assert(PoolIndex != TLS_INVALID_INDEX);
OS_FreeTLSIndex(PoolIndex);
PoolIndex = OS_INVALID_TLS_INDEX;
DestroyTLSIndex(PoolIndex);
PoolIndex = TLS_INVALID_INDEX;
}
TPoolAllocator* GetGlobalPoolAllocator()
{
assert(PoolIndex != OS_INVALID_TLS_INDEX);
return static_cast<TPoolAllocator*>(OS_GetTLSValue(PoolIndex));
assert(PoolIndex != TLS_INVALID_INDEX);
return static_cast<TPoolAllocator*>(GetTLSValue(PoolIndex));
}
void SetGlobalPoolAllocator(TPoolAllocator* poolAllocator)
{
assert(PoolIndex != OS_INVALID_TLS_INDEX);
OS_SetTLSValue(PoolIndex, poolAllocator);
assert(PoolIndex != TLS_INVALID_INDEX);
SetTLSValue(PoolIndex, poolAllocator);
}
//

Просмотреть файл

@ -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"

Просмотреть файл

@ -0,0 +1,477 @@
//
// 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<TString, int> &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<TType> 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 &parameter = 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 &parameter = 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<size_t>(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<size_t>(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();
}
}

Просмотреть файл

@ -0,0 +1,74 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// 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 <set>
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<TString, int> &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<TString, int> &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<TString, int> mStd140StructElementIndexes;
typedef std::set<TString> StructNames;
StructNames mStructNames;
typedef std::set<TString> Constructors;
Constructors mConstructors;
typedef std::vector<TString> 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_

Просмотреть файл

@ -18,7 +18,7 @@
#include <stdio.h>
#include <algorithm>
int TSymbolTableLevel::uniqueId = 0;
int TSymbolTable::uniqueIdCounter = 0;
//
// Functions have buried pointers to delete.
@ -38,6 +38,25 @@ 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
@ -188,7 +207,7 @@ void TSymbolTable::insertBuiltIn(
}
}
insert(level, *function);
insert(level, function);
}
TPrecision TSymbolTable::getDefaultPrecision(TBasicType type)

Просмотреть файл

@ -185,7 +185,7 @@ class TFunction : public TSymbol
defined(false)
{
}
TFunction(const TString *name, TType &retType, TOperator tOp = EOpNull)
TFunction(const TString *name, const TType &retType, TOperator tOp = EOpNull)
: TSymbol(name),
returnType(retType),
mangledName(TFunction::mangleName(*name)),
@ -288,36 +288,15 @@ class TSymbolTableLevel
}
~TSymbolTableLevel();
bool insert(const TString &name, TSymbol &symbol)
{
symbol.setUniqueId(++uniqueId);
bool insert(TSymbol *symbol);
// 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;
}
TSymbol *find(const TString &name) const;
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
@ -371,12 +350,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);
}
@ -386,7 +365,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,
@ -429,6 +408,11 @@ class TSymbolTable
// for the specified TBasicType
TPrecision getDefaultPrecision(TBasicType type);
static int nextUniqueId()
{
return ++uniqueIdCounter;
}
private:
ESymbolLevel currentLevel() const
{
@ -438,6 +422,8 @@ class TSymbolTable
std::vector<TSymbolTableLevel *> table;
typedef TMap<TBasicType, TPrecision> PrecisionStackLevel;
std::vector< PrecisionStackLevel *> precisionStack;
static int uniqueIdCounter;
};
#endif // _SYMBOL_TABLE_INCLUDED_

Просмотреть файл

@ -7,7 +7,7 @@
#ifndef COMPILER_TRANSLATORESSL_H_
#define COMPILER_TRANSLATORESSL_H_
#include "compiler/translator/ShHandle.h"
#include "compiler/translator/Compiler.h"
class TranslatorESSL : public TCompiler {
public:

Просмотреть файл

@ -7,7 +7,7 @@
#ifndef COMPILER_TRANSLATORGLSL_H_
#define COMPILER_TRANSLATORGLSL_H_
#include "compiler/translator/ShHandle.h"
#include "compiler/translator/Compiler.h"
class TranslatorGLSL : public TCompiler {
public:

Просмотреть файл

@ -7,7 +7,7 @@
#ifndef COMPILER_TRANSLATORHLSL_H_
#define COMPILER_TRANSLATORHLSL_H_
#include "compiler/translator/ShHandle.h"
#include "compiler/translator/Compiler.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<gl::Uniform> &getUniforms() { return mActiveUniforms; }
const std::vector<gl::InterfaceBlock> &getInterfaceBlocks() const { return mActiveInterfaceBlocks; }
const std::vector<gl::Attribute> &getOutputVariables() { return mActiveOutputVariables; }
const std::vector<gl::Attribute> &getAttributes() { return mActiveAttributes; }
const std::vector<gl::Varying> &getVaryings() { return mActiveVaryings; }
const std::vector<sh::Uniform> &getUniforms() { return mActiveUniforms; }
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return mActiveInterfaceBlocks; }
const std::vector<sh::Attribute> &getOutputVariables() { return mActiveOutputVariables; }
const std::vector<sh::Attribute> &getAttributes() { return mActiveAttributes; }
const std::vector<sh::Varying> &getVaryings() { return mActiveVaryings; }
protected:
virtual void translate(TIntermNode* root);
std::vector<gl::Uniform> mActiveUniforms;
std::vector<gl::InterfaceBlock> mActiveInterfaceBlocks;
std::vector<gl::Attribute> mActiveOutputVariables;
std::vector<gl::Attribute> mActiveAttributes;
std::vector<gl::Varying> mActiveVaryings;
std::vector<sh::Uniform> mActiveUniforms;
std::vector<sh::InterfaceBlock> mActiveInterfaceBlocks;
std::vector<sh::Attribute> mActiveOutputVariables;
std::vector<sh::Attribute> mActiveAttributes;
std::vector<sh::Varying> mActiveVaryings;
};
#endif // COMPILER_TRANSLATORHLSL_H_

Просмотреть файл

@ -22,57 +22,9 @@ 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 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;
return (uniqueId() == other.uniqueId());
}
//

Просмотреть файл

@ -15,6 +15,7 @@
struct TPublicType;
class TType;
class TSymbol;
class TField
{
@ -47,8 +48,6 @@ class TField
return mLine;
}
bool equals(const TField &other) const;
private:
DISALLOW_COPY_AND_ASSIGN(TField);
TType *mType;
@ -99,8 +98,6 @@ class TFieldListCollection
size_t calculateObjectSize() const;
virtual TString mangledNamePrefix() const = 0;
bool equals(const TFieldListCollection &other) const;
const TString *mName;
TFieldList *mFields;
@ -115,7 +112,8 @@ class TStructure : public TFieldListCollection
POOL_ALLOCATOR_NEW_DELETE();
TStructure(const TString *name, TFieldList *fields)
: TFieldListCollection(name, fields),
mDeepestNesting(0)
mDeepestNesting(0),
mUniqueId(0)
{
}
@ -129,6 +127,17 @@ 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
@ -138,6 +147,7 @@ class TStructure : public TFieldListCollection
int calculateDeepestNesting() const;
mutable int mDeepestNesting;
int mUniqueId;
};
class TInterfaceBlock : public TFieldListCollection
@ -179,8 +189,6 @@ class TInterfaceBlock : public TFieldListCollection
return mMatrixPacking;
}
bool equals(const TInterfaceBlock &other) const;
private:
DISALLOW_COPY_AND_ASSIGN(TInterfaceBlock);
virtual TString mangledNamePrefix() const
@ -371,10 +379,6 @@ 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 &&

Просмотреть файл

@ -12,6 +12,7 @@
#include "compiler/translator/InfoSink.h"
#include "compiler/translator/OutputHLSL.h"
#include "compiler/translator/UtilsHLSL.h"
namespace sh
{
@ -117,7 +118,7 @@ bool UnfoldShortCircuit::visitSelection(Visit visit, TIntermSelection *node)
{
int i = mTemporaryIndex;
out << mOutputHLSL->typeString(node->getType()) << " s" << i << ";\n";
out << TypeString(node->getType()) << " s" << i << ";\n";
out << "{\n";

Просмотреть файл

@ -0,0 +1,391 @@
//
// 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<Uniform> *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 &registerString = 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<unsigned int>(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<InterfaceBlockField>& 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);
}
}
}

Просмотреть файл

@ -0,0 +1,58 @@
//
// 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<Uniform> &getUniforms() const { return mActiveUniforms; }
const std::vector<InterfaceBlock> &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<InterfaceBlockField>& output);
Uniform declareUniformToList(const TType &type, const TString &name, int registerIndex, std::vector<Uniform> *output);
unsigned int mUniformRegister;
unsigned int mInterfaceBlockRegister;
unsigned int mSamplerRegister;
StructureHLSL *mStructureHLSL;
ShShaderOutput mOutputType;
std::vector<Uniform> mActiveUniforms;
std::vector<InterfaceBlock> mActiveInterfaceBlocks;
};
}
#endif // TRANSLATOR_UNIFORMHLSL_H_

Просмотреть файл

@ -0,0 +1,243 @@
//
// 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<int4>";
case EbtISampler3D: return "Texture3D<int4>";
case EbtISamplerCube: return "Texture2DArray<int4>";
case EbtISampler2DArray: return "Texture2DArray<int4>";
case EbtUSampler2D: return "Texture2D<uint4>";
case EbtUSampler3D: return "Texture3D<uint4>";
case EbtUSamplerCube: return "Texture2DArray<uint4>";
case EbtUSampler2DArray: return "Texture2DArray<uint4>";
case EbtSampler2DShadow: return "Texture2D";
case EbtSamplerCubeShadow: return "TextureCube";
case EbtSampler2DArrayShadow: return "Texture2DArray";
default: UNREACHABLE();
}
return "<unknown texture type>";
}
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 "<unknown type>";
}
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 "";
}
}

Просмотреть файл

@ -0,0 +1,37 @@
//
// 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 <vector>
#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_

Просмотреть файл

@ -6,7 +6,6 @@
#include "compiler/translator/VariablePacker.h"
#include <algorithm>
#include "compiler/translator/ShHandle.h"
namespace {
int GetSortOrder(ShDataType type)

Просмотреть файл

@ -8,7 +8,7 @@
#define _VARIABLEPACKER_INCLUDED_
#include <vector>
#include "compiler/translator/ShHandle.h"
#include "compiler/translator/VariableInfo.h"
class VariablePacker {
public:

Просмотреть файл

@ -36,8 +36,7 @@ static const int GLSL_VERSION_120 = 120;
// - varying vec3 color; invariant color;
//
TVersionGLSL::TVersionGLSL(ShShaderType type)
: mShaderType(type),
mVersion(GLSL_VERSION_110)
: mVersion(GLSL_VERSION_110)
{
}

Просмотреть файл

@ -49,7 +49,6 @@ protected:
void updateVersion(int version);
private:
ShShaderType mShaderType;
int mVersion;
};

0
gfx/angle/src/compiler/translator/generate_parser.sh Executable file → Normal file
Просмотреть файл

Просмотреть файл

@ -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,7 +887,8 @@ function_prototype
else
{
// Insert the unmangled name to detect potential future redefinition as a variable.
context->symbolTable.getOuterLevel()->insert($1->getName(), *$1);
TFunction *function = new TFunction(NewPoolTString($1->getName().c_str()), $1->getReturnType());
context->symbolTable.getOuterLevel()->insert(function);
}
//
@ -899,7 +900,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);
}
;
@ -1255,7 +1256,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();
}
@ -1899,7 +1900,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;

Просмотреть файл

@ -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,
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
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
};
#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,7 +3436,8 @@ yyreduce:
else
{
// Insert the unmangled name to detect potential future redefinition as a variable.
context->symbolTable.getOuterLevel()->insert((yyvsp[(1) - (2)].interm.function)->getName(), *(yyvsp[(1) - (2)].interm.function));
TFunction *function = new TFunction(NewPoolTString((yyvsp[(1) - (2)].interm.function)->getName().c_str()), (yyvsp[(1) - (2)].interm.function)->getReturnType());
context->symbolTable.getOuterLevel()->insert(function);
}
//
@ -3448,7 +3449,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;
@ -3939,7 +3940,7 @@ yyreduce:
(yyval.interm.type).precision = (yyvsp[(1) - (2)].interm.precision);
if (!SupportsPrecision((yyvsp[(2) - (2)].interm.type).type)) {
context->error((yylsp[(1) - (1)]), "illegal type for precision qualifier", getBasicString((yyvsp[(2) - (2)].interm.type).type));
context->error((yylsp[(1) - (2)]), "illegal type for precision qualifier", getBasicString((yyvsp[(2) - (2)].interm.type).type));
context->recover();
}
}
@ -4967,7 +4968,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;

Просмотреть файл

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@ -153,18 +153,6 @@ 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;

Просмотреть файл

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@ -50,19 +50,6 @@ enum TOperator {
EOpPreIncrement,
EOpPreDecrement,
EOpConvIntToBool,
EOpConvUIntToBool,
EOpConvFloatToBool,
EOpConvBoolToFloat,
EOpConvIntToFloat,
EOpConvUIntToFloat,
EOpConvFloatToInt,
EOpConvBoolToInt,
EOpConvUIntToInt,
EOpConvIntToUInt,
EOpConvFloatToUInt,
EOpConvBoolToUInt,
//
// binary operations
//

Просмотреть файл

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@ -24,7 +24,6 @@ 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&);
@ -36,7 +35,6 @@ 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&);

Просмотреть файл

@ -1,66 +0,0 @@
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#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 <windows.h>
#elif defined(ANGLE_OS_POSIX)
#include <pthread.h>
#include <semaphore.h>
#include <errno.h>
#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<OS_TLSIndex>(-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

Просмотреть файл

@ -1,64 +0,0 @@
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
//
// 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;
}

Просмотреть файл

@ -1,57 +0,0 @@
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#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;
}

Просмотреть файл

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@ -162,6 +162,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
ConstantUnion* leftUnionArray = unionArray;
size_t instanceSize = type.getObjectSize();
TBasicType basicType = type.getBasicType();
if (index >= instanceSize)
return;
@ -173,7 +174,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
for (size_t i=0; i < objectSize; i++) {
if (index >= instanceSize)
return;
leftUnionArray[index] = rightUnionArray[i];
leftUnionArray[index].cast(basicType, rightUnionArray[i]);
(index)++;
}
@ -186,7 +187,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
if (i >= instanceSize)
return;
leftUnionArray[i] = rightUnionArray[count];
leftUnionArray[i].cast(basicType, rightUnionArray[count]);
(index)++;
@ -203,7 +204,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
{
if (col == row)
{
leftUnionArray[i] = rightUnionArray[0];
leftUnionArray[i].cast(basicType, rightUnionArray[0]);
}
else
{

Просмотреть файл

@ -9,6 +9,7 @@
#include <limits>
#include "compiler/preprocessor/numeric_lex.h"
#include "common/shadervars.h"
bool atof_clamp(const char *str, float *value)
{
@ -26,3 +27,254 @@ 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;
}
}
}

Просмотреть файл

@ -7,6 +7,10 @@
#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.
@ -17,4 +21,17 @@ 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

Просмотреть файл

@ -13,10 +13,7 @@
#include <algorithm>
#include <vector>
#include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include "angle_gl.h"
#include <EGL/eglext.h>
#include "common/debug.h"

Просмотреть файл

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@ -13,6 +13,7 @@
#include <algorithm>
#include <map>
#include <vector>
#include <sstream>
#include "common/debug.h"
#include "common/mathutil.h"
@ -112,7 +113,7 @@ bool Display::initialize()
return false;
}
initExtensionString();
initDisplayExtensionString();
initVendorString();
return true;
@ -343,7 +344,7 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle,
return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
}
if (textureFormat != EGL_NO_TEXTURE && !mRenderer->getNonPower2TextureSupport() && (!gl::isPow2(width) || !gl::isPow2(height)))
if (textureFormat != EGL_NO_TEXTURE && !mRenderer->getCaps().extensions.textureNPOT && (!gl::isPow2(width) || !gl::isPow2(height)))
{
return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
}
@ -500,48 +501,58 @@ bool Display::hasExistingWindowSurface(HWND window)
return false;
}
void Display::initExtensionString()
std::string Display::generateClientExtensionString()
{
bool shareHandleSupported = mRenderer->getShareHandleSupport();
std::vector<std::string> extensions;
mExtensionString = "";
extensions.push_back("EGL_EXT_client_extensions");
std::ostringstream stream;
std::copy(extensions.begin(), extensions.end(), std::ostream_iterator<std::string>(stream, " "));
return stream.str();
}
void Display::initDisplayExtensionString()
{
std::vector<std::string> extensions;
// Multi-vendor (EXT) extensions
mExtensionString += "EGL_EXT_create_context_robustness ";
extensions.push_back("EGL_EXT_create_context_robustness");
// ANGLE-specific extensions
if (shareHandleSupported)
if (mRenderer->getShareHandleSupport())
{
mExtensionString += "EGL_ANGLE_d3d_share_handle_client_buffer ";
extensions.push_back("EGL_ANGLE_d3d_share_handle_client_buffer");
extensions.push_back("EGL_ANGLE_surface_d3d_texture_2d_share_handle");
}
mExtensionString += "EGL_ANGLE_query_surface_pointer ";
mExtensionString += "EGL_ANGLE_window_fixed_size ";
if (shareHandleSupported)
{
mExtensionString += "EGL_ANGLE_surface_d3d_texture_2d_share_handle ";
}
extensions.push_back("EGL_ANGLE_query_surface_pointer");
extensions.push_back("EGL_ANGLE_window_fixed_size");
if (mRenderer->getPostSubBufferSupport())
{
mExtensionString += "EGL_NV_post_sub_buffer ";
extensions.push_back("EGL_NV_post_sub_buffer");
}
// TODO: complete support for the EGL_KHR_create_context extension
mExtensionString += "EGL_KHR_create_context ";
extensions.push_back("EGL_KHR_create_context");
std::string::size_type end = mExtensionString.find_last_not_of(' ');
if (end != std::string::npos)
{
mExtensionString.resize(end+1);
}
std::ostringstream stream;
std::copy(extensions.begin(), extensions.end(), std::ostream_iterator<std::string>(stream, " "));
mDisplayExtensionString = stream.str();
}
const char *Display::getExtensionString() const
const char *Display::getExtensionString(egl::Display *display)
{
return mExtensionString.c_str();
if (display != EGL_NO_DISPLAY)
{
return display->mDisplayExtensionString.c_str();
}
else
{
static std::string clientExtensions = generateClientExtensionString();
return clientExtensions.c_str();
}
}
void Display::initVendorString()

Просмотреть файл

@ -35,6 +35,8 @@ 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);
@ -82,9 +84,12 @@ class Display
rx::Renderer *mRenderer;
void initExtensionString();
static std::string generateClientExtensionString();
void initDisplayExtensionString();
std::string mDisplayExtensionString;
void initVendorString();
std::string mExtensionString;
std::string mVendorString;
};
}

Просмотреть файл

@ -169,8 +169,7 @@ const char *__stdcall eglQueryString(EGLDisplay dpy, EGLint name)
ANGLE_TRY
{
egl::Display *display = static_cast<egl::Display*>(dpy);
if (!validateDisplay(display))
if (!(display == EGL_NO_DISPLAY && name == EGL_EXTENSIONS) && !validateDisplay(display))
{
return NULL;
}
@ -180,14 +179,14 @@ const char *__stdcall eglQueryString(EGLDisplay dpy, EGLint name)
case EGL_CLIENT_APIS:
return egl::success("OpenGL_ES");
case EGL_EXTENSIONS:
return egl::success(display->getExtensionString());
return egl::success(egl::Display::getExtensionString(display));
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
{

Просмотреть файл

@ -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

Просмотреть файл

@ -9,42 +9,42 @@
#include "libEGL/main.h"
#include "common/debug.h"
#include "common/tls.h"
static DWORD currentTLS = TLS_OUT_OF_INDEXES;
static TLSIndex currentTLS = TLS_OUT_OF_INDEXES;
namespace egl
{
Current *AllocateCurrent()
{
Current *current = (egl::Current*)LocalAlloc(LPTR, sizeof(egl::Current));
if (!current)
ASSERT(currentTLS != TLS_OUT_OF_INDEXES);
if (currentTLS == TLS_OUT_OF_INDEXES)
{
ERR("Could not allocate thread local storage.");
return NULL;
}
ASSERT(currentTLS != TLS_OUT_OF_INDEXES);
TlsSetValue(currentTLS, current);
Current *current = new 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()
{
void *current = TlsGetValue(currentTLS);
if (current)
{
LocalFree((HLOCAL)current);
}
Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS));
SafeDelete(current);
SetTLSValue(currentTLS, NULL);
}
}
@ -70,14 +70,13 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved
}
#endif
currentTLS = TlsAlloc();
currentTLS = CreateTLSIndex();
if (currentTLS == TLS_OUT_OF_INDEXES)
{
return FALSE;
}
}
// Fall throught to initialize index
// Fall through to initialize index
case DLL_THREAD_ATTACH:
{
egl::AllocateCurrent();
@ -91,7 +90,7 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved
case DLL_PROCESS_DETACH:
{
egl::DeallocateCurrent();
TlsFree(currentTLS);
DestroyTLSIndex(currentTLS);
}
break;
default:
@ -106,7 +105,7 @@ namespace egl
Current *GetCurrentData()
{
Current *current = (Current*)TlsGetValue(currentTLS);
Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS));
// ANGLE issue 488: when the dll is loaded after thread initialization,
// thread local storage (current) might not exist yet.

Просмотреть файл

@ -7,6 +7,7 @@ UNIFIED_SOURCES += [
'../common/event_tracer.cpp',
'../common/mathutil.cpp',
'../common/RefCountObject.cpp',
'../common/tls.cpp',
'../common/utilities.cpp',
'Config.cpp',
'Display.cpp',
@ -53,6 +54,7 @@ DISABLE_STL_WRAPPING = True
LOCAL_INCLUDES += [ '../../include', '../../src' ]
USE_LIBS += [ 'libGLESv2' ]
EXTRA_DSO_LDOPTS += [ '../libGLESv2/libGLESv2.lib' ]
SharedLibrary('libEGL')

Просмотреть файл

@ -38,7 +38,7 @@
'<!@(python <(angle_path)/enumerate_files.py \
-dirs common libGLESv2 third_party/murmurhash ../include third_party/systeminfo \
-types *.cpp *.h *.hlsl *.vs *.ps *.bat *.def *.rc \
-excludes */d3d/* */d3d9/* */d3d11/*)',
-excludes */d3d/*)',
],
'defines':
[
@ -53,7 +53,7 @@
'sources':
[
'<!@(python <(angle_path)/enumerate_files.py \
-dirs libGLESv2/renderer/d3d libGLESv2/renderer/d3d9 \
-dirs libGLESv2/renderer/d3d libGLESv2/renderer/d3d/d3d9 \
-types *.cpp *.h *.vs *.ps *.bat)',
],
'defines':
@ -76,7 +76,7 @@
'sources':
[
'<!@(python <(angle_path)/enumerate_files.py \
-dirs libGLESv2/renderer/d3d libGLESv2/renderer/d3d11 \
-dirs libGLESv2/renderer/d3d libGLESv2/renderer/d3d/d3d/d3d11 \
-types *.cpp *.h *.hlsl *.bat)',
],
'defines':

Просмотреть файл

@ -10,77 +10,56 @@
// [OpenGL ES 2.0.24] section 2.9 page 21.
#include "libGLESv2/Buffer.h"
#include "libGLESv2/renderer/VertexBuffer.h"
#include "libGLESv2/renderer/IndexBuffer.h"
#include "libGLESv2/renderer/BufferStorage.h"
#include "libGLESv2/renderer/BufferImpl.h"
#include "libGLESv2/renderer/Renderer.h"
namespace gl
{
Buffer::Buffer(rx::Renderer *renderer, GLuint id)
Buffer::Buffer(rx::BufferImpl *impl, GLuint id)
: RefCountObject(id),
mRenderer(renderer),
mBuffer(impl),
mUsage(GL_DYNAMIC_DRAW),
mSize(0),
mAccessFlags(0),
mMapped(GL_FALSE),
mMapPointer(NULL),
mMapOffset(0),
mMapLength(0),
mBufferStorage(NULL),
mStaticVertexBuffer(NULL),
mStaticIndexBuffer(NULL),
mUnmodifiedDataUse(0)
mMapLength(0)
{
mBufferStorage = renderer->createBufferStorage();
}
Buffer::~Buffer()
{
delete mBufferStorage;
delete mStaticVertexBuffer;
delete mStaticIndexBuffer;
delete mBuffer;
}
void Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage)
{
mBufferStorage->clear();
mIndexRangeCache.clear();
mBufferStorage->setData(data, size, 0);
mUsage = usage;
invalidateStaticData();
if (usage == GL_STATIC_DRAW)
{
mStaticVertexBuffer = new rx::StaticVertexBufferInterface(mRenderer);
mStaticIndexBuffer = new rx::StaticIndexBufferInterface(mRenderer);
}
mSize = size;
mBuffer->setData(data, size, usage);
}
void Buffer::bufferSubData(const void *data, GLsizeiptr size, GLintptr offset)
{
mBufferStorage->setData(data, size, offset);
mIndexRangeCache.invalidateRange(offset, size);
invalidateStaticData();
mBuffer->setSubData(data, size, offset);
}
void Buffer::copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size)
{
mBufferStorage->copyData(source->mBufferStorage, size, sourceOffset, destOffset);
invalidateStaticData();
mBuffer->copySubData(source->getImplementation(), size, sourceOffset, destOffset);
}
GLvoid *Buffer::mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access)
{
ASSERT(!mMapped);
ASSERT(offset + length <= mSize);
void *dataPointer = mBufferStorage->map(access);
void *dataPointer = mBuffer->map(offset, length, access);
mMapped = GL_TRUE;
mMapPointer = static_cast<GLvoid*>(static_cast<GLubyte*>(dataPointer) + offset);
mMapPointer = static_cast<GLvoid*>(static_cast<GLubyte*>(dataPointer));
mMapOffset = static_cast<GLint64>(offset);
mMapLength = static_cast<GLint64>(length);
mAccessFlags = static_cast<GLint>(access);
@ -92,7 +71,7 @@ void Buffer::unmap()
{
ASSERT(mMapped);
mBufferStorage->unmap();
mBuffer->unmap();
mMapped = GL_FALSE;
mMapPointer = NULL;
@ -101,94 +80,10 @@ void Buffer::unmap()
mAccessFlags = 0;
}
rx::BufferStorage *Buffer::getStorage() const
{
return mBufferStorage;
}
GLint64 Buffer::size() const
{
return static_cast<GLint64>(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()
{
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;
// TODO: Only used by the DX11 backend. Refactor to a more appropriate place.
mBuffer->markTransformFeedbackUsage();
}
}

Просмотреть файл

@ -13,14 +13,11 @@
#include "common/angleutils.h"
#include "common/RefCountObject.h"
#include "libGLESv2/renderer/IndexRangeCache.h"
namespace rx
{
class Renderer;
class BufferStorage;
class StaticIndexBufferInterface;
class StaticVertexBufferInterface;
class BufferImpl;
};
namespace gl
@ -29,7 +26,7 @@ namespace gl
class Buffer : public RefCountObject
{
public:
Buffer(rx::Renderer *renderer, GLuint id);
Buffer(rx::BufferImpl *impl, GLuint id);
virtual ~Buffer();
@ -39,43 +36,30 @@ class Buffer : public RefCountObject
GLvoid *mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access);
void unmap();
GLenum usage() const;
GLint accessFlags() const;
GLboolean mapped() const;
GLvoid *mapPointer() const;
GLint64 mapOffset() const;
GLint64 mapLength() const;
GLenum getUsage() const { return mUsage; }
GLint getAccessFlags() const { return mAccessFlags; }
GLboolean isMapped() const { return mMapped; }
GLvoid *getMapPointer() const { return mMapPointer; }
GLint64 getMapOffset() const { return mMapOffset; }
GLint64 getMapLength() const { return mMapLength; }
GLint64 getSize() const { return mSize; }
rx::BufferStorage *getStorage() const;
GLint64 size() const;
rx::BufferImpl *getImplementation() const { return mBuffer; }
void markTransformFeedbackUsage();
rx::StaticVertexBufferInterface *getStaticVertexBuffer();
rx::StaticIndexBufferInterface *getStaticIndexBuffer();
void invalidateStaticData();
void promoteStaticUsage(int dataSize);
rx::IndexRangeCache *getIndexRangeCache();
private:
DISALLOW_COPY_AND_ASSIGN(Buffer);
rx::Renderer *mRenderer;
rx::BufferImpl *mBuffer;
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;
};
}

Просмотреть файл

@ -0,0 +1,346 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "libGLESv2/Caps.h"
#include "common/debug.h"
#include "common/angleutils.h"
#include "angle_gl.h"
#include <algorithm>
#include <sstream>
namespace gl
{
TextureCaps::TextureCaps()
: 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<std::string> *extensionVector)
{
if (supported && minClientVersion >= curClientVersion && (maxClientVersion == 0 || curClientVersion <= maxClientVersion))
{
extensionVector->push_back(extension);
}
}
std::vector<std::string> Extensions::getStrings(GLuint clientVersion) const
{
std::vector<std::string> 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<GLenum> &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<GLenum> 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<GLenum> 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<GLenum> 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<GLenum> 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<GLenum> 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<GLenum> 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<GLenum> requiredFormats;
requiredFormats.push_back(GL_R8);
requiredFormats.push_back(GL_RG8);
if (checkHalfFloatFormats)
{
requiredFormats.push_back(GL_R16F);
requiredFormats.push_back(GL_RG16F);
}
if (checkFloatFormats)
{
requiredFormats.push_back(GL_R32F);
requiredFormats.push_back(GL_RG32F);
}
return GetFormatSupport(textureCaps, requiredFormats, true, false, false);
}
// Check for GL_EXT_texture_compression_dxt1
static bool DetermineDXT1TextureSupport(const TextureCapsMap &textureCaps)
{
std::vector<GLenum> requiredFormats;
requiredFormats.push_back(GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
return GetFormatSupport(textureCaps, requiredFormats, true, false, false);
}
// Check for GL_ANGLE_texture_compression_dxt3
static bool DetermineDXT3TextureSupport(const TextureCapsMap &textureCaps)
{
std::vector<GLenum> requiredFormats;
requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE);
return GetFormatSupport(textureCaps, requiredFormats, true, false, false);
}
// Check for GL_ANGLE_texture_compression_dxt5
static bool DetermineDXT5TextureSupport(const TextureCapsMap &textureCaps)
{
std::vector<GLenum> requiredFormats;
requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE);
return GetFormatSupport(textureCaps, requiredFormats, true, false, false);
}
// Check for GL_ANGLE_texture_compression_dxt5
static bool DetermineSRGBTextureSupport(const TextureCapsMap &textureCaps)
{
std::vector<GLenum> requiredFilterFormats;
requiredFilterFormats.push_back(GL_SRGB8);
requiredFilterFormats.push_back(GL_SRGB8_ALPHA8);
std::vector<GLenum> requiredRenderFormats;
requiredRenderFormats.push_back(GL_SRGB8_ALPHA8);
return GetFormatSupport(textureCaps, requiredFilterFormats, true, false, false) &&
GetFormatSupport(textureCaps, requiredRenderFormats, false, true, false);
}
// Check for GL_ANGLE_depth_texture
static bool DetermineDepthTextureSupport(const TextureCapsMap &textureCaps)
{
std::vector<GLenum> requiredFormats;
requiredFormats.push_back(GL_DEPTH_COMPONENT16);
requiredFormats.push_back(GL_DEPTH_COMPONENT32_OES);
requiredFormats.push_back(GL_DEPTH24_STENCIL8_OES);
return GetFormatSupport(textureCaps, requiredFormats, true, false, true);
}
// Check for GL_EXT_color_buffer_float
static bool DetermineColorBufferFloatSupport(const TextureCapsMap &textureCaps)
{
std::vector<GLenum> requiredFormats;
requiredFormats.push_back(GL_R16F);
requiredFormats.push_back(GL_RG16F);
requiredFormats.push_back(GL_RGBA16F);
requiredFormats.push_back(GL_R32F);
requiredFormats.push_back(GL_RG32F);
requiredFormats.push_back(GL_RGBA32F);
requiredFormats.push_back(GL_R11F_G11F_B10F);
return GetFormatSupport(textureCaps, requiredFormats, 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()
{
}
}

Просмотреть файл

@ -0,0 +1,203 @@
#ifndef LIBGLESV2_CAPS_H
#define LIBGLESV2_CAPS_H
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "angle_gl.h"
#include <set>
#include <unordered_map>
#include <vector>
#include <string>
namespace gl
{
struct TextureCaps
{
TextureCaps();
bool texture2D;
bool textureCubeMap;
bool texture3D;
bool texture2DArray;
bool filtering;
bool colorRendering;
bool depthRendering;
bool stencilRendering;
std::set<GLuint> 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<GLenum, TextureCaps> InternalFormatToCapsMap;
InternalFormatToCapsMap mCapsMap;
};
struct Extensions
{
Extensions();
// Generate a vector of supported extension strings
std::vector<std::string> 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

Просмотреть файл

@ -16,13 +16,14 @@
#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/IndexDataManager.h"
#include "libGLESv2/renderer/d3d/IndexDataManager.h"
#include "libGLESv2/renderer/RenderTarget.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/VertexArray.h"
@ -37,15 +38,6 @@
namespace gl
{
static const char* makeStaticString(const std::string& str)
{
static std::set<std::string> strings;
std::set<std::string>::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)
{
@ -203,7 +195,6 @@ Context::Context(int clientVersion, const gl::Context *shareContext, rx::Rendere
mState.currentProgram = 0;
mCurrentProgramBinary.set(NULL);
mCombinedExtensionsString = NULL;
mRendererString = NULL;
mInvalidEnum = false;
@ -218,12 +209,6 @@ 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;
}
@ -328,8 +313,6 @@ 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()),
@ -343,50 +326,29 @@ 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, MaxTextureAnisotropy=%f",
"MaxRenderbufferDimension=%d",
mMax2DTextureDimension, mMaxCubeTextureDimension, mMax3DTextureDimension, mMax2DArrayTextureLayers,
mMax2DTextureLevel, mMaxCubeTextureLevel, mMax3DTextureLevel, mMax2DArrayTextureLevel,
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();
mMaxRenderbufferDimension);
mNumCompressedTextureFormats = 0;
if (supportsDXT1Textures())
if (getCaps().extensions.textureCompressionDXT1)
{
mNumCompressedTextureFormats += 2;
}
if (supportsDXT3Textures())
if (getCaps().extensions.textureCompressionDXT3)
{
mNumCompressedTextureFormats += 1;
}
if (supportsDXT5Textures())
if (getCaps().extensions.textureCompressionDXT5)
{
mNumCompressedTextureFormats += 1;
}
initExtensionString();
initRendererString();
initExtensionStrings();
mState.viewport.x = 0;
mState.viewport.y = 0;
@ -614,6 +576,21 @@ 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;
@ -825,7 +802,7 @@ void Context::setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer,
const void *Context::getVertexAttribPointer(unsigned int attribNum) const
{
return getCurrentVertexArray()->getVertexAttribute(attribNum).mPointer;
return getCurrentVertexArray()->getVertexAttribute(attribNum).pointer;
}
void Context::setPackAlignment(GLint alignment)
@ -912,7 +889,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, handle);
mVertexArrayMap[handle] = new VertexArray(mRenderer->createVertexArray(), handle, MAX_VERTEX_ATTRIBS);
return handle;
}
@ -1157,6 +1134,11 @@ Framebuffer *Context::getDrawFramebuffer()
return mBoundDrawFramebuffer;
}
const Framebuffer *Context::getDrawFramebuffer() const
{
return mBoundDrawFramebuffer;
}
VertexArray *Context::getCurrentVertexArray() const
{
VertexArray *vao = getVertexArray(mState.vertexArray);
@ -1249,7 +1231,7 @@ void Context::bindVertexArray(GLuint vertexArray)
{
if (!getVertexArray(vertexArray))
{
mVertexArrayMap[vertexArray] = new VertexArray(mRenderer, vertexArray);
mVertexArrayMap[vertexArray] = new VertexArray(mRenderer->createVertexArray(), vertexArray, MAX_VERTEX_ATTRIBS);
}
mState.vertexArray = vertexArray;
@ -1412,25 +1394,23 @@ void Context::setFramebufferZero(Framebuffer *buffer)
void Context::setRenderbufferStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples)
{
const bool color = gl::IsColorRenderingSupported(internalformat, this);
const bool depth = gl::IsDepthRenderingSupported(internalformat, this);
const bool stencil = gl::IsStencilRenderingSupported(internalformat, this);
const TextureCaps &formatCaps = getCaps().textureCaps.get(internalformat);
RenderbufferStorage *renderbuffer = NULL;
if (color)
if (formatCaps.colorRendering)
{
renderbuffer = new gl::Colorbuffer(mRenderer,width, height, internalformat, samples);
}
else if (depth && stencil)
else if (formatCaps.depthRendering && formatCaps.stencilRendering)
{
renderbuffer = new gl::DepthStencilbuffer(mRenderer, width, height, samples);
}
else if (depth)
else if (formatCaps.depthRendering)
{
renderbuffer = new gl::Depthbuffer(mRenderer, width, height, samples);
}
else if (stencil)
else if (formatCaps.stencilRendering)
{
renderbuffer = new gl::Stencilbuffer(mRenderer, width, height, samples);
}
@ -1700,8 +1680,8 @@ void Context::getFloatv(GLenum pname, GLfloat *params)
params[3] = mState.blendColor.alpha;
break;
case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
ASSERT(supportsTextureFilterAnisotropy());
*params = mMaxTextureAnisotropy;
ASSERT(getCaps().extensions.textureFilterAnisotropic);
*params = getCaps().extensions.maxTextureAnisotropy;
break;
default:
UNREACHABLE();
@ -1849,16 +1829,16 @@ void Context::getIntegerv(GLenum pname, GLint *params)
break;
case GL_COMPRESSED_TEXTURE_FORMATS:
{
if (supportsDXT1Textures())
if (getCaps().extensions.textureCompressionDXT1)
{
*params++ = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
*params++ = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
}
if (supportsDXT3Textures())
if (getCaps().extensions.textureCompressionDXT3)
{
*params++ = GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE;
}
if (supportsDXT5Textures())
if (getCaps().extensions.textureCompressionDXT5)
{
*params++ = GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE;
}
@ -1884,7 +1864,7 @@ void Context::getIntegerv(GLenum pname, GLint *params)
case GL_ALPHA_BITS:
{
gl::Framebuffer *framebuffer = getDrawFramebuffer();
gl::Renderbuffer *colorbuffer = framebuffer->getFirstColorbuffer();
gl::FramebufferAttachment *colorbuffer = framebuffer->getFirstColorbuffer();
if (colorbuffer)
{
@ -1905,7 +1885,7 @@ void Context::getIntegerv(GLenum pname, GLint *params)
case GL_DEPTH_BITS:
{
gl::Framebuffer *framebuffer = getDrawFramebuffer();
gl::Renderbuffer *depthbuffer = framebuffer->getDepthbuffer();
gl::FramebufferAttachment *depthbuffer = framebuffer->getDepthbuffer();
if (depthbuffer)
{
@ -1920,7 +1900,7 @@ void Context::getIntegerv(GLenum pname, GLint *params)
case GL_STENCIL_BITS:
{
gl::Framebuffer *framebuffer = getDrawFramebuffer();
gl::Renderbuffer *stencilbuffer = framebuffer->getStencilbuffer();
gl::FramebufferAttachment *stencilbuffer = framebuffer->getStencilbuffer();
if (stencilbuffer)
{
@ -1976,7 +1956,7 @@ void Context::getIntegerv(GLenum pname, GLint *params)
*params = mState.unpack.pixelBuffer.id();
break;
case GL_NUM_EXTENSIONS:
*params = static_cast<GLint>(getNumExtensions());
*params = static_cast<GLint>(mExtensionStrings.size());
break;
default:
UNREACHABLE();
@ -2180,7 +2160,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
return true;
case GL_MAX_SAMPLES_ANGLE:
{
if (getMaxSupportedSamples() != 0)
if (getCaps().extensions.framebufferMultisample)
{
*type = GL_INT;
*numParams = 1;
@ -2194,7 +2174,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
case GL_PIXEL_PACK_BUFFER_BINDING:
case GL_PIXEL_UNPACK_BUFFER_BINDING:
{
if (supportsPBOs())
if (getCaps().extensions.pixelBufferObject)
{
*type = GL_INT;
*numParams = 1;
@ -2268,7 +2248,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
}
return true;
case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
if (!supportsTextureFilterAnisotropy())
if (!getCaps().extensions.maxTextureAnisotropy)
{
return false;
}
@ -2373,11 +2353,7 @@ bool Context::getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned
bool Context::applyRenderTarget(GLenum drawMode, bool ignoreViewport)
{
Framebuffer *framebufferObject = getDrawFramebuffer();
if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE)
{
return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
}
ASSERT(framebufferObject && framebufferObject->completeness() == GL_FRAMEBUFFER_COMPLETE);
mRenderer->applyRenderTarget(framebufferObject);
@ -2445,7 +2421,9 @@ void Context::applyShaders(ProgramBinary *programBinary, bool transformFeedbackA
VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS];
VertexFormat::GetInputLayout(inputLayout, programBinary, vertexAttributes, mState.vertexAttribCurrentValues);
mRenderer->applyShaders(programBinary, mState.rasterizer.rasterizerDiscard, transformFeedbackActive, inputLayout);
const Framebuffer *fbo = getDrawFramebuffer();
mRenderer->applyShaders(programBinary, inputLayout, fbo, mState.rasterizer.rasterizerDiscard, transformFeedbackActive);
programBinary->applyUniforms();
}
@ -2651,14 +2629,13 @@ void Context::clear(GLbitfield mask)
return;
}
if (gl::GetStencilBits(depthStencil->getActualFormat(), mClientVersion) > 0)
if (gl::GetStencilBits(depthStencil->getActualFormat()) > 0)
{
clearParams.clearStencil = true;
}
}
}
if (!applyRenderTarget(GL_TRIANGLES, true)) // Clips the clear to the scissor rectangle but not the viewport
{
return;
@ -2861,9 +2838,9 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
{
gl::Framebuffer *framebuffer = getReadFramebuffer();
bool isSized = IsSizedInternalFormat(format, mClientVersion);
GLenum sizedInternalFormat = (isSized ? format : GetSizedInternalFormat(format, type, mClientVersion));
GLuint outputPitch = GetRowPitch(sizedInternalFormat, type, mClientVersion, width, mState.pack.alignment);
bool isSized = IsSizedInternalFormat(format);
GLenum sizedInternalFormat = (isSized ? format : GetSizedInternalFormat(format, type));
GLuint outputPitch = GetRowPitch(sizedInternalFormat, type, width, mState.pack.alignment);
mRenderer->readPixels(framebuffer, x, y, width, height, format, type, outputPitch, mState.pack, pixels);
}
@ -3131,6 +3108,11 @@ int Context::getClientVersion() const
return mClientVersion;
}
const Caps &Context::getCaps() const
{
return mRenderer->getCaps();
}
int Context::getMajorShaderModel() const
{
return mMajorShaderModel;
@ -3188,66 +3170,6 @@ 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;
@ -3293,67 +3215,17 @@ 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);
Renderbuffer *renderbuffer = framebuffer->getReadColorbuffer();
ASSERT(renderbuffer);
FramebufferAttachment *attachment = framebuffer->getReadColorbuffer();
ASSERT(attachment);
*internalFormat = renderbuffer->getActualFormat();
*format = gl::GetFormat(renderbuffer->getActualFormat(), mClientVersion);
*type = gl::GetType(renderbuffer->getActualFormat(), mClientVersion);
*internalFormat = attachment->getActualFormat();
*format = gl::GetFormat(attachment->getActualFormat());
*type = gl::GetType(attachment->getActualFormat());
}
void Context::detachBuffer(GLuint buffer)
@ -3393,7 +3265,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 FramebufferTexture2D had been called, with a texture of 0, for each attachment point to which this
// as if Texture2DAttachment had been called, with a texture of 0, for each attachment point to which this
// image was attached in the currently bound framebuffer.
Framebuffer *readFramebuffer = getReadFramebuffer();
@ -3692,175 +3564,6 @@ 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;
@ -3868,7 +3571,7 @@ void Context::initRendererString()
rendererString << mRenderer->getRendererDescription();
rendererString << ")";
mRendererString = makeStaticString(rendererString.str());
mRendererString = MakeStaticString(rendererString.str());
}
const char *Context::getRendererString() const
@ -3876,6 +3579,34 @@ const char *Context::getRendererString() const
return mRendererString;
}
void Context::initExtensionStrings()
{
std::ostringstream combinedStringStream;
std::vector<std::string> 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;
@ -3883,17 +3614,17 @@ size_t Context::getBoundFramebufferTextureSerials(FramebufferTextureSerialArray
Framebuffer *drawFramebuffer = getDrawFramebuffer();
for (unsigned int i = 0; i < IMPLEMENTATION_MAX_DRAW_BUFFERS; i++)
{
Renderbuffer *renderBuffer = drawFramebuffer->getColorbuffer(i);
if (renderBuffer && renderBuffer->isTexture())
FramebufferAttachment *attachment = drawFramebuffer->getColorbuffer(i);
if (attachment && attachment->isTexture())
{
(*outSerialArray)[serialCount++] = renderBuffer->getTextureSerial();
(*outSerialArray)[serialCount++] = attachment->getTextureSerial();
}
}
Renderbuffer *depthStencilBuffer = drawFramebuffer->getDepthOrStencilbuffer();
if (depthStencilBuffer && depthStencilBuffer->isTexture())
FramebufferAttachment *depthStencilAttachment = drawFramebuffer->getDepthOrStencilbuffer();
if (depthStencilAttachment && depthStencilAttachment->isTexture())
{
(*outSerialArray)[serialCount++] = depthStencilBuffer->getTextureSerial();
(*outSerialArray)[serialCount++] = depthStencilAttachment->getTextureSerial();
}
std::sort(outSerialArray->begin(), outSerialArray->begin() + serialCount);
@ -3958,43 +3689,43 @@ void Context::invalidateFrameBuffer(GLenum target, GLsizei numAttachments, const
if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15)
{
gl::Renderbuffer *renderBuffer = frameBuffer->getColorbuffer(attachments[i] - GL_COLOR_ATTACHMENT0);
if (renderBuffer)
gl::FramebufferAttachment *attachment = frameBuffer->getColorbuffer(attachments[i] - GL_COLOR_ATTACHMENT0);
if (attachment)
{
renderTarget = renderBuffer->getRenderTarget();
renderTarget = attachment->getRenderTarget();
}
}
else if (attachments[i] == GL_COLOR)
{
gl::Renderbuffer *renderBuffer = frameBuffer->getColorbuffer(0);
if (renderBuffer)
gl::FramebufferAttachment *attachment = frameBuffer->getColorbuffer(0);
if (attachment)
{
renderTarget = renderBuffer->getRenderTarget();
renderTarget = attachment->getRenderTarget();
}
}
else
{
gl::Renderbuffer *renderBuffer = NULL;
gl::FramebufferAttachment *attachment = NULL;
switch (attachments[i])
{
case GL_DEPTH_ATTACHMENT:
case GL_DEPTH:
renderBuffer = frameBuffer->getDepthbuffer();
attachment = frameBuffer->getDepthbuffer();
break;
case GL_STENCIL_ATTACHMENT:
case GL_STENCIL:
renderBuffer = frameBuffer->getStencilbuffer();
attachment = frameBuffer->getStencilbuffer();
break;
case GL_DEPTH_STENCIL_ATTACHMENT:
renderBuffer = frameBuffer->getDepthOrStencilbuffer();
attachment = frameBuffer->getDepthOrStencilbuffer();
break;
default:
UNREACHABLE();
}
if (renderBuffer)
if (attachment)
{
renderTarget = renderBuffer->getDepthStencil();
renderTarget = attachment->getDepthStencil();
}
}
@ -4013,8 +3744,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.mBoundBuffer.get();
if (vertexAttrib.mArrayEnabled && boundBuffer && boundBuffer->mapped())
gl::Buffer *boundBuffer = vertexAttrib.buffer.get();
if (vertexAttrib.enabled && boundBuffer && boundBuffer->isMapped())
{
return true;
}
@ -4023,7 +3754,7 @@ bool Context::hasMappedBuffer(GLenum target) const
else if (target == GL_ELEMENT_ARRAY_BUFFER)
{
Buffer *elementBuffer = getElementArrayBuffer();
return (elementBuffer && elementBuffer->mapped());
return (elementBuffer && elementBuffer->isMapped());
}
else if (target == GL_TRANSFORM_FEEDBACK_BUFFER)
{

Просмотреть файл

@ -10,10 +10,7 @@
#ifndef LIBGLESV2_CONTEXT_H_
#define LIBGLESV2_CONTEXT_H_
#include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include "angle_gl.h"
#include <EGL/egl.h>
#include <string>
@ -24,6 +21,7 @@
#include "common/angleutils.h"
#include "common/RefCountObject.h"
#include "libGLESv2/Caps.h"
#include "libGLESv2/HandleAllocator.h"
#include "libGLESv2/angletypes.h"
#include "libGLESv2/Constants.h"
@ -61,7 +59,7 @@ class FenceSync;
class Query;
class ResourceManager;
class Buffer;
class VertexAttribute;
struct VertexAttribute;
class VertexArray;
class Sampler;
class TransformFeedback;
@ -181,6 +179,9 @@ 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;
@ -360,6 +361,7 @@ class Context
GLuint getTargetFramebufferHandle(GLenum target) const;
Framebuffer *getReadFramebuffer();
Framebuffer *getDrawFramebuffer();
const Framebuffer *getDrawFramebuffer() const;
VertexArray *getCurrentVertexArray() const;
TransformFeedback *getCurrentTransformFeedback() const;
@ -399,6 +401,8 @@ class Context
virtual int getClientVersion() const;
const Caps &getCaps() const;
int getMajorShaderModel() const;
float getMaximumPointSize() const;
unsigned int getMaximumCombinedTextureImageUnits() const;
@ -419,36 +423,14 @@ 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;
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;
const char *getExtensionString() const;
const char *getExtensionString(size_t idx) const;
size_t getExtensionStringCount() 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);
@ -490,8 +472,8 @@ class Context
bool skipDraw(GLenum drawMode);
void initExtensionString();
void initRendererString();
void initExtensionStrings();
size_t getBoundFramebufferTextureSerials(FramebufferTextureSerialArray *outSerialArray);
@ -527,10 +509,10 @@ class Context
TransformFeedbackMap mTransformFeedbackMap;
HandleAllocator mTransformFeedbackAllocator;
std::vector<std::string> mExtensionStringList;
const char *mCombinedExtensionsString;
const char *mRendererString;
const char *mExtensionString;
std::vector<const char *> mExtensionStrings;
BindingPointer<Texture> mIncompleteTextures[TEXTURE_TYPE_COUNT];
// Recorded errors
@ -553,8 +535,6 @@ class Context
int mMajorShaderModel;
float mMaximumPointSize;
bool mSupportsVertexTexture;
bool mSupportsNonPower2Texture;
bool mSupportsInstancing;
int mMaxViewportDimension;
int mMaxRenderbufferDimension;
int mMax2DTextureDimension;
@ -565,26 +545,6 @@ 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;

Просмотреть файл

@ -69,7 +69,7 @@ std::string HLSLTypeString(GLenum type)
return HLSLMatrixTypeString(type);
}
return HLSLComponentTypeString(gl::UniformComponentType(type), gl::UniformComponentCount(type));
return HLSLComponentTypeString(gl::VariableComponentType(type), gl::VariableComponentCount(type));
}
}
@ -82,7 +82,8 @@ std::string ArrayString(unsigned int i)
return (i == GL_INVALID_INDEX ? "" : "[" + Str(i) + "]");
}
const std::string DynamicHLSL::VERTEX_ATTRIBUTE_STUB_STRING = "@@ VERTEX ATTRIBUTES @@";
const std::string VERTEX_ATTRIBUTE_STUB_STRING = "@@ VERTEX ATTRIBUTES @@";
const std::string PIXEL_OUTPUT_STUB_STRING = "@@ PIXEL OUTPUT @@";
DynamicHLSL::DynamicHLSL(rx::Renderer *const renderer)
: mRenderer(renderer)
@ -281,9 +282,9 @@ int DynamicHLSL::packVaryings(InfoLog &infoLog, VaryingPacking packing, Fragment
return registers;
}
std::string DynamicHLSL::generateVaryingHLSL(VertexShader *shader, const std::string &varyingSemantic,
std::vector<LinkedVarying> *linkedVaryings) const
std::string DynamicHLSL::generateVaryingHLSL(VertexShader *shader) const
{
std::string varyingSemantic = getVaryingSemantic(shader->mUsesPointSize);
std::string varyingHLSL;
for (unsigned int varyingIndex = 0; varyingIndex < shader->mVaryings.size(); varyingIndex++)
@ -300,9 +301,9 @@ std::string DynamicHLSL::generateVaryingHLSL(VertexShader *shader, const std::st
{
switch (varying.interpolation)
{
case INTERPOLATION_SMOOTH: varyingHLSL += " "; break;
case INTERPOLATION_FLAT: varyingHLSL += " nointerpolation "; break;
case INTERPOLATION_CENTROID: varyingHLSL += " centroid "; break;
case sh::INTERPOLATION_SMOOTH: varyingHLSL += " "; break;
case sh::INTERPOLATION_FLAT: varyingHLSL += " nointerpolation "; break;
case sh::INTERPOLATION_CENTROID: varyingHLSL += " centroid "; break;
default: UNREACHABLE();
}
@ -319,27 +320,22 @@ std::string DynamicHLSL::generateVaryingHLSL(VertexShader *shader, const std::st
}
else
{
GLenum componentType = UniformComponentType(transposedType);
GLenum componentType = VariableComponentType(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::generateInputLayoutHLSL(const VertexFormat inputLayout[], const Attribute shaderAttributes[]) const
std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &sourceShader,
const VertexFormat inputLayout[],
const sh::Attribute shaderAttributes[]) const
{
std::string structHLSL, initHLSL;
@ -351,7 +347,7 @@ std::string DynamicHLSL::generateInputLayoutHLSL(const VertexFormat inputLayout[
ASSERT(inputIndex < MAX_VERTEX_ATTRIBS);
const VertexFormat &vertexFormat = inputLayout[inputIndex];
const Attribute &shaderAttribute = shaderAttributes[attributeIndex];
const sh::Attribute &shaderAttribute = shaderAttributes[attributeIndex];
if (!shaderAttribute.name.empty())
{
@ -364,11 +360,11 @@ std::string DynamicHLSL::generateInputLayoutHLSL(const VertexFormat inputLayout[
else
{
GLenum componentType = mRenderer->getVertexComponentType(vertexFormat);
structHLSL += " " + gl_d3d::HLSLComponentTypeString(componentType, UniformComponentCount(shaderAttribute.type));
structHLSL += " " + gl_d3d::HLSLComponentTypeString(componentType, VariableComponentCount(shaderAttribute.type));
}
structHLSL += " " + decorateVariable(shaderAttribute.name) + " : TEXCOORD" + Str(semanticIndex) + ";\n";
semanticIndex += AttributeRegisterCount(shaderAttribute.type);
semanticIndex += VariableRegisterCount(shaderAttribute.type);
// HLSL code for initialization
initHLSL += " " + decorateVariable(shaderAttribute.name) + " = ";
@ -392,15 +388,247 @@ std::string DynamicHLSL::generateInputLayoutHLSL(const VertexFormat inputLayout[
}
}
return "struct VS_INPUT\n"
"{\n" +
structHLSL +
"};\n"
"\n"
"void initAttributes(VS_INPUT input)\n"
"{\n" +
initHLSL +
"}\n";
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<PixelShaderOuputVariable> &outputVariables,
bool usesFragDepth, const std::vector<GLenum> &outputLayout) const
{
const int shaderModel = mRenderer->getMajorShaderModel();
std::string targetSemantic = (shaderModel >= 4) ? "SV_TARGET" : "COLOR";
std::string depthSemantic = (shaderModel >= 4) ? "SV_Depth" : "DEPTH";
std::string declarationHLSL;
std::string copyHLSL;
for (size_t 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<LinkedVarying> *linkedVaryings) const
{
ASSERT(info.glPosition.enabled);
linkedVaryings->push_back(LinkedVarying("gl_Position", GL_FLOAT_VEC4, 1, info.glPosition.semantic,
info.glPosition.index, 1));
if (info.glFragCoord.enabled)
{
linkedVaryings->push_back(LinkedVarying("gl_FragCoord", GL_FLOAT_VEC4, 1, info.glFragCoord.semantic,
info.glFragCoord.index, 1));
}
if (info.glPointSize.enabled)
{
linkedVaryings->push_back(LinkedVarying("gl_PointSize", GL_FLOAT, 1, "PSIZE", 0, 1));
}
}
void DynamicHLSL::storeUserLinkedVaryings(const VertexShader *vertexShader,
std::vector<LinkedVarying> *linkedVaryings) const
{
const std::string &varyingSemantic = getVaryingSemantic(vertexShader->mUsesPointSize);
const std::vector<PackedVarying> &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()));
}
}
}
bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const VaryingPacking packing,
@ -408,7 +636,9 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
FragmentShader *fragmentShader, VertexShader *vertexShader,
const std::vector<std::string>& transformFeedbackVaryings,
std::vector<LinkedVarying> *linkedVaryings,
std::map<int, VariableLocation> *programOutputVars) const
std::map<int, VariableLocation> *programOutputVars,
std::vector<PixelShaderOuputVariable> *outPixelShaderKey,
bool *outUsesFragDepth) const
{
if (pixelHLSL.empty() || vertexHLSL.empty())
{
@ -418,6 +648,10 @@ 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.");
@ -428,12 +662,12 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
const int shaderModel = mRenderer->getMajorShaderModel();
const int maxVaryingVectors = mRenderer->getMaxVaryingVectors();
const int registersNeeded = registers + (fragmentShader->mUsesFragCoord ? 1 : 0) + (fragmentShader->mUsesPointCoord ? 1 : 0);
const int registersNeeded = registers + (usesFragCoord ? 1 : 0) + (usesPointCoord ? 1 : 0);
// Two cases when writing to gl_FragColor and using ESSL 1.0:
// - with a 3.0 context, the output color is copied to channel 0
// - with a 2.0 context, the output color is broadcast to all channels
const bool broadcast = (fragmentShader->mUsesFragColor && mRenderer->getCurrentClientVersion() < 3);
const bool broadcast = (usesFragColor && mRenderer->getCurrentClientVersion() < 3);
const unsigned int numRenderTargets = (broadcast || usesMRT ? mRenderer->getMaxRenderTargets() : 1);
int shaderVersion = vertexShader->getShaderVersion();
@ -441,86 +675,19 @@ 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;
}
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";
const std::string &varyingHLSL = generateVaryingHLSL(vertexShader);
const SemanticInfo &vertexSemantics = getSemanticInfo(registers, usesFragCoord,
false, usesPointSize, false);
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;
}
}
storeUserLinkedVaryings(vertexShader, linkedVaryings);
storeBuiltinLinkedVaryings(vertexSemantics, linkedVaryings);
// Add stub string to be replaced when shader is dynamically defined by its layout
vertexHLSL += "\n" + VERTEX_ATTRIBUTE_STUB_STRING + "\n";
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"
vertexHLSL += "\n" + VERTEX_ATTRIBUTE_STUB_STRING + "\n"
"struct VS_OUTPUT\n" + generateVaryingLinkHLSL(vertexSemantics, varyingHLSL) + "\n"
"VS_OUTPUT main(VS_INPUT input)\n"
"{\n"
" initAttributes(input);\n";
@ -532,10 +699,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
{
@ -544,18 +711,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 (vertexShader->mUsesPointSize && shaderModel >= 3)
if (usesPointSize && shaderModel >= 3)
{
vertexHLSL += " output.gl_PointSize = gl_PointSize;\n";
}
if (fragmentShader->mUsesFragCoord)
if (usesFragCoord)
{
vertexHLSL += " output.gl_FragCoord = gl_Position;\n";
}
@ -626,76 +793,51 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
" return output;\n"
"}\n";
pixelHLSL += "struct PS_INPUT\n"
"{\n";
const SemanticInfo &pixelSemantics = getSemanticInfo(registers, usesFragCoord, usesPointCoord,
usesPointSize, true);
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";
pixelHLSL += "struct PS_INPUT\n" + generateVaryingLinkHLSL(pixelSemantics, varyingHLSL) + "\n";
if (shaderVersion < 300)
{
for (unsigned int renderTargetIndex = 0; renderTargetIndex < numRenderTargets; renderTargetIndex++)
{
pixelHLSL += " float4 gl_Color" + Str(renderTargetIndex) + " : " + targetSemantic + Str(renderTargetIndex) + ";\n";
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);
}
if (fragmentShader->mUsesFragDepth)
{
pixelHLSL += " float gl_Depth : " + depthSemantic + ";\n";
}
*outUsesFragDepth = fragmentShader->mUsesFragDepth;
}
else
{
defineOutputVariables(fragmentShader, programOutputVars);
const std::vector<Attribute> &shaderOutputVars = fragmentShader->getOutputVariables();
const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getOutputVariables();
for (auto locationIt = programOutputVars->begin(); locationIt != programOutputVars->end(); locationIt++)
{
const VariableLocation &outputLocation = locationIt->second;
const ShaderVariable &outputVariable = shaderOutputVars[outputLocation.index];
const sh::ShaderVariable &outputVariable = shaderOutputVars[outputLocation.index];
const std::string &variableName = "out_" + outputLocation.name;
const std::string &elementString = (outputLocation.element == GL_INVALID_INDEX ? "" : Str(outputLocation.element));
pixelHLSL += " " + gl_d3d::HLSLTypeString(outputVariable.type) +
" out_" + outputLocation.name + elementString +
" : " + targetSemantic + Str(locationIt->first) + ";\n";
PixelShaderOuputVariable outputKeyVariable;
outputKeyVariable.type = outputVariable.type;
outputKeyVariable.name = variableName + elementString;
outputKeyVariable.source = variableName + ArrayString(outputLocation.element);
outputKeyVariable.outputIndex = locationIt->first;
outPixelShaderKey->push_back(outputKeyVariable);
}
*outUsesFragDepth = false;
}
pixelHLSL += "};\n"
"\n";
pixelHLSL += PIXEL_OUTPUT_STUB_STRING + "\n";
if (fragmentShader->mUsesFrontFacing)
{
@ -716,19 +858,19 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
"{\n";
}
if (fragmentShader->mUsesFragCoord)
if (usesFragCoord)
{
pixelHLSL += " float rhw = 1.0 / input.gl_FragCoord.w;\n";
if (shaderModel >= 4)
{
pixelHLSL += " gl_FragCoord.x = input.dx_VPos.x;\n"
" gl_FragCoord.y = input.dx_VPos.y;\n";
pixelHLSL += " gl_FragCoord.x = input.dx_Position.x;\n"
" gl_FragCoord.y = input.dx_Position.y;\n";
}
else if (shaderModel >= 3)
{
pixelHLSL += " gl_FragCoord.x = input.dx_VPos.x + 0.5;\n"
" gl_FragCoord.y = input.dx_VPos.y + 0.5;\n";
pixelHLSL += " gl_FragCoord.x = input.dx_Position.x + 0.5;\n"
" gl_FragCoord.y = input.dx_Position.y + 0.5;\n";
}
else
{
@ -741,7 +883,7 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
" gl_FragCoord.w = rhw;\n";
}
if (fragmentShader->mUsesPointCoord && shaderModel >= 3)
if (usesPointCoord && shaderModel >= 3)
{
pixelHLSL += " gl_PointCoord.x = input.gl_PointCoord.x;\n";
pixelHLSL += " gl_PointCoord.y = 1.0 - input.gl_PointCoord.y;\n";
@ -807,37 +949,7 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
pixelHLSL += "\n"
" gl_main();\n"
"\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"
" return generateOutput();\n"
"}\n";
return true;
@ -845,11 +957,11 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
void DynamicHLSL::defineOutputVariables(FragmentShader *fragmentShader, std::map<int, VariableLocation> *programOutputVars) const
{
const std::vector<Attribute> &shaderOutputVars = fragmentShader->getOutputVariables();
const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getOutputVariables();
for (unsigned int outputVariableIndex = 0; outputVariableIndex < shaderOutputVars.size(); outputVariableIndex++)
{
const Attribute &outputVariable = shaderOutputVars[outputVariableIndex];
const sh::Attribute &outputVariable = shaderOutputVars[outputVariableIndex];
const int baseLocation = outputVariable.location == -1 ? 0 : outputVariable.location;
if (outputVariable.arraySize > 0)
@ -884,60 +996,20 @@ std::string DynamicHLSL::generatePointSpriteHLSL(int registers, FragmentShader *
std::string geomHLSL;
std::string varyingSemantic = "TEXCOORD";
const SemanticInfo &inSemantics = getSemanticInfo(registers, fragmentShader->mUsesFragCoord,
false, true, false);
const SemanticInfo &outSemantics = getSemanticInfo(registers, fragmentShader->mUsesFragCoord,
fragmentShader->mUsesPointCoord, true, false);
std::string fragCoordSemantic;
std::string pointCoordSemantic;
int reservedRegisterIndex = registers;
if (fragmentShader->mUsesFragCoord)
{
fragCoordSemantic = varyingSemantic + Str(reservedRegisterIndex++);
}
if (fragmentShader->mUsesPointCoord)
{
pointCoordSemantic = varyingSemantic + Str(reservedRegisterIndex++);
}
std::string varyingHLSL = generateVaryingHLSL(vertexShader);
std::string inLinkHLSL = generateVaryingLinkHLSL(inSemantics, varyingHLSL);
std::string outLinkHLSL = generateVaryingLinkHLSL(outSemantics, varyingHLSL);
geomHLSL += "uniform float4 dx_ViewCoords : register(c1);\n"
"\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"
"struct GS_INPUT\n" + inLinkHLSL + "\n" +
"struct GS_OUTPUT\n" + outLinkHLSL + "\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"
@ -961,6 +1033,7 @@ std::string DynamicHLSL::generatePointSpriteHLSL(int registers, FragmentShader *
"void main(point GS_INPUT input[1], inout TriangleStream<GS_OUTPUT> outStream)\n"
"{\n"
" GS_OUTPUT output = (GS_OUTPUT)0;\n"
" output.gl_Position = input[0].gl_Position;\n";
" output.gl_PointSize = input[0].gl_PointSize;\n";
for (int r = 0; r < registers; r++)
@ -975,13 +1048,13 @@ std::string DynamicHLSL::generatePointSpriteHLSL(int registers, FragmentShader *
geomHLSL += " \n"
" float gl_PointSize = clamp(input[0].gl_PointSize, minPointSize, maxPointSize);\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";
" float4 dx_Position = input[0].dx_Position;\n"
" float2 viewportScale = float2(1.0f / dx_ViewCoords.x, 1.0f / dx_ViewCoords.y) * dx_Position.w;\n";
for (int corner = 0; corner < 4; corner++)
{
geomHLSL += " \n"
" output.gl_Position = gl_Position + float4(pointSpriteCorners[" + Str(corner) + "] * viewportScale * gl_PointSize, 0.0f, 0.0f);\n";
" output.dx_Position = dx_Position + float4(pointSpriteCorners[" + Str(corner) + "] * viewportScale * gl_PointSize, 0.0f, 0.0f);\n";
if (fragmentShader->mUsesPointCoord)
{
@ -1001,7 +1074,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_") != 0 && name.compare(0, 3, "dx_") != 0)
if (name.compare(0, 3, "gl_"))
{
return "_" + name;
}
@ -1009,7 +1082,7 @@ std::string DynamicHLSL::decorateVariable(const std::string &name)
return name;
}
std::string DynamicHLSL::generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const ShaderVariable &shaderAttrib) const
std::string DynamicHLSL::generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const sh::ShaderVariable &shaderAttrib) const
{
std::string attribString = "input." + decorateVariable(shaderAttrib.name);
@ -1019,8 +1092,8 @@ std::string DynamicHLSL::generateAttributeConversionHLSL(const VertexFormat &ver
return "transpose(" + attribString + ")";
}
GLenum shaderComponentType = UniformComponentType(shaderAttrib.type);
int shaderComponentCount = UniformComponentCount(shaderAttrib.type);
GLenum shaderComponentType = VariableComponentType(shaderAttrib.type);
int shaderComponentCount = VariableComponentCount(shaderAttrib.type);
// Perform integer to float conversion (if necessary)
bool requiresTypeConversion = (shaderComponentType == GL_FLOAT && vertexFormat.mType != GL_FLOAT);

Просмотреть файл

@ -17,6 +17,12 @@ namespace rx
class Renderer;
}
namespace sh
{
struct Attribute;
struct ShaderVariable;
}
namespace gl
{
@ -25,15 +31,20 @@ class FragmentShader;
class VertexShader;
struct VariableLocation;
struct LinkedVarying;
class VertexAttribute;
struct 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:
@ -41,33 +52,43 @@ class DynamicHLSL
int packVaryings(InfoLog &infoLog, VaryingPacking packing, FragmentShader *fragmentShader,
VertexShader *vertexShader, const std::vector<std::string>& transformFeedbackVaryings);
std::string generateInputLayoutHLSL(const VertexFormat inputLayout[], const Attribute shaderAttributes[]) const;
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<PixelShaderOuputVariable> &outputVariables,
bool usesFragDepth, const std::vector<GLenum> &outputLayout) const;
bool generateShaderLinkHLSL(InfoLog &infoLog, int registers, const VaryingPacking packing,
std::string& pixelHLSL, std::string& vertexHLSL,
FragmentShader *fragmentShader, VertexShader *vertexShader,
const std::vector<std::string>& transformFeedbackVaryings,
std::vector<LinkedVarying> *linkedVaryings,
std::map<int, VariableLocation> *programOutputVars) const;
std::map<int, VariableLocation> *programOutputVars,
std::vector<PixelShaderOuputVariable> *outPixelShaderKey,
bool *outUsesFragDepth) 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;
std::string generateVaryingHLSL(VertexShader *shader, const std::string &varyingSemantic,
std::vector<LinkedVarying> *linkedVaryings) const;
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<LinkedVarying> *linkedVaryings) const;
void storeBuiltinLinkedVaryings(const SemanticInfo &info, std::vector<LinkedVarying> *linkedVaryings) const;
void defineOutputVariables(FragmentShader *fragmentShader, std::map<int, VariableLocation> *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 ShaderVariable &shaderAttrib) const;
std::string generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const sh::ShaderVariable &shaderAttrib) const;
};
// Utility method shared between ProgramBinary and DynamicHLSL

Просмотреть файл

@ -1,6 +1,6 @@
#include "precompiled.h"
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@ -17,33 +17,42 @@
#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)
: mRenderer(renderer),
mReadBufferState(GL_COLOR_ATTACHMENT0_EXT),
mDepthbuffer(NULL),
mStencilbuffer(NULL)
{
for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
{
mColorbuffers[colorAttachment] = NULL;
mDrawBufferStates[colorAttachment] = GL_NONE;
}
mDrawBufferStates[0] = GL_COLOR_ATTACHMENT0_EXT;
mReadBufferState = GL_COLOR_ATTACHMENT0_EXT;
}
Framebuffer::~Framebuffer()
{
for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
{
mColorbuffers[colorAttachment].set(NULL, GL_NONE, 0, 0);
SafeDelete(mColorbuffers[colorAttachment]);
}
mDepthbuffer.set(NULL, GL_NONE, 0, 0);
mStencilbuffer.set(NULL, GL_NONE, 0, 0);
SafeDelete(mDepthbuffer);
SafeDelete(mStencilbuffer);
}
Renderbuffer *Framebuffer::lookupRenderbuffer(GLenum type, GLuint handle, GLint level, GLint layer) const
FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle, GLint level, GLint layer) const
{
if (handle == 0)
{
return NULL;
}
gl::Context *context = gl::getContext();
switch (type)
@ -52,14 +61,15 @@ Renderbuffer *Framebuffer::lookupRenderbuffer(GLenum type, GLuint handle, GLint
return NULL;
case GL_RENDERBUFFER:
return context->getRenderbuffer(handle);
return new RenderbufferAttachment(context->getRenderbuffer(handle));
case GL_TEXTURE_2D:
{
Texture *texture = context->getTexture(handle);
if (texture && texture->getTarget() == GL_TEXTURE_2D)
{
return static_cast<Texture2D*>(texture)->getRenderbuffer(level);
Texture2D *tex2D = static_cast<Texture2D*>(texture);
return new Texture2DAttachment(tex2D, level);
}
else
{
@ -77,7 +87,8 @@ Renderbuffer *Framebuffer::lookupRenderbuffer(GLenum type, GLuint handle, GLint
Texture *texture = context->getTexture(handle);
if (texture && texture->getTarget() == GL_TEXTURE_CUBE_MAP)
{
return static_cast<TextureCubeMap*>(texture)->getRenderbuffer(type, level);
TextureCubeMap *texCube = static_cast<TextureCubeMap*>(texture);
return new TextureCubeMapAttachment(texCube, type, level);
}
else
{
@ -90,7 +101,8 @@ Renderbuffer *Framebuffer::lookupRenderbuffer(GLenum type, GLuint handle, GLint
Texture *texture = context->getTexture(handle);
if (texture && texture->getTarget() == GL_TEXTURE_3D)
{
return static_cast<Texture3D*>(texture)->getRenderbuffer(level, layer);
Texture3D *tex3D = static_cast<Texture3D*>(texture);
return new Texture3DAttachment(tex3D, level, layer);
}
else
{
@ -103,7 +115,8 @@ Renderbuffer *Framebuffer::lookupRenderbuffer(GLenum type, GLuint handle, GLint
Texture *texture = context->getTexture(handle);
if (texture && texture->getTarget() == GL_TEXTURE_2D_ARRAY)
{
return static_cast<Texture2DArray*>(texture)->getRenderbuffer(level, layer);
Texture2DArray *tex2DArray = static_cast<Texture2DArray*>(texture);
return new Texture2DArrayAttachment(tex2DArray, level, layer);
}
else
{
@ -120,191 +133,138 @@ Renderbuffer *Framebuffer::lookupRenderbuffer(GLenum type, GLuint handle, GLint
void Framebuffer::setColorbuffer(unsigned int colorAttachment, GLenum type, GLuint colorbuffer, GLint level, GLint layer)
{
ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS);
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);
}
SafeDelete(mColorbuffers[colorAttachment]);
mColorbuffers[colorAttachment] = createAttachment(type, colorbuffer, level, layer);
}
void Framebuffer::setDepthbuffer(GLenum type, GLuint depthbuffer, GLint level, GLint layer)
{
Renderbuffer *renderBuffer = lookupRenderbuffer(type, depthbuffer, level, layer);
if (renderBuffer)
{
mDepthbuffer.set(renderBuffer, type, level, layer);
}
else
{
mDepthbuffer.set(NULL, GL_NONE, 0, 0);
}
SafeDelete(mDepthbuffer);
mDepthbuffer = createAttachment(type, depthbuffer, level, layer);
}
void Framebuffer::setStencilbuffer(GLenum type, GLuint stencilbuffer, GLint level, GLint layer)
{
Renderbuffer *renderBuffer = lookupRenderbuffer(type, stencilbuffer, level, layer);
if (renderBuffer)
{
mStencilbuffer.set(renderBuffer, type, level, layer);
}
else
{
mStencilbuffer.set(NULL, GL_NONE, 0, 0);
}
SafeDelete(mStencilbuffer);
mStencilbuffer = createAttachment(type, stencilbuffer, level, layer);
}
void Framebuffer::setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer, GLint level, GLint layer)
{
Renderbuffer *renderBuffer = lookupRenderbuffer(type, depthStencilBuffer, level, layer);
if (renderBuffer && renderBuffer->getDepthSize() > 0 && renderBuffer->getStencilSize() > 0)
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)
{
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);
mDepthbuffer = attachment;
// Make a new attachment object to ensure we do not double-delete
// See angle issue 686
mStencilbuffer = createAttachment(type, depthStencilBuffer, level, layer);
}
}
void Framebuffer::detachTexture(GLuint texture)
void Framebuffer::detachTexture(GLuint textureId)
{
for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
{
if (mColorbuffers[colorAttachment].id() == texture &&
IsInternalTextureTarget(mColorbuffers[colorAttachment].type(), mRenderer->getCurrentClientVersion()))
FramebufferAttachment *attachment = mColorbuffers[colorAttachment];
if (attachment && attachment->isTextureWithId(textureId))
{
mColorbuffers[colorAttachment].set(NULL, GL_NONE, 0, 0);
SafeDelete(mColorbuffers[colorAttachment]);
}
}
if (mDepthbuffer.id() == texture && IsInternalTextureTarget(mDepthbuffer.type(), mRenderer->getCurrentClientVersion()))
if (mDepthbuffer && mDepthbuffer->isTextureWithId(textureId))
{
mDepthbuffer.set(NULL, GL_NONE, 0, 0);
SafeDelete(mDepthbuffer);
}
if (mStencilbuffer.id() == texture && IsInternalTextureTarget(mStencilbuffer.type(), mRenderer->getCurrentClientVersion()))
if (mStencilbuffer && mStencilbuffer->isTextureWithId(textureId))
{
mStencilbuffer.set(NULL, GL_NONE, 0, 0);
SafeDelete(mStencilbuffer);
}
}
void Framebuffer::detachRenderbuffer(GLuint renderbuffer)
void Framebuffer::detachRenderbuffer(GLuint renderbufferId)
{
for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
{
if (mColorbuffers[colorAttachment].id() == renderbuffer && mColorbuffers[colorAttachment].type() == GL_RENDERBUFFER)
FramebufferAttachment *attachment = mColorbuffers[colorAttachment];
if (attachment && attachment->isRenderbufferWithId(renderbufferId))
{
mColorbuffers[colorAttachment].set(NULL, GL_NONE, 0, 0);
SafeDelete(mColorbuffers[colorAttachment]);
}
}
if (mDepthbuffer.id() == renderbuffer && mDepthbuffer.type() == GL_RENDERBUFFER)
if (mDepthbuffer && mDepthbuffer->isRenderbufferWithId(renderbufferId))
{
mDepthbuffer.set(NULL, GL_NONE, 0, 0);
SafeDelete(mDepthbuffer);
}
if (mStencilbuffer.id() == renderbuffer && mStencilbuffer.type() == GL_RENDERBUFFER)
if (mStencilbuffer && mStencilbuffer->isRenderbufferWithId(renderbufferId))
{
mStencilbuffer.set(NULL, GL_NONE, 0, 0);
SafeDelete(mStencilbuffer);
}
}
unsigned int Framebuffer::getRenderTargetSerial(unsigned int colorAttachment) const
FramebufferAttachment *Framebuffer::getColorbuffer(unsigned int colorAttachment) const
{
ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS);
Renderbuffer *colorbuffer = mColorbuffers[colorAttachment].get();
if (colorbuffer)
{
return colorbuffer->getSerial();
}
return 0;
return mColorbuffers[colorAttachment];
}
unsigned int Framebuffer::getDepthbufferSerial() const
FramebufferAttachment *Framebuffer::getDepthbuffer() const
{
Renderbuffer *depthbuffer = mDepthbuffer.get();
if (depthbuffer)
{
return depthbuffer->getSerial();
}
return 0;
return mDepthbuffer;
}
unsigned int Framebuffer::getStencilbufferSerial() const
FramebufferAttachment *Framebuffer::getStencilbuffer() const
{
Renderbuffer *stencilbuffer = mStencilbuffer.get();
if (stencilbuffer)
{
return stencilbuffer->getSerial();
}
return 0;
return mStencilbuffer;
}
Renderbuffer *Framebuffer::getColorbuffer(unsigned int colorAttachment) const
FramebufferAttachment *Framebuffer::getDepthStencilBuffer() const
{
ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS);
return mColorbuffers[colorAttachment].get();
return (hasValidDepthStencil() ? mDepthbuffer : NULL);
}
Renderbuffer *Framebuffer::getDepthbuffer() const
FramebufferAttachment *Framebuffer::getDepthOrStencilbuffer() const
{
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();
FramebufferAttachment *depthstencilbuffer = mDepthbuffer;
if (!depthstencilbuffer)
{
depthstencilbuffer = mStencilbuffer.get();
depthstencilbuffer = mStencilbuffer;
}
return depthstencilbuffer;
}
Renderbuffer *Framebuffer::getReadColorbuffer() const
FramebufferAttachment *Framebuffer::getReadColorbuffer() const
{
// Will require more logic if glReadBuffers is supported
return mColorbuffers[0].get();
return mColorbuffers[0];
}
GLenum Framebuffer::getReadColorbufferType() const
{
// Will require more logic if glReadBuffers is supported
return mColorbuffers[0].type();
return (mColorbuffers[0] ? mColorbuffers[0]->type() : GL_NONE);
}
Renderbuffer *Framebuffer::getFirstColorbuffer() const
FramebufferAttachment *Framebuffer::getFirstColorbuffer() const
{
for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
{
if (mColorbuffers[colorAttachment].type() != GL_NONE)
if (mColorbuffers[colorAttachment])
{
return mColorbuffers[colorAttachment].get();
return mColorbuffers[colorAttachment];
}
}
@ -314,85 +274,85 @@ Renderbuffer *Framebuffer::getFirstColorbuffer() const
GLenum Framebuffer::getColorbufferType(unsigned int colorAttachment) const
{
ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS);
return mColorbuffers[colorAttachment].type();
return (mColorbuffers[colorAttachment] ? mColorbuffers[colorAttachment]->type() : GL_NONE);
}
GLenum Framebuffer::getDepthbufferType() const
{
return mDepthbuffer.type();
return (mDepthbuffer ? mDepthbuffer->type() : GL_NONE);
}
GLenum Framebuffer::getStencilbufferType() const
{
return mStencilbuffer.type();
return (mStencilbuffer ? mStencilbuffer->type() : GL_NONE);
}
GLenum Framebuffer::getDepthStencilbufferType() const
{
return (mDepthbuffer.id() == mStencilbuffer.id()) ? mDepthbuffer.type() : GL_NONE;
return (hasValidDepthStencil() ? mDepthbuffer->type() : GL_NONE);
}
GLuint Framebuffer::getColorbufferHandle(unsigned int colorAttachment) const
{
ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS);
return mColorbuffers[colorAttachment].id();
return (mColorbuffers[colorAttachment] ? mColorbuffers[colorAttachment]->id() : 0);
}
GLuint Framebuffer::getDepthbufferHandle() const
{
return mDepthbuffer.id();
return (mDepthbuffer ? mDepthbuffer->id() : 0);
}
GLuint Framebuffer::getStencilbufferHandle() const
{
return mStencilbuffer.id();
return (mStencilbuffer ? mStencilbuffer->id() : 0);
}
GLenum Framebuffer::getDepthStencilbufferHandle() const
GLuint Framebuffer::getDepthStencilbufferHandle() const
{
return (mDepthbuffer.id() == mStencilbuffer.id()) ? mDepthbuffer.id() : 0;
return (hasValidDepthStencil() ? mDepthbuffer->id() : 0);
}
GLenum Framebuffer::getColorbufferMipLevel(unsigned int colorAttachment) const
GLint Framebuffer::getColorbufferMipLevel(unsigned int colorAttachment) const
{
ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS);
return mColorbuffers[colorAttachment].mipLevel();
return (mColorbuffers[colorAttachment] ? mColorbuffers[colorAttachment]->mipLevel() : 0);
}
GLenum Framebuffer::getDepthbufferMipLevel() const
GLint Framebuffer::getDepthbufferMipLevel() const
{
return mDepthbuffer.mipLevel();
return (mDepthbuffer ? mDepthbuffer->mipLevel() : 0);
}
GLenum Framebuffer::getStencilbufferMipLevel() const
GLint Framebuffer::getStencilbufferMipLevel() const
{
return mStencilbuffer.mipLevel();
return (mStencilbuffer ? mStencilbuffer->mipLevel() : 0);
}
GLenum Framebuffer::getDepthStencilbufferMipLevel() const
GLint Framebuffer::getDepthStencilbufferMipLevel() const
{
return (mDepthbuffer.id() == mStencilbuffer.id()) ? mDepthbuffer.mipLevel() : 0;
return (hasValidDepthStencil() ? mDepthbuffer->mipLevel() : 0);
}
GLenum Framebuffer::getColorbufferLayer(unsigned int colorAttachment) const
GLint Framebuffer::getColorbufferLayer(unsigned int colorAttachment) const
{
ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS);
return mColorbuffers[colorAttachment].layer();
return (mColorbuffers[colorAttachment] ? mColorbuffers[colorAttachment]->layer() : 0);
}
GLenum Framebuffer::getDepthbufferLayer() const
GLint Framebuffer::getDepthbufferLayer() const
{
return mDepthbuffer.layer();
return (mDepthbuffer ? mDepthbuffer->layer() : 0);
}
GLenum Framebuffer::getStencilbufferLayer() const
GLint Framebuffer::getStencilbufferLayer() const
{
return mStencilbuffer.layer();
return (mStencilbuffer ? mStencilbuffer->layer() : 0);
}
GLenum Framebuffer::getDepthStencilbufferLayer() const
GLint Framebuffer::getDepthStencilbufferLayer() const
{
return (mDepthbuffer.id() == mStencilbuffer.id()) ? mDepthbuffer.layer() : 0;
return (hasValidDepthStencil() ? mDepthbuffer->layer() : 0);
}
GLenum Framebuffer::getDrawBufferState(unsigned int colorAttachment) const
@ -407,7 +367,7 @@ void Framebuffer::setDrawBufferState(unsigned int colorAttachment, GLenum drawBu
bool Framebuffer::isEnabledColorAttachment(unsigned int colorAttachment) const
{
return (mColorbuffers[colorAttachment].type() != GL_NONE && mDrawBufferStates[colorAttachment] != GL_NONE);
return (mColorbuffers[colorAttachment] && mDrawBufferStates[colorAttachment] != GL_NONE);
}
bool Framebuffer::hasEnabledColorAttachment() const
@ -425,17 +385,7 @@ bool Framebuffer::hasEnabledColorAttachment() const
bool Framebuffer::hasStencil() const
{
if (mStencilbuffer.type() != GL_NONE)
{
const Renderbuffer *stencilbufferObject = getStencilbuffer();
if (stencilbufferObject)
{
return stencilbufferObject->getStencilSize() > 0;
}
}
return false;
return (mStencilbuffer && mStencilbuffer->getStencilSize() > 0);
}
bool Framebuffer::usingExtendedDrawBuffers() const
@ -462,46 +412,36 @@ GLenum Framebuffer::completeness() const
for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
{
if (mColorbuffers[colorAttachment].type() != GL_NONE)
const FramebufferAttachment *colorbuffer = mColorbuffers[colorAttachment];
if (colorbuffer)
{
const Renderbuffer *colorbuffer = getColorbuffer(colorAttachment);
if (!colorbuffer)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (colorbuffer->getWidth() == 0 || colorbuffer->getHeight() == 0)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (mColorbuffers[colorAttachment].type() == GL_RENDERBUFFER)
GLenum internalformat = colorbuffer->getInternalFormat();
const TextureCaps &formatCaps = mRenderer->getCaps().textureCaps.get(internalformat);
if (colorbuffer->isTexture())
{
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))
if (!formatCaps.colorRendering)
{
return GL_FRAMEBUFFER_UNSUPPORTED;
}
if (gl::GetDepthBits(internalformat, clientVersion) > 0 ||
gl::GetStencilBits(internalformat, clientVersion) > 0)
if (gl::GetDepthBits(internalformat) > 0 ||
gl::GetStencilBits(internalformat) > 0)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
}
else
{
UNREACHABLE();
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
if (!formatCaps.colorRendering)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
}
if (!missingAttachment)
@ -523,7 +463,7 @@ GLenum Framebuffer::completeness() const
// in GLES 3.0, there is no such restriction
if (clientVersion < 3)
{
if (gl::GetPixelBytes(colorbuffer->getInternalFormat(), clientVersion) != colorbufferSize)
if (gl::GetPixelBytes(colorbuffer->getInternalFormat()) != colorbufferSize)
{
return GL_FRAMEBUFFER_UNSUPPORTED;
}
@ -532,7 +472,8 @@ GLenum Framebuffer::completeness() const
// D3D11 does not allow for overlapping RenderTargetViews, so ensure uniqueness
for (unsigned int previousColorAttachment = 0; previousColorAttachment < colorAttachment; previousColorAttachment++)
{
if (mColorbuffers[colorAttachment].get() == mColorbuffers[previousColorAttachment].get())
if (colorbuffer->id() == getColorbufferHandle(previousColorAttachment) &&
colorbuffer->type() == getColorbufferType(previousColorAttachment))
{
return GL_FRAMEBUFFER_UNSUPPORTED;
}
@ -543,129 +484,116 @@ GLenum Framebuffer::completeness() const
width = colorbuffer->getWidth();
height = colorbuffer->getHeight();
samples = colorbuffer->getSamples();
colorbufferSize = gl::GetPixelBytes(colorbuffer->getInternalFormat(), clientVersion);
colorbufferSize = gl::GetPixelBytes(colorbuffer->getInternalFormat());
missingAttachment = false;
}
}
}
const Renderbuffer *depthbuffer = NULL;
const Renderbuffer *stencilbuffer = NULL;
if (mDepthbuffer.type() != GL_NONE)
if (mDepthbuffer)
{
depthbuffer = getDepthbuffer();
if (!depthbuffer)
if (mDepthbuffer->getWidth() == 0 || mDepthbuffer->getHeight() == 0)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (depthbuffer->getWidth() == 0 || depthbuffer->getHeight() == 0)
GLenum internalformat = mDepthbuffer->getInternalFormat();
const TextureCaps &formatCaps = mRenderer->getCaps().textureCaps.get(internalformat);
if (mDepthbuffer->isTexture())
{
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();
GLenum internalformat = mDepthbuffer->getInternalFormat();
// depth texture attachments require OES/ANGLE_depth_texture
if (!mRenderer->getDepthTextureSupport())
if (!mRenderer->getCaps().extensions.depthTextures)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (gl::GetDepthBits(internalformat, clientVersion) == 0)
if (!formatCaps.depthRendering)
{
return GL_FRAMEBUFFER_UNSUPPORTED;
}
if (gl::GetDepthBits(internalformat) == 0)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
}
else
{
UNREACHABLE();
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
if (!formatCaps.depthRendering)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
}
if (missingAttachment)
{
width = depthbuffer->getWidth();
height = depthbuffer->getHeight();
samples = depthbuffer->getSamples();
width = mDepthbuffer->getWidth();
height = mDepthbuffer->getHeight();
samples = mDepthbuffer->getSamples();
missingAttachment = false;
}
else if (width != depthbuffer->getWidth() || height != depthbuffer->getHeight())
else if (width != mDepthbuffer->getWidth() || height != mDepthbuffer->getHeight())
{
return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
}
else if (samples != depthbuffer->getSamples())
else if (samples != mDepthbuffer->getSamples())
{
return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE;
}
}
if (mStencilbuffer.type() != GL_NONE)
if (mStencilbuffer)
{
stencilbuffer = getStencilbuffer();
if (!stencilbuffer)
if (mStencilbuffer->getWidth() == 0 || mStencilbuffer->getHeight() == 0)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (stencilbuffer->getWidth() == 0 || stencilbuffer->getHeight() == 0)
GLenum internalformat = mStencilbuffer->getInternalFormat();
const TextureCaps &formatCaps = mRenderer->getCaps().textureCaps.get(internalformat);
if (mStencilbuffer->isTexture())
{
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();
GLenum internalformat = mStencilbuffer->getInternalFormat();
// texture stencil attachments come along as part
// of OES_packed_depth_stencil + OES/ANGLE_depth_texture
if (!mRenderer->getDepthTextureSupport())
if (!mRenderer->getCaps().extensions.depthTextures)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (gl::GetStencilBits(internalformat, clientVersion) == 0)
if (!formatCaps.stencilRendering)
{
return GL_FRAMEBUFFER_UNSUPPORTED;
}
if (gl::GetStencilBits(internalformat) == 0)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
}
else
{
UNREACHABLE();
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
if (!formatCaps.stencilRendering)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
}
if (missingAttachment)
{
width = stencilbuffer->getWidth();
height = stencilbuffer->getHeight();
samples = stencilbuffer->getSamples();
width = mStencilbuffer->getWidth();
height = mStencilbuffer->getHeight();
samples = mStencilbuffer->getSamples();
missingAttachment = false;
}
else if (width != stencilbuffer->getWidth() || height != stencilbuffer->getHeight())
else if (width != mStencilbuffer->getWidth() || height != mStencilbuffer->getHeight())
{
return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
}
else if (samples != stencilbuffer->getSamples())
else if (samples != mStencilbuffer->getSamples())
{
return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE;
}
@ -673,7 +601,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 (depthbuffer && stencilbuffer && (depthbuffer != stencilbuffer))
if (mDepthbuffer && mStencilbuffer && !hasValidDepthStencil())
{
return GL_FRAMEBUFFER_UNSUPPORTED;
}
@ -690,11 +618,15 @@ GLenum Framebuffer::completeness() const
DefaultFramebuffer::DefaultFramebuffer(rx::Renderer *renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil)
: Framebuffer(renderer)
{
mColorbuffers[0].set(new Renderbuffer(mRenderer, 0, colorbuffer), GL_RENDERBUFFER, 0, 0);
Renderbuffer *colorRenderbuffer = new Renderbuffer(0, colorbuffer);
mColorbuffers[0] = new RenderbufferAttachment(colorRenderbuffer);
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);
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);
mDrawBufferStates[0] = GL_BACK;
mReadBufferState = GL_BACK;
@ -708,9 +640,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].type() != GL_NONE)
if (mColorbuffers[colorAttachment])
{
return getColorbuffer(colorAttachment)->getSamples();
return mColorbuffers[colorAttachment]->getSamples();
}
}
}
@ -718,6 +650,15 @@ 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

Просмотреть файл

@ -21,7 +21,7 @@ class Renderer;
namespace gl
{
class Renderbuffer;
class FramebufferAttachment;
class Colorbuffer;
class Depthbuffer;
class Stencilbuffer;
@ -42,18 +42,14 @@ class Framebuffer
void detachTexture(GLuint texture);
void detachRenderbuffer(GLuint renderbuffer);
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;
FramebufferAttachment *getColorbuffer(unsigned int colorAttachment) const;
FramebufferAttachment *getDepthbuffer() const;
FramebufferAttachment *getStencilbuffer() const;
FramebufferAttachment *getDepthStencilBuffer() const;
FramebufferAttachment *getDepthOrStencilbuffer() const;
FramebufferAttachment *getReadColorbuffer() const;
GLenum getReadColorbufferType() const;
Renderbuffer *getFirstColorbuffer() const;
FramebufferAttachment *getFirstColorbuffer() const;
GLenum getColorbufferType(unsigned int colorAttachment) const;
GLenum getDepthbufferType() const;
@ -63,17 +59,17 @@ class Framebuffer
GLuint getColorbufferHandle(unsigned int colorAttachment) const;
GLuint getDepthbufferHandle() const;
GLuint getStencilbufferHandle() const;
GLenum getDepthStencilbufferHandle() const;
GLuint getDepthStencilbufferHandle() const;
GLenum getColorbufferMipLevel(unsigned int colorAttachment) const;
GLenum getDepthbufferMipLevel() const;
GLenum getStencilbufferMipLevel() const;
GLenum getDepthStencilbufferMipLevel() const;
GLint getColorbufferMipLevel(unsigned int colorAttachment) const;
GLint getDepthbufferMipLevel() const;
GLint getStencilbufferMipLevel() const;
GLint getDepthStencilbufferMipLevel() const;
GLenum getColorbufferLayer(unsigned int colorAttachment) const;
GLenum getDepthbufferLayer() const;
GLenum getStencilbufferLayer() const;
GLenum getDepthStencilbufferLayer() const;
GLint getColorbufferLayer(unsigned int colorAttachment) const;
GLint getDepthbufferLayer() const;
GLint getStencilbufferLayer() const;
GLint getDepthStencilbufferLayer() const;
GLenum getDrawBufferState(unsigned int colorAttachment) const;
void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
@ -87,19 +83,21 @@ class Framebuffer
virtual GLenum completeness() const;
protected:
FramebufferTextureBindingPointer<Renderbuffer> mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
rx::Renderer *mRenderer;
FramebufferAttachment *mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS];
GLenum mReadBufferState;
FramebufferTextureBindingPointer<Renderbuffer> mDepthbuffer;
FramebufferTextureBindingPointer<Renderbuffer> mStencilbuffer;
FramebufferAttachment *mDepthbuffer;
FramebufferAttachment *mStencilbuffer;
rx::Renderer *mRenderer;
bool hasValidDepthStencil() const;
private:
private:
DISALLOW_COPY_AND_ASSIGN(Framebuffer);
Renderbuffer *lookupRenderbuffer(GLenum type, GLuint handle, GLint level, GLint layer) const;
FramebufferAttachment *createAttachment(GLenum type, GLuint handle, GLint level, GLint layer) const;
};
class DefaultFramebuffer : public Framebuffer

Просмотреть файл

@ -0,0 +1,495 @@
#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;
}
}

Просмотреть файл

@ -0,0 +1,246 @@
//
// 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<Texture2D> 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<TextureCubeMap> 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<Texture3D> 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<Texture2DArray> 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<Renderbuffer> mRenderbuffer;
};
}
#endif // LIBGLESV2_FRAMEBUFFERATTACHMENT_H_

Просмотреть файл

@ -10,8 +10,7 @@
#ifndef LIBGLESV2_HANDLEALLOCATOR_H_
#define LIBGLESV2_HANDLEALLOCATOR_H_
#include <GLES3/gl3.h>
#include <GLES2/gl2.h>
#include "angle_gl.h"
#include <vector>

Просмотреть файл

@ -10,6 +10,8 @@
#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"
@ -20,7 +22,7 @@
#include "libGLESv2/Shader.h"
#include "libGLESv2/Program.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/VertexDataManager.h"
#include "libGLESv2/renderer/d3d/VertexDataManager.h"
#include "libGLESv2/Context.h"
#include "libGLESv2/Buffer.h"
#include "libGLESv2/DynamicHLSL.h"
@ -51,14 +53,14 @@ unsigned int ParseAndStripArrayIndex(std::string* name)
return subscript;
}
void GetInputLayoutFromShader(const std::vector<gl::Attribute> &shaderAttributes, VertexFormat inputLayout[MAX_VERTEX_ATTRIBS])
void GetInputLayoutFromShader(const std::vector<sh::Attribute> &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 gl::Attribute &shaderAttr = shaderAttributes[attributeIndex];
const sh::Attribute &shaderAttr = shaderAttributes[attributeIndex];
if (shaderAttr.type != GL_NONE)
{
@ -68,7 +70,7 @@ void GetInputLayoutFromShader(const std::vector<gl::Attribute> &shaderAttributes
{
VertexFormat *defaultFormat = &inputLayout[layoutIndex];
defaultFormat->mType = UniformComponentType(transposedType);
defaultFormat->mType = VariableComponentType(transposedType);
defaultFormat->mNormalized = false;
defaultFormat->mPureInteger = (defaultFormat->mType != GL_FLOAT); // note: inputs can not be bool
defaultFormat->mComponents = VariableColumnCount(transposedType);
@ -84,8 +86,7 @@ VariableLocation::VariableLocation(const std::string &name, unsigned int element
{
}
ProgramBinary::VertexExecutable::VertexExecutable(rx::Renderer *const renderer,
const VertexFormat inputLayout[],
ProgramBinary::VertexExecutable::VertexExecutable(const VertexFormat inputLayout[],
const GLenum signature[],
rx::ShaderExecutable *shaderExecutable)
: mShaderExecutable(shaderExecutable)
@ -99,7 +100,7 @@ ProgramBinary::VertexExecutable::VertexExecutable(rx::Renderer *const renderer,
ProgramBinary::VertexExecutable::~VertexExecutable()
{
delete mShaderExecutable;
SafeDelete(mShaderExecutable);
}
bool ProgramBinary::VertexExecutable::matchesSignature(const GLenum signature[]) const
@ -115,6 +116,17 @@ bool ProgramBinary::VertexExecutable::matchesSignature(const GLenum signature[])
return true;
}
ProgramBinary::PixelExecutable::PixelExecutable(const std::vector<GLenum> &outputSignature, rx::ShaderExecutable *shaderExecutable)
: mOutputSignature(outputSignature),
mShaderExecutable(shaderExecutable)
{
}
ProgramBinary::PixelExecutable::~PixelExecutable()
{
SafeDelete(mShaderExecutable);
}
LinkedVarying::LinkedVarying()
{
}
@ -132,7 +144,7 @@ ProgramBinary::ProgramBinary(rx::Renderer *renderer)
mRenderer(renderer),
mDynamicHLSL(NULL),
mVertexWorkarounds(rx::ANGLE_D3D_WORKAROUND_NONE),
mPixelExecutable(NULL),
mPixelWorkarounds(rx::ANGLE_D3D_WORKAROUND_NONE),
mGeometryExecutable(NULL),
mUsedVertexSamplerRange(0),
mUsedPixelSamplerRange(0),
@ -163,29 +175,7 @@ ProgramBinary::ProgramBinary(rx::Renderer *renderer)
ProgramBinary::~ProgramBinary()
{
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);
reset();
SafeDelete(mDynamicHLSL);
}
@ -204,9 +194,57 @@ unsigned int ProgramBinary::issueSerial()
return mCurrentSerial++;
}
rx::ShaderExecutable *ProgramBinary::getPixelExecutable() const
rx::ShaderExecutable *ProgramBinary::getPixelExecutableForFramebuffer(const Framebuffer *fbo)
{
return mPixelExecutable;
std::vector<GLenum> 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<GLenum> &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<char> tempCharBuffer(tempInfoLog.getLength() + 3);
tempInfoLog.getLog(tempInfoLog.getLength(), NULL, &tempCharBuffer[0]);
ERR("Error compiling dynamic pixel executable:\n%s\n", &tempCharBuffer[0]);
}
else
{
mPixelExecutables.push_back(new PixelExecutable(outputSignature, pixelExecutable));
}
return pixelExecutable;
}
rx::ShaderExecutable *ProgramBinary::getVertexExecutableForInputLayout(const VertexFormat inputLayout[MAX_VERTEX_ATTRIBS])
@ -223,16 +261,11 @@ rx::ShaderExecutable *ProgramBinary::getVertexExecutableForInputLayout(const Ver
}
// Generate new dynamic layout with attribute conversions
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);
std::string finalVertexHLSL = mDynamicHLSL->generateVertexShaderForInputLayout(mVertexHLSL, inputLayout, mShaderAttributes);
// Generate new vertex executable
InfoLog tempInfoLog;
rx::ShaderExecutable *vertexExecutable = mRenderer->compileToExecutable(tempInfoLog, vertexHLSL.c_str(),
rx::ShaderExecutable *vertexExecutable = mRenderer->compileToExecutable(tempInfoLog, finalVertexHLSL.c_str(),
rx::SHADER_VERTEX,
mTransformFeedbackLinkedVaryings,
(mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS),
@ -246,7 +279,7 @@ rx::ShaderExecutable *ProgramBinary::getVertexExecutableForInputLayout(const Ver
}
else
{
mVertexExecutables.push_back(new VertexExecutable(mRenderer, inputLayout, signature, vertexExecutable));
mVertexExecutables.push_back(new VertexExecutable(inputLayout, signature, vertexExecutable));
}
return vertexExecutable;
@ -487,8 +520,8 @@ static inline void SetIfDirty(T *dest, const T& source, bool *dirtyFlag)
template <typename T>
void ProgramBinary::setUniform(GLint location, GLsizei count, const T* v, GLenum targetUniformType)
{
const int components = UniformComponentCount(targetUniformType);
const GLenum targetBoolType = UniformBoolVectorType(targetUniformType);
const int components = VariableComponentCount(targetUniformType);
const GLenum targetBoolType = VariableBoolVectorType(targetUniformType);
LinkedUniform *targetUniform = getUniformByLocation(location);
@ -777,7 +810,7 @@ bool ProgramBinary::getUniformv(GLint location, GLsizei *bufSize, T *params, GLe
// sized queries -- ensure the provided buffer is large enough
if (bufSize)
{
int requiredBytes = UniformExternalSize(targetUniform->type);
int requiredBytes = VariableExternalSize(targetUniform->type);
if (*bufSize < requiredBytes)
{
return false;
@ -790,16 +823,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 == UniformComponentType(targetUniform->type))
else if (uniformType == VariableComponentType(targetUniform->type))
{
unsigned int size = UniformComponentCount(targetUniform->type);
unsigned int size = VariableComponentCount(targetUniform->type);
memcpy(params, targetUniform->data + mUniformIndex[location].element * 4 * sizeof(T),
size * sizeof(T));
}
else
{
unsigned int size = UniformComponentCount(targetUniform->type);
switch (UniformComponentType(targetUniform->type))
unsigned int size = VariableComponentCount(targetUniform->type);
switch (VariableComponentType(targetUniform->type))
{
case GL_BOOL:
{
@ -946,12 +979,12 @@ bool ProgramBinary::applyUniformBuffers(const std::vector<gl::Buffer*> boundBuff
for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < mUniformBlocks.size(); uniformBlockIndex++)
{
gl::UniformBlock *uniformBlock = getUniformBlockByIndex(uniformBlockIndex);
UniformBlock *uniformBlock = getUniformBlockByIndex(uniformBlockIndex);
gl::Buffer *uniformBuffer = boundBuffers[uniformBlockIndex];
ASSERT(uniformBlock && uniformBuffer);
if (uniformBuffer->size() < uniformBlock->dataSize)
if (uniformBuffer->getSize() < uniformBlock->dataSize)
{
// undefined behaviour
return false;
@ -1018,6 +1051,11 @@ 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<int>();
@ -1101,7 +1139,7 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length)
int matrixStride = stream.readInt<int>();
bool isRowMajorMatrix = stream.readBool();
const gl::BlockMemberInfo blockInfo(offset, arrayStride, matrixStride, isRowMajorMatrix);
const sh::BlockMemberInfo blockInfo(offset, arrayStride, matrixStride, isRowMajorMatrix);
LinkedUniform *uniform = new LinkedUniform(type, precision, name, arraySize, blockIndex, blockInfo);
@ -1177,7 +1215,6 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length)
stream.readInt(&mVertexWorkarounds);
const unsigned int vertexShaderCount = stream.readInt<unsigned int>();
for (unsigned int vertexShaderIndex = 0; vertexShaderIndex < vertexShaderCount; vertexShaderIndex++)
{
VertexFormat inputLayout[MAX_VERTEX_ATTRIBS];
@ -1192,9 +1229,7 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length)
}
unsigned int vertexShaderSize = stream.readInt<unsigned int>();
const char *vertexShaderFunction = (const char*) binary + stream.offset();
const unsigned char *vertexShaderFunction = reinterpret_cast<const unsigned char*>(binary) + stream.offset();
rx::ShaderExecutable *shaderExecutable = mRenderer->loadExecutable(reinterpret_cast<const DWORD*>(vertexShaderFunction),
vertexShaderSize, rx::SHADER_VERTEX,
mTransformFeedbackLinkedVaryings,
@ -1210,23 +1245,52 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length)
mDynamicHLSL->getInputLayoutSignature(inputLayout, signature);
// add new binary
mVertexExecutables.push_back(new VertexExecutable(mRenderer, inputLayout, signature, shaderExecutable));
mVertexExecutables.push_back(new VertexExecutable(inputLayout, signature, shaderExecutable));
stream.skip(vertexShaderSize);
}
unsigned int pixelShaderSize = stream.readInt<unsigned int>();
stream.readString(&mPixelHLSL);
stream.readInt(&mPixelWorkarounds);
stream.readBool(&mUsesFragDepth);
const char *pixelShaderFunction = (const char*) binary + stream.offset();
mPixelExecutable = mRenderer->loadExecutable(reinterpret_cast<const DWORD*>(pixelShaderFunction),
pixelShaderSize, rx::SHADER_PIXEL, mTransformFeedbackLinkedVaryings,
(mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS));
if (!mPixelExecutable)
const size_t pixelShaderKeySize = stream.readInt<unsigned int>();
mPixelShaderKey.resize(pixelShaderKeySize);
for (size_t pixelShaderKeyIndex = 0; pixelShaderKeyIndex < pixelShaderKeySize; pixelShaderKeyIndex++)
{
infoLog.append("Could not create pixel shader.");
return false;
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<unsigned int>();
for (size_t pixelShaderIndex = 0; pixelShaderIndex < pixelShaderCount; pixelShaderIndex++)
{
const size_t outputCount = stream.readInt<unsigned int>();
std::vector<GLenum> outputs(outputCount);
for (size_t outputIndex = 0; outputIndex < outputCount; outputIndex++)
{
stream.readInt(&outputs[outputIndex]);
}
const size_t pixelShaderSize = stream.readInt<unsigned int>();
const unsigned char *pixelShaderFunction = reinterpret_cast<const unsigned char*>(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);
}
stream.skip(pixelShaderSize);
unsigned int geometryShaderSize = stream.readInt<unsigned int>();
@ -1239,7 +1303,6 @@ 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);
@ -1260,6 +1323,7 @@ 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)
@ -1387,11 +1451,38 @@ bool ProgramBinary::save(void* binary, GLsizei bufSize, GLsizei *length)
stream.writeBytes(vertexBlob, vertexShaderSize);
}
size_t pixelShaderSize = mPixelExecutable->getLength();
stream.writeInt(pixelShaderSize);
stream.writeString(mPixelHLSL);
stream.writeInt(mPixelWorkarounds);
stream.writeInt(mUsesFragDepth);
unsigned char *pixelBlob = static_cast<unsigned char *>(mPixelExecutable->getFunction());
stream.writeBytes(pixelBlob, 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<GLenum> outputs = pixelExecutable->outputSignature();
stream.writeInt(outputs.size());
for (size_t outputIndex = 0; outputIndex < outputs.size(); outputIndex++)
{
stream.writeInt(outputs[outputIndex]);
}
size_t pixelShaderSize = pixelExecutable->shaderExecutable()->getLength();
stream.writeInt(pixelShaderSize);
unsigned char *pixelBlob = static_cast<unsigned char *>(pixelExecutable->shaderExecutable()->getFunction());
stream.writeBytes(pixelBlob, pixelShaderSize);
}
size_t geometryShaderSize = (mGeometryExecutable != NULL) ? mGeometryExecutable->getLength() : 0;
stream.writeInt(geometryShaderSize);
@ -1465,12 +1556,15 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin
return false;
}
mTransformFeedbackLinkedVaryings.clear();
reset();
mTransformFeedbackBufferMode = transformFeedbackBufferMode;
mShaderVersion = vertexShader->getShaderVersion();
std::string pixelHLSL = fragmentShader->getHLSL();
mPixelHLSL = fragmentShader->getHLSL();
mPixelWorkarounds = fragmentShader->getD3DWorkarounds();
mVertexHLSL = vertexShader->getHLSL();
mVertexWorkarounds = vertexShader->getD3DWorkarounds();
@ -1490,9 +1584,9 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin
mUsesPointSize = vertexShader->usesPointSize();
std::vector<LinkedVarying> linkedVaryings;
if (!mDynamicHLSL->generateShaderLinkHLSL(infoLog, registers, packing, pixelHLSL, mVertexHLSL,
if (!mDynamicHLSL->generateShaderLinkHLSL(infoLog, registers, packing, mPixelHLSL, mVertexHLSL,
fragmentShader, vertexShader, transformFeedbackVaryings,
&linkedVaryings, &mOutputVariables))
&linkedVaryings, &mOutputVariables, &mPixelShaderKey, &mUsesFragDepth))
{
return false;
}
@ -1512,9 +1606,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, 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()));
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()));
}
if (!linkUniformBlocks(infoLog, vertexShader->getInterfaceBlocks(), fragmentShader->getInterfaceBlocks()))
@ -1532,12 +1626,14 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin
{
VertexFormat defaultInputLayout[MAX_VERTEX_ATTRIBS];
GetInputLayoutFromShader(vertexShader->activeAttributes(), defaultInputLayout);
rx::ShaderExecutable *defaultVertexExecutable = getVertexExecutableForInputLayout(defaultInputLayout);
mPixelExecutable = mRenderer->compileToExecutable(infoLog, pixelHLSL.c_str(), rx::SHADER_PIXEL,
mTransformFeedbackLinkedVaryings,
(mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS),
fragmentShader->getD3DWorkarounds());
std::vector<GLenum> 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);
if (usesGeometryShader())
{
@ -1548,21 +1644,11 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin
rx::ANGLE_D3D_WORKAROUND_NONE);
}
if (!defaultVertexExecutable || !mPixelExecutable || (usesGeometryShader() && !mGeometryExecutable))
if (!defaultVertexExecutable || !defaultPixelExecutable || (usesGeometryShader() && !mGeometryExecutable))
{
infoLog.append("Failed to create D3D shaders.");
success = false;
while (!mVertexExecutables.empty())
{
delete mVertexExecutables.back();
mVertexExecutables.pop_back();
}
SafeDelete(mGeometryExecutable);
SafeDelete(mPixelExecutable);
mTransformFeedbackLinkedVaryings.clear();
reset();
}
}
@ -1573,19 +1659,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<gl::Attribute> &activeAttributes = vertexShader->activeAttributes();
const std::vector<sh::Attribute> &activeAttributes = vertexShader->activeAttributes();
// Link attributes that have a binding location
for (unsigned int attributeIndex = 0; attributeIndex < activeAttributes.size(); attributeIndex++)
{
const gl::Attribute &attribute = activeAttributes[attributeIndex];
const sh::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 = AttributeRegisterCount(attribute.type);
const int rows = VariableRegisterCount(attribute.type);
if (rows + location > MAX_VERTEX_ATTRIBS)
{
@ -1597,7 +1683,7 @@ bool ProgramBinary::linkAttributes(InfoLog &infoLog, const AttributeBindings &at
for (int row = 0; row < rows; row++)
{
const int rowLocation = location + row;
gl::ShaderVariable &linkedAttribute = mLinkedAttribute[rowLocation];
sh::ShaderVariable &linkedAttribute = mLinkedAttribute[rowLocation];
// In GLSL 3.00, attribute aliasing produces a link error
// In GLSL 1.00, attribute aliasing is allowed
@ -1619,12 +1705,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 gl::Attribute &attribute = activeAttributes[attributeIndex];
const sh::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 = AttributeRegisterCount(attribute.type);
int rows = VariableRegisterCount(attribute.type);
int availableIndex = AllocateFirstFreeBits(&usedLocations, rows, MAX_VERTEX_ATTRIBS);
if (availableIndex == -1 || availableIndex + rows > MAX_VERTEX_ATTRIBS)
@ -1641,7 +1727,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 = AttributeRegisterCount(mLinkedAttribute[attributeIndex].type);
int rows = VariableRegisterCount(mLinkedAttribute[attributeIndex].type);
for (int r = 0; r < rows; r++)
{
@ -1654,7 +1740,8 @@ bool ProgramBinary::linkAttributes(InfoLog &infoLog, const AttributeBindings &at
return true;
}
bool ProgramBinary::linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const gl::ShaderVariable &vertexVariable, const gl::ShaderVariable &fragmentVariable, bool validatePrecision)
bool ProgramBinary::linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const sh::ShaderVariable &vertexVariable,
const sh::ShaderVariable &fragmentVariable, bool validatePrecision)
{
if (vertexVariable.type != fragmentVariable.type)
{
@ -1706,14 +1793,14 @@ bool ProgramBinary::linkValidateFields(InfoLog &infoLog, const std::string &varN
return true;
}
bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const gl::Uniform &vertexUniform, const gl::Uniform &fragmentUniform)
bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform)
{
if (!linkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform, true))
{
return false;
}
if (!linkValidateFields<gl::Uniform>(infoLog, uniformName, vertexUniform, fragmentUniform))
if (!linkValidateFields<sh::Uniform>(infoLog, uniformName, vertexUniform, fragmentUniform))
{
return false;
}
@ -1721,7 +1808,7 @@ bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &u
return true;
}
bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &varyingName, const gl::Varying &vertexVarying, const gl::Varying &fragmentVarying)
bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &varyingName, const sh::Varying &vertexVarying, const sh::Varying &fragmentVarying)
{
if (!linkValidateVariablesBase(infoLog, varyingName, vertexVarying, fragmentVarying, false))
{
@ -1734,7 +1821,7 @@ bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &v
return false;
}
if (!linkValidateFields<gl::Varying>(infoLog, varyingName, vertexVarying, fragmentVarying))
if (!linkValidateFields<sh::Varying>(infoLog, varyingName, vertexVarying, fragmentVarying))
{
return false;
}
@ -1742,7 +1829,7 @@ bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &v
return true;
}
bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const gl::InterfaceBlockField &vertexUniform, const gl::InterfaceBlockField &fragmentUniform)
bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform)
{
if (!linkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform, true))
{
@ -1755,7 +1842,7 @@ bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &u
return false;
}
if (!linkValidateFields<gl::InterfaceBlockField>(infoLog, uniformName, vertexUniform, fragmentUniform))
if (!linkValidateFields<sh::InterfaceBlockField>(infoLog, uniformName, vertexUniform, fragmentUniform))
{
return false;
}
@ -1763,25 +1850,25 @@ bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &u
return true;
}
bool ProgramBinary::linkUniforms(InfoLog &infoLog, const std::vector<gl::Uniform> &vertexUniforms, const std::vector<gl::Uniform> &fragmentUniforms)
bool ProgramBinary::linkUniforms(InfoLog &infoLog, const std::vector<sh::Uniform> &vertexUniforms, const std::vector<sh::Uniform> &fragmentUniforms)
{
// Check that uniforms defined in the vertex and fragment shaders are identical
typedef std::map<std::string, const gl::Uniform*> UniformMap;
typedef std::map<std::string, const sh::Uniform*> UniformMap;
UniformMap linkedUniforms;
for (unsigned int vertexUniformIndex = 0; vertexUniformIndex < vertexUniforms.size(); vertexUniformIndex++)
{
const gl::Uniform &vertexUniform = vertexUniforms[vertexUniformIndex];
const sh::Uniform &vertexUniform = vertexUniforms[vertexUniformIndex];
linkedUniforms[vertexUniform.name] = &vertexUniform;
}
for (unsigned int fragmentUniformIndex = 0; fragmentUniformIndex < fragmentUniforms.size(); fragmentUniformIndex++)
{
const gl::Uniform &fragmentUniform = fragmentUniforms[fragmentUniformIndex];
const sh::Uniform &fragmentUniform = fragmentUniforms[fragmentUniformIndex];
UniformMap::const_iterator entry = linkedUniforms.find(fragmentUniform.name);
if (entry != linkedUniforms.end())
{
const gl::Uniform &vertexUniform = *entry->second;
const sh::Uniform &vertexUniform = *entry->second;
const std::string &uniformName = "uniform '" + vertexUniform.name + "'";
if (!linkValidateVariables(infoLog, uniformName, vertexUniform, fragmentUniform))
{
@ -1841,7 +1928,7 @@ TextureType ProgramBinary::getTextureType(GLenum samplerType, InfoLog &infoLog)
return TEXTURE_2D;
}
bool ProgramBinary::defineUniform(GLenum shader, const gl::Uniform &constant, InfoLog &infoLog)
bool ProgramBinary::defineUniform(GLenum shader, const sh::Uniform &constant, InfoLog &infoLog)
{
if (constant.isStruct())
{
@ -1856,10 +1943,10 @@ bool ProgramBinary::defineUniform(GLenum shader, const gl::Uniform &constant, In
for (size_t fieldIndex = 0; fieldIndex < constant.fields.size(); fieldIndex++)
{
const gl::Uniform &field = constant.fields[fieldIndex];
const sh::Uniform &field = constant.fields[fieldIndex];
const std::string &uniformName = constant.name + ArrayString(elementIndex) + "." + field.name;
const unsigned int fieldRegisterIndex = field.registerIndex + elementRegisterOffset;
gl::Uniform fieldUniform(field.type, field.precision, uniformName.c_str(), field.arraySize,
sh::Uniform fieldUniform(field.type, field.precision, uniformName.c_str(), field.arraySize,
fieldRegisterIndex, field.elementIndex);
fieldUniform.fields = field.fields;
@ -1874,10 +1961,10 @@ bool ProgramBinary::defineUniform(GLenum shader, const gl::Uniform &constant, In
{
for (size_t fieldIndex = 0; fieldIndex < constant.fields.size(); fieldIndex++)
{
const gl::Uniform &field = constant.fields[fieldIndex];
const sh::Uniform &field = constant.fields[fieldIndex];
const std::string &uniformName = constant.name + "." + field.name;
gl::Uniform fieldUniform(field.type, field.precision, uniformName.c_str(), field.arraySize,
sh::Uniform fieldUniform(field.type, field.precision, uniformName.c_str(), field.arraySize,
field.registerIndex, field.elementIndex);
fieldUniform.fields = field.fields;
@ -1945,7 +2032,7 @@ bool ProgramBinary::defineUniform(GLenum shader, const gl::Uniform &constant, In
else
{
uniform = new LinkedUniform(constant.type, constant.precision, constant.name, constant.arraySize,
-1, BlockMemberInfo::getDefaultBlockInfo());
-1, sh::BlockMemberInfo::getDefaultBlockInfo());
uniform->registerElement = constant.elementIndex;
}
@ -1998,7 +2085,7 @@ bool ProgramBinary::defineUniform(GLenum shader, const gl::Uniform &constant, In
return true;
}
bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &infoLog, const gl::InterfaceBlock &vertexInterfaceBlock, const gl::InterfaceBlock &fragmentInterfaceBlock)
bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::InterfaceBlock &vertexInterfaceBlock, const sh::InterfaceBlock &fragmentInterfaceBlock)
{
const char* blockName = vertexInterfaceBlock.name.c_str();
@ -2024,8 +2111,8 @@ bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &infoLog, const gl::Inter
const unsigned int numBlockMembers = vertexInterfaceBlock.fields.size();
for (unsigned int blockMemberIndex = 0; blockMemberIndex < numBlockMembers; blockMemberIndex++)
{
const gl::InterfaceBlockField &vertexMember = vertexInterfaceBlock.fields[blockMemberIndex];
const gl::InterfaceBlockField &fragmentMember = fragmentInterfaceBlock.fields[blockMemberIndex];
const sh::InterfaceBlockField &vertexMember = vertexInterfaceBlock.fields[blockMemberIndex];
const sh::InterfaceBlockField &fragmentMember = fragmentInterfaceBlock.fields[blockMemberIndex];
if (vertexMember.name != fragmentMember.name)
{
@ -2044,26 +2131,26 @@ bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &infoLog, const gl::Inter
return true;
}
bool ProgramBinary::linkUniformBlocks(InfoLog &infoLog, const std::vector<gl::InterfaceBlock> &vertexInterfaceBlocks,
const std::vector<gl::InterfaceBlock> &fragmentInterfaceBlocks)
bool ProgramBinary::linkUniformBlocks(InfoLog &infoLog, const std::vector<sh::InterfaceBlock> &vertexInterfaceBlocks,
const std::vector<sh::InterfaceBlock> &fragmentInterfaceBlocks)
{
// Check that interface blocks defined in the vertex and fragment shaders are identical
typedef std::map<std::string, const gl::InterfaceBlock*> UniformBlockMap;
typedef std::map<std::string, const sh::InterfaceBlock*> UniformBlockMap;
UniformBlockMap linkedUniformBlocks;
for (unsigned int blockIndex = 0; blockIndex < vertexInterfaceBlocks.size(); blockIndex++)
{
const gl::InterfaceBlock &vertexInterfaceBlock = vertexInterfaceBlocks[blockIndex];
const sh::InterfaceBlock &vertexInterfaceBlock = vertexInterfaceBlocks[blockIndex];
linkedUniformBlocks[vertexInterfaceBlock.name] = &vertexInterfaceBlock;
}
for (unsigned int blockIndex = 0; blockIndex < fragmentInterfaceBlocks.size(); blockIndex++)
{
const gl::InterfaceBlock &fragmentInterfaceBlock = fragmentInterfaceBlocks[blockIndex];
const sh::InterfaceBlock &fragmentInterfaceBlock = fragmentInterfaceBlocks[blockIndex];
UniformBlockMap::const_iterator entry = linkedUniformBlocks.find(fragmentInterfaceBlock.name);
if (entry != linkedUniformBlocks.end())
{
const gl::InterfaceBlock &vertexInterfaceBlock = *entry->second;
const sh::InterfaceBlock &vertexInterfaceBlock = *entry->second;
if (!areMatchingInterfaceBlocks(infoLog, vertexInterfaceBlock, fragmentInterfaceBlock))
{
return false;
@ -2148,11 +2235,11 @@ bool ProgramBinary::gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, cons
return true;
}
void ProgramBinary::defineUniformBlockMembers(const std::vector<gl::InterfaceBlockField> &fields, const std::string &prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector<unsigned int> *blockUniformIndexes)
void ProgramBinary::defineUniformBlockMembers(const std::vector<sh::InterfaceBlockField> &fields, const std::string &prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector<unsigned int> *blockUniformIndexes)
{
for (unsigned int uniformIndex = 0; uniformIndex < fields.size(); uniformIndex++)
{
const gl::InterfaceBlockField &field = fields[uniformIndex];
const sh::InterfaceBlockField &field = fields[uniformIndex];
const std::string &fieldName = (prefix.empty() ? field.name : prefix + "." + field.name);
if (!field.fields.empty())
@ -2183,7 +2270,7 @@ void ProgramBinary::defineUniformBlockMembers(const std::vector<gl::InterfaceBlo
}
}
bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, GLenum shader, const gl::InterfaceBlock &interfaceBlock)
bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, GLenum shader, const sh::InterfaceBlock &interfaceBlock)
{
// create uniform block entries if they do not exist
if (getUniformBlockIndex(interfaceBlock.name) == GL_INVALID_INDEX)
@ -2200,14 +2287,14 @@ bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, GLenum shader, const gl
{
for (unsigned int uniformBlockElement = 0; uniformBlockElement < interfaceBlock.arraySize; uniformBlockElement++)
{
gl::UniformBlock *newUniformBlock = new UniformBlock(interfaceBlock.name, uniformBlockElement, interfaceBlock.dataSize);
UniformBlock *newUniformBlock = new UniformBlock(interfaceBlock.name, uniformBlockElement, interfaceBlock.dataSize);
newUniformBlock->memberUniformIndexes = blockUniformIndexes;
mUniformBlocks.push_back(newUniformBlock);
}
}
else
{
gl::UniformBlock *newUniformBlock = new UniformBlock(interfaceBlock.name, GL_INVALID_INDEX, interfaceBlock.dataSize);
UniformBlock *newUniformBlock = new UniformBlock(interfaceBlock.name, GL_INVALID_INDEX, interfaceBlock.dataSize);
newUniformBlock->memberUniformIndexes = blockUniformIndexes;
mUniformBlocks.push_back(newUniformBlock);
}
@ -2221,7 +2308,7 @@ bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, GLenum shader, const gl
for (unsigned int uniformBlockElement = 0; uniformBlockElement < elementCount; uniformBlockElement++)
{
gl::UniformBlock *uniformBlock = mUniformBlocks[blockIndex + uniformBlockElement];
UniformBlock *uniformBlock = mUniformBlocks[blockIndex + uniformBlockElement];
ASSERT(uniformBlock->name == interfaceBlock.name);
if (!assignUniformBlockRegister(infoLog, uniformBlock, shader, interfaceBlock.registerIndex + uniformBlockElement))
@ -2684,4 +2771,44 @@ 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;
}
}

Просмотреть файл

@ -10,10 +10,7 @@
#ifndef LIBGLESV2_PROGRAM_BINARY_H_
#define LIBGLESV2_PROGRAM_BINARY_H_
#include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include "angle_gl.h"
#include <string>
#include <vector>
@ -24,7 +21,8 @@
#include "libGLESv2/Uniform.h"
#include "libGLESv2/Shader.h"
#include "libGLESv2/Constants.h"
#include "libGLESv2/renderer/VertexDataManager.h"
#include "libGLESv2/renderer/d3d/VertexDataManager.h"
#include "libGLESv2/DynamicHLSL.h"
namespace rx
{
@ -32,7 +30,6 @@ class ShaderExecutable;
class Renderer;
struct TranslatedAttribute;
class UniformStorage;
class DynamicHLSL;
}
namespace gl
@ -42,6 +39,7 @@ class VertexShader;
class InfoLog;
class AttributeBindings;
class Buffer;
class Framebuffer;
// Struct used for correlating uniforms/elements of uniform arrays to handles
struct VariableLocation
@ -82,7 +80,8 @@ class ProgramBinary : public RefCountObject
explicit ProgramBinary(rx::Renderer *renderer);
~ProgramBinary();
rx::ShaderExecutable *getPixelExecutable() const;
rx::ShaderExecutable *getPixelExecutableForFramebuffer(const Framebuffer *fbo);
rx::ShaderExecutable *getPixelExecutableForOutputLayout(const std::vector<GLenum> &outputLayout);
rx::ShaderExecutable *getVertexExecutableForInputLayout(const VertexFormat inputLayout[MAX_VERTEX_ATTRIBS]);
rx::ShaderExecutable *getGeometryExecutable() const;
@ -177,28 +176,30 @@ 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<BlockMemberInfo>::const_iterator BlockInfoItr;
typedef std::vector<sh::BlockMemberInfo>::const_iterator BlockInfoItr;
template <class ShaderVarType>
bool linkValidateFields(InfoLog &infoLog, const std::string &varName, const ShaderVarType &vertexVar, const ShaderVarType &fragmentVar);
bool linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const ShaderVariable &vertexVariable, const ShaderVariable &fragmentVariable, bool validatePrecision);
bool linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const sh::ShaderVariable &vertexVariable, const sh::ShaderVariable &fragmentVariable, bool validatePrecision);
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<Uniform> &vertexUniforms, const std::vector<Uniform> &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<InterfaceBlock> &vertexUniformBlocks, const std::vector<InterfaceBlock> &fragmentUniformBlocks);
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<sh::Uniform> &vertexUniforms, const std::vector<sh::Uniform> &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<sh::InterfaceBlock> &vertexUniformBlocks, const std::vector<sh::InterfaceBlock> &fragmentUniformBlocks);
bool gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, const std::vector<LinkedVarying> &linkedVaryings,
const std::vector<std::string> &transformFeedbackVaryingNames,
GLenum transformFeedbackBufferMode,
std::vector<LinkedVarying> *outTransformFeedbackLinkedVaryings) const;
void defineUniformBlockMembers(const std::vector<InterfaceBlockField> &fields, const std::string &prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector<unsigned int> *blockUniformIndexes);
bool defineUniformBlock(InfoLog &infoLog, GLenum shader, const InterfaceBlock &interfaceBlock);
void defineUniformBlockMembers(const std::vector<sh::InterfaceBlockField> &fields, const std::string &prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector<unsigned int> *blockUniformIndexes);
bool defineUniformBlock(InfoLog &infoLog, GLenum shader, const sh::InterfaceBlock &interfaceBlock);
bool assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex);
void defineOutputVariables(FragmentShader *fragmentShader);
void initializeUniformStorage();
@ -217,8 +218,7 @@ class ProgramBinary : public RefCountObject
class VertexExecutable
{
public:
VertexExecutable(rx::Renderer *const renderer,
const VertexFormat inputLayout[MAX_VERTEX_ATTRIBS],
VertexExecutable(const VertexFormat inputLayout[MAX_VERTEX_ATTRIBS],
const GLenum signature[MAX_VERTEX_ATTRIBS],
rx::ShaderExecutable *shaderExecutable);
~VertexExecutable();
@ -235,17 +235,40 @@ class ProgramBinary : public RefCountObject
rx::ShaderExecutable *mShaderExecutable;
};
class PixelExecutable
{
public:
PixelExecutable(const std::vector<GLenum> &outputSignature, rx::ShaderExecutable *shaderExecutable);
~PixelExecutable();
// FIXME(geofflang): Work around NVIDIA driver bug by repacking buffers
bool matchesSignature(const std::vector<GLenum> &signature) const { return true; /* mOutputSignature == signature; */ }
const std::vector<GLenum> &outputSignature() const { return mOutputSignature; }
rx::ShaderExecutable *shaderExecutable() const { return mShaderExecutable; }
private:
std::vector<GLenum> mOutputSignature;
rx::ShaderExecutable *mShaderExecutable;
};
rx::Renderer *const mRenderer;
DynamicHLSL *mDynamicHLSL;
std::string mVertexHLSL;
rx::D3DWorkaroundType mVertexWorkarounds;
std::vector<VertexExecutable *> mVertexExecutables;
rx::ShaderExecutable *mGeometryExecutable;
rx::ShaderExecutable *mPixelExecutable;
Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS];
Attribute mShaderAttributes[MAX_VERTEX_ATTRIBS];
std::string mPixelHLSL;
rx::D3DWorkaroundType mPixelWorkarounds;
bool mUsesFragDepth;
std::vector<PixelShaderOuputVariable> mPixelShaderKey;
std::vector<PixelExecutable *> mPixelExecutables;
rx::ShaderExecutable *mGeometryExecutable;
sh::Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS];
sh::Attribute mShaderAttributes[MAX_VERTEX_ATTRIBS];
int mSemanticIndex[MAX_VERTEX_ATTRIBS];
int mAttributesByLayout[MAX_VERTEX_ATTRIBS];

Просмотреть файл

@ -9,8 +9,7 @@
#ifndef LIBGLESV2_QUERY_H_
#define LIBGLESV2_QUERY_H_
#include <GLES3/gl3.h>
#include <GLES2/gl2.h>
#include "angle_gl.h"
#include "common/angleutils.h"
#include "common/RefCountObject.h"

Просмотреть файл

@ -17,518 +17,91 @@
#include "libGLESv2/renderer/TextureStorage.h"
#include "common/utilities.h"
#include "libGLESv2/formatutils.h"
#include "libGLESv2/FramebufferAttachment.h"
namespace gl
{
unsigned int RenderbufferStorage::mCurrentSerial = 1;
RenderbufferInterface::RenderbufferInterface()
Renderbuffer::Renderbuffer(GLuint id, RenderbufferStorage *newStorage)
: RefCountObject(id),
mStorage(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)
{
}
void RenderbufferInterface::releaseProxy(const Renderbuffer *proxy)
{
}
///// 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
{
return mInstance->getWidth();
}
GLsizei Renderbuffer::getHeight() const
{
return mInstance->getHeight();
}
GLenum Renderbuffer::getInternalFormat() const
{
return mInstance->getInternalFormat();
}
GLenum Renderbuffer::getActualFormat() const
{
return mInstance->getActualFormat();
}
GLuint Renderbuffer::getRedSize() const
{
if (gl::GetRedBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetRedBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
}
GLuint Renderbuffer::getGreenSize() const
{
if (gl::GetGreenBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetGreenBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
}
GLuint Renderbuffer::getBlueSize() const
{
if (gl::GetBlueBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetBlueBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
}
GLuint Renderbuffer::getAlphaSize() const
{
if (gl::GetAlphaBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetAlphaBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
}
GLuint Renderbuffer::getDepthSize() const
{
if (gl::GetDepthBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetDepthBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
}
GLuint Renderbuffer::getStencilSize() const
{
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();
ASSERT(mStorage);
}
void Renderbuffer::setStorage(RenderbufferStorage *newStorage)
{
ASSERT(newStorage != NULL);
ASSERT(newStorage);
delete mInstance;
mInstance = newStorage;
SafeDelete(mStorage);
mStorage = newStorage;
}
RenderbufferStorage *Renderbuffer::getStorage()
{
ASSERT(mStorage);
return mStorage;
}
GLsizei Renderbuffer::getWidth() const
{
ASSERT(mStorage);
return mStorage->getWidth();
}
GLsizei Renderbuffer::getHeight() const
{
ASSERT(mStorage);
return mStorage->getHeight();
}
GLenum Renderbuffer::getInternalFormat() const
{
ASSERT(mStorage);
return mStorage->getInternalFormat();
}
GLenum Renderbuffer::getActualFormat() const
{
ASSERT(mStorage);
return mStorage->getActualFormat();
}
GLsizei Renderbuffer::getSamples() const
{
ASSERT(mStorage);
return mStorage->getSamples();
}
GLuint Renderbuffer::getRedSize() const
{
return gl::GetRedBits(getActualFormat());
}
GLuint Renderbuffer::getGreenSize() const
{
return gl::GetGreenBits(getActualFormat());
}
GLuint Renderbuffer::getBlueSize() const
{
return gl::GetBlueBits(getActualFormat());
}
GLuint Renderbuffer::getAlphaSize() const
{
return gl::GetAlphaBits(getActualFormat());
}
GLuint Renderbuffer::getDepthSize() const
{
return gl::GetDepthBits(getActualFormat());
}
GLuint Renderbuffer::getStencilSize() const
{
return gl::GetStencilBits(getActualFormat());
}
RenderbufferStorage::RenderbufferStorage() : mSerial(issueSerials(1))

Просмотреть файл

@ -12,8 +12,7 @@
#ifndef LIBGLESV2_RENDERBUFFER_H_
#define LIBGLESV2_RENDERBUFFER_H_
#include <GLES3/gl3.h>
#include <GLES2/gl2.h>
#include "angle_gl.h"
#include "common/angleutils.h"
#include "common/RefCountObject.h"
@ -28,178 +27,42 @@ class TextureStorage;
namespace gl
{
class Texture2D;
class TextureCubeMap;
class Texture3D;
class Texture2DArray;
class Renderbuffer;
class Colorbuffer;
class DepthStencilbuffer;
class RenderbufferStorage;
class FramebufferAttachment;
class RenderbufferInterface
// A GL renderbuffer object is usually used as a depth or stencil buffer attachment
// for a framebuffer object. The renderbuffer itself is a distinct GL object, see
// FramebufferAttachment and Framebuffer for how they are applied to an FBO via an
// attachment point.
class Renderbuffer : public RefCountObject
{
public:
RenderbufferInterface();
Renderbuffer(GLuint id, RenderbufferStorage *newStorage);
virtual ~RenderbufferInterface() {};
void setStorage(RenderbufferStorage *newStorage);
RenderbufferStorage *getStorage();
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;
GLsizei getWidth() const;
GLsizei getHeight() const;
GLenum getInternalFormat() const;
GLenum getActualFormat() const;
GLsizei getSamples() const;
GLuint getRedSize() const;
GLuint getGreenSize() const;
GLuint getBlueSize() const;
GLuint getAlphaSize() const;
GLuint getDepthSize() const;
GLuint getStencilSize() const;
private:
DISALLOW_COPY_AND_ASSIGN(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 <Texture2D> 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 <TextureCubeMap> 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<Texture3D> 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<Texture2DArray> mTexture2DArray;
const GLint mLevel;
const GLint mLayer;
RenderbufferStorage *mStorage;
};
// 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 : public RenderbufferInterface
class RenderbufferStorage
{
public:
RenderbufferStorage();
@ -238,55 +101,6 @@ class RenderbufferStorage : public RenderbufferInterface
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:
@ -341,6 +155,7 @@ class Stencilbuffer : public DepthStencilbuffer
private:
DISALLOW_COPY_AND_ASSIGN(Stencilbuffer);
};
}
#endif // LIBGLESV2_RENDERBUFFER_H_

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше