#include "pipe/p_shader_tokens.h"
#include "pipe/p_state.h"
#include "util/slab.h"
+#include <util/u_suballoc.h>
struct pipe_screen;
struct etna_shader_variant;
} dirty;
struct slab_child_pool transfer_pool;
+ struct u_suballocator tex_desc_allocator;
struct blitter_context *blitter;
/* compiled bindable state */
pctx->set_sampler_views = etna_set_sampler_views;
pctx->texture_barrier = etna_texture_barrier;
- if (screen->specs.halti >= 5)
+ if (screen->specs.halti >= 5) {
+ u_suballocator_init(&ctx->tex_desc_allocator, pctx, 4096, 0,
+ PIPE_USAGE_IMMUTABLE, 0, true);
etna_texture_desc_init(pctx);
- else
+ } else {
etna_texture_state_init(pctx);
+ }
+}
+
+void
+etna_texture_fini(struct pipe_context *pctx)
+{
+ struct etna_context *ctx = etna_context(pctx);
+ struct etna_screen *screen = ctx->screen;
+
+ if (screen->specs.halti >= 5)
+ u_suballocator_destroy(&ctx->tex_desc_allocator);
}
uint32_t SAMP_CTRL0;
uint32_t SAMP_CTRL1;
- struct etna_bo *bo;
+ struct pipe_resource *res;
struct etna_reloc DESC_ADDR;
struct etna_sampler_ts ts;
};
const uint32_t swiz = get_texture_swiz(so->format, so->swizzle_r,
so->swizzle_g, so->swizzle_b,
so->swizzle_a);
+ unsigned suballoc_offset;
if (!sv)
return NULL;
sv->SAMP_CTRL1 |= VIVS_NTE_DESCRIPTOR_SAMP_CTRL1_SRGB;
/* Create texture descriptor */
- sv->bo = etna_bo_new(ctx->screen->dev, 0x100, DRM_ETNA_GEM_CACHE_WC);
- if (!sv->bo)
+ u_suballocator_alloc(&ctx->tex_desc_allocator, 256, 64,
+ &suballoc_offset, &sv->res);
+ if (!sv->res)
goto error;
- uint32_t *buf = etna_bo_map(sv->bo);
- etna_bo_cpu_prep(sv->bo, DRM_ETNA_PREP_WRITE);
- memset(buf, 0, 0x100);
+ uint32_t *buf = etna_bo_map(etna_resource(sv->res)->bo) + suballoc_offset;
/** GC7000 needs the size of the BASELOD level */
uint32_t base_width = u_minify(res->base.width0, sv->base.u.tex.first_level);
DESC_SET(LOD_ADDR(lod), etna_bo_gpu_va(res->bo) + res->levels[lod].offset);
#undef DESC_SET
- etna_bo_cpu_fini(sv->bo);
-
- sv->DESC_ADDR.bo = sv->bo;
- sv->DESC_ADDR.offset = 0;
+ sv->DESC_ADDR.bo = etna_resource(sv->res)->bo;
+ sv->DESC_ADDR.offset = suballoc_offset;
sv->DESC_ADDR.flags = ETNA_RELOC_READ;
return &sv->base;
struct pipe_sampler_view *so)
{
struct etna_sampler_view_desc *sv = etna_sampler_view_desc(so);
+
pipe_resource_reference(&sv->base.texture, NULL);
- etna_bo_del(sv->bo);
+ pipe_resource_reference(&sv->res, NULL);
FREE(sv);
}