Skip to content

Commit 75c5b9f

Browse files
committed
added new dot partial spec
1 parent e4ab255 commit 75c5b9f

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl

+21-2
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,8 @@ struct fma_helper<T NBL_PARTIAL_REQ_BOT(VECTOR_SPECIALIZATION_CONCEPT) >
908908
#endif
909909

910910
template<typename Vectorial>
911-
NBL_PARTIAL_REQ_TOP(DOT_HELPER_REQUIREMENT)
912-
struct dot_helper<Vectorial NBL_PARTIAL_REQ_BOT(DOT_HELPER_REQUIREMENT) >
911+
NBL_PARTIAL_REQ_TOP(DOT_HELPER_REQUIREMENT && concepts::FloatingPoint<Vectorial>)
912+
struct dot_helper<Vectorial NBL_PARTIAL_REQ_BOT(DOT_HELPER_REQUIREMENT && concepts::FloatingPoint<Vectorial>) >
913913
{
914914
using scalar_type = typename vector_traits<Vectorial>::scalar_type;
915915

@@ -926,6 +926,25 @@ struct dot_helper<Vectorial NBL_PARTIAL_REQ_BOT(DOT_HELPER_REQUIREMENT) >
926926
}
927927
};
928928

929+
template<typename Vectorial>
930+
NBL_PARTIAL_REQ_TOP(DOT_HELPER_REQUIREMENT && !concepts::FloatingPoint<Vectorial>)
931+
struct dot_helper<Vectorial NBL_PARTIAL_REQ_BOT(DOT_HELPER_REQUIREMENT && !concepts::FloatingPoint<Vectorial>) >
932+
{
933+
using scalar_type = typename vector_traits<Vectorial>::scalar_type;
934+
935+
static inline scalar_type __call(NBL_CONST_REF_ARG(Vectorial) lhs, NBL_CONST_REF_ARG(Vectorial) rhs)
936+
{
937+
static const uint32_t ArrayDim = vector_traits<Vectorial>::Dimension;
938+
static array_get<Vectorial, scalar_type> getter;
939+
940+
scalar_type retval = getter(lhs, 0) * getter(rhs, 0);
941+
for (uint32_t i = 1; i < ArrayDim; ++i)
942+
retval = retval + getter(lhs, i) * getter(rhs, i);
943+
944+
return retval;
945+
}
946+
};
947+
929948
#undef DOT_HELPER_REQUIREMENT
930949

931950
}

0 commit comments

Comments
 (0)