aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compute/common
diff options
context:
space:
mode:
authorGravatar Allan MacKinnon <allanmac@google.com>2018-07-16 15:57:05 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-17 17:01:41 +0000
commit9e0d7e4072e43495a3907bb2bac7824e8e60c368 (patch)
treebaaff58dd81c1dc5e26668a8d517cbdf568bdb94 /src/compute/common
parent53c876900247ad700ce28f7b33031047a6cff402 (diff)
Bug fixes and improvements to SKC and HotSort. Vulkan is WIP.
Bug: skia: Change-Id: Iffc75a5b4dfcbfa4a6c23d972bb9798c2f550335 Reviewed-on: https://skia-review.googlesource.com/141582 Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Allan MacKinnon <allanmac@google.com> Commit-Queue: Allan MacKinnon <allanmac@google.com>
Diffstat (limited to 'src/compute/common')
-rw-r--r--src/compute/common/cl/assert_cl.c2
-rw-r--r--src/compute/common/cl/assert_cl.h1
-rw-r--r--src/compute/common/cl/find_cl.c11
-rw-r--r--src/compute/common/cl/find_cl.h1
-rw-r--r--src/compute/common/macros.h41
-rw-r--r--src/compute/common/util.c4
-rw-r--r--src/compute/common/util.h2
7 files changed, 37 insertions, 25 deletions
diff --git a/src/compute/common/cl/assert_cl.c b/src/compute/common/cl/assert_cl.c
index 5d420586b3..944256daec 100644
--- a/src/compute/common/cl/assert_cl.c
+++ b/src/compute/common/cl/assert_cl.c
@@ -129,7 +129,7 @@ assert_cl(cl_int const code, char const * const file, int const line, bool const
char const * const cl_err_str = cl_get_error_string(code);
fprintf(stderr,
- "\"%s\", line %d: cl_assert (%d) = \"%s\"",
+ "\"%s\", line %d: assert_cl( %d ) = \"%s\"",
file,line,code,cl_err_str);
if (abort)
diff --git a/src/compute/common/cl/assert_cl.h b/src/compute/common/cl/assert_cl.h
index 517ada8d37..efe698f29e 100644
--- a/src/compute/common/cl/assert_cl.h
+++ b/src/compute/common/cl/assert_cl.h
@@ -53,4 +53,3 @@ cl_get_event_command_type_string(cl_command_type const type);
//
//
//
-
diff --git a/src/compute/common/cl/find_cl.c b/src/compute/common/cl/find_cl.c
index a04d9ebd69..6c500c0865 100644
--- a/src/compute/common/cl/find_cl.c
+++ b/src/compute/common/cl/find_cl.c
@@ -45,7 +45,7 @@ clFindIdsByName(char const * const target_platform_substring,
cl(GetPlatformIDs(0,NULL,&platform_count));
- cl_platform_id * const platform_ids = ALLOCA(sizeof(*platform_ids) * platform_count);
+ cl_platform_id * const platform_ids = ALLOCA_MACRO(sizeof(*platform_ids) * platform_count);
cl(GetPlatformIDs(platform_count,platform_ids,NULL));
@@ -62,7 +62,7 @@ clFindIdsByName(char const * const target_platform_substring,
NULL,
&platform_name_size));
- char * const platform_name = ALLOCA(platform_name_size);
+ char * const platform_name = ALLOCA_MACRO(platform_name_size);
cl(GetPlatformInfo(platform_ids[ii],
CL_PLATFORM_NAME,
@@ -93,7 +93,7 @@ clFindIdsByName(char const * const target_platform_substring,
NULL,
&device_count);
- cl_device_id * const device_ids = ALLOCA(sizeof(*device_ids) * device_count);
+ cl_device_id * const device_ids = ALLOCA_MACRO(sizeof(*device_ids) * device_count);
cl_err = clGetDeviceIDs(platform_ids[ii],
CL_DEVICE_TYPE_ALL,
@@ -121,8 +121,8 @@ clFindIdsByName(char const * const target_platform_substring,
NULL,
&driver_version_size));
- char * const device_name = ALLOCA(device_name_size);
- char * const driver_version = ALLOCA(driver_version_size);
+ char * const device_name = ALLOCA_MACRO(device_name_size);
+ char * const driver_version = ALLOCA_MACRO(driver_version_size);
cl(GetDeviceInfo(device_ids[jj],
CL_DEVICE_NAME,
@@ -207,4 +207,3 @@ clFindIdsByName(char const * const target_platform_substring,
//
//
//
-
diff --git a/src/compute/common/cl/find_cl.h b/src/compute/common/cl/find_cl.h
index 5143e39f85..6dbfe10838 100644
--- a/src/compute/common/cl/find_cl.h
+++ b/src/compute/common/cl/find_cl.h
@@ -32,4 +32,3 @@ clFindIdsByName(char const * const target_platform_substring,
//
//
//
-
diff --git a/src/compute/common/macros.h b/src/compute/common/macros.h
index 52dc8689fc..266b58f108 100644
--- a/src/compute/common/macros.h
+++ b/src/compute/common/macros.h
@@ -12,16 +12,35 @@
//
//
-#define ARRAY_LENGTH(x) (sizeof(x)/sizeof(x[0]))
+#include <stdint.h>
//
//
//
-#define MAX_MACRO(a,b) (((a) > (b)) ? (a) : (b))
-#define MIN_MACRO(a,b) (((a) < (b)) ? (a) : (b))
-#define GTE_MACRO(a,b) ((a) >= (b))
-#define LT_MACRO(a,b) ((a) < (b))
+#define ARRAY_LENGTH_MACRO(x) (sizeof(x)/sizeof(x[0]))
+#define OFFSET_OF_MACRO(t,m) ((size_t)&(((t*)0)->m))
+#define MEMBER_SIZE_MACRO(t,m) sizeof(((t*)0)->m)
+
+
+//
+//
+//
+
+#define MAX_MACRO(a,b) (((a) > (b)) ? (a) : (b))
+#define MIN_MACRO(a,b) (((a) < (b)) ? (a) : (b))
+#define GTE_MACRO(a,b) ((a) >= (b))
+#define LT_MACRO(a,b) ((a) < (b))
+
+//
+//
+//
+
+#if defined(_MSC_VER)
+#define ALLOCA_MACRO(n) _alloca(n)
+#else
+#define ALLOCA_MACRO(n) alloca(n)
+#endif
//
//
@@ -34,14 +53,14 @@
#define BITS_TO_MASK_AT_64(n,b) (BITS_TO_MASK_64(n)<<(b))
//
-//
+// Convert 4 byte pointer to network order dword to a host order.
//
-#if defined(_MSC_VER)
-#define ALLOCA(n) _alloca(n)
-#else
-#define ALLOCA(n) alloca(n)
-#endif
+#define NPBTOHL_MACRO(pb4) ((((pb4)[0])<<24) | (((pb4)[1])<<16) | \
+ (((pb4)[2])<< 8) | (pb4)[3])
+
+#define NTOHL_MACRO(nl) ntohl(nl)
+
//
//
//
diff --git a/src/compute/common/util.c b/src/compute/common/util.c
index eb05d91a9f..51a8e0128e 100644
--- a/src/compute/common/util.c
+++ b/src/compute/common/util.c
@@ -59,12 +59,11 @@ pow2_rd_u32(uint32_t n)
uint32_t
msb_idx_u32(uint32_t n)
{
-
#ifdef _MSC_VER
uint32_t index;
- _BitScanReverse(&index,n);
+ _BitScanReverse((unsigned long *)&index,n);
return index;
@@ -78,7 +77,6 @@ msb_idx_u32(uint32_t n)
#error "No msb_index()"
#endif
-
}
//
diff --git a/src/compute/common/util.h b/src/compute/common/util.h
index 7d5a7b4600..113e26d789 100644
--- a/src/compute/common/util.h
+++ b/src/compute/common/util.h
@@ -27,5 +27,3 @@ uint32_t msb_idx_u32(uint32_t n); // 0-based bit position
//
//
//
-
-