Backed out changeset 589752703e0c (Bug 1036068) for suspicion of breaking b2g linux debug builds on a CLOSED TREE

--HG--
extra : amend_source : 8cbc45d68f68b534f0d392f7e39841731fb6f5a4
This commit is contained in:
Carsten "Tomcat" Book 2014-09-10 12:55:27 +02:00
Родитель f41185b16b
Коммит 406a6adec7
285 изменённых файлов: 9770 добавлений и 9940 удалений

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

@ -1,638 +0,0 @@
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This config is applied to internal Angle targets (not pushed to dependents).
config("internal_config") {
include_dirs = [
"include",
"src",
]
}
component("translator") {
sources = [
"src/compiler/translator/ShaderLang.cpp",
]
defines = [ "ANGLE_TRANSLATOR_IMPLEMENTATION" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
":internal_config",
"//build/config/compiler:no_chromium_code",
]
deps = [
":translator_lib",
]
}
# Holds the shared includes so we only need to list them once.
source_set("includes") {
sources = [
"include/EGL/egl.h",
"include/EGL/eglext.h",
"include/EGL/eglplatform.h",
"include/GLES2/gl2.h",
"include/GLES2/gl2ext.h",
"include/GLES2/gl2platform.h",
"include/GLES3/gl3.h",
"include/GLES3/gl3ext.h",
"include/GLES3/gl3platform.h",
"include/GLSLANG/ShaderLang.h",
"include/KHR/khrplatform.h",
]
}
static_library("preprocessor") {
sources = [
"src/compiler/preprocessor/DiagnosticsBase.cpp",
"src/compiler/preprocessor/DiagnosticsBase.h",
"src/compiler/preprocessor/DirectiveHandlerBase.cpp",
"src/compiler/preprocessor/DirectiveHandlerBase.h",
"src/compiler/preprocessor/DirectiveParser.cpp",
"src/compiler/preprocessor/DirectiveParser.h",
"src/compiler/preprocessor/ExpressionParser.cpp",
"src/compiler/preprocessor/ExpressionParser.h",
"src/compiler/preprocessor/ExpressionParser.y",
"src/compiler/preprocessor/Input.cpp",
"src/compiler/preprocessor/Input.h",
"src/compiler/preprocessor/Lexer.cpp",
"src/compiler/preprocessor/Lexer.h",
"src/compiler/preprocessor/Macro.cpp",
"src/compiler/preprocessor/Macro.h",
"src/compiler/preprocessor/MacroExpander.cpp",
"src/compiler/preprocessor/MacroExpander.h",
"src/compiler/preprocessor/Preprocessor.cpp",
"src/compiler/preprocessor/Preprocessor.h",
"src/compiler/preprocessor/SourceLocation.h",
"src/compiler/preprocessor/Token.cpp",
"src/compiler/preprocessor/Token.h",
"src/compiler/preprocessor/Tokenizer.cpp",
"src/compiler/preprocessor/Tokenizer.h",
"src/compiler/preprocessor/Tokenizer.l",
"src/compiler/preprocessor/numeric_lex.h",
"src/compiler/preprocessor/pp_utils.h",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
":internal_config",
"//build/config/compiler:no_chromium_code",
]
}
static_library("translator_lib") {
sources = [
"src/common/RefCountObject.cpp",
"src/common/RefCountObject.h",
"src/common/angleutils.h",
"src/common/blocklayout.cpp",
"src/common/blocklayout.h",
"src/common/debug.cpp",
"src/common/debug.h",
"src/common/event_tracer.cpp",
"src/common/event_tracer.h",
"src/common/mathutil.cpp",
"src/common/mathutil.h",
"src/common/platform.h",
"src/common/shadervars.h",
"src/common/tls.cpp",
"src/common/tls.h",
"src/common/utilities.cpp",
"src/common/utilities.h",
"src/common/version.h",
"src/compiler/translator/BaseTypes.h",
"src/compiler/translator/BuiltInFunctionEmulator.cpp",
"src/compiler/translator/BuiltInFunctionEmulator.h",
"src/compiler/translator/CodeGen.cpp",
"src/compiler/translator/Common.h",
"src/compiler/translator/Compiler.cpp",
"src/compiler/translator/ConstantUnion.h",
"src/compiler/translator/DetectCallDepth.cpp",
"src/compiler/translator/DetectCallDepth.h",
"src/compiler/translator/DetectDiscontinuity.cpp",
"src/compiler/translator/DetectDiscontinuity.h",
"src/compiler/translator/Diagnostics.cpp",
"src/compiler/translator/Diagnostics.h",
"src/compiler/translator/DirectiveHandler.cpp",
"src/compiler/translator/DirectiveHandler.h",
"src/compiler/translator/ExtensionBehavior.h",
"src/compiler/translator/FlagStd140Structs.cpp",
"src/compiler/translator/FlagStd140Structs.h",
"src/compiler/translator/ForLoopUnroll.cpp",
"src/compiler/translator/ForLoopUnroll.h",
"src/compiler/translator/HashNames.h",
"src/compiler/translator/InfoSink.cpp",
"src/compiler/translator/InfoSink.h",
"src/compiler/translator/Initialize.cpp",
"src/compiler/translator/Initialize.h",
"src/compiler/translator/InitializeDll.cpp",
"src/compiler/translator/InitializeDll.h",
"src/compiler/translator/InitializeGlobals.h",
"src/compiler/translator/InitializeParseContext.cpp",
"src/compiler/translator/InitializeParseContext.h",
"src/compiler/translator/InitializeVariables.cpp",
"src/compiler/translator/InitializeVariables.h",
"src/compiler/translator/IntermTraverse.cpp",
"src/compiler/translator/Intermediate.cpp",
"src/compiler/translator/LoopInfo.cpp",
"src/compiler/translator/LoopInfo.h",
"src/compiler/translator/MMap.h",
"src/compiler/translator/NodeSearch.h",
"src/compiler/translator/OutputESSL.cpp",
"src/compiler/translator/OutputESSL.h",
"src/compiler/translator/OutputGLSL.cpp",
"src/compiler/translator/OutputGLSL.h",
"src/compiler/translator/OutputGLSLBase.cpp",
"src/compiler/translator/OutputGLSLBase.h",
"src/compiler/translator/OutputHLSL.cpp",
"src/compiler/translator/OutputHLSL.h",
"src/compiler/translator/ParseContext.cpp",
"src/compiler/translator/ParseContext.h",
"src/compiler/translator/PoolAlloc.cpp",
"src/compiler/translator/PoolAlloc.h",
"src/compiler/translator/Pragma.h",
"src/compiler/translator/QualifierAlive.cpp",
"src/compiler/translator/QualifierAlive.h",
"src/compiler/translator/RemoveTree.cpp",
"src/compiler/translator/RemoveTree.h",
"src/compiler/translator/RenameFunction.h",
"src/compiler/translator/RewriteElseBlocks.cpp",
"src/compiler/translator/RewriteElseBlocks.h",
"src/compiler/translator/SearchSymbol.cpp",
"src/compiler/translator/SearchSymbol.h",
"src/compiler/translator/ShHandle.h",
"src/compiler/translator/StructureHLSL.cpp",
"src/compiler/translator/StructureHLSL.h",
"src/compiler/translator/SymbolTable.cpp",
"src/compiler/translator/SymbolTable.h",
"src/compiler/translator/TranslatorESSL.cpp",
"src/compiler/translator/TranslatorESSL.h",
"src/compiler/translator/TranslatorGLSL.cpp",
"src/compiler/translator/TranslatorGLSL.h",
"src/compiler/translator/TranslatorHLSL.cpp",
"src/compiler/translator/TranslatorHLSL.h",
"src/compiler/translator/Types.cpp",
"src/compiler/translator/Types.h",
"src/compiler/translator/UnfoldShortCircuit.cpp",
"src/compiler/translator/UnfoldShortCircuit.h",
"src/compiler/translator/UnfoldShortCircuitAST.cpp",
"src/compiler/translator/UnfoldShortCircuitAST.h",
"src/compiler/translator/UniformHLSL.cpp",
"src/compiler/translator/UniformHLSL.h",
"src/compiler/translator/UtilsHLSL.cpp",
"src/compiler/translator/UtilsHLSL.h",
"src/compiler/translator/ValidateLimitations.cpp",
"src/compiler/translator/ValidateLimitations.h",
"src/compiler/translator/ValidateOutputs.cpp",
"src/compiler/translator/ValidateOutputs.h",
"src/compiler/translator/VariableInfo.cpp",
"src/compiler/translator/VariableInfo.h",
"src/compiler/translator/VariablePacker.cpp",
"src/compiler/translator/VariablePacker.h",
"src/compiler/translator/VersionGLSL.cpp",
"src/compiler/translator/VersionGLSL.h",
"src/compiler/translator/compilerdebug.cpp",
"src/compiler/translator/compilerdebug.h",
"src/compiler/translator/depgraph/DependencyGraph.cpp",
"src/compiler/translator/depgraph/DependencyGraph.h",
"src/compiler/translator/depgraph/DependencyGraphBuilder.cpp",
"src/compiler/translator/depgraph/DependencyGraphBuilder.h",
"src/compiler/translator/depgraph/DependencyGraphOutput.cpp",
"src/compiler/translator/depgraph/DependencyGraphOutput.h",
"src/compiler/translator/depgraph/DependencyGraphTraverse.cpp",
"src/compiler/translator/glslang.h",
"src/compiler/translator/glslang.l",
"src/compiler/translator/glslang.y",
"src/compiler/translator/glslang_lex.cpp",
"src/compiler/translator/glslang_tab.cpp",
"src/compiler/translator/glslang_tab.h",
"src/compiler/translator/intermOut.cpp",
"src/compiler/translator/intermediate.h",
"src/compiler/translator/length_limits.h",
"src/compiler/translator/localintermediate.h",
"src/compiler/translator/parseConst.cpp",
"src/compiler/translator/timing/RestrictFragmentShaderTiming.cpp",
"src/compiler/translator/timing/RestrictFragmentShaderTiming.h",
"src/compiler/translator/timing/RestrictVertexShaderTiming.cpp",
"src/compiler/translator/timing/RestrictVertexShaderTiming.h",
"src/compiler/translator/util.cpp",
"src/compiler/translator/util.h",
"src/third_party/compiler/ArrayBoundsClamper.cpp",
"src/third_party/compiler/ArrayBoundsClamper.h",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
":internal_config",
"//build/config/compiler:no_chromium_code",
]
deps = [
":includes",
":preprocessor",
]
}
config("translator_static_config") {
defines = [ "ANGLE_TRANSLATOR_STATIC" ]
}
static_library("translator_static") {
sources = [
"src/compiler/translator/ShaderLang.cpp",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
":internal_config",
"//build/config/compiler:no_chromium_code",
]
direct_dependent_configs = [ ":translator_static_config" ]
deps = [
":translator_lib",
]
}
config("commit_id_config") {
include_dirs = [ "$root_gen_dir/angle" ]
}
action("commit_id") {
script = "src/commit_id.py"
output_file = "$root_gen_dir/angle/id/commit.h"
outputs = [ output_file ]
args = [
"gen",
rebase_path(".", root_build_dir),
rebase_path(output_file, root_build_dir),
]
direct_dependent_configs = [ ":commit_id_config" ]
}
if (is_win) {
angle_enable_d3d9 = true
angle_enable_d3d11 = true
shared_library("libGLESv2") {
sources = [
"src/common/RefCountObject.cpp",
"src/common/RefCountObject.h",
"src/common/angleutils.h",
"src/common/blocklayout.cpp",
"src/common/blocklayout.h",
"src/common/debug.cpp",
"src/common/debug.h",
"src/common/event_tracer.cpp",
"src/common/event_tracer.h",
"src/common/mathutil.cpp",
"src/common/mathutil.h",
"src/common/platform.h",
"src/common/shadervars.h",
"src/common/tls.cpp",
"src/common/tls.h",
"src/common/utilities.cpp",
"src/common/utilities.h",
"src/common/version.h",
"src/libGLESv2/BinaryStream.h",
"src/libGLESv2/Buffer.cpp",
"src/libGLESv2/Buffer.h",
"src/libGLESv2/Caps.cpp",
"src/libGLESv2/Caps.h",
"src/libGLESv2/Context.cpp",
"src/libGLESv2/Context.h",
"src/libGLESv2/DynamicHLSL.cpp",
"src/libGLESv2/DynamicHLSL.h",
"src/libGLESv2/Fence.cpp",
"src/libGLESv2/Fence.h",
"src/libGLESv2/Float16ToFloat32.cpp",
"src/libGLESv2/Framebuffer.cpp",
"src/libGLESv2/Framebuffer.h",
"src/libGLESv2/FramebufferAttachment.cpp",
"src/libGLESv2/FramebufferAttachment.h",
"src/libGLESv2/HandleAllocator.cpp",
"src/libGLESv2/HandleAllocator.h",
"src/libGLESv2/Program.cpp",
"src/libGLESv2/Program.h",
"src/libGLESv2/ProgramBinary.cpp",
"src/libGLESv2/ProgramBinary.h",
"src/libGLESv2/Query.cpp",
"src/libGLESv2/Query.h",
"src/libGLESv2/Renderbuffer.cpp",
"src/libGLESv2/Renderbuffer.h",
"src/libGLESv2/RenderbufferProxySet.cpp",
"src/libGLESv2/RenderbufferProxySet.h",
"src/libGLESv2/ResourceManager.cpp",
"src/libGLESv2/ResourceManager.h",
"src/libGLESv2/Sampler.cpp",
"src/libGLESv2/Sampler.h",
"src/libGLESv2/Shader.cpp",
"src/libGLESv2/Shader.h",
"src/libGLESv2/Texture.cpp",
"src/libGLESv2/Texture.h",
"src/libGLESv2/TransformFeedback.cpp",
"src/libGLESv2/TransformFeedback.h",
"src/libGLESv2/Uniform.cpp",
"src/libGLESv2/Uniform.h",
"src/libGLESv2/VertexArray.cpp",
"src/libGLESv2/VertexArray.h",
"src/libGLESv2/VertexAttribute.h",
"src/libGLESv2/VertexAttribute.cpp",
"src/libGLESv2/angletypes.cpp",
"src/libGLESv2/angletypes.h",
"src/libGLESv2/constants.h",
"src/libGLESv2/formatutils.cpp",
"src/libGLESv2/formatutils.h",
"src/libGLESv2/libGLESv2.cpp",
"src/libGLESv2/libGLESv2.def",
"src/libGLESv2/libGLESv2.rc",
"src/libGLESv2/main.cpp",
"src/libGLESv2/main.h",
"src/libGLESv2/precompiled.cpp",
"src/libGLESv2/precompiled.h",
"src/libGLESv2/queryconversions.cpp",
"src/libGLESv2/queryconversions.h",
"src/libGLESv2/renderer/BufferStorage.cpp",
"src/libGLESv2/renderer/BufferStorage.h",
"src/libGLESv2/renderer/FenceImpl.h",
"src/libGLESv2/renderer/Image.cpp",
"src/libGLESv2/renderer/Image.h",
"src/libGLESv2/renderer/IndexBuffer.cpp",
"src/libGLESv2/renderer/IndexBuffer.h",
"src/libGLESv2/renderer/IndexDataManager.cpp",
"src/libGLESv2/renderer/IndexDataManager.h",
"src/libGLESv2/renderer/IndexRangeCache.cpp",
"src/libGLESv2/renderer/IndexRangeCache.h",
"src/libGLESv2/renderer/QueryImpl.h",
"src/libGLESv2/renderer/RenderTarget.h",
"src/libGLESv2/renderer/Renderer.cpp",
"src/libGLESv2/renderer/Renderer.h",
"src/libGLESv2/renderer/ShaderExecutable.h",
"src/libGLESv2/renderer/SwapChain.h",
"src/libGLESv2/renderer/TextureStorage.cpp",
"src/libGLESv2/renderer/TextureStorage.h",
"src/libGLESv2/renderer/VertexArrayImpl.h",
"src/libGLESv2/renderer/VertexBuffer.cpp",
"src/libGLESv2/renderer/VertexBuffer.h",
"src/libGLESv2/renderer/VertexDataManager.cpp",
"src/libGLESv2/renderer/VertexDataManager.h",
"src/libGLESv2/renderer/copyimage.cpp",
"src/libGLESv2/renderer/copyimage.h",
"src/libGLESv2/renderer/copyvertex.h",
"src/libGLESv2/renderer/generatemip.h",
"src/libGLESv2/renderer/imageformats.h",
"src/libGLESv2/renderer/loadimage.cpp",
"src/libGLESv2/renderer/loadimage.h",
"src/libGLESv2/renderer/loadimageSSE2.cpp",
"src/libGLESv2/renderer/vertexconversion.h",
"src/libGLESv2/resource.h",
"src/libGLESv2/validationES.cpp",
"src/libGLESv2/validationES.h",
"src/libGLESv2/validationES2.cpp",
"src/libGLESv2/validationES2.h",
"src/libGLESv2/validationES3.cpp",
"src/libGLESv2/validationES3.h",
"src/third_party/murmurhash/MurmurHash3.cpp",
"src/third_party/murmurhash/MurmurHash3.h",
"src/third_party/systeminfo/SystemInfo.cpp",
"src/third_party/systeminfo/SystemInfo.h",
]
defines = [
"ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ " +
"TEXT(\"d3dcompiler_46.dll\"), TEXT(\"d3dcompiler_43.dll\") }",
"GL_APICALL=",
"GL_GLEXT_PROTOTYPES=",
"EGLAPI=",
]
libs = []
# Shared D3dD sources.
if (angle_enable_d3d9 || angle_enable_d3d11) {
sources += [
"src/libGLESv2/renderer/d3d/HLSLCompiler.cpp",
"src/libGLESv2/renderer/d3d/HLSLCompiler.h",
]
}
if (angle_enable_d3d9) {
sources += [
"src/libGLESv2/renderer/d3d9/Blit9.cpp",
"src/libGLESv2/renderer/d3d9/Blit9.h",
"src/libGLESv2/renderer/d3d9/BufferStorage9.cpp",
"src/libGLESv2/renderer/d3d9/BufferStorage9.h",
"src/libGLESv2/renderer/d3d9/Fence9.cpp",
"src/libGLESv2/renderer/d3d9/Fence9.h",
"src/libGLESv2/renderer/d3d9/Image9.cpp",
"src/libGLESv2/renderer/d3d9/Image9.h",
"src/libGLESv2/renderer/d3d9/IndexBuffer9.cpp",
"src/libGLESv2/renderer/d3d9/IndexBuffer9.h",
"src/libGLESv2/renderer/d3d9/Query9.cpp",
"src/libGLESv2/renderer/d3d9/Query9.h",
"src/libGLESv2/renderer/d3d9/RenderTarget9.cpp",
"src/libGLESv2/renderer/d3d9/RenderTarget9.h",
"src/libGLESv2/renderer/d3d9/Renderer9.cpp",
"src/libGLESv2/renderer/d3d9/Renderer9.h",
"src/libGLESv2/renderer/d3d9/ShaderCache.h",
"src/libGLESv2/renderer/d3d9/ShaderExecutable9.cpp",
"src/libGLESv2/renderer/d3d9/ShaderExecutable9.h",
"src/libGLESv2/renderer/d3d9/SwapChain9.cpp",
"src/libGLESv2/renderer/d3d9/SwapChain9.h",
"src/libGLESv2/renderer/d3d9/TextureStorage9.cpp",
"src/libGLESv2/renderer/d3d9/TextureStorage9.h",
"src/libGLESv2/renderer/d3d9/VertexArray9.h",
"src/libGLESv2/renderer/d3d9/VertexBuffer9.cpp",
"src/libGLESv2/renderer/d3d9/VertexBuffer9.h",
"src/libGLESv2/renderer/d3d9/VertexDeclarationCache.cpp",
"src/libGLESv2/renderer/d3d9/VertexDeclarationCache.h",
"src/libGLESv2/renderer/d3d9/formatutils9.cpp",
"src/libGLESv2/renderer/d3d9/formatutils9.h",
"src/libGLESv2/renderer/d3d9/renderer9_utils.cpp",
"src/libGLESv2/renderer/d3d9/renderer9_utils.h",
"src/libGLESv2/renderer/d3d9/shaders/compiled/componentmaskps.h",
"src/libGLESv2/renderer/d3d9/shaders/compiled/flipyvs.h",
"src/libGLESv2/renderer/d3d9/shaders/compiled/luminanceps.h",
"src/libGLESv2/renderer/d3d9/shaders/compiled/passthroughps.h",
"src/libGLESv2/renderer/d3d9/shaders/compiled/standardvs.h",
]
defines += [ "ANGLE_ENABLE_D3D9" ]
libs += [ "d3d9.lib" ]
}
if (angle_enable_d3d11) {
sources += [
"src/libGLESv2/renderer/d3d11/Blit11.cpp",
"src/libGLESv2/renderer/d3d11/Blit11.h",
"src/libGLESv2/renderer/d3d11/BufferStorage11.cpp",
"src/libGLESv2/renderer/d3d11/BufferStorage11.h",
"src/libGLESv2/renderer/d3d11/Clear11.cpp",
"src/libGLESv2/renderer/d3d11/Clear11.h",
"src/libGLESv2/renderer/d3d11/Fence11.cpp",
"src/libGLESv2/renderer/d3d11/Fence11.h",
"src/libGLESv2/renderer/d3d11/Image11.cpp",
"src/libGLESv2/renderer/d3d11/Image11.h",
"src/libGLESv2/renderer/d3d11/IndexBuffer11.cpp",
"src/libGLESv2/renderer/d3d11/IndexBuffer11.h",
"src/libGLESv2/renderer/d3d11/InputLayoutCache.cpp",
"src/libGLESv2/renderer/d3d11/InputLayoutCache.h",
"src/libGLESv2/renderer/d3d11/PixelTransfer11.cpp",
"src/libGLESv2/renderer/d3d11/PixelTransfer11.h",
"src/libGLESv2/renderer/d3d11/Query11.cpp",
"src/libGLESv2/renderer/d3d11/Query11.h",
"src/libGLESv2/renderer/d3d11/RenderStateCache.cpp",
"src/libGLESv2/renderer/d3d11/RenderStateCache.h",
"src/libGLESv2/renderer/d3d11/RenderTarget11.cpp",
"src/libGLESv2/renderer/d3d11/RenderTarget11.h",
"src/libGLESv2/renderer/d3d11/Renderer11.cpp",
"src/libGLESv2/renderer/d3d11/Renderer11.h",
"src/libGLESv2/renderer/d3d11/ShaderExecutable11.cpp",
"src/libGLESv2/renderer/d3d11/ShaderExecutable11.h",
"src/libGLESv2/renderer/d3d11/SwapChain11.cpp",
"src/libGLESv2/renderer/d3d11/SwapChain11.h",
"src/libGLESv2/renderer/d3d11/TextureStorage11.cpp",
"src/libGLESv2/renderer/d3d11/TextureStorage11.h",
"src/libGLESv2/renderer/d3d11/VertexArray11.h",
"src/libGLESv2/renderer/d3d11/VertexBuffer11.cpp",
"src/libGLESv2/renderer/d3d11/VertexBuffer11.h",
"src/libGLESv2/renderer/d3d11/formatutils11.cpp",
"src/libGLESv2/renderer/d3d11/formatutils11.h",
"src/libGLESv2/renderer/d3d11/renderer11_utils.cpp",
"src/libGLESv2/renderer/d3d11/renderer11_utils.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_gs.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4f.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4i.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4ui.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_vs.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/clearfloat11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/clearfloat11vs.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/clearsint11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/clearsint11vs.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/clearuint11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/clearuint11vs.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough2d11vs.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough3d11gs.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough3d11vs.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughdepth2d11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum2d11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum3d11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha2d11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha3d11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2d11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2di11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2dui11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3d11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3di11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3dui11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2d11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2di11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2dui11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3d11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3di11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3dui11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2d11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2di11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2dui11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3d11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3di11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3dui11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2d11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2di11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2dui11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3d11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3di11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3dui11ps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlef2darrayps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlef2dps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlef3dps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlei2darrayps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlei2dps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlei3dps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/swizzleui2darrayps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/swizzleui2dps.h",
"src/libGLESv2/renderer/d3d11/shaders/compiled/swizzleui3dps.h",
]
defines += [ "ANGLE_ENABLE_D3D11" ]
libs += [ "dxguid.lib" ]
}
if (is_debug) {
defines += [ "ANGLE_ENABLE_PERF" ]
libs += [ "d3d9.lib" ]
}
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
":internal_config",
"//build/config/compiler:no_chromium_code",
]
include_dirs = [ "src/libGLESv2" ]
deps = [
":commit_id",
":includes",
":translator",
#":copy_compiler_dll", TODO(GYP)
]
}
shared_library("libEGL") {
sources = [
"src/common/RefCountObject.cpp",
"src/common/RefCountObject.h",
"src/common/angleutils.h",
"src/common/blocklayout.cpp",
"src/common/blocklayout.h",
"src/common/debug.cpp",
"src/common/debug.h",
"src/common/event_tracer.cpp",
"src/common/event_tracer.h",
"src/common/mathutil.cpp",
"src/common/mathutil.h",
"src/common/shadervars.h",
"src/common/utilities.cpp",
"src/common/utilities.h",
"src/common/version.h",
"src/libEGL/Config.cpp",
"src/libEGL/Config.h",
"src/libEGL/Display.cpp",
"src/libEGL/Display.h",
"src/libEGL/Surface.cpp",
"src/libEGL/Surface.h",
"src/libEGL/libEGL.cpp",
"src/libEGL/libEGL.def",
"src/libEGL/libEGL.rc",
"src/libEGL/main.cpp",
"src/libEGL/main.h",
"src/libEGL/resource.h",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
":internal_config",
"//build/config/compiler:no_chromium_code",
]
if (is_debug) {
defines = [ "ANGLE_ENABLE_PERF" ]
}
include_dirs = [ "src/libGLESv2" ]
libs = [ "d3d9.lib" ]
deps = [
":commit_id",
":includes",
":libGLESv2",
]
}
} # is_win

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

@ -17,11 +17,8 @@ includes Mozilla-specific patches on top of upstream.
git checkout mozilla git checkout mozilla
5. Rebase the mozilla branch on top of the new google master. Fix up patches along the way, 5. Rebase the mozilla branch on top of the new google master. Fix up patches along the way,
remove unneded commits. Google seems to have "chromium/2059" branches as well, that I remove unneded commits.
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 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: 6. Re-generate moz.build files:
./gyp_mozbuild ./gyp_mozbuild
@ -36,13 +33,3 @@ includes Mozilla-specific patches on top of upstream.
9. Build. Fix things until it builds. 9. Build. Fix things until it builds.
10. Try runs and reviews! 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,12 +1,11 @@
#ifndef __egl_h_ /* -*- mode: c; tab-width: 8; -*- */
#define __egl_h_ 1 /* vi: set sw=4 ts=8: */
/* Reference version of egl.h for EGL 1.4.
#ifdef __cplusplus * $Revision: 9356 $ on $Date: 2009-10-21 05:52:25 -0400 (Wed, 21 Oct 2009) $
extern "C" { */
#endif
/* /*
** Copyright (c) 2013-2014 The Khronos Group Inc. ** Copyright (c) 2007-2009 The Khronos Group Inc.
** **
** Permission is hereby granted, free of charge, to any person obtaining a ** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the ** copy of this software and/or associated documentation files (the
@ -27,272 +26,304 @@ extern "C" {
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. ** 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> #include <EGL/eglplatform.h>
/* Generated on date 20140610 */ #ifdef __cplusplus
extern "C" {
#endif
/* Generated C header for: /* EGL Types */
* API: egl /* EGLint is defined in eglplatform.h */
* Versions considered: .* typedef unsigned int EGLBoolean;
* Versions emitted: .* typedef unsigned int EGLenum;
* Default extensions included: None typedef void *EGLConfig;
* Additional extensions included: _nomatch_^ typedef void *EGLContext;
* Extensions removed: _nomatch_^ typedef void *EGLDisplay;
typedef void *EGLSurface;
typedef void *EGLClientBuffer;
/* EGL Versioning */
#define EGL_VERSION_1_0 1
#define EGL_VERSION_1_1 1
#define EGL_VERSION_1_2 1
#define EGL_VERSION_1_3 1
#define EGL_VERSION_1_4 1
/* EGL Enumerants. Bitmasks and other exceptional cases aside, most
* enums are assigned unique values starting at 0x3000.
*/ */
#ifndef EGL_VERSION_1_0 /* EGL aliases */
#define EGL_VERSION_1_0 1 #define EGL_FALSE 0
typedef unsigned int EGLBoolean; #define EGL_TRUE 1
typedef void *EGLDisplay;
#include <KHR/khrplatform.h> /* Out-of-band handle values */
#include <EGL/eglplatform.h> #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
typedef void *EGLConfig; #define EGL_NO_CONTEXT ((EGLContext)0)
typedef void *EGLSurface; #define EGL_NO_DISPLAY ((EGLDisplay)0)
typedef void *EGLContext; #define EGL_NO_SURFACE ((EGLSurface)0)
/* Out-of-band attribute value */
#define EGL_DONT_CARE ((EGLint)-1)
/* Errors / GetError return values */
#define EGL_SUCCESS 0x3000
#define EGL_NOT_INITIALIZED 0x3001
#define EGL_BAD_ACCESS 0x3002
#define EGL_BAD_ALLOC 0x3003
#define EGL_BAD_ATTRIBUTE 0x3004
#define EGL_BAD_CONFIG 0x3005
#define EGL_BAD_CONTEXT 0x3006
#define EGL_BAD_CURRENT_SURFACE 0x3007
#define EGL_BAD_DISPLAY 0x3008
#define EGL_BAD_MATCH 0x3009
#define EGL_BAD_NATIVE_PIXMAP 0x300A
#define EGL_BAD_NATIVE_WINDOW 0x300B
#define EGL_BAD_PARAMETER 0x300C
#define EGL_BAD_SURFACE 0x300D
#define EGL_CONTEXT_LOST 0x300E /* EGL 1.1 - IMG_power_management */
/* Reserved 0x300F-0x301F for additional errors */
/* Config attributes */
#define EGL_BUFFER_SIZE 0x3020
#define EGL_ALPHA_SIZE 0x3021
#define EGL_BLUE_SIZE 0x3022
#define EGL_GREEN_SIZE 0x3023
#define EGL_RED_SIZE 0x3024
#define EGL_DEPTH_SIZE 0x3025
#define EGL_STENCIL_SIZE 0x3026
#define EGL_CONFIG_CAVEAT 0x3027
#define EGL_CONFIG_ID 0x3028
#define EGL_LEVEL 0x3029
#define EGL_MAX_PBUFFER_HEIGHT 0x302A
#define EGL_MAX_PBUFFER_PIXELS 0x302B
#define EGL_MAX_PBUFFER_WIDTH 0x302C
#define EGL_NATIVE_RENDERABLE 0x302D
#define EGL_NATIVE_VISUAL_ID 0x302E
#define EGL_NATIVE_VISUAL_TYPE 0x302F
#define EGL_SAMPLES 0x3031
#define EGL_SAMPLE_BUFFERS 0x3032
#define EGL_SURFACE_TYPE 0x3033
#define EGL_TRANSPARENT_TYPE 0x3034
#define EGL_TRANSPARENT_BLUE_VALUE 0x3035
#define EGL_TRANSPARENT_GREEN_VALUE 0x3036
#define EGL_TRANSPARENT_RED_VALUE 0x3037
#define EGL_NONE 0x3038 /* Attrib list terminator */
#define EGL_BIND_TO_TEXTURE_RGB 0x3039
#define EGL_BIND_TO_TEXTURE_RGBA 0x303A
#define EGL_MIN_SWAP_INTERVAL 0x303B
#define EGL_MAX_SWAP_INTERVAL 0x303C
#define EGL_LUMINANCE_SIZE 0x303D
#define EGL_ALPHA_MASK_SIZE 0x303E
#define EGL_COLOR_BUFFER_TYPE 0x303F
#define EGL_RENDERABLE_TYPE 0x3040
#define EGL_MATCH_NATIVE_PIXMAP 0x3041 /* Pseudo-attribute (not queryable) */
#define EGL_CONFORMANT 0x3042
/* Reserved 0x3041-0x304F for additional config attributes */
/* Config attribute values */
#define EGL_SLOW_CONFIG 0x3050 /* EGL_CONFIG_CAVEAT value */
#define EGL_NON_CONFORMANT_CONFIG 0x3051 /* EGL_CONFIG_CAVEAT value */
#define EGL_TRANSPARENT_RGB 0x3052 /* EGL_TRANSPARENT_TYPE value */
#define EGL_RGB_BUFFER 0x308E /* EGL_COLOR_BUFFER_TYPE value */
#define EGL_LUMINANCE_BUFFER 0x308F /* EGL_COLOR_BUFFER_TYPE value */
/* More config attribute values, for EGL_TEXTURE_FORMAT */
#define EGL_NO_TEXTURE 0x305C
#define EGL_TEXTURE_RGB 0x305D
#define EGL_TEXTURE_RGBA 0x305E
#define EGL_TEXTURE_2D 0x305F
/* Config attribute mask bits */
#define EGL_PBUFFER_BIT 0x0001 /* EGL_SURFACE_TYPE mask bits */
#define EGL_PIXMAP_BIT 0x0002 /* EGL_SURFACE_TYPE mask bits */
#define EGL_WINDOW_BIT 0x0004 /* EGL_SURFACE_TYPE mask bits */
#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 /* EGL_SURFACE_TYPE mask bits */
#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 /* EGL_SURFACE_TYPE mask bits */
#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 /* EGL_SURFACE_TYPE mask bits */
#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 /* EGL_SURFACE_TYPE mask bits */
#define EGL_OPENGL_ES_BIT 0x0001 /* EGL_RENDERABLE_TYPE mask bits */
#define EGL_OPENVG_BIT 0x0002 /* EGL_RENDERABLE_TYPE mask bits */
#define EGL_OPENGL_ES2_BIT 0x0004 /* EGL_RENDERABLE_TYPE mask bits */
#define EGL_OPENGL_BIT 0x0008 /* EGL_RENDERABLE_TYPE mask bits */
/* QueryString targets */
#define EGL_VENDOR 0x3053
#define EGL_VERSION 0x3054
#define EGL_EXTENSIONS 0x3055
#define EGL_CLIENT_APIS 0x308D
/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */
#define EGL_HEIGHT 0x3056
#define EGL_WIDTH 0x3057
#define EGL_LARGEST_PBUFFER 0x3058
#define EGL_TEXTURE_FORMAT 0x3080
#define EGL_TEXTURE_TARGET 0x3081
#define EGL_MIPMAP_TEXTURE 0x3082
#define EGL_MIPMAP_LEVEL 0x3083
#define EGL_RENDER_BUFFER 0x3086
#define EGL_VG_COLORSPACE 0x3087
#define EGL_VG_ALPHA_FORMAT 0x3088
#define EGL_HORIZONTAL_RESOLUTION 0x3090
#define EGL_VERTICAL_RESOLUTION 0x3091
#define EGL_PIXEL_ASPECT_RATIO 0x3092
#define EGL_SWAP_BEHAVIOR 0x3093
#define EGL_MULTISAMPLE_RESOLVE 0x3099
/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */
#define EGL_BACK_BUFFER 0x3084
#define EGL_SINGLE_BUFFER 0x3085
/* OpenVG color spaces */
#define EGL_VG_COLORSPACE_sRGB 0x3089 /* EGL_VG_COLORSPACE value */
#define EGL_VG_COLORSPACE_LINEAR 0x308A /* EGL_VG_COLORSPACE value */
/* OpenVG alpha formats */
#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B /* EGL_ALPHA_FORMAT value */
#define EGL_VG_ALPHA_FORMAT_PRE 0x308C /* EGL_ALPHA_FORMAT value */
/* Constant scale factor by which fractional display resolutions &
* aspect ratio are scaled when queried as integer values.
*/
#define EGL_DISPLAY_SCALING 10000
/* Unknown display resolution/aspect ratio */
#define EGL_UNKNOWN ((EGLint)-1)
/* Back buffer swap behaviors */
#define EGL_BUFFER_PRESERVED 0x3094 /* EGL_SWAP_BEHAVIOR value */
#define EGL_BUFFER_DESTROYED 0x3095 /* EGL_SWAP_BEHAVIOR value */
/* CreatePbufferFromClientBuffer buffer types */
#define EGL_OPENVG_IMAGE 0x3096
/* QueryContext targets */
#define EGL_CONTEXT_CLIENT_TYPE 0x3097
/* CreateContext attributes */
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
/* Multisample resolution behaviors */
#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A /* EGL_MULTISAMPLE_RESOLVE value */
#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B /* EGL_MULTISAMPLE_RESOLVE value */
/* BindAPI/QueryAPI targets */
#define EGL_OPENGL_ES_API 0x30A0
#define EGL_OPENVG_API 0x30A1
#define EGL_OPENGL_API 0x30A2
/* GetCurrentSurface targets */
#define EGL_DRAW 0x3059
#define EGL_READ 0x305A
/* WaitNative engines */
#define EGL_CORE_NATIVE_ENGINE 0x305B
/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */
#define EGL_COLORSPACE EGL_VG_COLORSPACE
#define EGL_ALPHA_FORMAT EGL_VG_ALPHA_FORMAT
#define EGL_COLORSPACE_sRGB EGL_VG_COLORSPACE_sRGB
#define EGL_COLORSPACE_LINEAR EGL_VG_COLORSPACE_LINEAR
#define EGL_ALPHA_FORMAT_NONPRE EGL_VG_ALPHA_FORMAT_NONPRE
#define EGL_ALPHA_FORMAT_PRE EGL_VG_ALPHA_FORMAT_PRE
/* EGL extensions must request enum blocks from the Khronos
* API Registrar, who maintains the enumerant registry. Submit
* a bug in Khronos Bugzilla against task "Registry".
*/
/* EGL Functions */
EGLAPI EGLint EGLAPIENTRY eglGetError(void);
EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id);
EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy);
EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
EGLint config_size, EGLint *num_config);
EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
EGLConfig *configs, EGLint config_size,
EGLint *num_config);
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
EGLint attribute, EGLint *value);
EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
EGLNativeWindowType win,
const EGLint *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
const EGLint *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
EGLNativePixmapType pixmap,
const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface,
EGLint attribute, EGLint *value);
EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api);
EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void);
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(
EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
EGLConfig config, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
EGLint attribute, EGLint value);
EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);
EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config,
EGLContext share_context,
const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,
EGLSurface read, EGLContext ctx);
EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void);
EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw);
EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx,
EGLint attribute, EGLint *value);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine);
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface,
EGLNativePixmapType target);
/* This is a generic function pointer type, whose name indicates it must
* be cast to the proper type *and calling convention* before use.
*/
typedef void (*__eglMustCastToProperFunctionPointerType)(void); typedef void (*__eglMustCastToProperFunctionPointerType)(void);
#define EGL_ALPHA_SIZE 0x3021
#define EGL_BAD_ACCESS 0x3002
#define EGL_BAD_ALLOC 0x3003
#define EGL_BAD_ATTRIBUTE 0x3004
#define EGL_BAD_CONFIG 0x3005
#define EGL_BAD_CONTEXT 0x3006
#define EGL_BAD_CURRENT_SURFACE 0x3007
#define EGL_BAD_DISPLAY 0x3008
#define EGL_BAD_MATCH 0x3009
#define EGL_BAD_NATIVE_PIXMAP 0x300A
#define EGL_BAD_NATIVE_WINDOW 0x300B
#define EGL_BAD_PARAMETER 0x300C
#define EGL_BAD_SURFACE 0x300D
#define EGL_BLUE_SIZE 0x3022
#define EGL_BUFFER_SIZE 0x3020
#define EGL_CONFIG_CAVEAT 0x3027
#define EGL_CONFIG_ID 0x3028
#define EGL_CORE_NATIVE_ENGINE 0x305B
#define EGL_DEPTH_SIZE 0x3025
#define EGL_DONT_CARE ((EGLint)-1)
#define EGL_DRAW 0x3059
#define EGL_EXTENSIONS 0x3055
#define EGL_FALSE 0
#define EGL_GREEN_SIZE 0x3023
#define EGL_HEIGHT 0x3056
#define EGL_LARGEST_PBUFFER 0x3058
#define EGL_LEVEL 0x3029
#define EGL_MAX_PBUFFER_HEIGHT 0x302A
#define EGL_MAX_PBUFFER_PIXELS 0x302B
#define EGL_MAX_PBUFFER_WIDTH 0x302C
#define EGL_NATIVE_RENDERABLE 0x302D
#define EGL_NATIVE_VISUAL_ID 0x302E
#define EGL_NATIVE_VISUAL_TYPE 0x302F
#define EGL_NONE 0x3038
#define EGL_NON_CONFORMANT_CONFIG 0x3051
#define EGL_NOT_INITIALIZED 0x3001
#define EGL_NO_CONTEXT ((EGLContext)0)
#define EGL_NO_DISPLAY ((EGLDisplay)0)
#define EGL_NO_SURFACE ((EGLSurface)0)
#define EGL_PBUFFER_BIT 0x0001
#define EGL_PIXMAP_BIT 0x0002
#define EGL_READ 0x305A
#define EGL_RED_SIZE 0x3024
#define EGL_SAMPLES 0x3031
#define EGL_SAMPLE_BUFFERS 0x3032
#define EGL_SLOW_CONFIG 0x3050
#define EGL_STENCIL_SIZE 0x3026
#define EGL_SUCCESS 0x3000
#define EGL_SURFACE_TYPE 0x3033
#define EGL_TRANSPARENT_BLUE_VALUE 0x3035
#define EGL_TRANSPARENT_GREEN_VALUE 0x3036
#define EGL_TRANSPARENT_RED_VALUE 0x3037
#define EGL_TRANSPARENT_RGB 0x3052
#define EGL_TRANSPARENT_TYPE 0x3034
#define EGL_TRUE 1
#define EGL_VENDOR 0x3053
#define EGL_VERSION 0x3054
#define EGL_WIDTH 0x3057
#define EGL_WINDOW_BIT 0x0004
EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
EGLAPI EGLContext EGLAPIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface);
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay (void);
EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface (EGLint readdraw);
EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay (EGLNativeDisplayType display_id);
EGLAPI EGLint EGLAPIENTRY eglGetError (void);
EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname);
EGLAPI EGLBoolean EGLAPIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor);
EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
EGLAPI const char *EGLAPIENTRY eglQueryString (EGLDisplay dpy, EGLint name);
EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface surface);
EGLAPI EGLBoolean EGLAPIENTRY eglTerminate (EGLDisplay dpy);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL (void);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine);
#endif /* EGL_VERSION_1_0 */
#ifndef EGL_VERSION_1_1 /* Now, define eglGetProcAddress using the generic function ptr. type */
#define EGL_VERSION_1_1 1 EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY
#define EGL_BACK_BUFFER 0x3084 eglGetProcAddress(const char *procname);
#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 #ifdef __cplusplus
} }
#endif #endif
#endif #endif /* __egl_h_ */

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

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

@ -2,7 +2,7 @@
#define __eglplatform_h_ #define __eglplatform_h_
/* /*
** Copyright (c) 2007-2013 The Khronos Group Inc. ** Copyright (c) 2007-2009 The Khronos Group Inc.
** **
** Permission is hereby granted, free of charge, to any person obtaining a ** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the ** copy of this software and/or associated documentation files (the
@ -25,7 +25,7 @@
*/ */
/* Platform-specific types and definitions for egl.h /* Platform-specific types and definitions for egl.h
* $Revision: 23432 $ on $Date: 2013-10-09 00:57:24 -0700 (Wed, 09 Oct 2013) $ * $Revision: 12306 $ on $Date: 2010-08-25 12:51:28 -0400 (Wed, 25 Aug 2010) $
* *
* Adopters may modify khrplatform.h and this file to suit their platform. * 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 * You are encouraged to submit all modifications to the Khronos group so that
@ -83,16 +83,6 @@ typedef int EGLNativeDisplayType;
typedef void *EGLNativeWindowType; typedef void *EGLNativeWindowType;
typedef void *EGLNativePixmapType; 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__) #elif defined(__unix__)
/* X11 (tentative) */ /* X11 (tentative) */

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

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

@ -1,23 +0,0 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// angle_gl.h:
// Includes all necessary GL headers and definitions for ANGLE.
//
#ifndef ANGLE_GL_H_
#define ANGLE_GL_H_
#include "GLES2/gl2.h"
#include "GLES2/gl2ext.h"
#include "GLES3/gl3.h"
#include "GLES3/gl3ext.h"
// The following enum is used in ANGLE, but is from desktop GL
#ifndef GL_SAMPLER_2D_RECT_ARB
#define GL_SAMPLER_2D_RECT_ARB 0x8B63
#endif
#endif // ANGLE_GL_H_

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

@ -7,7 +7,6 @@ UNIFIED_SOURCES += [
'src/common/event_tracer.cpp', 'src/common/event_tracer.cpp',
'src/common/mathutil.cpp', 'src/common/mathutil.cpp',
'src/common/RefCountObject.cpp', 'src/common/RefCountObject.cpp',
'src/common/tls.cpp',
'src/common/utilities.cpp', 'src/common/utilities.cpp',
'src/compiler/preprocessor/DiagnosticsBase.cpp', 'src/compiler/preprocessor/DiagnosticsBase.cpp',
'src/compiler/preprocessor/DirectiveHandlerBase.cpp', 'src/compiler/preprocessor/DirectiveHandlerBase.cpp',
@ -55,7 +54,6 @@ UNIFIED_SOURCES += [
'src/compiler/translator/RewriteElseBlocks.cpp', 'src/compiler/translator/RewriteElseBlocks.cpp',
'src/compiler/translator/SearchSymbol.cpp', 'src/compiler/translator/SearchSymbol.cpp',
'src/compiler/translator/ShaderLang.cpp', 'src/compiler/translator/ShaderLang.cpp',
'src/compiler/translator/StructureHLSL.cpp',
'src/compiler/translator/SymbolTable.cpp', 'src/compiler/translator/SymbolTable.cpp',
'src/compiler/translator/timing/RestrictFragmentShaderTiming.cpp', 'src/compiler/translator/timing/RestrictFragmentShaderTiming.cpp',
'src/compiler/translator/timing/RestrictVertexShaderTiming.cpp', 'src/compiler/translator/timing/RestrictVertexShaderTiming.cpp',
@ -65,9 +63,7 @@ UNIFIED_SOURCES += [
'src/compiler/translator/Types.cpp', 'src/compiler/translator/Types.cpp',
'src/compiler/translator/UnfoldShortCircuit.cpp', 'src/compiler/translator/UnfoldShortCircuit.cpp',
'src/compiler/translator/UnfoldShortCircuitAST.cpp', 'src/compiler/translator/UnfoldShortCircuitAST.cpp',
'src/compiler/translator/UniformHLSL.cpp',
'src/compiler/translator/util.cpp', 'src/compiler/translator/util.cpp',
'src/compiler/translator/UtilsHLSL.cpp',
'src/compiler/translator/ValidateLimitations.cpp', 'src/compiler/translator/ValidateLimitations.cpp',
'src/compiler/translator/ValidateOutputs.cpp', 'src/compiler/translator/ValidateOutputs.cpp',
'src/compiler/translator/VariableInfo.cpp', 'src/compiler/translator/VariableInfo.cpp',
@ -79,6 +75,26 @@ SOURCES += [
'src/compiler/translator/glslang_lex.cpp', 'src/compiler/translator/glslang_lex.cpp',
'src/compiler/translator/glslang_tab.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']: if CONFIG['GNU_CXX']:

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

@ -7,12 +7,6 @@
{ {
'angle_code': 1, 'angle_code': 1,
'angle_post_build_script%': 0, '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': 'includes':
[ [
@ -29,71 +23,57 @@
'copies': 'copies':
[ [
{ {
'destination': '<(angle_gen_path)', 'destination': '<(SHARED_INTERMEDIATE_DIR)',
'files': [ 'copy_compiler_dll.bat', '<(angle_id_script_base)' ], 'files': [ 'commit_id.bat', 'copy_compiler_dll.bat', 'commit_id.py' ],
}, },
], ],
}, },
{
'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': '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"', ['OS=="win"',
{ {
'targets': 'targets':
@ -110,10 +90,10 @@
'message': 'Copying D3D Compiler DLL...', 'message': 'Copying D3D Compiler DLL...',
'msvs_cygwin_shell': 0, 'msvs_cygwin_shell': 0,
'inputs': [ 'copy_compiler_dll.bat' ], 'inputs': [ 'copy_compiler_dll.bat' ],
'outputs': [ '<(PRODUCT_DIR)/d3dcompiler_46.dll' ], 'outputs': [ '<(PRODUCT_DIR)/D3DCompiler_46.dll' ],
'action': 'action':
[ [
"<(angle_gen_path)/copy_compiler_dll.bat", "<(SHARED_INTERMEDIATE_DIR)/copy_compiler_dll.bat",
"$(PlatformName)", "$(PlatformName)",
"<(windows_sdk_path)", "<(windows_sdk_path)",
"<(PRODUCT_DIR)" "<(PRODUCT_DIR)"

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

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

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

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

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

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

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

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

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

@ -12,7 +12,7 @@
#include "common/mathutil.h" #include "common/mathutil.h"
#include "common/utilities.h" #include "common/utilities.h"
namespace sh namespace gl
{ {
BlockLayoutEncoder::BlockLayoutEncoder(std::vector<BlockMemberInfo> *blockInfoOut) 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) 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) // We assume we are only dealing with 4 byte components (no doubles or half-words currently)
ASSERT(gl::VariableComponentSize(gl::VariableComponentType(type)) == BytesPerComponent); ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent);
size_t baseAlignment = 0; size_t baseAlignment = 0;
int matrixStride = 0; int matrixStride = 0;
@ -127,7 +127,7 @@ void Std140BlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize,
} }
else else
{ {
const int numComponents = gl::VariableComponentCount(type); const int numComponents = gl::UniformComponentCount(type);
baseAlignment = (numComponents == 3 ? 4u : static_cast<size_t>(numComponents)); baseAlignment = (numComponents == 3 ? 4u : static_cast<size_t>(numComponents));
} }
@ -151,7 +151,7 @@ void Std140BlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool
} }
else else
{ {
mCurrentOffset += gl::VariableComponentCount(type); mCurrentOffset += gl::UniformComponentCount(type);
} }
} }
@ -173,7 +173,7 @@ void HLSLBlockEncoder::exitAggregateType()
void HLSLBlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut) 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) // We assume we are only dealing with 4 byte components (no doubles or half-words currently)
ASSERT(gl::VariableComponentSize(gl::VariableComponentType(type)) == BytesPerComponent); ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent);
int matrixStride = 0; int matrixStride = 0;
int arrayStride = 0; int arrayStride = 0;
@ -204,7 +204,7 @@ void HLSLBlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, b
} }
else if (isPacked()) else if (isPacked())
{ {
int numComponents = gl::VariableComponentCount(type); int numComponents = gl::UniformComponentCount(type);
if ((numComponents + (mCurrentOffset % ComponentsPerRegister)) > ComponentsPerRegister) if ((numComponents + (mCurrentOffset % ComponentsPerRegister)) > ComponentsPerRegister)
{ {
nextRegister(); nextRegister();
@ -232,7 +232,7 @@ void HLSLBlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool i
} }
else if (isPacked()) else if (isPacked())
{ {
mCurrentOffset += gl::VariableComponentCount(type); mCurrentOffset += gl::UniformComponentCount(type);
} }
else else
{ {
@ -245,8 +245,8 @@ void HLSLBlockEncoder::skipRegisters(unsigned int numRegisters)
mCurrentOffset += (numRegisters * ComponentsPerRegister); mCurrentOffset += (numRegisters * ComponentsPerRegister);
} }
void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable, HLSLBlockEncoder *encoder, void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, gl::Uniform *variable, HLSLBlockEncoder *encoder,
const std::vector<BlockMemberInfo> &blockInfo, ShShaderOutput outputType) const std::vector<gl::BlockMemberInfo> &blockInfo, ShShaderOutput outputType)
{ {
// because this method computes offsets (element indexes) instead of any total sizes, // because this method computes offsets (element indexes) instead of any total sizes,
// we can ignore the array size of the variable // we can ignore the array size of the variable
@ -282,7 +282,7 @@ void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variab
} }
} }
void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable, ShShaderOutput outputType) void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, gl::Uniform *variable, ShShaderOutput outputType)
{ {
std::vector<BlockMemberInfo> blockInfo; std::vector<BlockMemberInfo> blockInfo;
HLSLBlockEncoder encoder(&blockInfo, HLSLBlockEncoder encoder(&blockInfo,

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

@ -11,12 +11,14 @@
#define COMMON_BLOCKLAYOUT_H_ #define COMMON_BLOCKLAYOUT_H_
#include <vector> #include <vector>
#include "angle_gl.h" #include <GLES3/gl3.h>
#include <GLES2/gl2.h>
#include <GLSLANG/ShaderLang.h> #include <GLSLANG/ShaderLang.h>
#include <cstddef> #include <cstddef>
namespace sh namespace gl
{ {
struct ShaderVariable; struct ShaderVariable;
struct InterfaceBlockField; struct InterfaceBlockField;
struct BlockMemberInfo; struct BlockMemberInfo;
@ -67,7 +69,7 @@ class Std140BlockEncoder : public BlockLayoutEncoder
// Block layout packed according to the D3D9 or default D3D10+ register packing rules // 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 // See http://msdn.microsoft.com/en-us/library/windows/desktop/bb509632(v=vs.85).aspx
// The strategy should be ENCODE_LOOSE for D3D9 constant blocks, and ENCODE_PACKED // The strategy should be ENCODE_LOOSE for D3D9 constnat blocks, and ENCODE_PACKED
// for everything else (D3D10+ constant blocks and all attributes/varyings). // for everything else (D3D10+ constant blocks and all attributes/varyings).
class HLSLBlockEncoder : public BlockLayoutEncoder class HLSLBlockEncoder : public BlockLayoutEncoder

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

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

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

@ -83,12 +83,6 @@ namespace gl
#define UNUSED_ASSERTION_VARIABLE(variable) ((void)variable) #define UNUSED_ASSERTION_VARIABLE(variable) ((void)variable)
#endif #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 // A macro to indicate unimplemented functionality
// Define NOASSERT_UNIMPLEMENTED to non zero to skip the assert fail in the unimplemented checks // Define NOASSERT_UNIMPLEMENTED to non zero to skip the assert fail in the unimplemented checks

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

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

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

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

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

@ -1,67 +0,0 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// platform.h: Operating system specific includes and defines.
#ifndef COMMON_PLATFORM_H_
#define COMMON_PLATFORM_H_
#if defined(_WIN32) || defined(_WIN64)
# define ANGLE_PLATFORM_WINDOWS 1
#elif defined(__APPLE__)
# define ANGLE_PLATFORM_APPLE 1
# define ANGLE_PLATFORM_POSIX 1
#elif defined(__linux__)
# define ANGLE_PLATFORM_LINUX 1
# define ANGLE_PLATFORM_POSIX 1
#elif defined(ANDROID)
# define ANGLE_PLATFORM_ANDROID 1
# define ANGLE_PLATFORM_POSIX 1
#elif defined(__FreeBSD__) || \
defined(__OpenBSD__) || \
defined(__NetBSD__) || \
defined(__DragonFly__) || \
defined(__sun) || \
defined(__GLIBC__) || \
defined(__GNU__) || \
defined(__QNX__)
# define ANGLE_PLATFORM_POSIX 1
#else
# error Unsupported platform.
#endif
#ifdef ANGLE_PLATFORM_WINDOWS
# ifndef STRICT
# define STRICT 1
# endif
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN 1
# endif
# ifndef NOMINMAX
# define NOMINMAX 1
# endif
# include <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,14 +13,13 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#include "GLSLANG/ShaderLang.h"
namespace sh #include <GLES3/gl3.h>
#include <GLES2/gl2.h>
namespace gl
{ {
// GLenum alias
typedef unsigned int GLenum;
// Varying interpolation qualifier, see section 4.3.9 of the ESSL 3.00.4 spec // Varying interpolation qualifier, see section 4.3.9 of the ESSL 3.00.4 spec
enum InterpolationType enum InterpolationType
{ {
@ -40,115 +39,105 @@ enum BlockLayoutType
// Base class for all variables defined in shaders, including Varyings, Uniforms, etc // Base class for all variables defined in shaders, including Varyings, Uniforms, etc
struct ShaderVariable struct ShaderVariable
{ {
ShaderVariable(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn)
: type(typeIn),
precision(precisionIn),
name(nameIn),
arraySize(arraySizeIn)
{}
bool isArray() const { return arraySize > 0; }
unsigned int elementCount() const { return std::max(1u, arraySize); }
GLenum type; GLenum type;
GLenum precision; GLenum precision;
std::string name; std::string name;
unsigned int arraySize; unsigned int arraySize;
ShaderVariable(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn)
: type(typeIn),
precision(precisionIn),
name(nameIn),
arraySize(arraySizeIn)
{}
bool isArray() const { return arraySize > 0; }
unsigned int elementCount() const { return std::max(1u, arraySize); }
}; };
// Uniform registers (and element indices) are assigned when outputting shader code // Uniform registers (and element indices) are assigned when outputting shader code
struct Uniform : public ShaderVariable 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, Uniform(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn,
unsigned int registerIndexIn, unsigned int elementIndexIn) unsigned int registerIndexIn, unsigned int elementIndexIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn), : ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
registerIndex(registerIndexIn), registerIndex(registerIndexIn),
elementIndex(elementIndexIn) elementIndex(elementIndexIn)
{} {}
bool isStruct() const { return !fields.empty(); } 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 struct Attribute : public ShaderVariable
{ {
int location;
Attribute() Attribute()
: ShaderVariable((GLenum)0, (GLenum)0, "", 0), : ShaderVariable(GL_NONE, GL_NONE, "", 0),
location(-1) location(-1)
{} {}
Attribute(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, int locationIn) Attribute(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, int locationIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn), : ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
location(locationIn) location(locationIn)
{} {}
int location;
}; };
struct InterfaceBlockField : public ShaderVariable struct InterfaceBlockField : public ShaderVariable
{ {
bool isRowMajorMatrix;
std::vector<InterfaceBlockField> fields;
InterfaceBlockField(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, bool isRowMajorMatrix) InterfaceBlockField(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, bool isRowMajorMatrix)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn), : ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
isRowMajorMatrix(isRowMajorMatrix) isRowMajorMatrix(isRowMajorMatrix)
{} {}
bool isStruct() const { return !fields.empty(); } bool isStruct() const { return !fields.empty(); }
bool isRowMajorMatrix;
std::vector<InterfaceBlockField> fields;
}; };
struct Varying : public ShaderVariable struct Varying : public ShaderVariable
{ {
Varying(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, InterpolationType interpolationIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
interpolation(interpolationIn)
{}
bool isStruct() const { return !fields.empty(); }
InterpolationType interpolation; InterpolationType interpolation;
std::vector<Varying> fields; std::vector<Varying> fields;
std::string structName; std::string structName;
Varying(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, InterpolationType interpolationIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
interpolation(interpolationIn)
{}
bool isStruct() const { return !fields.empty(); }
}; };
struct BlockMemberInfo struct BlockMemberInfo
{ {
BlockMemberInfo(int offset, int arrayStride, int matrixStride, bool isRowMajorMatrix) int offset;
: offset(offset), int arrayStride;
arrayStride(arrayStride), int matrixStride;
matrixStride(matrixStride), bool isRowMajorMatrix;
isRowMajorMatrix(isRowMajorMatrix)
{}
static BlockMemberInfo getDefaultBlockInfo() static BlockMemberInfo getDefaultBlockInfo()
{ {
return BlockMemberInfo(-1, -1, -1, false); return BlockMemberInfo(-1, -1, -1, false);
} }
int offset; BlockMemberInfo(int offset, int arrayStride, int matrixStride, bool isRowMajorMatrix)
int arrayStride; : offset(offset),
int matrixStride; arrayStride(arrayStride),
bool isRowMajorMatrix; matrixStride(matrixStride),
isRowMajorMatrix(isRowMajorMatrix)
{}
}; };
typedef std::vector<BlockMemberInfo> BlockMemberInfoArray; typedef std::vector<BlockMemberInfo> BlockMemberInfoArray;
struct InterfaceBlock 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; std::string name;
unsigned int arraySize; unsigned int arraySize;
size_t dataSize; size_t dataSize;
@ -157,8 +146,15 @@ struct InterfaceBlock
std::vector<InterfaceBlockField> fields; std::vector<InterfaceBlockField> fields;
std::vector<BlockMemberInfo> blockInfo; std::vector<BlockMemberInfo> blockInfo;
// HLSL-specific members
unsigned int registerIndex; unsigned int registerIndex;
InterfaceBlock(const char *name, unsigned int arraySize, unsigned int registerIndex)
: name(name),
arraySize(arraySize),
layout(BLOCKLAYOUT_SHARED),
registerIndex(registerIndex),
isRowMajorLayout(false)
{}
}; };
} }

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

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

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

@ -1,33 +0,0 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// tls.h: Simple cross-platform interface for thread local storage.
#ifndef COMMON_TLS_H_
#define COMMON_TLS_H_
#include "common/platform.h"
#ifdef ANGLE_PLATFORM_WINDOWS
typedef DWORD TLSIndex;
# define TLS_INVALID_INDEX (TLS_OUT_OF_INDEXES)
#elif defined(ANGLE_PLATFORM_POSIX)
# include <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,14 +8,17 @@
#include "common/utilities.h" #include "common/utilities.h"
#include "common/mathutil.h" #include "common/mathutil.h"
#include "common/platform.h"
#if defined(_WIN32)
#include <windows.h>
#endif
#include <set> #include <set>
namespace gl namespace gl
{ {
int VariableComponentCount(GLenum type) int UniformComponentCount(GLenum type)
{ {
switch (type) switch (type)
{ {
@ -75,7 +78,7 @@ int VariableComponentCount(GLenum type)
return 0; return 0;
} }
GLenum VariableComponentType(GLenum type) GLenum UniformComponentType(GLenum type)
{ {
switch(type) switch(type)
{ {
@ -130,7 +133,7 @@ GLenum VariableComponentType(GLenum type)
return GL_NONE; return GL_NONE;
} }
size_t VariableComponentSize(GLenum type) size_t UniformComponentSize(GLenum type)
{ {
switch(type) switch(type)
{ {
@ -144,18 +147,18 @@ size_t VariableComponentSize(GLenum type)
return 0; return 0;
} }
size_t VariableInternalSize(GLenum type) size_t UniformInternalSize(GLenum type)
{ {
// Expanded to 4-element vectors // Expanded to 4-element vectors
return VariableComponentSize(VariableComponentType(type)) * VariableRowCount(type) * 4; return UniformComponentSize(UniformComponentType(type)) * VariableRowCount(type) * 4;
} }
size_t VariableExternalSize(GLenum type) size_t UniformExternalSize(GLenum type)
{ {
return VariableComponentSize(VariableComponentType(type)) * VariableComponentCount(type); return UniformComponentSize(UniformComponentType(type)) * UniformComponentCount(type);
} }
GLenum VariableBoolVectorType(GLenum type) GLenum UniformBoolVectorType(GLenum type)
{ {
switch (type) switch (type)
{ {
@ -362,7 +365,7 @@ int MatrixComponentCount(GLenum type, bool isRowMajorMatrix)
return isRowMajorMatrix ? VariableColumnCount(type) : VariableRowCount(type); return isRowMajorMatrix ? VariableColumnCount(type) : VariableRowCount(type);
} }
int VariableRegisterCount(GLenum type) int AttributeRegisterCount(GLenum type)
{ {
return IsMatrixType(type) ? VariableColumnCount(type) : 1; return IsMatrixType(type) ? VariableColumnCount(type) : 1;
} }
@ -392,6 +395,24 @@ bool IsCubemapTextureTarget(GLenum target)
return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z); 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) bool IsTriangleMode(GLenum drawMode)
{ {
switch (drawMode) switch (drawMode)
@ -415,7 +436,7 @@ bool IsTriangleMode(GLenum drawMode)
std::string getTempPath() std::string getTempPath()
{ {
#ifdef ANGLE_PLATFORM_WINDOWS #if defined (_WIN32)
char path[MAX_PATH]; char path[MAX_PATH];
DWORD pathLen = GetTempPathA(sizeof(path) / sizeof(path[0]), path); DWORD pathLen = GetTempPathA(sizeof(path) / sizeof(path[0]), path);
if (pathLen == 0) if (pathLen == 0)

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

@ -9,31 +9,36 @@
#ifndef LIBGLESV2_UTILITIES_H #ifndef LIBGLESV2_UTILITIES_H
#define LIBGLESV2_UTILITIES_H #define LIBGLESV2_UTILITIES_H
#include "angle_gl.h" #include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <string> #include <string>
#include <math.h> #include <math.h>
namespace gl namespace gl
{ {
int VariableComponentCount(GLenum type); int UniformComponentCount(GLenum type);
GLenum VariableComponentType(GLenum type); GLenum UniformComponentType(GLenum type);
size_t VariableComponentSize(GLenum type); size_t UniformComponentSize(GLenum type);
size_t VariableInternalSize(GLenum type); size_t UniformInternalSize(GLenum type);
size_t VariableExternalSize(GLenum type); size_t UniformExternalSize(GLenum type);
GLenum VariableBoolVectorType(GLenum type); GLenum UniformBoolVectorType(GLenum type);
int VariableRowCount(GLenum type); int VariableRowCount(GLenum type);
int VariableColumnCount(GLenum type); int VariableColumnCount(GLenum type);
bool IsSampler(GLenum type); bool IsSampler(GLenum type);
bool IsMatrixType(GLenum type); bool IsMatrixType(GLenum type);
GLenum TransposeMatrixType(GLenum type); GLenum TransposeMatrixType(GLenum type);
int VariableRegisterCount(GLenum type); int AttributeRegisterCount(GLenum type);
int MatrixRegisterCount(GLenum type, bool isRowMajorMatrix); int MatrixRegisterCount(GLenum type, bool isRowMajorMatrix);
int MatrixComponentCount(GLenum type, bool isRowMajorMatrix); int MatrixComponentCount(GLenum type, bool isRowMajorMatrix);
int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize); int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize);
bool IsCubemapTextureTarget(GLenum target); bool IsCubemapTextureTarget(GLenum target);
bool IsInternalTextureTarget(GLenum target, GLuint clientVersion);
bool IsTriangleMode(GLenum drawMode); bool IsTriangleMode(GLenum drawMode);

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

@ -28,6 +28,18 @@
-excludes compiler/translator/ShaderLang.cpp \ -excludes compiler/translator/ShaderLang.cpp \
-types *.cpp *.h *.y *.l)', -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': 'msvs_settings':
{ {
'VCLibrarianTool': 'VCLibrarianTool':

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

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

@ -5,7 +5,6 @@
// //
#include "compiler/translator/BuiltInFunctionEmulator.h" #include "compiler/translator/BuiltInFunctionEmulator.h"
#include "compiler/translator/Compiler.h"
#include "compiler/translator/DetectCallDepth.h" #include "compiler/translator/DetectCallDepth.h"
#include "compiler/translator/ForLoopUnroll.h" #include "compiler/translator/ForLoopUnroll.h"
#include "compiler/translator/Initialize.h" #include "compiler/translator/Initialize.h"
@ -13,6 +12,7 @@
#include "compiler/translator/InitializeVariables.h" #include "compiler/translator/InitializeVariables.h"
#include "compiler/translator/ParseContext.h" #include "compiler/translator/ParseContext.h"
#include "compiler/translator/RenameFunction.h" #include "compiler/translator/RenameFunction.h"
#include "compiler/translator/ShHandle.h"
#include "compiler/translator/UnfoldShortCircuitAST.h" #include "compiler/translator/UnfoldShortCircuitAST.h"
#include "compiler/translator/ValidateLimitations.h" #include "compiler/translator/ValidateLimitations.h"
#include "compiler/translator/ValidateOutputs.h" #include "compiler/translator/ValidateOutputs.h"

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

@ -1,5 +1,5 @@
// //
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
@ -18,67 +18,6 @@ public:
type = EbtVoid; 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 setIConst(int i) {iConst = i; type = EbtInt; }
void setUConst(unsigned int u) { uConst = u; type = EbtUInt; } void setUConst(unsigned int u) { uConst = u; type = EbtUInt; }
void setFConst(float f) {fConst = f; type = EbtFloat; } void setFConst(float f) {fConst = f; type = EbtFloat; }

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

@ -566,10 +566,10 @@ void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltI
fields->push_back(diff); fields->push_back(diff);
TStructure *depthRangeStruct = new TStructure(NewPoolTString("gl_DepthRangeParameters"), fields); TStructure *depthRangeStruct = new TStructure(NewPoolTString("gl_DepthRangeParameters"), fields);
TVariable *depthRangeParameters = new TVariable(&depthRangeStruct->name(), depthRangeStruct, true); 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)); TVariable *depthRange = new TVariable(NewPoolTString("gl_DepthRange"), TType(depthRangeStruct));
depthRange->setQualifier(EvqUniform); depthRange->setQualifier(EvqUniform);
symbolTable.insert(COMMON_BUILTINS, depthRange); symbolTable.insert(COMMON_BUILTINS, *depthRange);
// //
// Implementation dependent built-in constants. // Implementation dependent built-in constants.
@ -604,31 +604,31 @@ void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec,
// //
switch(type) { switch(type) {
case SH_FRAGMENT_SHADER: 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_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_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_PointCoord"), TType(EbtFloat, EbpMedium, EvqPointCoord, 2)));
// //
// In CSS Shaders, gl_FragColor, gl_FragData, and gl_MaxDrawBuffers are not available. // In CSS Shaders, gl_FragColor, gl_FragData, and gl_MaxDrawBuffers are not available.
// Instead, css_MixColor and css_ColorMatrix are available. // Instead, css_MixColor and css_ColorMatrix are available.
// //
if (spec != SH_CSS_SHADERS_SPEC) { 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_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_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData, 4)));
if (resources.EXT_frag_depth) { 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"); symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_FragDepthEXT", "GL_EXT_frag_depth");
} }
} else { } else {
symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("css_MixColor"), TType(EbtFloat, EbpMedium, EvqGlobal, 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))); symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("css_ColorMatrix"), TType(EbtFloat, EbpMedium, EvqGlobal, 4, 4)));
} }
break; break;
case SH_VERTEX_SHADER: 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_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_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1)));
break; break;
default: assert(false && "Language not supported"); default: assert(false && "Language not supported");
@ -735,7 +735,7 @@ void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec,
// Set up gl_FragData. The array size. // Set up gl_FragData. The array size.
TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true); TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true);
fragData.setArraySize(resources.MaxDrawBuffers); 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; break;
default: break; default: break;

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

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

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

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

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

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

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

@ -1,5 +1,5 @@
// //
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
@ -78,6 +78,26 @@ const char* getOperatorString(TOperator op)
case EOpPreIncrement: return "++"; case EOpPreIncrement: return "++";
case EOpPreDecrement: 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 EOpRadians: return "radians";
case EOpDegrees: return "degrees"; case EOpDegrees: return "degrees";
case EOpSin: return "sin"; case EOpSin: return "sin";
@ -168,9 +188,23 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
default: break; default: break;
} }
if (left->getBasicType() != right->getBasicType()) //
{ // First try converting the children to compatible types.
return 0; //
if (left->getType().getStruct() && right->getType().getStruct()) {
if (left->getType() != right->getType())
return 0;
} else {
TIntermTyped* child = addConversion(op, left->getType(), right);
if (child)
right = child;
else {
child = addConversion(op, right->getType(), left);
if (child)
left = child;
else
return 0;
}
} }
// //
@ -207,19 +241,19 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
// //
TIntermTyped* TIntermediate::addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc& line) TIntermTyped* TIntermediate::addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc& line)
{ {
if (left->getType().getStruct() || right->getType().getStruct()) //
{ // Like adding binary math, except the conversion can only go
if (left->getType() != right->getType()) // from right to left.
{ //
return 0;
}
}
TIntermBinary* node = new TIntermBinary(op); TIntermBinary* node = new TIntermBinary(op);
node->setLine(line); node->setLine(line);
TIntermTyped* child = addConversion(op, left->getType(), right);
if (child == 0)
return 0;
node->setLeft(left); node->setLeft(left);
node->setRight(right); node->setRight(child);
if (! node->promote(infoSink)) if (! node->promote(infoSink))
return 0; return 0;
@ -277,6 +311,42 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode,
default: break; 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; TIntermConstantUnion *childTempConstant = 0;
if (child->getAsConstantUnion()) if (child->getAsConstantUnion())
childTempConstant = child->getAsConstantUnion(); childTempConstant = child->getAsConstantUnion();
@ -339,6 +409,140 @@ TIntermAggregate* TIntermediate::setAggregateOperator(TIntermNode* node, TOperat
return aggNode; 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, // Safe way to combine two nodes into an aggregate. Works with null pointers,
// a node that's not a aggregate yet, etc. // a node that's not a aggregate yet, etc.
@ -436,9 +640,18 @@ TIntermTyped* TIntermediate::addComma(TIntermTyped* left, TIntermTyped* right, c
// //
TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc& line) TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc& line)
{ {
if (trueBlock->getType() != falseBlock->getType()) //
{ // Get compatible types.
return 0; //
TIntermTyped* child = addConversion(EOpSequence, trueBlock->getType(), falseBlock);
if (child)
falseBlock = child;
else {
child = addConversion(EOpSequence, falseBlock->getType(), trueBlock);
if (child)
trueBlock = child;
else
return 0;
} }
// //
@ -830,9 +1043,7 @@ bool TIntermBinary::promote(TInfoSink& infoSink)
// GLSL ES 2.0 does not support implicit type casting. // GLSL ES 2.0 does not support implicit type casting.
// So the basic type should always match. // So the basic type should always match.
if (left->getBasicType() != right->getBasicType()) if (left->getBasicType() != right->getBasicType())
{
return false; return false;
}
// //
// Base assumption: just make the type the same as the left // Base assumption: just make the type the same as the left
@ -1513,6 +1724,104 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
} }
} }
TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermConstantUnion* node)
{
size_t size = node->getType().getObjectSize();
ConstantUnion *leftUnionArray = new ConstantUnion[size];
for (size_t i=0; i < size; i++) {
switch (promoteTo) {
case EbtFloat:
switch (node->getType().getBasicType()) {
case EbtInt:
leftUnionArray[i].setFConst(static_cast<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 // static
TString TIntermTraverser::hash(const TString& name, ShHashFunction64 hashFunction) TString TIntermTraverser::hash(const TString& name, ShHashFunction64 hashFunction)
{ {

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

@ -1,5 +1,5 @@
// //
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
@ -55,6 +55,8 @@ TOutputGLSLBase::TOutputGLSLBase(TInfoSinkBase &objSink,
mSymbolTable(symbolTable), mSymbolTable(symbolTable),
mShaderVersion(shaderVersion) mShaderVersion(shaderVersion)
{ {
// Set up global scope.
mDeclaredStructs.push_back(ScopedDeclaredStructs());
} }
void TOutputGLSLBase::writeTriplet( void TOutputGLSLBase::writeTriplet(
@ -87,14 +89,8 @@ void TOutputGLSLBase::writeVariableType(const TType &type)
// Declare the struct if we have not done so already. // Declare the struct if we have not done so already.
if (type.getBasicType() == EbtStruct && !structDeclared(type.getStruct())) if (type.getBasicType() == EbtStruct && !structDeclared(type.getStruct()))
{ {
TStructure *structure = type.getStruct(); declareStruct(type.getStruct());
mDeclaredStructs[mDeclaredStructs.size() - 1].push_back(type.getStruct());
declareStruct(structure);
if (!structure->name().empty())
{
mDeclaredStructs.insert(structure->uniqueId());
}
} }
else else
{ {
@ -402,6 +398,67 @@ bool TOutputGLSLBase::visitUnary(Visit visit, TIntermUnary *node)
case EOpPreIncrement: preString = "(++"; break; case EOpPreIncrement: preString = "(++"; break;
case EOpPreDecrement: 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: case EOpRadians:
preString = "radians("; preString = "radians(";
break; break;
@ -547,6 +604,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node)
if (depth > 0) if (depth > 0)
{ {
out << "{\n"; out << "{\n";
pushDeclaredStructsScope();
} }
incrementDepth(node); incrementDepth(node);
@ -565,6 +623,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node)
// Scope the sequences except when at the global scope. // Scope the sequences except when at the global scope.
if (depth > 0) if (depth > 0)
{ {
popDeclaredStructsScope();
out << "}\n"; out << "}\n";
} }
visitChildren = false; visitChildren = false;
@ -976,12 +1035,17 @@ TString TOutputGLSLBase::hashFunctionName(const TString &mangled_name)
bool TOutputGLSLBase::structDeclared(const TStructure *structure) const bool TOutputGLSLBase::structDeclared(const TStructure *structure) const
{ {
ASSERT(structure); ASSERT(structure);
if (structure->name().empty()) ASSERT(mDeclaredStructs.size() > 0);
for (size_t ii = mDeclaredStructs.size(); ii > 0; --ii)
{ {
return false; const ScopedDeclaredStructs &scope = mDeclaredStructs[ii - 1];
for (size_t jj = 0; jj < scope.size(); ++jj)
{
if (scope[jj]->equals(*structure))
return true;
}
} }
return false;
return (mDeclaredStructs.count(structure->uniqueId()) > 0);
} }
void TOutputGLSLBase::declareStruct(const TStructure *structure) void TOutputGLSLBase::declareStruct(const TStructure *structure)
@ -1003,3 +1067,14 @@ void TOutputGLSLBase::declareStruct(const TStructure *structure)
out << "}"; 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_ #ifndef CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_
#define CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ #define CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_
#include <set> #include <vector>
#include "compiler/translator/intermediate.h" #include "compiler/translator/intermediate.h"
#include "compiler/translator/LoopInfo.h" #include "compiler/translator/LoopInfo.h"
@ -56,14 +56,22 @@ class TOutputGLSLBase : public TIntermTraverser
private: private:
bool structDeclared(const TStructure *structure) const; bool structDeclared(const TStructure *structure) const;
void declareStruct(const TStructure *structure); void declareStruct(const TStructure *structure);
void pushDeclaredStructsScope();
void popDeclaredStructsScope();
void writeBuiltInFunctionTriplet(Visit visit, const char *preStr, bool useEmulatedFunction); void writeBuiltInFunctionTriplet(Visit visit, const char *preStr, bool useEmulatedFunction);
TInfoSinkBase &mObjSink; TInfoSinkBase &mObjSink;
bool mDeclaringVariables; bool mDeclaringVariables;
// This set contains all the ids of the structs from every scope. // Structs are declared as the tree is traversed. This list contains all
std::set<int> mDeclaredStructs; // 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;
// Stack of loops that need to be unrolled. // Stack of loops that need to be unrolled.
TLoopStack mLoopUnrollStack; TLoopStack mLoopUnrollStack;

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

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

@ -11,7 +11,9 @@
#include <set> #include <set>
#include <map> #include <map>
#include "angle_gl.h" #include <GLES3/gl3.h>
#include <GLES2/gl2.h>
#include "compiler/translator/intermediate.h" #include "compiler/translator/intermediate.h"
#include "compiler/translator/ParseContext.h" #include "compiler/translator/ParseContext.h"
#include "common/shadervars.h" #include "common/shadervars.h"
@ -19,10 +21,6 @@
namespace sh namespace sh
{ {
class UnfoldShortCircuit; class UnfoldShortCircuit;
class StructureHLSL;
class UniformHLSL;
typedef std::map<TString, TIntermSymbol*> ReferencedSymbols;
class OutputHLSL : public TIntermTraverser class OutputHLSL : public TIntermTraverser
{ {
@ -33,13 +31,24 @@ class OutputHLSL : public TIntermTraverser
void output(); void output();
TInfoSinkBase &getBodyStream(); TInfoSinkBase &getBodyStream();
const std::vector<sh::Uniform> &getUniforms(); const std::vector<gl::Uniform> &getUniforms();
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const; const std::vector<gl::InterfaceBlock> &getInterfaceBlocks() const;
const std::vector<sh::Attribute> &getOutputVariables() const; const std::vector<gl::Attribute> &getOutputVariables() const;
const std::vector<sh::Attribute> &getAttributes() const; const std::vector<gl::Attribute> &getAttributes() const;
const std::vector<sh::Varying> &getVaryings() const; const std::vector<gl::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 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: protected:
void header(); void header();
@ -62,9 +71,13 @@ class OutputHLSL : public TIntermTraverser
TString argumentString(const TIntermSymbol *symbol); TString argumentString(const TIntermSymbol *symbol);
int vectorSize(const TType &type) const; int vectorSize(const TType &type) const;
void outputConstructor(Visit visit, const TType &type, const TString &name, const TIntermSequence *parameters); void addConstructor(const TType &type, const TString &name, const TIntermSequence *parameters);
const ConstantUnion *writeConstantUnion(const TType &type, const ConstantUnion *constUnion); 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; TParseContext &mContext;
const ShShaderOutput mOutputType; const ShShaderOutput mOutputType;
UnfoldShortCircuit *mUnfoldShortCircuit; UnfoldShortCircuit *mUnfoldShortCircuit;
@ -75,15 +88,13 @@ class OutputHLSL : public TIntermTraverser
TInfoSinkBase mBody; TInfoSinkBase mBody;
TInfoSinkBase mFooter; TInfoSinkBase mFooter;
typedef std::map<TString, TIntermSymbol*> ReferencedSymbols;
ReferencedSymbols mReferencedUniforms; ReferencedSymbols mReferencedUniforms;
ReferencedSymbols mReferencedInterfaceBlocks; ReferencedSymbols mReferencedInterfaceBlocks;
ReferencedSymbols mReferencedAttributes; ReferencedSymbols mReferencedAttributes;
ReferencedSymbols mReferencedVaryings; ReferencedSymbols mReferencedVaryings;
ReferencedSymbols mReferencedOutputVariables; ReferencedSymbols mReferencedOutputVariables;
StructureHLSL *mStructureHLSL;
UniformHLSL *mUniformHLSL;
struct TextureFunction struct TextureFunction
{ {
enum Method enum Method
@ -142,6 +153,19 @@ class OutputHLSL : public TIntermTraverser
int mNumRenderTargets; 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 int mUniqueIndex; // For creating unique names
bool mContainsLoopDiscontinuity; bool mContainsLoopDiscontinuity;
@ -151,19 +175,51 @@ class OutputHLSL : public TIntermTraverser
TIntermSymbol *mExcessiveLoopIndex; TIntermSymbol *mExcessiveLoopIndex;
void declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector<sh::Varying>& fieldsOut); int mUniformRegister;
int mInterfaceBlockRegister;
int mSamplerRegister;
int mPaddingCounter;
TString registerString(TIntermSymbol *operand);
int samplerRegister(TIntermSymbol *sampler);
int uniformRegister(TIntermSymbol *uniform);
void declareInterfaceBlockField(const TType &type, const TString &name, std::vector<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); TString structInitializerString(int indent, const TStructure &structure, const TString &rhsStructName);
std::vector<sh::Attribute> mActiveOutputVariables; static GLenum glVariableType(const TType &type);
std::vector<sh::Attribute> mActiveAttributes; static GLenum glVariablePrecision(const TType &type);
std::vector<sh::Varying> mActiveVaryings; 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::map<TIntermTyped*, TString> mFlaggedStructMappedNames; std::map<TIntermTyped*, TString> mFlaggedStructMappedNames;
std::map<TIntermTyped*, TString> mFlaggedStructOriginalNames; std::map<TIntermTyped*, TString> mFlaggedStructOriginalNames;
void makeFlaggedStructMaps(const std::vector<TIntermTyped *> &flaggedStructs); void makeFlaggedStructMaps(const std::vector<TIntermTyped *> &flaggedStructs);
}; };
} }
#endif // COMPILER_OUTPUTHLSL_H_ #endif // COMPILER_OUTPUTHLSL_H_

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

@ -1,5 +1,5 @@
// //
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
@ -701,44 +701,28 @@ bool TParseContext::arraySizeErrorCheck(const TSourceLoc& line, TIntermTyped* ex
return true; return true;
} }
unsigned int unsignedSize = 0;
if (constant->getBasicType() == EbtUInt) if (constant->getBasicType() == EbtUInt)
{ {
unsignedSize = constant->getUConst(0); unsigned int uintSize = constant->getUConst(0);
size = static_cast<int>(unsignedSize); 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);
} }
else else
{ {
size = constant->getIConst(0); size = constant->getIConst(0);
if (size < 0) if (size <= 0)
{ {
error(line, "array size must be non-negative", ""); error(line, "array size must be a positive integer", "");
size = 1; size = 1;
return true; 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; return false;
@ -804,7 +788,7 @@ bool TParseContext::arrayErrorCheck(const TSourceLoc& line, const TString& ident
if (type.arraySize) if (type.arraySize)
variable->getType().setArraySize(type.arraySize); variable->getType().setArraySize(type.arraySize);
if (! symbolTable.declare(variable)) { if (! symbolTable.declare(*variable)) {
delete variable; delete variable;
error(line, "INTERNAL ERROR inserting new symbol", identifier.c_str()); error(line, "INTERNAL ERROR inserting new symbol", identifier.c_str());
return true; return true;
@ -884,7 +868,7 @@ bool TParseContext::nonInitErrorCheck(const TSourceLoc& line, const TString& ide
variable = new TVariable(&identifier, TType(type)); variable = new TVariable(&identifier, TType(type));
if (! symbolTable.declare(variable)) { if (! symbolTable.declare(*variable)) {
error(line, "redefinition", variable->getName().c_str()); error(line, "redefinition", variable->getName().c_str());
delete variable; delete variable;
variable = 0; variable = 0;
@ -1066,7 +1050,7 @@ bool TParseContext::executeInitializer(const TSourceLoc& line, const TString& id
// add variable to symbol table // add variable to symbol table
// //
variable = new TVariable(&identifier, type); variable = new TVariable(&identifier, type);
if (! symbolTable.declare(variable)) { if (! symbolTable.declare(*variable)) {
error(line, "redefinition", variable->getName().c_str()); error(line, "redefinition", variable->getName().c_str());
return true; return true;
// don't delete variable, it's used by error recovery, and the pool // don't delete variable, it's used by error recovery, and the pool
@ -1531,40 +1515,81 @@ TFunction *TParseContext::addConstructorFunc(TPublicType publicType)
// //
// Returns 0 for an error or the constructed node (aggregate or typed) for no error. // Returns 0 for an error or the constructed node (aggregate or typed) for no error.
// //
TIntermTyped *TParseContext::addConstructor(TIntermNode *arguments, const TType *type, TOperator op, TFunction *fnCall, const TSourceLoc &line) TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type, TOperator op, TFunction* fnCall, const TSourceLoc& line)
{ {
TIntermAggregate *aggregateArguments = arguments->getAsAggregate(); if (node == 0)
return 0;
if (!aggregateArguments) TIntermAggregate* aggrNode = node->getAsAggregate();
{
aggregateArguments = new TIntermAggregate; TFieldList::const_iterator memberTypes;
aggregateArguments->getSequence().push_back(arguments); if (op == EOpConstructStruct)
memberTypes = type->getStruct()->fields().begin();
TType elementType = *type;
if (type->isArray())
elementType.clearArrayness();
bool singleArg;
if (aggrNode) {
if (aggrNode->getOp() != EOpNull || aggrNode->getSequence().size() == 1)
singleArg = true;
else
singleArg = false;
} else
singleArg = true;
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;
} }
if (op == EOpConstructStruct) //
{ // Handle list of arguments.
const TFieldList &fields = type->getStruct()->fields(); //
TIntermSequence &args = aggregateArguments->getSequence(); 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
for (size_t i = 0; i < fields.size(); i++) int paramCount = 0; // keeps a track of the constructor parameter number being checked
{
if (args[i]->getAsTyped()->getType() != *fields[i]->type())
{
error(line, "Structure constructor arguments do not match structure fields", "Error");
recover();
return 0; // for each parameter to the constructor call, check to see if the right type is passed or convert them
} // to the right type if possible (and allowed).
// for structure constructors, just check if the right type is passed, no conversion is allowed.
for (TIntermSequence::iterator p = sequenceVector.begin();
p != sequenceVector.end(); p++, paramCount++) {
if (type->isArray())
newNode = constructStruct(*p, &elementType, paramCount+1, node->getLine(), true);
else if (op == EOpConstructStruct)
newNode = constructStruct(*p, (memberTypes[paramCount])->type(), paramCount+1, node->getLine(), true);
else
newNode = constructBuiltIn(type, op, *p, node->getLine(), true);
if (newNode) {
*p = newNode;
} }
} }
// Turn the argument list itself into a constructor TIntermTyped* constructor = intermediate.setAggregateOperator(aggrNode, op, line);
TIntermTyped *constructor = intermediate.setAggregateOperator(aggregateArguments, op, line); TIntermTyped* constConstructor = foldConstConstructor(constructor->getAsAggregate(), *type);
TIntermTyped *constConstructor = foldConstConstructor(constructor->getAsAggregate(), *type);
if (constConstructor) if (constConstructor)
{
return constConstructor; return constConstructor;
}
return constructor; return constructor;
} }
@ -1591,6 +1616,102 @@ TIntermTyped* TParseContext::foldConstConstructor(TIntermAggregate* aggrNode, co
return 0; 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. // 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 // If only one component of vector is accessed (v.x or v[0] where v is a contant vector), then a contant node is
@ -1774,7 +1895,7 @@ TIntermAggregate* TParseContext::addInterfaceBlock(const TPublicType& typeQualif
} }
TSymbol* blockNameSymbol = new TInterfaceBlockName(&blockName); TSymbol* blockNameSymbol = new TInterfaceBlockName(&blockName);
if (!symbolTable.declare(blockNameSymbol)) { if (!symbolTable.declare(*blockNameSymbol)) {
error(nameLine, "redefinition", blockName.c_str(), "interface block name"); error(nameLine, "redefinition", blockName.c_str(), "interface block name");
recover(); recover();
} }
@ -1854,7 +1975,7 @@ TIntermAggregate* TParseContext::addInterfaceBlock(const TPublicType& typeQualif
TVariable* fieldVariable = new TVariable(&field->name(), *fieldType); TVariable* fieldVariable = new TVariable(&field->name(), *fieldType);
fieldVariable->setQualifier(typeQualifier.qualifier); fieldVariable->setQualifier(typeQualifier.qualifier);
if (!symbolTable.declare(fieldVariable)) { if (!symbolTable.declare(*fieldVariable)) {
error(field->line(), "redefinition", field->name().c_str(), "interface block member name"); error(field->line(), "redefinition", field->name().c_str(), "interface block member name");
recover(); recover();
} }
@ -1866,7 +1987,7 @@ TIntermAggregate* TParseContext::addInterfaceBlock(const TPublicType& typeQualif
TVariable* instanceTypeDef = new TVariable(instanceName, interfaceBlockType, false); TVariable* instanceTypeDef = new TVariable(instanceName, interfaceBlockType, false);
instanceTypeDef->setQualifier(typeQualifier.qualifier); instanceTypeDef->setQualifier(typeQualifier.qualifier);
if (!symbolTable.declare(instanceTypeDef)) { if (!symbolTable.declare(*instanceTypeDef)) {
error(instanceLine, "redefinition", instanceName->c_str(), "interface block instance name"); error(instanceLine, "redefinition", instanceName->c_str(), "interface block instance name");
recover(); recover();
} }
@ -2446,8 +2567,6 @@ TPublicType TParseContext::addStructure(const TSourceLoc& structLine, const TSou
TStructure* structure = new TStructure(structName, fieldList); TStructure* structure = new TStructure(structName, fieldList);
TType* structureType = new TType(structure); TType* structureType = new TType(structure);
structure->setUniqueId(TSymbolTable::nextUniqueId());
if (!structName->empty()) if (!structName->empty())
{ {
if (reservedErrorCheck(nameLine, *structName)) if (reservedErrorCheck(nameLine, *structName))
@ -2455,7 +2574,7 @@ TPublicType TParseContext::addStructure(const TSourceLoc& structLine, const TSou
recover(); recover();
} }
TVariable* userTypeDef = new TVariable(structName, *structureType, true); TVariable* userTypeDef = new TVariable(structName, *structureType, true);
if (!symbolTable.declare(userTypeDef)) { if (!symbolTable.declare(*userTypeDef)) {
error(nameLine, "redefinition", structName->c_str(), "struct"); error(nameLine, "redefinition", structName->c_str(), "struct");
recover(); recover();
} }

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

@ -1,15 +1,15 @@
// //
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
#ifndef _PARSER_HELPER_INCLUDED_ #ifndef _PARSER_HELPER_INCLUDED_
#define _PARSER_HELPER_INCLUDED_ #define _PARSER_HELPER_INCLUDED_
#include "compiler/translator/Compiler.h"
#include "compiler/translator/Diagnostics.h" #include "compiler/translator/Diagnostics.h"
#include "compiler/translator/DirectiveHandler.h" #include "compiler/translator/DirectiveHandler.h"
#include "compiler/translator/localintermediate.h" #include "compiler/translator/localintermediate.h"
#include "compiler/translator/ShHandle.h"
#include "compiler/translator/SymbolTable.h" #include "compiler/translator/SymbolTable.h"
#include "compiler/preprocessor/Preprocessor.h" #include "compiler/preprocessor/Preprocessor.h"
@ -133,6 +133,8 @@ struct TParseContext {
TFunction *addConstructorFunc(TPublicType publicType); TFunction *addConstructorFunc(TPublicType publicType);
TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, const TSourceLoc&); TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, const TSourceLoc&);
TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type); 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* addConstVectorNode(TVectorFields&, TIntermTyped*, const TSourceLoc&);
TIntermTyped* addConstMatrixNode(int , TIntermTyped*, const TSourceLoc&); TIntermTyped* addConstMatrixNode(int , TIntermTyped*, const TSourceLoc&);
TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, const TSourceLoc& line); TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, const TSourceLoc& line);

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

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

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

@ -11,9 +11,9 @@
#include "GLSLANG/ShaderLang.h" #include "GLSLANG/ShaderLang.h"
#include "compiler/translator/Compiler.h"
#include "compiler/translator/InitializeDll.h" #include "compiler/translator/InitializeDll.h"
#include "compiler/translator/length_limits.h" #include "compiler/translator/length_limits.h"
#include "compiler/translator/ShHandle.h"
#include "compiler/translator/TranslatorHLSL.h" #include "compiler/translator/TranslatorHLSL.h"
#include "compiler/translator/VariablePacker.h" #include "compiler/translator/VariablePacker.h"

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

@ -1,477 +0,0 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// StructureHLSL.cpp:
// Definitions of methods for HLSL translation of GLSL structures.
//
#include "compiler/translator/StructureHLSL.h"
#include "common/utilities.h"
#include "compiler/translator/OutputHLSL.h"
#include "compiler/translator/Types.h"
#include "compiler/translator/util.h"
#include "compiler/translator/UtilsHLSL.h"
namespace sh
{
Std140PaddingHelper::Std140PaddingHelper(const std::map<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();
}
}

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

@ -1,74 +0,0 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// StructureHLSL.h:
// Interfaces of methods for HLSL translation of GLSL structures.
//
#ifndef TRANSLATOR_STRUCTUREHLSL_H_
#define TRANSLATOR_STRUCTUREHLSL_H_
#include "compiler/translator/Common.h"
#include "compiler/translator/intermediate.h"
#include <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 <stdio.h>
#include <algorithm> #include <algorithm>
int TSymbolTable::uniqueIdCounter = 0; int TSymbolTableLevel::uniqueId = 0;
// //
// Functions have buried pointers to delete. // Functions have buried pointers to delete.
@ -38,25 +38,6 @@ TSymbolTableLevel::~TSymbolTableLevel()
delete (*it).second; 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 // 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 // to be related to the provided built-in operation. This is a low
@ -207,7 +188,7 @@ void TSymbolTable::insertBuiltIn(
} }
} }
insert(level, function); insert(level, *function);
} }
TPrecision TSymbolTable::getDefaultPrecision(TBasicType type) TPrecision TSymbolTable::getDefaultPrecision(TBasicType type)

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

@ -185,7 +185,7 @@ class TFunction : public TSymbol
defined(false) defined(false)
{ {
} }
TFunction(const TString *name, const TType &retType, TOperator tOp = EOpNull) TFunction(const TString *name, TType &retType, TOperator tOp = EOpNull)
: TSymbol(name), : TSymbol(name),
returnType(retType), returnType(retType),
mangledName(TFunction::mangleName(*name)), mangledName(TFunction::mangleName(*name)),
@ -288,15 +288,36 @@ class TSymbolTableLevel
} }
~TSymbolTableLevel(); ~TSymbolTableLevel();
bool insert(TSymbol *symbol); bool insert(const TString &name, TSymbol &symbol)
{
symbol.setUniqueId(++uniqueId);
TSymbol *find(const TString &name) const; // returning true means symbol was added to the table
tInsertResult result = level.insert(tLevelPair(name, &symbol));
return result.second;
}
bool insert(TSymbol &symbol)
{
return insert(symbol.getMangledName(), symbol);
}
TSymbol *find(const TString &name) const
{
tLevel::const_iterator it = level.find(name);
if (it == level.end())
return 0;
else
return (*it).second;
}
void relateToOperator(const char *name, TOperator op); void relateToOperator(const char *name, TOperator op);
void relateToExtension(const char *name, const TString &ext); void relateToExtension(const char *name, const TString &ext);
protected: protected:
tLevel level; tLevel level;
static int uniqueId; // for unique identification in code generation
}; };
enum ESymbolLevel enum ESymbolLevel
@ -350,12 +371,12 @@ class TSymbolTable
precisionStack.pop_back(); precisionStack.pop_back();
} }
bool declare(TSymbol *symbol) bool declare(TSymbol &symbol)
{ {
return insert(currentLevel(), symbol); return insert(currentLevel(), symbol);
} }
bool insert(ESymbolLevel level, TSymbol *symbol) bool insert(ESymbolLevel level, TSymbol &symbol)
{ {
return table[level]->insert(symbol); return table[level]->insert(symbol);
} }
@ -365,7 +386,7 @@ class TSymbolTable
TVariable *constant = new TVariable( TVariable *constant = new TVariable(
NewPoolTString(name), TType(EbtInt, EbpUndefined, EvqConst, 1)); NewPoolTString(name), TType(EbtInt, EbpUndefined, EvqConst, 1));
constant->getConstPointer()->setIConst(value); constant->getConstPointer()->setIConst(value);
return insert(level, constant); return insert(level, *constant);
} }
void insertBuiltIn(ESymbolLevel level, TType *rvalue, const char *name, void insertBuiltIn(ESymbolLevel level, TType *rvalue, const char *name,
@ -408,11 +429,6 @@ class TSymbolTable
// for the specified TBasicType // for the specified TBasicType
TPrecision getDefaultPrecision(TBasicType type); TPrecision getDefaultPrecision(TBasicType type);
static int nextUniqueId()
{
return ++uniqueIdCounter;
}
private: private:
ESymbolLevel currentLevel() const ESymbolLevel currentLevel() const
{ {
@ -422,8 +438,6 @@ class TSymbolTable
std::vector<TSymbolTableLevel *> table; std::vector<TSymbolTableLevel *> table;
typedef TMap<TBasicType, TPrecision> PrecisionStackLevel; typedef TMap<TBasicType, TPrecision> PrecisionStackLevel;
std::vector< PrecisionStackLevel *> precisionStack; std::vector< PrecisionStackLevel *> precisionStack;
static int uniqueIdCounter;
}; };
#endif // _SYMBOL_TABLE_INCLUDED_ #endif // _SYMBOL_TABLE_INCLUDED_

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

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

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

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

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

@ -7,7 +7,7 @@
#ifndef COMPILER_TRANSLATORHLSL_H_ #ifndef COMPILER_TRANSLATORHLSL_H_
#define COMPILER_TRANSLATORHLSL_H_ #define COMPILER_TRANSLATORHLSL_H_
#include "compiler/translator/Compiler.h" #include "compiler/translator/ShHandle.h"
#include "common/shadervars.h" #include "common/shadervars.h"
class TranslatorHLSL : public TCompiler { class TranslatorHLSL : public TCompiler {
@ -15,20 +15,20 @@ public:
TranslatorHLSL(ShShaderType type, ShShaderSpec spec, ShShaderOutput output); TranslatorHLSL(ShShaderType type, ShShaderSpec spec, ShShaderOutput output);
virtual TranslatorHLSL *getAsTranslatorHLSL() { return this; } virtual TranslatorHLSL *getAsTranslatorHLSL() { return this; }
const std::vector<sh::Uniform> &getUniforms() { return mActiveUniforms; } const std::vector<gl::Uniform> &getUniforms() { return mActiveUniforms; }
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return mActiveInterfaceBlocks; } const std::vector<gl::InterfaceBlock> &getInterfaceBlocks() const { return mActiveInterfaceBlocks; }
const std::vector<sh::Attribute> &getOutputVariables() { return mActiveOutputVariables; } const std::vector<gl::Attribute> &getOutputVariables() { return mActiveOutputVariables; }
const std::vector<sh::Attribute> &getAttributes() { return mActiveAttributes; } const std::vector<gl::Attribute> &getAttributes() { return mActiveAttributes; }
const std::vector<sh::Varying> &getVaryings() { return mActiveVaryings; } const std::vector<gl::Varying> &getVaryings() { return mActiveVaryings; }
protected: protected:
virtual void translate(TIntermNode* root); virtual void translate(TIntermNode* root);
std::vector<sh::Uniform> mActiveUniforms; std::vector<gl::Uniform> mActiveUniforms;
std::vector<sh::InterfaceBlock> mActiveInterfaceBlocks; std::vector<gl::InterfaceBlock> mActiveInterfaceBlocks;
std::vector<sh::Attribute> mActiveOutputVariables; std::vector<gl::Attribute> mActiveOutputVariables;
std::vector<sh::Attribute> mActiveAttributes; std::vector<gl::Attribute> mActiveAttributes;
std::vector<sh::Varying> mActiveVaryings; std::vector<gl::Varying> mActiveVaryings;
}; };
#endif // COMPILER_TRANSLATORHLSL_H_ #endif // COMPILER_TRANSLATORHLSL_H_

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

@ -22,9 +22,57 @@ TType::TType(const TPublicType &p)
structure = p.userDef->getStruct(); 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 bool TStructure::equals(const TStructure &other) const
{ {
return (uniqueId() == other.uniqueId()); return TFieldListCollection::equals(other);
}
bool TInterfaceBlock::equals(const TInterfaceBlock &other) const
{
if (!TFieldListCollection::equals(other))
return false;
// TODO(zmo): do we need to consider mBlockStorage and mMatrixPacking?
return mArraySize == other.mArraySize;
} }
// //

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

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

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

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

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

@ -1,391 +0,0 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// UniformHLSL.cpp:
// Methods for GLSL to HLSL translation for uniforms and interface blocks.
//
#include "OutputHLSL.h"
#include "common/blocklayout.h"
#include "common/utilities.h"
#include "compiler/translator/UniformHLSL.h"
#include "compiler/translator/StructureHLSL.h"
#include "compiler/translator/util.h"
#include "compiler/translator/UtilsHLSL.h"
namespace sh
{
// Use the same layout for packed and shared
static void SetBlockLayout(InterfaceBlock *interfaceBlock, BlockLayoutType newLayout)
{
interfaceBlock->layout = newLayout;
interfaceBlock->blockInfo.clear();
switch (newLayout)
{
case BLOCKLAYOUT_SHARED:
case BLOCKLAYOUT_PACKED:
{
HLSLBlockEncoder hlslEncoder(&interfaceBlock->blockInfo, HLSLBlockEncoder::ENCODE_PACKED);
hlslEncoder.encodeInterfaceBlockFields(interfaceBlock->fields);
interfaceBlock->dataSize = hlslEncoder.getBlockSize();
}
break;
case BLOCKLAYOUT_STANDARD:
{
Std140BlockEncoder stdEncoder(&interfaceBlock->blockInfo);
stdEncoder.encodeInterfaceBlockFields(interfaceBlock->fields);
interfaceBlock->dataSize = stdEncoder.getBlockSize();
}
break;
default:
UNREACHABLE();
break;
}
}
static BlockLayoutType ConvertBlockLayoutType(TLayoutBlockStorage blockStorage)
{
switch (blockStorage)
{
case EbsPacked: return BLOCKLAYOUT_PACKED;
case EbsShared: return BLOCKLAYOUT_SHARED;
case EbsStd140: return BLOCKLAYOUT_STANDARD;
default: UNREACHABLE(); return BLOCKLAYOUT_SHARED;
}
}
static const char *UniformRegisterPrefix(const TType &type)
{
if (IsSampler(type.getBasicType()))
{
return "s";
}
else
{
return "c";
}
}
static TString InterfaceBlockFieldName(const TInterfaceBlock &interfaceBlock, const TField &field)
{
if (interfaceBlock.hasInstanceName())
{
return interfaceBlock.name() + "." + field.name();
}
else
{
return field.name();
}
}
static TString InterfaceBlockFieldTypeString(const TField &field, TLayoutBlockStorage blockStorage)
{
const TType &fieldType = *field.type();
const TLayoutMatrixPacking matrixPacking = fieldType.getLayoutQualifier().matrixPacking;
ASSERT(matrixPacking != EmpUnspecified);
TStructure *structure = fieldType.getStruct();
if (fieldType.isMatrix())
{
// Use HLSL row-major packing for GLSL column-major matrices
const TString &matrixPackString = (matrixPacking == EmpRowMajor ? "column_major" : "row_major");
return matrixPackString + " " + TypeString(fieldType);
}
else if (structure)
{
// Use HLSL row-major packing for GLSL column-major matrices
return QualifiedStructNameString(*structure, matrixPacking == EmpColumnMajor,
blockStorage == EbsStd140);
}
else
{
return TypeString(fieldType);
}
}
static TString InterfaceBlockStructName(const TInterfaceBlock &interfaceBlock)
{
return DecoratePrivate(interfaceBlock.name()) + "_type";
}
UniformHLSL::UniformHLSL(StructureHLSL *structureHLSL, ShShaderOutput outputType)
: mUniformRegister(0),
mInterfaceBlockRegister(0),
mSamplerRegister(0),
mStructureHLSL(structureHLSL),
mOutputType(outputType)
{}
void UniformHLSL::reserveUniformRegisters(unsigned int registerCount)
{
mUniformRegister = registerCount;
}
void UniformHLSL::reserveInterfaceBlockRegisters(unsigned int registerCount)
{
mInterfaceBlockRegister = registerCount;
}
int UniformHLSL::declareUniformAndAssignRegister(const TType &type, const TString &name)
{
int registerIndex = (IsSampler(type.getBasicType()) ? mSamplerRegister : mUniformRegister);
const Uniform &uniform = declareUniformToList(type, name, registerIndex, &mActiveUniforms);
if (IsSampler(type.getBasicType()))
{
mSamplerRegister += HLSLVariableRegisterCount(uniform, mOutputType);
}
else
{
mUniformRegister += HLSLVariableRegisterCount(uniform, mOutputType);
}
return registerIndex;
}
Uniform UniformHLSL::declareUniformToList(const TType &type, const TString &name, int registerIndex, std::vector<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);
}
}
}

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

@ -1,58 +0,0 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// UniformHLSL.h:
// Methods for GLSL to HLSL translation for uniforms and interface blocks.
//
#ifndef TRANSLATOR_UNIFORMHLSL_H_
#define TRANSLATOR_UNIFORMHLSL_H_
#include "common/shadervars.h"
#include "compiler/translator/Types.h"
namespace sh
{
class StructureHLSL;
class UniformHLSL
{
public:
UniformHLSL(StructureHLSL *structureHLSL, ShShaderOutput outputType);
void reserveUniformRegisters(unsigned int registerCount);
void reserveInterfaceBlockRegisters(unsigned int registerCount);
TString uniformsHeader(ShShaderOutput outputType, const ReferencedSymbols &referencedUniforms);
TString interfaceBlocksHeader(const ReferencedSymbols &referencedInterfaceBlocks);
// Used for direct index references
static TString interfaceBlockInstanceString(const TInterfaceBlock& interfaceBlock, unsigned int arrayIndex);
const std::vector<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_

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

@ -1,243 +0,0 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// UtilsHLSL.cpp:
// Utility methods for GLSL to HLSL translation.
//
#include "compiler/translator/UtilsHLSL.h"
#include "compiler/translator/StructureHLSL.h"
#include "compiler/translator/SymbolTable.h"
namespace sh
{
TString SamplerString(const TType &type)
{
if (IsShadowSampler(type.getBasicType()))
{
return "SamplerComparisonState";
}
else
{
return "SamplerState";
}
}
TString TextureString(const TType &type)
{
switch (type.getBasicType())
{
case EbtSampler2D: return "Texture2D";
case EbtSamplerCube: return "TextureCube";
case EbtSamplerExternalOES: return "Texture2D";
case EbtSampler2DArray: return "Texture2DArray";
case EbtSampler3D: return "Texture3D";
case EbtISampler2D: return "Texture2D<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 "";
}
}

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

@ -1,37 +0,0 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// UtilsHLSL.h:
// Utility methods for GLSL to HLSL translation.
//
#ifndef TRANSLATOR_UTILSHLSL_H_
#define TRANSLATOR_UTILSHLSL_H_
#include <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,6 +6,7 @@
#include "compiler/translator/VariablePacker.h" #include "compiler/translator/VariablePacker.h"
#include <algorithm> #include <algorithm>
#include "compiler/translator/ShHandle.h"
namespace { namespace {
int GetSortOrder(ShDataType type) int GetSortOrder(ShDataType type)

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

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

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

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

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

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

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

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

@ -237,7 +237,7 @@ variable_identifier
{ {
TType type(EbtFloat, EbpUndefined); TType type(EbtFloat, EbpUndefined);
TVariable *fakeVariable = new TVariable($1.string, type); TVariable *fakeVariable = new TVariable($1.string, type);
context->symbolTable.declare(fakeVariable); context->symbolTable.declare(*fakeVariable);
variable = fakeVariable; variable = fakeVariable;
} }
@ -887,8 +887,7 @@ function_prototype
else else
{ {
// Insert the unmangled name to detect potential future redefinition as a variable. // Insert the unmangled name to detect potential future redefinition as a variable.
TFunction *function = new TFunction(NewPoolTString($1->getName().c_str()), $1->getReturnType()); context->symbolTable.getOuterLevel()->insert($1->getName(), *$1);
context->symbolTable.getOuterLevel()->insert(function);
} }
// //
@ -900,7 +899,7 @@ function_prototype
// We're at the inner scope level of the function's arguments and body statement. // We're at the inner scope level of the function's arguments and body statement.
// Add the function prototype to the surrounding scope instead. // Add the function prototype to the surrounding scope instead.
context->symbolTable.getOuterLevel()->insert($$.function); context->symbolTable.getOuterLevel()->insert(*$$.function);
} }
; ;
@ -1256,7 +1255,7 @@ type_specifier
$$ = $2; $$ = $2;
$$.precision = $1; $$.precision = $1;
if (!SupportsPrecision($2.type)) { if (!SupportsPrecision($2.type) {
context->error(@1, "illegal type for precision qualifier", getBasicString($2.type)); context->error(@1, "illegal type for precision qualifier", getBasicString($2.type));
context->recover(); context->recover();
} }
@ -1900,7 +1899,7 @@ function_definition
// //
// Insert the parameters with name in the symbol table. // 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->error(@1, "redefinition", variable->getName().c_str());
context->recover(); context->recover();
delete variable; delete variable;

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

@ -807,19 +807,19 @@ static const yytype_uint16 yyrline[] =
1064, 1068, 1072, 1079, 1083, 1087, 1094, 1098, 1102, 1123, 1064, 1068, 1072, 1079, 1083, 1087, 1094, 1098, 1102, 1123,
1132, 1138, 1141, 1147, 1153, 1160, 1169, 1178, 1186, 1189, 1132, 1138, 1141, 1147, 1153, 1160, 1169, 1178, 1186, 1189,
1196, 1200, 1207, 1210, 1214, 1218, 1227, 1236, 1244, 1254, 1196, 1200, 1207, 1210, 1214, 1218, 1227, 1236, 1244, 1254,
1266, 1269, 1272, 1278, 1285, 1288, 1294, 1297, 1300, 1306, 1261, 1264, 1267, 1273, 1280, 1283, 1289, 1292, 1295, 1301,
1309, 1324, 1328, 1332, 1336, 1340, 1344, 1349, 1354, 1359, 1304, 1319, 1323, 1327, 1331, 1335, 1339, 1344, 1349, 1354,
1364, 1369, 1374, 1379, 1384, 1389, 1394, 1399, 1404, 1409, 1359, 1364, 1369, 1374, 1379, 1384, 1389, 1394, 1399, 1404,
1414, 1419, 1424, 1429, 1434, 1439, 1444, 1449, 1453, 1457, 1409, 1414, 1419, 1424, 1429, 1434, 1439, 1444, 1448, 1452,
1461, 1465, 1469, 1473, 1477, 1481, 1485, 1489, 1493, 1497, 1456, 1460, 1464, 1468, 1472, 1476, 1480, 1484, 1488, 1492,
1501, 1505, 1509, 1517, 1525, 1529, 1542, 1542, 1545, 1545, 1496, 1500, 1504, 1512, 1520, 1524, 1537, 1537, 1540, 1540,
1551, 1554, 1570, 1573, 1582, 1586, 1592, 1599, 1614, 1618, 1546, 1549, 1565, 1568, 1577, 1581, 1587, 1594, 1609, 1613,
1622, 1623, 1629, 1630, 1631, 1632, 1633, 1637, 1638, 1638, 1617, 1618, 1624, 1625, 1626, 1627, 1628, 1632, 1633, 1633,
1638, 1648, 1649, 1653, 1653, 1654, 1654, 1659, 1662, 1672, 1633, 1643, 1644, 1648, 1648, 1649, 1649, 1654, 1657, 1667,
1675, 1681, 1682, 1686, 1694, 1698, 1708, 1713, 1730, 1730, 1670, 1676, 1677, 1681, 1689, 1693, 1703, 1708, 1725, 1725,
1735, 1735, 1742, 1742, 1750, 1753, 1759, 1762, 1768, 1772, 1730, 1730, 1737, 1737, 1745, 1748, 1754, 1757, 1763, 1767,
1779, 1786, 1793, 1800, 1811, 1820, 1824, 1831, 1834, 1840, 1774, 1781, 1788, 1795, 1806, 1815, 1819, 1826, 1829, 1835,
1840 1835
}; };
#endif #endif
@ -2575,7 +2575,7 @@ yyreduce:
{ {
TType type(EbtFloat, EbpUndefined); TType type(EbtFloat, EbpUndefined);
TVariable *fakeVariable = new TVariable((yyvsp[(1) - (1)].lex).string, type); TVariable *fakeVariable = new TVariable((yyvsp[(1) - (1)].lex).string, type);
context->symbolTable.declare(fakeVariable); context->symbolTable.declare(*fakeVariable);
variable = fakeVariable; variable = fakeVariable;
} }
@ -3436,8 +3436,7 @@ yyreduce:
else else
{ {
// Insert the unmangled name to detect potential future redefinition as a variable. // Insert the unmangled name to detect potential future redefinition as a variable.
TFunction *function = new TFunction(NewPoolTString((yyvsp[(1) - (2)].interm.function)->getName().c_str()), (yyvsp[(1) - (2)].interm.function)->getReturnType()); context->symbolTable.getOuterLevel()->insert((yyvsp[(1) - (2)].interm.function)->getName(), *(yyvsp[(1) - (2)].interm.function));
context->symbolTable.getOuterLevel()->insert(function);
} }
// //
@ -3449,7 +3448,7 @@ yyreduce:
// We're at the inner scope level of the function's arguments and body statement. // We're at the inner scope level of the function's arguments and body statement.
// Add the function prototype to the surrounding scope instead. // Add the function prototype to the surrounding scope instead.
context->symbolTable.getOuterLevel()->insert((yyval.interm).function); context->symbolTable.getOuterLevel()->insert(*(yyval.interm).function);
} }
break; break;
@ -3940,7 +3939,7 @@ yyreduce:
(yyval.interm.type).precision = (yyvsp[(1) - (2)].interm.precision); (yyval.interm.type).precision = (yyvsp[(1) - (2)].interm.precision);
if (!SupportsPrecision((yyvsp[(2) - (2)].interm.type).type)) { if (!SupportsPrecision((yyvsp[(2) - (2)].interm.type).type)) {
context->error((yylsp[(1) - (2)]), "illegal type for precision qualifier", getBasicString((yyvsp[(2) - (2)].interm.type).type)); context->error((yylsp[(1) - (1)]), "illegal type for precision qualifier", getBasicString((yyvsp[(2) - (2)].interm.type).type));
context->recover(); context->recover();
} }
} }
@ -4968,7 +4967,7 @@ yyreduce:
// //
// Insert the parameters with name in the symbol table. // 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->error((yylsp[(1) - (1)]), "redefinition", variable->getName().c_str());
context->recover(); context->recover();
delete variable; delete variable;

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

@ -1,5 +1,5 @@
// //
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
@ -153,6 +153,18 @@ bool TOutputTraverser::visitUnary(Visit visit, TIntermUnary* node)
case EOpPreIncrement: out << "Pre-Increment"; break; case EOpPreIncrement: out << "Pre-Increment"; break;
case EOpPreDecrement: out << "Pre-Decrement"; 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 EOpRadians: out << "radians"; break;
case EOpDegrees: out << "degrees"; break; case EOpDegrees: out << "degrees"; break;
case EOpSin: out << "sine"; break; case EOpSin: out << "sine"; break;

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

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

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

@ -1,5 +1,5 @@
// //
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
@ -24,6 +24,7 @@ public:
TIntermediate(TInfoSink& i) : infoSink(i) { } TIntermediate(TInfoSink& i) : infoSink(i) { }
TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TSourceLoc&); 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* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
TIntermTyped* addAssign(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&); TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, const TSourceLoc&);
@ -35,6 +36,7 @@ public:
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc&); TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc&);
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, const TSourceLoc&); TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
TIntermConstantUnion* addConstantUnion(ConstantUnion*, const TType&, const TSourceLoc&); TIntermConstantUnion* addConstantUnion(ConstantUnion*, const TType&, const TSourceLoc&);
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
bool parseConstTree(const TSourceLoc&, TIntermNode*, ConstantUnion*, TOperator, TType, bool singleConstantParam = false); bool parseConstTree(const TSourceLoc&, TIntermNode*, ConstantUnion*, TOperator, TType, bool singleConstantParam = false);
TIntermNode* addLoop(TLoopType, TIntermNode*, TIntermTyped*, TIntermTyped*, TIntermNode*, const TSourceLoc&); TIntermNode* addLoop(TLoopType, TIntermNode*, TIntermTyped*, TIntermTyped*, TIntermNode*, const TSourceLoc&);
TIntermBranch* addBranch(TOperator, const TSourceLoc&); TIntermBranch* addBranch(TOperator, const TSourceLoc&);

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

@ -0,0 +1,66 @@
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#ifndef __OSINCLUDE_H
#define __OSINCLUDE_H
//
// This file contains contains os-specific datatypes and
// declares any os-specific functions.
//
#if defined(_WIN32) || defined(_WIN64)
#define ANGLE_OS_WIN
#elif defined(__APPLE__) || defined(__linux__) || \
defined(__FreeBSD__) || defined(__OpenBSD__) || \
defined(__NetBSD__) || defined(__DragonFly__) || \
defined(__sun) || defined(ANDROID) || \
defined(__GLIBC__) || defined(__GNU__) || \
defined(__QNX__)
#define ANGLE_OS_POSIX
#else
#error Unsupported platform.
#endif
#if defined(ANGLE_OS_WIN)
#define STRICT
#define VC_EXTRALEAN 1
#include <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

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

@ -0,0 +1,64 @@
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
//
// This file contains the posix specific functions
//
#include "compiler/translator/osinclude.h"
#if !defined(ANGLE_OS_POSIX)
#error Trying to build a posix specific file in a non-posix build.
#endif
//
// Thread Local Storage Operations
//
OS_TLSIndex OS_AllocTLSIndex()
{
pthread_key_t pPoolIndex;
//
// Create global pool key.
//
if ((pthread_key_create(&pPoolIndex, NULL)) != 0) {
assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
return false;
}
else {
return pPoolIndex;
}
}
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
{
if (nIndex == OS_INVALID_TLS_INDEX) {
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
return false;
}
if (pthread_setspecific(nIndex, lpvValue) == 0)
return true;
else
return false;
}
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
{
if (nIndex == OS_INVALID_TLS_INDEX) {
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
return false;
}
//
// Delete the global pool key.
//
if (pthread_key_delete(nIndex) == 0)
return true;
else
return false;
}

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

@ -0,0 +1,57 @@
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "compiler/translator/osinclude.h"
//
// This file contains contains the window's specific functions
//
#if !defined(ANGLE_OS_WIN)
#error Trying to build a windows specific file in a non windows build.
#endif
//
// Thread Local Storage Operations
//
OS_TLSIndex OS_AllocTLSIndex()
{
DWORD dwIndex = TlsAlloc();
if (dwIndex == TLS_OUT_OF_INDEXES) {
assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
return OS_INVALID_TLS_INDEX;
}
return dwIndex;
}
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
{
if (nIndex == OS_INVALID_TLS_INDEX) {
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
return false;
}
if (TlsSetValue(nIndex, lpvValue))
return true;
else
return false;
}
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
{
if (nIndex == OS_INVALID_TLS_INDEX) {
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
return false;
}
if (TlsFree(nIndex))
return true;
else
return false;
}

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

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

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

@ -9,7 +9,6 @@
#include <limits> #include <limits>
#include "compiler/preprocessor/numeric_lex.h" #include "compiler/preprocessor/numeric_lex.h"
#include "common/shadervars.h"
bool atof_clamp(const char *str, float *value) bool atof_clamp(const char *str, float *value)
{ {
@ -27,254 +26,3 @@ bool atoi_clamp(const char *str, int *value)
return success; 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,10 +7,6 @@
#ifndef COMPILER_UTIL_H #ifndef COMPILER_UTIL_H
#define 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 // atof_clamp is like atof but
// 1. it forces C locale, i.e. forcing '.' as decimal point. // 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. // 2. it clamps the value to -FLT_MAX or FLT_MAX if overflow happens.
@ -21,17 +17,4 @@ extern bool atof_clamp(const char *str, float *value);
// Return false if overflow happens. // Return false if overflow happens.
extern bool atoi_clamp(const char *str, int *value); 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 #endif // COMPILER_UTIL_H

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

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

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

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

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

@ -35,8 +35,6 @@ class Display
static egl::Display *getDisplay(EGLNativeDisplayType displayId); 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 getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig);
bool getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value); bool getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value);
@ -84,12 +82,9 @@ class Display
rx::Renderer *mRenderer; rx::Renderer *mRenderer;
static std::string generateClientExtensionString(); void initExtensionString();
void initDisplayExtensionString();
std::string mDisplayExtensionString;
void initVendorString(); void initVendorString();
std::string mExtensionString;
std::string mVendorString; std::string mVendorString;
}; };
} }

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

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

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

@ -1,36 +1,36 @@
LIBRARY libEGL LIBRARY libEGL
EXPORTS EXPORTS
eglBindAPI @14 eglBindAPI @14
eglBindTexImage @20 eglBindTexImage @20
eglChooseConfig @7 eglChooseConfig @7
eglCopyBuffers @33 eglCopyBuffers @33
eglCreateContext @23 eglCreateContext @23
eglCreatePbufferFromClientBuffer @18 eglCreatePbufferFromClientBuffer @18
eglCreatePbufferSurface @10 eglCreatePbufferSurface @10
eglCreatePixmapSurface @11 eglCreatePixmapSurface @11
eglCreateWindowSurface @9 eglCreateWindowSurface @9
eglDestroyContext @24 eglDestroyContext @24
eglDestroySurface @12 eglDestroySurface @12
eglGetConfigAttrib @8 eglGetConfigAttrib @8
eglGetConfigs @6 eglGetConfigs @6
eglGetCurrentContext @26 eglGetCurrentContext @26
eglGetCurrentDisplay @28 eglGetCurrentDisplay @28
eglGetCurrentSurface @27 eglGetCurrentSurface @27
eglGetDisplay @2 eglGetDisplay @2
eglGetError @1 eglGetError @1
eglGetProcAddress @34 eglGetProcAddress @34
eglInitialize @3 eglInitialize @3
eglMakeCurrent @25 eglMakeCurrent @25
eglQueryAPI @15 eglQueryAPI @15
eglQueryContext @29 eglQueryContext @29
eglQueryString @5 eglQueryString @5
eglQuerySurface @13 eglQuerySurface @13
eglReleaseTexImage @21 eglReleaseTexImage @21
eglReleaseThread @17 eglReleaseThread @17
eglSurfaceAttrib @19 eglSurfaceAttrib @19
eglSwapBuffers @32 eglSwapBuffers @32
eglSwapInterval @22 eglSwapInterval @22
eglTerminate @4 eglTerminate @4
eglWaitClient @16 eglWaitClient @16
eglWaitGL @30 eglWaitGL @30
eglWaitNative @31 eglWaitNative @31

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

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

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

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

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

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

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

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

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

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

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

@ -1,346 +0,0 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "libGLESv2/Caps.h"
#include "common/debug.h"
#include "common/angleutils.h"
#include "angle_gl.h"
#include <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()
{
}
}

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

@ -1,203 +0,0 @@
#ifndef LIBGLESV2_CAPS_H
#define LIBGLESV2_CAPS_H
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "angle_gl.h"
#include <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,14 +16,13 @@
#include "libGLESv2/Buffer.h" #include "libGLESv2/Buffer.h"
#include "libGLESv2/Fence.h" #include "libGLESv2/Fence.h"
#include "libGLESv2/Framebuffer.h" #include "libGLESv2/Framebuffer.h"
#include "libGLESv2/FramebufferAttachment.h"
#include "libGLESv2/Renderbuffer.h" #include "libGLESv2/Renderbuffer.h"
#include "libGLESv2/Program.h" #include "libGLESv2/Program.h"
#include "libGLESv2/ProgramBinary.h" #include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/Query.h" #include "libGLESv2/Query.h"
#include "libGLESv2/Texture.h" #include "libGLESv2/Texture.h"
#include "libGLESv2/ResourceManager.h" #include "libGLESv2/ResourceManager.h"
#include "libGLESv2/renderer/d3d/IndexDataManager.h" #include "libGLESv2/renderer/IndexDataManager.h"
#include "libGLESv2/renderer/RenderTarget.h" #include "libGLESv2/renderer/RenderTarget.h"
#include "libGLESv2/renderer/Renderer.h" #include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/VertexArray.h" #include "libGLESv2/VertexArray.h"
@ -38,6 +37,15 @@
namespace gl 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) Context::Context(int clientVersion, const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess) : mRenderer(renderer)
{ {
@ -195,6 +203,7 @@ Context::Context(int clientVersion, const gl::Context *shareContext, rx::Rendere
mState.currentProgram = 0; mState.currentProgram = 0;
mCurrentProgramBinary.set(NULL); mCurrentProgramBinary.set(NULL);
mCombinedExtensionsString = NULL;
mRendererString = NULL; mRendererString = NULL;
mInvalidEnum = false; mInvalidEnum = false;
@ -209,6 +218,12 @@ Context::Context(int clientVersion, const gl::Context *shareContext, rx::Rendere
mResetStrategy = (notifyResets ? GL_LOSE_CONTEXT_ON_RESET_EXT : GL_NO_RESET_NOTIFICATION_EXT); mResetStrategy = (notifyResets ? GL_LOSE_CONTEXT_ON_RESET_EXT : GL_NO_RESET_NOTIFICATION_EXT);
mRobustAccess = robustAccess; mRobustAccess = robustAccess;
mSupportsBGRATextures = false;
mSupportsDXT1Textures = false;
mSupportsDXT3Textures = false;
mSupportsDXT5Textures = false;
mSupportsEventQueries = false;
mSupportsOcclusionQueries = false;
mNumCompressedTextureFormats = 0; mNumCompressedTextureFormats = 0;
} }
@ -313,6 +328,8 @@ void Context::makeCurrent(egl::Surface *surface)
mMajorShaderModel = mRenderer->getMajorShaderModel(); mMajorShaderModel = mRenderer->getMajorShaderModel();
mMaximumPointSize = mRenderer->getMaxPointSize(); mMaximumPointSize = mRenderer->getMaxPointSize();
mSupportsVertexTexture = mRenderer->getVertexTextureSupport(); mSupportsVertexTexture = mRenderer->getVertexTextureSupport();
mSupportsNonPower2Texture = mRenderer->getNonPower2TextureSupport();
mSupportsInstancing = mRenderer->getInstancingSupport();
mMaxViewportDimension = mRenderer->getMaxViewportDimension(); mMaxViewportDimension = mRenderer->getMaxViewportDimension();
mMax2DTextureDimension = std::min(std::min(mRenderer->getMaxTextureWidth(), mRenderer->getMaxTextureHeight()), mMax2DTextureDimension = std::min(std::min(mRenderer->getMaxTextureWidth(), mRenderer->getMaxTextureHeight()),
@ -326,29 +343,50 @@ void Context::makeCurrent(egl::Surface *surface)
mMaxCubeTextureLevel = log2(mMaxCubeTextureDimension) + 1; mMaxCubeTextureLevel = log2(mMaxCubeTextureDimension) + 1;
mMax3DTextureLevel = log2(mMax3DTextureDimension) + 1; mMax3DTextureLevel = log2(mMax3DTextureDimension) + 1;
mMax2DArrayTextureLevel = log2(mMax2DTextureDimension) + 1; mMax2DArrayTextureLevel = log2(mMax2DTextureDimension) + 1;
mMaxTextureAnisotropy = mRenderer->getTextureMaxAnisotropy();
TRACE("Max2DTextureDimension=%d, MaxCubeTextureDimension=%d, Max3DTextureDimension=%d, Max2DArrayTextureLayers = %d, " TRACE("Max2DTextureDimension=%d, MaxCubeTextureDimension=%d, Max3DTextureDimension=%d, Max2DArrayTextureLayers = %d, "
"Max2DTextureLevel=%d, MaxCubeTextureLevel=%d, Max3DTextureLevel=%d, Max2DArrayTextureLevel=%d, " "Max2DTextureLevel=%d, MaxCubeTextureLevel=%d, Max3DTextureLevel=%d, Max2DArrayTextureLevel=%d, "
"MaxRenderbufferDimension=%d", "MaxRenderbufferDimension=%d, MaxTextureAnisotropy=%f",
mMax2DTextureDimension, mMaxCubeTextureDimension, mMax3DTextureDimension, mMax2DArrayTextureLayers, mMax2DTextureDimension, mMaxCubeTextureDimension, mMax3DTextureDimension, mMax2DArrayTextureLayers,
mMax2DTextureLevel, mMaxCubeTextureLevel, mMax3DTextureLevel, mMax2DArrayTextureLevel, mMax2DTextureLevel, mMaxCubeTextureLevel, mMax3DTextureLevel, mMax2DArrayTextureLevel,
mMaxRenderbufferDimension); mMaxRenderbufferDimension, mMaxTextureAnisotropy);
mSupportsEventQueries = mRenderer->getEventQuerySupport();
mSupportsOcclusionQueries = mRenderer->getOcclusionQuerySupport();
mSupportsBGRATextures = mRenderer->getBGRATextureSupport();
mSupportsDXT1Textures = mRenderer->getDXT1TextureSupport();
mSupportsDXT3Textures = mRenderer->getDXT3TextureSupport();
mSupportsDXT5Textures = mRenderer->getDXT5TextureSupport();
mSupportsFloat32Textures = mRenderer->getFloat32TextureSupport();
mSupportsFloat32LinearFilter = mRenderer->getFloat32TextureFilteringSupport();
mSupportsFloat32RenderableTextures = mRenderer->getFloat32TextureRenderingSupport();
mSupportsFloat16Textures = mRenderer->getFloat16TextureSupport();
mSupportsFloat16LinearFilter = mRenderer->getFloat16TextureFilteringSupport();
mSupportsFloat16RenderableTextures = mRenderer->getFloat16TextureRenderingSupport();
mSupportsLuminanceTextures = mRenderer->getLuminanceTextureSupport();
mSupportsLuminanceAlphaTextures = mRenderer->getLuminanceAlphaTextureSupport();
mSupportsRGTextures = mRenderer->getRGTextureSupport();
mSupportsDepthTextures = mRenderer->getDepthTextureSupport();
mSupportsTextureFilterAnisotropy = mRenderer->getTextureFilterAnisotropySupport();
mSupports32bitIndices = mRenderer->get32BitIndexSupport();
mSupportsPBOs = mRenderer->getPBOSupport();
mNumCompressedTextureFormats = 0; mNumCompressedTextureFormats = 0;
if (getCaps().extensions.textureCompressionDXT1) if (supportsDXT1Textures())
{ {
mNumCompressedTextureFormats += 2; mNumCompressedTextureFormats += 2;
} }
if (getCaps().extensions.textureCompressionDXT3) if (supportsDXT3Textures())
{ {
mNumCompressedTextureFormats += 1; mNumCompressedTextureFormats += 1;
} }
if (getCaps().extensions.textureCompressionDXT5) if (supportsDXT5Textures())
{ {
mNumCompressedTextureFormats += 1; mNumCompressedTextureFormats += 1;
} }
initExtensionString();
initRendererString(); initRendererString();
initExtensionStrings();
mState.viewport.x = 0; mState.viewport.x = 0;
mState.viewport.y = 0; mState.viewport.y = 0;
@ -576,21 +614,6 @@ void Context::setStencilBackOperations(GLenum stencilBackFail, GLenum stencilBac
mState.depthStencil.stencilBackPassDepthPass = stencilBackPassDepthPass; 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) void Context::setPolygonOffsetFill(bool enabled)
{ {
mState.rasterizer.polygonOffsetFill = enabled; mState.rasterizer.polygonOffsetFill = enabled;
@ -802,7 +825,7 @@ void Context::setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer,
const void *Context::getVertexAttribPointer(unsigned int attribNum) const const void *Context::getVertexAttribPointer(unsigned int attribNum) const
{ {
return getCurrentVertexArray()->getVertexAttribute(attribNum).pointer; return getCurrentVertexArray()->getVertexAttribute(attribNum).mPointer;
} }
void Context::setPackAlignment(GLint alignment) void Context::setPackAlignment(GLint alignment)
@ -889,7 +912,7 @@ GLuint Context::createVertexArray()
// Although the spec states VAO state is not initialized until the object is bound, // 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, // 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. // since it's not currently possible to access the state until the object is bound.
mVertexArrayMap[handle] = new VertexArray(mRenderer->createVertexArray(), handle, MAX_VERTEX_ATTRIBS); mVertexArrayMap[handle] = new VertexArray(mRenderer, handle);
return handle; return handle;
} }
@ -1134,11 +1157,6 @@ Framebuffer *Context::getDrawFramebuffer()
return mBoundDrawFramebuffer; return mBoundDrawFramebuffer;
} }
const Framebuffer *Context::getDrawFramebuffer() const
{
return mBoundDrawFramebuffer;
}
VertexArray *Context::getCurrentVertexArray() const VertexArray *Context::getCurrentVertexArray() const
{ {
VertexArray *vao = getVertexArray(mState.vertexArray); VertexArray *vao = getVertexArray(mState.vertexArray);
@ -1231,7 +1249,7 @@ void Context::bindVertexArray(GLuint vertexArray)
{ {
if (!getVertexArray(vertexArray)) if (!getVertexArray(vertexArray))
{ {
mVertexArrayMap[vertexArray] = new VertexArray(mRenderer->createVertexArray(), vertexArray, MAX_VERTEX_ATTRIBS); mVertexArrayMap[vertexArray] = new VertexArray(mRenderer, vertexArray);
} }
mState.vertexArray = vertexArray; mState.vertexArray = vertexArray;
@ -1394,23 +1412,25 @@ void Context::setFramebufferZero(Framebuffer *buffer)
void Context::setRenderbufferStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples) void Context::setRenderbufferStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples)
{ {
const TextureCaps &formatCaps = getCaps().textureCaps.get(internalformat); const bool color = gl::IsColorRenderingSupported(internalformat, this);
const bool depth = gl::IsDepthRenderingSupported(internalformat, this);
const bool stencil = gl::IsStencilRenderingSupported(internalformat, this);
RenderbufferStorage *renderbuffer = NULL; RenderbufferStorage *renderbuffer = NULL;
if (formatCaps.colorRendering) if (color)
{ {
renderbuffer = new gl::Colorbuffer(mRenderer,width, height, internalformat, samples); renderbuffer = new gl::Colorbuffer(mRenderer,width, height, internalformat, samples);
} }
else if (formatCaps.depthRendering && formatCaps.stencilRendering) else if (depth && stencil)
{ {
renderbuffer = new gl::DepthStencilbuffer(mRenderer, width, height, samples); renderbuffer = new gl::DepthStencilbuffer(mRenderer, width, height, samples);
} }
else if (formatCaps.depthRendering) else if (depth)
{ {
renderbuffer = new gl::Depthbuffer(mRenderer, width, height, samples); renderbuffer = new gl::Depthbuffer(mRenderer, width, height, samples);
} }
else if (formatCaps.stencilRendering) else if (stencil)
{ {
renderbuffer = new gl::Stencilbuffer(mRenderer, width, height, samples); renderbuffer = new gl::Stencilbuffer(mRenderer, width, height, samples);
} }
@ -1680,8 +1700,8 @@ void Context::getFloatv(GLenum pname, GLfloat *params)
params[3] = mState.blendColor.alpha; params[3] = mState.blendColor.alpha;
break; break;
case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
ASSERT(getCaps().extensions.textureFilterAnisotropic); ASSERT(supportsTextureFilterAnisotropy());
*params = getCaps().extensions.maxTextureAnisotropy; *params = mMaxTextureAnisotropy;
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -1829,16 +1849,16 @@ void Context::getIntegerv(GLenum pname, GLint *params)
break; break;
case GL_COMPRESSED_TEXTURE_FORMATS: case GL_COMPRESSED_TEXTURE_FORMATS:
{ {
if (getCaps().extensions.textureCompressionDXT1) if (supportsDXT1Textures())
{ {
*params++ = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; *params++ = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
*params++ = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; *params++ = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
} }
if (getCaps().extensions.textureCompressionDXT3) if (supportsDXT3Textures())
{ {
*params++ = GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE; *params++ = GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE;
} }
if (getCaps().extensions.textureCompressionDXT5) if (supportsDXT5Textures())
{ {
*params++ = GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE; *params++ = GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE;
} }
@ -1864,7 +1884,7 @@ void Context::getIntegerv(GLenum pname, GLint *params)
case GL_ALPHA_BITS: case GL_ALPHA_BITS:
{ {
gl::Framebuffer *framebuffer = getDrawFramebuffer(); gl::Framebuffer *framebuffer = getDrawFramebuffer();
gl::FramebufferAttachment *colorbuffer = framebuffer->getFirstColorbuffer(); gl::Renderbuffer *colorbuffer = framebuffer->getFirstColorbuffer();
if (colorbuffer) if (colorbuffer)
{ {
@ -1885,7 +1905,7 @@ void Context::getIntegerv(GLenum pname, GLint *params)
case GL_DEPTH_BITS: case GL_DEPTH_BITS:
{ {
gl::Framebuffer *framebuffer = getDrawFramebuffer(); gl::Framebuffer *framebuffer = getDrawFramebuffer();
gl::FramebufferAttachment *depthbuffer = framebuffer->getDepthbuffer(); gl::Renderbuffer *depthbuffer = framebuffer->getDepthbuffer();
if (depthbuffer) if (depthbuffer)
{ {
@ -1900,7 +1920,7 @@ void Context::getIntegerv(GLenum pname, GLint *params)
case GL_STENCIL_BITS: case GL_STENCIL_BITS:
{ {
gl::Framebuffer *framebuffer = getDrawFramebuffer(); gl::Framebuffer *framebuffer = getDrawFramebuffer();
gl::FramebufferAttachment *stencilbuffer = framebuffer->getStencilbuffer(); gl::Renderbuffer *stencilbuffer = framebuffer->getStencilbuffer();
if (stencilbuffer) if (stencilbuffer)
{ {
@ -1956,7 +1976,7 @@ void Context::getIntegerv(GLenum pname, GLint *params)
*params = mState.unpack.pixelBuffer.id(); *params = mState.unpack.pixelBuffer.id();
break; break;
case GL_NUM_EXTENSIONS: case GL_NUM_EXTENSIONS:
*params = static_cast<GLint>(mExtensionStrings.size()); *params = static_cast<GLint>(getNumExtensions());
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -2160,7 +2180,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
return true; return true;
case GL_MAX_SAMPLES_ANGLE: case GL_MAX_SAMPLES_ANGLE:
{ {
if (getCaps().extensions.framebufferMultisample) if (getMaxSupportedSamples() != 0)
{ {
*type = GL_INT; *type = GL_INT;
*numParams = 1; *numParams = 1;
@ -2174,7 +2194,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
case GL_PIXEL_PACK_BUFFER_BINDING: case GL_PIXEL_PACK_BUFFER_BINDING:
case GL_PIXEL_UNPACK_BUFFER_BINDING: case GL_PIXEL_UNPACK_BUFFER_BINDING:
{ {
if (getCaps().extensions.pixelBufferObject) if (supportsPBOs())
{ {
*type = GL_INT; *type = GL_INT;
*numParams = 1; *numParams = 1;
@ -2248,7 +2268,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
} }
return true; return true;
case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
if (!getCaps().extensions.maxTextureAnisotropy) if (!supportsTextureFilterAnisotropy())
{ {
return false; return false;
} }
@ -2353,7 +2373,11 @@ bool Context::getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned
bool Context::applyRenderTarget(GLenum drawMode, bool ignoreViewport) bool Context::applyRenderTarget(GLenum drawMode, bool ignoreViewport)
{ {
Framebuffer *framebufferObject = getDrawFramebuffer(); Framebuffer *framebufferObject = getDrawFramebuffer();
ASSERT(framebufferObject && framebufferObject->completeness() == GL_FRAMEBUFFER_COMPLETE);
if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE)
{
return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
}
mRenderer->applyRenderTarget(framebufferObject); mRenderer->applyRenderTarget(framebufferObject);
@ -2421,9 +2445,7 @@ void Context::applyShaders(ProgramBinary *programBinary, bool transformFeedbackA
VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS]; VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS];
VertexFormat::GetInputLayout(inputLayout, programBinary, vertexAttributes, mState.vertexAttribCurrentValues); VertexFormat::GetInputLayout(inputLayout, programBinary, vertexAttributes, mState.vertexAttribCurrentValues);
const Framebuffer *fbo = getDrawFramebuffer(); mRenderer->applyShaders(programBinary, mState.rasterizer.rasterizerDiscard, transformFeedbackActive, inputLayout);
mRenderer->applyShaders(programBinary, inputLayout, fbo, mState.rasterizer.rasterizerDiscard, transformFeedbackActive);
programBinary->applyUniforms(); programBinary->applyUniforms();
} }
@ -2629,13 +2651,14 @@ void Context::clear(GLbitfield mask)
return; return;
} }
if (gl::GetStencilBits(depthStencil->getActualFormat()) > 0) if (gl::GetStencilBits(depthStencil->getActualFormat(), mClientVersion) > 0)
{ {
clearParams.clearStencil = true; clearParams.clearStencil = true;
} }
} }
} }
if (!applyRenderTarget(GL_TRIANGLES, true)) // Clips the clear to the scissor rectangle but not the viewport if (!applyRenderTarget(GL_TRIANGLES, true)) // Clips the clear to the scissor rectangle but not the viewport
{ {
return; return;
@ -2838,9 +2861,9 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
{ {
gl::Framebuffer *framebuffer = getReadFramebuffer(); gl::Framebuffer *framebuffer = getReadFramebuffer();
bool isSized = IsSizedInternalFormat(format); bool isSized = IsSizedInternalFormat(format, mClientVersion);
GLenum sizedInternalFormat = (isSized ? format : GetSizedInternalFormat(format, type)); GLenum sizedInternalFormat = (isSized ? format : GetSizedInternalFormat(format, type, mClientVersion));
GLuint outputPitch = GetRowPitch(sizedInternalFormat, type, width, mState.pack.alignment); GLuint outputPitch = GetRowPitch(sizedInternalFormat, type, mClientVersion, width, mState.pack.alignment);
mRenderer->readPixels(framebuffer, x, y, width, height, format, type, outputPitch, mState.pack, pixels); mRenderer->readPixels(framebuffer, x, y, width, height, format, type, outputPitch, mState.pack, pixels);
} }
@ -3108,11 +3131,6 @@ int Context::getClientVersion() const
return mClientVersion; return mClientVersion;
} }
const Caps &Context::getCaps() const
{
return mRenderer->getCaps();
}
int Context::getMajorShaderModel() const int Context::getMajorShaderModel() const
{ {
return mMajorShaderModel; return mMajorShaderModel;
@ -3170,6 +3188,66 @@ unsigned int Context::getMaximumRenderTargets() const
return mRenderer->getMaxRenderTargets(); 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 int Context::getMaximumRenderbufferDimension() const
{ {
return mMaxRenderbufferDimension; return mMaxRenderbufferDimension;
@ -3215,17 +3293,67 @@ int Context::getMaximum2DArrayTextureLevel() const
return mMax2DArrayTextureLevel; 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) void Context::getCurrentReadFormatType(GLenum *internalFormat, GLenum *format, GLenum *type)
{ {
Framebuffer *framebuffer = getReadFramebuffer(); Framebuffer *framebuffer = getReadFramebuffer();
ASSERT(framebuffer && framebuffer->completeness() == GL_FRAMEBUFFER_COMPLETE); ASSERT(framebuffer && framebuffer->completeness() == GL_FRAMEBUFFER_COMPLETE);
FramebufferAttachment *attachment = framebuffer->getReadColorbuffer(); Renderbuffer *renderbuffer = framebuffer->getReadColorbuffer();
ASSERT(attachment); ASSERT(renderbuffer);
*internalFormat = attachment->getActualFormat(); *internalFormat = renderbuffer->getActualFormat();
*format = gl::GetFormat(attachment->getActualFormat()); *format = gl::GetFormat(renderbuffer->getActualFormat(), mClientVersion);
*type = gl::GetType(attachment->getActualFormat()); *type = gl::GetType(renderbuffer->getActualFormat(), mClientVersion);
} }
void Context::detachBuffer(GLuint buffer) void Context::detachBuffer(GLuint buffer)
@ -3265,7 +3393,7 @@ void Context::detachTexture(GLuint texture)
// [OpenGL ES 2.0.24] section 4.4 page 112: // [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 // If a texture object is deleted while its image is attached to the currently bound framebuffer, then it is
// as if Texture2DAttachment had been called, with a texture of 0, for each attachment point to which this // as if FramebufferTexture2D had been called, with a texture of 0, for each attachment point to which this
// image was attached in the currently bound framebuffer. // image was attached in the currently bound framebuffer.
Framebuffer *readFramebuffer = getReadFramebuffer(); Framebuffer *readFramebuffer = getReadFramebuffer();
@ -3564,6 +3692,175 @@ GLfloat Context::getSamplerParameterf(GLuint sampler, GLenum pname)
} }
} }
// keep list sorted in following order
// OES extensions
// EXT extensions
// Vendor extensions
void Context::initExtensionString()
{
// Do not report extension in GLES 3 contexts for now
if (mClientVersion == 2)
{
// OES extensions
if (supports32bitIndices())
{
mExtensionStringList.push_back("GL_OES_element_index_uint");
}
mExtensionStringList.push_back("GL_OES_packed_depth_stencil");
mExtensionStringList.push_back("GL_OES_get_program_binary");
mExtensionStringList.push_back("GL_OES_rgb8_rgba8");
if (supportsPBOs())
{
mExtensionStringList.push_back("NV_pixel_buffer_object");
mExtensionStringList.push_back("GL_OES_mapbuffer");
mExtensionStringList.push_back("GL_EXT_map_buffer_range");
}
if (mRenderer->getDerivativeInstructionSupport())
{
mExtensionStringList.push_back("GL_OES_standard_derivatives");
}
if (supportsFloat16Textures())
{
mExtensionStringList.push_back("GL_OES_texture_half_float");
}
if (supportsFloat16LinearFilter())
{
mExtensionStringList.push_back("GL_OES_texture_half_float_linear");
}
if (supportsFloat32Textures())
{
mExtensionStringList.push_back("GL_OES_texture_float");
}
if (supportsFloat32LinearFilter())
{
mExtensionStringList.push_back("GL_OES_texture_float_linear");
}
if (supportsRGTextures())
{
mExtensionStringList.push_back("GL_EXT_texture_rg");
}
if (supportsNonPower2Texture())
{
mExtensionStringList.push_back("GL_OES_texture_npot");
}
// Multi-vendor (EXT) extensions
if (supportsOcclusionQueries())
{
mExtensionStringList.push_back("GL_EXT_occlusion_query_boolean");
}
mExtensionStringList.push_back("GL_EXT_read_format_bgra");
mExtensionStringList.push_back("GL_EXT_robustness");
mExtensionStringList.push_back("GL_EXT_shader_texture_lod");
if (supportsDXT1Textures())
{
mExtensionStringList.push_back("GL_EXT_texture_compression_dxt1");
}
if (supportsTextureFilterAnisotropy())
{
mExtensionStringList.push_back("GL_EXT_texture_filter_anisotropic");
}
if (supportsBGRATextures())
{
mExtensionStringList.push_back("GL_EXT_texture_format_BGRA8888");
}
if (mRenderer->getMaxRenderTargets() > 1)
{
mExtensionStringList.push_back("GL_EXT_draw_buffers");
}
mExtensionStringList.push_back("GL_EXT_texture_storage");
mExtensionStringList.push_back("GL_EXT_frag_depth");
mExtensionStringList.push_back("GL_EXT_blend_minmax");
// ANGLE-specific extensions
if (supportsDepthTextures())
{
mExtensionStringList.push_back("GL_ANGLE_depth_texture");
}
mExtensionStringList.push_back("GL_ANGLE_framebuffer_blit");
if (getMaxSupportedSamples() != 0)
{
mExtensionStringList.push_back("GL_ANGLE_framebuffer_multisample");
}
if (supportsInstancing())
{
mExtensionStringList.push_back("GL_ANGLE_instanced_arrays");
}
mExtensionStringList.push_back("GL_ANGLE_pack_reverse_row_order");
if (supportsDXT3Textures())
{
mExtensionStringList.push_back("GL_ANGLE_texture_compression_dxt3");
}
if (supportsDXT5Textures())
{
mExtensionStringList.push_back("GL_ANGLE_texture_compression_dxt5");
}
mExtensionStringList.push_back("GL_ANGLE_texture_usage");
mExtensionStringList.push_back("GL_ANGLE_translated_shader_source");
// Other vendor-specific extensions
if (supportsEventQueries())
{
mExtensionStringList.push_back("GL_NV_fence");
}
}
if (mClientVersion == 3)
{
mExtensionStringList.push_back("GL_EXT_color_buffer_float");
mExtensionStringList.push_back("GL_EXT_read_format_bgra");
if (supportsBGRATextures())
{
mExtensionStringList.push_back("GL_EXT_texture_format_BGRA8888");
}
}
// Join the extension strings to one long string for use with GetString
std::stringstream strstr;
for (unsigned int extensionIndex = 0; extensionIndex < mExtensionStringList.size(); extensionIndex++)
{
strstr << mExtensionStringList[extensionIndex];
strstr << " ";
}
mCombinedExtensionsString = makeStaticString(strstr.str());
}
const char *Context::getCombinedExtensionsString() const
{
return mCombinedExtensionsString;
}
const char *Context::getExtensionString(const GLuint index) const
{
ASSERT(index < mExtensionStringList.size());
return mExtensionStringList[index].c_str();
}
unsigned int Context::getNumExtensions() const
{
return mExtensionStringList.size();
}
void Context::initRendererString() void Context::initRendererString()
{ {
std::ostringstream rendererString; std::ostringstream rendererString;
@ -3571,7 +3868,7 @@ void Context::initRendererString()
rendererString << mRenderer->getRendererDescription(); rendererString << mRenderer->getRendererDescription();
rendererString << ")"; rendererString << ")";
mRendererString = MakeStaticString(rendererString.str()); mRendererString = makeStaticString(rendererString.str());
} }
const char *Context::getRendererString() const const char *Context::getRendererString() const
@ -3579,34 +3876,6 @@ const char *Context::getRendererString() const
return mRendererString; 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 Context::getBoundFramebufferTextureSerials(FramebufferTextureSerialArray *outSerialArray)
{ {
size_t serialCount = 0; size_t serialCount = 0;
@ -3614,17 +3883,17 @@ size_t Context::getBoundFramebufferTextureSerials(FramebufferTextureSerialArray
Framebuffer *drawFramebuffer = getDrawFramebuffer(); Framebuffer *drawFramebuffer = getDrawFramebuffer();
for (unsigned int i = 0; i < IMPLEMENTATION_MAX_DRAW_BUFFERS; i++) for (unsigned int i = 0; i < IMPLEMENTATION_MAX_DRAW_BUFFERS; i++)
{ {
FramebufferAttachment *attachment = drawFramebuffer->getColorbuffer(i); Renderbuffer *renderBuffer = drawFramebuffer->getColorbuffer(i);
if (attachment && attachment->isTexture()) if (renderBuffer && renderBuffer->isTexture())
{ {
(*outSerialArray)[serialCount++] = attachment->getTextureSerial(); (*outSerialArray)[serialCount++] = renderBuffer->getTextureSerial();
} }
} }
FramebufferAttachment *depthStencilAttachment = drawFramebuffer->getDepthOrStencilbuffer(); Renderbuffer *depthStencilBuffer = drawFramebuffer->getDepthOrStencilbuffer();
if (depthStencilAttachment && depthStencilAttachment->isTexture()) if (depthStencilBuffer && depthStencilBuffer->isTexture())
{ {
(*outSerialArray)[serialCount++] = depthStencilAttachment->getTextureSerial(); (*outSerialArray)[serialCount++] = depthStencilBuffer->getTextureSerial();
} }
std::sort(outSerialArray->begin(), outSerialArray->begin() + serialCount); std::sort(outSerialArray->begin(), outSerialArray->begin() + serialCount);
@ -3689,43 +3958,43 @@ void Context::invalidateFrameBuffer(GLenum target, GLsizei numAttachments, const
if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15) if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15)
{ {
gl::FramebufferAttachment *attachment = frameBuffer->getColorbuffer(attachments[i] - GL_COLOR_ATTACHMENT0); gl::Renderbuffer *renderBuffer = frameBuffer->getColorbuffer(attachments[i] - GL_COLOR_ATTACHMENT0);
if (attachment) if (renderBuffer)
{ {
renderTarget = attachment->getRenderTarget(); renderTarget = renderBuffer->getRenderTarget();
} }
} }
else if (attachments[i] == GL_COLOR) else if (attachments[i] == GL_COLOR)
{ {
gl::FramebufferAttachment *attachment = frameBuffer->getColorbuffer(0); gl::Renderbuffer *renderBuffer = frameBuffer->getColorbuffer(0);
if (attachment) if (renderBuffer)
{ {
renderTarget = attachment->getRenderTarget(); renderTarget = renderBuffer->getRenderTarget();
} }
} }
else else
{ {
gl::FramebufferAttachment *attachment = NULL; gl::Renderbuffer *renderBuffer = NULL;
switch (attachments[i]) switch (attachments[i])
{ {
case GL_DEPTH_ATTACHMENT: case GL_DEPTH_ATTACHMENT:
case GL_DEPTH: case GL_DEPTH:
attachment = frameBuffer->getDepthbuffer(); renderBuffer = frameBuffer->getDepthbuffer();
break; break;
case GL_STENCIL_ATTACHMENT: case GL_STENCIL_ATTACHMENT:
case GL_STENCIL: case GL_STENCIL:
attachment = frameBuffer->getStencilbuffer(); renderBuffer = frameBuffer->getStencilbuffer();
break; break;
case GL_DEPTH_STENCIL_ATTACHMENT: case GL_DEPTH_STENCIL_ATTACHMENT:
attachment = frameBuffer->getDepthOrStencilbuffer(); renderBuffer = frameBuffer->getDepthOrStencilbuffer();
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
if (attachment) if (renderBuffer)
{ {
renderTarget = attachment->getDepthStencil(); renderTarget = renderBuffer->getDepthStencil();
} }
} }
@ -3744,8 +4013,8 @@ bool Context::hasMappedBuffer(GLenum target) const
for (unsigned int attribIndex = 0; attribIndex < gl::MAX_VERTEX_ATTRIBS; attribIndex++) for (unsigned int attribIndex = 0; attribIndex < gl::MAX_VERTEX_ATTRIBS; attribIndex++)
{ {
const gl::VertexAttribute &vertexAttrib = getVertexAttribState(attribIndex); const gl::VertexAttribute &vertexAttrib = getVertexAttribState(attribIndex);
gl::Buffer *boundBuffer = vertexAttrib.buffer.get(); gl::Buffer *boundBuffer = vertexAttrib.mBoundBuffer.get();
if (vertexAttrib.enabled && boundBuffer && boundBuffer->isMapped()) if (vertexAttrib.mArrayEnabled && boundBuffer && boundBuffer->mapped())
{ {
return true; return true;
} }
@ -3754,7 +4023,7 @@ bool Context::hasMappedBuffer(GLenum target) const
else if (target == GL_ELEMENT_ARRAY_BUFFER) else if (target == GL_ELEMENT_ARRAY_BUFFER)
{ {
Buffer *elementBuffer = getElementArrayBuffer(); Buffer *elementBuffer = getElementArrayBuffer();
return (elementBuffer && elementBuffer->isMapped()); return (elementBuffer && elementBuffer->mapped());
} }
else if (target == GL_TRANSFORM_FEEDBACK_BUFFER) else if (target == GL_TRANSFORM_FEEDBACK_BUFFER)
{ {

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

@ -10,7 +10,10 @@
#ifndef LIBGLESV2_CONTEXT_H_ #ifndef LIBGLESV2_CONTEXT_H_
#define LIBGLESV2_CONTEXT_H_ #define LIBGLESV2_CONTEXT_H_
#include "angle_gl.h" #include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <EGL/egl.h> #include <EGL/egl.h>
#include <string> #include <string>
@ -21,7 +24,6 @@
#include "common/angleutils.h" #include "common/angleutils.h"
#include "common/RefCountObject.h" #include "common/RefCountObject.h"
#include "libGLESv2/Caps.h"
#include "libGLESv2/HandleAllocator.h" #include "libGLESv2/HandleAllocator.h"
#include "libGLESv2/angletypes.h" #include "libGLESv2/angletypes.h"
#include "libGLESv2/Constants.h" #include "libGLESv2/Constants.h"
@ -59,7 +61,7 @@ class FenceSync;
class Query; class Query;
class ResourceManager; class ResourceManager;
class Buffer; class Buffer;
struct VertexAttribute; class VertexAttribute;
class VertexArray; class VertexArray;
class Sampler; class Sampler;
class TransformFeedback; class TransformFeedback;
@ -179,9 +181,6 @@ class Context
void setStencilBackWritemask(GLuint stencilBackWritemask); void setStencilBackWritemask(GLuint stencilBackWritemask);
void setStencilOperations(GLenum stencilFail, GLenum stencilPassDepthFail, GLenum stencilPassDepthPass); void setStencilOperations(GLenum stencilFail, GLenum stencilPassDepthFail, GLenum stencilPassDepthPass);
void setStencilBackOperations(GLenum stencilBackFail, GLenum stencilBackPassDepthFail, GLenum stencilBackPassDepthPass); void setStencilBackOperations(GLenum stencilBackFail, GLenum stencilBackPassDepthFail, GLenum stencilBackPassDepthPass);
const gl::DepthStencilState &getDepthStencilState() const;
GLint getStencilRef() const;
GLint getStencilBackRef() const;
void setPolygonOffsetFill(bool enabled); void setPolygonOffsetFill(bool enabled);
bool isPolygonOffsetFillEnabled() const; bool isPolygonOffsetFillEnabled() const;
@ -361,7 +360,6 @@ class Context
GLuint getTargetFramebufferHandle(GLenum target) const; GLuint getTargetFramebufferHandle(GLenum target) const;
Framebuffer *getReadFramebuffer(); Framebuffer *getReadFramebuffer();
Framebuffer *getDrawFramebuffer(); Framebuffer *getDrawFramebuffer();
const Framebuffer *getDrawFramebuffer() const;
VertexArray *getCurrentVertexArray() const; VertexArray *getCurrentVertexArray() const;
TransformFeedback *getCurrentTransformFeedback() const; TransformFeedback *getCurrentTransformFeedback() const;
@ -401,8 +399,6 @@ class Context
virtual int getClientVersion() const; virtual int getClientVersion() const;
const Caps &getCaps() const;
int getMajorShaderModel() const; int getMajorShaderModel() const;
float getMaximumPointSize() const; float getMaximumPointSize() const;
unsigned int getMaximumCombinedTextureImageUnits() const; unsigned int getMaximumCombinedTextureImageUnits() const;
@ -423,14 +419,36 @@ class Context
void getSampleCounts(GLenum internalFormat, GLsizei bufSize, GLint *params) const; void getSampleCounts(GLenum internalFormat, GLsizei bufSize, GLint *params) const;
unsigned int getMaxTransformFeedbackBufferBindings() const; unsigned int getMaxTransformFeedbackBufferBindings() const;
GLintptr getUniformBufferOffsetAlignment() const; GLintptr getUniformBufferOffsetAlignment() const;
const char *getCombinedExtensionsString() const;
const char *getExtensionString(const GLuint index) const;
unsigned int getNumExtensions() const;
const char *getRendererString() const; const char *getRendererString() const;
bool supportsEventQueries() const;
const char *getExtensionString() const; bool supportsOcclusionQueries() const;
const char *getExtensionString(size_t idx) const; bool supportsBGRATextures() const;
size_t getExtensionStringCount() const; bool supportsDXT1Textures() const;
bool supportsDXT3Textures() const;
bool supportsDXT5Textures() const;
bool supportsFloat32Textures() const;
bool supportsFloat32LinearFilter() const;
bool supportsFloat32RenderableTextures() const;
bool supportsFloat16Textures() const;
bool supportsFloat16LinearFilter() const;
bool supportsFloat16RenderableTextures() const;
bool supportsLuminanceTextures() const;
bool supportsLuminanceAlphaTextures() const;
bool supportsRGTextures() const;
bool supportsDepthTextures() const;
bool supports32bitIndices() const;
bool supportsNonPower2Texture() const;
bool supportsInstancing() const;
bool supportsTextureFilterAnisotropy() const;
bool supportsPBOs() const;
void getCurrentReadFormatType(GLenum *internalFormat, GLenum *format, GLenum *type); 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, void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter); GLbitfield mask, GLenum filter);
@ -472,8 +490,8 @@ class Context
bool skipDraw(GLenum drawMode); bool skipDraw(GLenum drawMode);
void initExtensionString();
void initRendererString(); void initRendererString();
void initExtensionStrings();
size_t getBoundFramebufferTextureSerials(FramebufferTextureSerialArray *outSerialArray); size_t getBoundFramebufferTextureSerials(FramebufferTextureSerialArray *outSerialArray);
@ -509,9 +527,9 @@ class Context
TransformFeedbackMap mTransformFeedbackMap; TransformFeedbackMap mTransformFeedbackMap;
HandleAllocator mTransformFeedbackAllocator; HandleAllocator mTransformFeedbackAllocator;
std::vector<std::string> mExtensionStringList;
const char *mCombinedExtensionsString;
const char *mRendererString; const char *mRendererString;
const char *mExtensionString;
std::vector<const char *> mExtensionStrings;
BindingPointer<Texture> mIncompleteTextures[TEXTURE_TYPE_COUNT]; BindingPointer<Texture> mIncompleteTextures[TEXTURE_TYPE_COUNT];
@ -535,6 +553,8 @@ class Context
int mMajorShaderModel; int mMajorShaderModel;
float mMaximumPointSize; float mMaximumPointSize;
bool mSupportsVertexTexture; bool mSupportsVertexTexture;
bool mSupportsNonPower2Texture;
bool mSupportsInstancing;
int mMaxViewportDimension; int mMaxViewportDimension;
int mMaxRenderbufferDimension; int mMaxRenderbufferDimension;
int mMax2DTextureDimension; int mMax2DTextureDimension;
@ -545,6 +565,26 @@ class Context
int mMaxCubeTextureLevel; int mMaxCubeTextureLevel;
int mMax3DTextureLevel; int mMax3DTextureLevel;
int mMax2DArrayTextureLevel; 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; int mNumCompressedTextureFormats;
ResourceManager *mResourceManager; ResourceManager *mResourceManager;

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

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

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

@ -17,12 +17,6 @@ namespace rx
class Renderer; class Renderer;
} }
namespace sh
{
struct Attribute;
struct ShaderVariable;
}
namespace gl namespace gl
{ {
@ -31,20 +25,15 @@ class FragmentShader;
class VertexShader; class VertexShader;
struct VariableLocation; struct VariableLocation;
struct LinkedVarying; struct LinkedVarying;
struct VertexAttribute; class VertexAttribute;
struct VertexFormat; struct VertexFormat;
struct ShaderVariable;
struct Varying;
struct Attribute;
struct PackedVarying; struct PackedVarying;
typedef const PackedVarying *VaryingPacking[IMPLEMENTATION_MAX_VARYING_VECTORS][4]; typedef const PackedVarying *VaryingPacking[IMPLEMENTATION_MAX_VARYING_VECTORS][4];
struct PixelShaderOuputVariable
{
GLenum type;
std::string name;
std::string source;
size_t outputIndex;
};
class DynamicHLSL class DynamicHLSL
{ {
public: public:
@ -52,43 +41,33 @@ class DynamicHLSL
int packVaryings(InfoLog &infoLog, VaryingPacking packing, FragmentShader *fragmentShader, int packVaryings(InfoLog &infoLog, VaryingPacking packing, FragmentShader *fragmentShader,
VertexShader *vertexShader, const std::vector<std::string>& transformFeedbackVaryings); VertexShader *vertexShader, const std::vector<std::string>& transformFeedbackVaryings);
std::string generateVertexShaderForInputLayout(const std::string &sourceShader, const VertexFormat inputLayout[], std::string generateInputLayoutHLSL(const VertexFormat inputLayout[], const Attribute shaderAttributes[]) const;
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, bool generateShaderLinkHLSL(InfoLog &infoLog, int registers, const VaryingPacking packing,
std::string& pixelHLSL, std::string& vertexHLSL, std::string& pixelHLSL, std::string& vertexHLSL,
FragmentShader *fragmentShader, VertexShader *vertexShader, FragmentShader *fragmentShader, VertexShader *vertexShader,
const std::vector<std::string>& transformFeedbackVaryings, const std::vector<std::string>& transformFeedbackVaryings,
std::vector<LinkedVarying> *linkedVaryings, std::vector<LinkedVarying> *linkedVaryings,
std::map<int, VariableLocation> *programOutputVars, std::map<int, VariableLocation> *programOutputVars) const;
std::vector<PixelShaderOuputVariable> *outPixelShaderKey,
bool *outUsesFragDepth) const;
std::string generateGeometryShaderHLSL(int registers, FragmentShader *fragmentShader, VertexShader *vertexShader) const; std::string generateGeometryShaderHLSL(int registers, FragmentShader *fragmentShader, VertexShader *vertexShader) const;
void getInputLayoutSignature(const VertexFormat inputLayout[], GLenum signature[]) const; void getInputLayoutSignature(const VertexFormat inputLayout[], GLenum signature[]) const;
static const std::string VERTEX_ATTRIBUTE_STUB_STRING;
private: private:
DISALLOW_COPY_AND_ASSIGN(DynamicHLSL); DISALLOW_COPY_AND_ASSIGN(DynamicHLSL);
rx::Renderer *const mRenderer; rx::Renderer *const mRenderer;
struct SemanticInfo; std::string generateVaryingHLSL(VertexShader *shader, const std::string &varyingSemantic,
std::vector<LinkedVarying> *linkedVaryings) const;
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; void defineOutputVariables(FragmentShader *fragmentShader, std::map<int, VariableLocation> *programOutputVars) const;
std::string generatePointSpriteHLSL(int registers, FragmentShader *fragmentShader, VertexShader *vertexShader) const; std::string generatePointSpriteHLSL(int registers, FragmentShader *fragmentShader, VertexShader *vertexShader) const;
// Prepend an underscore // Prepend an underscore
static std::string decorateVariable(const std::string &name); static std::string decorateVariable(const std::string &name);
std::string generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const sh::ShaderVariable &shaderAttrib) const; std::string generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const ShaderVariable &shaderAttrib) const;
}; };
// Utility method shared between ProgramBinary and DynamicHLSL // Utility method shared between ProgramBinary and DynamicHLSL

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

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

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

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

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

@ -1,495 +0,0 @@
#include "precompiled.h"
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// FramebufferAttachment.cpp: the gl::FramebufferAttachment class and its derived classes
// objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108.
#include "libGLESv2/FramebufferAttachment.h"
#include "libGLESv2/renderer/RenderTarget.h"
#include "libGLESv2/Texture.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/TextureStorage.h"
#include "common/utilities.h"
#include "libGLESv2/formatutils.h"
#include "libGLESv2/Renderbuffer.h"
namespace gl
{
////// FramebufferAttachment Implementation //////
FramebufferAttachment::FramebufferAttachment()
{
}
FramebufferAttachment::~FramebufferAttachment()
{
}
GLuint FramebufferAttachment::getRedSize() const
{
return (gl::GetRedBits(getInternalFormat()) > 0) ? gl::GetRedBits(getActualFormat()) : 0;
}
GLuint FramebufferAttachment::getGreenSize() const
{
return (gl::GetGreenBits(getInternalFormat()) > 0) ? gl::GetGreenBits(getActualFormat()) : 0;
}
GLuint FramebufferAttachment::getBlueSize() const
{
return (gl::GetBlueBits(getInternalFormat()) > 0) ? gl::GetBlueBits(getActualFormat()) : 0;
}
GLuint FramebufferAttachment::getAlphaSize() const
{
return (gl::GetAlphaBits(getInternalFormat()) > 0) ? gl::GetAlphaBits(getActualFormat()) : 0;
}
GLuint FramebufferAttachment::getDepthSize() const
{
return (gl::GetDepthBits(getInternalFormat()) > 0) ? gl::GetDepthBits(getActualFormat()) : 0;
}
GLuint FramebufferAttachment::getStencilSize() const
{
return (gl::GetStencilBits(getInternalFormat()) > 0) ? gl::GetStencilBits(getActualFormat()) : 0;
}
GLenum FramebufferAttachment::getComponentType() const
{
return gl::GetComponentType(getActualFormat());
}
GLenum FramebufferAttachment::getColorEncoding() const
{
return gl::GetColorEncoding(getActualFormat());
}
bool FramebufferAttachment::isTexture() const
{
return (type() != GL_RENDERBUFFER);
}
///// Texture2DAttachment Implementation ////////
Texture2DAttachment::Texture2DAttachment(Texture2D *texture, GLint level) : mLevel(level)
{
mTexture2D.set(texture);
}
Texture2DAttachment::~Texture2DAttachment()
{
mTexture2D.set(NULL);
}
rx::RenderTarget *Texture2DAttachment::getRenderTarget()
{
return mTexture2D->getRenderTarget(mLevel);
}
rx::RenderTarget *Texture2DAttachment::getDepthStencil()
{
return mTexture2D->getDepthSencil(mLevel);
}
rx::TextureStorage *Texture2DAttachment::getTextureStorage()
{
return mTexture2D->getNativeTexture()->getStorageInstance();
}
GLsizei Texture2DAttachment::getWidth() const
{
return mTexture2D->getWidth(mLevel);
}
GLsizei Texture2DAttachment::getHeight() const
{
return mTexture2D->getHeight(mLevel);
}
GLenum Texture2DAttachment::getInternalFormat() const
{
return mTexture2D->getInternalFormat(mLevel);
}
GLenum Texture2DAttachment::getActualFormat() const
{
return mTexture2D->getActualFormat(mLevel);
}
GLsizei Texture2DAttachment::getSamples() const
{
return 0;
}
unsigned int Texture2DAttachment::getSerial() const
{
return mTexture2D->getRenderTargetSerial(mLevel);
}
GLuint Texture2DAttachment::id() const
{
return mTexture2D->id();
}
GLenum Texture2DAttachment::type() const
{
return GL_TEXTURE_2D;
}
GLint Texture2DAttachment::mipLevel() const
{
return mLevel;
}
GLint Texture2DAttachment::layer() const
{
return 0;
}
unsigned int Texture2DAttachment::getTextureSerial() const
{
return mTexture2D->getTextureSerial();
}
///// TextureCubeMapAttachment Implementation ////////
TextureCubeMapAttachment::TextureCubeMapAttachment(TextureCubeMap *texture, GLenum faceTarget, GLint level)
: mFaceTarget(faceTarget), mLevel(level)
{
mTextureCubeMap.set(texture);
}
TextureCubeMapAttachment::~TextureCubeMapAttachment()
{
mTextureCubeMap.set(NULL);
}
rx::RenderTarget *TextureCubeMapAttachment::getRenderTarget()
{
return mTextureCubeMap->getRenderTarget(mFaceTarget, mLevel);
}
rx::RenderTarget *TextureCubeMapAttachment::getDepthStencil()
{
return mTextureCubeMap->getDepthStencil(mFaceTarget, mLevel);
}
rx::TextureStorage *TextureCubeMapAttachment::getTextureStorage()
{
return mTextureCubeMap->getNativeTexture()->getStorageInstance();
}
GLsizei TextureCubeMapAttachment::getWidth() const
{
return mTextureCubeMap->getWidth(mFaceTarget, mLevel);
}
GLsizei TextureCubeMapAttachment::getHeight() const
{
return mTextureCubeMap->getHeight(mFaceTarget, mLevel);
}
GLenum TextureCubeMapAttachment::getInternalFormat() const
{
return mTextureCubeMap->getInternalFormat(mFaceTarget, mLevel);
}
GLenum TextureCubeMapAttachment::getActualFormat() const
{
return mTextureCubeMap->getActualFormat(mFaceTarget, mLevel);
}
GLsizei TextureCubeMapAttachment::getSamples() const
{
return 0;
}
unsigned int TextureCubeMapAttachment::getSerial() const
{
return mTextureCubeMap->getRenderTargetSerial(mFaceTarget, mLevel);
}
GLuint TextureCubeMapAttachment::id() const
{
return mTextureCubeMap->id();
}
GLenum TextureCubeMapAttachment::type() const
{
return mFaceTarget;
}
GLint TextureCubeMapAttachment::mipLevel() const
{
return mLevel;
}
GLint TextureCubeMapAttachment::layer() const
{
return 0;
}
unsigned int TextureCubeMapAttachment::getTextureSerial() const
{
return mTextureCubeMap->getTextureSerial();
}
///// Texture3DAttachment Implementation ////////
Texture3DAttachment::Texture3DAttachment(Texture3D *texture, GLint level, GLint layer)
: mLevel(level), mLayer(layer)
{
mTexture3D.set(texture);
}
Texture3DAttachment::~Texture3DAttachment()
{
mTexture3D.set(NULL);
}
rx::RenderTarget *Texture3DAttachment::getRenderTarget()
{
return mTexture3D->getRenderTarget(mLevel, mLayer);
}
rx::RenderTarget *Texture3DAttachment::getDepthStencil()
{
return mTexture3D->getDepthStencil(mLevel, mLayer);
}
rx::TextureStorage *Texture3DAttachment::getTextureStorage()
{
return mTexture3D->getNativeTexture()->getStorageInstance();
}
GLsizei Texture3DAttachment::getWidth() const
{
return mTexture3D->getWidth(mLevel);
}
GLsizei Texture3DAttachment::getHeight() const
{
return mTexture3D->getHeight(mLevel);
}
GLenum Texture3DAttachment::getInternalFormat() const
{
return mTexture3D->getInternalFormat(mLevel);
}
GLenum Texture3DAttachment::getActualFormat() const
{
return mTexture3D->getActualFormat(mLevel);
}
GLsizei Texture3DAttachment::getSamples() const
{
return 0;
}
unsigned int Texture3DAttachment::getSerial() const
{
return mTexture3D->getRenderTargetSerial(mLevel, mLayer);
}
GLuint Texture3DAttachment::id() const
{
return mTexture3D->id();
}
GLenum Texture3DAttachment::type() const
{
return GL_TEXTURE_3D;
}
GLint Texture3DAttachment::mipLevel() const
{
return mLevel;
}
GLint Texture3DAttachment::layer() const
{
return mLayer;
}
unsigned int Texture3DAttachment::getTextureSerial() const
{
return mTexture3D->getTextureSerial();
}
////// Texture2DArrayAttachment Implementation //////
Texture2DArrayAttachment::Texture2DArrayAttachment(Texture2DArray *texture, GLint level, GLint layer)
: mLevel(level), mLayer(layer)
{
mTexture2DArray.set(texture);
}
Texture2DArrayAttachment::~Texture2DArrayAttachment()
{
mTexture2DArray.set(NULL);
}
rx::RenderTarget *Texture2DArrayAttachment::getRenderTarget()
{
return mTexture2DArray->getRenderTarget(mLevel, mLayer);
}
rx::RenderTarget *Texture2DArrayAttachment::getDepthStencil()
{
return mTexture2DArray->getDepthStencil(mLevel, mLayer);
}
rx::TextureStorage *Texture2DArrayAttachment::getTextureStorage()
{
return mTexture2DArray->getNativeTexture()->getStorageInstance();
}
GLsizei Texture2DArrayAttachment::getWidth() const
{
return mTexture2DArray->getWidth(mLevel);
}
GLsizei Texture2DArrayAttachment::getHeight() const
{
return mTexture2DArray->getHeight(mLevel);
}
GLenum Texture2DArrayAttachment::getInternalFormat() const
{
return mTexture2DArray->getInternalFormat(mLevel);
}
GLenum Texture2DArrayAttachment::getActualFormat() const
{
return mTexture2DArray->getActualFormat(mLevel);
}
GLsizei Texture2DArrayAttachment::getSamples() const
{
return 0;
}
unsigned int Texture2DArrayAttachment::getSerial() const
{
return mTexture2DArray->getRenderTargetSerial(mLevel, mLayer);
}
GLuint Texture2DArrayAttachment::id() const
{
return mTexture2DArray->id();
}
GLenum Texture2DArrayAttachment::type() const
{
return GL_TEXTURE_2D_ARRAY;
}
GLint Texture2DArrayAttachment::mipLevel() const
{
return mLevel;
}
GLint Texture2DArrayAttachment::layer() const
{
return mLayer;
}
unsigned int Texture2DArrayAttachment::getTextureSerial() const
{
return mTexture2DArray->getTextureSerial();
}
////// RenderbufferAttachment Implementation //////
RenderbufferAttachment::RenderbufferAttachment(Renderbuffer *renderbuffer)
{
ASSERT(renderbuffer);
mRenderbuffer.set(renderbuffer);
}
RenderbufferAttachment::~RenderbufferAttachment()
{
mRenderbuffer.set(NULL);
}
rx::RenderTarget *RenderbufferAttachment::getRenderTarget()
{
return mRenderbuffer->getStorage()->getRenderTarget();
}
rx::RenderTarget *RenderbufferAttachment::getDepthStencil()
{
return mRenderbuffer->getStorage()->getDepthStencil();
}
rx::TextureStorage *RenderbufferAttachment::getTextureStorage()
{
UNREACHABLE();
return NULL;
}
GLsizei RenderbufferAttachment::getWidth() const
{
return mRenderbuffer->getWidth();
}
GLsizei RenderbufferAttachment::getHeight() const
{
return mRenderbuffer->getHeight();
}
GLenum RenderbufferAttachment::getInternalFormat() const
{
return mRenderbuffer->getInternalFormat();
}
GLenum RenderbufferAttachment::getActualFormat() const
{
return mRenderbuffer->getActualFormat();
}
GLsizei RenderbufferAttachment::getSamples() const
{
return mRenderbuffer->getStorage()->getSamples();
}
unsigned int RenderbufferAttachment::getSerial() const
{
return mRenderbuffer->getStorage()->getSerial();
}
GLuint RenderbufferAttachment::id() const
{
return mRenderbuffer->id();
}
GLenum RenderbufferAttachment::type() const
{
return GL_RENDERBUFFER;
}
GLint RenderbufferAttachment::mipLevel() const
{
return 0;
}
GLint RenderbufferAttachment::layer() const
{
return 0;
}
unsigned int RenderbufferAttachment::getTextureSerial() const
{
UNREACHABLE();
return 0;
}
}

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

@ -1,246 +0,0 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// FramebufferAttachment.h: Defines the wrapper class gl::FramebufferAttachment, as well as the
// objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108.
#ifndef LIBGLESV2_FRAMEBUFFERATTACHMENT_H_
#define LIBGLESV2_FRAMEBUFFERATTACHMENT_H_
#include "angle_gl.h"
#include "common/angleutils.h"
#include "common/RefCountObject.h"
namespace rx
{
class Renderer;
class RenderTarget;
class TextureStorage;
}
namespace gl
{
class Texture2D;
class TextureCubeMap;
class Texture3D;
class Texture2DArray;
class Renderbuffer;
// FramebufferAttachment implements a GL framebuffer attachment.
// Attachments are "light" containers, which store pointers to ref-counted GL objects.
// We support GL texture (2D/3D/Cube/2D array) and renderbuffer object attachments.
// Note: Our old naming scheme used the term "Renderbuffer" for both GL renderbuffers and for
// framebuffer attachments, which confused their usage.
class FramebufferAttachment
{
public:
FramebufferAttachment();
virtual ~FramebufferAttachment();
// Helper methods
GLuint getRedSize() const;
GLuint getGreenSize() const;
GLuint getBlueSize() const;
GLuint getAlphaSize() const;
GLuint getDepthSize() const;
GLuint getStencilSize() const;
GLenum getComponentType() const;
GLenum getColorEncoding() const;
bool isTexture() const;
bool isTextureWithId(GLuint textureId) const { return isTexture() && id() == textureId; }
bool isRenderbufferWithId(GLuint renderbufferId) const { return !isTexture() && id() == renderbufferId; }
// Child class interface
virtual rx::RenderTarget *getRenderTarget() = 0;
virtual rx::RenderTarget *getDepthStencil() = 0;
virtual rx::TextureStorage *getTextureStorage() = 0;
virtual GLsizei getWidth() const = 0;
virtual GLsizei getHeight() const = 0;
virtual GLenum getInternalFormat() const = 0;
virtual GLenum getActualFormat() const = 0;
virtual GLsizei getSamples() const = 0;
virtual unsigned int getSerial() const = 0;
virtual GLuint id() const = 0;
virtual GLenum type() const = 0;
virtual GLint mipLevel() const = 0;
virtual GLint layer() const = 0;
virtual unsigned int getTextureSerial() const = 0;
private:
DISALLOW_COPY_AND_ASSIGN(FramebufferAttachment);
};
class Texture2DAttachment : public FramebufferAttachment
{
public:
Texture2DAttachment(Texture2D *texture, GLint level);
virtual ~Texture2DAttachment();
rx::RenderTarget *getRenderTarget();
rx::RenderTarget *getDepthStencil();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const;
virtual GLuint id() const;
virtual GLenum type() const;
virtual GLint mipLevel() const;
virtual GLint layer() const;
virtual unsigned int getTextureSerial() const;
private:
DISALLOW_COPY_AND_ASSIGN(Texture2DAttachment);
BindingPointer<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,7 +10,8 @@
#ifndef LIBGLESV2_HANDLEALLOCATOR_H_ #ifndef LIBGLESV2_HANDLEALLOCATOR_H_
#define LIBGLESV2_HANDLEALLOCATOR_H_ #define LIBGLESV2_HANDLEALLOCATOR_H_
#include "angle_gl.h" #include <GLES3/gl3.h>
#include <GLES2/gl2.h>
#include <vector> #include <vector>

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

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

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

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

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

@ -17,91 +17,518 @@
#include "libGLESv2/renderer/TextureStorage.h" #include "libGLESv2/renderer/TextureStorage.h"
#include "common/utilities.h" #include "common/utilities.h"
#include "libGLESv2/formatutils.h" #include "libGLESv2/formatutils.h"
#include "libGLESv2/FramebufferAttachment.h"
namespace gl namespace gl
{ {
unsigned int RenderbufferStorage::mCurrentSerial = 1; unsigned int RenderbufferStorage::mCurrentSerial = 1;
Renderbuffer::Renderbuffer(GLuint id, RenderbufferStorage *newStorage) RenderbufferInterface::RenderbufferInterface()
: RefCountObject(id),
mStorage(newStorage)
{ {
ASSERT(mStorage);
} }
void Renderbuffer::setStorage(RenderbufferStorage *newStorage) // The default case for classes inherited from RenderbufferInterface is not to
// need to do anything upon the reference count to the parent Renderbuffer incrementing
// or decrementing.
void RenderbufferInterface::addProxyRef(const Renderbuffer *proxy)
{ {
ASSERT(newStorage);
SafeDelete(mStorage);
mStorage = newStorage;
} }
RenderbufferStorage *Renderbuffer::getStorage() void RenderbufferInterface::releaseProxy(const Renderbuffer *proxy)
{ {
ASSERT(mStorage); }
return mStorage;
///// RenderbufferTexture2D Implementation ////////
RenderbufferTexture2D::RenderbufferTexture2D(Texture2D *texture, GLint level) : mLevel(level)
{
mTexture2D.set(texture);
}
RenderbufferTexture2D::~RenderbufferTexture2D()
{
mTexture2D.set(NULL);
}
// Textures need to maintain their own reference count for references via
// Renderbuffers acting as proxies. Here, we notify the texture of a reference.
void RenderbufferTexture2D::addProxyRef(const Renderbuffer *proxy)
{
mTexture2D->addProxyRef(proxy);
}
void RenderbufferTexture2D::releaseProxy(const Renderbuffer *proxy)
{
mTexture2D->releaseProxy(proxy);
}
rx::RenderTarget *RenderbufferTexture2D::getRenderTarget()
{
return mTexture2D->getRenderTarget(mLevel);
}
rx::RenderTarget *RenderbufferTexture2D::getDepthStencil()
{
return mTexture2D->getDepthSencil(mLevel);
}
rx::TextureStorage *RenderbufferTexture2D::getTextureStorage()
{
return mTexture2D->getNativeTexture()->getStorageInstance();
}
GLsizei RenderbufferTexture2D::getWidth() const
{
return mTexture2D->getWidth(mLevel);
}
GLsizei RenderbufferTexture2D::getHeight() const
{
return mTexture2D->getHeight(mLevel);
}
GLenum RenderbufferTexture2D::getInternalFormat() const
{
return mTexture2D->getInternalFormat(mLevel);
}
GLenum RenderbufferTexture2D::getActualFormat() const
{
return mTexture2D->getActualFormat(mLevel);
}
GLsizei RenderbufferTexture2D::getSamples() const
{
return 0;
}
unsigned int RenderbufferTexture2D::getSerial() const
{
return mTexture2D->getRenderTargetSerial(mLevel);
}
bool RenderbufferTexture2D::isTexture() const
{
return true;
}
unsigned int RenderbufferTexture2D::getTextureSerial() const
{
return mTexture2D->getTextureSerial();
}
///// RenderbufferTextureCubeMap Implementation ////////
RenderbufferTextureCubeMap::RenderbufferTextureCubeMap(TextureCubeMap *texture, GLenum faceTarget, GLint level)
: mFaceTarget(faceTarget), mLevel(level)
{
mTextureCubeMap.set(texture);
}
RenderbufferTextureCubeMap::~RenderbufferTextureCubeMap()
{
mTextureCubeMap.set(NULL);
}
// Textures need to maintain their own reference count for references via
// Renderbuffers acting as proxies. Here, we notify the texture of a reference.
void RenderbufferTextureCubeMap::addProxyRef(const Renderbuffer *proxy)
{
mTextureCubeMap->addProxyRef(proxy);
}
void RenderbufferTextureCubeMap::releaseProxy(const Renderbuffer *proxy)
{
mTextureCubeMap->releaseProxy(proxy);
}
rx::RenderTarget *RenderbufferTextureCubeMap::getRenderTarget()
{
return mTextureCubeMap->getRenderTarget(mFaceTarget, mLevel);
}
rx::RenderTarget *RenderbufferTextureCubeMap::getDepthStencil()
{
return mTextureCubeMap->getDepthStencil(mFaceTarget, mLevel);
}
rx::TextureStorage *RenderbufferTextureCubeMap::getTextureStorage()
{
return mTextureCubeMap->getNativeTexture()->getStorageInstance();
}
GLsizei RenderbufferTextureCubeMap::getWidth() const
{
return mTextureCubeMap->getWidth(mFaceTarget, mLevel);
}
GLsizei RenderbufferTextureCubeMap::getHeight() const
{
return mTextureCubeMap->getHeight(mFaceTarget, mLevel);
}
GLenum RenderbufferTextureCubeMap::getInternalFormat() const
{
return mTextureCubeMap->getInternalFormat(mFaceTarget, mLevel);
}
GLenum RenderbufferTextureCubeMap::getActualFormat() const
{
return mTextureCubeMap->getActualFormat(mFaceTarget, mLevel);
}
GLsizei RenderbufferTextureCubeMap::getSamples() const
{
return 0;
}
unsigned int RenderbufferTextureCubeMap::getSerial() const
{
return mTextureCubeMap->getRenderTargetSerial(mFaceTarget, mLevel);
}
bool RenderbufferTextureCubeMap::isTexture() const
{
return true;
}
unsigned int RenderbufferTextureCubeMap::getTextureSerial() const
{
return mTextureCubeMap->getTextureSerial();
}
///// RenderbufferTexture3DLayer Implementation ////////
RenderbufferTexture3DLayer::RenderbufferTexture3DLayer(Texture3D *texture, GLint level, GLint layer)
: mLevel(level), mLayer(layer)
{
mTexture3D.set(texture);
}
RenderbufferTexture3DLayer::~RenderbufferTexture3DLayer()
{
mTexture3D.set(NULL);
}
// Textures need to maintain their own reference count for references via
// Renderbuffers acting as proxies. Here, we notify the texture of a reference.
void RenderbufferTexture3DLayer::addProxyRef(const Renderbuffer *proxy)
{
mTexture3D->addProxyRef(proxy);
}
void RenderbufferTexture3DLayer::releaseProxy(const Renderbuffer *proxy)
{
mTexture3D->releaseProxy(proxy);
}
rx::RenderTarget *RenderbufferTexture3DLayer::getRenderTarget()
{
return mTexture3D->getRenderTarget(mLevel, mLayer);
}
rx::RenderTarget *RenderbufferTexture3DLayer::getDepthStencil()
{
return mTexture3D->getDepthStencil(mLevel, mLayer);
}
rx::TextureStorage *RenderbufferTexture3DLayer::getTextureStorage()
{
return mTexture3D->getNativeTexture()->getStorageInstance();
}
GLsizei RenderbufferTexture3DLayer::getWidth() const
{
return mTexture3D->getWidth(mLevel);
}
GLsizei RenderbufferTexture3DLayer::getHeight() const
{
return mTexture3D->getHeight(mLevel);
}
GLenum RenderbufferTexture3DLayer::getInternalFormat() const
{
return mTexture3D->getInternalFormat(mLevel);
}
GLenum RenderbufferTexture3DLayer::getActualFormat() const
{
return mTexture3D->getActualFormat(mLevel);
}
GLsizei RenderbufferTexture3DLayer::getSamples() const
{
return 0;
}
unsigned int RenderbufferTexture3DLayer::getSerial() const
{
return mTexture3D->getRenderTargetSerial(mLevel, mLayer);
}
bool RenderbufferTexture3DLayer::isTexture() const
{
return true;
}
unsigned int RenderbufferTexture3DLayer::getTextureSerial() const
{
return mTexture3D->getTextureSerial();
}
////// RenderbufferTexture2DArrayLayer Implementation //////
RenderbufferTexture2DArrayLayer::RenderbufferTexture2DArrayLayer(Texture2DArray *texture, GLint level, GLint layer)
: mLevel(level), mLayer(layer)
{
mTexture2DArray.set(texture);
}
RenderbufferTexture2DArrayLayer::~RenderbufferTexture2DArrayLayer()
{
mTexture2DArray.set(NULL);
}
void RenderbufferTexture2DArrayLayer::addProxyRef(const Renderbuffer *proxy)
{
mTexture2DArray->addProxyRef(proxy);
}
void RenderbufferTexture2DArrayLayer::releaseProxy(const Renderbuffer *proxy)
{
mTexture2DArray->releaseProxy(proxy);
}
rx::RenderTarget *RenderbufferTexture2DArrayLayer::getRenderTarget()
{
return mTexture2DArray->getRenderTarget(mLevel, mLayer);
}
rx::RenderTarget *RenderbufferTexture2DArrayLayer::getDepthStencil()
{
return mTexture2DArray->getDepthStencil(mLevel, mLayer);
}
rx::TextureStorage *RenderbufferTexture2DArrayLayer::getTextureStorage()
{
return mTexture2DArray->getNativeTexture()->getStorageInstance();
}
GLsizei RenderbufferTexture2DArrayLayer::getWidth() const
{
return mTexture2DArray->getWidth(mLevel);
}
GLsizei RenderbufferTexture2DArrayLayer::getHeight() const
{
return mTexture2DArray->getHeight(mLevel);
}
GLenum RenderbufferTexture2DArrayLayer::getInternalFormat() const
{
return mTexture2DArray->getInternalFormat(mLevel);
}
GLenum RenderbufferTexture2DArrayLayer::getActualFormat() const
{
return mTexture2DArray->getActualFormat(mLevel);
}
GLsizei RenderbufferTexture2DArrayLayer::getSamples() const
{
return 0;
}
unsigned int RenderbufferTexture2DArrayLayer::getSerial() const
{
return mTexture2DArray->getRenderTargetSerial(mLevel, mLayer);
}
bool RenderbufferTexture2DArrayLayer::isTexture() const
{
return true;
}
unsigned int RenderbufferTexture2DArrayLayer::getTextureSerial() const
{
return mTexture2DArray->getTextureSerial();
}
////// Renderbuffer Implementation //////
Renderbuffer::Renderbuffer(rx::Renderer *renderer, GLuint id, RenderbufferInterface *instance) : RefCountObject(id)
{
ASSERT(instance != NULL);
mInstance = instance;
ASSERT(renderer != NULL);
mRenderer = renderer;
}
Renderbuffer::~Renderbuffer()
{
delete mInstance;
}
// The RenderbufferInterface contained in this Renderbuffer may need to maintain
// its own reference count, so we pass it on here.
void Renderbuffer::addRef() const
{
mInstance->addProxyRef(this);
RefCountObject::addRef();
}
void Renderbuffer::release() const
{
mInstance->releaseProxy(this);
RefCountObject::release();
}
rx::RenderTarget *Renderbuffer::getRenderTarget()
{
return mInstance->getRenderTarget();
}
rx::RenderTarget *Renderbuffer::getDepthStencil()
{
return mInstance->getDepthStencil();
}
rx::TextureStorage *Renderbuffer::getTextureStorage()
{
return mInstance->getTextureStorage();
} }
GLsizei Renderbuffer::getWidth() const GLsizei Renderbuffer::getWidth() const
{ {
ASSERT(mStorage); return mInstance->getWidth();
return mStorage->getWidth();
} }
GLsizei Renderbuffer::getHeight() const GLsizei Renderbuffer::getHeight() const
{ {
ASSERT(mStorage); return mInstance->getHeight();
return mStorage->getHeight();
} }
GLenum Renderbuffer::getInternalFormat() const GLenum Renderbuffer::getInternalFormat() const
{ {
ASSERT(mStorage); return mInstance->getInternalFormat();
return mStorage->getInternalFormat();
} }
GLenum Renderbuffer::getActualFormat() const GLenum Renderbuffer::getActualFormat() const
{ {
ASSERT(mStorage); return mInstance->getActualFormat();
return mStorage->getActualFormat();
}
GLsizei Renderbuffer::getSamples() const
{
ASSERT(mStorage);
return mStorage->getSamples();
} }
GLuint Renderbuffer::getRedSize() const GLuint Renderbuffer::getRedSize() const
{ {
return gl::GetRedBits(getActualFormat()); if (gl::GetRedBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetRedBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
} }
GLuint Renderbuffer::getGreenSize() const GLuint Renderbuffer::getGreenSize() const
{ {
return gl::GetGreenBits(getActualFormat()); if (gl::GetGreenBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetGreenBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
} }
GLuint Renderbuffer::getBlueSize() const GLuint Renderbuffer::getBlueSize() const
{ {
return gl::GetBlueBits(getActualFormat()); if (gl::GetBlueBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetBlueBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
} }
GLuint Renderbuffer::getAlphaSize() const GLuint Renderbuffer::getAlphaSize() const
{ {
return gl::GetAlphaBits(getActualFormat()); if (gl::GetAlphaBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetAlphaBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
} }
GLuint Renderbuffer::getDepthSize() const GLuint Renderbuffer::getDepthSize() const
{ {
return gl::GetDepthBits(getActualFormat()); if (gl::GetDepthBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetDepthBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
} }
GLuint Renderbuffer::getStencilSize() const GLuint Renderbuffer::getStencilSize() const
{ {
return gl::GetStencilBits(getActualFormat()); if (gl::GetStencilBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetStencilBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
}
GLenum Renderbuffer::getComponentType() const
{
return gl::GetComponentType(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLenum Renderbuffer::getColorEncoding() const
{
return gl::GetColorEncoding(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLsizei Renderbuffer::getSamples() const
{
return mInstance->getSamples();
}
unsigned int Renderbuffer::getSerial() const
{
return mInstance->getSerial();
}
bool Renderbuffer::isTexture() const
{
return mInstance->isTexture();
}
unsigned int Renderbuffer::getTextureSerial() const
{
return mInstance->getTextureSerial();
}
void Renderbuffer::setStorage(RenderbufferStorage *newStorage)
{
ASSERT(newStorage != NULL);
delete mInstance;
mInstance = newStorage;
} }
RenderbufferStorage::RenderbufferStorage() : mSerial(issueSerials(1)) RenderbufferStorage::RenderbufferStorage() : mSerial(issueSerials(1))

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