Commit 1587cb78 authored by Xiang, Haihao's avatar Xiang, Haihao

i965_drv_vidoe: thread safety for rendering

parent db1a88d1
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
SUBDIRS = shaders SUBDIRS = shaders
AM_CFLAGS = -Wall -I$(top_srcdir) -I$(top_srcdir)/va -I$(top_srcdir)/va/x11 @DRM_CFLAGS@ AM_CFLAGS = -Wall -I$(top_srcdir) -I$(top_srcdir)/va -I$(top_srcdir)/va/x11 -DPTHREADS @DRM_CFLAGS@
i965_drv_video_la_LTLIBRARIES = i965_drv_video.la i965_drv_video_la_LTLIBRARIES = i965_drv_video.la
i965_drv_video_ladir = @LIBVA_DRIVERS_PATH@ i965_drv_video_ladir = @LIBVA_DRIVERS_PATH@
...@@ -69,4 +69,6 @@ noinst_HEADERS = \ ...@@ -69,4 +69,6 @@ noinst_HEADERS = \
gen6_mfd.h \ gen6_mfd.h \
i965_encoder.h \ i965_encoder.h \
gen6_vme.h \ gen6_vme.h \
gen6_mfc.h gen6_mfc.h \
intel_compiler.h \
i965_mutext.h
...@@ -1649,6 +1649,7 @@ i965_Init(VADriverContextP ctx) ...@@ -1649,6 +1649,7 @@ i965_Init(VADriverContextP ctx)
if (i965_render_init(ctx) == False) if (i965_render_init(ctx) == False)
return VA_STATUS_ERROR_UNKNOWN; return VA_STATUS_ERROR_UNKNOWN;
_i965InitMutex(&i965->render_mutex);
i965->batch = intel_batchbuffer_new(&i965->intel, I915_EXEC_RENDER); i965->batch = intel_batchbuffer_new(&i965->intel, I915_EXEC_RENDER);
return VA_STATUS_SUCCESS; return VA_STATUS_SUCCESS;
...@@ -2228,6 +2229,8 @@ i965_PutSurface(VADriverContextP ctx, ...@@ -2228,6 +2229,8 @@ i965_PutSurface(VADriverContextP ctx,
if (!obj_surface || !obj_surface->bo) if (!obj_surface || !obj_surface->bo)
return VA_STATUS_SUCCESS; return VA_STATUS_SUCCESS;
_i965LockMutex(&i965->render_mutex);
dri_drawable = dri_get_drawable(ctx, (Drawable)draw); dri_drawable = dri_get_drawable(ctx, (Drawable)draw);
assert(dri_drawable); assert(dri_drawable);
...@@ -2295,6 +2298,8 @@ i965_PutSurface(VADriverContextP ctx, ...@@ -2295,6 +2298,8 @@ i965_PutSurface(VADriverContextP ctx,
obj_surface->free_private_data(&obj_surface->private_data); obj_surface->free_private_data(&obj_surface->private_data);
} }
_i965UnlockMutex(&i965->render_mutex);
return VA_STATUS_SUCCESS; return VA_STATUS_SUCCESS;
} }
...@@ -2306,6 +2311,8 @@ i965_Terminate(VADriverContextP ctx) ...@@ -2306,6 +2311,8 @@ i965_Terminate(VADriverContextP ctx)
if (i965->batch) if (i965->batch)
intel_batchbuffer_free(i965->batch); intel_batchbuffer_free(i965->batch);
_i965DestroyMutex(&i965->render_mutex);
if (i965_render_terminate(ctx) == False) if (i965_render_terminate(ctx) == False)
return VA_STATUS_ERROR_UNKNOWN; return VA_STATUS_ERROR_UNKNOWN;
......
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
#include <va/va.h> #include <va/va.h>
#include <va/va_backend.h> #include <va/va_backend.h>
#include "i965_mutext.h"
#include "object_heap.h" #include "object_heap.h"
#include "intel_driver.h" #include "intel_driver.h"
#define I965_MAX_PROFILES 11 #define I965_MAX_PROFILES 11
...@@ -217,6 +217,7 @@ struct i965_driver_data ...@@ -217,6 +217,7 @@ struct i965_driver_data
struct object_heap subpic_heap; struct object_heap subpic_heap;
struct hw_codec_info *codec_info; struct hw_codec_info *codec_info;
_I965Mutex render_mutex;
struct intel_batchbuffer *batch; struct intel_batchbuffer *batch;
struct i965_render_state render_state; struct i965_render_state render_state;
void *pp_context; void *pp_context;
......
#ifndef _I965_MUTEX_H_
#define _I965_MUTEX_H_
#include "intel_compiler.h"
#if defined PTHREADS
#include <pthread.h>
typedef pthread_mutex_t _I965Mutex;
static INLINE void _i965InitMutex(_I965Mutex *m)
{
pthread_mutex_init(m, NULL);
}
static INLINE void
_i965DestroyMutex(_I965Mutex *m)
{
pthread_mutex_destroy(m);
}
static INLINE void
_i965LockMutex(_I965Mutex *m)
{
pthread_mutex_lock(m);
}
static INLINE void
_i965UnlockMutex(_I965Mutex *m)
{
pthread_mutex_unlock(m);
}
#define _I965_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#define _I965_DECLARE_MUTEX(m) \
_I965Mutex m = _I965_MUTEX_INITIALIZER
#else
typedef int _I965Mutex;
static INLINE void _i965InitMutex(_I965Mutex *m) { (void) m; }
static INLINE void _i965DestroyMutex(_I965Mutex *m) { (void) m; }
static INLINE void _i965LockMutex(_I965Mutex *m) { (void) m; }
static INLINE void _i965UnlockMutex(_I965Mutex *m) { (void) m; }
#define _I965_MUTEX_INITIALIZER 0
#define _I965_DECLARE_MUTEX(m) \
_I965Mutex m = _I965_MUTEX_INITIALIZER
#endif
#endif /* _I965_MUTEX_H_ */
#ifndef _INTEL_COMPILER_H_
#define _INTEL_COMPILER_H_
/**
* Function inlining
*/
#if defined(__GNUC__)
# define INLINE __inline__
#elif (__STDC_VERSION__ >= 199901L) /* C99 */
# define INLINE inline
#else
# define INLINE
#endif
#endif /* _INTEL_COMPILER_H_ */
...@@ -11,11 +11,7 @@ ...@@ -11,11 +11,7 @@
#include <va/va_backend.h> #include <va/va_backend.h>
#if defined(__GNUC__) #include "intel_compiler.h"
#define INLINE __inline__
#else
#define INLINE
#endif
#define BATCH_SIZE 0x80000 #define BATCH_SIZE 0x80000
#define BATCH_RESERVED 0x10 #define BATCH_RESERVED 0x10
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment