Commit 5a737833 by Shahbaz Youssefi Committed by Angle LUCI CQ

Vulkan: SPIR-V Gen: Fix row-major matrices

Prior to this change, row-major and column-major matrices generated different types. That is not correct. With this change, the same type is generated for both. Row-major only comes into account when calculating the alignment and offset of fields in a block. Bug: angleproject:4889 Change-Id: Ifa03e1799a2510b90323d9d4fc2f681a3184069b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2953367 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 74c6c144
...@@ -51,9 +51,8 @@ struct SpirvType ...@@ -51,9 +51,8 @@ struct SpirvType
// - `matrixPacking` only applies to members of a struct // - `matrixPacking` only applies to members of a struct
TBasicType type = EbtFloat; TBasicType type = EbtFloat;
uint8_t primarySize = 1; uint8_t primarySize = 1;
uint8_t secondarySize = 1; uint8_t secondarySize = 1;
TLayoutMatrixPacking matrixPacking = EmpColumnMajor;
TSpan<const unsigned int> arraySizes; TSpan<const unsigned int> arraySizes;
...@@ -117,14 +116,13 @@ struct SpirvTypeHash ...@@ -117,14 +116,13 @@ struct SpirvTypeHash
static_assert(sh::EbtLast < 256, "Basic type doesn't fit in uint8_t"); static_assert(sh::EbtLast < 256, "Basic type doesn't fit in uint8_t");
static_assert(sh::EbsLast < 8, "Block storage doesn't fit in 3 bits"); static_assert(sh::EbsLast < 8, "Block storage doesn't fit in 3 bits");
static_assert(sh::EiifLast < 32, "Image format doesn't fit in 5 bits"); static_assert(sh::EiifLast < 32, "Image format doesn't fit in 5 bits");
static_assert(sh::EmpLast < 4, "Matrix packing doesn't fit in 2 bits");
ASSERT(type.primarySize > 0 && type.primarySize <= 4); ASSERT(type.primarySize > 0 && type.primarySize <= 4);
ASSERT(type.secondarySize > 0 && type.secondarySize <= 4); ASSERT(type.secondarySize > 0 && type.secondarySize <= 4);
const uint8_t properties[4] = { const uint8_t properties[4] = {
static_cast<uint8_t>(type.type), static_cast<uint8_t>(type.type),
static_cast<uint8_t>((type.primarySize - 1) | (type.secondarySize - 1) << 2 | static_cast<uint8_t>((type.primarySize - 1) | (type.secondarySize - 1) << 2 |
type.isSamplerBaseImage << 4 | type.matrixPacking << 5), type.isSamplerBaseImage << 4),
static_cast<uint8_t>(type.blockStorage | type.imageInternalFormat << 3), static_cast<uint8_t>(type.blockStorage | type.imageInternalFormat << 3),
// Padding because ComputeGenericHash expects a key size divisible by 4 // Padding because ComputeGenericHash expects a key size divisible by 4
}; };
...@@ -161,8 +159,6 @@ struct SpirvTypeData ...@@ -161,8 +159,6 @@ struct SpirvTypeData
// applicable). // applicable).
uint32_t baseAlignment; uint32_t baseAlignment;
uint32_t sizeInStorageBlock; uint32_t sizeInStorageBlock;
// The matrix stride, if matrix or array of matrix.
uint32_t matrixStride;
}; };
// Decorations to be applied to variable or intermediate ids which are not part of the SPIR-V type // Decorations to be applied to variable or intermediate ids which are not part of the SPIR-V type
...@@ -350,9 +346,9 @@ class SPIRVBuilder : angle::NonCopyable ...@@ -350,9 +346,9 @@ class SPIRVBuilder : angle::NonCopyable
private: private:
SpirvTypeData declareType(const SpirvType &type, const char *blockName); SpirvTypeData declareType(const SpirvType &type, const char *blockName);
uint32_t calculateBaseAlignmentAndSize(const SpirvType &type, const SpirvTypeData &getFieldTypeDataForAlignmentAndSize(const TType &type,
uint32_t *sizeInStorageBlockOut, TLayoutBlockStorage blockStorage);
uint32_t *matrixStrideOut); uint32_t calculateBaseAlignmentAndSize(const SpirvType &type, uint32_t *sizeInStorageBlockOut);
uint32_t calculateSizeAndWriteOffsetDecorations(const SpirvType &type, spirv::IdRef typeId); uint32_t calculateSizeAndWriteOffsetDecorations(const SpirvType &type, spirv::IdRef typeId);
void writeMemberDecorations(const SpirvType &type, spirv::IdRef typeId); void writeMemberDecorations(const SpirvType &type, spirv::IdRef typeId);
......
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