diff options
author | Eric Anholt <[email protected]> | 2011-07-29 14:35:01 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2011-08-29 10:10:03 -0700 |
commit | bfc09e92ffbf3e03f5ea09421d2b8cbae1df53bf (patch) | |
tree | b9454e7d90e8908c86cbfc7813622feb6f03b36a /src/mesa/drivers | |
parent | 0abb2659dda3ac7828cade6f9a999c511e33e905 (diff) |
intel: Add implementation of MapTextureImage/UnmapTextureImage.
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_tex.c | 84 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_tex.h | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_tex_image.c | 4 |
3 files changed, 92 insertions, 2 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_tex.c b/src/mesa/drivers/dri/intel/intel_tex.c index 1c607246cd6..4faa01a8627 100644 --- a/src/mesa/drivers/dri/intel/intel_tex.c +++ b/src/mesa/drivers/dri/intel/intel_tex.c @@ -72,6 +72,88 @@ intel_free_texture_image_buffer(struct gl_context * ctx, } /** + * Map texture memory/buffer into user space. + * Note: the region of interest parameters are ignored here. + * \param mapOut returns start of mapping of region of interest + * \param rowStrideOut returns row stride in bytes + */ +static void +intel_map_texture_image(struct gl_context *ctx, + struct gl_texture_image *tex_image, + GLuint slice, + GLuint x, GLuint y, GLuint w, GLuint h, + GLbitfield mode, + GLubyte **map, + GLint *stride) +{ + struct intel_context *intel = intel_context(ctx); + struct intel_texture_image *intel_image = intel_texture_image(tex_image); + struct intel_mipmap_tree *mt = intel_image->mt; + unsigned int bw, bh; + + if (intel_image->stencil_rb) { + /* + * The texture has packed depth/stencil format, but uses separate + * stencil. The texture's embedded stencil buffer contains the real + * stencil data, so copy that into the miptree. + */ + intel_tex_image_s8z24_gather(intel, intel_image); + } + + /* For compressed formats, the stride is the number of bytes per + * row of blocks. intel_miptree_get_image_offset() already does + * the divide. + */ + _mesa_get_format_block_size(mt->format, &bw, &bh); + assert(y % bh == 0); + y /= bh; + + if (likely(mt)) { + void *base = intel_region_map(intel, mt->region); + unsigned int image_x, image_y; + + intel_miptree_get_image_offset(mt, tex_image->Level, tex_image->Face, + slice, &image_x, &image_y); + x += image_x; + y += image_y; + + *stride = mt->region->pitch * mt->cpp; + *map = base + y * *stride + x * mt->cpp; + } else { + /* texture data is in malloc'd memory */ + GLuint width = tex_image->Width; + GLuint height = ALIGN(tex_image->Height, bh) / bh; + GLuint texelSize = _mesa_get_format_bytes(tex_image->TexFormat); + + assert(map); + + *stride = _mesa_format_row_stride(tex_image->TexFormat, width); + *map = tex_image->Data + (slice * height + y) * *stride + x * texelSize; + + return; + } +} + +static void +intel_unmap_texture_image(struct gl_context *ctx, + struct gl_texture_image *tex_image, GLuint slice) +{ + struct intel_context *intel = intel_context(ctx); + struct intel_texture_image *intel_image = intel_texture_image(tex_image); + + intel_region_unmap(intel, intel_image->mt->region); + + if (intel_image->stencil_rb) { + /* + * The texture has packed depth/stencil format, but uses separate + * stencil. The texture's embedded stencil buffer contains the real + * stencil data, so copy that into the miptree. + */ + intel_tex_image_s8z24_scatter(intel, intel_image); + } +} + +/** * Called via ctx->Driver.GenerateMipmap() * This is basically a wrapper for _mesa_meta_GenerateMipmap() which checks * if we'll be using software mipmap generation. In that case, we need to @@ -125,4 +207,6 @@ intelInitTextureFuncs(struct dd_function_table *functions) functions->NewTextureImage = intelNewTextureImage; functions->DeleteTexture = intelDeleteTextureObject; functions->FreeTextureImageBuffer = intel_free_texture_image_buffer; + functions->MapTextureImage = intel_map_texture_image; + functions->UnmapTextureImage = intel_unmap_texture_image; } diff --git a/src/mesa/drivers/dri/intel/intel_tex.h b/src/mesa/drivers/dri/intel/intel_tex.h index 52462f39d54..1eaa3cc9167 100644 --- a/src/mesa/drivers/dri/intel/intel_tex.h +++ b/src/mesa/drivers/dri/intel/intel_tex.h @@ -63,6 +63,12 @@ void intel_tex_map_images(struct intel_context *intel, void intel_tex_unmap_images(struct intel_context *intel, struct intel_texture_object *intelObj); +void intel_tex_image_s8z24_scatter(struct intel_context *intel, + struct intel_texture_image *intel_image); + +void intel_tex_image_s8z24_gather(struct intel_context *intel, + struct intel_texture_image *intel_image); + int intel_compressed_num_bytes(GLuint mesaFormat); GLboolean intel_copy_texsubimage(struct intel_context *intel, diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index 4149f4510ef..29a6d3be2a6 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -312,7 +312,7 @@ intel_tex_image_s8z24_scattergather(struct intel_context *intel, /** * Copy the x8 bits from intel_image->depth_rb to intel_image->stencil_rb. */ -static void +void intel_tex_image_s8z24_scatter(struct intel_context *intel, struct intel_texture_image *intel_image) { @@ -323,7 +323,7 @@ intel_tex_image_s8z24_scatter(struct intel_context *intel, * Copy the data in intel_image->stencil_rb to the x8 bits in * intel_image->depth_rb. */ -static void +void intel_tex_image_s8z24_gather(struct intel_context *intel, struct intel_texture_image *intel_image) { |