summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-02-07 13:10:04 -0500
committerGitHub <noreply@github.com>2020-02-07 13:10:04 -0500
commit199d1f52b6690843fbdc7a383775396469516e56 (patch)
tree672304471e8cc86131fd317d76ede1f60ea8e7a5
parentaf84d85799758234110fc42f0ba5c771dacb5fe3 (diff)
HLSL Intrinsic coverage test improvements (#1206)
* Fix CPP construct when matrix type. * Test intrinsics on float matrices. * Fix typo in _areNearlyEqual test. Increased default sensitivity. Added matrix-float test. * Matrix double test. Fixed some issues with CUDA. * Added reduced intrinsic version of matrix-double test. * Improve matrix double coverage. Test reflect/length etc on vector float. * * Added literal-float test. * Added vector double test * Improved coverage of vector/matrix tests * Disable Dx11 double-vector test because fails on CI. * Disable literal-float, because on CI fails.
-rw-r--r--docs/64bit-type-support.md3
-rw-r--r--prelude/slang-cuda-prelude.h7
-rw-r--r--source/slang/slang-emit-cpp.cpp23
-rw-r--r--source/slang/slang-emit-cuda.cpp10
-rw-r--r--tests/hlsl-intrinsic/literal-float.slang31
-rw-r--r--tests/hlsl-intrinsic/literal-float.slang.expected.txt4
-rw-r--r--tests/hlsl-intrinsic/matrix-double-reduced-intrinsic.slang80
-rw-r--r--tests/hlsl-intrinsic/matrix-double-reduced-intrinsic.slang.expected.txt5
-rw-r--r--tests/hlsl-intrinsic/matrix-double.slang138
-rw-r--r--tests/hlsl-intrinsic/matrix-double.slang.expected.txt5
-rw-r--r--tests/hlsl-intrinsic/matrix-float.slang4
-rw-r--r--tests/hlsl-intrinsic/vector-double-reduced-intrinsic.slang74
-rw-r--r--tests/hlsl-intrinsic/vector-double-reduced-intrinsic.slang.expected.txt17
-rw-r--r--tests/hlsl-intrinsic/vector-float.slang47
-rw-r--r--tests/hlsl-intrinsic/vector-float.slang.expected.txt30
15 files changed, 437 insertions, 41 deletions
diff --git a/docs/64bit-type-support.md b/docs/64bit-type-support.md
index 2f52ef6a8..506e05493 100644
--- a/docs/64bit-type-support.md
+++ b/docs/64bit-type-support.md
@@ -13,6 +13,7 @@ Slang 64-bit Type Support
* D3D targets *appear* to support double intrinsics (like sin, cos, log etc), but behind the scenes they are actually being converted to float
* When using D3D12, it is best to use DXIL if you use double because there are some serious issues around double and DXBC
* VK will produce an error in validation if a double intrinsic is used it does support (which is most of them)
+* Vector and Matrix types have even spottier than scalar intrinsic support across targets
Overview
========
@@ -60,8 +61,6 @@ uint64_t j = ~0; // Equivalent to 'i' because uint64_t(int64_t(~int32_t
These issues are discussed more on issue [#1185](https://github.com/shader-slang/slang/issues/1185)
-Note this initial testing only tested scalar usage, and not vector or matrix intrinsics.
-
Double support
==============
diff --git a/prelude/slang-cuda-prelude.h b/prelude/slang-cuda-prelude.h
index edfa9b5e0..dc0ba4b5e 100644
--- a/prelude/slang-cuda-prelude.h
+++ b/prelude/slang-cuda-prelude.h
@@ -91,6 +91,13 @@ typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
+typedef long long longlong;
+typedef unsigned long long ulonglong;
+
+typedef unsigned char uchar;
+typedef unsigned short ushort;
+typedef unsigned int uint;
+
union Union32
{
uint32_t u;
diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp
index 99d1fbf22..f3d16444a 100644
--- a/source/slang/slang-emit-cpp.cpp
+++ b/source/slang/slang-emit-cpp.cpp
@@ -1166,8 +1166,18 @@ void CPPSourceEmitter::_emitConstructConvertDefinition(const UnownedStringSlice&
{
writer->emit(", \n");
}
- writer->emit(rowTypeName);
- writer->emit("{ ");
+
+ if (m_target == CodeGenTarget::CUDASource)
+ {
+ m_writer->emit("make_");
+ writer->emit(rowTypeName);
+ m_writer->emit("(");
+ }
+ else
+ {
+ writer->emit(rowTypeName);
+ writer->emit("{ ");
+ }
}
for (int j = 0; j < dim.colCount; ++j)
@@ -1184,7 +1194,14 @@ void CPPSourceEmitter::_emitConstructConvertDefinition(const UnownedStringSlice&
}
if (dim.rowCount > 1)
{
- writer->emit("}");
+ if (m_target == CodeGenTarget::CUDASource)
+ {
+ writer->emit(")");
+ }
+ else
+ {
+ writer->emit("}");
+ }
}
}
diff --git a/source/slang/slang-emit-cuda.cpp b/source/slang/slang-emit-cuda.cpp
index 019bf8b94..c628e5caf 100644
--- a/source/slang/slang-emit-cuda.cpp
+++ b/source/slang/slang-emit-cuda.cpp
@@ -37,12 +37,12 @@ static bool _isSingleNameBasicType(IROp op)
case kIROp_Int8Type: return UnownedStringSlice("char");
case kIROp_Int16Type: return UnownedStringSlice("short");
case kIROp_IntType: return UnownedStringSlice("int");
- case kIROp_Int64Type: return UnownedStringSlice("long long");
+ case kIROp_Int64Type: return UnownedStringSlice("longlong");
- case kIROp_UInt8Type: return UnownedStringSlice("unsigned char");
- case kIROp_UInt16Type: return UnownedStringSlice("unsigned short");
- case kIROp_UIntType: return UnownedStringSlice("unsigned int");
- case kIROp_UInt64Type: return UnownedStringSlice("unsigned long long");
+ case kIROp_UInt8Type: return UnownedStringSlice("uchar");
+ case kIROp_UInt16Type: return UnownedStringSlice("ushort");
+ case kIROp_UIntType: return UnownedStringSlice("uint");
+ case kIROp_UInt64Type: return UnownedStringSlice("ulonglong");
// Not clear just yet how we should handle half... we want all processing as float probly, but when reading/writing to memory converting
case kIROp_HalfType: return UnownedStringSlice("half");
diff --git a/tests/hlsl-intrinsic/literal-float.slang b/tests/hlsl-intrinsic/literal-float.slang
new file mode 100644
index 000000000..49179b53a
--- /dev/null
+++ b/tests/hlsl-intrinsic/literal-float.slang
@@ -0,0 +1,31 @@
+// TODO(JS): Disabled because fails on windows CI.
+// Probably because on CI it is using std output to detect errors/warnings, not looking at the return code.
+
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12
+//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute
+//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int idx = int(dispatchThreadID.x);
+
+ float v = 0.0f;
+
+ // Test to check handling of + and -inf
+ if (idx == 0)
+ {
+ v = 5e+40;
+ }
+ else if (idx == 1)
+ {
+ v = -5e+40;
+ }
+
+ outputBuffer[idx] = v;
+} \ No newline at end of file
diff --git a/tests/hlsl-intrinsic/literal-float.slang.expected.txt b/tests/hlsl-intrinsic/literal-float.slang.expected.txt
new file mode 100644
index 000000000..b776a7a3a
--- /dev/null
+++ b/tests/hlsl-intrinsic/literal-float.slang.expected.txt
@@ -0,0 +1,4 @@
+7F800000
+FF800000
+0
+0
diff --git a/tests/hlsl-intrinsic/matrix-double-reduced-intrinsic.slang b/tests/hlsl-intrinsic/matrix-double-reduced-intrinsic.slang
new file mode 100644
index 000000000..38fbe4f5d
--- /dev/null
+++ b/tests/hlsl-intrinsic/matrix-double-reduced-intrinsic.slang
@@ -0,0 +1,80 @@
+// We currently don't support matrix intrinsics on glsl based targets
+// There are problems with double on dx12/dxbc so we disable that
+
+//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile sm_6_0 -use-dxil -output-using-type
+//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<double> outputBuffer;
+
+typedef double Float;
+
+typedef matrix<Float, 2, 2> FloatMatrix;
+typedef matrix<int64_t, 2, 2> IntMatrix;
+typedef matrix<uint64_t, 2, 2> UIntMatrix;
+typedef vector<Float, 2> FloatVector;
+
+Float calcTotal(FloatVector v)
+{
+ return v.x + v.y;
+}
+
+Float calcTotal(FloatMatrix v)
+{
+ return calcTotal(v[0]) + calcTotal(v[1]);
+}
+
+FloatMatrix makeFloatMatrix(Float f)
+{
+ FloatMatrix m = { { f, f }, { f, f } };
+ return m;
+}
+
+IntMatrix makeIntMatrix(int v)
+{
+ IntMatrix m = { { v, v }, { v, v } };
+ return m;
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int idx = int(dispatchThreadID.x);
+
+ Float scalarF = idx * (1.0f / (4.0f));
+
+ FloatMatrix ft = {};
+
+ FloatMatrix f = { { scalarF + 0.01, scalarF + 0.02}, { scalarF + 0.011, scalarF + 0.022}};
+
+ // fmod - doesn't work on double on D3D/DX
+ // ft += FloatMatrix(IntMatrix(((f % makeFloatMatrix(0.11f)) * makeFloatMatrix(100)) + makeFloatMatrix(0.5)));
+
+ ft += rcp(makeFloatMatrix(1.0l) + f);
+ ft += FloatMatrix(sign(f - makeFloatMatrix(0.5l)));
+
+ // Lets try some matrix/matrix
+ ft = f * ft;
+
+ // Lets try some vector matrix
+
+ {
+ FloatMatrix r = {mul(f[0], ft), mul(ft, f[1])};
+ ft += r;
+ }
+
+ ft += saturate(f * makeFloatMatrix(4) - makeFloatMatrix(2.0l));
+
+ ft += abs(f * makeFloatMatrix(4) - makeFloatMatrix(2.0l));
+
+ ft += min(makeFloatMatrix(0.5l), f);
+ ft += max(f, makeFloatMatrix(0.75l));
+
+ ft += clamp(f, makeFloatMatrix(0.1l), makeFloatMatrix(0.3l));
+
+ outputBuffer[idx] = calcTotal(ft);
+} \ No newline at end of file
diff --git a/tests/hlsl-intrinsic/matrix-double-reduced-intrinsic.slang.expected.txt b/tests/hlsl-intrinsic/matrix-double-reduced-intrinsic.slang.expected.txt
new file mode 100644
index 000000000..7b543d789
--- /dev/null
+++ b/tests/hlsl-intrinsic/matrix-double-reduced-intrinsic.slang.expected.txt
@@ -0,0 +1,5 @@
+type: double
+11.209877
+8.532063
+13.660064
+26.660431
diff --git a/tests/hlsl-intrinsic/matrix-double.slang b/tests/hlsl-intrinsic/matrix-double.slang
new file mode 100644
index 000000000..9b4f8ac19
--- /dev/null
+++ b/tests/hlsl-intrinsic/matrix-double.slang
@@ -0,0 +1,138 @@
+// TODO(JS):
+// It doesn't look like fxc, dxc, vk support double versions of many of the intrinsics, so they are disabled here.
+// Arguably we should implement simple intrinsics if missing in the stdlib
+// More complicated functions (like say sin) can also be written, if not available on a target, but requires significant
+// care.
+
+//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -output-using-type
+//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<double> outputBuffer;
+
+typedef double Float;
+
+typedef matrix<Float, 2, 2> FloatMatrix;
+typedef matrix<int64_t, 2, 2> IntMatrix;
+typedef matrix<uint64_t, 2, 2> UIntMatrix;
+typedef vector<Float, 2> FloatVector;
+
+Float calcTotal(FloatVector v)
+{
+ return v.x + v.y;
+}
+
+Float calcTotal(FloatMatrix v)
+{
+ return calcTotal(v[0]) + calcTotal(v[1]);
+}
+
+FloatMatrix makeFloatMatrix(Float f)
+{
+ FloatMatrix m = { { f, f }, { f, f } };
+ return m;
+}
+
+IntMatrix makeIntMatrix(int v)
+{
+ IntMatrix m = { { v, v }, { v, v } };
+ return m;
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int idx = int(dispatchThreadID.x);
+
+ Float scalarF = idx * (1.0f / (4.0f));
+
+ FloatMatrix ft = {};
+
+ FloatMatrix f = { { scalarF + 0.01, scalarF + 0.02}, { scalarF + 0.011, scalarF + 0.022}};
+
+ // fmod
+ ft += FloatMatrix(IntMatrix(((f % makeFloatMatrix(0.11f)) * makeFloatMatrix(100)) + makeFloatMatrix(0.5)));
+
+ ft += sin(f);
+
+ // Lets try some matrix/matrix
+ ft = f * ft;
+
+ // Lets try some vector matrix
+
+ {
+ FloatMatrix r = {mul(f[0], ft), mul(ft, f[1])};
+ ft += r;
+ }
+
+ // Back to the transcendentals
+
+ ft += cos(f);
+ ft += tan(f);
+
+ ft += asin(f);
+ ft += acos(f);
+ ft += atan(f);
+
+ ft += atan2(f, makeFloatMatrix(2));
+
+ {
+ FloatMatrix sf, cf;
+ sincos(f, sf, cf);
+
+ ft += sf;
+ ft += cf;
+ }
+
+ ft += rcp(makeFloatMatrix(1.0) + f);
+ ft += FloatMatrix(sign(f - makeFloatMatrix(0.5)));
+
+ ft += saturate(f * makeFloatMatrix(4) - makeFloatMatrix(2.0));
+
+ ft += sqrt(f);
+ ft += rsqrt(makeFloatMatrix(1.0f) + f);
+
+ ft += exp2(f);
+ ft += exp(f);
+
+ ft += frac(f * makeFloatMatrix(3));
+ ft += ceil(f * makeFloatMatrix(5) - makeFloatMatrix(3));
+
+ ft += floor(f * makeFloatMatrix(10) - makeFloatMatrix(7));
+ ft += trunc(f * makeFloatMatrix(7));
+
+ ft += log(f + makeFloatMatrix(10.0));
+ ft += log2(f * makeFloatMatrix(3) + makeFloatMatrix(2));
+
+ {
+ float scalarVs[] = { 1, 10, 100, 1000 };
+ ft += FloatMatrix(IntMatrix(log10(makeFloatMatrix(scalarVs[idx])) + makeFloatMatrix(0.5f)));
+ }
+
+ ft += abs(f * makeFloatMatrix(4) - makeFloatMatrix(2.0f));
+
+ ft += min(makeFloatMatrix(0.5), f);
+ ft += max(f, makeFloatMatrix(0.75));
+
+ ft += pow(makeFloatMatrix(0.5), f);
+
+ ft += smoothstep(makeFloatMatrix(0.2), makeFloatMatrix(0.7), f);
+ ft += lerp(makeFloatMatrix(-100), makeFloatMatrix(100), f);
+
+ ft += clamp(f, makeFloatMatrix(0.1), makeFloatMatrix(0.3));
+
+ ft += step(f, makeFloatMatrix(0.5));
+
+#if 0
+ IntMatrix vi = asint(makeFloatMatrix(idx));
+ ft += asfloat(vi);
+
+ UIntMatrix vu = asuint(f);
+ ft += asfloat(vu);
+#endif
+
+ outputBuffer[idx] = calcTotal(ft);
+} \ No newline at end of file
diff --git a/tests/hlsl-intrinsic/matrix-double.slang.expected.txt b/tests/hlsl-intrinsic/matrix-double.slang.expected.txt
new file mode 100644
index 000000000..0067ec549
--- /dev/null
+++ b/tests/hlsl-intrinsic/matrix-double.slang.expected.txt
@@ -0,0 +1,5 @@
+type: double
+-363.570686
+-128.281824
+134.883405
+383.294965
diff --git a/tests/hlsl-intrinsic/matrix-float.slang b/tests/hlsl-intrinsic/matrix-float.slang
index 34591d3d9..4d49297a8 100644
--- a/tests/hlsl-intrinsic/matrix-float.slang
+++ b/tests/hlsl-intrinsic/matrix-float.slang
@@ -1,4 +1,7 @@
+// TODO(JS):
// NOTE we can't test on VK/gl at the moment because we don't support intrinsics over matrices on that target currently
+// TODO(JS):
+// Also NOTE, we do not test matrix inverse as currently unsupported on C++/CUDA targets
//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type
@@ -74,6 +77,7 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
ft += atan2(f, makeFloatMatrix(2));
#if 0
+ // TODO(JS):
// This fails from DXC with a validation error(!)
{
FloatMatrix sf, cf;
diff --git a/tests/hlsl-intrinsic/vector-double-reduced-intrinsic.slang b/tests/hlsl-intrinsic/vector-double-reduced-intrinsic.slang
new file mode 100644
index 000000000..288dfe9db
--- /dev/null
+++ b/tests/hlsl-intrinsic/vector-double-reduced-intrinsic.slang
@@ -0,0 +1,74 @@
+//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type
+// TODO(JS):
+// On CI systems DX11 test failed, so disable for now
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<double4> outputBuffer;
+
+typedef double Float;
+
+typedef vector<Float, 3> FloatVector;
+typedef vector<int, 3> IntVector;
+typedef vector<uint, 3> UIntVector;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int idx = int(dispatchThreadID.x);
+
+ Float vf = idx * (1.0f / (4.0f));
+
+ FloatVector f = FloatVector(0.1f, vf, vf + 0.2f);
+
+ // Operate over all values
+ FloatVector ft = {};
+
+ // TODO(JS):
+ // fmod - disabled not available on D3D for double
+ //ft += FloatVector(IntVector(((f % 0.11f) * 100) + 0.5));
+
+ {
+ // Vector specific
+ FloatVector nv = normalize(f);
+ ft += nv;
+
+ FloatVector perp = cross(nv, f.zxy);
+ ft += perp;
+
+
+ // TODO(JS):
+ // Disabled because dotwith a double vector fails on dxc, with validation error (!)
+ //ft += dot(perp, f.zyx);
+
+ ft += length(f);
+
+ // TODO(JS):
+ // Disabled because reflect with double fails on dxc
+ //ft += reflect(f, FloatVector(0, 1, 0));
+ }
+
+ // Reduced set of intrinsics that should work on all targets
+
+#if 0
+ // TODO(JS):
+ // Disabled because not supported on VK (glsl) in vector form
+ ft += rcp(1.0l + f);
+#endif
+
+ ft += sign(f - 0.5l);
+
+ ft += saturate(f * 4 - 2.0l);
+
+ ft += abs(f * 4 - 2.0l);
+
+ ft += min(0.5l, f);
+ ft += max(f, 0.75l);
+
+ ft += clamp(f, 0.1l, 0.3l);
+
+ outputBuffer[idx] = vector<Float, 4>(ft, 0);
+} \ No newline at end of file
diff --git a/tests/hlsl-intrinsic/vector-double-reduced-intrinsic.slang.expected.txt b/tests/hlsl-intrinsic/vector-double-reduced-intrinsic.slang.expected.txt
new file mode 100644
index 000000000..d10d62540
--- /dev/null
+++ b/tests/hlsl-intrinsic/vector-double-reduced-intrinsic.slang.expected.txt
@@ -0,0 +1,17 @@
+type: double
+2.131378
+2.252492
+2.512755
+0.000000
+2.298468
+2.589615
+1.887061
+0.000000
+2.739342
+3.501444
+5.431718
+0.000000
+3.231768
+7.063389
+6.968284
+0.000000
diff --git a/tests/hlsl-intrinsic/vector-float.slang b/tests/hlsl-intrinsic/vector-float.slang
index 2ca98de6c..f1d37c71e 100644
--- a/tests/hlsl-intrinsic/vector-float.slang
+++ b/tests/hlsl-intrinsic/vector-float.slang
@@ -7,29 +7,45 @@
//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
RWStructuredBuffer<float4> outputBuffer;
+typedef float Float;
+
+typedef vector<Float, 3> FloatVector;
+typedef vector<int, 3> IntVector;
+typedef vector<uint, 3> UIntVector;
+
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
int idx = int(dispatchThreadID.x);
- float vf = idx * (1.0f / (4.0f));
+ Float vf = idx * (1.0f / (4.0f));
- float3 f = float3(0.1f, vf, vf + 0.2f);
-
- // Vector specific
- float3 nv = normalize(f);
-
+ FloatVector f = FloatVector(0.1f, vf, vf + 0.2f);
// Operate over all values
- float3 ft = {};
+ FloatVector ft = {};
// fmod
- ft += float3(int3(((f % 0.11f) * 100) + 0.5));
+ ft += FloatVector(IntVector(((f % 0.11f) * 100) + 0.5));
ft += sin(f);
ft += cos(f);
ft += tan(f);
+ {
+ // Vector specific
+ FloatVector nv = normalize(f);
+ ft += nv;
+
+ FloatVector perp = cross(nv, f.zxy);
+ ft += perp;
+
+ ft += dot(perp, f.zyx);
+ ft += length(perp);
+
+ ft += reflect(f, perp.yzx);
+ }
+
ft += asin(f);
ft += acos(f);
ft += atan(f);
@@ -39,7 +55,7 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
#if 0
{
// Disabled because not supported on VK (glsl) in vector form
- float3 sf, cf;
+ FloatVector sf, cf;
sincos(f, sf, cf);
ft += sf;
@@ -75,7 +91,7 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
float v[] = { 1, 10, 100, 1000 };
- ft += int3(log10(float3(v[idx] + vf) + 0.5f));
+ ft += IntVector(log10(FloatVector(v[idx] + vf) + 0.5f));
}
@@ -93,11 +109,10 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
ft += step(f, 0.5);
- int3 vi = asint(f - f) + idx;
+ {
+ IntVector vi = asint(f - f) + idx;
+ ft += FloatVector(vi);
+ }
- ft += float3(vi);
-
- float4 result = float4(ft + nv, 0) + float4(vf);
-
- outputBuffer[idx] = result;
+ outputBuffer[idx] = vector<Float, 4>(ft, 0);
} \ No newline at end of file
diff --git a/tests/hlsl-intrinsic/vector-float.slang.expected.txt b/tests/hlsl-intrinsic/vector-float.slang.expected.txt
index c2a569574..3f480da5f 100644
--- a/tests/hlsl-intrinsic/vector-float.slang.expected.txt
+++ b/tests/hlsl-intrinsic/vector-float.slang.expected.txt
@@ -1,17 +1,17 @@
type: float
--64.893356
--98.276619
--42.604630
+-64.691277
+-97.906212
+-42.168385
+0.000000
+-62.544128
+-33.527363
+10.426896
+0.000000
+-59.882103
+29.953676
+74.433708
+0.000000
+-56.981304
+96.036606
+140.310608
0.000000
--62.899876
--34.338215
-9.949981
-0.250000
--60.725098
-28.410460
-73.591156
-0.500000
--58.508228
-93.563255
-138.897034
-0.750000