Validate matching uniform precisions.

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@1941 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent fe3c0ef0
#define MAJOR_VERSION 1
#define MINOR_VERSION 1
#define BUILD_VERSION 0
#define BUILD_REVISION 1818
#define BUILD_REVISION 1831
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -1627,14 +1627,16 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length)
for (unsigned int i = 0; i < size; ++i)
{
GLenum type;
GLenum precision;
std::string name;
unsigned int arraySize;
stream.read(&type);
stream.read(&precision);
stream.read(&name);
stream.read(&arraySize);
mUniforms[i] = new Uniform(type, name, arraySize);
mUniforms[i] = new Uniform(type, precision, name, arraySize);
stream.read(&mUniforms[i]->psRegisterIndex);
stream.read(&mUniforms[i]->vsRegisterIndex);
......@@ -1762,6 +1764,7 @@ bool ProgramBinary::save(void* binary, GLsizei bufSize, GLsizei *length)
for (unsigned int i = 0; i < mUniforms.size(); ++i)
{
stream.write(mUniforms[i]->type);
stream.write(mUniforms[i]->precision);
stream.write(mUniforms[i]->name);
stream.write(mUniforms[i]->arraySize);
......@@ -2054,18 +2057,18 @@ bool ProgramBinary::defineUniform(GLenum shader, const sh::Uniform &constant, In
Uniform *uniform = NULL;
GLint location = getUniformLocation(constant.name);
if (location >= 0) // Previously defined, types must match
if (location >= 0) // Previously defined, type and precision must match
{
uniform = mUniforms[mUniformIndex[location].index];
if (uniform->type != constant.type)
if (uniform->type != constant.type || uniform->precision != constant.precision)
{
return false;
}
}
else
{
uniform = new Uniform(constant.type, constant.name, constant.arraySize);
uniform = new Uniform(constant.type, constant.precision, constant.name, constant.arraySize);
}
if (!uniform)
......
......@@ -12,8 +12,8 @@
namespace gl
{
Uniform::Uniform(GLenum type, const std::string &name, unsigned int arraySize)
: type(type), name(name), arraySize(arraySize)
Uniform::Uniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize)
: type(type), precision(precision), name(name), arraySize(arraySize)
{
int bytes = gl::UniformInternalSize(type) * elementCount();
data = new unsigned char[bytes];
......
......@@ -21,7 +21,7 @@ namespace gl
// Helper struct representing a single shader uniform
struct Uniform
{
Uniform(GLenum type, const std::string &name, unsigned int arraySize);
Uniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize);
~Uniform();
......@@ -29,6 +29,7 @@ struct Uniform
unsigned int elementCount() const;
const GLenum type;
const GLenum precision;
const std::string name;
const unsigned int arraySize;
......
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