[Mesa-dev] [PATCH 02/11] mesa/glthread: remove HAVE_PTHREAD guards
Marek Olšák
maraeo at gmail.com
Thu Jun 22 01:02:57 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
we are switching to util_queue.
---
src/mapi/glapi/gen/gl_marshal.py | 5 +----
src/mesa/main/glthread.c | 4 ----
src/mesa/main/glthread.h | 30 ------------------------------
src/mesa/main/marshal.c | 4 ----
src/mesa/main/marshal.h | 27 ---------------------------
5 files changed, 1 insertion(+), 69 deletions(-)
diff --git a/src/mapi/glapi/gen/gl_marshal.py b/src/mapi/glapi/gen/gl_marshal.py
index f52b9b7..062afe5 100644
--- a/src/mapi/glapi/gen/gl_marshal.py
+++ b/src/mapi/glapi/gen/gl_marshal.py
@@ -59,34 +59,31 @@ def indent(delta = 3):
class PrintCode(gl_XML.gl_print_base):
def __init__(self):
super(PrintCode, self).__init__()
self.name = 'gl_marshal.py'
self.license = license.bsd_license_template % (
'Copyright (C) 2012 Intel Corporation', 'INTEL CORPORATION')
def printRealHeader(self):
print header
- print '#ifdef HAVE_PTHREAD'
- print
print 'static inline int safe_mul(int a, int b)'
print '{'
print ' if (a < 0 || b < 0) return -1;'
print ' if (a == 0 || b == 0) return 0;'
print ' if (a > INT_MAX / b) return -1;'
print ' return a * b;'
print '}'
print
def printRealFooter(self):
- print
- print '#endif'
+ pass
def print_sync_call(self, func):
call = 'CALL_{0}(ctx->CurrentServerDispatch, ({1}))'.format(
func.name, func.get_called_parameter_string())
if func.return_type == 'void':
out('{0};'.format(call))
else:
out('return {0};'.format(call))
def print_sync_dispatch(self, func):
diff --git a/src/mesa/main/glthread.c b/src/mesa/main/glthread.c
index 455b829..e90709c 100644
--- a/src/mesa/main/glthread.c
+++ b/src/mesa/main/glthread.c
@@ -31,22 +31,20 @@
* quickly logs the GL commands to a buffer to be processed by a worker
* thread.
*/
#include "main/mtypes.h"
#include "main/glthread.h"
#include "main/marshal.h"
#include "main/marshal_generated.h"
#include "util/u_thread.h"
-#ifdef HAVE_PTHREAD
-
static void
glthread_allocate_batch(struct gl_context *ctx)
{
struct glthread_state *glthread = ctx->GLThread;
/* TODO: handle memory allocation failure. */
glthread->batch = malloc(sizeof(*glthread->batch));
if (!glthread->batch)
return;
memset(glthread->batch, 0, offsetof(struct glthread_batch, buffer));
@@ -277,12 +275,10 @@ _mesa_glthread_finish(struct gl_context *ctx)
_glapi_set_dispatch(dispatch);
}
} else {
_mesa_glthread_flush_batch_locked(ctx);
while (glthread->batch_queue || glthread->busy)
pthread_cond_wait(&glthread->work_done, &glthread->mutex);
}
pthread_mutex_unlock(&glthread->mutex);
}
-
-#endif
diff --git a/src/mesa/main/glthread.h b/src/mesa/main/glthread.h
index 50c1db2..07bed38 100644
--- a/src/mesa/main/glthread.h
+++ b/src/mesa/main/glthread.h
@@ -22,22 +22,20 @@
*/
#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>
enum marshal_dispatch_cmd_id;
struct glthread_state
{
/** The worker thread that asynchronously processes our GL commands. */
pthread_t thread;
@@ -117,39 +115,11 @@ struct glthread_batch
uint8_t buffer[MARSHAL_MAX_CMD_SIZE];
};
void _mesa_glthread_init(struct gl_context *ctx);
void _mesa_glthread_destroy(struct gl_context *ctx);
void _mesa_glthread_restore_dispatch(struct gl_context *ctx);
void _mesa_glthread_flush_batch(struct gl_context *ctx);
void _mesa_glthread_finish(struct gl_context *ctx);
-#else /* HAVE_PTHREAD */
-
-static inline void
-_mesa_glthread_init(struct gl_context *ctx)
-{
-}
-
-static inline void
-_mesa_glthread_destroy(struct gl_context *ctx)
-{
-}
-
-static inline void
-_mesa_glthread_finish(struct gl_context *ctx)
-{
-}
-
-static inline void
-_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*/
diff --git a/src/mesa/main/marshal.c b/src/mesa/main/marshal.c
index ae4efb5..4840f32 100644
--- a/src/mesa/main/marshal.c
+++ b/src/mesa/main/marshal.c
@@ -26,22 +26,20 @@
* Custom functions for marshalling GL calls from the main thread to a worker
* thread when automatic code generation isn't appropriate.
*/
#include "main/enums.h"
#include "main/macros.h"
#include "marshal.h"
#include "dispatch.h"
#include "marshal_generated.h"
-#ifdef HAVE_PTHREAD
-
struct marshal_cmd_Flush
{
struct marshal_cmd_base cmd_base;
};
void
_mesa_unmarshal_Flush(struct gl_context *ctx,
const struct marshal_cmd_Flush *cmd)
{
@@ -474,12 +472,10 @@ _mesa_marshal_ClearBufferfv(GLenum buffer, GLint drawbuffer,
*variable_data = *value;
_mesa_post_marshal_hook(ctx);
} else {
debug_print_sync("ClearBufferfv");
_mesa_glthread_finish(ctx);
CALL_ClearBufferfv(ctx->CurrentServerDispatch,
(buffer, drawbuffer, value));
}
}
-
-#endif
diff --git a/src/mesa/main/marshal.h b/src/mesa/main/marshal.h
index 4842d27..e9ecaf9 100644
--- a/src/mesa/main/marshal.h
+++ b/src/mesa/main/marshal.h
@@ -40,22 +40,20 @@ struct marshal_cmd_base
* Type of command. See enum marshal_dispatch_cmd_id.
*/
uint16_t cmd_id;
/**
* Size of command, in multiples of 4 bytes, including cmd_base.
*/
uint16_t cmd_size;
};
-#ifdef HAVE_PTHREAD
-
static inline void *
_mesa_glthread_allocate_command(struct gl_context *ctx,
uint16_t cmd_id,
size_t size)
{
struct glthread_state *glthread = ctx->GLThread;
struct marshal_cmd_base *cmd_base;
const size_t aligned_size = ALIGN(size, 8);
if (unlikely(glthread->batch->used + size > MARSHAL_MAX_CMD_SIZE))
@@ -87,45 +85,20 @@ _mesa_glthread_is_non_vbo_vertex_attrib_pointer(const struct gl_context *ctx)
* 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
/**
* This is printed when we have fallen back to a sync. This can happen when
* MARSHAL_MAX_CMD_SIZE is exceeded.
*/
static inline void
debug_print_sync_fallback(const char *func)
{
#if DEBUG_MARSHAL_PRINT_CALLS
--
2.7.4
More information about the mesa-dev
mailing list