HLSL: opcode specific promotion rules for interlocked ops
authorsteve-lunarg <steve_gh@khasekhemwy.net>
Tue, 6 Dec 2016 22:50:11 +0000 (15:50 -0700)
committersteve-lunarg <steve_gh@khasekhemwy.net>
Wed, 7 Dec 2016 19:00:32 +0000 (12:00 -0700)
commit05f75142d638a56b67dec6d4740a960089ce5973
tree998d67e84973203b12c87fd4384283faab8bc734
parentb56f4ac72c57f5c50f14ddb0bf1f78eaaef21c2b
HLSL: opcode specific promotion rules for interlocked ops

PR #577 addresses most but not all of the intrinsic promotion problems.
This PR resolves all known cases in the remainder.

Interlocked ops need special promotion rules because at the time
of function selection, the first argument has not been converted
to a buffer object.  It's just an int or uint, but you don't want
to convert THAT argument, because that implies converting the
buffer object itself.  Rather, you can convert other arguments,
but want to stay in the same "family" of functions.  E.g, if
the first interlocked arg is a uint, use only the uint family,
never the int family, you can convert the other args as you please.

This PR allows making such opcode and arg specific choices by
passing the op and arg to the convertible lambda.  The code in
the new test "hlsl.promote.atomic.frag" would not compile without
this change, but it must compile.

Also, it provides better handling of downconversions (to "worse"
types), which are permitted in HLSL.  The existing method of
selecting upconversions is unchanged, but if that doesn't find
any valid ones, then it will allow downconversions.  In effect
this always uses an upconversion if there is one.
Test/baseResults/hlsl.promote.atomic.frag.out [new file with mode: 0644]
Test/hlsl.promote.atomic.frag [new file with mode: 0644]
glslang/MachineIndependent/ParseContextBase.cpp
glslang/MachineIndependent/ParseHelper.cpp
glslang/MachineIndependent/ParseHelper.h
gtests/Hlsl.FromFile.cpp
hlsl/hlslParseHelper.cpp