Implement rsDebug for half
http://b/27556050
Add needed support in libRSDriver and libclcore.
Change-Id: I374b4372bd4f550e99f9916e1c0a08b8c406f0fc
(cherry picked from commit 92185a7b5e7821ce5b584329a2483f224ca12e0f)
diff --git a/driver/rsdRuntimeStubs.cpp b/driver/rsdRuntimeStubs.cpp
index b4958e2..79a1315 100644
--- a/driver/rsdRuntimeStubs.cpp
+++ b/driver/rsdRuntimeStubs.cpp
@@ -1122,6 +1122,33 @@
ALOGD("%s {%f, %f, %f, %f}", s, f.x, f.y, f.z, f.w);
}
+// Accept a half value converted to float. This eliminates the need in the
+// driver to properly support the half datatype (either by adding compiler flags
+// for half or link against compiler_rt).
+void rsDebug(const char *s, float f, ushort us) {
+ ALOGD("%s {%f} {0x%hx}", s, f, us);
+}
+
+void rsDebug(const char *s, const float2 *f2, const ushort2 *us2) {
+ float2 f = *f2;
+ ushort2 us = *us2;
+ ALOGD("%s {%f %f} {0x%hx 0x%hx}", s, f.x, f.y, us.x, us.y);
+}
+
+void rsDebug(const char *s, const float3 *f3, const ushort3 *us3) {
+ float3 f = *f3;
+ ushort3 us = *us3;
+ ALOGD("%s {%f %f %f} {0x%hx 0x%hx 0x%hx}", s, f.x, f.y, f.z, us.x, us.y,
+ us.z);
+}
+
+void rsDebug(const char *s, const float4 *f4, const ushort4 *us4) {
+ float4 f = *f4;
+ ushort4 us = *us4;
+ ALOGD("%s {%f %f %f %f} {0x%hx 0x%hx 0x%hx 0x%hx}", s, f.x, f.y, f.z, f.w,
+ us.x, us.y, us.z, us.w);
+}
+
void rsDebug(const char *s, double d) {
ALOGD("%s %f, 0x%08llx", s, d, *((long long *) (&d)));
}
diff --git a/driver/runtime/rs_core.c b/driver/runtime/rs_core.c
index 60d8578..6e4c6d0 100644
--- a/driver/runtime/rs_core.c
+++ b/driver/runtime/rs_core.c
@@ -310,3 +310,37 @@
PRIM_DEBUG(double4)
#undef PRIM_DEBUG
+
+// Convert the half values to float before handing off to the driver. This
+// eliminates the need in the driver to properly support the half datatype
+// (either by adding compiler flags for half or link against compiler_rt).
+// Also, pass the bit-equivalent ushort to be printed.
+extern void __attribute__((overloadable)) rsDebug(const char *s, float f,
+ ushort us);
+extern void __attribute__((overloadable)) rsDebug(const char *s, half h) {
+ rsDebug(s, (float) h, *(ushort *) &h);
+}
+
+extern void __attribute__((overloadable)) rsDebug(const char *s,
+ const float2 *f,
+ const ushort2 *us);
+extern void __attribute__((overloadable)) rsDebug(const char *s, half2 h2) {
+ float2 f = convert_float2(h2);
+ rsDebug(s, &f, (ushort2 *) &h2);
+}
+
+extern void __attribute__((overloadable)) rsDebug(const char *s,
+ const float3 *f,
+ const ushort3 *us);
+extern void __attribute__((overloadable)) rsDebug(const char *s, half3 h3) {
+ float3 f = convert_float3(h3);
+ rsDebug(s, &f, (ushort3 *) &h3);
+}
+
+extern void __attribute__((overloadable)) rsDebug(const char *s,
+ const float4 *f,
+ const ushort4 *us);
+extern void __attribute__((overloadable)) rsDebug(const char *s, half4 h4) {
+ float4 f = convert_float4(h4);
+ rsDebug(s, &f, (ushort4 *) &h4);
+}