[Mesa-dev] [PATCH 05/16] intel: Make PBO TexImage use AllocTextureImageBuffer like non-PBO does.
Eric Anholt
eric at anholt.net
Thu Sep 29 15:39:56 PDT 2011
Now that whole block that also lives in AllocTextureImageBuffer can go
away.
---
src/mesa/drivers/dri/intel/intel_tex.c | 6 ++
src/mesa/drivers/dri/intel/intel_tex_image.c | 68 +++++--------------------
2 files changed, 20 insertions(+), 54 deletions(-)
diff --git a/src/mesa/drivers/dri/intel/intel_tex.c b/src/mesa/drivers/dri/intel/intel_tex.c
index ba1e364..2b4047f 100644
--- a/src/mesa/drivers/dri/intel/intel_tex.c
+++ b/src/mesa/drivers/dri/intel/intel_tex.c
@@ -60,6 +60,12 @@ intel_alloc_texture_image_buffer(struct gl_context *ctx,
struct gl_texture_object *texobj = image->TexObject;
struct intel_texture_object *intel_texobj = intel_texture_object(texobj);
+ /* Because the driver uses AllocTextureImageBuffer() internally, it may end
+ * up mismatched with FreeTextureImageBuffer(), but that is safe to call
+ * multiple times.
+ */
+ ctx->Driver.FreeTextureImageBuffer(ctx, image);
+
if (intel->must_use_separate_stencil
&& image->TexFormat == MESA_FORMAT_S8_Z24) {
intel_tex_image_s8z24_create_renderbuffers(intel, intel_image);
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 8c87a25..62dc18d 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -146,12 +146,14 @@ check_pbo_format(GLenum format, GLenum type,
/* XXX: Do this for TexSubImage also:
*/
static bool
-try_pbo_upload(struct intel_context *intel,
- struct intel_texture_image *intelImage,
+try_pbo_upload(struct gl_context *ctx,
+ struct gl_texture_image *image,
const struct gl_pixelstore_attrib *unpack,
GLenum format, GLenum type,
GLint width, GLint height, const void *pixels)
{
+ struct intel_texture_image *intelImage = intel_texture_image(image);
+ struct intel_context *intel = intel_context(ctx);
struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);
GLuint src_offset, src_stride;
GLuint dst_x, dst_y, dst_stride;
@@ -162,11 +164,6 @@ try_pbo_upload(struct intel_context *intel,
DBG("trying pbo upload\n");
- if (!intelImage->mt) {
- DBG("%s: no miptree\n", __FUNCTION__);
- return false;
- }
-
if (intel->ctx._ImageTransferState ||
unpack->SkipPixels || unpack->SkipRows) {
DBG("%s: image transfer\n", __FUNCTION__);
@@ -180,6 +177,14 @@ try_pbo_upload(struct intel_context *intel,
return false;
}
+ ctx->Driver.AllocTextureImageBuffer(ctx, image, image->TexFormat,
+ width, height, 1);
+
+ if (!intelImage->mt) {
+ DBG("%s: no miptree\n", __FUNCTION__);
+ return false;
+ }
+
dst_buffer = intelImage->mt->region->bo;
src_buffer = intel_bufferobj_source(intel, pbo, 64, &src_offset);
/* note: potential 64-bit ptr to 32-bit int cast */
@@ -349,63 +354,18 @@ intelTexImage(struct gl_context * ctx,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage, GLsizei imageSize)
{
- struct intel_context *intel = intel_context(ctx);
- struct intel_texture_object *intelObj = intel_texture_object(texObj);
- struct intel_texture_image *intelImage = intel_texture_image(texImage);
- GLint texelBytes;
- GLuint dstRowStride = 0;
-
DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__,
_mesa_lookup_enum_by_nr(target), level, width, height, depth, border);
- if (_mesa_is_format_compressed(texImage->TexFormat)) {
- texelBytes = 0;
- }
- else {
- texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
-
- if (!intelImage->mt) {
- assert(texImage->RowStride == width);
- }
- }
-
- if (intelObj->mt &&
- intel_miptree_match_image(intelObj->mt, &intelImage->base.Base)) {
- /* Use an existing miptree when possible */
- intel_miptree_reference(&intelImage->mt, intelObj->mt);
- assert(intelImage->mt);
- } else if (intelImage->base.Base.Border == 0) {
- /* Didn't fit in the object miptree, but it's suitable for inclusion in
- * a miptree, so create one just for our level and store it in the image.
- * It'll get moved into the object miptree at validate time.
- */
- intelImage->mt = intel_miptree_create_for_teximage(intel, intelObj,
- intelImage,
- pixels == NULL);
-
- /* Even if the object currently has a mipmap tree associated
- * with it, this one is a more likely candidate to represent the
- * whole object since our level didn't fit what was there
- * before, and any lower levels would fit into our miptree.
- */
- intel_miptree_reference(&intelObj->mt, intelImage->mt);
- } else {
- /* Allocate fallback texImage->Data storage through swrast. */
- ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
- width, height, depth);
- }
-
/* Attempt to use the blitter for PBO image uploads.
*/
if (dims <= 2 &&
- try_pbo_upload(intel, intelImage, unpack, format, type,
+ try_pbo_upload(ctx, texImage, unpack, format, type,
width, height, pixels)) {
return;
}
- DBG("Upload image %dx%dx%d row_len %d pitch %d pixels %d\n",
- width, height, depth, width * texelBytes, dstRowStride,
- pixels ? 1 : 0);
+ DBG("Upload image %dx%dx%d pixels %p\n", width, height, depth, pixels);
if (pixels || _mesa_is_bufferobj(unpack->BufferObj)) {
_mesa_store_teximage3d(ctx, target, level, internalFormat,
--
1.7.6.3
More information about the mesa-dev
mailing list