From 2b1d5ea4f0250a6a7fa312ced0a7af85e909381b Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Tue, 19 Jan 2010 01:42:41 -0500 Subject: [PATCH] r100/r200/r600: check if blitting for given format is supported earlier based on Maciej's r300 patch. --- src/mesa/drivers/dri/r200/r200_blit.c | 25 +++++++++- src/mesa/drivers/dri/r600/r600_blit.c | 59 ++++++++++++++++++++++- src/mesa/drivers/dri/radeon/radeon_blit.c | 25 +++++++++- 3 files changed, 105 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c index 2b3b165c5ff..27f18e07387 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.c +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -37,6 +37,29 @@ static inline uint32_t cmdpacket0(struct radeon_screen *rscrn, return CP_PACKET2; } +/* common formats supported as both textures and render targets */ +static unsigned is_blit_supported(gl_format mesa_format) +{ + /* XXX others? BE/LE? */ + switch (mesa_format) { + case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_XRGB8888: + case MESA_FORMAT_RGB565: + case MESA_FORMAT_ARGB4444: + case MESA_FORMAT_ARGB1555: + case MESA_FORMAT_A8: + break; + default: + return 0; + } + + /* ??? */ + if (_mesa_get_format_bits(mesa_format, GL_DEPTH_BITS) > 0) + return 0; + + return 1; +} + static inline void emit_vtx_state(struct r200_context *r200) { BATCH_LOCALS(&r200->radeon); @@ -309,7 +332,7 @@ GLboolean r200_blit(struct r200_context *r200, unsigned reg_height, unsigned flip_y) { - if (_mesa_get_format_bits(src_mesaformat, GL_DEPTH_BITS) > 0) + if (is_blit_supported(dst_mesaformat)) return GL_FALSE; /* Make sure that colorbuffer has even width - hw limitation */ diff --git a/src/mesa/drivers/dri/r600/r600_blit.c b/src/mesa/drivers/dri/r600/r600_blit.c index a75b1003cbc..1e87d3d7c80 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.c +++ b/src/mesa/drivers/dri/r600/r600_blit.c @@ -32,6 +32,62 @@ #include "r600_blit_shaders.h" #include "r600_cmdbuf.h" +/* common formats supported as both textures and render targets */ +static unsigned is_blit_supported(gl_format mesa_format) +{ + switch (mesa_format) { + case MESA_FORMAT_RGBA8888: + case MESA_FORMAT_SIGNED_RGBA8888: + case MESA_FORMAT_RGBA8888_REV: + case MESA_FORMAT_SIGNED_RGBA8888_REV: + case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_XRGB8888: + case MESA_FORMAT_ARGB8888_REV: + case MESA_FORMAT_XRGB8888_REV: + case MESA_FORMAT_RGB565: + case MESA_FORMAT_RGB565_REV: + case MESA_FORMAT_ARGB4444: + case MESA_FORMAT_ARGB4444_REV: + case MESA_FORMAT_ARGB1555: + case MESA_FORMAT_ARGB1555_REV: + case MESA_FORMAT_AL88: + case MESA_FORMAT_AL88_REV: + case MESA_FORMAT_RGB332: + case MESA_FORMAT_A8: + case MESA_FORMAT_I8: + case MESA_FORMAT_CI8: + case MESA_FORMAT_L8: + case MESA_FORMAT_RGBA_FLOAT32: + case MESA_FORMAT_RGBA_FLOAT16: + case MESA_FORMAT_ALPHA_FLOAT32: + case MESA_FORMAT_ALPHA_FLOAT16: + case MESA_FORMAT_LUMINANCE_FLOAT32: + case MESA_FORMAT_LUMINANCE_FLOAT16: + case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32: + case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16: + case MESA_FORMAT_INTENSITY_FLOAT32: /* X, X, X, X */ + case MESA_FORMAT_INTENSITY_FLOAT16: /* X, X, X, X */ + case MESA_FORMAT_X8_Z24: + case MESA_FORMAT_S8_Z24: + case MESA_FORMAT_Z24_S8: + case MESA_FORMAT_Z16: + case MESA_FORMAT_Z32: + case MESA_FORMAT_SRGBA8: + case MESA_FORMAT_SLA8: + case MESA_FORMAT_SL8: + break; + default: + return 0; + } + + /* ??? */ + /* not sure blit to depth works or not yet */ + if (_mesa_get_format_bits(mesa_format, GL_DEPTH_BITS) > 0) + return 0; + + return 1; +} + static inline void set_render_target(context_t *context, struct radeon_bo *bo, gl_format mesa_format, int pitch, int w, int h, intptr_t dst_offset) @@ -1526,8 +1582,7 @@ GLboolean r600_blit(context_t *context, { int id = 0; - /* not sure blit to depth works or not yet */ - if (_mesa_get_format_bits(src_mesaformat, GL_DEPTH_BITS) > 0) + if (is_blit_supported(dst_mesaformat)) return GL_FALSE; if (src_bo == dst_bo) { diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c index bc46018255d..d9343b30641 100644 --- a/src/mesa/drivers/dri/radeon/radeon_blit.c +++ b/src/mesa/drivers/dri/radeon/radeon_blit.c @@ -37,6 +37,29 @@ static inline uint32_t cmdpacket0(struct radeon_screen *rscrn, return CP_PACKET2; } +/* common formats supported as both textures and render targets */ +static unsigned is_blit_supported(gl_format mesa_format) +{ + /* XXX others? BE/LE? */ + switch (mesa_format) { + case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_XRGB8888: + case MESA_FORMAT_RGB565: + case MESA_FORMAT_ARGB4444: + case MESA_FORMAT_ARGB1555: + case MESA_FORMAT_A8: + break; + default: + return 0; + } + + /* ??? */ + if (_mesa_get_format_bits(mesa_format, GL_DEPTH_BITS) > 0) + return 0; + + return 1; +} + static inline void emit_vtx_state(struct r100_context *r100) { BATCH_LOCALS(&r100->radeon); @@ -305,7 +328,7 @@ GLboolean r100_blit(struct r100_context *r100, unsigned reg_height, unsigned flip_y) { - if (_mesa_get_format_bits(src_mesaformat, GL_DEPTH_BITS) > 0) + if (is_blit_supported(dst_mesaformat)) return GL_FALSE; /* Make sure that colorbuffer has even width - hw limitation */ -- 2.30.2