From 2c0301c988dcf6fa5e28ec5b69916ba2cf26cd5e Mon Sep 17 00:00:00 2001 From: David Pinedo Date: Mon, 2 Feb 2015 18:02:40 -0700 Subject: nulldrv: Creation of the nulldrv, for use on Windows. Since the sample Intel driver hasn't been ported to Windows, this nulldrv is being used to bootstrap Windows support. It can also provide a hint to new IHV's for how to set the magic number. --- icd/common/CMakeLists.txt | 4 ++++ icd/common/icd-alloc.c | 6 +++++- icd/common/icd-format.h | 6 +++--- icd/common/icd-utils.h | 22 ++++++++++++++-------- icd/common/icd.h | 10 ++++++++++ 5 files changed, 36 insertions(+), 12 deletions(-) (limited to 'icd/common') diff --git a/icd/common/CMakeLists.txt b/icd/common/CMakeLists.txt index e1946cf3..235601d1 100644 --- a/icd/common/CMakeLists.txt +++ b/icd/common/CMakeLists.txt @@ -1,3 +1,7 @@ +if (WIN32) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS") +endif() + set(sources icd-alloc.c icd-format.c diff --git a/icd/common/icd-alloc.c b/icd/common/icd-alloc.c index 30aad783..bbe27819 100644 --- a/icd/common/icd-alloc.c +++ b/icd/common/icd-alloc.c @@ -42,7 +42,7 @@ static void *default_alloc(void *user_data, size_t size, size_t alignment, { if (alignment <= 1) { return malloc(size); - } else if (u_is_pow2(alignment)) { + } else if (u_is_pow2((uint32_t) alignment)) { if (alignment < sizeof(void *)) { assert(u_is_pow2(sizeof(void*))); alignment = sizeof(void *); @@ -50,7 +50,11 @@ static void *default_alloc(void *user_data, size_t size, size_t alignment, size = (size + alignment - 1) & ~(alignment - 1); +#if defined(PLATFORM_LINUX) return aligned_alloc(alignment, size); +#else + return _aligned_malloc(size, alignment); +#endif } else { return NULL; diff --git a/icd/common/icd-format.h b/icd/common/icd-format.h index 3ab9be8e..7aa50019 100644 --- a/icd/common/icd-format.h +++ b/icd/common/icd-format.h @@ -31,14 +31,14 @@ #include #include "icd.h" -static inline bool icd_format_is_undef(XGL_FORMAT format) +STATIC_INLINE bool icd_format_is_undef(XGL_FORMAT format) { return (format == XGL_FMT_UNDEFINED); } bool icd_format_is_ds(XGL_FORMAT format); -static inline bool icd_format_is_color(XGL_FORMAT format) +STATIC_INLINE bool icd_format_is_color(XGL_FORMAT format) { return !(icd_format_is_undef(format) || icd_format_is_ds(format)); } @@ -53,7 +53,7 @@ bool icd_format_is_srgb(XGL_FORMAT format); bool icd_format_is_compressed(XGL_FORMAT format); -static inline int icd_format_get_block_width(XGL_FORMAT format) +STATIC_INLINE int icd_format_get_block_width(XGL_FORMAT format) { /* all compressed formats use 4x4 blocks */ return (icd_format_is_compressed(format)) ? 4 : 1; diff --git a/icd/common/icd-utils.h b/icd/common/icd-utils.h index 5304d158..aad6c3e5 100644 --- a/icd/common/icd-utils.h +++ b/icd/common/icd-utils.h @@ -31,7 +31,9 @@ #include #include #include +#if defined(PLATFORM_LINUX) #include /* for ffs() */ +#endif #include "icd.h" #if defined(NDEBUG) && defined(__GNUC__) @@ -63,28 +65,32 @@ /** * Return true if val is power of two, or zero. */ -static inline bool u_is_pow2(unsigned int val) +STATIC_INLINE bool u_is_pow2(unsigned int val) { return ((val & (val - 1)) == 0); } -static inline int u_ffs(int val) +STATIC_INLINE int u_ffs(int val) { - return ffs(val); +#if defined(PLATFORM_LINUX) + return ffs(val); +#else + return __lzcnt(val) + 1; +#endif } -static inline unsigned int u_align(unsigned int val, unsigned alignment) +STATIC_INLINE unsigned int u_align(unsigned int val, unsigned alignment) { assert(alignment && u_is_pow2(alignment)); return (val + alignment - 1) & ~(alignment - 1); } -static inline unsigned int u_minify(unsigned int val, unsigned level) +STATIC_INLINE unsigned int u_minify(unsigned int val, unsigned level) { return (val >> level) ? val >> level : 1; } -static inline uint32_t u_fui(float f) +STATIC_INLINE uint32_t u_fui(float f) { union { float f; @@ -94,7 +100,7 @@ static inline uint32_t u_fui(float f) return u.ui; } -static inline float u_uif(uint32_t ui) +STATIC_INLINE float u_uif(uint32_t ui) { union { float f; @@ -104,7 +110,7 @@ static inline float u_uif(uint32_t ui) return u.f; } -static inline int u_iround(float f) +STATIC_INLINE int u_iround(float f) { if (f >= 0.0f) return (int) (f + 0.5f); diff --git a/icd/common/icd.h b/icd/common/icd.h index 1e053c8a..da5e0079 100644 --- a/icd/common/icd.h +++ b/icd/common/icd.h @@ -29,9 +29,19 @@ #define ICD_H #include +#include #include + +#if defined(PLATFORM_LINUX) + #include +#else + +#include + +#endif + #if defined(__GNUC__) && __GNUC__ >= 4 # define ICD_EXPORT __attribute__((visibility("default"))) #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) -- cgit v1.2.3