summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2011-12-29 06:36:55 -0700
committerBrian Paul <[email protected]>2012-01-07 15:04:23 -0700
commit56b57aa360a8bad0c4b68fbdf7c64ac33f9e7661 (patch)
treea448d03e61122b0c68aaac023a3004f1144e1b8f /src/mesa/drivers/dri
parent4c0f1fb5ec6117f07c9c911d7f74ff0d18c51d98 (diff)
mesa: rework ctx->Driver.CopyTexSubImage() parameters
Replace target, level parameters with gl_texture_image. Add gl_renderbuffer parameter to indicate source buffer for the copy. This removes some redundant code in the drivers to find the source renderbuffer and the destination texture image (which we already had in _mesa_CopyTexSubImage). Signed-off-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r--src/mesa/drivers/dri/intel/intel_fbo.c5
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex.h11
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_copy.c67
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_tex_copy.c45
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_texture.h10
5 files changed, 57 insertions, 81 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index ecb4a86b243..b95193d2b6e 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -854,13 +854,15 @@ intel_blit_framebuffer_copy_tex_sub_image(struct gl_context *ctx,
const struct gl_framebuffer *readFb = ctx->ReadBuffer;
const struct gl_renderbuffer_attachment *drawAtt =
&drawFb->Attachment[drawFb->_ColorDrawBufferIndexes[0]];
+ struct intel_renderbuffer *srcRb =
+ intel_renderbuffer(readFb->_ColorReadBuffer);
/* If the source and destination are the same size with no
mirroring, the rectangles are within the size of the
texture and there is no scissor then we can use
glCopyTexSubimage2D to implement the blit. This will end
up as a fast hardware blit on some drivers */
- if (drawAtt && drawAtt->Texture &&
+ if (srcRb && drawAtt && drawAtt->Texture &&
srcX0 - srcX1 == dstX0 - dstX1 &&
srcY0 - srcY1 == dstY0 - dstY1 &&
srcX1 >= srcX0 &&
@@ -880,6 +882,7 @@ intel_blit_framebuffer_copy_tex_sub_image(struct gl_context *ctx,
if (intel_copy_texsubimage(intel_context(ctx),
intel_texture_image(texImage),
dstX0, dstY0,
+ srcRb,
srcX0, srcY0,
srcX1 - srcX0, /* width */
srcY1 - srcY0))
diff --git a/src/mesa/drivers/dri/intel/intel_tex.h b/src/mesa/drivers/dri/intel/intel_tex.h
index 42a37e67b48..88a7d55414a 100644
--- a/src/mesa/drivers/dri/intel/intel_tex.h
+++ b/src/mesa/drivers/dri/intel/intel_tex.h
@@ -32,6 +32,8 @@
#include "main/formats.h"
#include "intel_context.h"
+struct intel_renderbuffer;
+
void intelInitTextureFuncs(struct dd_function_table *functions);
void intelInitTextureImageFuncs(struct dd_function_table *functions);
@@ -77,9 +79,10 @@ intel_tex_image_s8z24_create_renderbuffers(struct intel_context *intel,
int intel_compressed_num_bytes(GLuint mesaFormat);
bool intel_copy_texsubimage(struct intel_context *intel,
- struct intel_texture_image *intelImage,
- GLint dstx, GLint dsty,
- GLint x, GLint y,
- GLsizei width, GLsizei height);
+ struct intel_texture_image *intelImage,
+ GLint dstx, GLint dsty,
+ struct intel_renderbuffer *irb,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height);
#endif
diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c
index 543326a0580..b6e29f78de6 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_copy.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c
@@ -43,34 +43,15 @@
#define FILE_DEBUG_FLAG DEBUG_TEXTURE
-/**
- * Get the intel_region which is the source for any glCopyTex[Sub]Image call.
- *
- * Do the best we can using the blitter. A future project is to use
- * the texture engine and fragment programs for these copies.
- */
-static struct intel_renderbuffer *
-get_teximage_readbuffer(struct intel_context *intel, GLenum internalFormat)
-{
- DBG("%s %s\n", __FUNCTION__,
- _mesa_lookup_enum_by_nr(internalFormat));
-
- if (_mesa_is_depth_format(internalFormat) ||
- _mesa_is_depthstencil_format(internalFormat))
- return intel_get_renderbuffer(intel->ctx.ReadBuffer, BUFFER_DEPTH);
-
- return intel_renderbuffer(intel->ctx.ReadBuffer->_ColorReadBuffer);
-}
-
bool
intel_copy_texsubimage(struct intel_context *intel,
struct intel_texture_image *intelImage,
GLint dstx, GLint dsty,
+ struct intel_renderbuffer *irb,
GLint x, GLint y, GLsizei width, GLsizei height)
{
struct gl_context *ctx = &intel->ctx;
- struct intel_renderbuffer *irb;
struct intel_region *region;
const GLenum internalFormat = intelImage->base.Base.InternalFormat;
bool copy_supported = false;
@@ -78,7 +59,6 @@ intel_copy_texsubimage(struct intel_context *intel,
intel_prepare_render(intel);
- irb = get_teximage_readbuffer(intel, internalFormat);
if (!intelImage->mt || !irb || !irb->mt) {
if (unlikely(INTEL_DEBUG & DEBUG_FALLBACKS))
fprintf(stderr, "%s fail %p %p (0x%08x)\n",
@@ -164,49 +144,38 @@ intel_copy_texsubimage(struct intel_context *intel,
static void
-intelCopyTexSubImage1D(struct gl_context * ctx, GLenum target, GLint level,
- GLint xoffset, GLint x, GLint y, GLsizei width)
+intelCopyTexSubImage1D(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLint xoffset,
+ struct gl_renderbuffer *rb,
+ GLint x, GLint y, GLsizei width)
{
- struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
- struct gl_texture_object *texObj =
- _mesa_select_tex_object(ctx, texUnit, target);
- struct gl_texture_image *texImage =
- _mesa_select_tex_image(ctx, texObj, target, level);
-
- /* XXX need to check <border> as in above function? */
-
- /* Need to check texture is compatible with source format.
- */
-
if (!intel_copy_texsubimage(intel_context(ctx),
intel_texture_image(texImage),
- xoffset, 0, x, y, width, 1)) {
+ xoffset, 0,
+ intel_renderbuffer(rb), x, y, width, 1)) {
fallback_debug("%s - fallback to swrast\n", __FUNCTION__);
- _mesa_meta_CopyTexSubImage1D(ctx, target, level, xoffset, x, y, width);
+ _mesa_meta_CopyTexSubImage1D(ctx, texImage, xoffset,
+ rb, x, y, width);
}
}
static void
-intelCopyTexSubImage2D(struct gl_context * ctx, GLenum target, GLint level,
+intelCopyTexSubImage2D(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset,
+ struct gl_renderbuffer *rb,
GLint x, GLint y, GLsizei width, GLsizei height)
{
- struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
- struct gl_texture_object *texObj =
- _mesa_select_tex_object(ctx, texUnit, target);
- struct gl_texture_image *texImage =
- _mesa_select_tex_image(ctx, texObj, target, level);
-
- /* Need to check texture is compatible with source format.
- */
-
if (!intel_copy_texsubimage(intel_context(ctx),
intel_texture_image(texImage),
- xoffset, yoffset, x, y, width, height)) {
+ xoffset, yoffset,
+ intel_renderbuffer(rb), x, y, width, height)) {
fallback_debug("%s - fallback to swrast\n", __FUNCTION__);
- _mesa_meta_CopyTexSubImage2D(ctx, target, level,
- xoffset, yoffset, x, y, width, height);
+ _mesa_meta_CopyTexSubImage2D(ctx, texImage,
+ xoffset, yoffset,
+ rb, x, y, width, height);
}
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_tex_copy.c b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c
index 76ca8e6b27d..726692ef241 100644
--- a/src/mesa/drivers/dri/radeon/radeon_tex_copy.c
+++ b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c
@@ -38,15 +38,16 @@
static GLboolean
do_copy_texsubimage(struct gl_context *ctx,
- GLenum target, GLint level,
struct radeon_tex_obj *tobj,
radeon_texture_image *timg,
GLint dstx, GLint dsty,
+ struct radeon_renderbuffer *rrb,
GLint x, GLint y,
GLsizei width, GLsizei height)
{
radeonContextPtr radeon = RADEON_CONTEXT(ctx);
- struct radeon_renderbuffer *rrb;
+ const GLuint face = timg->base.Base.Face;
+ const GLuint level = timg->base.Base.Level;
unsigned src_bpp;
unsigned dst_bpp;
gl_format src_mesaformat;
@@ -57,22 +58,19 @@ do_copy_texsubimage(struct gl_context *ctx,
return GL_FALSE;
}
+ // This is software renderbuffer, fallback to swrast
+ if (!rrb) {
+ return GL_FALSE;
+ }
+
if (_mesa_get_format_bits(timg->base.Base.TexFormat, GL_DEPTH_BITS) > 0) {
- /* copying a depth values */
- rrb = radeon_renderbuffer(ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer);
- assert(rrb);
+ /* copying depth values */
flip_y = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Type == GL_NONE;
} else {
/* copying color */
- rrb = radeon_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
flip_y = ctx->ReadBuffer->Attachment[BUFFER_COLOR0].Type == GL_NONE;
}
- // This is software renderbuffer, fallback to swrast
- if (!rrb) {
- return GL_FALSE;
- }
-
if (!timg->mt) {
radeon_validate_texture_miptree(ctx, &tobj->base);
}
@@ -84,11 +82,11 @@ do_copy_texsubimage(struct gl_context *ctx,
assert(timg->base.Base.Height >= dsty + height);
intptr_t src_offset = rrb->draw_offset;
- intptr_t dst_offset = radeon_miptree_image_offset(timg->mt, _mesa_tex_target_to_face(target), level);
+ intptr_t dst_offset = radeon_miptree_image_offset(timg->mt, face, level);
if (0) {
fprintf(stderr, "%s: copying to face %d, level %d\n",
- __FUNCTION__, _mesa_tex_target_to_face(target), level);
+ __FUNCTION__, face, level);
fprintf(stderr, "to: x %d, y %d, offset %d\n", dstx, dsty, (uint32_t) dst_offset);
fprintf(stderr, "from (%dx%d) width %d, height %d, offset %d, pitch %d\n",
x, y, rrb->base.Width, rrb->base.Height, (uint32_t) src_offset, rrb->pitch/rrb->cpp);
@@ -136,26 +134,27 @@ do_copy_texsubimage(struct gl_context *ctx,
}
void
-radeonCopyTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level,
+radeonCopyTexSubImage2D(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset,
+ struct gl_renderbuffer *rb,
GLint x, GLint y,
GLsizei width, GLsizei height)
{
- struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
- struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target);
- struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level);
-
radeonContextPtr radeon = RADEON_CONTEXT(ctx);
radeon_prepare_render(radeon);
- if (!do_copy_texsubimage(ctx, target, level,
- radeon_tex_obj(texObj), (radeon_texture_image *)texImage,
- xoffset, yoffset, x, y, width, height)) {
+ if (!do_copy_texsubimage(ctx,
+ radeon_tex_obj(texImage->TexObject),
+ (radeon_texture_image *)texImage,
+ xoffset, yoffset,
+ radeon_renderbuffer(rb), x, y, width, height)) {
radeon_print(RADEON_FALLBACKS, RADEON_NORMAL,
"Falling back to sw for glCopyTexSubImage2D\n");
- _mesa_meta_CopyTexSubImage2D(ctx, target, level,
- xoffset, yoffset, x, y, width, height);
+ _mesa_meta_CopyTexSubImage2D(ctx, texImage,
+ xoffset, yoffset,
+ rb, x, y, width, height);
}
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.h b/src/mesa/drivers/dri/radeon/radeon_texture.h
index c1e5360ff4e..6cca011bf2f 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.h
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.h
@@ -65,10 +65,12 @@ gl_format radeonChooseTextureFormat(struct gl_context * ctx,
GLenum format,
GLenum type, GLboolean fbo);
-void radeonCopyTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLint x, GLint y,
- GLsizei width, GLsizei height);
+void radeonCopyTexSubImage2D(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset,
+ struct gl_renderbuffer *rb,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height);
unsigned radeonIsFormatRenderable(gl_format mesa_format);