intel: Add offset field to miptree
authorKristian Høgsberg <krh@bitplanet.net>
Thu, 5 Jul 2012 03:09:14 +0000 (23:09 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Wed, 11 Jul 2012 19:28:35 +0000 (15:28 -0400)
This lets us specify an offset into the bo where the miptree starts,
which will let us set up a texture for a single plane in a planar buffer.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i915/i915_texstate.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
src/mesa/drivers/dri/intel/intel_mipmap_tree.c
src/mesa/drivers/dri/intel/intel_mipmap_tree.h
src/mesa/drivers/dri/intel/intel_tex_image.c

index fd63a69151fc7c6a6bb10a0bbee1ede704a06c69..9e6d3b1d25f312023fc74455524e94eb34e97286 100644 (file)
@@ -165,7 +165,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
 
    drm_intel_bo_reference(intelObj->mt->region->bo);
    i915->state.tex_buffer[unit] = intelObj->mt->region->bo;
-   i915->state.tex_offset[unit] = 0; /* Always the origin of the miptree */
+   i915->state.tex_offset[unit] = intelObj->mt->offset;
 
    format = translate_texture_format(firstImage->TexFormat,
                                     sampler->DepthMode);
index 26e65afabd4b1ecf5252fd072907a3a83f736b30..04ae6b23289f75b13acb43af37fabaaa01e73394 100644 (file)
@@ -736,7 +736,7 @@ brw_update_texture_surface( struct gl_context *ctx, GLuint unit )
                                    sampler->sRGBDecode) <<
               BRW_SURFACE_FORMAT_SHIFT));
 
-   surf[1] = intelObj->mt->region->bo->offset; /* reloc */
+   surf[1] = intelObj->mt->region->bo->offset + intelObj->mt->offset; /* reloc */
 
    surf[2] = ((intelObj->_MaxLevel - tObj->BaseLevel) << BRW_SURFACE_LOD_SHIFT |
              (width - 1) << BRW_SURFACE_WIDTH_SHIFT |
@@ -754,7 +754,8 @@ brw_update_texture_surface( struct gl_context *ctx, GLuint unit )
    /* Emit relocation to surface contents */
    drm_intel_bo_emit_reloc(brw->intel.batch.bo,
                           brw->wm.surf_offset[surf_index] + 4,
-                          intelObj->mt->region->bo, 0,
+                          intelObj->mt->region->bo,
+                           intelObj->mt->offset,
                           I915_GEM_DOMAIN_SAMPLER, 0);
 }
 
index d34bf53d4800ac4ccbbfadacf2ca93d41ec2f437..557f36f1be089046a7db175acb9febc766f8579c 100644 (file)
@@ -273,7 +273,8 @@ gen7_update_texture_surface(struct gl_context *ctx, GLuint unit)
     * - render_cache_read_write (exists on gen6 but ignored here)
     */
 
-   surf->ss1.base_addr = intelObj->mt->region->bo->offset; /* reloc */
+   surf->ss1.base_addr =
+      intelObj->mt->region->bo->offset + intelObj->mt->offset; /* reloc */
 
    surf->ss2.width = width - 1;
    surf->ss2.height = height - 1;
@@ -303,7 +304,7 @@ gen7_update_texture_surface(struct gl_context *ctx, GLuint unit)
    drm_intel_bo_emit_reloc(brw->intel.batch.bo,
                           brw->wm.surf_offset[surf_index] +
                           offsetof(struct gen7_surface_state, ss1),
-                          intelObj->mt->region->bo, 0,
+                          intelObj->mt->region->bo, intelObj->mt->offset,
                           I915_GEM_DOMAIN_SAMPLER, 0);
 
    gen7_check_surface_setup(surf, false /* is_render_target */);
index 7018c3732bf19acdf800d030e2a69aca87a4ce46..41d337fba16004f57d426b346a5f287d1bf45e0a 100644 (file)
@@ -233,6 +233,7 @@ intel_miptree_create(struct intel_context *intel,
                                   mt->total_width,
                                   mt->total_height,
                                   expect_accelerated_upload);
+   mt->offset = 0;
 
    if (!mt->region) {
        intel_miptree_release(&mt);
index 5c57e02f031ed37a47b5da430d63d3ad73fb2468..564c6a49f1413427d93f60001b60bd40f2f0bbc4 100644 (file)
@@ -210,6 +210,10 @@ struct intel_mipmap_tree
     */
    struct intel_region *region;
 
+   /* Offset into region bo where miptree starts:
+    */
+   uint32_t offset;
+
    /**
     * \brief HiZ miptree
     *
index 6e7e7018182492cf87e0d3f6978a335d16675c53..0caa2e2d66e01e56c7596a1789e1c16f8c7c894e 100644 (file)
@@ -242,7 +242,8 @@ intel_set_texture_image_region(struct gl_context *ctx,
                               struct intel_region *region,
                               GLenum target,
                               GLenum internalFormat,
-                              gl_format format)
+                              gl_format format,
+                               uint32_t offset)
 {
    struct intel_context *intel = intel_context(ctx);
    struct intel_texture_image *intel_image = intel_texture_image(image);
@@ -261,6 +262,7 @@ intel_set_texture_image_region(struct gl_context *ctx,
    if (intel_image->mt == NULL)
        return;
 
+   intel_image->mt->offset = offset;
    intel_image->base.RowStride = region->pitch;
 
    /* Immediately validate the image to the object. */
@@ -316,7 +318,7 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
    _mesa_lock_texture(&intel->ctx, texObj);
    texImage = _mesa_get_tex_image(ctx, texObj, target, level);
    intel_set_texture_image_region(ctx, texImage, rb->mt->region, target,
-                                 internalFormat, texFormat);
+                                 internalFormat, texFormat, 0);
    _mesa_unlock_texture(&intel->ctx, texObj);
 }
 
@@ -347,7 +349,8 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
       return;
 
    intel_set_texture_image_region(ctx, texImage, image->region,
-                                 target, image->internal_format, image->format);
+                                 target, image->internal_format,
+                                  image->format, 0);
 }
 #endif