panfrost: pass blendable formats to pan_pack_color

This allows us to specify the correct array later on, while still being
able to use the function as-is from call-sites that doesn't have a
panfrost_device.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25968>
This commit is contained in:
Erik Faye-Lund 2023-11-01 15:24:20 +01:00
parent f69b573dfc
commit 40656b6fa0
6 changed files with 16 additions and 9 deletions

View file

@ -948,7 +948,8 @@ panfrost_batch_clear(struct panfrost_batch *batch, unsigned buffers,
continue;
enum pipe_format format = ctx->pipe_framebuffer.cbufs[i]->format;
pan_pack_color(batch->clear_color[i], color, format, false);
pan_pack_color(panfrost_blendable_formats_v7, batch->clear_color[i],
color, format, false);
}
}

View file

@ -118,12 +118,12 @@ pan_pack_raw(uint32_t *packed, const union pipe_color_union *color,
}
void
pan_pack_color(uint32_t *packed, const union pipe_color_union *color,
pan_pack_color(const struct pan_blendable_format *blendable_formats,
uint32_t *packed, const union pipe_color_union *color,
enum pipe_format format, bool dithered)
{
/* Set of blendable formats is common across versions. TODO: v9 */
enum mali_color_buffer_internal_format internal =
panfrost_blendable_formats_v7[format].internal;
blendable_formats[format].internal;
if (internal == MALI_COLOR_BUFFER_INTERNAL_FORMAT_RAW_VALUE) {
pan_pack_raw(packed, color, format);

View file

@ -56,6 +56,7 @@
#define PAN_DBG_FORCE_PACK 0x40000
struct panfrost_device;
struct pan_blendable_format;
unsigned panfrost_translate_swizzle_4(const unsigned char swizzle[4]);
@ -65,7 +66,8 @@ unsigned panfrost_format_to_bifrost_blend(const struct panfrost_device *dev,
enum pipe_format format,
bool dithered);
void pan_pack_color(uint32_t *packed, const union pipe_color_union *color,
void pan_pack_color(const struct pan_blendable_format *blendable_formats,
uint32_t *packed, const union pipe_color_union *color,
enum pipe_format format, bool dithered);
/* Get the last blend shader, for an erratum workaround on v5 */

View file

@ -21,6 +21,7 @@
* SOFTWARE.
*/
#include "pan_texture.h"
#include "pan_util.h"
/* A test consists of a render target format, clear colour, dither state, and
@ -175,7 +176,8 @@ main(int argc, const char **argv)
for (unsigned i = 0; i < ARRAY_SIZE(clear_tests); ++i) {
struct test T = clear_tests[i];
uint32_t packed[4];
pan_pack_color(&packed[0], &T.colour, T.format, T.dithered);
pan_pack_color(panfrost_blendable_formats_v7, &packed[0], &T.colour,
T.format, T.dithered);
ASSERT_EQ(T.packed, packed);
}

View file

@ -408,7 +408,8 @@ panvk_cmd_prepare_clear_values(struct panvk_cmd_buffer *cmdbuf,
if (attachment->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
union pipe_color_union *col =
(union pipe_color_union *)&in[i].color;
pan_pack_color(cmdbuf->state.clear[i].color, col, fmt, false);
pan_pack_color(panfrost_blendable_formats_v7,
cmdbuf->state.clear[i].color, col, fmt, false);
} else {
memset(cmdbuf->state.clear[i].color, 0,
sizeof(cmdbuf->state.clear[0].color));

View file

@ -341,8 +341,9 @@ panvk_meta_clear_color_img(struct panvk_cmd_buffer *cmdbuf,
};
uint32_t clearval[4];
pan_pack_color(clearval, (union pipe_color_union *)color,
img->pimage.layout.format, false);
pan_pack_color(panfrost_blendable_formats_v7, clearval,
(union pipe_color_union *)color, img->pimage.layout.format,
false);
memcpy(fbinfo->rts[0].clear_value, clearval,
sizeof(fbinfo->rts[0].clear_value));