diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2023-05-05 03:46:42 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-04 12:46:42 -0700 |
| commit | ab3ac985479132856613d6dcc8b43f4a4ef8c6b7 (patch) | |
| tree | e4e911d10b8ec2866e7e408f9a10b51d743ee675 /source/slang | |
| parent | c0b6f59a6920a9efbb4ecc3b622529db484c64ef (diff) | |
Add SLANG_ASSUME and use it in release asserts (#2859)
* Remove UNREACHABLE
* formatting
* Remove unused SLANG_EXPECT macros
* Add SLANG_ASSUME and use it in release asserts
* Reassure GCC that we are using memcpy responsibly
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang')
| -rw-r--r-- | source/slang/slang-emit-hlsl.cpp | 2 | ||||
| -rw-r--r-- | source/slang/slang-ir-glsl-legalize.cpp | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp index 434f0803e..96b751789 100644 --- a/source/slang/slang-emit-hlsl.cpp +++ b/source/slang/slang-emit-hlsl.cpp @@ -1168,7 +1168,7 @@ void HLSLSourceEmitter::emitMeshOutputModifiersImpl(IRInst* varInst) : as<IRIndicesDecoration>(modifier) ? "indices " : as<IRPrimitivesDecoration>(modifier) ? "primitives " : nullptr; - SLANG_EXPECT(s, "Unhandled type of mesh output decoration"); + SLANG_ASSERT(s && "Unhandled type of mesh output decoration"); m_writer->emit(s); } } diff --git a/source/slang/slang-ir-glsl-legalize.cpp b/source/slang/slang-ir-glsl-legalize.cpp index 8181deb1b..f6df7aa23 100644 --- a/source/slang/slang-ir-glsl-legalize.cpp +++ b/source/slang/slang-ir-glsl-legalize.cpp @@ -952,7 +952,7 @@ ScalarizedVal createSimpleGLSLGlobalVarying( // It's legal to declare these as unsized arrays, but by sizing // them by the (max) max size GLSL allows us to index into them // with variable index. - SLANG_EXPECT(dd->elementCount, "Mesh output declarator didn't specify element count"); + SLANG_ASSERT(dd->elementCount && "Mesh output declarator didn't specify element count"); auto arrayType = builder->getArrayType(type, dd->elementCount); IRArrayTypeLayout::Builder arrayTypeLayoutBuilder(builder, typeLayout); @@ -1737,7 +1737,7 @@ void legalizeMeshOutputParam( { auto builder = context->getBuilder(); auto stage = context->getStage(); - SLANG_EXPECT(stage == Stage::Mesh, "legalizing mesh output, but we're not a mesh shader"); + SLANG_ASSERT(stage == Stage::Mesh && "legalizing mesh output, but we're not a mesh shader"); IRBuilderInsertLocScope locScope{builder}; builder->setInsertInto(func); @@ -1814,7 +1814,7 @@ void legalizeMeshOutputParam( traverseUsers(g, [&](IRInst* u) { auto l = as<IRLoad>(u); - SLANG_EXPECT(l, "Mesh Output sentinel parameter wasn't used in a load"); + SLANG_ASSERT(l && "Mesh Output sentinel parameter wasn't used in a load"); std::function<void(ScalarizedVal&, IRInst*)> assignUses = [&](ScalarizedVal& d, IRInst* a) @@ -1838,7 +1838,7 @@ void legalizeMeshOutputParam( if(auto m = as<IRFieldAddress>(s)) { auto key = as<IRStructKey>(m->getField()); - SLANG_EXPECT(key, "Result of getField wasn't a struct key"); + SLANG_ASSERT(key && "Result of getField wasn't a struct key"); auto d_ = extractField(builder, d, kMaxUInt, key); assignUses(d_, m); @@ -1880,7 +1880,7 @@ void legalizeMeshOutputParam( // best we can hope for without going and // specializing foo. auto ptr = as<IRPtrTypeBase>(a->getFullType()); - SLANG_EXPECT(ptr, "Mesh output parameter was passed by value"); + SLANG_ASSERT(ptr && "Mesh output parameter was passed by value"); auto t = ptr->getValueType(); auto tmp = builder->emitVar(t); for(UInt i = 0; i < c->getOperandCount(); i++) @@ -2045,7 +2045,7 @@ void legalizeMeshOutputParam( traverseUsers(builtin.param, [&](IRInst* u) { auto p = as<IRGetElementPtr>(u); - SLANG_EXPECT(p, "Mesh Output sentinel parameter wasn't used as an array"); + SLANG_ASSERT(p && "Mesh Output sentinel parameter wasn't used as an array"); IRBuilderInsertLocScope locScope{builder}; builder->setInsertBefore(p); |
