mesa: fix glthread marshal build issues on platforms without PTHREAD

This commit is contained in:
Timothy Arceri
2017-03-16 15:28:47 +11:00
parent 643b0fd7e9
commit 4a32d473fd
4 changed files with 68 additions and 30 deletions

View File

@@ -68,6 +68,8 @@ class PrintCode(gl_XML.gl_print_base):
print header
print '#include <X11/Xlib-xcb.h>'
print
print '#ifdef HAVE_PTHREAD'
print
print 'static _X_INLINE int safe_mul(int a, int b)'
print '{'
print ' if (a < 0 || b < 0) return -1;'
@@ -78,7 +80,8 @@ class PrintCode(gl_XML.gl_print_base):
print
def printRealFooter(self):
pass
print
print '#endif'
def print_sync_call(self, func):
call = 'CALL_{0}(ctx->CurrentServerDispatch, ({1}))'.format(

View File

@@ -24,18 +24,19 @@
#ifndef _GLTHREAD_H
#define _GLTHREAD_H
#include "main/mtypes.h"
/* Command size is a number of bytes stored in a short. */
#define MARSHAL_MAX_CMD_SIZE 65535
#ifdef HAVE_PTHREAD
#include <inttypes.h>
#include <stdbool.h>
#include <pthread.h>
#include "main/mtypes.h"
enum marshal_dispatch_cmd_id;
/* Command size is a number of bytes stored in a short. */
#define MARSHAL_MAX_CMD_SIZE 65535
struct glthread_state
{
/** The worker thread that asynchronously processes our GL commands. */
@@ -145,5 +146,10 @@ _mesa_glthread_restore_dispatch(struct gl_context *ctx)
{
}
static inline void
_mesa_glthread_flush_batch(struct gl_context *ctx)
{
}
#endif /* !HAVE_PTHREAD */
#endif /* _GLTHREAD_H*/

View File

@@ -31,6 +31,8 @@
#include "dispatch.h"
#include "marshal_generated.h"
#ifdef HAVE_PTHREAD
struct marshal_cmd_Flush
{
struct marshal_cmd_base cmd_base;
@@ -257,3 +259,4 @@ _mesa_marshal_BindBuffer(GLenum target, GLuint buffer)
}
}
#endif

View File

@@ -46,6 +46,7 @@ struct marshal_cmd_base
uint16_t cmd_size;
};
#ifdef HAVE_PTHREAD
static inline void *
_mesa_glthread_allocate_command(struct gl_context *ctx,
@@ -66,6 +67,56 @@ _mesa_glthread_allocate_command(struct gl_context *ctx,
return cmd_base;
}
/**
* Instead of conditionally handling marshaling previously-bound user vertex
* array data in draw calls (deprecated and removed in GL core), we just
* disable threading at the point where the user sets a user vertex array.
*/
static inline bool
_mesa_glthread_is_non_vbo_vertex_attrib_pointer(const struct gl_context *ctx)
{
struct glthread_state *glthread = ctx->GLThread;
return ctx->API != API_OPENGL_CORE && !glthread->vertex_array_is_vbo;
}
/**
* Instead of conditionally handling marshaling immediate index data in draw
* calls (deprecated and removed in GL core), we just disable threading.
*/
static inline bool
_mesa_glthread_is_non_vbo_draw_elements(const struct gl_context *ctx)
{
struct glthread_state *glthread = ctx->GLThread;
return ctx->API != API_OPENGL_CORE && !glthread->element_array_is_vbo;
}
#else
/* FIXME: dummy functions for non PTHREAD platforms */
static inline void *
_mesa_glthread_allocate_command(struct gl_context *ctx,
uint16_t cmd_id,
size_t size)
{
return NULL;
}
static inline bool
_mesa_glthread_is_non_vbo_vertex_attrib_pointer(const struct gl_context *ctx)
{
return false;
}
static inline bool
_mesa_glthread_is_non_vbo_draw_elements(const struct gl_context *ctx)
{
return false;
}
#endif
#define DEBUG_MARSHAL_PRINT_CALLS 0
static inline void
@@ -133,31 +184,6 @@ _mesa_glthread_is_compat_bind_vertex_array(const struct gl_context *ctx)
return ctx->API != API_OPENGL_CORE;
}
/**
* Instead of conditionally handling marshaling previously-bound user vertex
* array data in draw calls (deprecated and removed in GL core), we just
* disable threading at the point where the user sets a user vertex array.
*/
static inline bool
_mesa_glthread_is_non_vbo_vertex_attrib_pointer(const struct gl_context *ctx)
{
struct glthread_state *glthread = ctx->GLThread;
return ctx->API != API_OPENGL_CORE && !glthread->vertex_array_is_vbo;
}
/**
* Instead of conditionally handling marshaling immediate index data in draw
* calls (deprecated and removed in GL core), we just disable threading.
*/
static inline bool
_mesa_glthread_is_non_vbo_draw_elements(const struct gl_context *ctx)
{
struct glthread_state *glthread = ctx->GLThread;
return ctx->API != API_OPENGL_CORE && !glthread->element_array_is_vbo;
}
struct marshal_cmd_ShaderSource;
struct marshal_cmd_Flush;
struct marshal_cmd_BindBuffer;