diff --git a/src/gallium/drivers/v3d/v3d_blit.c b/src/gallium/drivers/v3d/v3d_blit.c index bc9d21731e0..d425c308738 100644 --- a/src/gallium/drivers/v3d/v3d_blit.c +++ b/src/gallium/drivers/v3d/v3d_blit.c @@ -31,6 +31,9 @@ #include "broadcom/common/v3d_tiling.h" #include "broadcom/common/v3d_tfu.h" +#define V3D_VERSION 42 +#include "v3dx_format_table.h" + /** * The param @op_blit is used to tell if we are saving state for blitter_blit * (if true) or blitter_clear (if false). If other blitter functions are used diff --git a/src/gallium/drivers/v3d/v3d_context.h b/src/gallium/drivers/v3d/v3d_context.h index 460decd397c..0b8d40042c4 100644 --- a/src/gallium/drivers/v3d/v3d_context.h +++ b/src/gallium/drivers/v3d/v3d_context.h @@ -837,8 +837,7 @@ bool v3d_rt_format_supported(const struct v3d_device_info *devinfo, enum pipe_format f); bool v3d_tex_format_supported(const struct v3d_device_info *devinfo, enum pipe_format f); -uint8_t v3d_get_rt_format(const struct v3d_device_info *devinfo, enum pipe_format f); -uint8_t v3d_get_tex_format(const struct v3d_device_info *devinfo, enum pipe_format f); + uint8_t v3d_get_tex_return_size(const struct v3d_device_info *devinfo, enum pipe_format f); uint8_t v3d_get_tex_return_channels(const struct v3d_device_info *devinfo, diff --git a/src/gallium/drivers/v3d/v3d_format_table.h b/src/gallium/drivers/v3d/v3d_format_table.h index 45cddeb669d..fbc22433508 100644 --- a/src/gallium/drivers/v3d/v3d_format_table.h +++ b/src/gallium/drivers/v3d/v3d_format_table.h @@ -26,6 +26,19 @@ #include #include +#ifdef v3dX +# include "v3dx_context.h" +# include "broadcom/cle/v3dx_pack.h" +#else +# define v3dX(x) v3d42_##x +# include "v3dx_format_table.h" +# undef v3dX + +# define v3dX(x) v3d71_##x +# include "v3dx_format_table.h" +# undef v3dX +#endif + struct v3d_format { /** Set if the pipe format is defined in the table. */ bool present; diff --git a/src/gallium/drivers/v3d/v3d_formats.c b/src/gallium/drivers/v3d/v3d_formats.c index 3da5f25124a..916a23fc2a9 100644 --- a/src/gallium/drivers/v3d/v3d_formats.c +++ b/src/gallium/drivers/v3d/v3d_formats.c @@ -35,11 +35,10 @@ #include "util/macros.h" #include "v3d_context.h" -#include "v3d_format_table.h" /* The format internal types are the same across V3D versions */ #define V3D_VERSION 42 -#include "broadcom/cle/v3dx_pack.h" +#include "v3d_format_table.h" bool v3d_rt_format_supported(const struct v3d_device_info *devinfo, diff --git a/src/gallium/drivers/v3d/v3dx_context.h b/src/gallium/drivers/v3d/v3dx_context.h index 07c7409e11f..f68a3d0a192 100644 --- a/src/gallium/drivers/v3d/v3dx_context.h +++ b/src/gallium/drivers/v3d/v3dx_context.h @@ -42,16 +42,6 @@ void v3dX(bcl_epilogue)(struct v3d_context *v3d, struct v3d_job *job); void v3dX(job_emit_enable_double_buffer)(struct v3d_job *job); const struct v3d_format *v3dX(get_format_desc)(enum pipe_format f); -void v3dX(get_internal_type_bpp_for_output_format)(uint32_t format, - uint32_t *type, - uint32_t *bpp); - -/* 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, - bool for_mipmap); bool v3dX(tfu)(struct pipe_context *pctx, struct pipe_resource *pdst, diff --git a/src/gallium/drivers/v3d/v3dx_format_table.c b/src/gallium/drivers/v3d/v3dx_format_table.c index ee88e22601b..afc59493b66 100644 --- a/src/gallium/drivers/v3d/v3dx_format_table.c +++ b/src/gallium/drivers/v3d/v3dx_format_table.c @@ -24,9 +24,8 @@ #include "util/format/u_format.h" #include "v3d_context.h" -#include "broadcom/cle/v3dx_pack.h" -#include "broadcom/common/v3d_macros.h" #include "v3d_format_table.h" +#include "v3dx_format_table.h" #define SWIZ(x,y,z,w) { \ PIPE_SWIZZLE_##x, \ diff --git a/src/gallium/drivers/v3d/v3dx_format_table.h b/src/gallium/drivers/v3d/v3dx_format_table.h new file mode 100644 index 00000000000..e8e0247bdd0 --- /dev/null +++ b/src/gallium/drivers/v3d/v3dx_format_table.h @@ -0,0 +1,37 @@ +/* + * Copyright © 2025 Broadcom + * + * 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 "broadcom/common/v3d_macros.h" +#include "broadcom/cle/v3dx_pack.h" + +uint8_t v3d_get_tex_format(const struct v3d_device_info *devinfo, enum pipe_format f); + +uint8_t v3d_get_rt_format(const struct v3d_device_info *devinfo, enum pipe_format f); + +bool v3dX(tfu_supports_tex_format)(uint32_t tex_format, + bool for_mipmap); + +void v3dX(get_internal_type_bpp_for_output_format)(uint32_t format, + uint32_t *type, + uint32_t *bpp); + diff --git a/src/gallium/drivers/v3d/v3dx_rcl.c b/src/gallium/drivers/v3d/v3dx_rcl.c index 27cf729df7f..b67293cbb38 100644 --- a/src/gallium/drivers/v3d/v3dx_rcl.c +++ b/src/gallium/drivers/v3d/v3dx_rcl.c @@ -24,10 +24,9 @@ #include "util/format/u_format.h" #include "util/macros.h" #include "v3d_context.h" -#include "broadcom/common/v3d_macros.h" #include "broadcom/common/v3d_tiling.h" #include "broadcom/common/v3d_util.h" -#include "broadcom/cle/v3dx_pack.h" +#include "v3dx_format_table.h" #define PIPE_CLEAR_COLOR_BUFFERS (PIPE_CLEAR_COLOR0 | \ PIPE_CLEAR_COLOR1 | \ diff --git a/src/gallium/drivers/v3d/v3dx_state.c b/src/gallium/drivers/v3d/v3dx_state.c index fb27f8cb626..f1077d959e9 100644 --- a/src/gallium/drivers/v3d/v3dx_state.c +++ b/src/gallium/drivers/v3d/v3dx_state.c @@ -35,10 +35,9 @@ #include "v3d_context.h" #include "broadcom/common/v3d_tiling.h" -#include "broadcom/common/v3d_macros.h" #include "broadcom/common/v3d_util.h" #include "broadcom/compiler/v3d_compiler.h" -#include "broadcom/cle/v3dx_pack.h" +#include "v3dx_format_table.h" static void v3d_generic_cso_state_delete(struct pipe_context *pctx, void *hwcso) diff --git a/src/gallium/drivers/v3d/v3dx_tfu.c b/src/gallium/drivers/v3d/v3dx_tfu.c index 29b29e1dbc3..85d9b8b4a31 100644 --- a/src/gallium/drivers/v3d/v3dx_tfu.c +++ b/src/gallium/drivers/v3d/v3dx_tfu.c @@ -24,6 +24,7 @@ #include "v3d_context.h" #include "broadcom/common/v3d_tfu.h" #include "util/perf/cpu_trace.h" +#include "v3dx_format_table.h" bool v3dX(tfu)(struct pipe_context *pctx,