Commit 4dfe8094 by Olli Etuaho

Always collect variables when generating HLSL

HLSL output needs uniform information generated by the collectVariables() step to be able to write uniform registers. Tested manually by compiling a shader with a uniform with shader_translator. BUG=angleproject:1132 Change-Id: I91d19b5fa789b7b33cf76a654ffbbd17d279db01 Reviewed-on: https://chromium-review.googlesource.com/294962Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org>
parent 4001e1da
......@@ -329,7 +329,7 @@ TIntermNode *TCompiler::compileTreeImpl(const char *const shaderStrings[],
RemovePow(root);
}
if (success && (compileOptions & SH_VARIABLES))
if (success && shouldCollectVariables(compileOptions))
{
collectVariables(root);
if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS)
......
......@@ -164,6 +164,11 @@ class TCompiler : public TShHandleBase
std::vector<sh::Varying> varyings;
std::vector<sh::InterfaceBlock> interfaceBlocks;
virtual bool shouldCollectVariables(int compileOptions)
{
return (compileOptions & SH_VARIABLES) != 0;
}
private:
// Creates the function call DAG for further analysis, returning false if there is a recursion
bool initCallDag(TIntermNode *root);
......
......@@ -13,7 +13,7 @@ class TranslatorHLSL : public TCompiler
{
public:
TranslatorHLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output);
virtual TranslatorHLSL *getAsTranslatorHLSL() { return this; }
TranslatorHLSL *getAsTranslatorHLSL() override { return this; }
bool hasInterfaceBlock(const std::string &interfaceBlockName) const;
unsigned int getInterfaceBlockRegister(const std::string &interfaceBlockName) const;
......@@ -22,7 +22,10 @@ class TranslatorHLSL : public TCompiler
unsigned int getUniformRegister(const std::string &uniformName) const;
protected:
virtual void translate(TIntermNode *root, int compileOptions);
void translate(TIntermNode *root, int compileOptions) override;
// collectVariables needs to be run always so registers can be assigned.
bool shouldCollectVariables(int compileOptions) override { return true; }
std::map<std::string, unsigned int> mInterfaceBlockRegisterMap;
std::map<std::string, unsigned int> mUniformRegisterMap;
......
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