[Mesa-dev] [PATCH v2] r600g: Use R600_MAX_VIEWPORTS instead of 16
Marek Olšák
maraeo at gmail.com
Mon Mar 9 15:03:38 PDT 2015
Pushed, thanks.
Marek
On Wed, Feb 25, 2015 at 7:50 AM, Alexandre Demers
<alexandre.f.demers at gmail.com> wrote:
> Lets define R600_MAX_VIEWPORTS instead of using 16 here and there
> in the code when looping through viewports and scissors. It is
> easier to understand what this number represents.
>
> v2: Missed a case where R600_MAX_VIEWPORTS should have been used.
>
> Signed-off-by: Alexandre Demers <alexandre.f.demers at gmail.com>
> ---
> src/gallium/drivers/r600/evergreen_state.c | 10 +++++-----
> src/gallium/drivers/r600/r600_hw_context.c | 2 +-
> src/gallium/drivers/r600/r600_pipe.c | 2 +-
> src/gallium/drivers/r600/r600_pipe.h | 6 ++++--
> src/gallium/drivers/r600/r600_state.c | 4 ++--
> 5 files changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
> index 8aa8082..f0b04f0 100644
> --- a/src/gallium/drivers/r600/evergreen_state.c
> +++ b/src/gallium/drivers/r600/evergreen_state.c
> @@ -2293,8 +2293,8 @@ static void cayman_init_atom_start_cs(struct r600_context *rctx)
> r600_store_context_reg(cb, R_028200_PA_SC_WINDOW_OFFSET, 0);
> r600_store_context_reg(cb, R_02820C_PA_SC_CLIPRECT_RULE, 0xFFFF);
>
> - r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * 16);
> - for (tmp = 0; tmp < 16; tmp++) {
> + r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * R600_MAX_VIEWPORTS);
> + for (tmp = 0; tmp < R600_MAX_VIEWPORTS; tmp++) {
> r600_store_value(cb, 0); /* R_0282D0_PA_SC_VPORT_ZMIN_0 */
> r600_store_value(cb, fui(1.0)); /* R_0282D4_PA_SC_VPORT_ZMAX_0 */
> }
> @@ -2727,8 +2727,8 @@ void evergreen_init_atom_start_cs(struct r600_context *rctx)
> r600_store_context_reg(cb, R_02820C_PA_SC_CLIPRECT_RULE, 0xFFFF);
> r600_store_context_reg(cb, R_028230_PA_SC_EDGERULE, 0xAAAAAAAA);
>
> - r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * 16);
> - for (tmp = 0; tmp < 16; tmp++) {
> + r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * R600_MAX_VIEWPORTS);
> + for (tmp = 0; tmp < R600_MAX_VIEWPORTS; tmp++) {
> r600_store_value(cb, 0); /* R_0282D0_PA_SC_VPORT_ZMIN_0 */
> r600_store_value(cb, fui(1.0)); /* R_0282D4_PA_SC_VPORT_ZMAX_0 */
> }
> @@ -3458,7 +3458,7 @@ void evergreen_init_state_functions(struct r600_context *rctx)
> r600_init_atom(rctx, &rctx->dsa_state.atom, id++, r600_emit_cso_state, 0);
> r600_init_atom(rctx, &rctx->poly_offset_state.atom, id++, evergreen_emit_polygon_offset, 6);
> r600_init_atom(rctx, &rctx->rasterizer_state.atom, id++, r600_emit_cso_state, 0);
> - for (i = 0; i < 16; i++) {
> + for (i = 0; i < R600_MAX_VIEWPORTS; i++) {
> r600_init_atom(rctx, &rctx->viewport[i].atom, id++, r600_emit_viewport_state, 8);
> r600_init_atom(rctx, &rctx->scissor[i].atom, id++, evergreen_emit_scissor_state, 4);
> rctx->viewport[i].idx = i;
> diff --git a/src/gallium/drivers/r600/r600_hw_context.c b/src/gallium/drivers/r600/r600_hw_context.c
> index cd57eed..7961a96 100644
> --- a/src/gallium/drivers/r600/r600_hw_context.c
> +++ b/src/gallium/drivers/r600/r600_hw_context.c
> @@ -307,7 +307,7 @@ void r600_begin_new_cs(struct r600_context *ctx)
> ctx->poly_offset_state.atom.dirty = true;
> ctx->vgt_state.atom.dirty = true;
> ctx->sample_mask.atom.dirty = true;
> - for (i = 0; i < 16; i++) {
> + for (i = 0; i < R600_MAX_VIEWPORTS; i++) {
> ctx->scissor[i].atom.dirty = true;
> ctx->viewport[i].atom.dirty = true;
> }
> diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
> index c8a0e9c..24d901e 100644
> --- a/src/gallium/drivers/r600/r600_pipe.c
> +++ b/src/gallium/drivers/r600/r600_pipe.c
> @@ -374,7 +374,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
> return 8;
>
> case PIPE_CAP_MAX_VIEWPORTS:
> - return 16;
> + return R600_MAX_VIEWPORTS;
>
> /* Timer queries, present when the clock frequency is non zero. */
> case PIPE_CAP_QUERY_TIME_ELAPSED:
> diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
> index 7237854..ac69895 100644
> --- a/src/gallium/drivers/r600/r600_pipe.h
> +++ b/src/gallium/drivers/r600/r600_pipe.h
> @@ -38,6 +38,8 @@
>
> #define R600_NUM_ATOMS 73
>
> +#define R600_MAX_VIEWPORTS 16
> +
> /* read caches */
> #define R600_CONTEXT_INV_VERTEX_CACHE (R600_CONTEXT_PRIVATE_FLAG << 0)
> #define R600_CONTEXT_INV_TEX_CACHE (R600_CONTEXT_PRIVATE_FLAG << 1)
> @@ -443,12 +445,12 @@ struct r600_context {
> struct r600_poly_offset_state poly_offset_state;
> struct r600_cso_state rasterizer_state;
> struct r600_sample_mask sample_mask;
> - struct r600_scissor_state scissor[16];
> + struct r600_scissor_state scissor[R600_MAX_VIEWPORTS];
> struct r600_seamless_cube_map seamless_cube_map;
> struct r600_config_state config_state;
> struct r600_stencil_ref_state stencil_ref;
> struct r600_vgt_state vgt_state;
> - struct r600_viewport_state viewport[16];
> + struct r600_viewport_state viewport[R600_MAX_VIEWPORTS];
> /* Shaders and shader resources. */
> struct r600_cso_state vertex_fetch_shader;
> struct r600_shader_state vertex_shader;
> diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
> index 26d7300..79a08e3 100644
> --- a/src/gallium/drivers/r600/r600_state.c
> +++ b/src/gallium/drivers/r600/r600_state.c
> @@ -2388,7 +2388,7 @@ void r600_init_atom_start_cs(struct r600_context *rctx)
> r600_store_value(cb, fui(1.0)); /* R_028C18_PA_CL_GB_HORZ_DISC_ADJ */
>
> - r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * 16);
> + r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * R600_MAX_VIEWPORTS);
> - for (tmp = 0; tmp < 16; tmp++) {
> + for (tmp = 0; tmp < R600_MAX_VIEWPORTS; tmp++) {
> r600_store_value(cb, 0); /* R_0282D0_PA_SC_VPORT_ZMIN_0 */
> r600_store_value(cb, fui(1.0)); /* R_0282D4_PA_SC_VPORT_ZMAX_0 */
> }
> @@ -3065,7 +3065,7 @@ void r600_init_state_functions(struct r600_context *rctx)
> r600_init_atom(rctx, &rctx->dsa_state.atom, id++, r600_emit_cso_state, 0);
> r600_init_atom(rctx, &rctx->poly_offset_state.atom, id++, r600_emit_polygon_offset, 6);
> r600_init_atom(rctx, &rctx->rasterizer_state.atom, id++, r600_emit_cso_state, 0);
> - for (i = 0;i < 16; i++) {
> + for (i = 0;i < R600_MAX_VIEWPORTS; i++) {
> r600_init_atom(rctx, &rctx->scissor[i].atom, id++, r600_emit_scissor_state, 4);
> r600_init_atom(rctx, &rctx->viewport[i].atom, id++, r600_emit_viewport_state, 8);
> rctx->scissor[i].idx = i;
> --
> 2.3.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list