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/294962
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index 555d794..b61fb6d 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -329,7 +329,7 @@
RemovePow(root);
}
- if (success && (compileOptions & SH_VARIABLES))
+ if (success && shouldCollectVariables(compileOptions))
{
collectVariables(root);
if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS)
diff --git a/src/compiler/translator/Compiler.h b/src/compiler/translator/Compiler.h
index 1fb5c82..cedb20c 100644
--- a/src/compiler/translator/Compiler.h
+++ b/src/compiler/translator/Compiler.h
@@ -164,6 +164,11 @@
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);
diff --git a/src/compiler/translator/TranslatorHLSL.h b/src/compiler/translator/TranslatorHLSL.h
index 1920ed5..907d816 100644
--- a/src/compiler/translator/TranslatorHLSL.h
+++ b/src/compiler/translator/TranslatorHLSL.h
@@ -13,7 +13,7 @@
{
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 @@
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;