Is there a way to pass our C++ maths vector class to an ISPC export
function as a short vector? It feels like there must be a way to do this,
but the compiler denies it's possible, and the docs don't mention anything
at all.
A simple example:
// test.ispc
export uniform float<3> AddVectors(uniform float<3> a, uniform float<3> b)
{
return a + b;
}
// Vector.h
class Vector
{
public:
float X;
float Y;
float Z;
/* snip operators and helper functions */
};
// Test.cpp
Vector a = {1.f, 2.f, 3.f};
Vector b = {4.f, 5.f, 6.f};
Vector result = ispc::AddVectors(a, b);
This returns ispc errors complaining about the use of short vectors in the
function signature:
<source>:42:25: Error: Illegal to return a "varying" or vector type from
exported function "AddVectors"
export uniform float<3> AddVectors(uniform float<3> a, uniform float<3> b)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<source>:42:53: Error: Vector-typed parameter "a" is illegal in an
exported function.
export uniform float<3> AddVectors(uniform float<3> a, uniform float<3> b)
^
<source>:42:73: Error: Vector-typed parameter "b" is illegal in an
exported function.
export uniform float<3> AddVectors(uniform float<3> a, uniform float<3> b)
>From what I can tell, my alternatives are to do some conversion manually,
eg use uniform float[3], or uniform float*, or pass x/y/z parameters
separately.
Am I missing another option?
--
You received this message because you are subscribed to the Google Groups
"Intel SPMD Program Compiler Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ispc-users/4a9c9a93-7ac9-4a2f-b97f-fbe2c6f75cd1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.