summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPirama Arumuga Nainar <pirama@google.com>2016-04-04 23:22:57 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-04-04 23:22:57 +0000
commitd4beeb175a64c0b6d6a10766784c28466f6bfece (patch)
tree33d45068255cd54026dec4780843a6559391d4c1
parentfc67d62209f280380e709547ed926c93bff6d88d (diff)
parentbc3789bcda1e7a86a680de1bb2c16319396dae46 (diff)
downloadrs-d4beeb175a64c0b6d6a10766784c28466f6bfece.tar.gz
Merge changes from topic \'rsdebug\' into nyc-dev
am: bc3789b * commit 'bc3789bcda1e7a86a680de1bb2c16319396dae46': Test rsDebug for half Implement rsDebug for half Add rsDebug for half Change-Id: If06676bb943e4cf10b5025cd0bd1fadb01970fbd
-rw-r--r--api/rs_debug.spec9
-rw-r--r--driver/rsdRuntimeStubs.cpp27
-rw-r--r--driver/runtime/rs_core.c34
-rw-r--r--java/tests/RsTest/src/com/android/rs/test/rsdebug.rs11
-rw-r--r--scriptc/rs_debug.rsh20
5 files changed, 101 insertions, 0 deletions
diff --git a/api/rs_debug.spec b/api/rs_debug.spec
index dcafe203..35d9265c 100644
--- a/api/rs_debug.spec
+++ b/api/rs_debug.spec
@@ -67,6 +67,15 @@ test: none
end:
function: rsDebug
+version: 24
+w: 1, 2, 3, 4
+ret: void
+arg: const char* message
+arg: half#1 a
+test: none
+end:
+
+function: rsDebug
version: 17
w: 1, 2, 3, 4
t: i8, u8, i16, u16
diff --git a/driver/rsdRuntimeStubs.cpp b/driver/rsdRuntimeStubs.cpp
index 9fea491b..c0f5ddb5 100644
--- a/driver/rsdRuntimeStubs.cpp
+++ b/driver/rsdRuntimeStubs.cpp
@@ -1122,6 +1122,33 @@ void rsDebug(const char *s, const float4 *f4) {
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 60d8578f..6e4c6d0f 100644
--- a/driver/runtime/rs_core.c
+++ b/driver/runtime/rs_core.c
@@ -310,3 +310,37 @@ PRIM_DEBUG(double3)
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);
+}
diff --git a/java/tests/RsTest/src/com/android/rs/test/rsdebug.rs b/java/tests/RsTest/src/com/android/rs/test/rsdebug.rs
index 199816b0..5316e61a 100644
--- a/java/tests/RsTest/src/com/android/rs/test/rsdebug.rs
+++ b/java/tests/RsTest/src/com/android/rs/test/rsdebug.rs
@@ -28,6 +28,17 @@ static bool basic_test(uint32_t index) {
// This test focuses primarily on compilation-time, not run-time.
// For this reason, none of the outputs are actually checked.
+ // http://b/27526302 - globals of half type cannot be exported and fail compilation
+ half halfTest = (half) 1.5f;
+ half2 half2Test = {(half) 1.5f, (half) 2.5f};
+ half3 half3Test = {(half) 1.5f, (half) 2.5f, (half) 3.5f};
+ half4 half4Test = {(half) 0.f, (half) -0.f, (half) 1.f/0.f, (half) 0.f/0.f};
+
+ rsDebug("halfTest", halfTest);
+ rsDebug("half2Test", half2Test);
+ rsDebug("half3Test", half3Test);
+ rsDebug("half4Test", half4Test);
+
rsDebug("floatTest", floatTest);
rsDebug("float2Test", float2Test);
rsDebug("float3Test", float3Test);
diff --git a/scriptc/rs_debug.rsh b/scriptc/rs_debug.rsh
index 51a74bd9..13c5faa8 100644
--- a/scriptc/rs_debug.rsh
+++ b/scriptc/rs_debug.rsh
@@ -139,6 +139,26 @@ extern void __attribute__((overloadable))
extern void __attribute__((overloadable))
rsDebug(const char* message, float4 a);
+#if (defined(RS_VERSION) && (RS_VERSION >= 24))
+extern void __attribute__((overloadable))
+ rsDebug(const char* message, half a);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 24))
+extern void __attribute__((overloadable))
+ rsDebug(const char* message, half2 a);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 24))
+extern void __attribute__((overloadable))
+ rsDebug(const char* message, half3 a);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 24))
+extern void __attribute__((overloadable))
+ rsDebug(const char* message, half4 a);
+#endif
+
#if (defined(RS_VERSION) && (RS_VERSION >= 17))
extern void __attribute__((overloadable))
rsDebug(const char* message, char a);