v3d: add per hw-version caller macro
Instead of hardcoding conditionals to know which hardwared-based version of a function to call, just wrap them in a macro to use Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22733>
This commit is contained in:

committed by
Marge Bot

parent
1e334e9818
commit
d95bff8e1c
@@ -554,7 +554,7 @@ v3d_tlb_blit(struct pipe_context *pctx, struct pipe_blit_info *info)
|
||||
info->mask &= ~PIPE_MASK_S;
|
||||
}
|
||||
|
||||
v3d41_start_binning(v3d, job);
|
||||
v3d_X(&v3d->screen->devinfo, start_binning)(v3d, job);
|
||||
|
||||
v3d_job_submit(v3d, job);
|
||||
|
||||
|
@@ -223,10 +223,7 @@ void
|
||||
v3d_create_texture_shader_state_bo(struct v3d_context *v3d,
|
||||
struct v3d_sampler_view *so)
|
||||
{
|
||||
if (v3d->screen->devinfo.ver >= 41)
|
||||
v3d41_create_texture_shader_state_bo(v3d, so);
|
||||
else
|
||||
v3d33_create_texture_shader_state_bo(v3d, so);
|
||||
v3d_X(&v3d->screen->devinfo, create_texture_shader_state_bo)(v3d, so);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -374,13 +371,8 @@ v3d_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
||||
pctx->invalidate_resource = v3d_invalidate_resource;
|
||||
pctx->get_sample_position = v3d_get_sample_position;
|
||||
|
||||
if (screen->devinfo.ver >= 41) {
|
||||
v3d41_draw_init(pctx);
|
||||
v3d41_state_init(pctx);
|
||||
} else {
|
||||
v3d33_draw_init(pctx);
|
||||
v3d33_state_init(pctx);
|
||||
}
|
||||
v3d_X(&screen->devinfo, draw_init)(pctx);
|
||||
v3d_X(&screen->devinfo, state_init)(pctx);
|
||||
v3d_program_init(pctx);
|
||||
v3d_query_init(pctx);
|
||||
v3d_resource_context_init(pctx);
|
||||
|
@@ -825,6 +825,18 @@ void v3d_disk_cache_store(struct v3d_context *v3d,
|
||||
uint32_t qpu_size);
|
||||
#endif /* ENABLE_SHADER_CACHE */
|
||||
|
||||
/* Helper to call hw ver specific functions */
|
||||
#define v3d_X(devinfo, thing) ({ \
|
||||
__typeof(&v3d41_##thing) v3d_X_thing; \
|
||||
if ((devinfo)->ver >= 41) \
|
||||
v3d_X_thing = &v3d41_##thing; \
|
||||
else if ((devinfo)->ver >= 33) \
|
||||
v3d_X_thing = &v3d33_##thing; \
|
||||
else \
|
||||
unreachable("Unsupported hardware generation"); \
|
||||
v3d_X_thing; \
|
||||
})
|
||||
|
||||
#ifdef v3dX
|
||||
# include "v3dx_context.h"
|
||||
#else
|
||||
|
@@ -41,20 +41,11 @@
|
||||
#define V3D_VERSION 33
|
||||
#include "broadcom/cle/v3dx_pack.h"
|
||||
|
||||
static const struct v3d_format *
|
||||
get_format(const struct v3d_device_info *devinfo, enum pipe_format f)
|
||||
{
|
||||
if (devinfo->ver >= 41)
|
||||
return v3d41_get_format_desc(f);
|
||||
else
|
||||
return v3d33_get_format_desc(f);
|
||||
}
|
||||
|
||||
bool
|
||||
v3d_rt_format_supported(const struct v3d_device_info *devinfo,
|
||||
enum pipe_format f)
|
||||
{
|
||||
const struct v3d_format *vf = get_format(devinfo, f);
|
||||
const struct v3d_format *vf = v3d_X(devinfo, get_format_desc)(f);
|
||||
|
||||
if (!vf)
|
||||
return false;
|
||||
@@ -65,7 +56,7 @@ v3d_rt_format_supported(const struct v3d_device_info *devinfo,
|
||||
uint8_t
|
||||
v3d_get_rt_format(const struct v3d_device_info *devinfo, enum pipe_format f)
|
||||
{
|
||||
const struct v3d_format *vf = get_format(devinfo, f);
|
||||
const struct v3d_format *vf = v3d_X(devinfo, get_format_desc)(f);
|
||||
|
||||
if (!vf)
|
||||
return 0;
|
||||
@@ -77,7 +68,7 @@ bool
|
||||
v3d_tex_format_supported(const struct v3d_device_info *devinfo,
|
||||
enum pipe_format f)
|
||||
{
|
||||
const struct v3d_format *vf = get_format(devinfo, f);
|
||||
const struct v3d_format *vf = v3d_X(devinfo, get_format_desc)(f);
|
||||
|
||||
return vf != NULL;
|
||||
}
|
||||
@@ -85,7 +76,7 @@ v3d_tex_format_supported(const struct v3d_device_info *devinfo,
|
||||
uint8_t
|
||||
v3d_get_tex_format(const struct v3d_device_info *devinfo, enum pipe_format f)
|
||||
{
|
||||
const struct v3d_format *vf = get_format(devinfo, f);
|
||||
const struct v3d_format *vf = v3d_X(devinfo, get_format_desc)(f);
|
||||
|
||||
if (!vf)
|
||||
return 0;
|
||||
@@ -97,7 +88,7 @@ uint8_t
|
||||
v3d_get_tex_return_size(const struct v3d_device_info *devinfo,
|
||||
enum pipe_format f)
|
||||
{
|
||||
const struct v3d_format *vf = get_format(devinfo, f);
|
||||
const struct v3d_format *vf = v3d_X(devinfo, get_format_desc)(f);
|
||||
|
||||
if (!vf)
|
||||
return 0;
|
||||
@@ -115,7 +106,7 @@ uint8_t
|
||||
v3d_get_tex_return_channels(const struct v3d_device_info *devinfo,
|
||||
enum pipe_format f)
|
||||
{
|
||||
const struct v3d_format *vf = get_format(devinfo, f);
|
||||
const struct v3d_format *vf = v3d_X(devinfo, get_format_desc)(f);
|
||||
|
||||
if (!vf)
|
||||
return 0;
|
||||
@@ -126,7 +117,7 @@ v3d_get_tex_return_channels(const struct v3d_device_info *devinfo,
|
||||
const uint8_t *
|
||||
v3d_get_format_swizzle(const struct v3d_device_info *devinfo, enum pipe_format f)
|
||||
{
|
||||
const struct v3d_format *vf = get_format(devinfo, f);
|
||||
const struct v3d_format *vf = v3d_X(devinfo, get_format_desc)(f);
|
||||
static const uint8_t fallback[] = {0, 1, 2, 3};
|
||||
|
||||
if (!vf)
|
||||
@@ -141,13 +132,7 @@ v3d_get_internal_type_bpp_for_output_format(const struct v3d_device_info *devinf
|
||||
uint32_t *type,
|
||||
uint32_t *bpp)
|
||||
{
|
||||
if (devinfo->ver >= 41) {
|
||||
return v3d41_get_internal_type_bpp_for_output_format(format,
|
||||
type, bpp);
|
||||
} else {
|
||||
return v3d33_get_internal_type_bpp_for_output_format(format,
|
||||
type, bpp);
|
||||
}
|
||||
v3d_X(devinfo, get_internal_type_bpp_for_output_format)(format, type, bpp);
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -155,11 +140,7 @@ v3d_tfu_supports_tex_format(const struct v3d_device_info *devinfo,
|
||||
uint32_t tex_format,
|
||||
bool for_mipmap)
|
||||
{
|
||||
if (devinfo->ver >= 41) {
|
||||
return v3d41_tfu_supports_tex_format(tex_format, for_mipmap);
|
||||
} else {
|
||||
return v3d33_tfu_supports_tex_format(tex_format, for_mipmap);
|
||||
}
|
||||
return v3d_X(devinfo, tfu_supports_tex_format)(tex_format, for_mipmap);
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -169,7 +150,7 @@ v3d_format_supports_tlb_msaa_resolve(const struct v3d_device_info *devinfo,
|
||||
uint32_t internal_type;
|
||||
uint32_t internal_bpp;
|
||||
|
||||
const struct v3d_format *vf = get_format(devinfo, f);
|
||||
const struct v3d_format *vf = v3d_X(devinfo, get_format_desc)(f);
|
||||
|
||||
if (!vf)
|
||||
return false;
|
||||
|
@@ -495,17 +495,10 @@ v3d_job_submit(struct v3d_context *v3d, struct v3d_job *job)
|
||||
if (job->needs_primitives_generated)
|
||||
v3d_ensure_prim_counts_allocated(v3d);
|
||||
|
||||
if (screen->devinfo.ver >= 41)
|
||||
v3d41_emit_rcl(job);
|
||||
else
|
||||
v3d33_emit_rcl(job);
|
||||
v3d_X(&screen->devinfo, emit_rcl)(job);
|
||||
|
||||
if (cl_offset(&job->bcl) > 0) {
|
||||
if (screen->devinfo.ver >= 41)
|
||||
v3d41_bcl_epilogue(v3d, job);
|
||||
else
|
||||
v3d33_bcl_epilogue(v3d, job);
|
||||
}
|
||||
if (cl_offset(&job->bcl) > 0)
|
||||
v3d_X(&screen->devinfo, bcl_epilogue)(v3d, job);
|
||||
|
||||
/* While the RCL will implicitly depend on the last RCL to have
|
||||
* finished, we also need to block on any previous TFU job we may have
|
||||
|
@@ -1089,11 +1089,7 @@ v3d_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info,
|
||||
*/
|
||||
v3d_emit_wait_for_tf_if_needed(v3d, job);
|
||||
|
||||
#if V3D_VERSION >= 41
|
||||
v3d41_emit_state(pctx);
|
||||
#else
|
||||
v3d33_emit_state(pctx);
|
||||
#endif
|
||||
v3dX(emit_state)(pctx);
|
||||
|
||||
if (v3d->dirty & (V3D_DIRTY_VTXBUF |
|
||||
V3D_DIRTY_VTXSTATE |
|
||||
|
Reference in New Issue
Block a user