/* Texturing. */
case PIPE_CAP_MAX_TEXTURE_2D_SIZE:
+ case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: /* TODO: verify */
return screen->specs.max_texture_size;
case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
+ case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
{
int log2_max_tex_size = util_last_bit(screen->specs.max_texture_size);
assert(log2_max_tex_size > 0);
return log2_max_tex_size;
}
- case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: /* 3D textures not supported - fake it */
- return 5;
+
case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET:
case PIPE_CAP_MIN_TEXEL_OFFSET:
return -8;
struct etna_screen *screen = etna_screen(pscreen);
unsigned allowed = 0;
- if (target != PIPE_BUFFER &&
- target != PIPE_TEXTURE_1D &&
- target != PIPE_TEXTURE_2D &&
- target != PIPE_TEXTURE_3D &&
- target != PIPE_TEXTURE_CUBE &&
- target != PIPE_TEXTURE_RECT)
+ if (translate_texture_target(target) == ETNA_NO_MATCH)
+ return false;
+
+ /* pre-halti has no array/3D */
+ if (screen->specs.halti < 0 &&
+ (target == PIPE_TEXTURE_1D_ARRAY ||
+ target == PIPE_TEXTURE_2D_ARRAY ||
+ target == PIPE_TEXTURE_3D))
return false;
if (MAX2(1, sample_count) != MAX2(1, storage_sample_count))
COND(ss->lod_bias != 0.0, VIVS_TE_SAMPLER_LOD_CONFIG_BIAS_ENABLE) |
VIVS_TE_SAMPLER_LOD_CONFIG_BIAS(etna_float_to_fixp55(ss->lod_bias));
+ cs->TE_SAMPLER_3D_CONFIG =
+ VIVS_TE_SAMPLER_3D_CONFIG_WRAP(translate_texture_wrapmode(ss->wrap_r));
+
if (ss->min_mip_filter != PIPE_TEX_MIPFILTER_NONE) {
cs->min_lod = etna_float_to_fixp55(ss->min_lod);
cs->max_lod = etna_float_to_fixp55(ss->max_lod);
sv->base.context = pctx;
/* merged with sampler state */
- sv->TE_SAMPLER_CONFIG0 = COND(!ext && !astc, VIVS_TE_SAMPLER_CONFIG0_FORMAT(format));
+ sv->TE_SAMPLER_CONFIG0 =
+ VIVS_TE_SAMPLER_CONFIG0_TYPE(translate_texture_target(sv->base.target)) |
+ COND(!ext && !astc, VIVS_TE_SAMPLER_CONFIG0_FORMAT(format));
sv->TE_SAMPLER_CONFIG0_MASK = 0xffffffff;
+ uint32_t base_height = res->base.height0;
+ uint32_t base_depth = res->base.depth0;
+ bool is_array = false;
+
switch (sv->base.target) {
case PIPE_TEXTURE_1D:
- /* For 1D textures, we will have a height of 1, so we can use 2D
- * but set T wrap to repeat */
+ /* use 2D texture with T wrap to repeat for 1D texture
+ * TODO: check if old HW supports 1D texture
+ */
sv->TE_SAMPLER_CONFIG0_MASK = ~VIVS_TE_SAMPLER_CONFIG0_VWRAP__MASK;
- sv->TE_SAMPLER_CONFIG0 |= VIVS_TE_SAMPLER_CONFIG0_VWRAP(TEXTURE_WRAPMODE_REPEAT);
- /* fallthrough */
- case PIPE_TEXTURE_2D:
- case PIPE_TEXTURE_RECT:
- sv->TE_SAMPLER_CONFIG0 |= VIVS_TE_SAMPLER_CONFIG0_TYPE(TEXTURE_TYPE_2D);
+ sv->TE_SAMPLER_CONFIG0 &= ~VIVS_TE_SAMPLER_CONFIG0_TYPE__MASK;
+ sv->TE_SAMPLER_CONFIG0 |=
+ VIVS_TE_SAMPLER_CONFIG0_TYPE(TEXTURE_TYPE_2D) |
+ VIVS_TE_SAMPLER_CONFIG0_VWRAP(TEXTURE_WRAPMODE_REPEAT);
+ break;
+ case PIPE_TEXTURE_1D_ARRAY:
+ is_array = true;
+ base_height = res->base.array_size;
break;
- case PIPE_TEXTURE_CUBE:
- sv->TE_SAMPLER_CONFIG0 |= VIVS_TE_SAMPLER_CONFIG0_TYPE(TEXTURE_TYPE_CUBE_MAP);
+ case PIPE_TEXTURE_2D_ARRAY:
+ is_array = true;
+ base_depth = res->base.array_size;
break;
default:
- BUG("Unhandled texture target");
- free(sv);
- return NULL;
+ break;
}
if (res->addressing_mode == ETNA_ADDRESSING_MODE_LINEAR) {
sv->TE_SAMPLER_CONFIG1 |= COND(ext, VIVS_TE_SAMPLER_CONFIG1_FORMAT_EXT(format)) |
COND(astc, VIVS_TE_SAMPLER_CONFIG1_FORMAT_EXT(TEXTURE_FORMAT_EXT_ASTC)) |
+ COND(is_array, VIVS_TE_SAMPLER_CONFIG1_TEXTURE_ARRAY) |
VIVS_TE_SAMPLER_CONFIG1_HALIGN(res->halign) | swiz;
sv->TE_SAMPLER_ASTC0 = COND(astc, VIVS_NTE_SAMPLER_ASTC0_ASTC_FORMAT(format)) |
VIVS_NTE_SAMPLER_ASTC0_UNK8(0xc) |
VIVS_NTE_SAMPLER_ASTC0_UNK16(0xc) |
VIVS_NTE_SAMPLER_ASTC0_UNK24(0xc);
sv->TE_SAMPLER_SIZE = VIVS_TE_SAMPLER_SIZE_WIDTH(res->base.width0) |
- VIVS_TE_SAMPLER_SIZE_HEIGHT(res->base.height0);
+ VIVS_TE_SAMPLER_SIZE_HEIGHT(base_height);
sv->TE_SAMPLER_LOG_SIZE =
VIVS_TE_SAMPLER_LOG_SIZE_WIDTH(etna_log2_fixp55(res->base.width0)) |
- VIVS_TE_SAMPLER_LOG_SIZE_HEIGHT(etna_log2_fixp55(res->base.height0)) |
+ VIVS_TE_SAMPLER_LOG_SIZE_HEIGHT(etna_log2_fixp55(base_height)) |
COND(util_format_is_srgb(so->format) && !astc, VIVS_TE_SAMPLER_LOG_SIZE_SRGB) |
COND(astc, VIVS_TE_SAMPLER_LOG_SIZE_ASTC);
+ sv->TE_SAMPLER_3D_CONFIG =
+ VIVS_TE_SAMPLER_3D_CONFIG_DEPTH(base_depth) |
+ VIVS_TE_SAMPLER_3D_CONFIG_LOG_DEPTH(etna_log2_fixp55(base_depth));
/* Set up levels-of-detail */
for (int lod = 0; lod <= res->base.last_level; ++lod) {
ss = etna_sampler_state(ctx->sampler[x]);
sv = etna_sampler_view(ctx->sampler_view[x]);
+ /*02180*/ EMIT_STATE(TE_SAMPLER_3D_CONFIG(x), ss->TE_SAMPLER_3D_CONFIG |
+ sv->TE_SAMPLER_3D_CONFIG);
+ }
+ }
+ for (int x = 0; x < VIVS_TE_SAMPLER__LEN; ++x) {
+ if ((1 << x) & active_samplers) {
+ ss = etna_sampler_state(ctx->sampler[x]);
+ sv = etna_sampler_view(ctx->sampler_view[x]);
+
/*021C0*/ EMIT_STATE(TE_SAMPLER_CONFIG1(x), ss->TE_SAMPLER_CONFIG1 |
sv->TE_SAMPLER_CONFIG1 |
COND(sv->ts.enable, VIVS_TE_SAMPLER_CONFIG1_USE_TS));