diff options
author | Eric Anholt <[email protected]> | 2013-04-19 13:10:55 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2013-04-30 10:40:44 -0700 |
commit | adf958d9c2b4cbfbeef36c253b8889967d83c272 (patch) | |
tree | 0c8625f21f09461eb807f1afb59987d1a2675422 /src/mesa/drivers/dri/intel | |
parent | ea05e259c9490657a5062480a06ff1cd1b924043 (diff) |
swrast: Always use MapTextureImage for mapping textures for swrast.
Now that everything goes through ImageSlices[], we can rely on the
driver's existing texture mapping function.
A big block of code goes away on Radeon that looks like it was to deal with
the validate that happened at SpanRenderStart, which no longer occurs since we
don't need validation for the MapTextureImage hook.
v2: Rewrite comment about ImageSlices, fix duplicated swImages, touch up
unmap loop.
Reviewed-by: Kenneth Graunke <[email protected]> (v1)
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/intel')
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_span.c | 80 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_span.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_tex.h | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_tex_validate.c | 90 |
4 files changed, 5 insertions, 173 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c index d7eaa41241e..e74398d09b8 100644 --- a/src/mesa/drivers/dri/intel/intel_span.c +++ b/src/mesa/drivers/dri/intel/intel_span.c @@ -105,31 +105,8 @@ intel_offset_S8(uint32_t stride, uint32_t x, uint32_t y, bool swizzled) } /** - * Map the regions needed by intelSpanRenderStart(). - */ -static void -intel_span_map_buffers(struct intel_context *intel) -{ - struct gl_context *ctx = &intel->ctx; - struct intel_texture_object *tex_obj; - - for (int i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (!ctx->Texture.Unit[i]._ReallyEnabled) - continue; - tex_obj = intel_texture_object(ctx->Texture.Unit[i]._Current); - intel_finalize_mipmap_tree(intel, i); - intel_tex_map_images(intel, tex_obj, - GL_MAP_READ_BIT | GL_MAP_WRITE_BIT); - } - - _swrast_map_renderbuffers(ctx); -} - -/** * Prepare for software rendering. Map current read/draw framebuffers' - * renderbuffes and all currently bound texture objects. - * - * Old note: Moved locking out to get reasonable span performance. + * renderbuffers and all currently bound texture objects. */ void intelSpanRenderStart(struct gl_context * ctx) @@ -139,7 +116,9 @@ intelSpanRenderStart(struct gl_context * ctx) intel_flush(ctx); intel_prepare_render(intel); intel_flush(ctx); - intel_span_map_buffers(intel); + + _swrast_map_textures(ctx); + _swrast_map_renderbuffers(ctx); } /** @@ -149,18 +128,8 @@ intelSpanRenderStart(struct gl_context * ctx) void intelSpanRenderFinish(struct gl_context * ctx) { - struct intel_context *intel = intel_context(ctx); - GLuint i; - _swrast_flush(ctx); - - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Texture.Unit[i]._ReallyEnabled) { - struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current; - intel_tex_unmap_images(intel, intel_texture_object(texObj)); - } - } - + _swrast_unmap_textures(ctx); _swrast_unmap_renderbuffers(ctx); } @@ -174,42 +143,3 @@ intelInitSpanFuncs(struct gl_context * ctx) swdd->SpanRenderFinish = intelSpanRenderFinish; } } - -void -intel_map_vertex_shader_textures(struct gl_context *ctx) -{ - struct intel_context *intel = intel_context(ctx); - int i; - - if (ctx->VertexProgram._Current == NULL) - return; - - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Texture.Unit[i]._ReallyEnabled && - ctx->VertexProgram._Current->Base.TexturesUsed[i] != 0) { - struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current; - - intel_tex_map_images(intel, intel_texture_object(texObj), - GL_MAP_READ_BIT | GL_MAP_WRITE_BIT); - } - } -} - -void -intel_unmap_vertex_shader_textures(struct gl_context *ctx) -{ - struct intel_context *intel = intel_context(ctx); - int i; - - if (ctx->VertexProgram._Current == NULL) - return; - - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Texture.Unit[i]._ReallyEnabled && - ctx->VertexProgram._Current->Base.TexturesUsed[i] != 0) { - struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current; - - intel_tex_unmap_images(intel, intel_texture_object(texObj)); - } - } -} diff --git a/src/mesa/drivers/dri/intel/intel_span.h b/src/mesa/drivers/dri/intel/intel_span.h index e5218691c65..412f244107a 100644 --- a/src/mesa/drivers/dri/intel/intel_span.h +++ b/src/mesa/drivers/dri/intel/intel_span.h @@ -36,8 +36,6 @@ extern void intelInitSpanFuncs(struct gl_context * ctx); extern void intelSpanRenderFinish(struct gl_context * ctx); extern void intelSpanRenderStart(struct gl_context * ctx); -void intel_map_vertex_shader_textures(struct gl_context *ctx); -void intel_unmap_vertex_shader_textures(struct gl_context *ctx); intptr_t intel_offset_S8(uint32_t stride, uint32_t x, uint32_t y, bool swizzled); #endif diff --git a/src/mesa/drivers/dri/intel/intel_tex.h b/src/mesa/drivers/dri/intel/intel_tex.h index 0a631630183..e03811546ab 100644 --- a/src/mesa/drivers/dri/intel/intel_tex.h +++ b/src/mesa/drivers/dri/intel/intel_tex.h @@ -64,12 +64,6 @@ void intel_tex_unmap_level_images(struct intel_context *intel, struct intel_texture_object *intelObj, int level); -void intel_tex_map_images(struct intel_context *intel, - struct intel_texture_object *intelObj, - GLbitfield mode); - -void intel_tex_unmap_images(struct intel_context *intel, - struct intel_texture_object *intelObj); bool intel_tex_image_s8z24_create_renderbuffers(struct intel_context *intel, struct intel_texture_image *image); diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c index 60687332191..eaa25617bab 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_validate.c +++ b/src/mesa/drivers/dri/intel/intel_tex_validate.c @@ -139,93 +139,3 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit) return true; } - -/** - * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT - */ -static void -intel_tex_map_image_for_swrast(struct intel_context *intel, - struct intel_texture_image *intel_image, - GLbitfield mode) -{ - int level; - int face; - struct intel_mipmap_tree *mt; - unsigned int x, y; - - if (!intel_image || !intel_image->mt) - return; - - level = intel_image->base.Base.Level; - face = intel_image->base.Base.Face; - mt = intel_image->mt; - - for (int i = 0; i < mt->level[level].depth; i++) - intel_miptree_slice_resolve_depth(intel, mt, level, i); - - void *map = intel_miptree_map_raw(intel, mt); - - for (int i = 0; i < mt->level[level].depth; i++) { - intel_miptree_get_image_offset(mt, level, i, &x, &y); - intel_image->base.ImageSlices[i] = (map + - y * mt->region->pitch + - x * mt->cpp); - DBG("%s: (%d,%d,%d) -> (%d, %d)/%d\n", - __FUNCTION__, face, level, i, x, y, mt->region->pitch); - } - - intel_image->base.Map = intel_image->base.ImageSlices[0]; - - assert(mt->region->pitch % mt->region->cpp == 0); - intel_image->base.RowStride = mt->region->pitch / mt->region->cpp; -} - -static void -intel_tex_unmap_image_for_swrast(struct intel_context *intel, - struct intel_texture_image *intel_image) -{ - if (intel_image && intel_image->mt) { - intel_miptree_unmap_raw(intel, intel_image->mt); - intel_image->base.Map = NULL; - } -} - -/** - * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT - */ -void -intel_tex_map_images(struct intel_context *intel, - struct intel_texture_object *intelObj, - GLbitfield mode) -{ - GLuint nr_faces = _mesa_num_tex_faces(intelObj->base.Target); - int i, face; - - DBG("%s\n", __FUNCTION__); - - for (i = intelObj->base.BaseLevel; i <= intelObj->_MaxLevel; i++) { - for (face = 0; face < nr_faces; face++) { - struct intel_texture_image *intel_image = - intel_texture_image(intelObj->base.Image[face][i]); - - intel_tex_map_image_for_swrast(intel, intel_image, mode); - } - } -} - -void -intel_tex_unmap_images(struct intel_context *intel, - struct intel_texture_object *intelObj) -{ - GLuint nr_faces = _mesa_num_tex_faces(intelObj->base.Target); - int i, face; - - for (i = intelObj->base.BaseLevel; i <= intelObj->_MaxLevel; i++) { - for (face = 0; face < nr_faces; face++) { - struct intel_texture_image *intel_image = - intel_texture_image(intelObj->base.Image[face][i]); - - intel_tex_unmap_image_for_swrast(intel, intel_image); - } - } -} |