|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static struct intel_region * |
|
|
static struct intel_region * |
|
|
intel_region_alloc_internal(struct intel_context *intel, |
|
|
|
|
|
|
|
|
intel_region_alloc_internal(struct intel_screen *screen, |
|
|
GLuint cpp, |
|
|
GLuint cpp, |
|
|
GLuint width, GLuint height, GLuint pitch, |
|
|
GLuint width, GLuint height, GLuint pitch, |
|
|
drm_intel_bo *buffer) |
|
|
|
|
|
|
|
|
uint32_t tiling, drm_intel_bo *buffer) |
|
|
{ |
|
|
{ |
|
|
struct intel_region *region; |
|
|
struct intel_region *region; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
region->pitch = pitch; |
|
|
region->pitch = pitch; |
|
|
region->refcount = 1; |
|
|
region->refcount = 1; |
|
|
region->buffer = buffer; |
|
|
region->buffer = buffer; |
|
|
|
|
|
|
|
|
/* Default to no tiling */ |
|
|
|
|
|
region->tiling = I915_TILING_NONE; |
|
|
|
|
|
|
|
|
region->tiling = tiling; |
|
|
|
|
|
region->screen = screen; |
|
|
|
|
|
|
|
|
_DBG("%s <-- %p\n", __FUNCTION__, region); |
|
|
_DBG("%s <-- %p\n", __FUNCTION__, region); |
|
|
return region; |
|
|
return region; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
struct intel_region * |
|
|
struct intel_region * |
|
|
intel_region_alloc(struct intel_context *intel, |
|
|
|
|
|
|
|
|
intel_region_alloc(struct intel_screen *screen, |
|
|
uint32_t tiling, |
|
|
uint32_t tiling, |
|
|
GLuint cpp, GLuint width, GLuint height, |
|
|
GLuint cpp, GLuint width, GLuint height, |
|
|
GLboolean expect_accelerated_upload) |
|
|
GLboolean expect_accelerated_upload) |
|
|
{ |
|
|
{ |
|
|
drm_intel_bo *buffer; |
|
|
drm_intel_bo *buffer; |
|
|
struct intel_region *region; |
|
|
|
|
|
unsigned long flags = 0; |
|
|
unsigned long flags = 0; |
|
|
unsigned long aligned_pitch; |
|
|
unsigned long aligned_pitch; |
|
|
|
|
|
|
|
|
if (expect_accelerated_upload) |
|
|
if (expect_accelerated_upload) |
|
|
flags |= BO_ALLOC_FOR_RENDER; |
|
|
flags |= BO_ALLOC_FOR_RENDER; |
|
|
|
|
|
|
|
|
buffer = drm_intel_bo_alloc_tiled(intel->bufmgr, "region", |
|
|
|
|
|
|
|
|
buffer = drm_intel_bo_alloc_tiled(screen->bufmgr, "region", |
|
|
width, height, cpp, |
|
|
width, height, cpp, |
|
|
&tiling, &aligned_pitch, flags); |
|
|
&tiling, &aligned_pitch, flags); |
|
|
|
|
|
|
|
|
region = intel_region_alloc_internal(intel, cpp, width, height, |
|
|
|
|
|
aligned_pitch / cpp, buffer); |
|
|
|
|
|
if (region == NULL) |
|
|
|
|
|
return region; |
|
|
|
|
|
|
|
|
|
|
|
region->tiling = tiling; |
|
|
|
|
|
|
|
|
|
|
|
return region; |
|
|
|
|
|
|
|
|
return intel_region_alloc_internal(screen, cpp, width, height, |
|
|
|
|
|
aligned_pitch / cpp, tiling, buffer); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
struct intel_region * |
|
|
struct intel_region * |
|
|
intel_region_alloc_for_handle(struct intel_context *intel, |
|
|
|
|
|
|
|
|
intel_region_alloc_for_handle(struct intel_screen *screen, |
|
|
GLuint cpp, |
|
|
GLuint cpp, |
|
|
GLuint width, GLuint height, GLuint pitch, |
|
|
GLuint width, GLuint height, GLuint pitch, |
|
|
GLuint handle, const char *name) |
|
|
GLuint handle, const char *name) |
|
|
|
|
|
|
|
|
struct intel_region *region, *dummy; |
|
|
struct intel_region *region, *dummy; |
|
|
drm_intel_bo *buffer; |
|
|
drm_intel_bo *buffer; |
|
|
int ret; |
|
|
int ret; |
|
|
uint32_t bit_6_swizzle; |
|
|
|
|
|
|
|
|
uint32_t bit_6_swizzle, tiling; |
|
|
|
|
|
|
|
|
region = _mesa_HashLookup(intel->intelScreen->named_regions, handle); |
|
|
|
|
|
|
|
|
region = _mesa_HashLookup(screen->named_regions, handle); |
|
|
if (region != NULL) { |
|
|
if (region != NULL) { |
|
|
dummy = NULL; |
|
|
dummy = NULL; |
|
|
if (region->width != width || region->height != height || |
|
|
if (region->width != width || region->height != height || |
|
|
|
|
|
|
|
|
return dummy; |
|
|
return dummy; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
buffer = intel_bo_gem_create_from_name(intel->bufmgr, name, handle); |
|
|
|
|
|
|
|
|
|
|
|
region = intel_region_alloc_internal(intel, cpp, |
|
|
|
|
|
width, height, pitch, buffer); |
|
|
|
|
|
if (region == NULL) |
|
|
|
|
|
return region; |
|
|
|
|
|
|
|
|
|
|
|
ret = drm_intel_bo_get_tiling(region->buffer, ®ion->tiling, |
|
|
|
|
|
&bit_6_swizzle); |
|
|
|
|
|
|
|
|
buffer = intel_bo_gem_create_from_name(screen->bufmgr, name, handle); |
|
|
|
|
|
if (buffer == NULL) |
|
|
|
|
|
return NULL; |
|
|
|
|
|
ret = drm_intel_bo_get_tiling(buffer, &tiling, &bit_6_swizzle); |
|
|
if (ret != 0) { |
|
|
if (ret != 0) { |
|
|
fprintf(stderr, "Couldn't get tiling of buffer %d (%s): %s\n", |
|
|
fprintf(stderr, "Couldn't get tiling of buffer %d (%s): %s\n", |
|
|
handle, name, strerror(-ret)); |
|
|
handle, name, strerror(-ret)); |
|
|
intel_region_release(®ion); |
|
|
|
|
|
|
|
|
drm_intel_bo_unreference(buffer); |
|
|
|
|
|
return NULL; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
region = intel_region_alloc_internal(screen, cpp, |
|
|
|
|
|
width, height, pitch, tiling, buffer); |
|
|
|
|
|
if (region == NULL) { |
|
|
|
|
|
drm_intel_bo_unreference(buffer); |
|
|
return NULL; |
|
|
return NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
region->name = handle; |
|
|
region->name = handle; |
|
|
region->screen = intel->intelScreen; |
|
|
|
|
|
_mesa_HashInsert(intel->intelScreen->named_regions, handle, region); |
|
|
|
|
|
|
|
|
_mesa_HashInsert(screen->named_regions, handle, region); |
|
|
|
|
|
|
|
|
return region; |
|
|
return region; |
|
|
} |
|
|
} |