From df9dc5710725d00630831b77ca7005e390383aa6 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 28 Jan 2019 12:28:05 -0500 Subject: Feature/bit cast glsl (#808) * First attempt at asint, asuint, asfloat intrinsics. * Test with countbits * Placing glsl definitions first makes them get picked up. * Some more improvements around asint. * Add support for vector versions of asint/asunit * Fix some typos in asuint/asint intrinsics for glsl. Simplified and increased coverage of as/u/int tests. * Added bit-cast-double test. Added notional support for asdouble bit casts to glsl - but couldn't test because glslang doesn't seem to support the extension. * Try to get double bit casts working - doesn't work cos of block issue. * Only output parents on intrinic replacement if return type is not void. --- source/slang/emit.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'source/slang/emit.cpp') diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 914aea7fd..71b961616 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -3002,9 +3002,19 @@ struct EmitVisitor } else { + // If it returns void -> then we don't need parenthesis + + const auto returnType = inst->getDataType(); + const bool isVoid = as(returnType) != nullptr; + + // We could determine here is the return type is void... if so no braces? + // General case: we are going to emit some more complex text. - Emit("("); + if (!isVoid) + { + Emit("("); + } char const* cursor = name.begin(); char const* end = name.end(); @@ -3364,7 +3374,10 @@ struct EmitVisitor } } - Emit(")"); + if (!isVoid) + { + Emit(")"); + } } } -- cgit v1.2.3