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,
// Reserve registers for the default uniform block and driver constants
mResourcesHLSL->reserveUniformBlockRegisters(2);
mSSBOOutputHLSL =
new ShaderStorageBlockOutputHLSL(this, symbolTable, mResourcesHLSL, shaderStorageBlocks);
mSSBOOutputHLSL = new ShaderStorageBlockOutputHLSL(this, mResourcesHLSL, shaderStorageBlocks);
}
OutputHLSL::~OutputHLSL()
......
......@@ -10,10 +10,9 @@
#ifndef COMPILER_TRANSLATOR_SHADERSTORAGEBLOCKOUTPUTHLSL_H_
#define COMPILER_TRANSLATOR_SHADERSTORAGEBLOCKOUTPUTHLSL_H_
#include <stack>
#include "compiler/translator/IntermNode.h"
#include "compiler/translator/ShaderStorageBlockFunctionHLSL.h"
#include "compiler/translator/blocklayout.h"
#include "compiler/translator/tree_util/IntermTraverse.h"
namespace sh
{
......@@ -37,15 +36,14 @@ using BlockMemberInfoMap = std::map<const TField *, BlockMemberInfo>;
using ShaderVarToFieldMap = std::map<std::string, const TField *>;
class ShaderStorageBlockOutputHLSL : public TIntermTraverser
class ShaderStorageBlockOutputHLSL
{
public:
ShaderStorageBlockOutputHLSL(OutputHLSL *outputHLSL,
TSymbolTable *symbolTable,
ResourcesHLSL *resourcesHLSL,
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
// calling this, ", <stored value>)" should be written to the output stream to complete the
......@@ -60,27 +58,21 @@ class ShaderStorageBlockOutputHLSL : public TIntermTraverser
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:
void traverseSSBOAccess(TIntermTyped *node, SSBOMethod method);
void setMatrixStride(TIntermTyped *node, TLayoutBlockStorage storage, bool rowMajor);
bool isEndOfSSBOAccessChain();
void writeEOpIndexDirectOrIndirectOutput(TInfoSinkBase &out, Visit visit, TIntermBinary *node);
TIntermTyped *traverseNode(TInfoSinkBase &out,
TIntermTyped *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.
void writeDotOperatorOutput(TInfoSinkBase &out, const TField *field);
TIntermTyped *createFieldOffset(const TField *field, BlockMemberInfo *blockMemberInfo);
void collectShaderStorageBlocks(TIntermTyped *node);
int mMatrixStride;
bool mRowMajor;
std::stack<SSBOMethod> mMethodTypeStack;
OutputHLSL *mOutputHLSL;
ShaderStorageBlockFunctionHLSL *mSSBOFunctionHLSL;
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