Assign constant registers manually in HLSL.

TRAC #22293 Signed-off-by: Daniel Koch Signed-off-by: Shannon Woods Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1622 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 3ca980a3
......@@ -89,6 +89,9 @@ OutputHLSL::OutputHLSL(TParseContext &context) : TIntermTraverser(true, true, tr
mInsideDiscontinuousLoop = false;
mExcessiveLoopIndex = NULL;
mUniformRegister = 0;
mSamplerRegister = 0;
}
OutputHLSL::~OutputHLSL()
......@@ -144,7 +147,8 @@ void OutputHLSL::header()
const TType &type = uniform->second->getType();
const TString &name = uniform->second->getSymbol();
uniforms += "uniform " + typeString(type) + " " + decorateUniform(name, type) + arrayString(type) + ";\n";
uniforms += "uniform " + typeString(type) + " " + decorateUniform(name, type) + arrayString(type) +
" : register(" + registerString(mReferencedUniforms[name]) + ");\n";
}
for (ReferencedSymbols::const_iterator varying = mReferencedVaryings.begin(); varying != mReferencedVaryings.end(); varying++)
......@@ -2591,4 +2595,39 @@ TString OutputHLSL::decorateField(const TString &string, const TType &structure)
return string;
}
TString OutputHLSL::registerString(TIntermSymbol *operand)
{
ASSERT(operand->getQualifier() == EvqUniform);
if (IsSampler(operand->getBasicType()))
{
return "s" + str(samplerRegister(operand));
}
return "c" + str(uniformRegister(operand));
}
int OutputHLSL::samplerRegister(TIntermSymbol *sampler)
{
const TType &type = sampler->getType();
ASSERT(IsSampler(type.getBasicType()));
int index = mSamplerRegister;
mSamplerRegister += sampler->totalRegisterCount();
return index;
}
int OutputHLSL::uniformRegister(TIntermSymbol *uniform)
{
const TType &type = uniform->getType();
ASSERT(!IsSampler(type.getBasicType()));
int index = mUniformRegister;
mUniformRegister += uniform->totalRegisterCount();
return index;
}
}
......@@ -9,6 +9,10 @@
#include <list>
#include <set>
#include <map>
#define GL_APICALL
#include <GLES2/gl2.h>
#include "compiler/intermediate.h"
#include "compiler/ParseHelper.h"
......@@ -147,6 +151,13 @@ class OutputHLSL : public TIntermTraverser
bool mInsideDiscontinuousLoop;
TIntermSymbol *mExcessiveLoopIndex;
int mUniformRegister;
int mSamplerRegister;
TString registerString(TIntermSymbol *operand);
int samplerRegister(TIntermSymbol *sampler);
int uniformRegister(TIntermSymbol *uniform);
};
}
......
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