aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/drivers/dri
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/drivers/dri')
-rwxr-xr-x[-rw-r--r--]mesalib/src/mesa/drivers/dri/common/dri_util.c84
-rw-r--r--mesalib/src/mesa/drivers/dri/common/megadriver_stub.c2
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlconfig.c39
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlconfig.h4
-rw-r--r--mesalib/src/mesa/drivers/dri/swrast/swrast.c47
-rw-r--r--mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h7
6 files changed, 114 insertions, 69 deletions
diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c
index 6c78928ee..f18fac61e 100644..100755
--- a/mesalib/src/mesa/drivers/dri/common/dri_util.c
+++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c
@@ -116,6 +116,8 @@ driCreateNewScreen2(int scrn, int fd,
{
static const __DRIextension *emptyExtensionList[] = { NULL };
__DRIscreen *psp;
+ int gl_version_override;
+ int i;
psp = calloc(1, sizeof(*psp));
if (!psp)
@@ -128,7 +130,7 @@ driCreateNewScreen2(int scrn, int fd,
* (megadrivers), use that instead.
*/
if (driver_extensions) {
- for (int i = 0; driver_extensions[i]; i++) {
+ for (i = 0; driver_extensions[i]; i++) {
if (strcmp(driver_extensions[i]->name, __DRI_DRIVER_VTABLE) == 0) {
psp->driver =
((__DRIDriverVtableExtension *)driver_extensions[i])->vtable;
@@ -162,7 +164,7 @@ driCreateNewScreen2(int scrn, int fd,
return NULL;
}
- int gl_version_override = _mesa_get_gl_version_override();
+ gl_version_override = _mesa_get_gl_version_override();
if (gl_version_override >= 31) {
psp->max_gl_core_version = MAX2(psp->max_gl_core_version,
gl_version_override);
@@ -310,6 +312,8 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
unsigned minor_version = 0;
uint32_t flags = 0;
bool notify_reset = false;
+ unsigned i;
+ struct gl_context *ctx;
assert((num_attribs == 0) || (attribs != NULL));
@@ -337,7 +341,7 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
return NULL;
}
- for (unsigned i = 0; i < num_attribs; i++) {
+ for (i = 0; i < num_attribs; i++) {
switch (attribs[i * 2]) {
case __DRI_CTX_ATTRIB_MAJOR_VERSION:
major_version = attribs[i * 2 + 1];
@@ -732,36 +736,36 @@ driSwapBuffers(__DRIdrawable *pdp)
/** Core interface */
const __DRIcoreExtension driCoreExtension = {
- .base = { __DRI_CORE, 1 },
-
- .createNewScreen = NULL,
- .destroyScreen = driDestroyScreen,
- .getExtensions = driGetExtensions,
- .getConfigAttrib = driGetConfigAttrib,
- .indexConfigAttrib = driIndexConfigAttrib,
- .createNewDrawable = NULL,
- .destroyDrawable = driDestroyDrawable,
- .swapBuffers = driSwapBuffers, /* swrast */
- .createNewContext = driCreateNewContext, /* swrast */
- .copyContext = driCopyContext,
- .destroyContext = driDestroyContext,
- .bindContext = driBindContext,
- .unbindContext = driUnbindContext
+ /*.base =*/ { __DRI_CORE, 1 },
+
+ /*.createNewScreen =*/ NULL,
+ /*.destroyScreen =*/ driDestroyScreen,
+ /*.getExtensions =*/ driGetExtensions,
+ /*.getConfigAttrib =*/ driGetConfigAttrib,
+ /*.indexConfigAttrib =*/ driIndexConfigAttrib,
+ /*.createNewDrawable =*/ NULL,
+ /*.destroyDrawable =*/ driDestroyDrawable,
+ /*.swapBuffers =*/ driSwapBuffers, /* swrast */
+ /*.createNewContext =*/ driCreateNewContext, /* swrast */
+ /*.copyContext =*/ driCopyContext,
+ /*.destroyContext =*/ driDestroyContext,
+ /*.bindContext =*/ driBindContext,
+ /*.unbindContext =*/ driUnbindContext
};
/** DRI2 interface */
const __DRIdri2Extension driDRI2Extension = {
- .base = { __DRI_DRI2, 4 },
-
- .createNewScreen = dri2CreateNewScreen,
- .createNewDrawable = driCreateNewDrawable,
- .createNewContext = driCreateNewContext,
- .getAPIMask = driGetAPIMask,
- .createNewContextForAPI = driCreateNewContextForAPI,
- .allocateBuffer = dri2AllocateBuffer,
- .releaseBuffer = dri2ReleaseBuffer,
- .createContextAttribs = driCreateContextAttribs,
- .createNewScreen2 = driCreateNewScreen2,
+ /*.base =*/ { __DRI_DRI2, 4 },
+
+ /*.createNewScreen =*/ dri2CreateNewScreen,
+ /*.createNewDrawable =*/ driCreateNewDrawable,
+ /*.createNewContext =*/ driCreateNewContext,
+ /*.getAPIMask =*/ driGetAPIMask,
+ /*.createNewContextForAPI =*/ driCreateNewContextForAPI,
+ /*.allocateBuffer =*/ dri2AllocateBuffer,
+ /*.releaseBuffer =*/ dri2ReleaseBuffer,
+ /*.createContextAttribs =*/ driCreateContextAttribs,
+ /*.createNewScreen2 =*/ driCreateNewScreen2,
};
const __DRIswrastExtension driSWRastExtension = {
@@ -775,11 +779,11 @@ const __DRIswrastExtension driSWRastExtension = {
};
const __DRI2configQueryExtension dri2ConfigQueryExtension = {
- .base = { __DRI2_CONFIG_QUERY, 1 },
+ /*.base =*/ { __DRI2_CONFIG_QUERY, 1 },
- .configQueryb = dri2ConfigQueryb,
- .configQueryi = dri2ConfigQueryi,
- .configQueryf = dri2ConfigQueryf,
+ /*.configQueryb =*/ dri2ConfigQueryb,
+ /*.configQueryi =*/ dri2ConfigQueryi,
+ /*.configQueryf =*/ dri2ConfigQueryf,
};
void
@@ -871,12 +875,12 @@ driImageFormatToGLFormat(uint32_t image_format)
/** Image driver interface */
const __DRIimageDriverExtension driImageDriverExtension = {
- .base = { __DRI_IMAGE_DRIVER, 1 },
+ /*.base =*/ { __DRI_IMAGE_DRIVER, 1 },
- .createNewScreen2 = driCreateNewScreen2,
- .createNewDrawable = driCreateNewDrawable,
- .getAPIMask = driGetAPIMask,
- .createContextAttribs = driCreateContextAttribs,
+ /*.createNewScreen2 =*/ driCreateNewScreen2,
+ /*.createNewDrawable =*/ driCreateNewDrawable,
+ /*.createContextAttribs =*/ driCreateContextAttribs,
+ /*.getAPIMask =*/ driGetAPIMask,
};
/* swrast copy sub buffer entrypoint. */
@@ -890,7 +894,7 @@ static void driCopySubBuffer(__DRIdrawable *pdp, int x, int y,
/* for swrast only */
const __DRIcopySubBufferExtension driCopySubBufferExtension = {
- .base = { __DRI_COPY_SUB_BUFFER, 1 },
+ /*.base =*/ { __DRI_COPY_SUB_BUFFER, 1 },
- .copySubBuffer = driCopySubBuffer,
+ /*.copySubBuffer =*/ driCopySubBuffer,
};
diff --git a/mesalib/src/mesa/drivers/dri/common/megadriver_stub.c b/mesalib/src/mesa/drivers/dri/common/megadriver_stub.c
index d085080a1..f0c8878a8 100644
--- a/mesalib/src/mesa/drivers/dri/common/megadriver_stub.c
+++ b/mesalib/src/mesa/drivers/dri/common/megadriver_stub.c
@@ -162,5 +162,5 @@ __DRIconfig **stub_error_init_screen(__DRIscreen *psp)
* never be used.
*/
const struct __DriverAPIRec driDriverAPI = {
- .InitScreen = stub_error_init_screen,
+ /*.InitScreen = */stub_error_init_screen,
};
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
index 58d0e0656..b129979d2 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
+++ b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
@@ -99,7 +99,11 @@ static const char *__getProgramName () {
# define GET_PROGRAM_NAME() __getProgramName()
# else
# define GET_PROGRAM_NAME() ""
+# ifdef _MSC_VER
+# pragma message("Per application configuration won't work with your OS version.")
+# else
# warning "Per application configuration won't work with your OS version."
+# endif
# endif
#endif
@@ -284,6 +288,29 @@ static float strToF (const XML_Char *string, const XML_Char **tail) {
return result;
}
+#if !defined(HAVE_STRNDUP)
+
+/* Emulates glibc's strndup() */
+char *
+strndup(const char *str, size_t size)
+{
+ size_t len;
+ char *result = (char *)NULL;
+
+ if ((char *)NULL == str) return (char *)NULL;
+
+ len = strlen(str);
+ if (!len) return strdup("");
+ if (size > len) size = len;
+
+ result = (char *)malloc((size + 1) * sizeof (char));
+ memcpy(result, str, size);
+ result[size] = 0x0;
+ return result;
+}
+
+#endif /* _WIN32 should be !HAVE_STRNDUP */
+
/** \brief Parse a value of a given type. */
static unsigned char parseValue (driOptionValue *v, driOptionType type,
const XML_Char *string) {
@@ -443,11 +470,11 @@ __driUtilMessage(const char *f, ...)
(int) XML_GetCurrentLineNumber(data->parser), \
(int) XML_GetCurrentColumnNumber(data->parser)); \
} while (0)
-#define XML_WARNING(msg,args...) do { \
+#define XML_WARNING(msg, ...) do { \
__driUtilMessage ("Warning in %s line %d, column %d: "msg, data->name, \
(int) XML_GetCurrentLineNumber(data->parser), \
(int) XML_GetCurrentColumnNumber(data->parser), \
- args); \
+ __VA_ARGS__); \
} while (0)
/** \brief Output an error message. */
#define XML_ERROR1(msg) do { \
@@ -455,11 +482,11 @@ __driUtilMessage(const char *f, ...)
(int) XML_GetCurrentLineNumber(data->parser), \
(int) XML_GetCurrentColumnNumber(data->parser)); \
} while (0)
-#define XML_ERROR(msg,args...) do { \
+#define XML_ERROR(msg, ...) do { \
__driUtilMessage ("Error in %s line %d, column %d: "msg, data->name, \
(int) XML_GetCurrentLineNumber(data->parser), \
(int) XML_GetCurrentColumnNumber(data->parser), \
- args); \
+ __VA_ARGS__); \
} while (0)
/** \brief Output a fatal error message and abort. */
#define XML_FATAL1(msg) do { \
@@ -469,12 +496,12 @@ __driUtilMessage(const char *f, ...)
(int) XML_GetCurrentColumnNumber(data->parser)); \
abort();\
} while (0)
-#define XML_FATAL(msg,args...) do { \
+#define XML_FATAL(msg, ...) do { \
fprintf (stderr, "Fatal error in %s line %d, column %d: "msg"\n", \
data->name, \
(int) XML_GetCurrentLineNumber(data->parser), \
(int) XML_GetCurrentColumnNumber(data->parser), \
- args); \
+ __VA_ARGS__); \
abort();\
} while (0)
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlconfig.h b/mesalib/src/mesa/drivers/dri/common/xmlconfig.h
index af0323485..59a67b328 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlconfig.h
+++ b/mesalib/src/mesa/drivers/dri/common/xmlconfig.h
@@ -58,7 +58,7 @@ typedef struct driOptionInfo {
char *name; /**< \brief Name */
driOptionType type; /**< \brief Type */
driOptionRange *ranges; /**< \brief Array of ranges */
- uint nRanges; /**< \brief Number of ranges */
+ unsigned int nRanges; /**< \brief Number of ranges */
} driOptionInfo;
/** \brief Option cache
@@ -76,7 +76,7 @@ typedef struct driOptionCache {
* \li Default values in screen
* \li Actual values in contexts
*/
- uint tableSize;
+ unsigned int tableSize;
/**< \brief Size of the arrays
*
* In the current implementation it's not actually a size but log2(size).
diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
index 888138115..b9a5d71ef 100644
--- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c
+++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
@@ -32,6 +32,11 @@
* The back-buffer is allocated by the driver and is private.
*/
+#ifdef _MSC_VER
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
#include "main/api_exec.h"
#include "main/context.h"
#include "main/extensions.h"
@@ -59,7 +64,7 @@
#include "swrast_priv.h"
#include "swrast/s_context.h"
-const __DRIextension **__driDriverGetExtensions_swrast(void);
+PUBLIC const __DRIextension **__driDriverGetExtensions_swrast(void);
/**
* Screen and config-related functions
@@ -77,7 +82,7 @@ static void swrastSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
uint32_t internalFormat;
mesa_format texFormat;
- dri_ctx = pDRICtx->driverPrivate;
+ dri_ctx = (struct dri_context *)pDRICtx->driverPrivate;
internalFormat = (texture_format == __DRI_TEXTURE_FORMAT_RGB ? 3 : 4);
@@ -175,7 +180,7 @@ swrastFillInModes(__DRIscreen *psp,
format = MESA_FORMAT_B8G8R8A8_UNORM;
break;
default:
- fprintf(stderr, "[%s:%u] bad depth %d\n", __func__, __LINE__,
+ fprintf(stderr, "[%s:%u] bad depth %d\n", __FUNCTION__, __LINE__,
pixel_bits);
return NULL;
}
@@ -186,7 +191,7 @@ swrastFillInModes(__DRIscreen *psp,
back_buffer_factor, msaa_samples_array, 1,
GL_TRUE);
if (configs == NULL) {
- fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
+ fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __FUNCTION__,
__LINE__);
return NULL;
}
@@ -310,7 +315,7 @@ swrast_alloc_back_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
swrast_alloc_front_storage(ctx, rb, internalFormat, width, height);
- xrb->Base.Buffer = malloc(height * xrb->pitch);
+ xrb->Base.Buffer = (GLubyte*)malloc(height * xrb->pitch);
return GL_TRUE;
}
@@ -319,7 +324,7 @@ static struct dri_swrast_renderbuffer *
swrast_new_renderbuffer(const struct gl_config *visual, __DRIdrawable *dPriv,
GLboolean front)
{
- struct dri_swrast_renderbuffer *xrb = calloc(1, sizeof *xrb);
+ struct dri_swrast_renderbuffer *xrb = (struct dri_swrast_renderbuffer *)calloc(1, sizeof *xrb);
struct gl_renderbuffer *rb;
GLuint pixel_format;
@@ -400,7 +405,7 @@ swrast_map_renderbuffer(struct gl_context *ctx,
xrb->map_h = h;
stride = w * cpp;
- xrb->Base.Buffer = malloc(h * stride);
+ xrb->Base.Buffer = (GLubyte*)malloc(h * stride);
sPriv->swrast_loader->getImage(dPriv, x, rb->Height - y - h, w, h,
(char *) xrb->Base.Buffer,
@@ -469,7 +474,7 @@ dri_create_buffer(__DRIscreen * sPriv,
dPriv->driverPrivate = drawable;
drawable->dPriv = dPriv;
- drawable->row = malloc(SWRAST_MAX_WIDTH * 4);
+ drawable->row = (char*)malloc(SWRAST_MAX_WIDTH * 4);
if (drawable->row == NULL)
goto drawable_fail;
@@ -853,21 +858,23 @@ dri_copy_sub_buffer(__DRIdrawable *dPriv, int x, int y,
static const struct __DriverAPIRec swrast_driver_api = {
- .InitScreen = dri_init_screen,
- .DestroyScreen = dri_destroy_screen,
- .CreateContext = dri_create_context,
- .DestroyContext = dri_destroy_context,
- .CreateBuffer = dri_create_buffer,
- .DestroyBuffer = dri_destroy_buffer,
- .SwapBuffers = dri_swap_buffers,
- .MakeCurrent = dri_make_current,
- .UnbindContext = dri_unbind_context,
- .CopySubBuffer = dri_copy_sub_buffer,
+ /*.InitScreen = */dri_init_screen,
+ /*.DestroyScreen = */dri_destroy_screen,
+ /*.CreateContext = */dri_create_context,
+ /*.DestroyContext = */dri_destroy_context,
+ /*.CreateBuffer = */dri_create_buffer,
+ /*.DestroyBuffer = */dri_destroy_buffer,
+ /*.SwapBuffers = */dri_swap_buffers,
+ /*.MakeCurrent = */dri_make_current,
+ /*.UnbindContext = */dri_unbind_context,
+ /*.CopySubBuffer = */dri_copy_sub_buffer,
+ /*.AllocateBuffer = */NULL,
+ /*.ReleaseBuffer = */NULL
};
static const struct __DRIDriverVtableExtensionRec swrast_vtable = {
- .base = { __DRI_DRIVER_VTABLE, 1 },
- .vtable = &swrast_driver_api,
+ /*.base = */{ __DRI_DRIVER_VTABLE, 1 },
+ /*.vtable = */&swrast_driver_api,
};
static const __DRIextension *swrast_driver_extensions[] = {
diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h b/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h
index 535f6fe59..339e4502f 100644
--- a/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h
+++ b/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h
@@ -33,6 +33,13 @@
#include "dri_util.h"
#include "swrast/s_context.h"
+#ifdef _MSC_VER
+#ifdef PUBLIC
+#undef PUBLIC
+#endif
+#define PUBLIC __declspec(dllexport)
+#endif
+
/**
* Debugging