etna_create_sampler_view_desc(struct pipe_context *pctx, struct pipe_resource *prsc,
const struct pipe_sampler_view *so)
{
+ const struct util_format_description *desc = util_format_description(so->format);
struct etna_sampler_view_desc *sv = CALLOC_STRUCT(etna_sampler_view_desc);
struct etna_context *ctx = etna_context(pctx);
const uint32_t format = translate_texture_format(so->format);
/** GC7000 needs the size of the BASELOD level */
uint32_t base_width = u_minify(res->base.width0, sv->base.u.tex.first_level);
uint32_t base_height = u_minify(res->base.height0, sv->base.u.tex.first_level);
+ uint32_t base_depth = u_minify(res->base.depth0, sv->base.u.tex.first_level);
+ bool is_array = false;
+ bool sint = util_format_is_pure_sint(so->format);
+
+ if (sv->base.target == PIPE_TEXTURE_1D_ARRAY) {
+ is_array = true;
+ base_height = res->base.array_size;
+ } else if (sv->base.target == PIPE_TEXTURE_2D_ARRAY) {
+ is_array = true;
+ base_depth = res->base.array_size;
+ }
#define DESC_SET(x, y) buf[(TEXDESC_##x)>>2] = (y)
DESC_SET(CONFIG0, COND(!ext && !astc, VIVS_TE_SAMPLER_CONFIG0_FORMAT(format))
VIVS_TE_SAMPLER_CONFIG0_ADDRESSING_MODE(TEXTURE_ADDRESSING_MODE_LINEAR)));
DESC_SET(CONFIG1, COND(ext, VIVS_TE_SAMPLER_CONFIG1_FORMAT_EXT(format)) |
COND(astc, VIVS_TE_SAMPLER_CONFIG1_FORMAT_EXT(TEXTURE_FORMAT_EXT_ASTC)) |
- VIVS_TE_SAMPLER_CONFIG1_HALIGN(res->halign) | swiz);
- DESC_SET(CONFIG2, 0x00030000);
+ COND(is_array, VIVS_TE_SAMPLER_CONFIG1_TEXTURE_ARRAY) |
+ VIVS_TE_SAMPLER_CONFIG1_HALIGN(res->halign) | swiz);
+ DESC_SET(CONFIG2, 0x00030000 |
+ COND(sint && desc->channel[0].size == 8, TE_SAMPLER_CONFIG2_SIGNED_INT8) |
+ COND(sint && desc->channel[0].size == 16, TE_SAMPLER_CONFIG2_SIGNED_INT16));
DESC_SET(LINEAR_STRIDE, res->levels[0].stride);
+ DESC_SET(VOLUME, etna_log2_fixp88(base_depth));
DESC_SET(SLICE, res->levels[0].layer_stride);
- DESC_SET(3D_CONFIG, 0x00000001);
+ DESC_SET(3D_CONFIG, VIVS_TE_SAMPLER_3D_CONFIG_DEPTH(base_depth));
DESC_SET(ASTC0, COND(astc, VIVS_NTE_SAMPLER_ASTC0_ASTC_FORMAT(format)) |
VIVS_NTE_SAMPLER_ASTC0_UNK8(0xc) |
VIVS_NTE_SAMPLER_ASTC0_UNK16(0xc) |