diff options
| author | Jay Kwak <82421531+jkwak-work@users.noreply.github.com> | 2024-02-07 12:12:15 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-07 12:12:15 -0800 |
| commit | a16f712bb99e426519c9a556b17b54bcc4d1d22d (patch) | |
| tree | 32ae8c08de3e4aeb40890674c7fb3c042f79e23d /tests | |
| parent | a95b7530b782745d2778f3ea94c4ba9907991f78 (diff) | |
Implement basic GLSL built-in functions (#3525)
* Implement basic GLSL built-in functions
Partially resolves #3362
This change implemented GLSL build-in functions described in the
following sections of "OpenGL Spec" document.
8.1. Angle and Trigonometry Functions
8.2. Exponential Functions
8.3. Common Functions
8.5. Geometric Functions
8.7. Vector Relational Functions
8.8. Integer Functions
About 40 functions are newly implemented and about 150 functions
were preexisted on HLSL side implementation.
The implementation of new functions hasn't been tested yet.
* Unify some of GLSL functions into hlsl.meta.slang
Partially resoves #3362
This change moves Some of GLSL functions from glsl.meta.slang to
hlsl.meta.slang, because those functions are generic enough to be used
for HLSL. Those functions are: dot, normalize, fma, and reflect.
There was "fma" for double in hlsl.meta.slang and it is converted to use
__BuiltinFloatingPointType type, which required some modifications in
diff.meta.slang. The implementation for "fma" in diff.meta.slang is very
similar to how "mad" is implemented.
* Implement more GLSL built-in functions
Partially resolves #3362
This change implements more GLSL built-in functions mentioned in the
following sections.
8.4. Floating-Point Pack and Unpack Functions
8.6. Matrix Functions
This change implemented 11 new GLSL built-in functions and there were 3
already working functions.
The mistake in "normalize" is fixed.
"refract" function is moved from glsl.meta.slang to hlsl.meta.slang.
* Implement basic GLSL built-in functions
Partially resolves #3362
This change implemented GLSL build-in functions described in the
following sections of "OpenGL Spec" document.
8.1. Angle and Trigonometry Functions
8.2. Exponential Functions
8.3. Common Functions
8.5. Geometric Functions
8.7. Vector Relational Functions
8.8. Integer Functions
About 40 functions are newly implemented and about 150 functions
were preexisted on HLSL side implementation.
The implementation of new functions hasn't been tested yet.
* Unify some of GLSL functions into hlsl.meta.slang
Partially resoves #3362
This change moves Some of GLSL functions from glsl.meta.slang to
hlsl.meta.slang, because those functions are generic enough to be used
for HLSL. Those functions are: dot, normalize, fma, and reflect.
There was "fma" for double in hlsl.meta.slang and it is converted to use
__BuiltinFloatingPointType type, which required some modifications in
diff.meta.slang. The implementation for "fma" in diff.meta.slang is very
similar to how "mad" is implemented.
* Implement more GLSL built-in functions
Partially resolves #3362
This change implements more GLSL built-in functions mentioned in the
following sections.
8.4. Floating-Point Pack and Unpack Functions
8.6. Matrix Functions
This change implemented 11 new GLSL built-in functions and there were 3
already working functions.
The mistake in "normalize" is fixed.
"refract" function is moved from glsl.meta.slang to hlsl.meta.slang.
* Fix a few minor bugs on GLSL builtin functions
Partially resovles #3362
Following bugs were addressed:
1. "bitCounts" had to have a "Capability" on its function declaration.
2. "roundEven" is implemented. It is almost same to "round()" but the
behaivor is slightly different the given value is 1.5, 3.5, 5.5 and
so on.
3. umulExtended and imulExtended are simplified.
4. exp2 is implemented with "__target_switch" for GLSL and SPIR-V.
5. "tests/glsl-intrinsic/intrinsic-basic.slang" checks the results
from the GLSL functions. Currently it is mainly to test if the
functions exist or not, but it can now also test for a simple case
where the input value is zero and the result is most of the time
zero or one.
* Disable GLSL exp2 double type tests
This change disables some of GLSL exp2 related tests as a workaround.
The spir-v needs to handle the double-type argument for exp2 properly.
* Fix exp2(double) problem for SPIR-V
SPIR-V can handle a double-type input for exp2 with this change.
However, the slang-test is will failing to test it with an error message
saying, "abort compilation:".
With a simpler test case, I verified that SPIR-V assembly code is
properly generated for exp2(double) and I am not sure why slang-test is
still failing. We will need to revisit this issue later.
The simple testing is done with a following line:
outputBuffer.result[0] = float(exp2(double(outputBuffer.result[0])));
And it generated following lines and it looks correct:
; Function main
%main = OpFunction %void None %3
%5 = OpLabel
%16 = OpAccessChain %_ptr_Uniform_float %outputBuffer_0 %int_0 %uint_0
%17 = OpLoad %float %16
%19 = OpFConvert %double %17
%20 = OpFConvert %float %19
%21 = OpExtInst %float %1 Exp2 %20
%22 = OpAccessChain %_ptr_Uniform_float %outputBuffer_0 %int_0 %uint_0
OpStore %22 %21
OpReturn
OpFunctionEnd
* Add __floatCast that is safer than slang_noop_cast
Adding __floatCast that can be used for exp2 function.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/glsl-intrinsic/intrinsic-basic.slang | 509 |
1 files changed, 509 insertions, 0 deletions
diff --git a/tests/glsl-intrinsic/intrinsic-basic.slang b/tests/glsl-intrinsic/intrinsic-basic.slang new file mode 100644 index 000000000..14d03bf6c --- /dev/null +++ b/tests/glsl-intrinsic/intrinsic-basic.slang @@ -0,0 +1,509 @@ +//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -stage fragment -entry computeMain -target glsl +//TEST:SIMPLE(filecheck=CHECK_SPV): -allow-glsl -stage fragment -entry computeMain -target spirv +//TEST:SIMPLE(filecheck=CHECK_HLSL): -allow-glsl -stage fragment -entry computeMain -target hlsl +//TEST:SIMPLE(filecheck=CHECK_CUDA): -allow-glsl -stage fragment -entry computeMain -target cuda -DTARGET_CUDA +//TEST:SIMPLE(filecheck=CHECK_CPP): -allow-glsl -stage fragment -entry computeMain -target cpp + +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -output-using-type -emit-spirv-directly + +// "inverse()" function is not implemented yet. +//#defined TEST_when_inverse_works + +// "ftransform()" function is not implemented yet. +//#defined TEST_when_fransform_works + +// "exp2" for double type is causing an issue with SPIRV +//#define TEST_when_exp2_double_type_works + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +buffer MyBlockName2 +{ + int4 result; +} outputBuffer; + + +__generic<T : __BuiltinFloatingPointType, let N : int, let M : int> +bool equals(matrix<T, N, M> lhs, matrix<T, N, M> rhs) +{ + for (int i = 0; i < N; ++i) + { + for (int j = 0; j < M; ++j) + { + if (lhs[i][j] != rhs[i][j]) + { + return false; + } + } + } + return true; +} + +bool dim1TypeFuncs() +{ + typealias genFType = float; + typealias genDType = double; + typealias genIType = int; + typealias genUType = uint; + typealias genBType = bool; + + genFType outGenFType; + genDType outGenDType; + genIType outGenIType, outGenIType2; + genUType outGenUType, outGenUType2; + + constexpr float epsilon = 0.000001; + + bool voidResults = true; + + // 8.8. Integer Functions + umulExtended(genUType(0), genUType(0), outGenUType, outGenUType2); + voidResults = voidResults && genUType(0) == outGenUType; + voidResults = voidResults && genUType(0) == outGenUType2; + + imulExtended(genIType(0), genIType(0), outGenIType, outGenIType2); + voidResults = voidResults && genIType(0) == outGenIType; + voidResults = voidResults && genIType(0) == outGenIType2; + + return voidResults + // 8.1. Angle and Trigonometry Functions + && genFType(0) == radians(genFType(0)) + && genFType(0) == degrees(genFType(0)) + && genFType(0) == sin(genFType(0)) + && genFType(1) == cos(genFType(0)) + && genFType(0) == tan(genFType(0)) + && genFType(0) == asin(genFType(0)) + && genFType(0) == acos(genFType(1)) + && genFType(0) == atan(genFType(0), genFType(0)) + && genFType(0) == atan(genFType(0)) + && genFType(0) == sinh(genFType(0)) + && genFType(1) == cosh(genFType(0)) + && genFType(0) == tanh(genFType(0)) + && genFType(0) == asinh(genFType(0)) + && genFType(0) == acosh(genFType(1)) + && genFType(0) == atanh(genFType(0)) + + // 8.2. Exponential Functions + && genFType(1) == pow(genFType(1), genFType(0)) + && genFType(1) == exp(genFType(0)) + && genFType(0) == log(genFType(1)) + && genFType(1) == exp2(genFType(0)) +#if defined(TEST_when_exp2_double_type_works) + && genDType(1) == exp2(genDType(0)) +#endif // #if defined(TEST_when_exp2_double_type_works) + && genFType(0) == log2(genFType(1)) + && genFType(0) == sqrt(genFType(0)) + && genDType(0) == sqrt(genDType(0)) + && genFType(1) == inversesqrt(genFType(1)) + && genDType(1) == inversesqrt(genDType(1)) + + // 8.3. Common Functions + && genFType(0) == abs(genFType(0)) + && genIType(0) == abs(genIType(0)) + && genDType(0) == abs(genDType(0)) + && genFType(0) == sign(genFType(0)) +#if !defined(TARGET_CUDA) + && genIType(0) == sign(genIType(0)) +#endif // #if !defined(TARGET_CUDA) + && genDType(0) == sign(genDType(0)) + && genFType(0) == floor(genFType(0)) + && genDType(0) == floor(genDType(0)) + && genFType(0) == trunc(genFType(0)) + && genDType(0) == trunc(genDType(0)) + && genFType(0) == round(genFType(0)) + && genDType(0) == round(genDType(0)) + && genFType(0) == roundEven(genFType(0)) + && genDType(0) == roundEven(genDType(0)) + && genFType(0) == ceil(genFType(0)) + && genDType(0) == ceil(genDType(0)) + && genFType(0) == fract(genFType(0)) + && genDType(0) == fract(genDType(0)) + && genFType(0) == mod(genFType(0), float(1)) + && genFType(0) == mod(genFType(0), genFType(1)) + && genDType(0) == mod(genDType(0), double(1)) + && genDType(0) == mod(genDType(0), genDType(0)) + && genFType(0) == modf(genFType(0), outGenFType) && 0 == outGenFType + && genDType(0) == modf(genDType(0), outGenDType) && 0 == outGenDType + && genFType(0) == min(genFType(0), genFType(0)) + && genFType(0) == min(genFType(0), float(0)) + && genDType(0) == min(genDType(0), genDType(0)) + && genDType(0) == min(genDType(0), double(0)) + && genIType(0) == min(genIType(0), genIType(0)) + && genIType(0) == min(genIType(0), int(0)) + && genUType(0) == min(genUType(0), genUType(0)) + && genUType(0) == min(genUType(0), uint(0)) + && genFType(0) == max(genFType(0), genFType(0)) + && genFType(0) == max(genFType(0), float(0)) + && genDType(0) == max(genDType(0), genDType(0)) + && genDType(0) == max(genDType(0), double(0)) + && genIType(0) == max(genIType(0), genIType(0)) + && genIType(0) == max(genIType(0), int(0)) + && genUType(0) == max(genUType(0), genUType(0)) + && genUType(0) == max(genUType(0), uint(0)) + && genFType(0) == clamp(genFType(0), genFType(0), genFType(0)) + && genFType(0) == clamp(genFType(0), float(0), float(0)) + && genDType(0) == clamp(genDType(0), genDType(0), genDType(0)) + && genDType(0) == clamp(genDType(0), double(0), double(0)) + && genIType(0) == clamp(genIType(0), genIType(0), genIType(0)) + && genIType(0) == clamp(genIType(0), int(0), int(0)) + && genUType(0) == clamp(genUType(0), genUType(0), genUType(0)) + && genUType(0) == clamp(genUType(0), uint(0), uint(0)) + && genFType(0) == mix(genFType(0), genFType(0), genFType(0)) + && genFType(0) == mix(genFType(0), genFType(0), float(0)) + && genDType(0) == mix(genDType(0), genDType(0), genDType(0)) + && genDType(0) == mix(genDType(0), genDType(0), double(0)) + && genFType(0) == mix(genFType(0), genFType(0), genBType(0)) + && genDType(0) == mix(genDType(0), genDType(0), genBType(0)) + && genIType(0) == mix(genIType(0), genIType(0), genBType(0)) + && genUType(0) == mix(genUType(0), genUType(0), genBType(0)) + && genBType(0) == mix(genBType(0), genBType(0), genBType(0)) + && genFType(0) == step(genFType(1), genFType(0)) + && genFType(0) == step(float(1), genFType(0)) + && genDType(0) == step(genDType(1), genDType(0)) + && genDType(0) == step(double(1), genDType(0)) + && genFType(0) == smoothstep(genFType(0), genFType(1), genFType(0)) + && genFType(0) == smoothstep(float(0), float(1), genFType(0)) + && genDType(0) == smoothstep(genDType(0), genDType(1), genDType(0)) + && genDType(0) == smoothstep(double(0), double(1), genDType(0)) + && genBType(0) == isnan(genFType(0)) + && genBType(0) == isnan(genDType(0)) + && genBType(0) == isinf(genFType(0)) + && genBType(0) == isinf(genDType(0)) + && genIType(0) == floatBitsToInt(genFType(0)) + && genUType(0) == floatBitsToUint(genFType(0)) + && genFType(0) == intBitsToFloat(genIType(0)) + && genFType(0) == uintBitsToFloat(genUType(0)) + && genFType(0) == fma(genFType(0), genFType(0), genFType(0)) + && genDType(0) == fma(genDType(0), genDType(0), genDType(0)) + && genFType(0) == frexp(genFType(0), outGenIType) && genIType(0) == outGenIType + && genDType(0) == frexp(genDType(0), outGenIType) && genIType(0) == outGenIType + && genFType(0) == ldexp(genFType(0), genIType(0)) +#if defined(TEST_when_exp2_double_type_works) + && genDType(0) == ldexp(genDType(0), genIType(0)) +#endif // #if defined(TEST_when_exp2_double_type_works) + + // 8.5. Geometric Functions + && float(0) == length(genFType(0)) + && double(0) == length(genDType(0)) + && float(0) == distance(genFType(0), genFType(0)) + && double(0) == distance(genDType(0), genDType(0)) + && float(0) == dot(genFType(0), genFType(0)) + && double(0) == dot(genDType(0), genDType(0)) + && (abs(float(1) - length(normalize(genFType(1)))) < epsilon) + && (abs(double(1) - length(normalize(genDType(1)))) < double(epsilon)) + && genFType(1) == faceforward(genFType(1), genFType(1), genFType(-1)) + && genDType(1) == faceforward(genDType(1), genDType(1), genDType(-1)) + && genFType(0) == reflect(genFType(0), genFType(0)) + && genDType(0) == reflect(genDType(0), genDType(0)) + && genFType(0) == refract(genFType(0), genFType(0), float(0)) + && genDType(0) == refract(genDType(0), genDType(0), double(0)) + + // 8.6. Matrix Functions + && equals(mat2x2(0), matrixCompMult(mat2x2(0), mat2x2(0))) + && equals(mat2x3(0), matrixCompMult(mat2x3(0), mat2x3(0))) + && equals(mat2x4(0), matrixCompMult(mat2x4(0), mat2x4(0))) + && equals(mat3x2(0), matrixCompMult(mat3x2(0), mat3x2(0))) + && equals(mat3x3(0), matrixCompMult(mat3x3(0), mat3x3(0))) + && equals(mat3x4(0), matrixCompMult(mat3x4(0), mat3x4(0))) + && equals(mat4x2(0), matrixCompMult(mat4x2(0), mat4x2(0))) + && equals(mat4x3(0), matrixCompMult(mat4x3(0), mat4x3(0))) + && equals(mat4x4(0), matrixCompMult(mat4x4(0), mat4x4(0))) + && equals(mat2(0), outerProduct(vec2(0), vec2(0))) + && equals(mat3(0), outerProduct(vec3(0), vec3(0))) + && equals(mat4(0), outerProduct(vec4(0), vec4(0))) + && equals(mat2x3(0), outerProduct(vec3(0), vec2(0))) + && equals(mat3x2(0), outerProduct(vec2(0), vec3(0))) + && equals(mat2x4(0), outerProduct(vec4(0), vec2(0))) + && equals(mat4x2(0), outerProduct(vec2(0), vec4(0))) + && equals(mat3x4(0), outerProduct(vec4(0), vec3(0))) + && equals(mat4x3(0), outerProduct(vec3(0), vec4(0))) + && equals(mat2(0), transpose(mat2(0))) + && equals(mat3(0), transpose(mat3(0))) + && equals(mat4(0), transpose(mat4(0))) + && equals(mat2x3(0), transpose(mat3x2(0))) + && equals(mat3x2(0), transpose(mat2x3(0))) + && equals(mat2x4(0), transpose(mat4x2(0))) + && equals(mat4x2(0), transpose(mat2x4(0))) + && equals(mat3x4(0), transpose(mat4x3(0))) + && equals(mat4x3(0), transpose(mat3x4(0))) + && float(0) == determinant(mat2(0)) + && float(0) == determinant(mat3(0)) + && float(0) == determinant(mat4(0)) +#if defined(TEST_when_inverse_works) + && equals(mat2(0), inverse(mat2(0))) + && equals(mat3(0), inverse(mat3(0))) + && equals(mat4(0), inverse(mat4(0))) +#endif // #if defined(TEST_when_inverse_works) + + // 8.8. Integer Functions + && genUType(0) == uaddCarry(genUType(0), genUType(0), outGenUType) && genUType(0) == outGenUType + && genUType(0) == usubBorrow(genUType(0), genUType(0), outGenUType) && genUType(0) == outGenUType + && genIType(0) == bitfieldExtract(genIType(0), int(0), int(0)) + && genUType(0) == bitfieldExtract(genUType(0), int(0), int(0)) + && genIType(0) == bitfieldInsert(genIType(0), genIType(0), int(0), int(0)) + && genUType(0) == bitfieldInsert(genUType(0), genUType(0), int(0), int(0)) + && genIType(0) == bitfieldReverse(genIType(0)) + && genUType(0) == bitfieldReverse(genUType(0)) + && genIType(0) == bitCount(genIType(0)) + && genIType(0) == bitCount(genUType(0)) + && genIType(-1) == findLSB(genIType(0)) + && genIType(-1) == findLSB(genUType(0)) + && genIType(-1) == findMSB(genIType(0)) + && genIType(-1) == findMSB(genUType(0)) + ; +} + +__generic<let N : int> +bool dimNTypeFuncs() +{ + typealias genFType = vector<float, N>; + typealias genDType = vector<double, N>; + typealias genIType = vector<int, N>; + typealias genUType = vector<uint, N>; + typealias genBType = vector<bool, N>; + typealias vec = vector<float, N>; + typealias ivec = vector<int, N>; + typealias uvec = vector<uint, N>; + typealias bvec = vector<bool, N>; + + genFType outGenFType; + genDType outGenDType; + genIType outGenIType, outGenIType2; + genUType outGenUType, outGenUType2; + + constexpr float epsilon = 0.000001; + + bool voidResults = true; + + // 8.8. Integer Functions + umulExtended(genUType(0), genUType(0), outGenUType, outGenUType2); + voidResults = voidResults && genUType(0) == outGenUType; + voidResults = voidResults && genUType(0) == outGenUType2; + + imulExtended(genIType(0), genIType(0), outGenIType, outGenIType2); + voidResults = voidResults && genIType(0) == outGenIType; + voidResults = voidResults && genIType(0) == outGenIType2; + + return voidResults + // 8.1. Angle and Trigonometry Functions + && genFType(0) == radians(genFType(0)) + && genFType(0) == degrees(genFType(0)) + && genFType(0) == sin(genFType(0)) + && genFType(1) == cos(genFType(0)) + && genFType(0) == tan(genFType(0)) + && genFType(0) == asin(genFType(0)) + && genFType(0) == acos(genFType(1)) + && genFType(0) == atan(genFType(0), genFType(0)) + && genFType(0) == atan(genFType(0)) + && genFType(0) == sinh(genFType(0)) + && genFType(1) == cosh(genFType(0)) + && genFType(0) == tanh(genFType(0)) +#if !defined(TARGET_CUDA) + && genFType(0) == asinh(genFType(0)) + && genFType(0) == acosh(genFType(1)) + && genFType(0) == atanh(genFType(0)) +#endif // #if !defined(TARGET_CUDA) + + // 8.2. Exponential Functions + && genFType(1) == pow(genFType(1), genFType(0)) + && genFType(1) == exp(genFType(0)) + && genFType(0) == log(genFType(1)) + && genFType(1) == exp2(genFType(0)) +#if defined(TEST_when_exp2_double_type_works) + && genDType(1) == exp2(genDType(0)) +#endif // #if defined(TEST_when_exp2_double_type_works) + && genFType(0) == log2(genFType(1)) + && genFType(0) == sqrt(genFType(0)) + && genDType(0) == sqrt(genDType(0)) + && genFType(1) == inversesqrt(genFType(1)) + && genDType(1) == inversesqrt(genDType(1)) + + // 8.3. Common Functions + && genFType(0) == abs(genFType(0)) + && genIType(0) == abs(genIType(0)) + && genDType(0) == abs(genDType(0)) + && genFType(0) == sign(genFType(0)) +#if !defined(TARGET_CUDA) + && genIType(0) == sign(genIType(0)) +#endif // #if !defined(TARGET_CUDA) + && genDType(0) == sign(genDType(0)) + && genFType(0) == floor(genFType(0)) + && genDType(0) == floor(genDType(0)) + && genFType(0) == trunc(genFType(0)) + && genDType(0) == trunc(genDType(0)) + && genFType(0) == round(genFType(0)) + && genDType(0) == round(genDType(0)) + && genFType(0) == roundEven(genFType(0)) + && genDType(0) == roundEven(genDType(0)) + && genFType(0) == ceil(genFType(0)) + && genDType(0) == ceil(genDType(0)) + && genFType(0) == fract(genFType(0)) + && genDType(0) == fract(genDType(0)) + && genFType(0) == mod(genFType(0), float(1)) + && genFType(0) == mod(genFType(0), genFType(1)) + && genDType(0) == mod(genDType(0), double(1)) + && genDType(0) == mod(genDType(0), genDType(0)) + && genFType(0) == modf(genFType(0), outGenFType) && genFType(0) == outGenFType + && genDType(0) == modf(genDType(0), outGenDType) && genDType(0) == outGenDType + && genFType(0) == min(genFType(0), genFType(0)) + && genFType(0) == min(genFType(0), float(0)) + && genDType(0) == min(genDType(0), genDType(0)) + && genDType(0) == min(genDType(0), double(0)) + && genIType(0) == min(genIType(0), genIType(0)) + && genIType(0) == min(genIType(0), int(0)) + && genUType(0) == min(genUType(0), genUType(0)) + && genUType(0) == min(genUType(0), uint(0)) + && genFType(0) == max(genFType(0), genFType(0)) + && genFType(0) == max(genFType(0), float(0)) + && genDType(0) == max(genDType(0), genDType(0)) + && genDType(0) == max(genDType(0), double(0)) + && genIType(0) == max(genIType(0), genIType(0)) + && genIType(0) == max(genIType(0), int(0)) + && genUType(0) == max(genUType(0), genUType(0)) + && genUType(0) == max(genUType(0), uint(0)) + && genFType(0) == clamp(genFType(0), genFType(0), genFType(0)) + && genFType(0) == clamp(genFType(0), float(0), float(0)) + && genDType(0) == clamp(genDType(0), genDType(0), genDType(0)) + && genDType(0) == clamp(genDType(0), double(0), double(0)) + && genIType(0) == clamp(genIType(0), genIType(0), genIType(0)) + && genIType(0) == clamp(genIType(0), int(0), int(0)) + && genUType(0) == clamp(genUType(0), genUType(0), genUType(0)) + && genUType(0) == clamp(genUType(0), uint(0), uint(0)) + && genFType(0) == mix(genFType(0), genFType(0), genFType(0)) + && genFType(0) == mix(genFType(0), genFType(0), float(0)) + && genDType(0) == mix(genDType(0), genDType(0), genDType(0)) + && genDType(0) == mix(genDType(0), genDType(0), double(0)) +#if !defined(TARGET_CUDA) + && genFType(0) == mix(genFType(0), genFType(0), genBType(0)) + && genDType(0) == mix(genDType(0), genDType(0), genBType(0)) + && genIType(0) == mix(genIType(0), genIType(0), genBType(0)) + && genUType(0) == mix(genUType(0), genUType(0), genBType(0)) + && genBType(0) == mix(genBType(0), genBType(0), genBType(0)) +#endif // #if !defined(TARGET_CUDA) + && genFType(0) == step(genFType(1), genFType(0)) + && genFType(0) == step(float(1), genFType(0)) + && genDType(0) == step(genDType(1), genDType(0)) + && genDType(0) == step(double(1), genDType(0)) + && genFType(0) == smoothstep(genFType(0), genFType(1), genFType(0)) + && genFType(0) == smoothstep(float(0), float(1), genFType(0)) + && genDType(0) == smoothstep(genDType(0), genDType(1), genDType(0)) + && genDType(0) == smoothstep(double(0), double(1), genDType(0)) +#if !defined(TARGET_CUDA) + && genBType(0) == isnan(genFType(0)) + && genBType(0) == isnan(genDType(0)) + && genBType(0) == isinf(genFType(0)) + && genBType(0) == isinf(genDType(0)) +#endif // #if !defined(TARGET_CUDA) + && genIType(0) == floatBitsToInt(genFType(0)) + && genUType(0) == floatBitsToUint(genFType(0)) + && genFType(0) == intBitsToFloat(genIType(0)) + && genFType(0) == uintBitsToFloat(genUType(0)) + && genFType(0) == fma(genFType(0), genFType(0), genFType(0)) + && genDType(0) == fma(genDType(0), genDType(0), genDType(0)) + && genFType(0) == frexp(genFType(0), outGenIType) && genIType(0) == outGenIType + && genDType(0) == frexp(genDType(0), outGenIType) && genIType(0) == outGenIType + && genFType(0) == ldexp(genFType(0), genIType(0)) +#if defined(TEST_when_exp2_double_type_works) + && genDType(0) == ldexp(genDType(0), genIType(0)) +#endif // #if defined(TEST_when_exp2_double_type_works) + + // 8.4. Floating-Point Pack and Unpack Functions + && uint(0) == packUnorm2x16(vec2(0)) + && uint(0) == packSnorm2x16(vec2(-1)) + && uint(0) == packUnorm4x8(vec4(0)) + && uint(0) == packSnorm4x8(vec4(-1)) + && vec2(0) == unpackUnorm2x16(uint(0)) + && vec2(-1) == unpackSnorm2x16(uint(0)) + && vec4(0) == unpackUnorm4x8(uint(0)) + && vec4(-1) == unpackSnorm4x8(uint(0)) + && uint(0) == packHalf2x16(vec2(0)) + && vec2(0) == unpackHalf2x16(uint(0)) + && double(0) == packDouble2x32(uvec2(0)) + && uvec2(0) == unpackDouble2x32(double(0)) + + // 8.5. Geometric Functions + && float(0) == length(genFType(0)) + && double(0) == length(genDType(0)) + && float(0) == distance(genFType(0), genFType(0)) + && double(0) == distance(genDType(0), genDType(0)) + && float(0) == dot(genFType(0), genFType(0)) + && double(0) == dot(genDType(0), genDType(0)) + && vec3(0) == cross(vec3(0), vec3(0)) + && dvec3(0) == cross(dvec3(0), dvec3(0)) + && (abs(float(1) - length(normalize(genFType(1)))) < epsilon) + && (abs(double(1) - length(normalize(genDType(1)))) < double(epsilon)) +#if defined(TEST_when_fransform_works) + && vec4(0) == ftransform() +#endif // #if defined(TEST_when_fransform_works) + && genFType(1) == faceforward(genFType(1), genFType(1), genFType(-1)) + && genDType(1) == faceforward(genDType(1), genDType(1), genDType(-1)) + && genFType(0) == reflect(genFType(0), genFType(0)) + && genDType(0) == reflect(genDType(0), genDType(0)) + && genFType(0) == refract(genFType(0), genFType(0), float(0)) + && genDType(0) == refract(genDType(0), genDType(0), double(0)) + + // 8.7. Vector Relational Functions +#if !defined(TARGET_CUDA) + && bvec(1) == lessThan(vec(0), vec(1)) + && bvec(1) == lessThan(ivec(0), ivec(1)) + && bvec(1) == lessThan(uvec(0), uvec(1)) + && bvec(1) == lessThanEqual(vec(0), vec(1)) + && bvec(1) == lessThanEqual(ivec(0), ivec(1)) + && bvec(1) == lessThanEqual(uvec(0), uvec(1)) + && bvec(0) == greaterThan(vec(0), vec(1)) + && bvec(0) == greaterThan(ivec(0), ivec(1)) + && bvec(0) == greaterThan(uvec(0), uvec(1)) + && bvec(0) == greaterThanEqual(vec(0), vec(1)) + && bvec(0) == greaterThanEqual(ivec(0), ivec(1)) + && bvec(0) == greaterThanEqual(uvec(0), uvec(1)) + && bvec(1) == equal(vec(0), vec(0)) + && bvec(1) == equal(ivec(0), ivec(0)) + && bvec(1) == equal(uvec(0), uvec(0)) + && bvec(1) == equal(bvec(0), bvec(0)) + && bvec(0) == notEqual(vec(0), vec(0)) + && bvec(0) == notEqual(ivec(0), ivec(0)) + && bvec(0) == notEqual(uvec(0), uvec(0)) + && bvec(0) == notEqual(bvec(0), bvec(0)) + && bool(0) == any(bvec(0)) + && bool(0) == all(bvec(0)) + && bvec(1) == not(bvec(0)) +#endif // #if !defined(TARGET_CUDA) + + // 8.8. Integer Functions + && genUType(0) == uaddCarry(genUType(0), genUType(0), outGenUType) && genUType(0) == outGenUType + && genUType(0) == usubBorrow(genUType(0), genUType(0), outGenUType) && genUType(0) == outGenUType + && genIType(0) == bitfieldExtract(genIType(0), int(0), int(0)) + && genUType(0) == bitfieldExtract(genUType(0), int(0), int(0)) + && genIType(0) == bitfieldInsert(genIType(0), genIType(0), int(0), int(0)) + && genUType(0) == bitfieldInsert(genUType(0), genUType(0), int(0), int(0)) + && genIType(0) == bitfieldReverse(genIType(0)) + && genUType(0) == bitfieldReverse(genUType(0)) + && genIType(0) == bitCount(genIType(0)) + && genIType(0) == bitCount(genUType(0)) +#if !defined(TARGET_CUDA) + && genIType(-1) == findLSB(genIType(0)) + && genIType(-1) == findLSB(genUType(0)) + && genIType(-1) == findMSB(genIType(0)) + && genIType(-1) == findMSB(genUType(0)) +#endif // #if !defined(TARGET_CUDA) + ; +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + // CHECK_GLSL: void main( + // CHECK_SPV: OpEntryPoint + // CHECK_HLSL: void computeMain( + // CHECK_CUDA: void computeMain( + // CHECK_CPP: void _computeMain( + // BUF: 1 + + bool r = true + && dim1TypeFuncs() + && dimNTypeFuncs<2>() + && dimNTypeFuncs<3>() + && dimNTypeFuncs<4>(); + + outputBuffer.result[0] = int(r); +} |
