intel: track bufmgr move to libdrm_intel and bufmgr_fake irq emit/wait change.

This commit is contained in:
Eric Anholt
2008-09-06 03:09:43 +01:00
parent 7e0bbdcf03
commit 3628185f56
26 changed files with 96 additions and 196 deletions

View File

@@ -64,6 +64,8 @@ DRIVER_DEFINES = -I../intel -I../intel/server -DI915 \
$(shell pkg-config libdrm --atleast-version=2.3.1 \ $(shell pkg-config libdrm --atleast-version=2.3.1 \
&& echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP") && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
DRI_LIB_DEPS += -ldrm_intel
include ../Makefile.template include ../Makefile.template
intel_decode.o: ../intel/intel_decode.c intel_decode.o: ../intel/intel_decode.c

View File

@@ -28,7 +28,6 @@
#include "mtypes.h" #include "mtypes.h"
#include "enums.h" #include "enums.h"
#include "texformat.h" #include "texformat.h"
#include "dri_bufmgr.h"
#include "intel_mipmap_tree.h" #include "intel_mipmap_tree.h"
#include "intel_tex.h" #include "intel_tex.h"

View File

@@ -28,7 +28,6 @@
#include "mtypes.h" #include "mtypes.h"
#include "enums.h" #include "enums.h"
#include "texformat.h" #include "texformat.h"
#include "dri_bufmgr.h"
#include "intel_mipmap_tree.h" #include "intel_mipmap_tree.h"
#include "intel_tex.h" #include "intel_tex.h"

View File

@@ -91,6 +91,8 @@ ASM_SOURCES =
DRIVER_DEFINES = -I../intel -I../intel/server DRIVER_DEFINES = -I../intel -I../intel/server
DRI_LIB_DEPS += -ldrm_intel
include ../Makefile.template include ../Makefile.template
symlinks: symlinks:

View File

@@ -255,7 +255,7 @@ cc_unit_create_from_key(struct brw_context *brw, struct brw_cc_unit_key *key)
NULL, NULL); NULL, NULL);
/* Emit CC viewport relocation */ /* Emit CC viewport relocation */
intel_bo_emit_reloc(bo, dri_bo_emit_reloc(bo,
I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
0, 0,
0, 0,

View File

@@ -119,7 +119,7 @@ clip_unit_create_from_key(struct brw_context *brw,
/* Emit clip program relocation */ /* Emit clip program relocation */
assert(brw->clip.prog_bo); assert(brw->clip.prog_bo);
intel_bo_emit_reloc(bo, dri_bo_emit_reloc(bo,
I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
0, 0,
clip.thread0.grf_reg_count << 1, clip.thread0.grf_reg_count << 1,

View File

@@ -31,7 +31,6 @@
#include "mtypes.h" /* for GLcontext... */ #include "mtypes.h" /* for GLcontext... */
#include "vbo/vbo.h" #include "vbo/vbo.h"
#include "dri_bufmgr.h"
struct brw_context; struct brw_context;

View File

@@ -106,7 +106,7 @@ gs_unit_create_from_key(struct brw_context *brw, struct brw_gs_unit_key *key)
if (key->prog_active) { if (key->prog_active) {
/* Emit GS program relocation */ /* Emit GS program relocation */
intel_bo_emit_reloc(bo, dri_bo_emit_reloc(bo,
I915_GEM_DOMAIN_INSTRUCTION, 0, I915_GEM_DOMAIN_INSTRUCTION, 0,
gs.thread0.grf_reg_count << 1, gs.thread0.grf_reg_count << 1,
offsetof(struct brw_gs_unit_state, thread0), offsetof(struct brw_gs_unit_state, thread0),

View File

@@ -251,14 +251,14 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key,
NULL, NULL); NULL, NULL);
/* Emit SF program relocation */ /* Emit SF program relocation */
intel_bo_emit_reloc(bo, dri_bo_emit_reloc(bo,
I915_GEM_DOMAIN_INSTRUCTION, 0, I915_GEM_DOMAIN_INSTRUCTION, 0,
sf.thread0.grf_reg_count << 1, sf.thread0.grf_reg_count << 1,
offsetof(struct brw_sf_unit_state, thread0), offsetof(struct brw_sf_unit_state, thread0),
brw->sf.prog_bo); brw->sf.prog_bo);
/* Emit SF viewport relocation */ /* Emit SF viewport relocation */
intel_bo_emit_reloc(bo, dri_bo_emit_reloc(bo,
I915_GEM_DOMAIN_INSTRUCTION, 0, I915_GEM_DOMAIN_INSTRUCTION, 0,
sf.sf5.front_winding | (sf.sf5.viewport_transform << 1), sf.sf5.front_winding | (sf.sf5.viewport_transform << 1),
offsetof(struct brw_sf_unit_state, sf5), offsetof(struct brw_sf_unit_state, sf5),

View File

@@ -33,7 +33,6 @@
#include "brw_context.h" #include "brw_context.h"
#include "brw_state.h" #include "brw_state.h"
#include "dri_bufmgr.h"
#include "intel_batchbuffer.h" #include "intel_batchbuffer.h"
/* This is used to initialize brw->state.atoms[]. We could use this /* This is used to initialize brw->state.atoms[]. We could use this

View File

@@ -115,7 +115,7 @@ vs_unit_create_from_key(struct brw_context *brw, struct brw_vs_unit_key *key)
NULL, NULL); NULL, NULL);
/* Emit VS program relocation */ /* Emit VS program relocation */
intel_bo_emit_reloc(bo, dri_bo_emit_reloc(bo,
I915_GEM_DOMAIN_INSTRUCTION, 0, I915_GEM_DOMAIN_INSTRUCTION, 0,
vs.thread0.grf_reg_count << 1, vs.thread0.grf_reg_count << 1,
offsetof(struct brw_vs_unit_state, thread0), offsetof(struct brw_vs_unit_state, thread0),

View File

@@ -303,7 +303,7 @@ static void upload_wm_samplers( struct brw_context *brw )
if (!brw->attribs.Texture->Unit[i]._ReallyEnabled) if (!brw->attribs.Texture->Unit[i]._ReallyEnabled)
continue; continue;
intel_bo_emit_reloc(brw->wm.sampler_bo, dri_bo_emit_reloc(brw->wm.sampler_bo,
I915_GEM_DOMAIN_INSTRUCTION, 0, I915_GEM_DOMAIN_INSTRUCTION, 0,
0, 0,
i * sizeof(struct brw_sampler_state) + i * sizeof(struct brw_sampler_state) +

View File

@@ -34,7 +34,6 @@
#include "brw_context.h" #include "brw_context.h"
#include "brw_state.h" #include "brw_state.h"
#include "brw_defines.h" #include "brw_defines.h"
#include "dri_bufmgr.h"
#include "brw_wm.h" #include "brw_wm.h"
/*********************************************************************** /***********************************************************************
@@ -199,7 +198,7 @@ wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
NULL, NULL); NULL, NULL);
/* Emit WM program relocation */ /* Emit WM program relocation */
intel_bo_emit_reloc(bo, dri_bo_emit_reloc(bo,
I915_GEM_DOMAIN_INSTRUCTION, 0, I915_GEM_DOMAIN_INSTRUCTION, 0,
wm.thread0.grf_reg_count << 1, wm.thread0.grf_reg_count << 1,
offsetof(struct brw_wm_unit_state, thread0), offsetof(struct brw_wm_unit_state, thread0),
@@ -207,7 +206,7 @@ wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
/* Emit scratch space relocation */ /* Emit scratch space relocation */
if (key->total_scratch != 0) { if (key->total_scratch != 0) {
intel_bo_emit_reloc(bo, dri_bo_emit_reloc(bo,
0, 0, 0, 0,
wm.thread2.per_thread_scratch_space, wm.thread2.per_thread_scratch_space,
offsetof(struct brw_wm_unit_state, thread2), offsetof(struct brw_wm_unit_state, thread2),
@@ -216,7 +215,7 @@ wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
/* Emit sampler state relocation */ /* Emit sampler state relocation */
if (key->sampler_count != 0) { if (key->sampler_count != 0) {
intel_bo_emit_reloc(bo, dri_bo_emit_reloc(bo,
I915_GEM_DOMAIN_INSTRUCTION, 0, I915_GEM_DOMAIN_INSTRUCTION, 0,
wm.wm4.stats_enable | (wm.wm4.sampler_count << 2), wm.wm4.stats_enable | (wm.wm4.sampler_count << 2),
offsetof(struct brw_wm_unit_state, wm4), offsetof(struct brw_wm_unit_state, wm4),

View File

@@ -234,7 +234,7 @@ brw_create_texture_surface( struct brw_context *brw,
if (key->bo) { if (key->bo) {
/* Emit relocation to surface contents */ /* Emit relocation to surface contents */
intel_bo_emit_reloc(bo, dri_bo_emit_reloc(bo,
I915_GEM_DOMAIN_SAMPLER, 0, I915_GEM_DOMAIN_SAMPLER, 0,
0, 0,
offsetof(struct brw_surface_state, ss1), offsetof(struct brw_surface_state, ss1),
@@ -374,7 +374,7 @@ brw_update_region_surface(struct brw_context *brw, struct intel_region *region,
* them both. We might be able to figure out from other state * them both. We might be able to figure out from other state
* a more restrictive relocation to emit. * a more restrictive relocation to emit.
*/ */
intel_bo_emit_reloc(brw->wm.surf_bo[unit], dri_bo_emit_reloc(brw->wm.surf_bo[unit],
I915_GEM_DOMAIN_RENDER | I915_GEM_DOMAIN_RENDER |
I915_GEM_DOMAIN_SAMPLER, I915_GEM_DOMAIN_SAMPLER,
I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
@@ -420,7 +420,7 @@ brw_wm_get_binding_table(struct brw_context *brw)
/* Emit binding table relocations to surface state */ /* Emit binding table relocations to surface state */
for (i = 0; i < BRW_WM_MAX_SURF; i++) { for (i = 0; i < BRW_WM_MAX_SURF; i++) {
if (brw->wm.surf_bo[i] != NULL) { if (brw->wm.surf_bo[i] != NULL) {
intel_bo_emit_reloc(bind_bo, dri_bo_emit_reloc(bind_bo,
I915_GEM_DOMAIN_INSTRUCTION, 0, I915_GEM_DOMAIN_INSTRUCTION, 0,
0, 0,
i * sizeof(GLuint), i * sizeof(GLuint),

View File

@@ -261,13 +261,9 @@ _intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file,
UNLOCK_HARDWARE(intel); UNLOCK_HARDWARE(intel);
if (INTEL_DEBUG & DEBUG_SYNC) { if (INTEL_DEBUG & DEBUG_SYNC) {
int irq;
fprintf(stderr, "waiting for idle\n"); fprintf(stderr, "waiting for idle\n");
LOCK_HARDWARE(intel); dri_bo_map(batch->buf, GL_TRUE);
irq = intelEmitIrqLocked(intel->intelScreen); dri_bo_unmap(batch->buf);
UNLOCK_HARDWARE(intel);
intelWaitIrq(intel->intelScreen, irq);
} }
/* Reset the buffer: /* Reset the buffer:
@@ -289,7 +285,7 @@ intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch,
if (batch->ptr - batch->map > batch->buf->size) if (batch->ptr - batch->map > batch->buf->size)
_mesa_printf ("bad relocation ptr %p map %p offset %d size %d\n", _mesa_printf ("bad relocation ptr %p map %p offset %d size %d\n",
batch->ptr, batch->map, batch->ptr - batch->map, batch->buf->size); batch->ptr, batch->map, batch->ptr - batch->map, batch->buf->size);
ret = intel_bo_emit_reloc(batch->buf, read_domains, write_domain, ret = dri_bo_emit_reloc(batch->buf, read_domains, write_domain,
delta, batch->ptr - batch->map, buffer); delta, batch->ptr - batch->map, buffer);
/* /*

View File

@@ -3,7 +3,7 @@
#include "mtypes.h" #include "mtypes.h"
#include "dri_bufmgr.h" #include "intel_bufmgr.h"
#include "intel_reg.h" #include "intel_reg.h"
struct intel_context; struct intel_context;

View File

@@ -30,7 +30,6 @@
#include "intel_context.h" #include "intel_context.h"
#include "intel_ioctl.h" #include "intel_ioctl.h"
#include "dri_bufmgr.h"
extern void intelCopyBuffer(const __DRIdrawablePrivate * dpriv, extern void intelCopyBuffer(const __DRIdrawablePrivate * dpriv,
const drm_clip_rect_t * rect); const drm_clip_rect_t * rect);

View File

@@ -34,7 +34,6 @@
#include "intel_buffer_objects.h" #include "intel_buffer_objects.h"
#include "intel_batchbuffer.h" #include "intel_batchbuffer.h"
#include "intel_regions.h" #include "intel_regions.h"
#include "dri_bufmgr.h"
static GLboolean intel_bufferobj_unmap(GLcontext * ctx, static GLboolean intel_bufferobj_unmap(GLcontext * ctx,
GLenum target, GLenum target,

View File

@@ -278,7 +278,7 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
} }
if (rb->region) { if (rb->region) {
intel_bo_flink(rb->region->buffer, &name); dri_bo_flink(rb->region->buffer, &name);
if (name == buffers[i].name) if (name == buffers[i].name)
continue; continue;
} }
@@ -614,8 +614,6 @@ intelInitContext(struct intel_context *intel,
GLcontext *shareCtx = (GLcontext *) sharedContextPrivate; GLcontext *shareCtx = (GLcontext *) sharedContextPrivate;
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private; intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
volatile struct drm_i915_sarea *saPriv = (struct drm_i915_sarea *)
(((GLubyte *) sPriv->pSAREA) + intelScreen->sarea_priv_offset);
int fthrottle_mode; int fthrottle_mode;
if (!_mesa_initialize_context(&intel->ctx, mesaVis, shareCtx, if (!_mesa_initialize_context(&intel->ctx, mesaVis, shareCtx,
@@ -627,7 +625,7 @@ intelInitContext(struct intel_context *intel,
driContextPriv->driverPrivate = intel; driContextPriv->driverPrivate = intel;
intel->intelScreen = intelScreen; intel->intelScreen = intelScreen;
intel->driScreen = sPriv; intel->driScreen = sPriv;
intel->sarea = saPriv; intel->sarea = intelScreen->sarea;
intel->driContext = driContextPriv; intel->driContext = driContextPriv;
/* Dri stuff */ /* Dri stuff */

View File

@@ -34,7 +34,6 @@
#include "drm.h" #include "drm.h"
#include "mm.h" #include "mm.h"
#include "texmem.h" #include "texmem.h"
#include "dri_bufmgr.h"
#include "intel_bufmgr.h" #include "intel_bufmgr.h"
#include "intel_screen.h" #include "intel_screen.h"

View File

@@ -49,66 +49,6 @@
#define FILE_DEBUG_FLAG DEBUG_IOCTL #define FILE_DEBUG_FLAG DEBUG_IOCTL
int
intelEmitIrqLocked(intelScreenPrivate *intelScreen)
{
__DRIscreenPrivate *spriv = intelScreen->driScrnPriv;
struct drm_i915_irq_emit ie;
int ret, seq = 1;
if (intelScreen->no_hw)
return 1;
/*
assert(((*(int *)intelScreen->driHwLock) & ~DRM_LOCK_CONT) ==
(DRM_LOCK_HELD|intelScreen->hHWContext));
*/
ie.irq_seq = &seq;
ret = drmCommandWriteRead(spriv->fd, DRM_I915_IRQ_EMIT, &ie, sizeof(ie));
if (ret) {
fprintf(stderr, "%s: drm_i915_irq_emit: %d\n", __FUNCTION__, ret);
exit(1);
}
DBG("%s --> %d\n", __FUNCTION__, seq);
return seq;
}
void
intelWaitIrq(intelScreenPrivate *intelScreen, int seq)
{
__DRIscreenPrivate *spriv = intelScreen->driScrnPriv;
struct drm_i915_irq_wait iw;
int ret, lastdispatch;
volatile struct drm_i915_sarea *sarea = (struct drm_i915_sarea *)
(((GLubyte *) spriv->pSAREA) + intelScreen->sarea_priv_offset);
if (intelScreen->no_hw)
return;
DBG("%s %d\n", __FUNCTION__, seq);
iw.irq_seq = seq;
do {
lastdispatch = sarea->last_dispatch;
ret = drmCommandWrite(spriv->fd, DRM_I915_IRQ_WAIT, &iw, sizeof(iw));
} while (ret == -EAGAIN ||
ret == -EINTR ||
(ret == -EBUSY && lastdispatch != sarea->last_dispatch) ||
(ret == 0 && seq > sarea->last_dispatch) ||
(ret == 0 && sarea->last_dispatch - seq >= (1 << 24)));
if (ret) {
fprintf(stderr, "%s: drm_i915_irq_wait: %d\n", __FUNCTION__, ret);
exit(1);
}
}
int int
intel_batch_ioctl(struct intel_context *intel, intel_batch_ioctl(struct intel_context *intel,
GLuint start_offset, GLuint start_offset,

View File

@@ -30,9 +30,6 @@
#include "intel_context.h" #include "intel_context.h"
void intelWaitIrq(intelScreenPrivate *intelScreen, int seq);
int intelEmitIrqLocked(intelScreenPrivate *intelScreen);
int intel_batch_ioctl(struct intel_context *intel, int intel_batch_ioctl(struct intel_context *intel,
GLuint start_offset, GLuint start_offset,
GLuint used, GLuint used,

View File

@@ -46,7 +46,6 @@
#include "intel_regions.h" #include "intel_regions.h"
#include "intel_blit.h" #include "intel_blit.h"
#include "intel_buffer_objects.h" #include "intel_buffer_objects.h"
#include "dri_bufmgr.h"
#include "intel_bufmgr.h" #include "intel_bufmgr.h"
#include "intel_batchbuffer.h" #include "intel_batchbuffer.h"
#include "intel_chipset.h" #include "intel_chipset.h"

View File

@@ -34,8 +34,10 @@
* the basic structure for rectangular collections of pixels stored in a dri_bo. * the basic structure for rectangular collections of pixels stored in a dri_bo.
*/ */
#include <xf86drm.h>
#include "mtypes.h" #include "mtypes.h"
#include "dri_bufmgr.h" #include "intel_bufmgr.h"
struct intel_context; struct intel_context;
struct intel_buffer_object; struct intel_buffer_object;

View File

@@ -274,9 +274,9 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv)
intelScreen->driScrnPriv = sPriv; intelScreen->driScrnPriv = sPriv;
sPriv->private = (void *) intelScreen; sPriv->private = (void *) intelScreen;
intelScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
sarea = (struct drm_i915_sarea *) sarea = (struct drm_i915_sarea *)
(((GLubyte *) sPriv->pSAREA) + intelScreen->sarea_priv_offset); (((GLubyte *) sPriv->pSAREA) + gDRIPriv->sarea_priv_offset);
intelScreen->sarea = sarea;
intelScreen->deviceID = gDRIPriv->deviceID; intelScreen->deviceID = gDRIPriv->deviceID;
@@ -289,8 +289,6 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv)
return GL_FALSE; return GL_FALSE;
} }
intelScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
if (0) if (0)
intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv); intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv);
@@ -551,34 +549,6 @@ intelFillInModes(__DRIscreenPrivate *psp,
return configs; return configs;
} }
/** Driver-specific fence emit implementation for the fake memory manager. */
static unsigned int
intel_fence_emit(void *private)
{
intelScreenPrivate *intelScreen = (intelScreenPrivate *)private;
unsigned int fence;
/* XXX: Need to emit a flush, if we haven't already (at least with the
* current batchbuffer implementation, we have).
*/
fence = intelEmitIrqLocked(intelScreen);
return fence;
}
/** Driver-specific fence wait implementation for the fake memory manager. */
static int
intel_fence_wait(void *private, unsigned int cookie)
{
intelScreenPrivate *intelScreen = (intelScreenPrivate *)private;
intelWaitIrq(intelScreen, cookie);
return 0;
}
static GLboolean static GLboolean
intel_init_bufmgr(intelScreenPrivate *intelScreen) intel_init_bufmgr(intelScreenPrivate *intelScreen)
{ {
@@ -628,12 +598,13 @@ intel_init_bufmgr(intelScreenPrivate *intelScreen)
return GL_FALSE; return GL_FALSE;
} }
intelScreen->bufmgr = intel_bufmgr_fake_init(intelScreen->tex.offset, intelScreen->bufmgr =
intel_bufmgr_fake_init(spriv->fd,
intelScreen->tex.offset,
intelScreen->tex.map, intelScreen->tex.map,
intelScreen->tex.size, intelScreen->tex.size,
intel_fence_emit, (unsigned int * volatile)
intel_fence_wait, &intelScreen->sarea->last_dispatch);
intelScreen);
} }
/* XXX bufmgr should be per-screen, not per-context */ /* XXX bufmgr should be per-screen, not per-context */

View File

@@ -30,7 +30,7 @@
#include <sys/time.h> #include <sys/time.h>
#include "dri_util.h" #include "dri_util.h"
#include "dri_bufmgr.h" #include "intel_bufmgr.h"
#include "i915_drm.h" #include "i915_drm.h"
#include "xmlconfig.h" #include "xmlconfig.h"
@@ -68,7 +68,8 @@ typedef struct
int logTextureGranularity; int logTextureGranularity;
__DRIscreenPrivate *driScrnPriv; __DRIscreenPrivate *driScrnPriv;
unsigned int sarea_priv_offset;
volatile struct drm_i915_sarea *sarea;
int drmMinor; int drmMinor;