Store the precision of uniforms.
TRAC #22635
Signed-off-by: Shannon Woods
Signed-off-by: Geoff Lang
Author: Nicolas Capens
git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1940 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index c7f86f2..90e6e14 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -3036,7 +3036,7 @@
if (!structure)
{
- mActiveUniforms.push_back(Uniform(glVariableType(type), name.c_str(), type.getArraySize(), index));
+ mActiveUniforms.push_back(Uniform(glVariableType(type), glVariablePrecision(type), name.c_str(), type.getArraySize(), index));
}
else
{
@@ -3153,4 +3153,39 @@
return GL_NONE;
}
+GLenum OutputHLSL::glVariablePrecision(const TType &type)
+{
+ if (type.getBasicType() == EbtFloat)
+ {
+ switch (type.getPrecision())
+ {
+ case EbpHigh: return GL_HIGH_FLOAT;
+ case EbpMedium: return GL_MEDIUM_FLOAT;
+ case EbpLow: return GL_LOW_FLOAT;
+ case EbpUndefined:
+ // Should be defined as the default precision by the parser
+ default: UNREACHABLE();
+ }
+ }
+ else if (type.getBasicType() == EbtInt)
+ {
+ switch (type.getPrecision())
+ {
+ case EbpHigh: return GL_HIGH_INT;
+ case EbpMedium: return GL_MEDIUM_INT;
+ case EbpLow: return GL_LOW_INT;
+ case EbpUndefined:
+ // Should be defined as the default precision by the parser
+ default: UNREACHABLE();
+ }
+ }
+ else if (type.getBasicType() == EbtBool)
+ {
+ return GL_BOOL; // Booleans don't have a precision
+ }
+ else UNREACHABLE();
+
+ return GL_NONE;
+}
+
}
diff --git a/src/compiler/OutputHLSL.h b/src/compiler/OutputHLSL.h
index cd1f55b..af69c29 100644
--- a/src/compiler/OutputHLSL.h
+++ b/src/compiler/OutputHLSL.h
@@ -164,6 +164,7 @@
int uniformRegister(TIntermSymbol *uniform);
void declareUniform(const TType &type, const TString &name, int index);
static GLenum glVariableType(const TType &type);
+ static GLenum glVariablePrecision(const TType &type);
ActiveUniforms mActiveUniforms;
};
diff --git a/src/compiler/Uniform.cpp b/src/compiler/Uniform.cpp
index 55177fa..dcf3af1 100644
--- a/src/compiler/Uniform.cpp
+++ b/src/compiler/Uniform.cpp
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 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,9 +9,10 @@
namespace sh
{
-Uniform::Uniform(GLenum type, const char *name, int arraySize, int registerIndex)
+Uniform::Uniform(GLenum type, GLenum precision, const char *name, int arraySize, int registerIndex)
{
this->type = type;
+ this->precision = precision;
this->name = name;
this->arraySize = arraySize;
this->registerIndex = registerIndex;
diff --git a/src/compiler/Uniform.h b/src/compiler/Uniform.h
index 3ace48e..2ffd51e 100644
--- a/src/compiler/Uniform.h
+++ b/src/compiler/Uniform.h
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 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.
//
@@ -18,9 +18,10 @@
struct Uniform
{
- Uniform(GLenum type, const char *name, int arraySize, int registerIndex);
+ Uniform(GLenum type, GLenum precision, const char *name, int arraySize, int registerIndex);
GLenum type;
+ GLenum precision;
std::string name;
unsigned int arraySize;