Commit be873929 by Shahbaz Youssefi Committed by Angle LUCI CQ

Vulkan: SPIR-V Gen: Handle constants and constructors

This change translates constants and constructors (minus type casting). With this change, shaders such as gl_Position = vec4(aposition, 0, 1); are translated correctly. Bug: angleproject:4889 Change-Id: I4463717cf880c6d05db179b98691d5cabc1a2d7c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2920192 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent c39e2a18
......@@ -51,7 +51,7 @@ spirv::IdRef SPIRVBuilder::getNewId()
return newId;
}
const SpirvTypeData &SPIRVBuilder::getTypeData(const TType &type, TLayoutBlockStorage blockStorage)
SpirvType SPIRVBuilder::getSpirvType(const TType &type, TLayoutBlockStorage blockStorage) const
{
SpirvType spirvType;
spirvType.type = type.getBasicType();
......@@ -68,16 +68,13 @@ const SpirvTypeData &SPIRVBuilder::getTypeData(const TType &type, TLayoutBlockSt
spirvType.matrixPacking = EmpColumnMajor;
}
const char *blockName = "";
if (type.getStruct() != nullptr)
{
spirvType.block = type.getStruct();
blockName = type.getStruct()->name().data();
}
else if (type.isInterfaceBlock())
{
spirvType.block = type.getInterfaceBlock();
blockName = type.getInterfaceBlock()->name().data();
// Calculate the block storage from the interface block automatically. The fields inherit
// from this. Default to std140.
......@@ -94,6 +91,23 @@ const SpirvTypeData &SPIRVBuilder::getTypeData(const TType &type, TLayoutBlockSt
spirvType.blockStorage = EbsUnspecified;
}
return spirvType;
}
const SpirvTypeData &SPIRVBuilder::getTypeData(const TType &type, TLayoutBlockStorage blockStorage)
{
SpirvType spirvType = getSpirvType(type, blockStorage);
const char *blockName = "";
if (type.getStruct() != nullptr)
{
blockName = type.getStruct()->name().data();
}
else if (type.isInterfaceBlock())
{
blockName = type.getInterfaceBlock()->name().data();
}
return getSpirvTypeData(spirvType, blockName);
}
......
......@@ -169,6 +169,7 @@ class SPIRVBuilder : angle::NonCopyable
{}
spirv::IdRef getNewId();
SpirvType getSpirvType(const TType &type, TLayoutBlockStorage blockStorage) const;
const SpirvTypeData &getTypeData(const TType &type, TLayoutBlockStorage blockStorage);
const SpirvTypeData &getSpirvTypeData(const SpirvType &type, const char *blockName);
spirv::IdRef getTypePointerId(spirv::IdRef typeId, spv::StorageClass storageClass);
......
......@@ -27,6 +27,8 @@ void TIntermTraverser::traverse(T *node)
bool visit = true;
mCurrentChildIndex = 0;
// Visit the node before children if pre-visiting.
if (preVisit)
visit = node->visit(PreVisit, this);
......@@ -38,6 +40,7 @@ void TIntermTraverser::traverse(T *node)
while (childIndex < childCount && visit)
{
mCurrentChildIndex = childIndex;
node->getChildNode(childIndex)->traverse(this);
if (inVisit && childIndex != childCount - 1)
{
......@@ -217,7 +220,8 @@ TIntermTraverser::TIntermTraverser(bool preVisit,
mMaxDepth(0),
mMaxAllowedDepth(std::numeric_limits<int>::max()),
mInGlobalScope(true),
mSymbolTable(symbolTable)
mSymbolTable(symbolTable),
mCurrentChildIndex(0)
{
// Only enabling inVisit is not supported.
ASSERT(!(inVisit && !preVisit && !postVisit));
......
......@@ -149,6 +149,11 @@ class TIntermTraverser : angle::NonCopyable
return nullptr;
}
// Returns what child index is currently being visited. For example when visiting the children
// of an aggregate, it can be used to find out which argument of the parent (aggregate) node
// they correspond to.
size_t getParentChildIndex() const { return mCurrentChildIndex; }
const TIntermBlock *getParentBlock() const;
TIntermNode *getRootNode() const
......@@ -287,6 +292,8 @@ class TIntermTraverser : angle::NonCopyable
// All the nodes from root to the current node during traversing.
TVector<TIntermNode *> mPath;
// The current child of parent being traversed.
size_t mCurrentChildIndex;
// All the code blocks from the root to the current node's parent during traversal.
std::vector<ParentBlock> mParentBlockStack;
......
......@@ -1053,7 +1053,7 @@ TEST_P(BufferStorageTestES3, StorageBufferMapBufferOES)
ANGLE_INSTANTIATE_TEST_ES2(BufferDataTest);
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(BufferDataTestES3);
ANGLE_INSTANTIATE_TEST_ES3(BufferDataTestES3);
ANGLE_INSTANTIATE_TEST_ES3_AND(BufferDataTestES3, WithDirectSPIRVGeneration(ES3_VULKAN()));
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(BufferStorageTestES3);
ANGLE_INSTANTIATE_TEST_ES3(BufferStorageTestES3);
......
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