summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/intel
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2008-05-02 14:11:19 -0700
committerEric Anholt <eric@anholt.net>2008-05-02 14:11:19 -0700
commiteb10cdc838fc31ea2cf59f556f6f7d8b072f5bae (patch)
tree828e7a4bc08bb1565f2f9f0b0669e8f458ac80d1 /src/mesa/drivers/dri/intel
parent89bba44e969f15bf20da6d700c493237b095a588 (diff)
[intel] Fix build for GEM. TTM is now disabled, and fencing is gone.
Fencing was used in two places: ensuring that we didn't get too many frames ahead of ourselves, and glFinish. glFinish will be satisfied by waiting on buffers like we would do for CPU access on them. The "don't get too far ahead" is now the responsibility of the execution manager (kernel).
Diffstat (limited to 'src/mesa/drivers/dri/intel')
-rw-r--r--src/mesa/drivers/dri/intel/intel_batchbuffer.c28
-rw-r--r--src/mesa/drivers/dri/intel/intel_batchbuffer.h3
-rw-r--r--src/mesa/drivers/dri/intel/intel_blit.c13
-rw-r--r--src/mesa/drivers/dri/intel/intel_bufmgr_gem.c69
-rw-r--r--src/mesa/drivers/dri/intel/intel_bufmgr_gem.h7
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.c56
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.h3
-rw-r--r--src/mesa/drivers/dri/intel/intel_ioctl.c19
-rw-r--r--src/mesa/drivers/dri/intel/intel_ioctl.h3
-rw-r--r--src/mesa/drivers/dri/intel/intel_regions.c6
-rw-r--r--src/mesa/drivers/dri/intel/intel_screen.c2
11 files changed, 41 insertions, 168 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
index c5b0f531d4..683d06a552 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
@@ -99,7 +99,6 @@ intel_batchbuffer_alloc(struct intel_context *intel)
struct intel_batchbuffer *batch = calloc(sizeof(*batch), 1);
batch->intel = intel;
- batch->last_fence = NULL;
intel_batchbuffer_reset(batch);
return batch;
@@ -108,11 +107,6 @@ intel_batchbuffer_alloc(struct intel_context *intel)
void
intel_batchbuffer_free(struct intel_batchbuffer *batch)
{
- if (batch->last_fence) {
- dri_fence_wait(batch->last_fence);
- dri_fence_unreference(batch->last_fence);
- batch->last_fence = NULL;
- }
if (batch->map) {
dri_bo_unmap(batch->buf);
batch->map = NULL;
@@ -152,7 +146,7 @@ do_flush_locked(struct intel_batchbuffer *batch,
used,
batch->cliprect_mode != LOOP_CLIPRECTS,
allow_unlock,
- execbuf, &batch->last_fence);
+ execbuf);
} else {
dri_process_relocs(batch->buf);
intel_batch_ioctl(batch->intel,
@@ -162,8 +156,8 @@ do_flush_locked(struct intel_batchbuffer *batch,
allow_unlock);
}
}
-
- dri_post_submit(batch->buf, &batch->last_fence);
+
+ dri_post_submit(batch->buf);
if (intel->numClipRects == 0 &&
batch->cliprect_mode == LOOP_CLIPRECTS) {
@@ -243,9 +237,13 @@ _intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file,
UNLOCK_HARDWARE(intel);
if (INTEL_DEBUG & DEBUG_SYNC) {
+ int irq;
+
fprintf(stderr, "waiting for idle\n");
- if (batch->last_fence != NULL)
- dri_fence_wait(batch->last_fence);
+ LOCK_HARDWARE(intel);
+ irq = intelEmitIrqLocked(intel);
+ UNLOCK_HARDWARE(intel);
+ intelWaitIrq(intel, irq);
}
/* Reset the buffer:
@@ -253,14 +251,6 @@ _intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file,
intel_batchbuffer_reset(batch);
}
-void
-intel_batchbuffer_finish(struct intel_batchbuffer *batch)
-{
- intel_batchbuffer_flush(batch);
- if (batch->last_fence != NULL)
- dri_fence_wait(batch->last_fence);
-}
-
/* This is the only way buffers get added to the validate list.
*/
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.h b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
index 2d636df2ce..feddfb46df 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.h
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
@@ -40,7 +40,6 @@ struct intel_batchbuffer
struct intel_context *intel;
dri_bo *buf;
- dri_fence *last_fence;
GLubyte *map;
GLubyte *ptr;
@@ -58,8 +57,6 @@ struct intel_batchbuffer *intel_batchbuffer_alloc(struct intel_context
void intel_batchbuffer_free(struct intel_batchbuffer *batch);
-void intel_batchbuffer_finish(struct intel_batchbuffer *batch);
-
void _intel_batchbuffer_flush(struct intel_batchbuffer *batch,
const char *file, int line);
diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c
index 4890826a19..b7d36d8cd6 100644
--- a/src/mesa/drivers/dri/intel/intel_blit.c
+++ b/src/mesa/drivers/dri/intel/intel_blit.c
@@ -66,14 +66,6 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv,
intelScreen = intel->intelScreen;
- if (intel->last_swap_fence) {
- dri_fence_wait(intel->last_swap_fence);
- dri_fence_unreference(intel->last_swap_fence);
- intel->last_swap_fence = NULL;
- }
- intel->last_swap_fence = intel->first_swap_fence;
- intel->first_swap_fence = NULL;
-
/* The LOCK_HARDWARE is required for the cliprects. Buffer offsets
* should work regardless.
*/
@@ -163,12 +155,7 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv,
ADVANCE_BATCH();
}
- if (intel->first_swap_fence)
- dri_fence_unreference(intel->first_swap_fence);
intel_batchbuffer_flush(intel->batch);
- intel->first_swap_fence = intel->batch->last_fence;
- if (intel->first_swap_fence)
- dri_fence_reference(intel->first_swap_fence);
}
UNLOCK_HARDWARE(intel);
diff --git a/src/mesa/drivers/dri/intel/intel_bufmgr_gem.c b/src/mesa/drivers/dri/intel/intel_bufmgr_gem.c
index 2d8dced214..07f782ca3a 100644
--- a/src/mesa/drivers/dri/intel/intel_bufmgr_gem.c
+++ b/src/mesa/drivers/dri/intel/intel_bufmgr_gem.c
@@ -127,15 +127,6 @@ typedef struct _dri_bo_gem {
void *virtual;
} dri_bo_gem;
-typedef struct _dri_fence_gem
-{
- dri_fence fence;
-
- int refcount;
- const char *name;
- drmFence drm_fence;
-} dri_fence_gem;
-
static int
logbase2(int n)
{
@@ -527,58 +518,6 @@ dri_gem_bo_unmap(dri_bo *bo)
}
static void
-dri_gem_fence_reference(dri_fence *fence)
-{
- dri_fence_gem *fence_gem = (dri_fence_gem *)fence;
- dri_bufmgr_gem *bufmgr_gem = (dri_bufmgr_gem *)fence->bufmgr;
-
- ++fence_gem->refcount;
- DBG("fence_reference: %p (%s)\n", &fence_gem->fence, fence_gem->name);
-}
-
-static void
-dri_gem_fence_unreference(dri_fence *fence)
-{
- dri_fence_gem *fence_gem = (dri_fence_gem *)fence;
- dri_bufmgr_gem *bufmgr_gem = (dri_bufmgr_gem *)fence->bufmgr;
-
- if (!fence)
- return;
-
- DBG("fence_unreference: %p (%s)\n", &fence_gem->fence, fence_gem->name);
-
- if (--fence_gem->refcount == 0) {
- int ret;
-
- ret = drmFenceUnreference(bufmgr_gem->fd, &fence_gem->drm_fence);
- if (ret != 0) {
- fprintf(stderr, "drmFenceUnreference failed (%s): %s\n",
- fence_gem->name, strerror(-ret));
- }
-
- free(fence);
- return;
- }
-}
-
-static void
-dri_gem_fence_wait(dri_fence *fence)
-{
- dri_fence_gem *fence_gem = (dri_fence_gem *)fence;
- dri_bufmgr_gem *bufmgr_gem = (dri_bufmgr_gem *)fence->bufmgr;
- int ret;
-
- ret = drmFenceWait(bufmgr_gem->fd, DRM_FENCE_FLAG_WAIT_LAZY, &fence_gem->drm_fence, 0);
- if (ret != 0) {
- fprintf(stderr, "%s:%d: Error waiting for fence %s: %s.\n",
- __FILE__, __LINE__, fence_gem->name, strerror(-ret));
- abort();
- }
-
- DBG("fence_wait: %p (%s)\n", &fence_gem->fence, fence_gem->name);
-}
-
-static void
dri_bufmgr_gem_destroy(dri_bufmgr *bufmgr)
{
dri_bufmgr_gem *bufmgr_gem = (dri_bufmgr_gem *)bufmgr;
@@ -717,7 +656,7 @@ intel_update_buffer_offsets (dri_bufmgr_gem *bufmgr_gem)
}
static void
-dri_gem_post_submit(dri_bo *batch_buf, dri_fence **last_fence)
+dri_gem_post_submit(dri_bo *batch_buf)
{
dri_bufmgr_gem *bufmgr_gem = (dri_bufmgr_gem *)batch_buf->bufmgr;
int i;
@@ -773,9 +712,6 @@ dri_gem_check_aperture_space(dri_bo *bo)
* and manage map buffer objections.
*
* \param fd File descriptor of the opened DRM device.
- * \param fence_type Driver-specific fence type used for fences with no flush.
- * \param fence_type_flush Driver-specific fence type used for fences with a
- * flush.
*/
dri_bufmgr *
intel_bufmgr_gem_init(int fd, int batch_size)
@@ -800,9 +736,6 @@ intel_bufmgr_gem_init(int fd, int batch_size)
bufmgr_gem->bufmgr.bo_unreference = dri_gem_bo_unreference;
bufmgr_gem->bufmgr.bo_map = dri_gem_bo_map;
bufmgr_gem->bufmgr.bo_unmap = dri_gem_bo_unmap;
- bufmgr_gem->bufmgr.fence_reference = dri_gem_fence_reference;
- bufmgr_gem->bufmgr.fence_unreference = dri_gem_fence_unreference;
- bufmgr_gem->bufmgr.fence_wait = dri_gem_fence_wait;
bufmgr_gem->bufmgr.destroy = dri_bufmgr_gem_destroy;
bufmgr_gem->bufmgr.emit_reloc = dri_gem_emit_reloc;
bufmgr_gem->bufmgr.process_relocs = dri_gem_process_reloc;
diff --git a/src/mesa/drivers/dri/intel/intel_bufmgr_gem.h b/src/mesa/drivers/dri/intel/intel_bufmgr_gem.h
index a28f5ae814..36caeba214 100644
--- a/src/mesa/drivers/dri/intel/intel_bufmgr_gem.h
+++ b/src/mesa/drivers/dri/intel/intel_bufmgr_gem.h
@@ -4,13 +4,10 @@
#include "dri_bufmgr.h"
-extern dri_bo *intel_gem_bo_create_from_handle(dri_bufmgr *bufmgr, const char *name,
+extern dri_bo *intel_gem_bo_create_from_handle(dri_bufmgr *bufmgr,
+ const char *name,
unsigned int handle);
-dri_fence *intel_gem_fence_create_from_arg(dri_bufmgr *bufmgr, const char *name,
- drm_fence_arg_t *arg);
-
-
dri_bufmgr *intel_bufmgr_gem_init(int fd, int batch_size);
void
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index 47e7d1afc2..4a1e1a9ac0 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -59,7 +59,7 @@
#include "intel_buffer_objects.h"
#include "intel_fbo.h"
#include "intel_decode.h"
-#include "intel_bufmgr_ttm.h"
+#include "intel_bufmgr_gem.h"
#include "drirenderbuffer.h"
#include "vblank.h"
@@ -368,12 +368,16 @@ intelFlush(GLcontext * ctx)
void
intelFinish(GLcontext * ctx)
{
- struct intel_context *intel = intel_context(ctx);
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ int i;
+
intelFlush(ctx);
- if (intel->batch->last_fence) {
- dri_fence_wait(intel->batch->last_fence);
- dri_fence_unreference(intel->batch->last_fence);
- intel->batch->last_fence = NULL;
+
+ for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
+ /* XXX: Wait on buffer idle */
+ }
+ if (fb->_DepthBuffer) {
+ /* XXX: Wait on buffer idle */
}
}
@@ -439,28 +443,25 @@ static GLboolean
intel_init_bufmgr(struct intel_context *intel)
{
intelScreenPrivate *intelScreen = intel->intelScreen;
- GLboolean ttm_disable = getenv("INTEL_NO_TTM") != NULL;
- GLboolean ttm_supported;
+ GLboolean gem_disable = getenv("INTEL_NO_GEM") != NULL;
+ GLboolean gem_supported;
- /* If we've got a new enough DDX that's initializing TTM and giving us
+ /* If we've got a new enough DDX that's initializing GEM and giving us
* object handles for the shared buffers, use that.
*/
intel->ttm = GL_FALSE;
if (intel->intelScreen->driScrnPriv->dri2.enabled)
- ttm_supported = GL_TRUE;
+ gem_supported = GL_TRUE;
else if (intel->intelScreen->driScrnPriv->ddx_version.minor >= 9 &&
intel->intelScreen->drmMinor >= 11 &&
intel->intelScreen->front.bo_handle != -1)
- ttm_supported = GL_TRUE;
+ gem_supported = GL_TRUE;
else
- ttm_supported = GL_FALSE;
+ gem_supported = GL_FALSE;
- if (!ttm_disable && ttm_supported) {
+ if (!gem_disable && gem_supported) {
int bo_reuse_mode;
- intel->bufmgr = intel_bufmgr_ttm_init(intel->driFd,
- DRM_FENCE_TYPE_EXE,
- DRM_FENCE_TYPE_EXE |
- DRM_I915_FENCE_TYPE_RW,
+ intel->bufmgr = intel_bufmgr_gem_init(intel->driFd,
BATCH_SZ);
if (intel->bufmgr != NULL)
intel->ttm = GL_TRUE;
@@ -470,16 +471,16 @@ intel_init_bufmgr(struct intel_context *intel)
case DRI_CONF_BO_REUSE_DISABLED:
break;
case DRI_CONF_BO_REUSE_ALL:
- intel_ttm_enable_bo_reuse(intel->bufmgr);
+ intel_gem_enable_bo_reuse(intel->bufmgr);
break;
}
}
/* Otherwise, use the classic buffer manager. */
if (intel->bufmgr == NULL) {
- if (ttm_disable) {
- fprintf(stderr, "TTM buffer manager disabled. Using classic.\n");
+ if (gem_disable) {
+ fprintf(stderr, "GEM disabled. Using classic.\n");
} else {
- fprintf(stderr, "Failed to initialize TTM buffer manager. "
+ fprintf(stderr, "Failed to initialize GEM. "
"Falling back to classic.\n");
}
@@ -663,8 +664,6 @@ intelInitContext(struct intel_context *intel,
intel_recreate_static_regions(intel);
intel->batch = intel_batchbuffer_alloc(intel);
- intel->last_swap_fence = NULL;
- intel->first_swap_fence = NULL;
intel_bufferobj_init(intel);
intel_fbo_init(intel);
@@ -718,17 +717,6 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv)
intel_batchbuffer_free(intel->batch);
- if (intel->last_swap_fence) {
- dri_fence_wait(intel->last_swap_fence);
- dri_fence_unreference(intel->last_swap_fence);
- intel->last_swap_fence = NULL;
- }
- if (intel->first_swap_fence) {
- dri_fence_wait(intel->first_swap_fence);
- dri_fence_unreference(intel->first_swap_fence);
- intel->first_swap_fence = NULL;
- }
-
if (release_texture_heaps) {
/* This share group is about to go away, free our private
* texture object data.
diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
index 1348b0adcf..35ef22aa27 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -174,9 +174,6 @@ struct intel_context
*/
GLboolean ttm;
- dri_fence *last_swap_fence;
- dri_fence *first_swap_fence;
-
struct intel_batchbuffer *batch;
GLboolean no_batch_wrap;
unsigned batch_id;
diff --git a/src/mesa/drivers/dri/intel/intel_ioctl.c b/src/mesa/drivers/dri/intel/intel_ioctl.c
index f9624a6abe..2f4caf9535 100644
--- a/src/mesa/drivers/dri/intel/intel_ioctl.c
+++ b/src/mesa/drivers/dri/intel/intel_ioctl.c
@@ -43,7 +43,7 @@
#include "drm.h"
#include "i915_drm.h"
-#include "intel_bufmgr_ttm.h"
+#include "intel_bufmgr_gem.h"
#define FILE_DEBUG_FLAG DEBUG_IOCTL
@@ -151,10 +151,8 @@ void
intel_exec_ioctl(struct intel_context *intel,
GLuint used,
GLboolean ignore_cliprects, GLboolean allow_unlock,
- struct drm_i915_gem_execbuffer *execbuf,
- dri_fence **fence)
+ struct drm_i915_gem_execbuffer *execbuf)
{
- dri_fence *fo;
int ret;
assert(intel->locked);
@@ -163,10 +161,6 @@ intel_exec_ioctl(struct intel_context *intel,
if (intel->no_hw)
return;
- if (*fence) {
- dri_fence_unreference(*fence);
- }
-
memset(&execbuf, 0, sizeof(execbuf));
execbuf->batch_start_offset = 0;
@@ -187,13 +181,4 @@ intel_exec_ioctl(struct intel_context *intel,
UNLOCK_HARDWARE(intel);
exit(1);
}
-
- fo = intel_ttm_fence_create_from_arg(intel->bufmgr, "fence buffers",
- &execbuf.fence_arg);
- if (!fo) {
- fprintf(stderr, "failed to fence handle: %08x\n", execbuf.fence_arg.handle);
- UNLOCK_HARDWARE(intel);
- exit(1);
- }
- *fence = fo;
}
diff --git a/src/mesa/drivers/dri/intel/intel_ioctl.h b/src/mesa/drivers/dri/intel/intel_ioctl.h
index 7691a27f92..52b0ab6102 100644
--- a/src/mesa/drivers/dri/intel/intel_ioctl.h
+++ b/src/mesa/drivers/dri/intel/intel_ioctl.h
@@ -41,7 +41,6 @@ void intel_batch_ioctl( struct intel_context *intel,
void intel_exec_ioctl(struct intel_context *intel,
GLuint used,
GLboolean ignore_cliprects, GLboolean allow_unlock,
- struct drm_i915_gem_execbuffer *execbuf,
- dri_fence **fence);
+ struct drm_i915_gem_execbuffer *execbuf);
#endif
diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c
index 8bc548913f..7d78e4eca7 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.c
+++ b/src/mesa/drivers/dri/intel/intel_regions.c
@@ -44,7 +44,7 @@
#include "intel_blit.h"
#include "intel_buffer_objects.h"
#include "dri_bufmgr.h"
-#include "intel_bufmgr_ttm.h"
+#include "intel_bufmgr_gem.h"
#include "intel_batchbuffer.h"
#define FILE_DEBUG_FLAG DEBUG_REGION
@@ -121,7 +121,7 @@ intel_region_alloc_for_handle(struct intel_context *intel,
{
dri_bo *buffer;
- buffer = intel_ttm_bo_create_from_handle(intel->bufmgr, "region", handle);
+ buffer = intel_gem_bo_create_from_handle(intel->bufmgr, "region", handle);
return intel_region_alloc_internal(intel,
cpp, pitch, height, tiled, buffer);
@@ -440,7 +440,7 @@ intel_recreate_static(struct intel_context *intel,
if (intel->ttm) {
assert(region_desc->bo_handle != -1);
- region->buffer = intel_ttm_bo_create_from_handle(intel->bufmgr,
+ region->buffer = intel_gem_bo_create_from_handle(intel->bufmgr,
name,
region_desc->bo_handle);
} else {
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 52e062eece..7e0713c4f4 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -49,7 +49,7 @@
#include "i830_dri.h"
#include "intel_regions.h"
#include "intel_batchbuffer.h"
-#include "intel_bufmgr_ttm.h"
+#include "intel_bufmgr_gem.h"
PUBLIC const char __driConfigOptions[] =
DRI_CONF_BEGIN