diff options
| author | Yong He <yonghe@outlook.com> | 2024-01-22 15:19:26 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-22 15:19:26 -0800 |
| commit | fec9c42d4c61d1bdd54d020d55a3155e0d54fce7 (patch) | |
| tree | 0e1c1777cad8dfab2766c6dee9635549445df428 /source | |
| parent | c4e42ab49019bcd9f05217abe8e5d4c083622473 (diff) | |
Bug fixes for the direct spirv backend. (#3474)
* Fix GLSL legalization bug that leads to crash.
* Update diagnostic id to avoid conflict.
* Fix std140 layout logic.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-diagnostic-defs.h | 2 | ||||
| -rw-r--r-- | source/slang/slang-ir-glsl-legalize.cpp | 10 | ||||
| -rw-r--r-- | source/slang/slang-ir-layout.cpp | 5 |
3 files changed, 12 insertions, 5 deletions
diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h index b7189ab0d..9bad4b716 100644 --- a/source/slang/slang-diagnostic-defs.h +++ b/source/slang/slang-diagnostic-defs.h @@ -451,7 +451,7 @@ DIAGNOSTIC(30510, Error, loopInDiffFuncRequireUnrollOrMaxIters, "loops inside a DIAGNOSTIC(39999, Fatal, cyclicReference, "cyclic reference '$0'.") DIAGNOSTIC(39999, Error, localVariableUsedBeforeDeclared, "local variable '$0' is being used before its declaration.") DIAGNOSTIC(39999, Error, variableUsedInItsOwnDefinition, "the initial-value expression for variable '$0' depends on the value of the variable itself") -DIAGNOSTIC(39001, Fatal , cannotProcessInclude, "internal compiler error: cannot process '__include' in the current semantic checking context.") +DIAGNOSTIC(39901, Fatal , cannotProcessInclude, "internal compiler error: cannot process '__include' in the current semantic checking context.") // 304xx: generics DIAGNOSTIC(30400, Error, genericTypeNeedsArgs, "generic type '$0' used without argument") diff --git a/source/slang/slang-ir-glsl-legalize.cpp b/source/slang/slang-ir-glsl-legalize.cpp index 4d2b12bc4..65efde214 100644 --- a/source/slang/slang-ir-glsl-legalize.cpp +++ b/source/slang/slang-ir-glsl-legalize.cpp @@ -1599,7 +1599,10 @@ void assign( auto arrayIndexInst = builder->getIntValue(builder->getIntType(), arrayIndex); // Store to the index - auto address = builder->emitElementAddress(right.irValue->getFullType(), left.irValue, arrayIndexInst); + auto address = builder->emitElementAddress( + builder->getPtrType(right.irValue->getFullType()), + left.irValue, + arrayIndexInst); builder->emitStore(address, rhs); break; @@ -1613,7 +1616,10 @@ void assign( auto address = left.irValue; if(index) { - address = builder->emitElementAddress(right.irValue->getFullType(), left.irValue, index); + address = builder->emitElementAddress( + builder->getPtrType(right.irValue->getFullType()), + left.irValue, + index); } builder->emitStore(address, right.irValue); break; diff --git a/source/slang/slang-ir-layout.cpp b/source/slang/slang-ir-layout.cpp index 79012e7ba..a6684c7b1 100644 --- a/source/slang/slang-ir-layout.cpp +++ b/source/slang/slang-ir-layout.cpp @@ -461,9 +461,10 @@ struct Std140LayoutRules : IRTypeLayoutRules } virtual IRSizeAndAlignment getVectorSizeAndAlignment(IRSizeAndAlignment element, IRIntegerValue count) { + IRIntegerValue alignmentCount = count; if (count == 3) - count = 4; - return IRSizeAndAlignment((int)(element.size * count), (int)(element.size * count)); + alignmentCount = 4; + return IRSizeAndAlignment((int)(element.size * count), (int)(element.size * alignmentCount)); } }; |
