Commit ac8e1196 by Stephen White Committed by Commit Bot

SSBO handling rewrite.

The basic idea is to replace the current SSBO output traversal by build a new AST for the Load and Store subtrees, then traverse that AST with the regular OutputHLSL traversal. This way, all the paren balancing and state management can go away. BUG: angleproject:5734 Change-Id: I14d2fecd724d7419fbc9315fad4e9202a741b03f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2773401 Commit-Queue: Stephen White <senorblanco@chromium.org> Reviewed-by: 's avatarJiajia Qin <jiajia.qin@intel.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 525fde75
...@@ -387,8 +387,7 @@ OutputHLSL::OutputHLSL(sh::GLenum shaderType, ...@@ -387,8 +387,7 @@ OutputHLSL::OutputHLSL(sh::GLenum shaderType,
// Reserve registers for the default uniform block and driver constants // Reserve registers for the default uniform block and driver constants
mResourcesHLSL->reserveUniformBlockRegisters(2); mResourcesHLSL->reserveUniformBlockRegisters(2);
mSSBOOutputHLSL = mSSBOOutputHLSL = new ShaderStorageBlockOutputHLSL(this, mResourcesHLSL, shaderStorageBlocks);
new ShaderStorageBlockOutputHLSL(this, symbolTable, mResourcesHLSL, shaderStorageBlocks);
} }
OutputHLSL::~OutputHLSL() OutputHLSL::~OutputHLSL()
......
...@@ -10,10 +10,9 @@ ...@@ -10,10 +10,9 @@
#ifndef COMPILER_TRANSLATOR_SHADERSTORAGEBLOCKOUTPUTHLSL_H_ #ifndef COMPILER_TRANSLATOR_SHADERSTORAGEBLOCKOUTPUTHLSL_H_
#define COMPILER_TRANSLATOR_SHADERSTORAGEBLOCKOUTPUTHLSL_H_ #define COMPILER_TRANSLATOR_SHADERSTORAGEBLOCKOUTPUTHLSL_H_
#include <stack> #include "compiler/translator/IntermNode.h"
#include "compiler/translator/ShaderStorageBlockFunctionHLSL.h" #include "compiler/translator/ShaderStorageBlockFunctionHLSL.h"
#include "compiler/translator/blocklayout.h" #include "compiler/translator/blocklayout.h"
#include "compiler/translator/tree_util/IntermTraverse.h"
namespace sh namespace sh
{ {
...@@ -37,15 +36,14 @@ using BlockMemberInfoMap = std::map<const TField *, BlockMemberInfo>; ...@@ -37,15 +36,14 @@ using BlockMemberInfoMap = std::map<const TField *, BlockMemberInfo>;
using ShaderVarToFieldMap = std::map<std::string, const TField *>; using ShaderVarToFieldMap = std::map<std::string, const TField *>;
class ShaderStorageBlockOutputHLSL : public TIntermTraverser class ShaderStorageBlockOutputHLSL
{ {
public: public:
ShaderStorageBlockOutputHLSL(OutputHLSL *outputHLSL, ShaderStorageBlockOutputHLSL(OutputHLSL *outputHLSL,
TSymbolTable *symbolTable,
ResourcesHLSL *resourcesHLSL, ResourcesHLSL *resourcesHLSL,
const std::vector<InterfaceBlock> &shaderStorageBlocks); const std::vector<InterfaceBlock> &shaderStorageBlocks);
~ShaderStorageBlockOutputHLSL() override; ~ShaderStorageBlockOutputHLSL();
// This writes part of the function call to store a value to a SSBO to the output stream. After // This writes part of the function call to store a value to a SSBO to the output stream. After
// calling this, ", <stored value>)" should be written to the output stream to complete the // calling this, ", <stored value>)" should be written to the output stream to complete the
...@@ -60,27 +58,21 @@ class ShaderStorageBlockOutputHLSL : public TIntermTraverser ...@@ -60,27 +58,21 @@ class ShaderStorageBlockOutputHLSL : public TIntermTraverser
void writeShaderStorageBlocksHeader(TInfoSinkBase &out) const; void writeShaderStorageBlocksHeader(TInfoSinkBase &out) const;
protected:
void visitSymbol(TIntermSymbol *) override;
void visitConstantUnion(TIntermConstantUnion *) override;
bool visitSwizzle(Visit visit, TIntermSwizzle *node) override;
bool visitBinary(Visit visit, TIntermBinary *) override;
bool visitAggregate(Visit visit, TIntermAggregate *node) override;
bool visitTernary(Visit visit, TIntermTernary *) override;
bool visitUnary(Visit visit, TIntermUnary *) override;
private: private:
void traverseSSBOAccess(TIntermTyped *node, SSBOMethod method); void traverseSSBOAccess(TIntermTyped *node, SSBOMethod method);
void setMatrixStride(TIntermTyped *node, TLayoutBlockStorage storage, bool rowMajor); TIntermTyped *traverseNode(TInfoSinkBase &out,
bool isEndOfSSBOAccessChain(); TIntermTyped *node,
void writeEOpIndexDirectOrIndirectOutput(TInfoSinkBase &out, Visit visit, TIntermBinary *node); BlockMemberInfo *blockMemberInfo);
int getMatrixStride(TIntermTyped *node,
TLayoutBlockStorage storage,
bool rowMajor,
bool *isRowMajor) const;
TIntermTyped *writeEOpIndexDirectOrIndirectOutput(TInfoSinkBase &out,
TIntermBinary *node,
BlockMemberInfo *blockMemberInfo);
// Common part in dot operations. // Common part in dot operations.
void writeDotOperatorOutput(TInfoSinkBase &out, const TField *field); TIntermTyped *createFieldOffset(const TField *field, BlockMemberInfo *blockMemberInfo);
void collectShaderStorageBlocks(TIntermTyped *node); void collectShaderStorageBlocks(TIntermTyped *node);
int mMatrixStride;
bool mRowMajor;
std::stack<SSBOMethod> mMethodTypeStack;
OutputHLSL *mOutputHLSL; OutputHLSL *mOutputHLSL;
ShaderStorageBlockFunctionHLSL *mSSBOFunctionHLSL; ShaderStorageBlockFunctionHLSL *mSSBOFunctionHLSL;
ResourcesHLSL *mResourcesHLSL; ResourcesHLSL *mResourcesHLSL;
......
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