Replace the flags/hint arguments to bo_alloc{,_static} with a location mask.
Now, allocations only take locations, rather than a variety of unused flags. The only interesting flag before was the no_move/no_evict pair for scanout and similar buffers, which the DRI drivers don't use. That will be readded when we get to using this code for display buffer allocation, by adding a pin/unpin call (dynamic pinning/unpinning may be useful for VT switching and root window resizing). This commit changes one instance of DRM_BO_FLAG_MEM_LOCAL with DRM_BO_FLAG_MEM_TT, which appeared to have been unintentional.
This commit is contained in:
@@ -35,18 +35,30 @@
|
|||||||
|
|
||||||
dri_bo *
|
dri_bo *
|
||||||
dri_bo_alloc(dri_bufmgr *bufmgr, const char *name, unsigned long size,
|
dri_bo_alloc(dri_bufmgr *bufmgr, const char *name, unsigned long size,
|
||||||
unsigned int alignment, unsigned int flags, unsigned int hint)
|
unsigned int alignment, unsigned int location_mask)
|
||||||
{
|
{
|
||||||
return bufmgr->bo_alloc(bufmgr, name, size, alignment, flags, hint);
|
assert((location_mask & ~(DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_MEM_TT |
|
||||||
|
DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_PRIV0 |
|
||||||
|
DRM_BO_FLAG_MEM_PRIV1 | DRM_BO_FLAG_MEM_PRIV2 |
|
||||||
|
DRM_BO_FLAG_MEM_PRIV3 |
|
||||||
|
DRM_BO_FLAG_MEM_PRIV4)) == 0);
|
||||||
|
|
||||||
|
return bufmgr->bo_alloc(bufmgr, name, size, alignment, location_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
dri_bo *
|
dri_bo *
|
||||||
dri_bo_alloc_static(dri_bufmgr *bufmgr, const char *name, unsigned long offset,
|
dri_bo_alloc_static(dri_bufmgr *bufmgr, const char *name, unsigned long offset,
|
||||||
unsigned long size, void *virtual, unsigned int flags,
|
unsigned long size, void *virtual,
|
||||||
unsigned int hint)
|
unsigned int location_mask)
|
||||||
{
|
{
|
||||||
|
assert((location_mask & ~(DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_MEM_TT |
|
||||||
|
DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_PRIV0 |
|
||||||
|
DRM_BO_FLAG_MEM_PRIV1 | DRM_BO_FLAG_MEM_PRIV2 |
|
||||||
|
DRM_BO_FLAG_MEM_PRIV3 |
|
||||||
|
DRM_BO_FLAG_MEM_PRIV4)) == 0);
|
||||||
|
|
||||||
return bufmgr->bo_alloc_static(bufmgr, name, offset, size, virtual,
|
return bufmgr->bo_alloc_static(bufmgr, name, offset, size, virtual,
|
||||||
flags, hint);
|
location_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -81,25 +81,20 @@ struct _dri_bufmgr {
|
|||||||
* address space or graphics device aperture. They must be mapped using
|
* address space or graphics device aperture. They must be mapped using
|
||||||
* bo_map() to be used by the CPU, and validated for use using bo_validate()
|
* bo_map() to be used by the CPU, and validated for use using bo_validate()
|
||||||
* to be used from the graphics device.
|
* to be used from the graphics device.
|
||||||
*
|
|
||||||
* XXX: flags/hint reason to live?
|
|
||||||
*/
|
*/
|
||||||
dri_bo *(*bo_alloc)(dri_bufmgr *bufmgr_ctx, const char *name,
|
dri_bo *(*bo_alloc)(dri_bufmgr *bufmgr_ctx, const char *name,
|
||||||
unsigned long size, unsigned int alignment,
|
unsigned long size, unsigned int alignment,
|
||||||
unsigned int flags, unsigned int hint);
|
unsigned int location_mask);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocates a buffer object for a static allocation.
|
* Allocates a buffer object for a static allocation.
|
||||||
*
|
*
|
||||||
* Static allocations are ones such as the front buffer that are offered by
|
* Static allocations are ones such as the front buffer that are offered by
|
||||||
* the X Server, which are never evicted and never moved.
|
* the X Server, which are never evicted and never moved.
|
||||||
*
|
|
||||||
* XXX: flags/hint reason to live?
|
|
||||||
*/
|
*/
|
||||||
dri_bo *(*bo_alloc_static)(dri_bufmgr *bufmgr_ctx, const char *name,
|
dri_bo *(*bo_alloc_static)(dri_bufmgr *bufmgr_ctx, const char *name,
|
||||||
unsigned long offset, unsigned long size,
|
unsigned long offset, unsigned long size,
|
||||||
void *virtual, unsigned int flags,
|
void *virtual, unsigned int location_mask);
|
||||||
unsigned int hint);
|
|
||||||
|
|
||||||
/** Takes a reference on a buffer object */
|
/** Takes a reference on a buffer object */
|
||||||
void (*bo_reference)(dri_bo *bo);
|
void (*bo_reference)(dri_bo *bo);
|
||||||
@@ -165,12 +160,10 @@ struct _dri_bufmgr {
|
|||||||
};
|
};
|
||||||
|
|
||||||
dri_bo *dri_bo_alloc(dri_bufmgr *bufmgr, const char *name, unsigned long size,
|
dri_bo *dri_bo_alloc(dri_bufmgr *bufmgr, const char *name, unsigned long size,
|
||||||
unsigned int alignment, unsigned int flags,
|
unsigned int alignment, unsigned int location_mask);
|
||||||
unsigned int hint);
|
|
||||||
dri_bo *dri_bo_alloc_static(dri_bufmgr *bufmgr, const char *name,
|
dri_bo *dri_bo_alloc_static(dri_bufmgr *bufmgr, const char *name,
|
||||||
unsigned long offset, unsigned long size,
|
unsigned long offset, unsigned long size,
|
||||||
void *virtual, unsigned int flags,
|
void *virtual, unsigned int location_mask);
|
||||||
unsigned int hint);
|
|
||||||
void dri_bo_reference(dri_bo *bo);
|
void dri_bo_reference(dri_bo *bo);
|
||||||
void dri_bo_unreference(dri_bo *bo);
|
void dri_bo_unreference(dri_bo *bo);
|
||||||
int dri_bo_map(dri_bo *buf, GLboolean write_enable);
|
int dri_bo_map(dri_bo *buf, GLboolean write_enable);
|
||||||
|
@@ -541,9 +541,9 @@ dri_bufmgr_fake_contended_lock_take(dri_bufmgr *bufmgr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static dri_bo *
|
static dri_bo *
|
||||||
dri_fake_alloc(dri_bufmgr *bufmgr, const char *name,
|
dri_fake_bo_alloc(dri_bufmgr *bufmgr, const char *name,
|
||||||
unsigned long size, unsigned int alignment, unsigned int flags,
|
unsigned long size, unsigned int alignment,
|
||||||
unsigned int hint)
|
unsigned int location_mask)
|
||||||
{
|
{
|
||||||
dri_bufmgr_fake *bufmgr_fake;
|
dri_bufmgr_fake *bufmgr_fake;
|
||||||
dri_bo_fake *bo_fake;
|
dri_bo_fake *bo_fake;
|
||||||
@@ -567,16 +567,16 @@ dri_fake_alloc(dri_bufmgr *bufmgr, const char *name,
|
|||||||
bo_fake->alignment = alignment;
|
bo_fake->alignment = alignment;
|
||||||
bo_fake->id = ++bufmgr_fake->buf_nr;
|
bo_fake->id = ++bufmgr_fake->buf_nr;
|
||||||
bo_fake->name = name;
|
bo_fake->name = name;
|
||||||
bo_fake->flags = flags;
|
bo_fake->flags = 0;
|
||||||
bo_fake->is_static = GL_FALSE;
|
bo_fake->is_static = GL_FALSE;
|
||||||
|
|
||||||
return &bo_fake->bo;
|
return &bo_fake->bo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static dri_bo *
|
static dri_bo *
|
||||||
dri_fake_alloc_static(dri_bufmgr *bufmgr, const char *name,
|
dri_fake_bo_alloc_static(dri_bufmgr *bufmgr, const char *name,
|
||||||
unsigned long offset, unsigned long size, void *virtual,
|
unsigned long offset, unsigned long size,
|
||||||
unsigned int flags, unsigned int hint)
|
void *virtual, unsigned int location_mask)
|
||||||
{
|
{
|
||||||
dri_bufmgr_fake *bufmgr_fake;
|
dri_bufmgr_fake *bufmgr_fake;
|
||||||
dri_bo_fake *bo_fake;
|
dri_bo_fake *bo_fake;
|
||||||
@@ -593,7 +593,7 @@ dri_fake_alloc_static(dri_bufmgr *bufmgr, const char *name,
|
|||||||
bo_fake->bo.bufmgr = bufmgr;
|
bo_fake->bo.bufmgr = bufmgr;
|
||||||
bo_fake->refcount = 1;
|
bo_fake->refcount = 1;
|
||||||
bo_fake->name = name;
|
bo_fake->name = name;
|
||||||
bo_fake->flags = flags;
|
bo_fake->flags = DRM_BO_FLAG_NO_EVICT | DRM_BO_FLAG_NO_MOVE;
|
||||||
bo_fake->is_static = GL_TRUE;
|
bo_fake->is_static = GL_TRUE;
|
||||||
|
|
||||||
return &bo_fake->bo;
|
return &bo_fake->bo;
|
||||||
@@ -854,8 +854,8 @@ dri_bufmgr_fake_init(unsigned long low_offset, void *low_virtual,
|
|||||||
_glthread_INIT_MUTEX(bufmgr_fake->mutex);
|
_glthread_INIT_MUTEX(bufmgr_fake->mutex);
|
||||||
|
|
||||||
/* Hook in methods */
|
/* Hook in methods */
|
||||||
bufmgr_fake->bufmgr.bo_alloc = dri_fake_alloc;
|
bufmgr_fake->bufmgr.bo_alloc = dri_fake_bo_alloc;
|
||||||
bufmgr_fake->bufmgr.bo_alloc_static = dri_fake_alloc_static;
|
bufmgr_fake->bufmgr.bo_alloc_static = dri_fake_bo_alloc_static;
|
||||||
bufmgr_fake->bufmgr.bo_reference = dri_fake_bo_reference;
|
bufmgr_fake->bufmgr.bo_reference = dri_fake_bo_reference;
|
||||||
bufmgr_fake->bufmgr.bo_unreference = dri_fake_bo_unreference;
|
bufmgr_fake->bufmgr.bo_unreference = dri_fake_bo_unreference;
|
||||||
bufmgr_fake->bufmgr.bo_map = dri_fake_bo_map;
|
bufmgr_fake->bufmgr.bo_map = dri_fake_bo_map;
|
||||||
|
@@ -89,13 +89,14 @@ driFenceSignaled(DriFenceObject * fence, unsigned type)
|
|||||||
|
|
||||||
static dri_bo *
|
static dri_bo *
|
||||||
dri_ttm_alloc(dri_bufmgr *bufmgr, const char *name,
|
dri_ttm_alloc(dri_bufmgr *bufmgr, const char *name,
|
||||||
unsigned long size, unsigned int alignment, unsigned int flags,
|
unsigned long size, unsigned int alignment,
|
||||||
unsigned int hint)
|
unsigned int location_mask)
|
||||||
{
|
{
|
||||||
dri_bufmgr_ttm *ttm_bufmgr;
|
dri_bufmgr_ttm *ttm_bufmgr;
|
||||||
dri_bo_ttm *ttm_buf;
|
dri_bo_ttm *ttm_buf;
|
||||||
unsigned int pageSize = getpagesize();
|
unsigned int pageSize = getpagesize();
|
||||||
int ret;
|
int ret;
|
||||||
|
unsigned int flags, hint;
|
||||||
|
|
||||||
ttm_bufmgr = (dri_bufmgr_ttm *)bufmgr;
|
ttm_bufmgr = (dri_bufmgr_ttm *)bufmgr;
|
||||||
|
|
||||||
@@ -103,6 +104,15 @@ dri_ttm_alloc(dri_bufmgr *bufmgr, const char *name,
|
|||||||
if (!ttm_buf)
|
if (!ttm_buf)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* The mask argument doesn't do anything for us that we want other than
|
||||||
|
* determine which pool (TTM or local) the buffer is allocated into, so just
|
||||||
|
* pass all of the allocation class flags.
|
||||||
|
*/
|
||||||
|
flags = location_mask | DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE |
|
||||||
|
DRM_BO_FLAG_EXE;
|
||||||
|
/* No hints we want to use. */
|
||||||
|
hint = 0;
|
||||||
|
|
||||||
ret = drmBOCreate(ttm_bufmgr->fd, 0, size, alignment / pageSize,
|
ret = drmBOCreate(ttm_bufmgr->fd, 0, size, alignment / pageSize,
|
||||||
NULL, drm_bo_type_dc,
|
NULL, drm_bo_type_dc,
|
||||||
flags, hint, &ttm_buf->drm_bo);
|
flags, hint, &ttm_buf->drm_bo);
|
||||||
@@ -122,11 +132,12 @@ dri_ttm_alloc(dri_bufmgr *bufmgr, const char *name,
|
|||||||
static dri_bo *
|
static dri_bo *
|
||||||
dri_ttm_alloc_static(dri_bufmgr *bufmgr, const char *name,
|
dri_ttm_alloc_static(dri_bufmgr *bufmgr, const char *name,
|
||||||
unsigned long offset, unsigned long size, void *virtual,
|
unsigned long offset, unsigned long size, void *virtual,
|
||||||
unsigned int flags, unsigned int hint)
|
unsigned int location_mask)
|
||||||
{
|
{
|
||||||
dri_bufmgr_ttm *ttm_bufmgr;
|
dri_bufmgr_ttm *ttm_bufmgr;
|
||||||
dri_bo_ttm *ttm_buf;
|
dri_bo_ttm *ttm_buf;
|
||||||
int ret;
|
int ret;
|
||||||
|
unsigned int flags, hint;
|
||||||
|
|
||||||
ttm_bufmgr = (dri_bufmgr_ttm *)bufmgr;
|
ttm_bufmgr = (dri_bufmgr_ttm *)bufmgr;
|
||||||
|
|
||||||
@@ -134,9 +145,18 @@ dri_ttm_alloc_static(dri_bufmgr *bufmgr, const char *name,
|
|||||||
if (!ttm_buf)
|
if (!ttm_buf)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* The mask argument doesn't do anything for us that we want other than
|
||||||
|
* determine which pool (TTM or local) the buffer is allocated into, so just
|
||||||
|
* pass all of the allocation class flags.
|
||||||
|
*/
|
||||||
|
flags = location_mask | DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE |
|
||||||
|
DRM_BO_FLAG_EXE | DRM_BO_FLAG_NO_EVICT | DRM_BO_FLAG_NO_MOVE;
|
||||||
|
/* No hints we want to use. */
|
||||||
|
hint = 0;
|
||||||
|
|
||||||
ret = drmBOCreate(ttm_bufmgr->fd, offset, size, 0,
|
ret = drmBOCreate(ttm_bufmgr->fd, offset, size, 0,
|
||||||
NULL, drm_bo_type_fake,
|
NULL, drm_bo_type_fake,
|
||||||
flags, 0, &ttm_buf->drm_bo);
|
flags, hint, &ttm_buf->drm_bo);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
free(ttm_buf);
|
free(ttm_buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@@ -102,8 +102,7 @@ intel_batchbuffer_reset(struct intel_batchbuffer *batch)
|
|||||||
|
|
||||||
batch->buf = dri_bo_alloc(intel->intelScreen->bufmgr, "batchbuffer",
|
batch->buf = dri_bo_alloc(intel->intelScreen->bufmgr, "batchbuffer",
|
||||||
intel->intelScreen->maxBatchSize, 4096,
|
intel->intelScreen->maxBatchSize, 4096,
|
||||||
DRM_BO_FLAG_MEM_TT |
|
DRM_BO_FLAG_MEM_TT);
|
||||||
DRM_BO_FLAG_EXE, 0);
|
|
||||||
dri_bo_map(batch->buf, GL_TRUE);
|
dri_bo_map(batch->buf, GL_TRUE);
|
||||||
batch->map = batch->buf->virtual;
|
batch->map = batch->buf->virtual;
|
||||||
batch->size = intel->intelScreen->maxBatchSize;
|
batch->size = intel->intelScreen->maxBatchSize;
|
||||||
|
@@ -42,8 +42,7 @@ intel_bufferobj_alloc_buffer(struct intel_context *intel,
|
|||||||
{
|
{
|
||||||
intel_obj->buffer = dri_bo_alloc(intel->intelScreen->bufmgr, "bufferobj",
|
intel_obj->buffer = dri_bo_alloc(intel->intelScreen->bufmgr, "bufferobj",
|
||||||
intel_obj->Base.Size, 64,
|
intel_obj->Base.Size, 64,
|
||||||
DRM_BO_FLAG_MEM_LOCAL |
|
DRM_BO_FLAG_MEM_TT);
|
||||||
DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -106,7 +106,7 @@ intel_region_alloc(intelScreenPrivate *intelScreen,
|
|||||||
region->refcount = 1;
|
region->refcount = 1;
|
||||||
|
|
||||||
region->buffer = dri_bo_alloc(intelScreen->bufmgr, "region",
|
region->buffer = dri_bo_alloc(intelScreen->bufmgr, "region",
|
||||||
pitch * cpp * height, 64, 0, 0);
|
pitch * cpp * height, 64, DRM_BO_FLAG_MEM_TT);
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,10 +162,7 @@ intel_region_create_static(intelScreenPrivate *intelScreen,
|
|||||||
/* XXX: questionable flags */
|
/* XXX: questionable flags */
|
||||||
region->buffer = dri_bo_alloc_static(intelScreen->bufmgr, "static region",
|
region->buffer = dri_bo_alloc_static(intelScreen->bufmgr, "static region",
|
||||||
offset, pitch * cpp * height, virtual,
|
offset, pitch * cpp * height, virtual,
|
||||||
DRM_BO_FLAG_MEM_TT |
|
DRM_BO_FLAG_MEM_TT);
|
||||||
DRM_BO_FLAG_NO_MOVE |
|
|
||||||
DRM_BO_FLAG_READ |
|
|
||||||
DRM_BO_FLAG_WRITE, 0);
|
|
||||||
|
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
@@ -195,10 +192,7 @@ intel_region_update_static(intelScreenPrivate *intelScreen,
|
|||||||
/* XXX: questionable flags */
|
/* XXX: questionable flags */
|
||||||
region->buffer = dri_bo_alloc_static(intelScreen->bufmgr, "static region",
|
region->buffer = dri_bo_alloc_static(intelScreen->bufmgr, "static region",
|
||||||
offset, pitch * cpp * height, virtual,
|
offset, pitch * cpp * height, virtual,
|
||||||
DRM_BO_FLAG_MEM_TT |
|
DRM_BO_FLAG_MEM_TT);
|
||||||
DRM_BO_FLAG_NO_MOVE |
|
|
||||||
DRM_BO_FLAG_READ |
|
|
||||||
DRM_BO_FLAG_WRITE, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -399,7 +393,7 @@ intel_region_release_pbo(intelScreenPrivate *intelScreen,
|
|||||||
|
|
||||||
region->buffer = dri_bo_alloc(intelScreen->bufmgr, "region",
|
region->buffer = dri_bo_alloc(intelScreen->bufmgr, "region",
|
||||||
region->pitch * region->cpp * region->height,
|
region->pitch * region->cpp * region->height,
|
||||||
64, 0, 0);
|
64, DRM_BO_FLAG_MEM_TT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Break the COW tie to the pbo. Both the pbo and the region end up
|
/* Break the COW tie to the pbo. Both the pbo and the region end up
|
||||||
|
Reference in New Issue
Block a user