From fb4e0b77d5f02efe757e585a316ad385e0570fd5 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 15 Nov 2017 08:26:23 +1000 Subject: [PATCH] r600: fix cubemap arrays A lot of cubemap array piglits fail, port the texture type picking code from radeonsi which seems to fix most of them. For images I will port the rest of the code. Fixes: getteximage-depth gl_texture_cube_map_array-* fbo-generatemipmap-cubemap array getteximage-targets cube_array amongst others. Reviewed-by: Roland Scheidegger Signed-off-by: Dave Airlie (cherry picked from commit 3ceee04a4f963694012ca7f9acd3c747a036472e) Squashed with: r600/eg: use texture target to pick array size not view target (v2) This fixes a few CTS cases in : KHR-GL45.texture_view.view_sampling some multisample cases are still broken, but not sure this is the same problem. v2: fix more cases Cc: Reviewed-by: Roland Scheidegger Signed-off-by: Dave Airlie (cherry picked from commit 012100b80936325945f24a580f643e535028fe19) --- src/gallium/drivers/r600/evergreen_state.c | 41 ++++++++++++++-------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index ff13bddc53e..89e2082239f 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -169,9 +169,20 @@ static uint32_t r600_translate_blend_factor(int blend_fact) return 0; } -static unsigned r600_tex_dim(unsigned dim, unsigned nr_samples) +static unsigned r600_tex_dim(struct r600_texture *rtex, + unsigned view_target, unsigned nr_samples) { - switch (dim) { + unsigned res_target = rtex->resource.b.b.target; + + if (view_target == PIPE_TEXTURE_CUBE || + view_target == PIPE_TEXTURE_CUBE_ARRAY) + res_target = view_target; + /* If interpreting cubemaps as something else, set 2D_ARRAY. */ + else if (res_target == PIPE_TEXTURE_CUBE || + res_target == PIPE_TEXTURE_CUBE_ARRAY) + res_target = PIPE_TEXTURE_2D_ARRAY; + + switch (res_target) { default: case PIPE_TEXTURE_1D: return V_030000_SQ_TEX_DIM_1D; @@ -794,24 +805,24 @@ static int evergreen_fill_tex_resource_words(struct r600_context *rctx, } nbanks = eg_num_banks(rscreen->b.info.r600_num_banks); - if (params->target == PIPE_TEXTURE_1D_ARRAY) { - height = 1; - depth = texture->array_size; - } else if (params->target == PIPE_TEXTURE_2D_ARRAY) { - depth = texture->array_size; - } else if (params->target == PIPE_TEXTURE_CUBE_ARRAY) - depth = texture->array_size / 6; va = tmp->resource.gpu_address; /* array type views and views into array types need to use layer offset */ - dim = params->target; - if (params->target != PIPE_TEXTURE_CUBE) - dim = MAX2(params->target, texture->target); + dim = r600_tex_dim(tmp, params->target, texture->nr_samples); - tex_resource_words[0] = (S_030000_DIM(r600_tex_dim(dim, texture->nr_samples)) | - S_030000_PITCH((pitch / 8) - 1) | - S_030000_TEX_WIDTH(width - 1)); + if (dim == V_030000_SQ_TEX_DIM_1D_ARRAY) { + height = 1; + depth = texture->array_size; + } else if (dim == V_030000_SQ_TEX_DIM_2D_ARRAY || + dim == V_030000_SQ_TEX_DIM_2D_ARRAY_MSAA) { + depth = texture->array_size; + } else if (dim == V_030000_SQ_TEX_DIM_CUBEMAP) + depth = texture->array_size / 6; + + tex_resource_words[0] = (S_030000_DIM(dim) | + S_030000_PITCH((pitch / 8) - 1) | + S_030000_TEX_WIDTH(width - 1)); if (rscreen->b.chip_class == CAYMAN) tex_resource_words[0] |= CM_S_030000_NON_DISP_TILING_ORDER(non_disp_tiling); else