Eliminated storing decorated uniform names.

TRAC #22326 Signed-off-by: Daniel Koch Signed-off-by: Shannon Woods Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1635 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 2275f915
#define MAJOR_VERSION 1 #define MAJOR_VERSION 1
#define MINOR_VERSION 1 #define MINOR_VERSION 1
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 1563 #define BUILD_REVISION 1564
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -2579,11 +2579,7 @@ TString OutputHLSL::decorate(const TString &string) ...@@ -2579,11 +2579,7 @@ TString OutputHLSL::decorate(const TString &string)
TString OutputHLSL::decorateUniform(const TString &string, const TType &type) TString OutputHLSL::decorateUniform(const TString &string, const TType &type)
{ {
if (type.isArray()) if (type.getBasicType() == EbtSamplerExternalOES)
{
return "ar_" + string; // Allows identifying arrays of size 1
}
else if (type.getBasicType() == EbtSamplerExternalOES)
{ {
return "ex_" + string; return "ex_" + string;
} }
......
...@@ -30,8 +30,8 @@ std::string str(int i) ...@@ -30,8 +30,8 @@ std::string str(int i)
return buffer; return buffer;
} }
UniformLocation::UniformLocation(const std::string &_name, unsigned int element, unsigned int index) UniformLocation::UniformLocation(const std::string &name, unsigned int element, unsigned int index)
: name(Uniform::undecorate(_name)), element(element), index(index) : name(name), element(element), index(index)
{ {
} }
...@@ -1577,14 +1577,14 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length) ...@@ -1577,14 +1577,14 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length)
for (unsigned int i = 0; i < size; ++i) for (unsigned int i = 0; i < size; ++i)
{ {
GLenum type; GLenum type;
std::string _name; std::string name;
unsigned int arraySize; unsigned int arraySize;
stream.read(&type); stream.read(&type);
stream.read(&_name); stream.read(&name);
stream.read(&arraySize); stream.read(&arraySize);
mUniforms[i] = new Uniform(type, _name, arraySize); mUniforms[i] = new Uniform(type, name, arraySize);
stream.read(&mUniforms[i]->ps.registerIndex); stream.read(&mUniforms[i]->ps.registerIndex);
stream.read(&mUniforms[i]->ps.registerCount); stream.read(&mUniforms[i]->ps.registerCount);
...@@ -1694,7 +1694,7 @@ bool ProgramBinary::save(void* binary, GLsizei bufSize, GLsizei *length) ...@@ -1694,7 +1694,7 @@ bool ProgramBinary::save(void* binary, GLsizei bufSize, GLsizei *length)
for (unsigned int i = 0; i < mUniforms.size(); ++i) for (unsigned int i = 0; i < mUniforms.size(); ++i)
{ {
stream.write(mUniforms[i]->type); stream.write(mUniforms[i]->type);
stream.write(mUniforms[i]->_name); stream.write(mUniforms[i]->name);
stream.write(mUniforms[i]->arraySize); stream.write(mUniforms[i]->arraySize);
stream.write(mUniforms[i]->ps.registerIndex); stream.write(mUniforms[i]->ps.registerIndex);
......
...@@ -37,7 +37,7 @@ struct UniformLocation ...@@ -37,7 +37,7 @@ struct UniformLocation
{ {
} }
UniformLocation(const std::string &_name, unsigned int element, unsigned int index); UniformLocation(const std::string &name, unsigned int element, unsigned int index);
std::string name; std::string name;
unsigned int element; unsigned int element;
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
namespace gl namespace gl
{ {
Uniform::Uniform(GLenum type, const std::string &_name, unsigned int arraySize) Uniform::Uniform(GLenum type, const std::string &name, unsigned int arraySize)
: type(type), _name(_name), name(undecorate(_name)), arraySize(arraySize) : type(type), name(name), arraySize(arraySize)
{ {
int bytes = gl::UniformInternalSize(type) * elementCount(); int bytes = gl::UniformInternalSize(type) * elementCount();
data = new unsigned char[bytes]; data = new unsigned char[bytes];
...@@ -27,17 +27,7 @@ Uniform::~Uniform() ...@@ -27,17 +27,7 @@ Uniform::~Uniform()
bool Uniform::isArray() const bool Uniform::isArray() const
{ {
if (name != _name) // D3D9_REPLACE return arraySize > 0;
{
size_t dot = _name.find_last_of('.');
if (dot == std::string::npos) dot = -1;
return _name.compare(dot + 1, dot + 4, "ar_") == 0;
}
else
{
return arraySize > 0;
}
} }
unsigned int Uniform::elementCount() const unsigned int Uniform::elementCount() const
...@@ -50,28 +40,4 @@ unsigned int Uniform::registerCount() const ...@@ -50,28 +40,4 @@ unsigned int Uniform::registerCount() const
return VariableRowCount(type) * elementCount(); return VariableRowCount(type) * elementCount();
} }
std::string Uniform::undecorate(const std::string &_name)
{
std::string name = _name;
// Remove any structure field decoration
size_t pos = 0;
while ((pos = name.find("._", pos)) != std::string::npos)
{
name.replace(pos, 2, ".");
}
// Remove the leading decoration
if (name[0] == '_')
{
return name.substr(1);
}
else if (name.compare(0, 3, "ar_") == 0)
{
return name.substr(3);
}
return name;
}
} }
...@@ -21,18 +21,16 @@ namespace gl ...@@ -21,18 +21,16 @@ namespace gl
// Helper struct representing a single shader uniform // Helper struct representing a single shader uniform
struct Uniform struct Uniform
{ {
Uniform(GLenum type, const std::string &_name, unsigned int arraySize); Uniform(GLenum type, const std::string &name, unsigned int arraySize);
~Uniform(); ~Uniform();
bool isArray() const; bool isArray() const;
unsigned int elementCount() const; unsigned int elementCount() const;
unsigned int registerCount() const; unsigned int registerCount() const;
static std::string Uniform::undecorate(const std::string &_name);
const GLenum type; const GLenum type;
const std::string _name; // Decorated name const std::string name;
const std::string name; // Undecorated name
const unsigned int arraySize; const unsigned int arraySize;
unsigned char *data; unsigned char *data;
......
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