[Mesa-dev] [PATCH 6/7] intel: image: handle plane id and offset attributes.
Gwenole Beauchesne
gb.devel at gmail.com
Tue Apr 24 08:30:38 PDT 2012
---
src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 1 +
src/mesa/drivers/dri/i965/gen7_wm_surface_state.c | 1 +
src/mesa/drivers/dri/intel/intel_regions.c | 7 +++++--
src/mesa/drivers/dri/intel/intel_regions.h | 5 +++++
src/mesa/drivers/dri/intel/intel_screen.c | 6 ++++++
5 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 0a6de2b..cf8210a 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -679,6 +679,7 @@ brw_update_texture_surface( struct gl_context *ctx, GLuint unit )
BRW_SURFACE_FORMAT_SHIFT));
surf[1] = intelObj->mt->region->bo->offset; /* reloc */
+ surf[1] += intelObj->mt->region->offset;
surf[2] = ((intelObj->_MaxLevel - tObj->BaseLevel) << BRW_SURFACE_LOD_SHIFT |
(width - 1) << BRW_SURFACE_WIDTH_SHIFT |
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
index c567fb0..dd01feb 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -176,6 +176,7 @@ gen7_update_texture_surface(struct gl_context *ctx, GLuint unit)
*/
surf->ss1.base_addr = intelObj->mt->region->bo->offset; /* reloc */
+ surf->ss1.base_addr += intelObj->mt->region->offset;
surf->ss2.width = width - 1;
surf->ss2.height = height - 1;
diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c
index 218be30..b4607a5 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.c
+++ b/src/mesa/drivers/dri/intel/intel_regions.c
@@ -257,7 +257,8 @@ intel_region_alloc_internal(struct intel_screen *screen,
if (region == NULL)
return region;
- region->plane_id = 0;
+ region->plane_id = attrs->plane_id;
+ region->offset = attrs->offset;
region->structure = attrs->structure;
region->cpp = attrs->cpp;
region->width = attrs->width;
@@ -293,6 +294,8 @@ intel_region_alloc(struct intel_screen *screen,
if (buffer == NULL)
return NULL;
+ attrs.plane_id = 0;
+ attrs.offset = 0;
attrs.structure = __DRI_IMAGE_STRUCTURE_FRAME;
attrs.cpp = cpp;
attrs.width = width;
@@ -345,7 +348,7 @@ intel_region_alloc_for_handle2(struct intel_screen *screen,
int ret;
uint32_t bit_6_swizzle, tiling;
- region = intel_region_hash_lookup(screen->named_regions, handle, 0);
+ region = intel_region_hash_lookup(screen->named_regions, handle, attrs->plane_id);
if (region != NULL) {
dummy = NULL;
if (!intel_region_validate_attributes(region, attrs)) {
diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h
index 052ee0b..9dcb901 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.h
+++ b/src/mesa/drivers/dri/intel/intel_regions.h
@@ -56,6 +56,7 @@ struct intel_buffer_object;
struct intel_region
{
drm_intel_bo *bo; /**< buffer manager's buffer */
+ uint32_t offset; /**< Offset (in bytes) to the base bo */
GLuint refcount; /**< Reference count for region */
GLuint plane_id; /**< Plane id out of 3 (range: 0..2) */
GLuint cpp; /**< bytes per pixel */
@@ -77,6 +78,8 @@ struct intel_region
* See. intel_region_alloc_for_handle().
*/
struct intel_region_attributes {
+ GLuint plane_id; /**< plane id */
+ uint32_t offset; /**< Offset (in bytes) to the base bo */
GLuint structure; /**< picture structure. See __DRI_IMAGE_STRUCTURE_xxx */
GLuint cpp; /**< bytes per pixel */
GLuint width; /**< in pixels */
@@ -108,6 +111,8 @@ intel_region_alloc_for_handle(struct intel_screen *screen,
{
struct intel_region_attributes attrs;
+ attrs.plane_id = 0;
+ attrs.offset = 0;
attrs.structure = __DRI_IMAGE_STRUCTURE_FRAME;
attrs.cpp = cpp;
attrs.width = width;
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 84e4e41..a5ac80c 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -239,6 +239,8 @@ intel_create_image_from_name2(__DRIscreen *screen,
image->data = loaderPrivate;
cpp = _mesa_get_format_bytes(image->format);
+ region_attrs.plane_id = attrs->plane_id;
+ region_attrs.offset = offset;
region_attrs.structure = attrs->structure;
region_attrs.cpp = cpp;
region_attrs.width = attrs->width;
@@ -387,6 +389,10 @@ intel_query_image(__DRIimage *image, int attrib, int *value)
return image->dri_format;
case __DRI_IMAGE_ATTRIB_STRUCTURE:
return image->region->structure;
+ case __DRI_IMAGE_ATTRIB_OFFSET:
+ return image->region->offset;
+ case __DRI_IMAGE_ATTRIB_PLANE_ID:
+ return image->region->plane_id;
default:
return false;
}
--
1.7.5.4
More information about the mesa-dev
mailing list