v3dv: move format helpers to new v3dv format table header files.

Move tfu_supports_tex_format() and
get_internal_type_bpp_for_output_format() from v3dvx_private.h
to v3dvx_format_table.h.
Move v3dv_format_plane and v3dv_format struct from v3dv_private.h
to v3dv_format_table.h.

Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38732>
This commit is contained in:
Daivik Bhatia 2025-12-01 04:35:36 +05:30 committed by Marge Bot
parent edb730f647
commit b06aa98246
17 changed files with 149 additions and 55 deletions

View file

@ -28,6 +28,9 @@
#include "vk_common_entrypoints.h"
#include "vk_util.h"
#define V3D_VERSION 42
#include "v3dv_format_table.h"
float
v3dv_get_aa_line_width(struct v3dv_pipeline *pipeline,
struct v3dv_cmd_buffer *buffer)

View file

@ -71,6 +71,9 @@
#include <wayland-client.h>
#endif
#define V3D_VERSION 42
#include "v3dv_format_table.h"
#define V3DV_API_VERSION VK_MAKE_VERSION(1, 3, VK_HEADER_VERSION)
#ifdef ANDROID_STRICT

View file

@ -0,0 +1,80 @@
/*
* Copyright © 2025 Raspberry Pi Ltd
*
* based in part on anv driver which is:
* Copyright © 2015 Intel Corporation
*
* based in part on radv driver which is:
* Copyright © 2016 Red Hat.
* Copyright © 2016 Bas Nieuwenhuizen
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include <stdbool.h>
#include <stdint.h>
#ifdef v3dX
# include "broadcom/cle/v3dx_pack.h"
#else
# define v3dX(x) v3d42_##x
# include "v3dvx_format_table.h"
# undef v3dX
# define v3dX(x) v3d71_##x
# include "v3dvx_format_table.h"
# undef v3dX
#endif
struct v3dv_format_plane {
/* One of V3D42_OUTPUT_IMAGE_FORMAT_*, or OUTPUT_IMAGE_FORMAT_NO */
uint8_t rt_type;
/* One of V3D42_TEXTURE_DATA_FORMAT_*. */
uint8_t tex_type;
/* Swizzle to apply to the RGBA shader output for storing to the tile
* buffer, to the RGBA tile buffer to produce shader input (for
* blending), and for turning the rgba8888 texture sampler return
* value into shader rgba values.
*/
uint8_t swizzle[4];
/* Whether the return value is 16F/I/UI or 32F/I/UI. */
uint8_t return_size;
/* Needs software unorm packing */
bool unorm;
/* Needs software snorm packing */
bool snorm;
};
struct v3dv_format {
/* Non 0 plane count implies supported */
uint8_t plane_count;
struct v3dv_format_plane planes[V3DV_MAX_PLANE_COUNT];
/* If the format supports (linear) filtering when texturing. */
bool supports_filtering;
};

View file

@ -33,6 +33,9 @@
#include <vulkan/vulkan_android.h>
#define V3D_VERSION 42
#include "v3dv_format_table.h"
const uint8_t *
v3dv_get_format_swizzle(struct v3dv_device *device, VkFormat f, uint8_t plane)
{

View file

@ -30,6 +30,9 @@
#include "vulkan/wsi/wsi_common.h"
#include "vk_android.h"
#define V3D_VERSION 42
#include "v3dv_format_table.h"
/**
* Computes the HW's UIFblock padding for a given height/cpp.
*

View file

@ -28,6 +28,9 @@
#include "util/u_pack_color.h"
#include "vk_common_entrypoints.h"
#define V3D_VERSION 42
#include "v3dv_format_table.h"
static void
get_hw_clear_color(struct v3dv_device *device,
const VkClearColorValue *color,

View file

@ -28,6 +28,9 @@
#include "util/u_pack_color.h"
#include "vk_common_entrypoints.h"
#define V3D_VERSION 42
#include "v3dv_format_table.h"
static uint32_t
meta_blit_key_hash(const void *key)
{

View file

@ -23,6 +23,9 @@
#include "v3dv_private.h"
#define V3D_VERSION 42
#include "v3dv_format_table.h"
static uint32_t
num_subpass_attachments(const VkSubpassDescription2 *desc)
{

View file

@ -116,6 +116,8 @@
struct v3dv_instance;
struct v3dv_image;
struct v3dv_format_plane;
struct v3dv_format;
struct v3d_simulator_file;
/* Minimum required by the Vulkan 1.1 spec */
@ -618,39 +620,6 @@ struct v3dv_device_memory {
#define TEXTURE_DATA_FORMAT_NO 255
#define V3DV_MAX_PLANE_COUNT 3
struct v3dv_format_plane {
/* One of V3D42_OUTPUT_IMAGE_FORMAT_*, or OUTPUT_IMAGE_FORMAT_NO */
uint8_t rt_type;
/* One of V3D42_TEXTURE_DATA_FORMAT_*. */
uint8_t tex_type;
/* Swizzle to apply to the RGBA shader output for storing to the tile
* buffer, to the RGBA tile buffer to produce shader input (for
* blending), and for turning the rgba8888 texture sampler return
* value into shader rgba values.
*/
uint8_t swizzle[4];
/* Whether the return value is 16F/I/UI or 32F/I/UI. */
uint8_t return_size;
/* Needs software unorm packing */
bool unorm;
/* Needs software snorm packing */
bool snorm;
};
struct v3dv_format {
/* Non 0 plane count implies supported */
uint8_t plane_count;
struct v3dv_format_plane planes[V3DV_MAX_PLANE_COUNT];
/* If the format supports (linear) filtering when texturing. */
bool supports_filtering;
};
/* Note that although VkImageAspectFlags would allow to combine more than one
* PLANE bit, for all the use cases we implement that use VkImageAspectFlags,

View file

@ -22,9 +22,8 @@
*/
#include "v3dv_private.h"
#include "broadcom/common/v3d_macros.h"
#include "v3dv_format_table.h"
#include "broadcom/common/v3d_util.h"
#include "broadcom/cle/v3dx_pack.h"
#include "broadcom/compiler/v3d_compiler.h"
#include "util/half_float.h"

View file

@ -22,9 +22,9 @@
*/
#include "v3dv_private.h"
#include "v3dv_format_table.h"
#include "v3dvx_format_table.h"
#include "broadcom/common/v3d_macros.h"
#include "broadcom/cle/v3dx_pack.h"
#include "broadcom/compiler/v3d_compiler.h"
#include "util/u_pack_color.h"
#include "util/half_float.h"

View file

@ -0,0 +1,38 @@
/*
* Copyright © 2025 Raspberry Pi Ltd
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
/* This file generates the per-v3d-version function prototypes. It must only
* be included from v3dv_private.h.
*/
#include "broadcom/common/v3d_macros.h"
#include "broadcom/cle/v3dx_pack.h"
/* FIXME: tex_format should be `enum V3DX(Texture_Data_Formats)`, but using
* that enum type in the header requires including v3dx_pack.h, which triggers
* circular include dependencies issues, so we're using a `uint32_t` for now.
*/
bool v3dX(tfu_supports_tex_format)(uint32_t tex_format);
void v3dX(get_internal_type_bpp_for_output_format)(uint32_t format,
uint32_t *type, uint32_t *bpp);

View file

@ -22,8 +22,8 @@
*/
#include "v3dv_private.h"
#include "broadcom/common/v3d_macros.h"
#include "broadcom/cle/v3dx_pack.h"
#include "v3dv_format_table.h"
#include "v3dvx_format_table.h"
#include "util/format/u_format.h"
#include "vk_enum_to_str.h"

View file

@ -22,8 +22,7 @@
*/
#include "v3dv_private.h"
#include "broadcom/common/v3d_macros.h"
#include "broadcom/cle/v3dx_pack.h"
#include "v3dv_format_table.h"
#include "broadcom/compiler/v3d_compiler.h"
/*

View file

@ -22,6 +22,7 @@
*/
#include "v3dv_private.h"
#include "v3dv_format_table.h"
#include "v3dv_meta_common.h"
#include "broadcom/common/v3d_macros.h"

View file

@ -22,8 +22,7 @@
*/
#include "v3dv_private.h"
#include "broadcom/common/v3d_macros.h"
#include "broadcom/cle/v3dx_pack.h"
#include "v3dv_format_table.h"
#include "broadcom/compiler/v3d_compiler.h"
static uint8_t

View file

@ -166,24 +166,12 @@ v3dX(device_check_prepacked_sizes)(void);
const struct v3dv_format *
v3dX(get_format)(VkFormat);
void
v3dX(get_internal_type_bpp_for_output_format)(uint32_t format,
uint32_t *type,
uint32_t *bpp);
bool
v3dX(format_supports_tlb_resolve)(const struct v3dv_format *format);
bool
v3dX(format_supports_blending)(const struct v3dv_format *format);
/* FIXME: tex_format should be `enum V3DX(Texture_Data_Formats)`, but using
* that enum type in the header requires including v3dx_pack.h, which triggers
* circular include dependencies issues, so we're using a `uint32_t` for now.
*/
bool
v3dX(tfu_supports_tex_format)(uint32_t tex_format);
/* Used at v3dv_image */
void