Pass the desired HLSL version down to the HLSL generator.

TRAC #22330 Signed-off-by: Geoff Lang Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1738 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent bd8c10c4
//
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
......@@ -36,7 +36,7 @@ extern "C" {
// Version number for shader translation API.
// It is incremented everytime the API changes.
#define SH_VERSION 108
#define SH_VERSION 109
//
// The names of the following enums have been derived by replacing GL prefix
......@@ -77,9 +77,10 @@ typedef enum {
} ShShaderSpec;
typedef enum {
SH_ESSL_OUTPUT = 0x8B45,
SH_GLSL_OUTPUT = 0x8B46,
SH_HLSL_OUTPUT = 0x8B47
SH_ESSL_OUTPUT = 0x8B45,
SH_GLSL_OUTPUT = 0x8B46,
SH_HLSL9_OUTPUT = 0x8B47,
SH_HLSL11_OUTPUT = 0x8B48
} ShShaderOutput;
typedef enum {
......
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
......@@ -14,9 +14,11 @@
TCompiler* ConstructCompiler(
ShShaderType type, ShShaderSpec spec, ShShaderOutput output)
{
switch (output) {
case SH_HLSL_OUTPUT:
return new TranslatorHLSL(type, spec);
switch (output)
{
case SH_HLSL9_OUTPUT:
case SH_HLSL11_OUTPUT:
return new TranslatorHLSL(type, spec, output);
default:
return NULL;
}
......
......@@ -27,7 +27,8 @@ TString str(int i)
return buffer;
}
OutputHLSL::OutputHLSL(TParseContext &context) : TIntermTraverser(true, true, true), mContext(context)
OutputHLSL::OutputHLSL(TParseContext &context, ShShaderOutput outputType)
: TIntermTraverser(true, true, true), mContext(context), mOutputType(outputType)
{
mUnfoldShortCircuit = new UnfoldShortCircuit(context, this);
mInsideFunction = false;
......
......@@ -25,7 +25,7 @@ class UnfoldShortCircuit;
class OutputHLSL : public TIntermTraverser
{
public:
explicit OutputHLSL(TParseContext &context);
OutputHLSL(TParseContext &context, ShShaderOutput outputType);
~OutputHLSL();
void output();
......@@ -70,6 +70,7 @@ class OutputHLSL : public TIntermTraverser
TString structLookup(const TString &typeName);
TParseContext &mContext;
const ShShaderOutput mOutputType;
UnfoldShortCircuit *mUnfoldShortCircuit;
bool mInsideFunction;
......
//
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
......@@ -9,15 +9,15 @@
#include "compiler/InitializeParseContext.h"
#include "compiler/OutputHLSL.h"
TranslatorHLSL::TranslatorHLSL(ShShaderType type, ShShaderSpec spec)
: TCompiler(type, spec)
TranslatorHLSL::TranslatorHLSL(ShShaderType type, ShShaderSpec spec, ShShaderOutput output)
: TCompiler(type, spec), mOutputType(output)
{
}
void TranslatorHLSL::translate(TIntermNode *root)
{
TParseContext& parseContext = *GetGlobalParseContext();
sh::OutputHLSL outputHLSL(parseContext);
sh::OutputHLSL outputHLSL(parseContext, mOutputType);
outputHLSL.output();
mActiveUniforms = outputHLSL.getUniforms();
......
//
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
......@@ -12,7 +12,7 @@
class TranslatorHLSL : public TCompiler {
public:
TranslatorHLSL(ShShaderType type, ShShaderSpec spec);
TranslatorHLSL(ShShaderType type, ShShaderSpec spec, ShShaderOutput output);
virtual TranslatorHLSL *getAsTranslatorHLSL() { return this; }
const sh::ActiveUniforms &getUniforms() { return mActiveUniforms; }
......@@ -21,6 +21,7 @@ protected:
virtual void translate(TIntermNode* root);
sh::ActiveUniforms mActiveUniforms;
ShShaderOutput mOutputType;
};
#endif // COMPILER_TRANSLATORHLSL_H_
......@@ -82,11 +82,11 @@ GLuint ResourceManager::createShader(GLenum type)
if (type == GL_VERTEX_SHADER)
{
mShaderMap[handle] = new VertexShader(this, handle);
mShaderMap[handle] = new VertexShader(this, mRenderer, handle);
}
else if (type == GL_FRAGMENT_SHADER)
{
mShaderMap[handle] = new FragmentShader(this, handle);
mShaderMap[handle] = new FragmentShader(this, mRenderer, handle);
}
else UNREACHABLE();
......
//
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
......@@ -21,7 +21,8 @@ namespace gl
void *Shader::mFragmentCompiler = NULL;
void *Shader::mVertexCompiler = NULL;
Shader::Shader(ResourceManager *manager, GLuint handle) : mHandle(handle), mResourceManager(manager)
Shader::Shader(ResourceManager *manager, const rx::Renderer *renderer, GLuint handle)
: mHandle(handle), mRenderer(renderer), mResourceManager(manager)
{
mSource = NULL;
mHlsl = NULL;
......@@ -228,9 +229,11 @@ void Shader::initializeCompiler()
if (result)
{
Context *context = getContext();
ShShaderOutput hlslVersion = (mRenderer->getMajorShaderModel() >= 4) ? SH_HLSL11_OUTPUT : SH_HLSL9_OUTPUT;
ShBuiltInResources resources;
ShInitBuiltInResources(&resources);
Context *context = getContext();
resources.MaxVertexAttribs = MAX_VERTEX_ATTRIBS;
resources.MaxVertexUniformVectors = MAX_VERTEX_UNIFORM_VECTORS;
......@@ -243,8 +246,8 @@ void Shader::initializeCompiler()
resources.OES_standard_derivatives = context->supportsDerivativeInstructions() ? 1 : 0;
// resources.OES_EGL_image_external = getDisplay()->getRenderer()->getShareHandleSupport() ? 1 : 0; // TODO: commented out until the extension is actually supported.
mFragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_GLES2_SPEC, SH_HLSL_OUTPUT, &resources);
mVertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_GLES2_SPEC, SH_HLSL_OUTPUT, &resources);
mFragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_GLES2_SPEC, hlslVersion, &resources);
mVertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_GLES2_SPEC, hlslVersion, &resources);
}
}
}
......@@ -496,7 +499,8 @@ bool Shader::compareVarying(const Varying &x, const Varying &y)
return false;
}
VertexShader::VertexShader(ResourceManager *manager, GLuint handle) : Shader(manager, handle)
VertexShader::VertexShader(ResourceManager *manager, const rx::Renderer *renderer, GLuint handle)
: Shader(manager, renderer, handle)
{
}
......@@ -571,7 +575,8 @@ void VertexShader::parseAttributes()
}
}
FragmentShader::FragmentShader(ResourceManager *manager, GLuint handle) : Shader(manager, handle)
FragmentShader::FragmentShader(ResourceManager *manager, const rx::Renderer *renderer, GLuint handle)
: Shader(manager, renderer, handle)
{
}
......
//
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
......@@ -21,6 +21,11 @@
#include "libGLESv2/ResourceManager.h"
#include "compiler/Uniform.h"
namespace rx
{
class Renderer;
}
namespace gl
{
struct Varying
......@@ -46,7 +51,7 @@ class Shader
friend class ProgramBinary;
public:
Shader(ResourceManager *manager, GLuint handle);
Shader(ResourceManager *manager, const rx::Renderer *renderer, GLuint handle);
virtual ~Shader();
......@@ -86,6 +91,8 @@ class Shader
static GLenum parseType(const std::string &type);
static bool compareVarying(const Varying &x, const Varying &y);
const rx::Renderer *const mRenderer;
VaryingList mVaryings;
bool mUsesFragCoord;
......@@ -134,7 +141,7 @@ class VertexShader : public Shader
friend class ProgramBinary;
public:
VertexShader(ResourceManager *manager, GLuint handle);
VertexShader(ResourceManager *manager, const rx::Renderer *renderer, GLuint handle);
~VertexShader();
......@@ -154,7 +161,7 @@ class VertexShader : public Shader
class FragmentShader : public Shader
{
public:
FragmentShader(ResourceManager *manager, GLuint handle);
FragmentShader(ResourceManager *manager,const rx::Renderer *renderer, GLuint handle);
~FragmentShader();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment