aboutsummaryrefslogtreecommitdiff
path: root/icd/common
diff options
context:
space:
mode:
authorDavid Pinedo <david@lunarg.com>2015-02-02 18:02:40 -0700
committerIan Elliott <ian@LunarG.com>2015-02-18 15:46:17 -0700
commit2c0301c988dcf6fa5e28ec5b69916ba2cf26cd5e (patch)
treedd8223e08331269a9cc44ff340c4a2c92b707385 /icd/common
parent7b8fee6cb12a92cd5c82f976ba2b8114d94290fc (diff)
downloadusermoji-2c0301c988dcf6fa5e28ec5b69916ba2cf26cd5e.tar.xz
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.
Diffstat (limited to 'icd/common')
-rw-r--r--icd/common/CMakeLists.txt4
-rw-r--r--icd/common/icd-alloc.c6
-rw-r--r--icd/common/icd-format.h6
-rw-r--r--icd/common/icd-utils.h22
-rw-r--r--icd/common/icd.h10
5 files changed, 36 insertions, 12 deletions
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 <stdbool.h>
#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 <stdbool.h>
#include <stdint.h>
#include <assert.h>
+#if defined(PLATFORM_LINUX)
#include <strings.h> /* 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 <xgl.h>
+#include <xglPlatform.h>
#include <xglDbg.h>
+
+#if defined(PLATFORM_LINUX)
+
#include <xglWsiX11Ext.h>
+#else
+
+#include <xglWsiWinExt.h>
+
+#endif
+
#if defined(__GNUC__) && __GNUC__ >= 4
# define ICD_EXPORT __attribute__((visibility("default")))
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)