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 <airlied@redhat.com>
}
}
+/*** 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,
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),
double depth, unsigned stencil)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- unsigned cv;
+ uint64_t cv;
uint i;
if (softpipe->no_rast)
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);
}
#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"
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);
}
}
}
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);
}
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]));
}
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);
}
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;
}
/*
static void
clear_tile(struct softpipe_cached_tile *tile,
enum pipe_format format,
- uint clear_value)
+ uint64_t clear_value)
{
uint i, j;
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;
}
}
}
void
sp_tile_cache_clear(struct softpipe_tile_cache *tc,
const union pipe_color_union *color,
- uint clearValue)
+ uint64_t clearValue)
{
uint pos;
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;
};
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 */
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,