summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_cb_texture.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-01-22 12:17:02 -0700
committerBrian Paul <brianp@vmware.com>2010-01-22 12:17:02 -0700
commitcd8614b0287dc5a69725ec4ee0208fad61f7789e (patch)
tree3ee089b8384e7a60c5c3a3cc87f2a633bd724bbe /src/mesa/state_tracker/st_cb_texture.c
parent2b20b604277e3cdf7afb2431b50dbb05da12ff1c (diff)
parent64871747bb7b611ffe429fbf1724bd98ee25dd84 (diff)
Merge branch 'mesa_7_7_branch'
Conflicts: src/gallium/auxiliary/draw/draw_context.c src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c src/gallium/auxiliary/pipebuffer/Makefile src/gallium/auxiliary/pipebuffer/SConscript src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c src/gallium/auxiliary/tgsi/tgsi_scan.c src/gallium/drivers/i915/i915_surface.c src/gallium/drivers/i915/i915_texture.c src/gallium/drivers/llvmpipe/lp_setup.c src/gallium/drivers/llvmpipe/lp_tex_sample_c.c src/gallium/drivers/llvmpipe/lp_texture.c src/gallium/drivers/softpipe/sp_prim_vbuf.c src/gallium/state_trackers/xorg/xorg_dri2.c src/gallium/winsys/drm/intel/gem/intel_drm_api.c src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c src/gallium/winsys/drm/radeon/core/radeon_drm.c src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c src/mesa/state_tracker/st_cb_clear.c
Diffstat (limited to 'src/mesa/state_tracker/st_cb_texture.c')
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c58
1 files changed, 44 insertions, 14 deletions
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index f01053cdac..b94bfc8538 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -31,15 +31,14 @@
#include "main/convolve.h"
#endif
#include "main/enums.h"
+#include "main/fbobject.h"
#include "main/formats.h"
#include "main/image.h"
#include "main/imports.h"
#include "main/macros.h"
#include "main/mipmap.h"
-#include "main/pixel.h"
#include "main/texcompress.h"
#include "main/texfetch.h"
-#include "main/texformat.h"
#include "main/texgetimage.h"
#include "main/teximage.h"
#include "main/texobj.h"
@@ -1368,33 +1367,64 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level,
}
+
+/**
+ * If the format of the src renderbuffer and the format of the dest
+ * texture are compatible (in terms of blitting), return a TGSI writemask
+ * to be used during the blit.
+ * If the src/dest are incompatible, return 0.
+ */
static unsigned
-compatible_src_dst_formats(const struct gl_renderbuffer *src,
+compatible_src_dst_formats(GLcontext *ctx,
+ const struct gl_renderbuffer *src,
const struct gl_texture_image *dst)
{
- const GLenum srcFormat = _mesa_get_format_base_format(src->Format);
- const GLenum dstLogicalFormat = _mesa_get_format_base_format(dst->TexFormat);
+ /* Get logical base formats for the src and dest.
+ * That is, use the user-requested formats and not the actual, device-
+ * chosen formats.
+ * For example, the user may have requested an A8 texture but the
+ * driver may actually be using an RGBA texture format. When we
+ * copy/blit to that texture, we only want to copy the Alpha channel
+ * and not the RGB channels.
+ *
+ * Similarly, when the src FBO was created an RGB format may have been
+ * requested but the driver actually chose an RGBA format. In that case,
+ * we don't want to copy the undefined Alpha channel to the dest texture
+ * (it should be 1.0).
+ */
+ const GLenum srcFormat = _mesa_base_fbo_format(ctx, src->InternalFormat);
+ const GLenum dstFormat = _mesa_base_tex_format(ctx, dst->InternalFormat);
- if (srcFormat == dstLogicalFormat) {
+ /**
+ * XXX when we have red-only and red/green renderbuffers we'll need
+ * to add more cases here (or implement a general-purpose routine that
+ * queries the existance of the R,G,B,A channels in the src and dest).
+ */
+ if (srcFormat == dstFormat) {
/* This is the same as matching_base_formats, which should
* always pass, as it did previously.
*/
return TGSI_WRITEMASK_XYZW;
}
- else if (srcFormat == GL_RGBA &&
- dstLogicalFormat == GL_RGB) {
- /* Add a single special case to cope with RGBA->RGB transfers,
- * setting A to 1.0 to cope with situations where the RGB
- * destination is actually stored as RGBA.
+ else if (srcFormat == GL_RGB && dstFormat == GL_RGBA) {
+ /* Make sure that A in the dest is 1. The actual src format
+ * may be RGBA and have undefined A values.
+ */
+ return TGSI_WRITEMASK_XYZ;
+ }
+ else if (srcFormat == GL_RGBA && dstFormat == GL_RGB) {
+ /* Make sure that A in the dest is 1. The actual dst format
+ * may be RGBA and will need A=1 to provide proper alpha values
+ * when sampled later.
*/
- return TGSI_WRITEMASK_XYZ; /* A ==> 1.0 */
+ return TGSI_WRITEMASK_XYZ;
}
else {
if (ST_DEBUG & DEBUG_FALLBACK)
debug_printf("%s failed for src %s, dst %s\n",
__FUNCTION__,
_mesa_lookup_enum_by_nr(srcFormat),
- _mesa_lookup_enum_by_nr(dstLogicalFormat));
+ _mesa_lookup_enum_by_nr(dstFormat));
/* Otherwise fail.
*/
@@ -1505,7 +1535,7 @@ st_copy_texsubimage(GLcontext *ctx,
matching_base_formats =
(_mesa_get_format_base_format(strb->Base.Format) ==
_mesa_get_format_base_format(texImage->TexFormat));
- format_writemask = compatible_src_dst_formats(&strb->Base, texImage);
+ format_writemask = compatible_src_dst_formats(ctx, &strb->Base, texImage);
if (ctx->_ImageTransferState == 0x0) {