diff options
author | Morgan Armand <[email protected]> | 2011-12-07 21:30:48 +0100 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2012-01-03 16:19:08 +0000 |
commit | e763b6e78825f11aa3e9e2368ba8fc47313a7848 (patch) | |
tree | f3bebf70b127e91378c52ebc3c070a3e8f09cb8e /src | |
parent | 2ae591bdf13f02f23471ea302b55eaccbb810dd7 (diff) |
softpipe: remove the 32bits limitation on depth(-stencil) formats
This patch remove the 32bits limitation. As a side effect, it bring the support for the GL_ARB_depth_buffer_float extension.
No regression have been found on piglit, and all tests for GL_ARB_depth_buffer_float pass successfully.
Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/auxiliary/util/u_tile.c | 28 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_clear.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_quad_depth_test.c | 44 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_screen.c | 13 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tile_cache.c | 18 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tile_cache.h | 5 |
6 files changed, 91 insertions, 21 deletions
diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 02bdb731d38..357e896ade7 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -344,6 +344,31 @@ z32f_x24s8_get_tile_rgba(const float *src, } } +/*** PIPE_FORMAT_X32_S8X24_UINT ***/ + +/** + * Return S component as four uint32_t in [0..255]. Z part ignored. + */ +static void +x32_s8_get_tile_rgba(const unsigned *src, + unsigned w, unsigned h, + float *p, + unsigned dst_stride) +{ + unsigned i, j; + + for (i = 0; i < h; i++) { + float *pRow = p; + for (j = 0; j < w; j++, pRow += 4) { + src++; + pRow[0] = + pRow[1] = + pRow[2] = + pRow[3] = (float)(*src++ & 0xff); + } + p += dst_stride; + } +} void pipe_tile_raw_to_rgba(enum pipe_format format, @@ -381,6 +406,9 @@ pipe_tile_raw_to_rgba(enum pipe_format format, case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: z32f_x24s8_get_tile_rgba((float *) src, w, h, dst, dst_stride); break; + case PIPE_FORMAT_X32_S8X24_UINT: + x32_s8_get_tile_rgba((float *) src, w, h, dst, dst_stride); + break; default: util_format_read_4f(format, dst, dst_stride * sizeof(float), diff --git a/src/gallium/drivers/softpipe/sp_clear.c b/src/gallium/drivers/softpipe/sp_clear.c index b59524a2214..dd6bd833e61 100644 --- a/src/gallium/drivers/softpipe/sp_clear.c +++ b/src/gallium/drivers/softpipe/sp_clear.c @@ -50,7 +50,7 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, double depth, unsigned stencil) { struct softpipe_context *softpipe = softpipe_context(pipe); - unsigned cv; + uint64_t cv; uint i; if (softpipe->no_rast) @@ -73,7 +73,7 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, static const union pipe_color_union zero; struct pipe_surface *ps = softpipe->framebuffer.zsbuf; - cv = util_pack_z_stencil(ps->format, depth, stencil); + cv = util_pack64_z_stencil(ps->format, depth, stencil); sp_tile_cache_clear(softpipe->zsbuf_cache, &zero, cv); } diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c index 4cf378e68e4..529a5ad5a4e 100644 --- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c +++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c @@ -32,6 +32,7 @@ #include "pipe/p_defines.h" #include "util/u_format.h" +#include "util/u_math.h" #include "util/u_memory.h" #include "tgsi/tgsi_scan.h" #include "sp_context.h" @@ -102,6 +103,21 @@ get_depth_stencil_values( struct depth_data *data, data->stencilVals[j] = tile->data.stencil8[y][x]; } break; + case PIPE_FORMAT_Z32_FLOAT: + for (j = 0; j < QUAD_SIZE; j++) { + int x = quad->input.x0 % TILE_SIZE + (j & 1); + int y = quad->input.y0 % TILE_SIZE + (j >> 1); + data->bzzzz[j] = tile->data.depth32[y][x]; + } + break; + case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: + for (j = 0; j < QUAD_SIZE; j++) { + int x = quad->input.x0 % TILE_SIZE + (j & 1); + int y = quad->input.y0 % TILE_SIZE + (j >> 1); + data->bzzzz[j] = tile->data.depth64[y][x] & 0xffffffff; + data->stencilVals[j] = (tile->data.depth64[y][x] >> 32) & 0xff; + } + break; default: assert(0); } @@ -182,6 +198,17 @@ convert_quad_depth( struct depth_data *data, } } break; + case PIPE_FORMAT_Z32_FLOAT: + case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: + { + union fi fui; + + for (j = 0; j < QUAD_SIZE; j++) { + fui.f = quad->output.depth[j]; + data->qzzzz[j] = fui.ui; + } + } + break; default: assert(0); } @@ -207,6 +234,8 @@ convert_quad_stencil( struct depth_data *data, case PIPE_FORMAT_X8Z24_UNORM: case PIPE_FORMAT_S8_UINT_Z24_UNORM: case PIPE_FORMAT_S8_UINT: + case PIPE_FORMAT_Z32_FLOAT: + case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: for (j = 0; j < QUAD_SIZE; j++) { data->shader_stencil_refs[j] = ((unsigned)(quad->output.stencil[j])); } @@ -272,7 +301,20 @@ write_depth_stencil_values( struct depth_data *data, tile->data.stencil8[y][x] = data->stencilVals[j]; } break; - + case PIPE_FORMAT_Z32_FLOAT: + for (j = 0; j < QUAD_SIZE; j++) { + int x = quad->input.x0 % TILE_SIZE + (j & 1); + int y = quad->input.y0 % TILE_SIZE + (j >> 1); + tile->data.depth32[y][x] = data->bzzzz[j]; + } + break; + case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: + for (j = 0; j < QUAD_SIZE; j++) { + int x = quad->input.x0 % TILE_SIZE + (j & 1); + int y = quad->input.y0 % TILE_SIZE + (j >> 1); + tile->data.depth64[y][x] = (uint64_t)data->bzzzz[j] | ((uint64_t)data->stencilVals[j] << 32); + } + break; default: assert(0); } diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 49e8626b0d4..e58a4867cad 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -250,19 +250,6 @@ softpipe_is_format_supported( struct pipe_screen *screen, if (bind & PIPE_BIND_DEPTH_STENCIL) { if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) return FALSE; - - /* - * TODO: Unfortunately we cannot render into anything more than 32 bits - * because we encode depth and stencil clear values into a 32bit word. - */ - if (format_desc->block.bits > 32) - return FALSE; - - /* - * TODO: eliminate this restriction - */ - if (format == PIPE_FORMAT_Z32_FLOAT) - return FALSE; } /* diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index ad6b0156c7e..659ac58e5b0 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -268,7 +268,7 @@ clear_tile_rgba(struct softpipe_cached_tile *tile, static void clear_tile(struct softpipe_cached_tile *tile, enum pipe_format format, - uint clear_value) + uint64_t clear_value) { uint i, j; @@ -295,7 +295,19 @@ clear_tile(struct softpipe_cached_tile *tile, else { for (i = 0; i < TILE_SIZE; i++) { for (j = 0; j < TILE_SIZE; j++) { - tile->data.color32[i][j] = clear_value; + tile->data.depth32[i][j] = clear_value; + } + } + } + break; + case 8: + if (clear_value == 0) { + memset(tile->data.any, 0, 8 * TILE_SIZE * TILE_SIZE); + } + else { + for (i = 0; i < TILE_SIZE; i++) { + for (j = 0; j < TILE_SIZE; j++) { + tile->data.depth64[i][j] = clear_value; } } } @@ -601,7 +613,7 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc, void sp_tile_cache_clear(struct softpipe_tile_cache *tc, const union pipe_color_union *color, - uint clearValue) + uint64_t clearValue) { uint pos; diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.h b/src/gallium/drivers/softpipe/sp_tile_cache.h index 88d527c3e99..775676b4bf5 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.h +++ b/src/gallium/drivers/softpipe/sp_tile_cache.h @@ -70,6 +70,7 @@ struct softpipe_cached_tile ubyte stencil8[TILE_SIZE][TILE_SIZE]; uint colorui128[TILE_SIZE][TILE_SIZE][4]; int colori128[TILE_SIZE][TILE_SIZE][4]; + uint64_t depth64[TILE_SIZE][TILE_SIZE]; ubyte any[1]; } data; }; @@ -88,7 +89,7 @@ struct softpipe_tile_cache struct softpipe_cached_tile *entries[NUM_ENTRIES]; uint clear_flags[(MAX_WIDTH / TILE_SIZE) * (MAX_HEIGHT / TILE_SIZE) / 32]; union pipe_color_union clear_color; /**< for color bufs */ - uint clear_val; /**< for z+stencil */ + uint64_t clear_val; /**< for z+stencil */ boolean depth_stencil; /**< Is the surface a depth/stencil format? */ struct softpipe_cached_tile *tile; /**< scratch tile for clears */ @@ -123,7 +124,7 @@ sp_flush_tile_cache(struct softpipe_tile_cache *tc); extern void sp_tile_cache_clear(struct softpipe_tile_cache *tc, const union pipe_color_union *color, - uint clearValue); + uint64_t clearValue); extern struct softpipe_cached_tile * sp_find_cached_tile(struct softpipe_tile_cache *tc, |