From c1d3d39e97106ebe95106d04be211b320cd5aee6 Mon Sep 17 00:00:00 2001 From: Icecream95 Date: Mon, 13 Jul 2020 22:45:51 +1200 Subject: panfrost: Fake RGTC support For most GPUs RGTC is disabled, so it needs to be emulated, using the fake_rgtc option of u_transfer_helper. Passes the rgtc-teximage tests in piglit. v2: Update docs/features.txt (Alyssa) Reviewed-by: Alyssa Rosenzweig Part-of: --- docs/features.txt | 2 +- src/gallium/drivers/panfrost/pan_context.c | 16 +++++++++++++--- src/gallium/drivers/panfrost/pan_resource.c | 6 +++++- src/gallium/drivers/panfrost/pan_screen.c | 12 +++++------- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/docs/features.txt b/docs/features.txt index fed566e2318..9d5198e62d3 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -52,7 +52,7 @@ GL 3.0, GLSL 1.30 --- all DONE: freedreno, i965, nv50, nvc0, r600, radeonsi, llv GL_EXT_texture_integer DONE (panfrost, v3d) GL_EXT_texture_array DONE (panfrost, v3d) GL_EXT_draw_buffers2 (Per-buffer blend and masks) DONE (panfrost, v3d) - GL_EXT_texture_compression_rgtc DONE (panfrost/if SoC supports) + GL_EXT_texture_compression_rgtc DONE (panfrost) GL_ARB_texture_rg DONE (panfrost, v3d) GL_EXT_transform_feedback (Transform feedback) DONE (panfrost, v3d) GL_ARB_vertex_array_object (Vertex array objects) DONE (panfrost, v3d) diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index d2b44f907de..5d84322109d 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -941,13 +941,25 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so, assert(prsrc->bo); /* Format to access the stencil portion of a Z32_S8 texture */ - if (so->base.format == PIPE_FORMAT_X32_S8X24_UINT) { + if (format == PIPE_FORMAT_X32_S8X24_UINT) { assert(prsrc->separate_stencil); texture = &prsrc->separate_stencil->base; prsrc = (struct panfrost_resource *)texture; format = texture->format; } + const struct util_format_description *desc = util_format_description(format); + + bool fake_rgtc = !panfrost_supports_compressed_format(device, MALI_BC4_UNORM); + + if (desc->layout == UTIL_FORMAT_LAYOUT_RGTC && fake_rgtc) { + if (desc->is_snorm) + format = PIPE_FORMAT_R8G8B8A8_SNORM; + else + format = PIPE_FORMAT_R8G8B8A8_UNORM; + desc = util_format_description(format); + } + so->texture_bo = prsrc->bo->gpu; so->layout = prsrc->layout; @@ -985,8 +997,6 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so, panfrost_translate_texture_type(so->base.target); if (device->quirks & IS_BIFROST) { - const struct util_format_description *desc = - util_format_description(format); unsigned char composed_swizzle[4]; util_format_compose_swizzles(desc->swizzle, user_swizzle, composed_swizzle); diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 3cd9b65bcae..f03cd9c4ea3 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -934,6 +934,10 @@ static const struct u_transfer_vtbl transfer_vtbl = { void panfrost_resource_screen_init(struct pipe_screen *pscreen) { + struct panfrost_device *dev = pan_device(pscreen); + + bool fake_rgtc = !panfrost_supports_compressed_format(dev, MALI_BC4_UNORM); + //pscreen->base.resource_create_with_modifiers = // panfrost_resource_create_with_modifiers; pscreen->resource_create = u_transfer_helper_resource_create; @@ -942,7 +946,7 @@ panfrost_resource_screen_init(struct pipe_screen *pscreen) pscreen->resource_get_handle = panfrost_resource_get_handle; pscreen->transfer_helper = u_transfer_helper_create(&transfer_vtbl, true, false, - true, true); + fake_rgtc, true); } void diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index a5d264e0b17..e776add1f20 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -463,11 +463,6 @@ panfrost_is_format_supported( struct pipe_screen *screen, if (scanout && renderable && !util_format_is_rgba8_variant(format_desc)) return false; - if (dev->debug & (PAN_DBG_GL3 | PAN_DBG_DEQP)) { - if (format_desc->layout == UTIL_FORMAT_LAYOUT_RGTC) - return true; - } - /* Check we support the format with the given bind */ unsigned relevant_bind = bind & @@ -478,9 +473,12 @@ panfrost_is_format_supported( struct pipe_screen *screen, /* Also check that compressed texture formats are supported on this * particular chip. They may not be depending on system integration - * differences. */ + * differences. RGTC can be emulated so is always supported. */ + + bool is_rgtc = format_desc->layout == UTIL_FORMAT_LAYOUT_RGTC; + bool supported = panfrost_supports_compressed_format(dev, fmt.hw); - if (!panfrost_supports_compressed_format(dev, fmt.hw)) + if (!is_rgtc && !supported) return false; return fmt.hw && ((relevant_bind & ~fmt.bind) == 0); -- cgit v1.2.3