mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 15:38:09 +02:00
intel: Rebuild PBO blit glTexImage() on top of miptrees.
This will ensure that we have resolves if we ever extend this to glTexSubImage(), and fixes missing image start offset handling. The texture buffer alloc ended up getting moved up, because we want to look at the format of the image's actual mt to see if we'll end up blitting the right thing, in the case of packed depth/stencil uploads. This is the last caller of intelEmitCopyBlit() on a miptree-wrapped BO. Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com> Acked-by: Paul Berry <stereotype441@gmail.com>
This commit is contained in:
parent
3c3e83014b
commit
5f29dca070
1 changed files with 30 additions and 28 deletions
|
|
@ -6,6 +6,7 @@
|
|||
#include "main/bufferobj.h"
|
||||
#include "main/context.h"
|
||||
#include "main/formats.h"
|
||||
#include "main/image.h"
|
||||
#include "main/pbo.h"
|
||||
#include "main/renderbuffer.h"
|
||||
#include "main/texcompress.h"
|
||||
|
|
@ -117,9 +118,8 @@ try_pbo_upload(struct gl_context *ctx,
|
|||
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;
|
||||
drm_intel_bo *dst_buffer, *src_buffer;
|
||||
GLuint src_offset;
|
||||
drm_intel_bo *src_buffer;
|
||||
|
||||
if (!_mesa_is_bufferobj(unpack->BufferObj))
|
||||
return false;
|
||||
|
|
@ -132,14 +132,6 @@ try_pbo_upload(struct gl_context *ctx,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!_mesa_format_matches_format_and_type(image->TexFormat,
|
||||
format, type, false)) {
|
||||
DBG("%s: format mismatch (upload to %s with format 0x%x, type 0x%x)\n",
|
||||
__FUNCTION__, _mesa_get_format_name(image->TexFormat),
|
||||
format, type);
|
||||
return false;
|
||||
}
|
||||
|
||||
ctx->Driver.AllocTextureImageBuffer(ctx, image);
|
||||
|
||||
if (!intelImage->mt) {
|
||||
|
|
@ -147,39 +139,49 @@ try_pbo_upload(struct gl_context *ctx,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!_mesa_format_matches_format_and_type(intelImage->mt->format,
|
||||
format, type, false)) {
|
||||
DBG("%s: format mismatch (upload to %s with format 0x%x, type 0x%x)\n",
|
||||
__FUNCTION__, _mesa_get_format_name(intelImage->mt->format),
|
||||
format, type);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (image->TexObject->Target == GL_TEXTURE_1D_ARRAY ||
|
||||
image->TexObject->Target == GL_TEXTURE_2D_ARRAY) {
|
||||
DBG("%s: no support for array textures\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 */
|
||||
src_offset += (GLuint) (unsigned long) pixels;
|
||||
|
||||
if (unpack->RowLength > 0)
|
||||
src_stride = unpack->RowLength;
|
||||
else
|
||||
src_stride = image->Width;
|
||||
src_stride *= intelImage->mt->region->cpp;
|
||||
int src_stride =
|
||||
_mesa_image_row_stride(unpack, image->Width, format, type);
|
||||
|
||||
intel_miptree_get_image_offset(intelImage->mt, intelImage->base.Base.Level,
|
||||
intelImage->base.Base.Face,
|
||||
&dst_x, &dst_y);
|
||||
struct intel_mipmap_tree *pbo_mt =
|
||||
intel_miptree_create_for_bo(intel,
|
||||
src_buffer,
|
||||
intelImage->mt->format,
|
||||
src_offset,
|
||||
image->Width, image->Height,
|
||||
src_stride, I915_TILING_NONE);
|
||||
if (!pbo_mt)
|
||||
return false;
|
||||
|
||||
if (!intelEmitCopyBlit(intel,
|
||||
intelImage->mt->cpp,
|
||||
src_stride, src_buffer,
|
||||
src_offset, false,
|
||||
intelImage->mt->region->pitch, dst_buffer, 0,
|
||||
intelImage->mt->region->tiling,
|
||||
0, 0, dst_x, dst_y, image->Width, image->Height,
|
||||
GL_COPY)) {
|
||||
if (!intel_miptree_blit(intel,
|
||||
pbo_mt, 0, 0,
|
||||
0, 0, false,
|
||||
intelImage->mt, image->Level, image->Face,
|
||||
0, 0, false,
|
||||
image->Width, image->Height, GL_COPY)) {
|
||||
DBG("%s: blit failed\n", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
|
||||
intel_miptree_release(&pbo_mt);
|
||||
|
||||
DBG("%s: success\n", __FUNCTION__);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue