refactor: move contents of OGLCompilersDLL/InitializeDll.cpp (lol at the name) into HLSL2GLSL.cpp

This commit is contained in:
Aras Pranckevicius 2013-04-14 12:47:40 +03:00
Родитель 1de50f08d0
Коммит 06ea2374d3
7 изменённых файлов: 133 добавлений и 176 удалений

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

@ -16,7 +16,6 @@ set(HEADER_FILES
hlslang/Include/Types.h
hlslang/MachineIndependent/SymbolTable.h
#hlslang/MachineIndependent/unistd.h
OGLCompilersDLL/InitializeDll.h
)
source_group("Header Files" FILES ${HEADER_FILES})
@ -52,7 +51,6 @@ set(INCLUDE_FILES
source_group("include" FILES ${INCLUDE_FILES})
set(MACHINE_INDEPENDENT_FILES
OGLCompilersDLL/InitializeDll.cpp
hlslang/MachineIndependent/HLSL2GLSL.cpp
hlslang/MachineIndependent/hlslang.l
hlslang/MachineIndependent/hlslang.y
@ -205,7 +203,6 @@ endif ()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/hlslang
${CMAKE_CURRENT_SOURCE_DIR}/hlslang/MachineIndependent
${CMAKE_CURRENT_SOURCE_DIR}/OGLCompilersDLL
)
add_library(hlsl2glsl

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

@ -1,128 +0,0 @@
// Copyright (c) The HLSL2GLSLFork Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE.txt file.
#include "InitializeDll.h"
#include "../hlslang/Include/InitializeGlobals.h"
#include "../hlslang/Include/InitializeParseContext.h"
#include "../include/hlsl2glsl.h"
#include "osinclude.h"
OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
bool InitProcess()
{
if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX)
{
//
// Function is re-entrant.
//
return true;
}
ThreadInitializeIndex = OS_AllocTLSIndex();
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
{
assert(0 && "InitProcess(): Failed to allocate TLS area for init flag");
return false;
}
if (!InitializePoolIndex())
{
assert(0 && "InitProcess(): Failed to initalize global pool");
return false;
}
if (!InitializeParseContextIndex())
{
assert(0 && "InitProcess(): Failed to initalize parse context");
return false;
}
InitThread();
return true;
}
bool InitThread()
{
//
// This function is re-entrant
//
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
{
assert(0 && "InitThread(): Process hasn't been initalised.");
return false;
}
if (OS_GetTLSValue(ThreadInitializeIndex) != 0)
return true;
InitializeGlobalPools();
if (!InitializeGlobalParseContext())
return false;
if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)1))
{
assert(0 && "InitThread(): Unable to set init flag.");
return false;
}
return true;
}
bool DetachThread()
{
bool success = true;
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
return true;
//
// Function is re-entrant and this thread may not have been initalised.
//
if (OS_GetTLSValue(ThreadInitializeIndex) != 0)
{
if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)0))
{
assert(0 && "DetachThread(): Unable to clear init flag.");
success = false;
}
FreeGlobalPools();
if (!FreeParseContext())
success = false;
}
return success;
}
bool DetachProcess()
{
bool success = true;
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
return true;
extern void Hlsl2Glsl_Finalize();
Hlsl2Glsl_Finalize();
success = DetachThread();
FreePoolIndex();
if (!FreeParseContextIndex())
success = false;
OS_FreeTLSIndex(ThreadInitializeIndex);
ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
return success;
}

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

@ -1,16 +0,0 @@
// Copyright (c) The HLSL2GLSLFork Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE.txt file.
#ifndef __INITIALIZEDLL_H
#define __INITIALIZEDLL_H
bool InitProcess();
bool InitThread();
bool DetachThread();
bool DetachProcess();
#endif // __INITIALIZEDLL_H

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

@ -78,7 +78,7 @@
<ClCompile>
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>hlslang;hlslang\MachineIndependent;hlslang\OSDependent\Windows;OGLCompilersDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>hlslang;hlslang\MachineIndependent;hlslang\OSDependent\Windows;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;WIN32;_CONSOLE;_LIB;GENERIC_COMPILER;_HAS_ITERATOR_DEBUGGING=0;_CRT_SECURE_NO_DEPRECATE;_HAS_EXCEPTIONS=0;_SECURE_SCL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>
</ExceptionHandling>
@ -111,7 +111,7 @@
<ClCompile>
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>hlslang;hlslang\MachineIndependent;hlslang\OSDependent\Windows;OGLCompilersDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>hlslang;hlslang\MachineIndependent;hlslang\OSDependent\Windows;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;WIN32;_CONSOLE;_LIB;GENERIC_COMPILER;_HAS_ITERATOR_DEBUGGING=0;_CRT_SECURE_NO_DEPRECATE;_HAS_EXCEPTIONS=0;_SECURE_SCL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>
</ExceptionHandling>
@ -143,7 +143,7 @@
<Optimization>MinSpace</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>hlslang;hlslang\MachineIndependent;hlslang\OSDependent\Windows;OGLCompilersDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>hlslang;hlslang\MachineIndependent;hlslang\OSDependent\Windows;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;WIN32;_CONSOLE;_LIB;GENERIC_COMPILER;_COMPILER;_HAS_ITERATOR_DEBUGGING=0;_CRT_SECURE_NO_DEPRECATE;_HAS_EXCEPTIONS=0;_SECURE_SCL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>
@ -182,7 +182,7 @@
<Optimization>MinSpace</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>hlslang;hlslang\MachineIndependent;hlslang\OSDependent\Windows;OGLCompilersDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>hlslang;hlslang\MachineIndependent;hlslang\OSDependent\Windows;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;WIN32;_CONSOLE;_LIB;GENERIC_COMPILER;_COMPILER;_HAS_ITERATOR_DEBUGGING=0;_CRT_SECURE_NO_DEPRECATE;_HAS_EXCEPTIONS=0;_SECURE_SCL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>
@ -217,7 +217,6 @@
<ClCompile Include="hlslang\MachineIndependent\HLSL2GLSL.cpp" />
<ClCompile Include="hlslang\MachineIndependent\InfoSink.cpp" />
<ClCompile Include="hlslang\MachineIndependent\Initialize.cpp" />
<ClCompile Include="OGLCompilersDLL\InitializeDll.cpp" />
<ClCompile Include="hlslang\MachineIndependent\Intermediate.cpp" />
<ClCompile Include="hlslang\MachineIndependent\intermOut.cpp" />
<ClCompile Include="hlslang\MachineIndependent\IntermTraverse.cpp" />
@ -351,7 +350,6 @@ rename %(RootDir)%(Directory)%(Filename)_tab.c Gen_%(Filename)_tab.cpp
<ClInclude Include="hlslang\Include\Common.h" />
<ClInclude Include="hlslang\Include\ConstantUnion.h" />
<ClInclude Include="hlslang\Include\InfoSink.h" />
<ClInclude Include="OGLCompilersDLL\InitializeDll.h" />
<ClInclude Include="hlslang\Include\InitializeGlobals.h" />
<ClInclude Include="hlslang\Include\InitializeParseContext.h" />
<ClInclude Include="hlslang\Include\intermediate.h" />

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

@ -43,9 +43,6 @@
<ClCompile Include="hlslang\MachineIndependent\Initialize.cpp">
<Filter>Machine Independent</Filter>
</ClCompile>
<ClCompile Include="OGLCompilersDLL\InitializeDll.cpp">
<Filter>Machine Independent</Filter>
</ClCompile>
<ClCompile Include="hlslang\MachineIndependent\Intermediate.cpp">
<Filter>Machine Independent</Filter>
</ClCompile>
@ -195,9 +192,6 @@
<ClInclude Include="hlslang\Include\InfoSink.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="OGLCompilersDLL\InitializeDll.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="hlslang\Include\InitializeGlobals.h">
<Filter>Header Files</Filter>
</ClInclude>

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

@ -24,7 +24,6 @@
2B951CAB1135197300DBAF46 /* hlslSupportLib.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3AC10E040AF103660045E29C /* hlslSupportLib.cpp */; };
2B951CAC1135197300DBAF46 /* InfoSink.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3AC10E270AF106F40045E29C /* InfoSink.cpp */; };
2B951CAD1135197300DBAF46 /* Initialize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3AC10E280AF106F40045E29C /* Initialize.cpp */; };
2B951CAE1135197300DBAF46 /* InitializeDll.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3A9176400A643D5A00E8641B /* InitializeDll.cpp */; };
2B951CAF1135197300DBAF46 /* Intermediate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3AC10E290AF106F40045E29C /* Intermediate.cpp */; };
2B951CB01135197300DBAF46 /* intermOut.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3AC10E2A0AF106F40045E29C /* intermOut.cpp */; };
2B951CB11135197300DBAF46 /* IntermTraverse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3AC10E2B0AF106F40045E29C /* IntermTraverse.cpp */; };
@ -49,8 +48,6 @@
2B951CC011351A2500DBAF46 /* hlsl2glsl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = hlsl2glsl.h; path = include/hlsl2glsl.h; sourceTree = SOURCE_ROOT; };
2B951CE1113527BC00DBAF46 /* hlslang.l */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.lex; name = hlslang.l; path = hlslang/MachineIndependent/hlslang.l; sourceTree = SOURCE_ROOT; };
2B951CE2113527BC00DBAF46 /* hlslang.y */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.yacc; name = hlslang.y; path = hlslang/MachineIndependent/hlslang.y; sourceTree = SOURCE_ROOT; };
3A9176400A643D5A00E8641B /* InitializeDll.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = InitializeDll.cpp; sourceTree = "<group>"; };
3A9176410A643D5A00E8641B /* InitializeDll.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = InitializeDll.h; sourceTree = "<group>"; };
3AC10DD20AF103020045E29C /* BaseTypes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = BaseTypes.h; path = hlslang/Include/BaseTypes.h; sourceTree = "<group>"; };
3AC10DD30AF103020045E29C /* Common.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Common.h; path = hlslang/Include/Common.h; sourceTree = "<group>"; };
3AC10DD50AF103020045E29C /* InfoSink.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = InfoSink.h; path = hlslang/Include/InfoSink.h; sourceTree = "<group>"; };
@ -154,20 +151,10 @@
3AC10DB00AF1027A0045E29C /* GenericCodeGen */,
3AC10DB90AF102990045E29C /* MachineIndependent */,
3AC10DC20AF102BB0045E29C /* OSDependent */,
3A91763F0A643D5A00E8641B /* OGLCompilersDLL */,
);
name = hlslang;
sourceTree = "<group>";
};
3A91763F0A643D5A00E8641B /* OGLCompilersDLL */ = {
isa = PBXGroup;
children = (
3A9176400A643D5A00E8641B /* InitializeDll.cpp */,
3A9176410A643D5A00E8641B /* InitializeDll.h */,
);
path = OGLCompilersDLL;
sourceTree = "<group>";
};
3AC10DB00AF1027A0045E29C /* GenericCodeGen */ = {
isa = PBXGroup;
children = (
@ -409,7 +396,6 @@
2B951CAB1135197300DBAF46 /* hlslSupportLib.cpp in Sources */,
2B951CAC1135197300DBAF46 /* InfoSink.cpp in Sources */,
2B951CAD1135197300DBAF46 /* Initialize.cpp in Sources */,
2B951CAE1135197300DBAF46 /* InitializeDll.cpp in Sources */,
2B951CAF1135197300DBAF46 /* Intermediate.cpp in Sources */,
2B951CB01135197300DBAF46 /* intermOut.cpp in Sources */,
2B951CB11135197300DBAF46 /* IntermTraverse.cpp in Sources */,

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

@ -7,8 +7,6 @@
#include "ParseHelper.h"
#include "RemoveTree.h"
#include "InitializeDll.h"
#include "../../include/hlsl2glsl.h"
#include "Initialize.h"
#include "../GLSLCodeGen/hlslSupportLib.h"
@ -16,8 +14,136 @@
#include "../GLSLCodeGen/hlslCrossCompiler.h"
#include "../GLSLCodeGen/hlslLinker.h"
#include "../Include/InitializeGlobals.h"
#include "../Include/InitializeParseContext.h"
#include "osinclude.h"
// A symbol table for each language. Each has a different set of built-ins, and we want to preserve that
// -----------------------------------------------------------------------------
static OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
static bool InitThread()
{
//
// This function is re-entrant
//
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
{
assert(0 && "InitThread(): Process hasn't been initalised.");
return false;
}
if (OS_GetTLSValue(ThreadInitializeIndex) != 0)
return true;
InitializeGlobalPools();
if (!InitializeGlobalParseContext())
return false;
if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)1))
{
assert(0 && "InitThread(): Unable to set init flag.");
return false;
}
return true;
}
static bool InitProcess()
{
if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX)
{
//
// Function is re-entrant.
//
return true;
}
ThreadInitializeIndex = OS_AllocTLSIndex();
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
{
assert(0 && "InitProcess(): Failed to allocate TLS area for init flag");
return false;
}
if (!InitializePoolIndex())
{
assert(0 && "InitProcess(): Failed to initalize global pool");
return false;
}
if (!InitializeParseContextIndex())
{
assert(0 && "InitProcess(): Failed to initalize parse context");
return false;
}
InitThread();
return true;
}
static bool DetachThread()
{
bool success = true;
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
return true;
//
// Function is re-entrant and this thread may not have been initalised.
//
if (OS_GetTLSValue(ThreadInitializeIndex) != 0)
{
if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)0))
{
assert(0 && "DetachThread(): Unable to clear init flag.");
success = false;
}
FreeGlobalPools();
if (!FreeParseContext())
success = false;
}
return success;
}
static bool DetachProcess()
{
bool success = true;
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
return true;
extern void Hlsl2Glsl_Finalize();
Hlsl2Glsl_Finalize();
success = DetachThread();
FreePoolIndex();
if (!FreeParseContextIndex())
success = false;
OS_FreeTLSIndex(ThreadInitializeIndex);
ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
return success;
}
// -----------------------------------------------------------------------------
// A symbol table for each language. Each has a different set of built-ins, and we want to preserve that
// from compile to compile.
TSymbolTable SymbolTables[EShLangCount];