diff --git a/src/gallium/drivers/v3d/v3d_blit.c b/src/gallium/drivers/v3d/v3d_blit.c index be63d1d403a..0b0990c75b5 100644 --- a/src/gallium/drivers/v3d/v3d_blit.c +++ b/src/gallium/drivers/v3d/v3d_blit.c @@ -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); diff --git a/src/gallium/drivers/v3d/v3d_context.c b/src/gallium/drivers/v3d/v3d_context.c index 145e330ddaa..2a3324b8796 100644 --- a/src/gallium/drivers/v3d/v3d_context.c +++ b/src/gallium/drivers/v3d/v3d_context.c @@ -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); diff --git a/src/gallium/drivers/v3d/v3d_context.h b/src/gallium/drivers/v3d/v3d_context.h index af2b4121cfc..bd33ebcf9ad 100644 --- a/src/gallium/drivers/v3d/v3d_context.h +++ b/src/gallium/drivers/v3d/v3d_context.h @@ -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 diff --git a/src/gallium/drivers/v3d/v3d_formats.c b/src/gallium/drivers/v3d/v3d_formats.c index b9d0ef68d6b..b94857fa006 100644 --- a/src/gallium/drivers/v3d/v3d_formats.c +++ b/src/gallium/drivers/v3d/v3d_formats.c @@ -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; diff --git a/src/gallium/drivers/v3d/v3d_job.c b/src/gallium/drivers/v3d/v3d_job.c index a25edd0f5fc..b4957054b9b 100644 --- a/src/gallium/drivers/v3d/v3d_job.c +++ b/src/gallium/drivers/v3d/v3d_job.c @@ -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 diff --git a/src/gallium/drivers/v3d/v3dx_draw.c b/src/gallium/drivers/v3d/v3dx_draw.c index 9f573d799bd..ae9026a6fae 100644 --- a/src/gallium/drivers/v3d/v3dx_draw.c +++ b/src/gallium/drivers/v3d/v3dx_draw.c @@ -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 |