panfrost: Don't lie about Z/S formats

Only Z24S8 is properly supported right now, so let's be careful. Fixes a
number of issues relating to improper Z/S handling. The most obvious is
depth buffers with incorrect strides, which manifests in truly bizarre
ways and can happen commonly with FBOs.

Fixes WebGL (Aquarium runs, etc).

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
Alyssa Rosenzweig 2019-07-10 14:50:48 -07:00
parent cd403a931f
commit 507e297431
4 changed files with 34 additions and 6 deletions

View file

@ -27,11 +27,8 @@ dEQP-GLES2.functional.fbo.render.recreate_colorbuffer.rebind_tex2d_rgb_depth_com
dEQP-GLES2.functional.fbo.render.recreate_colorbuffer.rebind_tex2d_rgb_stencil_index8
dEQP-GLES2.functional.fbo.render.recreate_colorbuffer.rebind_tex2d_rgba_depth_component16
dEQP-GLES2.functional.fbo.render.recreate_colorbuffer.rebind_tex2d_rgba_stencil_index8
dEQP-GLES2.functional.fbo.render.resize.rbo_rgb565_depth_component16
dEQP-GLES2.functional.fbo.render.resize.rbo_rgb565_stencil_index8
dEQP-GLES2.functional.fbo.render.resize.rbo_rgb5_a1_depth_component16
dEQP-GLES2.functional.fbo.render.resize.rbo_rgb5_a1_stencil_index8
dEQP-GLES2.functional.fbo.render.resize.rbo_rgba4_depth_component16
dEQP-GLES2.functional.fbo.render.resize.rbo_rgba4_stencil_index8
dEQP-GLES2.functional.fbo.render.resize.tex2d_rgb_depth_component16
dEQP-GLES2.functional.fbo.render.resize.tex2d_rgb_stencil_index8
@ -248,10 +245,8 @@ dEQP-GLES2.functional.fragment_ops.random.97
dEQP-GLES2.functional.fragment_ops.random.98
dEQP-GLES2.functional.fragment_ops.random.99
dEQP-GLES2.functional.polygon_offset.fixed16_displacement_with_units
dEQP-GLES2.functional.polygon_offset.fixed16_enable
dEQP-GLES2.functional.polygon_offset.fixed16_render_with_factor
dEQP-GLES2.functional.polygon_offset.fixed16_render_with_units
dEQP-GLES2.functional.polygon_offset.fixed16_result_depth_clamp
dEQP-GLES2.functional.shaders.builtin_variable.fragcoord_w
dEQP-GLES2.functional.shaders.preprocessor.predefined_macros.line_2_fragment
dEQP-GLES2.functional.shaders.preprocessor.predefined_macros.line_2_vertex

View file

@ -93,7 +93,12 @@ panfrost_format_supports_afbc(enum pipe_format format)
if (util_format_is_rgba8_variant(desc))
return true;
if (format == PIPE_FORMAT_Z32_UNORM)
/* Z32/Z16/S8 are all compressible as well, but they are implemented as
* Z24S8 with wasted bits. So Z24S8 is the only format we actually need
* to handle compressed, and we can make the state tracker deal with
* the rest. */
if (format == PIPE_FORMAT_Z24_UNORM_S8_UINT)
return true;
/* TODO: AFBC of other formats */

View file

@ -254,6 +254,7 @@ panfrost_mfbd_set_zsbuf(
struct pipe_surface *surf)
{
struct panfrost_resource *rsrc = pan_resource(surf->texture);
enum pipe_format format = surf->format;
unsigned level = surf->u.tex.level;
assert(surf->u.tex.first_layer == 0);
@ -261,6 +262,10 @@ panfrost_mfbd_set_zsbuf(
unsigned offset = rsrc->slices[level].offset;
if (rsrc->layout == PAN_AFBC) {
/* The only Z/S format we can compress is Z24S8 or variants
* thereof (handled by the state tracker) */
assert(format == PIPE_FORMAT_Z24_UNORM_S8_UINT);
mali_ptr base = rsrc->bo->gpu + offset;
unsigned header_size = rsrc->slices[level].header_size;
@ -280,6 +285,9 @@ panfrost_mfbd_set_zsbuf(
fbx->ds_afbc.zero1 = 0x10009;
fbx->ds_afbc.padding = 0x1000;
} else if (rsrc->layout == PAN_LINEAR) {
/* TODO: Z32F(S8) support, which is always linear */
assert(format == PIPE_FORMAT_Z24_UNORM_S8_UINT);
int stride = rsrc->slices[level].stride;
fb->mfbd_flags |= MALI_MFBD_EXTRA;

View file

@ -410,6 +410,26 @@ panfrost_is_format_supported( struct pipe_screen *screen,
return FALSE;
}
/* Internally, formats that are depth/stencil renderable are limited.
*
* In particular: Z16, Z24, Z24S8, S8 are all identical from the GPU
* rendering perspective. That is, we render to Z24S8 (which we can
* AFBC compress), ignore the different when texturing (who cares?),
* and then in the off-chance there's a CPU read we blit back to
* staging.
*
* ...alternatively, we can make the state tracker deal with that. */
if (bind & PIPE_BIND_DEPTH_STENCIL) {
switch (format) {
case PIPE_FORMAT_Z24_UNORM_S8_UINT:
return true;
default:
return false;
}
}
return TRUE;
}