summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-type-layout.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-08-14 16:23:19 -0700
committerGitHub <noreply@github.com>2023-08-14 16:23:19 -0700
commit661d6198bbb9857d3fdc6df477e0742ed0b0765c (patch)
tree974a57cfa2e43624e91502e9e652a0cc78105b3a /source/slang/slang-type-layout.cpp
parent0403e0556b470f6b316153caea2dc6f5c314da5b (diff)
Support per field matrix layout (#3101)
* Support per field matrix layout * Fix warnings. * Fix. * Fix tests. * Fix spiv gen. * Fix. * More test fixes. * Fix. * Run only GPU tests on self-hosted servers. * Remove -use-glsl-matrix-layout-modifier. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-type-layout.cpp')
-rw-r--r--source/slang/slang-type-layout.cpp28
1 files changed, 8 insertions, 20 deletions
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp
index d075b12e2..bf3df4adc 100644
--- a/source/slang/slang-type-layout.cpp
+++ b/source/slang/slang-type-layout.cpp
@@ -2866,23 +2866,6 @@ static TypeLayoutResult _createTypeLayout(
if (declForModifiers)
{
- // TODO: The approach implemented here has a row/column-major
- // layout model recursively affect any sub-fields (so that
- // the layout of a nested struct depends on the context where
- // it is nested). This is consistent with the GLSL behavior
- // for these modifiers, but it is *not* how HLSL is supposed
- // to work.
- //
- // In the trivial case where `row_major` and `column_major`
- // are only applied to leaf fields/variables of matrix type
- // the difference should be immaterial.
-
- if (declForModifiers->hasModifier<RowMajorLayoutModifier>())
- subContext.matrixLayoutMode = kMatrixLayoutMode_RowMajor;
-
- if (declForModifiers->hasModifier<ColumnMajorLayoutModifier>())
- subContext.matrixLayoutMode = kMatrixLayoutMode_ColumnMajor;
-
// TODO: really need to look for other modifiers that affect
// layout, such as GLSL `std140`.
}
@@ -3866,7 +3849,12 @@ static TypeLayoutResult _createTypeLayout(
//
size_t layoutMajorCount = rowCount;
size_t layoutMinorCount = colCount;
- if (context.matrixLayoutMode == kMatrixLayoutMode_ColumnMajor)
+ auto matrixLayout = getIntVal(matType->getLayout());
+ if (matrixLayout == SLANG_MATRIX_LAYOUT_MODE_UNKNOWN)
+ {
+ matrixLayout = context.matrixLayoutMode;
+ }
+ if (matrixLayout == SLANG_MATRIX_LAYOUT_COLUMN_MAJOR)
{
size_t tmp = layoutMajorCount;
layoutMajorCount = layoutMinorCount;
@@ -3891,7 +3879,7 @@ static TypeLayoutResult _createTypeLayout(
size_t rowStride = 0;
size_t colStride = 0;
- if(context.matrixLayoutMode == kMatrixLayoutMode_ColumnMajor)
+ if (matrixLayout == SLANG_MATRIX_LAYOUT_COLUMN_MAJOR)
{
colStride = majorStride;
rowStride = minorStride;
@@ -3918,7 +3906,7 @@ static TypeLayoutResult _createTypeLayout(
typeLayout->elementTypeLayout = rowTypeLayout;
typeLayout->uniformStride = rowStride;
- typeLayout->mode = context.matrixLayoutMode;
+ typeLayout->mode = (MatrixLayoutMode)matrixLayout;
typeLayout->addResourceUsage(info.kind, info.size);