зеркало из https://github.com/AvaloniaUI/angle.git
Added GLSL backend for ESSL translator.
Review URL: http://codereview.appspot.com/698041 git-svn-id: https://angleproject.googlecode.com/svn/trunk@69 736b8ea6-26fd-11df-bfd4-992fa37f6226
This commit is contained in:
Родитель
32e58cdedb
Коммит
76b820852b
|
@ -57,11 +57,31 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libEGL", "..\src\libEGL\lib
|
|||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGLESv2", "..\src\libGLESv2\libGLESv2.vcproj", "{B5871A7A-968C-42E3-A33B-981E6F448E78}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7} = {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_glsl", "..\src\compiler\translator_glsl.vcproj", "{65DB6E65-00E6-4533-8446-5F623BD94909}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} = {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compiler", "..\src\compiler\compiler.vcproj", "{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_hlsl", "..\src\compiler\translator_hlsl.vcproj", "{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} = {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "essl_to_glsl", "translator\essl_to_glsl.vcproj", "{EADEBCCD-65ED-45D1-9E06-949A21EBAB9E}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{65DB6E65-00E6-4533-8446-5F623BD94909} = {65DB6E65-00E6-4533-8446-5F623BD94909}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "essl_to_hlsl", "translator\essl_to_hlsl.vcproj", "{E12EA115-EBC7-47C2-B651-30A0CE986025}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7} = {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_common", "..\src\compiler\translator_common.vcproj", "{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -117,6 +137,22 @@ Global
|
|||
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.Build.0 = Release|Win32
|
||||
{65DB6E65-00E6-4533-8446-5F623BD94909}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{65DB6E65-00E6-4533-8446-5F623BD94909}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{65DB6E65-00E6-4533-8446-5F623BD94909}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{65DB6E65-00E6-4533-8446-5F623BD94909}.Release|Win32.Build.0 = Release|Win32
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.Build.0 = Release|Win32
|
||||
{EADEBCCD-65ED-45D1-9E06-949A21EBAB9E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{EADEBCCD-65ED-45D1-9E06-949A21EBAB9E}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{EADEBCCD-65ED-45D1-9E06-949A21EBAB9E}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{EADEBCCD-65ED-45D1-9E06-949A21EBAB9E}.Release|Win32.Build.0 = Release|Win32
|
||||
{E12EA115-EBC7-47C2-B651-30A0CE986025}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E12EA115-EBC7-47C2-B651-30A0CE986025}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E12EA115-EBC7-47C2-B651-30A0CE986025}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{E12EA115-EBC7-47C2-B651-30A0CE986025}.Release|Win32.Build.0 = Release|Win32
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|Win32.ActiveCfg = Release|Win32
|
||||
|
|
|
@ -0,0 +1,193 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="essl_to_glsl"
|
||||
ProjectGUID="{EADEBCCD-65ED-45D1-9E06-949A21EBAB9E}"
|
||||
RootNamespace="essl_to_glsl"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\src\common\debug.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\translator.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,193 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="essl_to_hlsl"
|
||||
ProjectGUID="{E12EA115-EBC7-47C2-B651-30A0CE986025}"
|
||||
RootNamespace="essl_to_hlsl"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\src\common\debug.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\translator.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,243 @@
|
|||
//
|
||||
// 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 "GLSLANG/ShaderLang.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
//
|
||||
// Return codes from main.
|
||||
//
|
||||
enum TFailCode {
|
||||
ESuccess = 0,
|
||||
EFailUsage,
|
||||
EFailCompile,
|
||||
EFailLink,
|
||||
EFailCompilerCreate,
|
||||
EFailLinkerCreate
|
||||
};
|
||||
|
||||
static EShLanguage FindLanguage(char *lang);
|
||||
bool CompileFile(char *fileName, ShHandle, int, const TBuiltInResource*);
|
||||
void usage();
|
||||
void FreeFileData(char **data);
|
||||
char** ReadFileData(char *fileName);
|
||||
void LogMsg(char* msg, const char* name, const int num, const char* logName);
|
||||
int ShOutputMultipleStrings(char ** );
|
||||
//Added to accomodate the multiple strings.
|
||||
int OutputMultipleStrings = 1;
|
||||
|
||||
//
|
||||
// Set up the per compile resources
|
||||
//
|
||||
void GenerateResources(TBuiltInResource& resources)
|
||||
{
|
||||
resources.maxVertexAttribs = 8;
|
||||
resources.maxVertexUniformVectors = 128;
|
||||
resources.maxVaryingVectors = 8;
|
||||
resources.maxVertexTextureImageUnits = 0;
|
||||
resources.maxCombinedTextureImageUnits = 8;
|
||||
resources.maxTextureImageUnits = 8;
|
||||
resources.maxFragmentUniformVectors = 16;
|
||||
resources.maxDrawBuffers = 1;
|
||||
}
|
||||
|
||||
int C_DECL main(int argc, char* argv[])
|
||||
{
|
||||
int numCompilers = 0;
|
||||
bool compileFailed = false;
|
||||
int debugOptions = 0;
|
||||
int i;
|
||||
|
||||
ShHandle linker = 0;
|
||||
ShHandle uniformMap = 0;
|
||||
ShHandle compilers[EShLangCount];
|
||||
|
||||
ShInitialize();
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
for (; argc >= 1; argc--, argv++) {
|
||||
if (argv[0][0] == '-' || argv[0][0] == '/') {
|
||||
switch (argv[0][1]) {
|
||||
case 'i': debugOptions |= EDebugOpIntermediate; break;
|
||||
case 'o': debugOptions |= EDebugOpObjectCode; break;
|
||||
default: usage(); return EFailUsage;
|
||||
}
|
||||
} else {
|
||||
compilers[numCompilers] = ShConstructCompiler(FindLanguage(argv[0]), debugOptions);
|
||||
if (compilers[numCompilers] == 0)
|
||||
return EFailCompilerCreate;
|
||||
++numCompilers;
|
||||
|
||||
TBuiltInResource resources;
|
||||
GenerateResources(resources);
|
||||
if (!CompileFile(argv[0], compilers[numCompilers-1], debugOptions, &resources))
|
||||
compileFailed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!numCompilers) {
|
||||
usage();
|
||||
return EFailUsage;
|
||||
}
|
||||
|
||||
for (i = 0; i < numCompilers; ++i) {
|
||||
LogMsg("BEGIN", "COMPILER", i, "INFO LOG");
|
||||
puts(ShGetInfoLog(compilers[i]));
|
||||
LogMsg("END", "COMPILER", i, "INFO LOG");
|
||||
}
|
||||
if ((debugOptions & EDebugOpObjectCode) != 0) {
|
||||
for (i = 0; i < numCompilers; ++i) {
|
||||
LogMsg("BEGIN", "COMPILER", i, "OBJ CODE");
|
||||
puts(ShGetObjectCode(compilers[i]));
|
||||
LogMsg("END", "COMPILER", i, "OBJ CODE");
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < numCompilers; ++i)
|
||||
ShDestruct(compilers[i]);
|
||||
|
||||
return compileFailed ? EFailCompile : ESuccess;
|
||||
}
|
||||
|
||||
//
|
||||
// Deduce the language from the filename. Files must end in one of the
|
||||
// following extensions:
|
||||
//
|
||||
// .frag* = fragment programs
|
||||
// .vert* = vertex programs
|
||||
//
|
||||
static EShLanguage FindLanguage(char *name)
|
||||
{
|
||||
if (!name)
|
||||
return EShLangFragment;
|
||||
|
||||
char *ext = strrchr(name, '.');
|
||||
|
||||
if (ext && strcmp(ext, ".sl") == 0)
|
||||
for (; ext > name && ext[0] != '.'; ext--);
|
||||
|
||||
if (ext = strrchr(name, '.')) {
|
||||
if (strncmp(ext, ".frag", 4) == 0) return EShLangFragment;
|
||||
if (strncmp(ext, ".vert", 4) == 0) return EShLangVertex;
|
||||
}
|
||||
|
||||
return EShLangFragment;
|
||||
}
|
||||
|
||||
//
|
||||
// Read a file's data into a string, and compile it using ShCompile
|
||||
//
|
||||
bool CompileFile(char *fileName, ShHandle compiler, int debugOptions, const TBuiltInResource *resources)
|
||||
{
|
||||
int ret;
|
||||
char **data = ReadFileData(fileName);
|
||||
|
||||
if (!data)
|
||||
return false;
|
||||
|
||||
ret = ShCompile(compiler, data, OutputMultipleStrings, EShOptNone, resources, debugOptions);
|
||||
|
||||
FreeFileData(data);
|
||||
|
||||
return ret ? true : false;
|
||||
}
|
||||
|
||||
//
|
||||
// print usage to stdout
|
||||
//
|
||||
void usage()
|
||||
{
|
||||
printf("Usage: translate [-i -o] file1 file2 ...\n"
|
||||
"Where: filename = filename ending in .frag or .vert\n"
|
||||
" -i = print intermediate tree\n"
|
||||
" -o = print translated code\n");
|
||||
}
|
||||
|
||||
//
|
||||
// Malloc a string of sufficient size and read a string into it.
|
||||
//
|
||||
# define MAX_SOURCE_STRINGS 5
|
||||
char** ReadFileData(char *fileName)
|
||||
{
|
||||
FILE* in = fopen(fileName, "r");
|
||||
char* fdata = 0;
|
||||
int count = 0;
|
||||
char** return_data = (char**)malloc(MAX_SOURCE_STRINGS+1);
|
||||
|
||||
if (!in) {
|
||||
printf("Error: unable to open input file: %s\n", fileName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (fgetc(in) != EOF)
|
||||
count++;
|
||||
|
||||
fseek(in, 0, SEEK_SET);
|
||||
|
||||
if (!(fdata = (char*)malloc(count+2))) {
|
||||
printf("Error allocating memory\n");
|
||||
return 0;
|
||||
}
|
||||
if (fread(fdata, 1, count, in) != count) {
|
||||
printf("Error reading input file: %s\n", fileName);
|
||||
return 0;
|
||||
}
|
||||
fdata[count] = '\0';
|
||||
fclose(in);
|
||||
if (count == 0){
|
||||
return_data[0] = (char*)malloc(count+2);
|
||||
return_data[0][0] = '\0';
|
||||
OutputMultipleStrings = 0;
|
||||
return return_data;
|
||||
}
|
||||
|
||||
int len = (int)(ceil)((float)count / (float)OutputMultipleStrings);
|
||||
int ptr_len = 0, i = 0;
|
||||
while (count > 0) {
|
||||
return_data[i] = (char*)malloc(len+2);
|
||||
memcpy(return_data[i], fdata+ptr_len, len);
|
||||
return_data[i][len] = '\0';
|
||||
count -= (len);
|
||||
ptr_len += (len);
|
||||
if (count < len){
|
||||
if(count == 0){
|
||||
OutputMultipleStrings = (i+1);
|
||||
break;
|
||||
}
|
||||
len = count;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return return_data;
|
||||
}
|
||||
|
||||
void FreeFileData(char** data)
|
||||
{
|
||||
for(int i=0;i<OutputMultipleStrings;i++)
|
||||
free(data[i]);
|
||||
}
|
||||
|
||||
void LogMsg(char* msg, const char* name, const int num, const char* logName)
|
||||
{
|
||||
printf(num >= 0 ? "#### %s %s %d %s ####\n" :
|
||||
"#### %s %s INFO LOG ####\n", msg, name, num, logName);
|
||||
}
|
||||
|
||||
int ShOutputMultipleStrings(char** argv)
|
||||
{
|
||||
if(!(abs(OutputMultipleStrings = atoi(*argv)))||((OutputMultipleStrings >5 || OutputMultipleStrings < 1)? 1:0)){
|
||||
printf("Invalid Command Line Argument after -c option.\n"
|
||||
"Usage: -c <integer> where integer =[1,5]\n"
|
||||
"This option must be specified before the input file path\n");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
|
@ -1,17 +1,27 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual C++ Express 2008
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libEGL", "libEGL\libEGL.vcproj", "{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{B5871A7A-968C-42E3-A33B-981E6F448E78} = {B5871A7A-968C-42E3-A33B-981E6F448E78}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGLESv2", "libGLESv2\libGLESv2.vcproj", "{B5871A7A-968C-42E3-A33B-981E6F448E78}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7} = {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_glsl", "compiler\translator_glsl.vcproj", "{65DB6E65-00E6-4533-8446-5F623BD94909}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} = {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compiler", "compiler\compiler.vcproj", "{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_hlsl", "compiler\translator_hlsl.vcproj", "{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} = {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_common", "compiler\translator_common.vcproj", "{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -27,6 +37,14 @@ Global
|
|||
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.Build.0 = Release|Win32
|
||||
{65DB6E65-00E6-4533-8446-5F623BD94909}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{65DB6E65-00E6-4533-8446-5F623BD94909}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{65DB6E65-00E6-4533-8446-5F623BD94909}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{65DB6E65-00E6-4533-8446-5F623BD94909}.Release|Win32.Build.0 = Release|Win32
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.Build.0 = Release|Win32
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|Win32.ActiveCfg = Release|Win32
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
//
|
||||
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "Common.h"
|
||||
#include "ShHandle.h"
|
||||
|
||||
//
|
||||
// Here is where real machine specific high-level data would be defined.
|
||||
//
|
||||
class TGenericCompiler : public TCompiler {
|
||||
public:
|
||||
TGenericCompiler(EShLanguage l, int dOptions) : TCompiler(l, infoSink), debugOptions(dOptions) { }
|
||||
virtual bool compile(TIntermNode* root);
|
||||
TInfoSink infoSink;
|
||||
int debugOptions;
|
||||
};
|
||||
|
||||
//
|
||||
// This function must be provided to create the actual
|
||||
// compile object used by higher level code. It returns
|
||||
// a subclass of TCompiler.
|
||||
//
|
||||
TCompiler* ConstructCompiler(EShLanguage language, int debugOptions)
|
||||
{
|
||||
return new TGenericCompiler(language, debugOptions);
|
||||
}
|
||||
|
||||
//
|
||||
// Delete the compiler made by ConstructCompiler
|
||||
//
|
||||
void DeleteCompiler(TCompiler* compiler)
|
||||
{
|
||||
delete compiler;
|
||||
}
|
||||
|
||||
//
|
||||
// Generate code from the given parse tree
|
||||
//
|
||||
bool TGenericCompiler::compile(TIntermNode *root)
|
||||
{
|
||||
haveValidObjectCode = true;
|
||||
|
||||
return haveValidObjectCode;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
// 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 "TranslatorGLSL.h"
|
||||
|
||||
//
|
||||
// This function must be provided to create the actual
|
||||
// compile object used by higher level code. It returns
|
||||
// a subclass of TCompiler.
|
||||
//
|
||||
TCompiler* ConstructCompiler(EShLanguage language, int debugOptions)
|
||||
{
|
||||
return new TranslatorGLSL(language, debugOptions);
|
||||
}
|
||||
|
||||
//
|
||||
// Delete the compiler made by ConstructCompiler
|
||||
//
|
||||
void DeleteCompiler(TCompiler* compiler)
|
||||
{
|
||||
delete compiler;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
// 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 "TranslatorHLSL.h"
|
||||
|
||||
//
|
||||
// This function must be provided to create the actual
|
||||
// compile object used by higher level code. It returns
|
||||
// a subclass of TCompiler.
|
||||
//
|
||||
TCompiler* ConstructCompiler(EShLanguage language, int debugOptions)
|
||||
{
|
||||
return new TranslatorHLSL(language, debugOptions);
|
||||
}
|
||||
|
||||
//
|
||||
// Delete the compiler made by ConstructCompiler
|
||||
//
|
||||
void DeleteCompiler(TCompiler* compiler)
|
||||
{
|
||||
delete compiler;
|
||||
}
|
|
@ -272,7 +272,7 @@ public:
|
|||
return returnValue;
|
||||
}
|
||||
|
||||
TBasicType getType() { return type; }
|
||||
TBasicType getType() const { return type; }
|
||||
private:
|
||||
|
||||
union {
|
||||
|
|
|
@ -16,10 +16,9 @@
|
|||
//
|
||||
class TGenericLinker : public TLinker {
|
||||
public:
|
||||
TGenericLinker(EShExecutable e, int dOptions) : TLinker(e, infoSink), debugOptions(dOptions) { }
|
||||
TGenericLinker(EShExecutable e, int dOptions) : TLinker(e), debugOptions(dOptions) { }
|
||||
bool link(TCompilerList&, TUniformMap*) { return true; }
|
||||
void getAttributeBindings(ShBindingTable const **t) const { }
|
||||
TInfoSink infoSink;
|
||||
void getAttributeBindings(ShBindingTable const **t) const { }
|
||||
int debugOptions;
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,469 @@
|
|||
//
|
||||
// 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 "OutputGLSL.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
TString getTypeName(const TType& type)
|
||||
{
|
||||
TInfoSinkBase out;
|
||||
if (type.isMatrix())
|
||||
{
|
||||
out << "mat";
|
||||
out << type.getNominalSize();
|
||||
}
|
||||
else if (type.isArray())
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
else if (type.isVector())
|
||||
{
|
||||
switch (type.getBasicType())
|
||||
{
|
||||
case EbtFloat: out << "vec"; break;
|
||||
case EbtInt: out << "ivec"; break;
|
||||
case EbtBool: out << "bvec"; break;
|
||||
default: UNREACHABLE(); break;
|
||||
}
|
||||
out << type.getNominalSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type.getBasicType() == EbtStruct)
|
||||
out << type.getTypeName();
|
||||
else
|
||||
out << type.getBasicString();
|
||||
}
|
||||
return TString(out.c_str());
|
||||
}
|
||||
|
||||
TString getUnmangledFunctionName(const TString& mangledName)
|
||||
{
|
||||
return TString(mangledName.c_str(), mangledName.find_first_of('('));
|
||||
}
|
||||
|
||||
TString getIndentationString(int depth)
|
||||
{
|
||||
TString indentation(depth, ' ');
|
||||
return indentation;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
TOutputGLSL::TOutputGLSL(TParseContext &context)
|
||||
: TIntermTraverser(true, true, true),
|
||||
writeFullSymbol(false),
|
||||
parseContext(context)
|
||||
{
|
||||
}
|
||||
|
||||
void TOutputGLSL::header()
|
||||
{
|
||||
TInfoSinkBase& out = objSink();
|
||||
|
||||
TSymbolTableLevel* symbols = parseContext.symbolTable.getGlobalLevel();
|
||||
for (TSymbolTableLevel::const_iterator symbolIter = symbols->begin(); symbolIter != symbols->end(); ++symbolIter)
|
||||
{
|
||||
const TSymbol* symbol = symbolIter->second;
|
||||
if (!symbol->isVariable())
|
||||
continue;
|
||||
|
||||
const TVariable* variable = static_cast<const TVariable*>(symbol);
|
||||
const TString& name = variable->getName();
|
||||
const TType& type = variable->getType();
|
||||
TQualifier qualifier = type.getQualifier();
|
||||
|
||||
//symbol->dump(parseContext.infoSink);
|
||||
}
|
||||
}
|
||||
|
||||
void TOutputGLSL::writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr)
|
||||
{
|
||||
TInfoSinkBase& out = objSink();
|
||||
if (visit == PreVisit && preStr)
|
||||
{
|
||||
out << preStr;
|
||||
}
|
||||
else if (visit == InVisit && inStr)
|
||||
{
|
||||
out << inStr;
|
||||
}
|
||||
else if (visit == PostVisit && postStr)
|
||||
{
|
||||
out << postStr;
|
||||
}
|
||||
}
|
||||
|
||||
void TOutputGLSL::visitSymbol(TIntermSymbol* node)
|
||||
{
|
||||
TInfoSinkBase& out = objSink();
|
||||
if (writeFullSymbol)
|
||||
{
|
||||
TQualifier qualifier = node->getQualifier();
|
||||
if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal))
|
||||
out << node->getQualifierString() << " ";
|
||||
|
||||
out << getTypeName(node->getType()) << " ";
|
||||
}
|
||||
out << node->getSymbol();
|
||||
}
|
||||
|
||||
void TOutputGLSL::visitConstantUnion(TIntermConstantUnion* node)
|
||||
{
|
||||
TInfoSinkBase& out = objSink();
|
||||
|
||||
TType type = node->getType();
|
||||
int size = type.getObjectSize();
|
||||
if (size > 1)
|
||||
out << getTypeName(type) << "(";
|
||||
for (int i = 0; i < size; ++i) {
|
||||
const constUnion& data = node->getUnionArrayPointer()[i];
|
||||
switch (data.getType())
|
||||
{
|
||||
case EbtFloat: out << data.getFConst(); break;
|
||||
case EbtInt: out << data.getIConst(); break;
|
||||
case EbtBool: out << data.getBConst(); break;
|
||||
default: UNREACHABLE(); break;
|
||||
}
|
||||
if (i != size - 1)
|
||||
out << ", ";
|
||||
}
|
||||
if (size > 1)
|
||||
out << ")";
|
||||
}
|
||||
|
||||
bool TOutputGLSL::visitBinary(Visit visit, TIntermBinary* node)
|
||||
{
|
||||
bool visitChildren = true;
|
||||
TInfoSinkBase& out = objSink();
|
||||
switch (node->getOp())
|
||||
{
|
||||
case EOpAssign: writeTriplet(visit, NULL, " = ", NULL); break;
|
||||
case EOpInitialize:
|
||||
if (visit == InVisit) {
|
||||
out << " = ";
|
||||
writeFullSymbol= false;
|
||||
}
|
||||
break;
|
||||
case EOpAddAssign: writeTriplet(visit, NULL, " += ", NULL); break;
|
||||
case EOpSubAssign: UNIMPLEMENTED(); break;
|
||||
case EOpMulAssign: UNIMPLEMENTED(); break;
|
||||
case EOpVectorTimesMatrixAssign: UNIMPLEMENTED(); break;
|
||||
case EOpVectorTimesScalarAssign: UNIMPLEMENTED(); break;
|
||||
case EOpMatrixTimesScalarAssign: UNIMPLEMENTED(); break;
|
||||
case EOpMatrixTimesMatrixAssign: UNIMPLEMENTED(); break;
|
||||
case EOpDivAssign: UNIMPLEMENTED(); break;
|
||||
|
||||
case EOpIndexDirect: writeTriplet(visit, NULL, "[", "]"); break;
|
||||
case EOpIndexIndirect: UNIMPLEMENTED(); break;
|
||||
case EOpIndexDirectStruct:
|
||||
if (visit == InVisit)
|
||||
{
|
||||
out << ".";
|
||||
// TODO(alokp): ASSERT
|
||||
out << node->getType().getFieldName();
|
||||
visitChildren = false;
|
||||
}
|
||||
break;
|
||||
case EOpVectorSwizzle:
|
||||
if (visit == InVisit)
|
||||
{
|
||||
out << ".";
|
||||
TIntermAggregate* rightChild = node->getRight()->getAsAggregate();
|
||||
TIntermSequence& sequence = rightChild->getSequence();
|
||||
for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); ++sit)
|
||||
{
|
||||
TIntermConstantUnion* element = (*sit)->getAsConstantUnion();
|
||||
ASSERT(element->getBasicType() == EbtInt);
|
||||
ASSERT(element->getNominalSize() == 1);
|
||||
const constUnion& data = element->getUnionArrayPointer()[0];
|
||||
ASSERT(data.getType() == EbtInt);
|
||||
switch (data.getIConst())
|
||||
{
|
||||
case 0: out << "x"; break;
|
||||
case 1: out << "y"; break;
|
||||
case 2: out << "z"; break;
|
||||
case 3: out << "w"; break;
|
||||
default: UNREACHABLE(); break;
|
||||
}
|
||||
}
|
||||
visitChildren = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case EOpAdd: writeTriplet(visit, "(", " + ", ")"); break;
|
||||
case EOpSub: writeTriplet(visit, "(", " - ", ")"); break;
|
||||
case EOpMul: writeTriplet(visit, "(", " * ", ")"); break;
|
||||
case EOpDiv: writeTriplet(visit, "(", " / ", ")"); break;
|
||||
case EOpMod: UNIMPLEMENTED(); break;
|
||||
case EOpEqual: UNIMPLEMENTED(); break;
|
||||
case EOpNotEqual: UNIMPLEMENTED(); break;
|
||||
case EOpLessThan: writeTriplet(visit, "(", " < ", ")"); break;
|
||||
case EOpGreaterThan: writeTriplet(visit, NULL, " > ", NULL); break;
|
||||
case EOpLessThanEqual: UNIMPLEMENTED(); break;
|
||||
case EOpGreaterThanEqual: UNIMPLEMENTED(); break;
|
||||
|
||||
// Notice the fall-through.
|
||||
case EOpVectorTimesScalar:
|
||||
case EOpVectorTimesMatrix:
|
||||
case EOpMatrixTimesVector:
|
||||
case EOpMatrixTimesScalar:
|
||||
case EOpMatrixTimesMatrix:
|
||||
writeTriplet(visit, "(", " * ", ")");
|
||||
break;
|
||||
|
||||
case EOpLogicalOr: writeTriplet(visit, "(", " || ", ")"); break;
|
||||
case EOpLogicalXor: UNIMPLEMENTED(); break;
|
||||
case EOpLogicalAnd: UNIMPLEMENTED(); break;
|
||||
default: UNREACHABLE(); break;
|
||||
}
|
||||
|
||||
return visitChildren;
|
||||
}
|
||||
|
||||
bool TOutputGLSL::visitUnary(Visit visit, TIntermUnary* node)
|
||||
{
|
||||
TInfoSinkBase& out = objSink();
|
||||
|
||||
switch (node->getOp())
|
||||
{
|
||||
case EOpNegative: writeTriplet(visit, "(-", NULL, ")"); break;
|
||||
case EOpVectorLogicalNot: UNIMPLEMENTED(); break;
|
||||
case EOpLogicalNot: UNIMPLEMENTED(); break;
|
||||
|
||||
case EOpPostIncrement: UNIMPLEMENTED(); break;
|
||||
case EOpPostDecrement: UNIMPLEMENTED(); break;
|
||||
case EOpPreIncrement: UNIMPLEMENTED(); break;
|
||||
case EOpPreDecrement: UNIMPLEMENTED(); break;
|
||||
|
||||
case EOpConvIntToBool: UNIMPLEMENTED(); break;
|
||||
case EOpConvFloatToBool: UNIMPLEMENTED(); break;
|
||||
case EOpConvBoolToFloat: UNIMPLEMENTED(); break;
|
||||
case EOpConvIntToFloat: writeTriplet(visit, "float(", NULL, ")"); break;
|
||||
case EOpConvFloatToInt: UNIMPLEMENTED(); break;
|
||||
case EOpConvBoolToInt: UNIMPLEMENTED(); break;
|
||||
|
||||
case EOpRadians: UNIMPLEMENTED(); break;
|
||||
case EOpDegrees: UNIMPLEMENTED(); break;
|
||||
case EOpSin: writeTriplet(visit, "sin(", NULL, ")"); break;
|
||||
case EOpCos: writeTriplet(visit, "cos(", NULL, ")"); break;
|
||||
case EOpTan: UNIMPLEMENTED(); break;
|
||||
case EOpAsin: UNIMPLEMENTED(); break;
|
||||
case EOpAcos: UNIMPLEMENTED(); break;
|
||||
case EOpAtan: UNIMPLEMENTED(); break;
|
||||
|
||||
case EOpExp: UNIMPLEMENTED(); break;
|
||||
case EOpLog: UNIMPLEMENTED(); break;
|
||||
case EOpExp2: UNIMPLEMENTED(); break;
|
||||
case EOpLog2: UNIMPLEMENTED(); break;
|
||||
case EOpSqrt: UNIMPLEMENTED(); break;
|
||||
case EOpInverseSqrt: UNIMPLEMENTED(); break;
|
||||
|
||||
case EOpAbs: UNIMPLEMENTED(); break;
|
||||
case EOpSign: UNIMPLEMENTED(); break;
|
||||
case EOpFloor: writeTriplet(visit, "floor(", NULL, ")"); break;
|
||||
case EOpCeil: UNIMPLEMENTED(); break;
|
||||
case EOpFract: UNIMPLEMENTED(); break;
|
||||
|
||||
case EOpLength: UNIMPLEMENTED(); break;
|
||||
case EOpNormalize: writeTriplet(visit, "normalize(", NULL, ")"); break;
|
||||
|
||||
case EOpAny: UNIMPLEMENTED(); break;
|
||||
case EOpAll: UNIMPLEMENTED(); break;
|
||||
|
||||
default: UNREACHABLE(); break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TOutputGLSL::visitSelection(Visit visit, TIntermSelection* node)
|
||||
{
|
||||
TInfoSinkBase& out = objSink();
|
||||
|
||||
out << "if (";
|
||||
node->getCondition()->traverse(this);
|
||||
out << ") {\n";
|
||||
|
||||
incrementDepth();
|
||||
node->getTrueBlock()->traverse(this);
|
||||
out << getIndentationString(depth - 2) << "}";
|
||||
|
||||
if (node->getFalseBlock())
|
||||
{
|
||||
out << " else {\n";
|
||||
node->getFalseBlock()->traverse(this);
|
||||
out << getIndentationString(depth - 2) << "}";
|
||||
}
|
||||
decrementDepth();
|
||||
|
||||
out << "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TOutputGLSL::visitAggregate(Visit visit, TIntermAggregate* node)
|
||||
{
|
||||
TInfoSinkBase& out = objSink();
|
||||
switch (node->getOp())
|
||||
{
|
||||
case EOpSequence:
|
||||
if (visit == PreVisit)
|
||||
{
|
||||
out << getIndentationString(depth);
|
||||
}
|
||||
else if (visit == InVisit)
|
||||
{
|
||||
out << ";\n";
|
||||
out << getIndentationString(depth - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
out << ";\n";
|
||||
}
|
||||
break;
|
||||
case EOpComma:
|
||||
UNIMPLEMENTED();
|
||||
return true;
|
||||
case EOpFunction:
|
||||
if (visit == PreVisit)
|
||||
{
|
||||
TString returnType = node->getBasicString();
|
||||
TString functionName = getUnmangledFunctionName(node->getName());
|
||||
out << returnType << " " << functionName;
|
||||
}
|
||||
else if (visit == InVisit)
|
||||
{
|
||||
// Called after traversing function arguments (EOpParameters)
|
||||
// but before traversing function body (EOpSequence).
|
||||
out << "{\n";
|
||||
}
|
||||
else if (visit == PostVisit)
|
||||
{
|
||||
// Called after traversing function body (EOpSequence).
|
||||
out << "}\n";
|
||||
}
|
||||
break;
|
||||
case EOpFunctionCall:
|
||||
if (visit == PreVisit)
|
||||
{
|
||||
TString functionName = getUnmangledFunctionName(node->getName());
|
||||
out << functionName << "(";
|
||||
}
|
||||
else if (visit == InVisit)
|
||||
{
|
||||
out << ", ";
|
||||
}
|
||||
else
|
||||
{
|
||||
out << ")";
|
||||
}
|
||||
break;
|
||||
case EOpParameters:
|
||||
if (visit == PreVisit)
|
||||
{
|
||||
out << "(";
|
||||
writeFullSymbol = true;
|
||||
}
|
||||
else if (visit == InVisit)
|
||||
{
|
||||
out << ", ";
|
||||
}
|
||||
else
|
||||
{
|
||||
out << ")";
|
||||
writeFullSymbol = false;
|
||||
}
|
||||
break;
|
||||
case EOpDeclaration:
|
||||
if (visit == PreVisit)
|
||||
{
|
||||
writeFullSymbol = true;
|
||||
}
|
||||
else if (visit == InVisit)
|
||||
{
|
||||
out << ", ";
|
||||
writeFullSymbol = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
writeFullSymbol = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case EOpConstructFloat: UNIMPLEMENTED(); break;
|
||||
case EOpConstructVec2: writeTriplet(visit, "vec2(", ", ", ")"); break;
|
||||
case EOpConstructVec3: writeTriplet(visit, "vec3(", ", ", ")"); break;
|
||||
case EOpConstructVec4: writeTriplet(visit, "vec4(", ", ", ")"); break;
|
||||
case EOpConstructBool: UNIMPLEMENTED(); break;
|
||||
case EOpConstructBVec2: UNIMPLEMENTED(); break;
|
||||
case EOpConstructBVec3: UNIMPLEMENTED(); break;
|
||||
case EOpConstructBVec4: UNIMPLEMENTED(); break;
|
||||
case EOpConstructInt: UNIMPLEMENTED(); break;
|
||||
case EOpConstructIVec2: UNIMPLEMENTED(); break;
|
||||
case EOpConstructIVec3: UNIMPLEMENTED(); break;
|
||||
case EOpConstructIVec4: UNIMPLEMENTED(); break;
|
||||
case EOpConstructMat2: UNIMPLEMENTED(); break;
|
||||
case EOpConstructMat3: UNIMPLEMENTED(); break;
|
||||
case EOpConstructMat4: writeTriplet(visit, "mat4(", ", ", ")"); break;
|
||||
case EOpConstructStruct: UNIMPLEMENTED(); break;
|
||||
|
||||
case EOpLessThan: UNIMPLEMENTED(); break;
|
||||
case EOpGreaterThan: UNIMPLEMENTED(); break;
|
||||
case EOpLessThanEqual: UNIMPLEMENTED(); break;
|
||||
case EOpGreaterThanEqual: UNIMPLEMENTED(); break;
|
||||
case EOpVectorEqual: UNIMPLEMENTED(); break;
|
||||
case EOpVectorNotEqual: UNIMPLEMENTED(); break;
|
||||
|
||||
case EOpMod: writeTriplet(visit, "mod(", ", ", ")"); break;
|
||||
case EOpPow: writeTriplet(visit, "pow(", ", ", ")"); break;
|
||||
|
||||
case EOpAtan: UNIMPLEMENTED(); break;
|
||||
|
||||
case EOpMin: writeTriplet(visit, "min(", ", ", ")"); break;
|
||||
case EOpMax: writeTriplet(visit, "max(", ", ", ")"); break;
|
||||
case EOpClamp: writeTriplet(visit, "clamp(", ", ", ")"); break;
|
||||
case EOpMix: writeTriplet(visit, "mix(", ", ", ")"); break;
|
||||
case EOpStep: UNIMPLEMENTED(); break;
|
||||
case EOpSmoothStep: UNIMPLEMENTED(); break;
|
||||
|
||||
case EOpDistance: UNIMPLEMENTED(); break;
|
||||
case EOpDot: writeTriplet(visit, "dot(", ", ", ")"); break;
|
||||
case EOpCross: UNIMPLEMENTED(); break;
|
||||
case EOpFaceForward: UNIMPLEMENTED(); break;
|
||||
case EOpReflect: writeTriplet(visit, "reflect(", ", ", ")"); break;
|
||||
case EOpRefract: UNIMPLEMENTED(); break;
|
||||
case EOpMul: UNIMPLEMENTED(); break;
|
||||
|
||||
default: UNREACHABLE(); break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TOutputGLSL::visitLoop(Visit visit, TIntermLoop* node)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TOutputGLSL::visitBranch(Visit visit, TIntermBranch* node)
|
||||
{
|
||||
TInfoSinkBase &out = objSink();
|
||||
|
||||
switch (node->getFlowOp())
|
||||
{
|
||||
case EOpKill: UNIMPLEMENTED(); break;
|
||||
case EOpBreak: UNIMPLEMENTED(); break;
|
||||
case EOpContinue: UNIMPLEMENTED(); break;
|
||||
case EOpReturn:
|
||||
if (visit == PreVisit)
|
||||
out << "return ";
|
||||
break;
|
||||
default: UNREACHABLE(); break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
//
|
||||
// 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 CROSSCOMPILERGLSL_OUTPUTGLSL_H_
|
||||
#define CROSSCOMPILERGLSL_OUTPUTGLSL_H_
|
||||
|
||||
#include "intermediate.h"
|
||||
#include "ParseHelper.h"
|
||||
|
||||
class TOutputGLSL : public TIntermTraverser
|
||||
{
|
||||
public:
|
||||
TOutputGLSL(TParseContext &context);
|
||||
|
||||
void header();
|
||||
|
||||
protected:
|
||||
TInfoSinkBase& objSink() { return parseContext.infoSink.obj; }
|
||||
void writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr);
|
||||
|
||||
virtual void visitSymbol(TIntermSymbol* node);
|
||||
virtual void visitConstantUnion(TIntermConstantUnion* node);
|
||||
virtual bool visitBinary(Visit visit, TIntermBinary* node);
|
||||
virtual bool visitUnary(Visit visit, TIntermUnary* node);
|
||||
virtual bool visitSelection(Visit visit, TIntermSelection* node);
|
||||
virtual bool visitAggregate(Visit visit, TIntermAggregate* node);
|
||||
virtual bool visitLoop(Visit visit, TIntermLoop* node);
|
||||
virtual bool visitBranch(Visit visit, TIntermBranch* node);
|
||||
|
||||
private:
|
||||
bool writeFullSymbol;
|
||||
TParseContext &parseContext;
|
||||
};
|
||||
|
||||
#endif // CROSSCOMPILERGLSL_OUTPUTGLSL_H_
|
|
@ -56,7 +56,7 @@ class TIntermNode;
|
|||
//
|
||||
class TCompiler : public TShHandleBase {
|
||||
public:
|
||||
TCompiler(EShLanguage l, TInfoSink& sink) : infoSink(sink) , language(l), haveValidObjectCode(false) { }
|
||||
TCompiler(EShLanguage l) : language(l), haveValidObjectCode(false) { }
|
||||
virtual ~TCompiler() { }
|
||||
EShLanguage getLanguage() { return language; }
|
||||
virtual TInfoSink& getInfoSink() { return infoSink; }
|
||||
|
@ -65,8 +65,8 @@ public:
|
|||
|
||||
virtual TCompiler* getAsCompiler() { return this; }
|
||||
virtual bool linkable() { return haveValidObjectCode; }
|
||||
|
||||
TInfoSink& infoSink;
|
||||
|
||||
TInfoSink infoSink;
|
||||
protected:
|
||||
EShLanguage language;
|
||||
bool haveValidObjectCode;
|
||||
|
@ -85,14 +85,13 @@ typedef TVector<TShHandleBase*> THandleList;
|
|||
|
||||
class TLinker : public TShHandleBase {
|
||||
public:
|
||||
TLinker(EShExecutable e, TInfoSink& iSink) :
|
||||
infoSink(iSink),
|
||||
TLinker(EShExecutable e) :
|
||||
executable(e),
|
||||
haveReturnableObjectCode(false),
|
||||
appAttributeBindings(0),
|
||||
fixedAttributeBindings(0),
|
||||
excludedAttributes(0),
|
||||
excludedCount(0),
|
||||
excludedAttributes(0),
|
||||
excludedCount(0),
|
||||
uniformBindings(0) { }
|
||||
virtual TLinker* getAsLinker() { return this; }
|
||||
virtual ~TLinker() { }
|
||||
|
@ -100,20 +99,20 @@ public:
|
|||
virtual bool link(THandleList&) { return false; }
|
||||
virtual void setAppAttributeBindings(const ShBindingTable* t) { appAttributeBindings = t; }
|
||||
virtual void setFixedAttributeBindings(const ShBindingTable* t) { fixedAttributeBindings = t; }
|
||||
virtual void getAttributeBindings(ShBindingTable const **t) const = 0;
|
||||
virtual void setExcludedAttributes(const int* attributes, int count) { excludedAttributes = attributes; excludedCount = count; }
|
||||
virtual void getAttributeBindings(ShBindingTable const **t) const = 0;
|
||||
virtual void setExcludedAttributes(const int* attributes, int count) { excludedAttributes = attributes; excludedCount = count; }
|
||||
virtual ShBindingTable* getUniformBindings() const { return uniformBindings; }
|
||||
virtual const void* getObjectCode() const { return 0; } // a real compiler would be returning object code here
|
||||
virtual TInfoSink& getInfoSink() { return infoSink; }
|
||||
TInfoSink& infoSink;
|
||||
TInfoSink infoSink;
|
||||
protected:
|
||||
EShExecutable executable;
|
||||
bool haveReturnableObjectCode; // true when objectCode is acceptable to send to driver
|
||||
|
||||
const ShBindingTable* appAttributeBindings;
|
||||
const ShBindingTable* fixedAttributeBindings;
|
||||
const int* excludedAttributes;
|
||||
int excludedCount;
|
||||
const int* excludedAttributes;
|
||||
int excludedCount;
|
||||
ShBindingTable* uniformBindings; // created by the linker
|
||||
};
|
||||
|
||||
|
@ -130,7 +129,7 @@ TCompiler* ConstructCompiler(EShLanguage, int);
|
|||
|
||||
TShHandleBase* ConstructLinker(EShExecutable, int);
|
||||
void DeleteLinker(TShHandleBase*);
|
||||
|
||||
|
||||
TUniformMap* ConstructUniformMap();
|
||||
void DeleteCompiler(TCompiler*);
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
#include "Initialize.h"
|
||||
#include "InitializeDll.h"
|
||||
#include "OutputHLSL.h"
|
||||
#include "ParseHelper.h"
|
||||
#include "ShHandle.h"
|
||||
#include "SymbolTable.h"
|
||||
|
@ -244,19 +243,20 @@ int ShCompile(
|
|||
return 0;
|
||||
|
||||
GlobalPoolAllocator.push();
|
||||
compiler->infoSink.info.erase();
|
||||
compiler->infoSink.debug.erase();
|
||||
compiler->infoSink.obj.erase();
|
||||
TInfoSink& infoSink = compiler->infoSink;
|
||||
infoSink.info.erase();
|
||||
infoSink.debug.erase();
|
||||
infoSink.obj.erase();
|
||||
|
||||
if (numStrings == 0)
|
||||
return 1;
|
||||
|
||||
TIntermediate intermediate(compiler->infoSink);
|
||||
TIntermediate intermediate(infoSink);
|
||||
TSymbolTable symbolTable(SymbolTables[compiler->getLanguage()]);
|
||||
|
||||
GenerateBuiltInSymbolTable(resources, compiler->infoSink, &symbolTable, compiler->getLanguage());
|
||||
GenerateBuiltInSymbolTable(resources, infoSink, &symbolTable, compiler->getLanguage());
|
||||
|
||||
TParseContext parseContext(symbolTable, intermediate, compiler->getLanguage(), compiler->infoSink);
|
||||
TParseContext parseContext(symbolTable, intermediate, compiler->getLanguage(), infoSink);
|
||||
parseContext.initializeExtensionBehavior();
|
||||
|
||||
GlobalParseContext = &parseContext;
|
||||
|
@ -290,18 +290,10 @@ int ShCompile(
|
|||
if (debugOptions & EDebugOpIntermediate)
|
||||
intermediate.outputTree(parseContext.treeRoot);
|
||||
|
||||
if(debugOptions & EDebugOpObjectCode)
|
||||
{
|
||||
sh::OutputHLSL outputHLSL(parseContext);
|
||||
|
||||
outputHLSL.header();
|
||||
parseContext.treeRoot->traverse(&outputHLSL);
|
||||
}
|
||||
|
||||
//
|
||||
// Call the machine dependent compiler
|
||||
//
|
||||
if (! compiler->compile(parseContext.treeRoot))
|
||||
if (!compiler->compile(parseContext.treeRoot))
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// 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 "TranslatorGLSL.h"
|
||||
#include "OutputGLSL.h"
|
||||
|
||||
TranslatorGLSL::TranslatorGLSL(EShLanguage l, int dOptions)
|
||||
: TCompiler(l),
|
||||
debugOptions(dOptions) {
|
||||
}
|
||||
|
||||
bool TranslatorGLSL::compile(TIntermNode* root) {
|
||||
TParseContext& parseContext = *GetGlobalParseContext();
|
||||
TOutputGLSL outputGLSL(parseContext);
|
||||
outputGLSL.header();
|
||||
parseContext.treeRoot->traverse(&outputGLSL);
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// 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 COMPILER_TRANSLATORGLSL_H_
|
||||
#define COMPILER_TRANSLATORGLSL_H_
|
||||
|
||||
#include "ShHandle.h"
|
||||
|
||||
class TranslatorGLSL : public TCompiler {
|
||||
public:
|
||||
TranslatorGLSL(EShLanguage l, int dOptions);
|
||||
virtual bool compile(TIntermNode* root);
|
||||
int debugOptions;
|
||||
};
|
||||
|
||||
#endif // COMPILER_TRANSLATORGLSL_H_
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// 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 "TranslatorHLSL.h"
|
||||
#include "OutputHLSL.h"
|
||||
|
||||
TranslatorHLSL::TranslatorHLSL(EShLanguage l, int dOptions)
|
||||
: TCompiler(l),
|
||||
debugOptions(dOptions) {
|
||||
}
|
||||
|
||||
bool TranslatorHLSL::compile(TIntermNode* root) {
|
||||
TParseContext& parseContext = *GetGlobalParseContext();
|
||||
sh::OutputHLSL outputHLSL(parseContext);
|
||||
outputHLSL.header();
|
||||
parseContext.treeRoot->traverse(&outputHLSL);
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// 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 COMPILER_TRANSLATORHLSL_H_
|
||||
#define COMPILER_TRANSLATORHLSL_H_
|
||||
|
||||
#include "ShHandle.h"
|
||||
|
||||
class TranslatorHLSL : public TCompiler {
|
||||
public:
|
||||
TranslatorHLSL(EShLanguage l, int dOptions);
|
||||
virtual bool compile(TIntermNode* root);
|
||||
int debugOptions;
|
||||
};
|
||||
|
||||
#endif // COMPILER_TRANSLATORHLSL_H_
|
|
@ -21,37 +21,37 @@
|
|||
//
|
||||
class TOutputTraverser : public TIntermTraverser {
|
||||
public:
|
||||
TOutputTraverser(TInfoSink& i) : infoSink(i) { }
|
||||
TInfoSink& infoSink;
|
||||
TOutputTraverser(TInfoSink& i) : infoSink(i) { }
|
||||
TInfoSink& infoSink;
|
||||
|
||||
protected:
|
||||
void visitSymbol(TIntermSymbol*);
|
||||
void visitConstantUnion(TIntermConstantUnion*);
|
||||
bool visitBinary(Visit visit, TIntermBinary*);
|
||||
bool visitUnary(Visit visit, TIntermUnary*);
|
||||
bool visitSelection(Visit visit, TIntermSelection*);
|
||||
bool visitAggregate(Visit visit, TIntermAggregate*);
|
||||
bool visitLoop(Visit visit, TIntermLoop*);
|
||||
bool visitBranch(Visit visit, TIntermBranch*);
|
||||
void visitSymbol(TIntermSymbol*);
|
||||
void visitConstantUnion(TIntermConstantUnion*);
|
||||
bool visitBinary(Visit visit, TIntermBinary*);
|
||||
bool visitUnary(Visit visit, TIntermUnary*);
|
||||
bool visitSelection(Visit visit, TIntermSelection*);
|
||||
bool visitAggregate(Visit visit, TIntermAggregate*);
|
||||
bool visitLoop(Visit visit, TIntermLoop*);
|
||||
bool visitBranch(Visit visit, TIntermBranch*);
|
||||
};
|
||||
|
||||
TString TType::getCompleteString() const
|
||||
{
|
||||
char buf[100];
|
||||
char *p = &buf[0];
|
||||
char buf[100];
|
||||
char *p = &buf[0];
|
||||
|
||||
if (qualifier != EvqTemporary && qualifier != EvqGlobal)
|
||||
p += sprintf(p, "%s ", getQualifierString());
|
||||
if (array)
|
||||
p += sprintf(p, "array of ");
|
||||
if (matrix)
|
||||
p += sprintf(p, "%dX%d matrix of ", size, size);
|
||||
else if (size > 1)
|
||||
p += sprintf(p, "%d-component vector of ", size);
|
||||
if (qualifier != EvqTemporary && qualifier != EvqGlobal)
|
||||
p += sprintf(p, "%s ", getQualifierString());
|
||||
if (array)
|
||||
p += sprintf(p, "array of ");
|
||||
if (matrix)
|
||||
p += sprintf(p, "%dX%d matrix of ", size, size);
|
||||
else if (size > 1)
|
||||
p += sprintf(p, "%d-component vector of ", size);
|
||||
|
||||
sprintf(p, "%s", getBasicString());
|
||||
sprintf(p, "%s", getBasicString());
|
||||
|
||||
return TString(buf);
|
||||
return TString(buf);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -60,12 +60,12 @@ TString TType::getCompleteString() const
|
|||
|
||||
void OutputTreeText(TInfoSink& infoSink, TIntermNode* node, const int depth)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
infoSink.debug << FormatSourceLoc(node->getLine());
|
||||
infoSink.debug << FormatSourceLoc(node->getLine());
|
||||
|
||||
for (i = 0; i < depth; ++i)
|
||||
infoSink.debug << " ";
|
||||
for (i = 0; i < depth; ++i)
|
||||
infoSink.debug << " ";
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -79,340 +79,333 @@ void OutputTreeText(TInfoSink& infoSink, TIntermNode* node, const int depth)
|
|||
|
||||
void TOutputTraverser::visitSymbol(TIntermSymbol* node)
|
||||
{
|
||||
OutputTreeText(infoSink, node, depth);
|
||||
OutputTreeText(infoSink, node, depth);
|
||||
|
||||
char buf[100];
|
||||
sprintf(buf, "'%s' (%s)\n",
|
||||
node->getSymbol().c_str(),
|
||||
node->getCompleteString().c_str());
|
||||
char buf[100];
|
||||
sprintf(buf, "'%s' (%s)\n",
|
||||
node->getSymbol().c_str(),
|
||||
node->getCompleteString().c_str());
|
||||
|
||||
infoSink.debug << buf;
|
||||
infoSink.debug << buf;
|
||||
}
|
||||
|
||||
bool TOutputTraverser::visitBinary(Visit visit, TIntermBinary* node)
|
||||
{
|
||||
TInfoSink& out = infoSink;
|
||||
TInfoSink& out = infoSink;
|
||||
|
||||
OutputTreeText(out, node, depth);
|
||||
OutputTreeText(out, node, depth);
|
||||
|
||||
switch (node->getOp()) {
|
||||
case EOpAssign: out.debug << "move second child to first child"; break;
|
||||
case EOpAddAssign: out.debug << "add second child into first child"; break;
|
||||
case EOpSubAssign: out.debug << "subtract second child into first child"; break;
|
||||
case EOpMulAssign: out.debug << "multiply second child into first child"; break;
|
||||
case EOpVectorTimesMatrixAssign: out.debug << "matrix mult second child into first child"; break;
|
||||
case EOpVectorTimesScalarAssign: out.debug << "vector scale second child into first child"; break;
|
||||
case EOpMatrixTimesScalarAssign: out.debug << "matrix scale second child into first child"; break;
|
||||
case EOpMatrixTimesMatrixAssign: out.debug << "matrix mult second child into first child"; break;
|
||||
case EOpDivAssign: out.debug << "divide second child into first child"; break;
|
||||
case EOpIndexDirect: out.debug << "direct index"; break;
|
||||
case EOpIndexIndirect: out.debug << "indirect index"; break;
|
||||
case EOpIndexDirectStruct: out.debug << "direct index for structure"; break;
|
||||
case EOpVectorSwizzle: out.debug << "vector swizzle"; break;
|
||||
switch (node->getOp()) {
|
||||
case EOpAssign: out.debug << "move second child to first child"; break;
|
||||
case EOpInitialize: out.debug << "initialize first child with second child"; break;
|
||||
case EOpAddAssign: out.debug << "add second child into first child"; break;
|
||||
case EOpSubAssign: out.debug << "subtract second child into first child"; break;
|
||||
case EOpMulAssign: out.debug << "multiply second child into first child"; break;
|
||||
case EOpVectorTimesMatrixAssign: out.debug << "matrix mult second child into first child"; break;
|
||||
case EOpVectorTimesScalarAssign: out.debug << "vector scale second child into first child"; break;
|
||||
case EOpMatrixTimesScalarAssign: out.debug << "matrix scale second child into first child"; break;
|
||||
case EOpMatrixTimesMatrixAssign: out.debug << "matrix mult second child into first child"; break;
|
||||
case EOpDivAssign: out.debug << "divide second child into first child"; break;
|
||||
case EOpIndexDirect: out.debug << "direct index"; break;
|
||||
case EOpIndexIndirect: out.debug << "indirect index"; break;
|
||||
case EOpIndexDirectStruct: out.debug << "direct index for structure"; break;
|
||||
case EOpVectorSwizzle: out.debug << "vector swizzle"; break;
|
||||
|
||||
case EOpAdd: out.debug << "add"; break;
|
||||
case EOpSub: out.debug << "subtract"; break;
|
||||
case EOpMul: out.debug << "component-wise multiply"; break;
|
||||
case EOpDiv: out.debug << "divide"; break;
|
||||
case EOpEqual: out.debug << "Compare Equal"; break;
|
||||
case EOpNotEqual: out.debug << "Compare Not Equal"; break;
|
||||
case EOpLessThan: out.debug << "Compare Less Than"; break;
|
||||
case EOpGreaterThan: out.debug << "Compare Greater Than"; break;
|
||||
case EOpLessThanEqual: out.debug << "Compare Less Than or Equal"; break;
|
||||
case EOpGreaterThanEqual: out.debug << "Compare Greater Than or Equal"; break;
|
||||
case EOpAdd: out.debug << "add"; break;
|
||||
case EOpSub: out.debug << "subtract"; break;
|
||||
case EOpMul: out.debug << "component-wise multiply"; break;
|
||||
case EOpDiv: out.debug << "divide"; break;
|
||||
case EOpEqual: out.debug << "Compare Equal"; break;
|
||||
case EOpNotEqual: out.debug << "Compare Not Equal"; break;
|
||||
case EOpLessThan: out.debug << "Compare Less Than"; break;
|
||||
case EOpGreaterThan: out.debug << "Compare Greater Than"; break;
|
||||
case EOpLessThanEqual: out.debug << "Compare Less Than or Equal"; break;
|
||||
case EOpGreaterThanEqual: out.debug << "Compare Greater Than or Equal"; break;
|
||||
|
||||
case EOpVectorTimesScalar: out.debug << "vector-scale"; break;
|
||||
case EOpVectorTimesMatrix: out.debug << "vector-times-matrix"; break;
|
||||
case EOpMatrixTimesVector: out.debug << "matrix-times-vector"; break;
|
||||
case EOpMatrixTimesScalar: out.debug << "matrix-scale"; break;
|
||||
case EOpMatrixTimesMatrix: out.debug << "matrix-multiply"; break;
|
||||
case EOpVectorTimesScalar: out.debug << "vector-scale"; break;
|
||||
case EOpVectorTimesMatrix: out.debug << "vector-times-matrix"; break;
|
||||
case EOpMatrixTimesVector: out.debug << "matrix-times-vector"; break;
|
||||
case EOpMatrixTimesScalar: out.debug << "matrix-scale"; break;
|
||||
case EOpMatrixTimesMatrix: out.debug << "matrix-multiply"; break;
|
||||
|
||||
case EOpLogicalOr: out.debug << "logical-or"; break;
|
||||
case EOpLogicalXor: out.debug << "logical-xor"; break;
|
||||
case EOpLogicalAnd: out.debug << "logical-and"; break;
|
||||
default: out.debug << "<unknown op>";
|
||||
}
|
||||
case EOpLogicalOr: out.debug << "logical-or"; break;
|
||||
case EOpLogicalXor: out.debug << "logical-xor"; break;
|
||||
case EOpLogicalAnd: out.debug << "logical-and"; break;
|
||||
default: out.debug << "<unknown op>";
|
||||
}
|
||||
|
||||
out.debug << " (" << node->getCompleteString() << ")";
|
||||
out.debug << " (" << node->getCompleteString() << ")";
|
||||
|
||||
out.debug << "\n";
|
||||
out.debug << "\n";
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TOutputTraverser::visitUnary(Visit visit, TIntermUnary* node)
|
||||
{
|
||||
TInfoSink& out = infoSink;
|
||||
TInfoSink& out = infoSink;
|
||||
|
||||
OutputTreeText(out, node, depth);
|
||||
OutputTreeText(out, node, depth);
|
||||
|
||||
switch (node->getOp()) {
|
||||
case EOpNegative: out.debug << "Negate value"; break;
|
||||
case EOpVectorLogicalNot:
|
||||
case EOpLogicalNot: out.debug << "Negate conditional"; break;
|
||||
switch (node->getOp()) {
|
||||
case EOpNegative: out.debug << "Negate value"; break;
|
||||
case EOpVectorLogicalNot:
|
||||
case EOpLogicalNot: out.debug << "Negate conditional"; break;
|
||||
|
||||
case EOpPostIncrement: out.debug << "Post-Increment"; break;
|
||||
case EOpPostDecrement: out.debug << "Post-Decrement"; break;
|
||||
case EOpPreIncrement: out.debug << "Pre-Increment"; break;
|
||||
case EOpPreDecrement: out.debug << "Pre-Decrement"; break;
|
||||
case EOpPostIncrement: out.debug << "Post-Increment"; break;
|
||||
case EOpPostDecrement: out.debug << "Post-Decrement"; break;
|
||||
case EOpPreIncrement: out.debug << "Pre-Increment"; break;
|
||||
case EOpPreDecrement: out.debug << "Pre-Decrement"; break;
|
||||
|
||||
case EOpConvIntToBool: out.debug << "Convert int to bool"; break;
|
||||
case EOpConvFloatToBool:out.debug << "Convert float to bool";break;
|
||||
case EOpConvBoolToFloat:out.debug << "Convert bool to float";break;
|
||||
case EOpConvIntToFloat: out.debug << "Convert int to float"; break;
|
||||
case EOpConvFloatToInt: out.debug << "Convert float to int"; break;
|
||||
case EOpConvBoolToInt: out.debug << "Convert bool to int"; break;
|
||||
case EOpConvIntToBool: out.debug << "Convert int to bool"; break;
|
||||
case EOpConvFloatToBool:out.debug << "Convert float to bool";break;
|
||||
case EOpConvBoolToFloat:out.debug << "Convert bool to float";break;
|
||||
case EOpConvIntToFloat: out.debug << "Convert int to float"; break;
|
||||
case EOpConvFloatToInt: out.debug << "Convert float to int"; break;
|
||||
case EOpConvBoolToInt: out.debug << "Convert bool to int"; break;
|
||||
|
||||
case EOpRadians: out.debug << "radians"; break;
|
||||
case EOpDegrees: out.debug << "degrees"; break;
|
||||
case EOpSin: out.debug << "sine"; break;
|
||||
case EOpCos: out.debug << "cosine"; break;
|
||||
case EOpTan: out.debug << "tangent"; break;
|
||||
case EOpAsin: out.debug << "arc sine"; break;
|
||||
case EOpAcos: out.debug << "arc cosine"; break;
|
||||
case EOpAtan: out.debug << "arc tangent"; break;
|
||||
case EOpRadians: out.debug << "radians"; break;
|
||||
case EOpDegrees: out.debug << "degrees"; break;
|
||||
case EOpSin: out.debug << "sine"; break;
|
||||
case EOpCos: out.debug << "cosine"; break;
|
||||
case EOpTan: out.debug << "tangent"; break;
|
||||
case EOpAsin: out.debug << "arc sine"; break;
|
||||
case EOpAcos: out.debug << "arc cosine"; break;
|
||||
case EOpAtan: out.debug << "arc tangent"; break;
|
||||
|
||||
case EOpExp: out.debug << "exp"; break;
|
||||
case EOpLog: out.debug << "log"; break;
|
||||
case EOpExp2: out.debug << "exp2"; break;
|
||||
case EOpLog2: out.debug << "log2"; break;
|
||||
case EOpSqrt: out.debug << "sqrt"; break;
|
||||
case EOpInverseSqrt: out.debug << "inverse sqrt"; break;
|
||||
case EOpExp: out.debug << "exp"; break;
|
||||
case EOpLog: out.debug << "log"; break;
|
||||
case EOpExp2: out.debug << "exp2"; break;
|
||||
case EOpLog2: out.debug << "log2"; break;
|
||||
case EOpSqrt: out.debug << "sqrt"; break;
|
||||
case EOpInverseSqrt: out.debug << "inverse sqrt"; break;
|
||||
|
||||
case EOpAbs: out.debug << "Absolute value"; break;
|
||||
case EOpSign: out.debug << "Sign"; break;
|
||||
case EOpFloor: out.debug << "Floor"; break;
|
||||
case EOpCeil: out.debug << "Ceiling"; break;
|
||||
case EOpFract: out.debug << "Fraction"; break;
|
||||
case EOpAbs: out.debug << "Absolute value"; break;
|
||||
case EOpSign: out.debug << "Sign"; break;
|
||||
case EOpFloor: out.debug << "Floor"; break;
|
||||
case EOpCeil: out.debug << "Ceiling"; break;
|
||||
case EOpFract: out.debug << "Fraction"; break;
|
||||
|
||||
case EOpLength: out.debug << "length"; break;
|
||||
case EOpNormalize: out.debug << "normalize"; break;
|
||||
// case EOpDPdx: out.debug << "dPdx"; break;
|
||||
// case EOpDPdy: out.debug << "dPdy"; break;
|
||||
// case EOpFwidth: out.debug << "fwidth"; break;
|
||||
case EOpLength: out.debug << "length"; break;
|
||||
case EOpNormalize: out.debug << "normalize"; break;
|
||||
// case EOpDPdx: out.debug << "dPdx"; break;
|
||||
// case EOpDPdy: out.debug << "dPdy"; break;
|
||||
// case EOpFwidth: out.debug << "fwidth"; break;
|
||||
|
||||
case EOpAny: out.debug << "any"; break;
|
||||
case EOpAll: out.debug << "all"; break;
|
||||
case EOpAny: out.debug << "any"; break;
|
||||
case EOpAll: out.debug << "all"; break;
|
||||
|
||||
default: out.debug.message(EPrefixError, "Bad unary op");
|
||||
}
|
||||
default: out.debug.message(EPrefixError, "Bad unary op");
|
||||
}
|
||||
|
||||
out.debug << " (" << node->getCompleteString() << ")";
|
||||
out.debug << " (" << node->getCompleteString() << ")";
|
||||
|
||||
out.debug << "\n";
|
||||
out.debug << "\n";
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TOutputTraverser::visitAggregate(Visit visit, TIntermAggregate* node)
|
||||
{
|
||||
TInfoSink& out = infoSink;
|
||||
TInfoSink& out = infoSink;
|
||||
|
||||
if (node->getOp() == EOpNull) {
|
||||
out.debug.message(EPrefixError, "node is still EOpNull!");
|
||||
return true;
|
||||
}
|
||||
if (node->getOp() == EOpNull) {
|
||||
out.debug.message(EPrefixError, "node is still EOpNull!");
|
||||
return true;
|
||||
}
|
||||
|
||||
OutputTreeText(out, node, depth);
|
||||
OutputTreeText(out, node, depth);
|
||||
|
||||
switch (node->getOp()) {
|
||||
case EOpSequence: out.debug << "Sequence\n"; return true;
|
||||
case EOpComma: out.debug << "Comma\n"; return true;
|
||||
case EOpFunction: out.debug << "Function Definition: " << node->getName(); break;
|
||||
case EOpFunctionCall: out.debug << "Function Call: " << node->getName(); break;
|
||||
case EOpParameters: out.debug << "Function Parameters: "; break;
|
||||
switch (node->getOp()) {
|
||||
case EOpSequence: out.debug << "Sequence\n"; return true;
|
||||
case EOpComma: out.debug << "Comma\n"; return true;
|
||||
case EOpFunction: out.debug << "Function Definition: " << node->getName(); break;
|
||||
case EOpFunctionCall: out.debug << "Function Call: " << node->getName(); break;
|
||||
case EOpParameters: out.debug << "Function Parameters: "; break;
|
||||
|
||||
case EOpConstructFloat: out.debug << "Construct float"; break;
|
||||
case EOpConstructVec2: out.debug << "Construct vec2"; break;
|
||||
case EOpConstructVec3: out.debug << "Construct vec3"; break;
|
||||
case EOpConstructVec4: out.debug << "Construct vec4"; break;
|
||||
case EOpConstructBool: out.debug << "Construct bool"; break;
|
||||
case EOpConstructBVec2: out.debug << "Construct bvec2"; break;
|
||||
case EOpConstructBVec3: out.debug << "Construct bvec3"; break;
|
||||
case EOpConstructBVec4: out.debug << "Construct bvec4"; break;
|
||||
case EOpConstructInt: out.debug << "Construct int"; break;
|
||||
case EOpConstructIVec2: out.debug << "Construct ivec2"; break;
|
||||
case EOpConstructIVec3: out.debug << "Construct ivec3"; break;
|
||||
case EOpConstructIVec4: out.debug << "Construct ivec4"; break;
|
||||
case EOpConstructMat2: out.debug << "Construct mat2"; break;
|
||||
case EOpConstructMat3: out.debug << "Construct mat3"; break;
|
||||
case EOpConstructMat4: out.debug << "Construct mat4"; break;
|
||||
case EOpConstructStruct: out.debug << "Construct structure"; break;
|
||||
case EOpConstructFloat: out.debug << "Construct float"; break;
|
||||
case EOpConstructVec2: out.debug << "Construct vec2"; break;
|
||||
case EOpConstructVec3: out.debug << "Construct vec3"; break;
|
||||
case EOpConstructVec4: out.debug << "Construct vec4"; break;
|
||||
case EOpConstructBool: out.debug << "Construct bool"; break;
|
||||
case EOpConstructBVec2: out.debug << "Construct bvec2"; break;
|
||||
case EOpConstructBVec3: out.debug << "Construct bvec3"; break;
|
||||
case EOpConstructBVec4: out.debug << "Construct bvec4"; break;
|
||||
case EOpConstructInt: out.debug << "Construct int"; break;
|
||||
case EOpConstructIVec2: out.debug << "Construct ivec2"; break;
|
||||
case EOpConstructIVec3: out.debug << "Construct ivec3"; break;
|
||||
case EOpConstructIVec4: out.debug << "Construct ivec4"; break;
|
||||
case EOpConstructMat2: out.debug << "Construct mat2"; break;
|
||||
case EOpConstructMat3: out.debug << "Construct mat3"; break;
|
||||
case EOpConstructMat4: out.debug << "Construct mat4"; break;
|
||||
case EOpConstructStruct: out.debug << "Construct structure"; break;
|
||||
|
||||
case EOpLessThan: out.debug << "Compare Less Than"; break;
|
||||
case EOpGreaterThan: out.debug << "Compare Greater Than"; break;
|
||||
case EOpLessThanEqual: out.debug << "Compare Less Than or Equal"; break;
|
||||
case EOpGreaterThanEqual: out.debug << "Compare Greater Than or Equal"; break;
|
||||
case EOpVectorEqual: out.debug << "Equal"; break;
|
||||
case EOpVectorNotEqual: out.debug << "NotEqual"; break;
|
||||
case EOpLessThan: out.debug << "Compare Less Than"; break;
|
||||
case EOpGreaterThan: out.debug << "Compare Greater Than"; break;
|
||||
case EOpLessThanEqual: out.debug << "Compare Less Than or Equal"; break;
|
||||
case EOpGreaterThanEqual: out.debug << "Compare Greater Than or Equal"; break;
|
||||
case EOpVectorEqual: out.debug << "Equal"; break;
|
||||
case EOpVectorNotEqual: out.debug << "NotEqual"; break;
|
||||
|
||||
case EOpMod: out.debug << "mod"; break;
|
||||
case EOpPow: out.debug << "pow"; break;
|
||||
case EOpMod: out.debug << "mod"; break;
|
||||
case EOpPow: out.debug << "pow"; break;
|
||||
|
||||
case EOpAtan: out.debug << "arc tangent"; break;
|
||||
case EOpAtan: out.debug << "arc tangent"; break;
|
||||
|
||||
case EOpMin: out.debug << "min"; break;
|
||||
case EOpMax: out.debug << "max"; break;
|
||||
case EOpClamp: out.debug << "clamp"; break;
|
||||
case EOpMix: out.debug << "mix"; break;
|
||||
case EOpStep: out.debug << "step"; break;
|
||||
case EOpSmoothStep: out.debug << "smoothstep"; break;
|
||||
case EOpMin: out.debug << "min"; break;
|
||||
case EOpMax: out.debug << "max"; break;
|
||||
case EOpClamp: out.debug << "clamp"; break;
|
||||
case EOpMix: out.debug << "mix"; break;
|
||||
case EOpStep: out.debug << "step"; break;
|
||||
case EOpSmoothStep: out.debug << "smoothstep"; break;
|
||||
|
||||
case EOpDistance: out.debug << "distance"; break;
|
||||
case EOpDot: out.debug << "dot-product"; break;
|
||||
case EOpCross: out.debug << "cross-product"; break;
|
||||
case EOpFaceForward: out.debug << "face-forward"; break;
|
||||
case EOpReflect: out.debug << "reflect"; break;
|
||||
case EOpRefract: out.debug << "refract"; break;
|
||||
case EOpMul: out.debug << "component-wise multiply"; break;
|
||||
case EOpDistance: out.debug << "distance"; break;
|
||||
case EOpDot: out.debug << "dot-product"; break;
|
||||
case EOpCross: out.debug << "cross-product"; break;
|
||||
case EOpFaceForward: out.debug << "face-forward"; break;
|
||||
case EOpReflect: out.debug << "reflect"; break;
|
||||
case EOpRefract: out.debug << "refract"; break;
|
||||
case EOpMul: out.debug << "component-wise multiply"; break;
|
||||
|
||||
default: out.debug.message(EPrefixError, "Bad aggregation op");
|
||||
}
|
||||
default: out.debug.message(EPrefixError, "Bad aggregation op");
|
||||
}
|
||||
|
||||
if (node->getOp() != EOpSequence && node->getOp() != EOpParameters)
|
||||
out.debug << " (" << node->getCompleteString() << ")";
|
||||
if (node->getOp() != EOpSequence && node->getOp() != EOpParameters)
|
||||
out.debug << " (" << node->getCompleteString() << ")";
|
||||
|
||||
out.debug << "\n";
|
||||
out.debug << "\n";
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TOutputTraverser::visitSelection(Visit visit, TIntermSelection* node)
|
||||
{
|
||||
TInfoSink& out = infoSink;
|
||||
TInfoSink& out = infoSink;
|
||||
|
||||
OutputTreeText(out, node, depth);
|
||||
OutputTreeText(out, node, depth);
|
||||
|
||||
out.debug << "Test condition and select";
|
||||
out.debug << " (" << node->getCompleteString() << ")\n";
|
||||
out.debug << "Test condition and select";
|
||||
out.debug << " (" << node->getCompleteString() << ")\n";
|
||||
|
||||
++depth;
|
||||
++depth;
|
||||
|
||||
OutputTreeText(infoSink, node, depth);
|
||||
out.debug << "Condition\n";
|
||||
node->getCondition()->traverse(this);
|
||||
OutputTreeText(infoSink, node, depth);
|
||||
out.debug << "Condition\n";
|
||||
node->getCondition()->traverse(this);
|
||||
|
||||
OutputTreeText(infoSink, node, depth);
|
||||
if (node->getTrueBlock()) {
|
||||
out.debug << "true case\n";
|
||||
node->getTrueBlock()->traverse(this);
|
||||
} else
|
||||
out.debug << "true case is null\n";
|
||||
OutputTreeText(infoSink, node, depth);
|
||||
if (node->getTrueBlock()) {
|
||||
out.debug << "true case\n";
|
||||
node->getTrueBlock()->traverse(this);
|
||||
} else
|
||||
out.debug << "true case is null\n";
|
||||
|
||||
if (node->getFalseBlock()) {
|
||||
OutputTreeText(infoSink, node, depth);
|
||||
out.debug << "false case\n";
|
||||
node->getFalseBlock()->traverse(this);
|
||||
}
|
||||
if (node->getFalseBlock()) {
|
||||
OutputTreeText(infoSink, node, depth);
|
||||
out.debug << "false case\n";
|
||||
node->getFalseBlock()->traverse(this);
|
||||
}
|
||||
|
||||
--depth;
|
||||
--depth;
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void TOutputTraverser::visitConstantUnion(TIntermConstantUnion* node)
|
||||
{
|
||||
TInfoSink& out = infoSink;
|
||||
TInfoSink& out = infoSink;
|
||||
|
||||
int size = node->getType().getObjectSize();
|
||||
int size = node->getType().getObjectSize();
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
OutputTreeText(out, node, depth);
|
||||
switch (node->getUnionArrayPointer()[i].getType()) {
|
||||
case EbtBool:
|
||||
if (node->getUnionArrayPointer()[i].getBConst())
|
||||
out.debug << "true";
|
||||
else
|
||||
out.debug << "false";
|
||||
char buf[300];
|
||||
for (int i = 0; i < size; i++) {
|
||||
OutputTreeText(out, node, depth);
|
||||
switch (node->getUnionArrayPointer()[i].getType()) {
|
||||
case EbtBool:
|
||||
if (node->getUnionArrayPointer()[i].getBConst())
|
||||
out.debug << "true";
|
||||
else
|
||||
out.debug << "false";
|
||||
|
||||
out.debug << " (" << "const bool" << ")";
|
||||
|
||||
out.debug << "\n";
|
||||
break;
|
||||
case EbtFloat:
|
||||
{
|
||||
char buf[300];
|
||||
sprintf(buf, "%f (%s)", node->getUnionArrayPointer()[i].getFConst(), "const float");
|
||||
|
||||
out.debug << buf << "\n";
|
||||
}
|
||||
break;
|
||||
case EbtInt:
|
||||
{
|
||||
char buf[300];
|
||||
sprintf(buf, "%d (%s)", node->getUnionArrayPointer()[i].getIConst(), "const int");
|
||||
|
||||
out.debug << buf << "\n";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
out.info.message(EPrefixInternalError, "Unknown constant", node->getLine());
|
||||
break;
|
||||
}
|
||||
}
|
||||
out.debug << " (" << "const bool" << ")";
|
||||
out.debug << "\n";
|
||||
break;
|
||||
case EbtFloat:
|
||||
sprintf(buf, "%f (%s)", node->getUnionArrayPointer()[i].getFConst(), "const float");
|
||||
out.debug << buf << "\n";
|
||||
break;
|
||||
case EbtInt:
|
||||
sprintf(buf, "%d (%s)", node->getUnionArrayPointer()[i].getIConst(), "const int");
|
||||
out.debug << buf << "\n";
|
||||
break;
|
||||
default:
|
||||
out.info.message(EPrefixInternalError, "Unknown constant", node->getLine());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TOutputTraverser::visitLoop(Visit visit, TIntermLoop* node)
|
||||
{
|
||||
TInfoSink& out = infoSink;
|
||||
TInfoSink& out = infoSink;
|
||||
|
||||
OutputTreeText(out, node, depth);
|
||||
OutputTreeText(out, node, depth);
|
||||
|
||||
out.debug << "Loop with condition ";
|
||||
if (! node->testFirst())
|
||||
out.debug << "not ";
|
||||
out.debug << "tested first\n";
|
||||
out.debug << "Loop with condition ";
|
||||
if (! node->testFirst())
|
||||
out.debug << "not ";
|
||||
out.debug << "tested first\n";
|
||||
|
||||
++depth;
|
||||
++depth;
|
||||
|
||||
OutputTreeText(infoSink, node, depth);
|
||||
if (node->getTest()) {
|
||||
out.debug << "Loop Condition\n";
|
||||
node->getTest()->traverse(this);
|
||||
} else
|
||||
out.debug << "No loop condition\n";
|
||||
OutputTreeText(infoSink, node, depth);
|
||||
if (node->getTest()) {
|
||||
out.debug << "Loop Condition\n";
|
||||
node->getTest()->traverse(this);
|
||||
} else
|
||||
out.debug << "No loop condition\n";
|
||||
|
||||
OutputTreeText(infoSink, node, depth);
|
||||
if (node->getBody()) {
|
||||
out.debug << "Loop Body\n";
|
||||
node->getBody()->traverse(this);
|
||||
} else
|
||||
out.debug << "No loop body\n";
|
||||
OutputTreeText(infoSink, node, depth);
|
||||
if (node->getBody()) {
|
||||
out.debug << "Loop Body\n";
|
||||
node->getBody()->traverse(this);
|
||||
} else
|
||||
out.debug << "No loop body\n";
|
||||
|
||||
if (node->getTerminal()) {
|
||||
OutputTreeText(infoSink, node, depth);
|
||||
out.debug << "Loop Terminal Expression\n";
|
||||
node->getTerminal()->traverse(this);
|
||||
}
|
||||
if (node->getTerminal()) {
|
||||
OutputTreeText(infoSink, node, depth);
|
||||
out.debug << "Loop Terminal Expression\n";
|
||||
node->getTerminal()->traverse(this);
|
||||
}
|
||||
|
||||
--depth;
|
||||
--depth;
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TOutputTraverser::visitBranch(Visit visit, TIntermBranch* node)
|
||||
{
|
||||
TInfoSink& out = infoSink;
|
||||
TInfoSink& out = infoSink;
|
||||
|
||||
OutputTreeText(out, node, depth);
|
||||
OutputTreeText(out, node, depth);
|
||||
|
||||
switch (node->getFlowOp()) {
|
||||
case EOpKill: out.debug << "Branch: Kill"; break;
|
||||
case EOpBreak: out.debug << "Branch: Break"; break;
|
||||
case EOpContinue: out.debug << "Branch: Continue"; break;
|
||||
case EOpReturn: out.debug << "Branch: Return"; break;
|
||||
default: out.debug << "Branch: Unknown Branch"; break;
|
||||
}
|
||||
switch (node->getFlowOp()) {
|
||||
case EOpKill: out.debug << "Branch: Kill"; break;
|
||||
case EOpBreak: out.debug << "Branch: Break"; break;
|
||||
case EOpContinue: out.debug << "Branch: Continue"; break;
|
||||
case EOpReturn: out.debug << "Branch: Return"; break;
|
||||
default: out.debug << "Branch: Unknown Branch"; break;
|
||||
}
|
||||
|
||||
if (node->getExpression()) {
|
||||
out.debug << " with expression\n";
|
||||
++depth;
|
||||
node->getExpression()->traverse(this);
|
||||
--depth;
|
||||
} else
|
||||
out.debug << "\n";
|
||||
if (node->getExpression()) {
|
||||
out.debug << " with expression\n";
|
||||
++depth;
|
||||
node->getExpression()->traverse(this);
|
||||
--depth;
|
||||
} else
|
||||
out.debug << "\n";
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -422,10 +415,10 @@ bool TOutputTraverser::visitBranch(Visit visit, TIntermBranch* node)
|
|||
//
|
||||
void TIntermediate::outputTree(TIntermNode* root)
|
||||
{
|
||||
if (root == 0)
|
||||
return;
|
||||
if (root == 0)
|
||||
return;
|
||||
|
||||
TOutputTraverser it(infoSink);
|
||||
TOutputTraverser it(infoSink);
|
||||
|
||||
root->traverse(&it);
|
||||
root->traverse(&it);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="compiler"
|
||||
Name="translator_common"
|
||||
ProjectGUID="{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}"
|
||||
RootNamespace="compiler"
|
||||
Keyword="Win32Proj"
|
||||
|
@ -149,10 +149,6 @@
|
|||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\CodeGen.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\glslang.l"
|
||||
>
|
||||
|
@ -235,10 +231,6 @@
|
|||
RelativePath=".\ossource.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\OutputHLSL.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\parseConst.cpp"
|
||||
>
|
||||
|
@ -365,10 +357,6 @@
|
|||
RelativePath=".\osinclude.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\OutputHLSL.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ParseHelper.h"
|
||||
>
|
|
@ -0,0 +1,183 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="translator_glsl"
|
||||
ProjectGUID="{65DB6E65-00E6-4533-8446-5F623BD94909}"
|
||||
RootNamespace="CrossCompilerGLSL"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="./;../;../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="./;../;../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\CodeGenGLSL.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\OutputGLSL.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TranslatorGLSL.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\OutputGLSL.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TranslatorGLSL.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,183 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="translator_hlsl"
|
||||
ProjectGUID="{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}"
|
||||
RootNamespace="CrossCompilerHLSL"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="./;../;../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="./;../;../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\CodeGenHLSL.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\OutputHLSL.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TranslatorHLSL.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\OutputHLSL.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TranslatorHLSL.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
Загрузка…
Ссылка в новой задаче