1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright (c) 2012-2015 Etnaviv Project 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sub license, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the 12bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 13bf215546Sopenharmony_ci * of the Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21bf215546Sopenharmony_ci * DEALINGS IN THE SOFTWARE. 22bf215546Sopenharmony_ci * 23bf215546Sopenharmony_ci * Authors: 24bf215546Sopenharmony_ci * Wladimir J. van der Laan <laanwj@gmail.com> 25bf215546Sopenharmony_ci */ 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#include "etnaviv_texture.h" 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#include "hw/common.xml.h" 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci#include "etnaviv_clear_blit.h" 32bf215546Sopenharmony_ci#include "etnaviv_context.h" 33bf215546Sopenharmony_ci#include "etnaviv_emit.h" 34bf215546Sopenharmony_ci#include "etnaviv_format.h" 35bf215546Sopenharmony_ci#include "etnaviv_texture_desc.h" 36bf215546Sopenharmony_ci#include "etnaviv_texture_state.h" 37bf215546Sopenharmony_ci#include "etnaviv_translate.h" 38bf215546Sopenharmony_ci#include "util/u_inlines.h" 39bf215546Sopenharmony_ci#include "util/u_memory.h" 40bf215546Sopenharmony_ci 41bf215546Sopenharmony_ci#include "drm-uapi/drm_fourcc.h" 42bf215546Sopenharmony_ci 43bf215546Sopenharmony_cistatic void 44bf215546Sopenharmony_cietna_bind_sampler_states(struct pipe_context *pctx, enum pipe_shader_type shader, 45bf215546Sopenharmony_ci unsigned start_slot, unsigned num_samplers, 46bf215546Sopenharmony_ci void **samplers) 47bf215546Sopenharmony_ci{ 48bf215546Sopenharmony_ci /* bind fragment sampler */ 49bf215546Sopenharmony_ci struct etna_context *ctx = etna_context(pctx); 50bf215546Sopenharmony_ci struct etna_screen *screen = ctx->screen; 51bf215546Sopenharmony_ci int offset; 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_ci switch (shader) { 54bf215546Sopenharmony_ci case PIPE_SHADER_FRAGMENT: 55bf215546Sopenharmony_ci offset = 0; 56bf215546Sopenharmony_ci ctx->num_fragment_samplers = num_samplers; 57bf215546Sopenharmony_ci break; 58bf215546Sopenharmony_ci case PIPE_SHADER_VERTEX: 59bf215546Sopenharmony_ci offset = screen->specs.vertex_sampler_offset; 60bf215546Sopenharmony_ci break; 61bf215546Sopenharmony_ci default: 62bf215546Sopenharmony_ci assert(!"Invalid shader"); 63bf215546Sopenharmony_ci return; 64bf215546Sopenharmony_ci } 65bf215546Sopenharmony_ci 66bf215546Sopenharmony_ci uint32_t mask = 1 << offset; 67bf215546Sopenharmony_ci for (int idx = 0; idx < num_samplers; ++idx, mask <<= 1) { 68bf215546Sopenharmony_ci ctx->sampler[offset + idx] = samplers[idx]; 69bf215546Sopenharmony_ci if (samplers[idx]) 70bf215546Sopenharmony_ci ctx->active_samplers |= mask; 71bf215546Sopenharmony_ci else 72bf215546Sopenharmony_ci ctx->active_samplers &= ~mask; 73bf215546Sopenharmony_ci } 74bf215546Sopenharmony_ci 75bf215546Sopenharmony_ci ctx->dirty |= ETNA_DIRTY_SAMPLERS; 76bf215546Sopenharmony_ci} 77bf215546Sopenharmony_ci 78bf215546Sopenharmony_cistatic bool 79bf215546Sopenharmony_cietna_configure_sampler_ts(struct etna_sampler_ts *sts, struct pipe_sampler_view *pview, bool enable) 80bf215546Sopenharmony_ci{ 81bf215546Sopenharmony_ci bool dirty = (sts->enable != enable); 82bf215546Sopenharmony_ci 83bf215546Sopenharmony_ci assert(sts); 84bf215546Sopenharmony_ci sts->enable = enable; 85bf215546Sopenharmony_ci 86bf215546Sopenharmony_ci if (!enable) { 87bf215546Sopenharmony_ci sts->TS_SAMPLER_CONFIG = 0; 88bf215546Sopenharmony_ci sts->TS_SAMPLER_STATUS_BASE.bo = NULL; 89bf215546Sopenharmony_ci return dirty; 90bf215546Sopenharmony_ci } 91bf215546Sopenharmony_ci 92bf215546Sopenharmony_ci struct etna_resource *rsc = etna_resource(pview->texture); 93bf215546Sopenharmony_ci struct etna_resource_level *lev = &rsc->levels[0]; 94bf215546Sopenharmony_ci 95bf215546Sopenharmony_ci if (lev->clear_value != sts->TS_SAMPLER_CLEAR_VALUE) 96bf215546Sopenharmony_ci dirty = true; 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_ci assert(rsc->ts_bo && lev->ts_valid); 99bf215546Sopenharmony_ci 100bf215546Sopenharmony_ci sts->mode = lev->ts_mode; 101bf215546Sopenharmony_ci sts->comp = lev->ts_compress_fmt >= 0; 102bf215546Sopenharmony_ci sts->TS_SAMPLER_CONFIG = 103bf215546Sopenharmony_ci VIVS_TS_SAMPLER_CONFIG_ENABLE | 104bf215546Sopenharmony_ci COND(lev->ts_compress_fmt >= 0, VIVS_TS_SAMPLER_CONFIG_COMPRESSION) | 105bf215546Sopenharmony_ci VIVS_TS_SAMPLER_CONFIG_COMPRESSION_FORMAT(lev->ts_compress_fmt); 106bf215546Sopenharmony_ci sts->TS_SAMPLER_CLEAR_VALUE = lev->clear_value; 107bf215546Sopenharmony_ci sts->TS_SAMPLER_CLEAR_VALUE2 = lev->clear_value >> 32; 108bf215546Sopenharmony_ci sts->TS_SAMPLER_STATUS_BASE.bo = rsc->ts_bo; 109bf215546Sopenharmony_ci sts->TS_SAMPLER_STATUS_BASE.offset = lev->ts_offset; 110bf215546Sopenharmony_ci sts->TS_SAMPLER_STATUS_BASE.flags = ETNA_RELOC_READ; 111bf215546Sopenharmony_ci 112bf215546Sopenharmony_ci return dirty; 113bf215546Sopenharmony_ci} 114bf215546Sopenharmony_ci 115bf215546Sopenharmony_ci/* Return true if the GPU can use sampler TS with this sampler view. 116bf215546Sopenharmony_ci * Sampler TS is an optimization used when rendering to textures, where 117bf215546Sopenharmony_ci * a resolve-in-place can be avoided when rendering has left a (valid) TS. 118bf215546Sopenharmony_ci */ 119bf215546Sopenharmony_cistatic bool 120bf215546Sopenharmony_cietna_can_use_sampler_ts(struct pipe_sampler_view *view, int num) 121bf215546Sopenharmony_ci{ 122bf215546Sopenharmony_ci /* Can use sampler TS when: 123bf215546Sopenharmony_ci * - the hardware supports sampler TS. 124bf215546Sopenharmony_ci * - the sampler view will be bound to sampler <VIVS_TS_SAMPLER__LEN. 125bf215546Sopenharmony_ci * HALTI5 adds a mapping from sampler to sampler TS unit, but this is AFAIK 126bf215546Sopenharmony_ci * absent on earlier models. 127bf215546Sopenharmony_ci * - it is a texture, not a buffer. 128bf215546Sopenharmony_ci * - the sampler view has a supported format for sampler TS. 129bf215546Sopenharmony_ci * - the sampler will have one LOD, and it happens to be level 0. 130bf215546Sopenharmony_ci * (it is not sure if the hw supports it for other levels, but available 131bf215546Sopenharmony_ci * state strongly suggests only one at a time). 132bf215546Sopenharmony_ci * - the resource TS is valid for level 0. 133bf215546Sopenharmony_ci */ 134bf215546Sopenharmony_ci struct etna_resource *rsc = etna_resource(view->texture); 135bf215546Sopenharmony_ci struct etna_screen *screen = etna_screen(rsc->base.screen); 136bf215546Sopenharmony_ci 137bf215546Sopenharmony_ci return VIV_FEATURE(screen, chipMinorFeatures2, TEXTURE_TILED_READ) && 138bf215546Sopenharmony_ci num < VIVS_TS_SAMPLER__LEN && 139bf215546Sopenharmony_ci rsc->base.target != PIPE_BUFFER && 140bf215546Sopenharmony_ci (rsc->levels[0].ts_compress_fmt < 0 || screen->specs.v4_compression) && 141bf215546Sopenharmony_ci view->u.tex.first_level == 0 && MIN2(view->u.tex.last_level, rsc->base.last_level) == 0 && 142bf215546Sopenharmony_ci rsc->levels[0].ts_valid; 143bf215546Sopenharmony_ci} 144bf215546Sopenharmony_ci 145bf215546Sopenharmony_civoid 146bf215546Sopenharmony_cietna_update_sampler_source(struct pipe_sampler_view *view, int num) 147bf215546Sopenharmony_ci{ 148bf215546Sopenharmony_ci struct etna_resource *base = etna_resource(view->texture); 149bf215546Sopenharmony_ci struct etna_resource *to = base, *from = base; 150bf215546Sopenharmony_ci struct etna_context *ctx = etna_context(view->context); 151bf215546Sopenharmony_ci bool enable_sampler_ts = false; 152bf215546Sopenharmony_ci 153bf215546Sopenharmony_ci if (base->render && etna_resource_newer(etna_resource(base->render), base)) 154bf215546Sopenharmony_ci from = etna_resource(base->render); 155bf215546Sopenharmony_ci 156bf215546Sopenharmony_ci if (base->texture) 157bf215546Sopenharmony_ci to = etna_resource(base->texture); 158bf215546Sopenharmony_ci 159bf215546Sopenharmony_ci if ((to != from) && etna_resource_older(to, from)) { 160bf215546Sopenharmony_ci etna_copy_resource(view->context, &to->base, &from->base, 0, 161bf215546Sopenharmony_ci view->texture->last_level); 162bf215546Sopenharmony_ci to->seqno = from->seqno; 163bf215546Sopenharmony_ci ctx->dirty |= ETNA_DIRTY_TEXTURE_CACHES; 164bf215546Sopenharmony_ci } else if ((to == from) && etna_resource_needs_flush(to)) { 165bf215546Sopenharmony_ci if (ctx->ts_for_sampler_view && etna_can_use_sampler_ts(view, num)) { 166bf215546Sopenharmony_ci enable_sampler_ts = true; 167bf215546Sopenharmony_ci /* Do not set flush_seqno because the resolve-to-self was bypassed */ 168bf215546Sopenharmony_ci } else { 169bf215546Sopenharmony_ci /* Resolve TS if needed */ 170bf215546Sopenharmony_ci etna_copy_resource(view->context, &to->base, &from->base, 0, 171bf215546Sopenharmony_ci view->texture->last_level); 172bf215546Sopenharmony_ci to->flush_seqno = from->seqno; 173bf215546Sopenharmony_ci ctx->dirty |= ETNA_DIRTY_TEXTURE_CACHES; 174bf215546Sopenharmony_ci } 175bf215546Sopenharmony_ci } else if ((to == from) && (to->flush_seqno < from->seqno)) { 176bf215546Sopenharmony_ci to->flush_seqno = from->seqno; 177bf215546Sopenharmony_ci ctx->dirty |= ETNA_DIRTY_TEXTURE_CACHES; 178bf215546Sopenharmony_ci } 179bf215546Sopenharmony_ci if (ctx->ts_for_sampler_view && 180bf215546Sopenharmony_ci etna_configure_sampler_ts(ctx->ts_for_sampler_view(view), view, enable_sampler_ts)) { 181bf215546Sopenharmony_ci ctx->dirty |= ETNA_DIRTY_SAMPLER_VIEWS | ETNA_DIRTY_TEXTURE_CACHES; 182bf215546Sopenharmony_ci ctx->dirty_sampler_views |= (1 << num); 183bf215546Sopenharmony_ci } 184bf215546Sopenharmony_ci} 185bf215546Sopenharmony_ci 186bf215546Sopenharmony_cistatic bool 187bf215546Sopenharmony_cietna_resource_sampler_compatible(struct etna_resource *res) 188bf215546Sopenharmony_ci{ 189bf215546Sopenharmony_ci if (util_format_is_compressed(res->base.format)) 190bf215546Sopenharmony_ci return true; 191bf215546Sopenharmony_ci 192bf215546Sopenharmony_ci struct etna_screen *screen = etna_screen(res->base.screen); 193bf215546Sopenharmony_ci /* This GPU supports texturing from supertiled textures? */ 194bf215546Sopenharmony_ci if (res->layout == ETNA_LAYOUT_SUPER_TILED && VIV_FEATURE(screen, chipMinorFeatures2, SUPERTILED_TEXTURE)) 195bf215546Sopenharmony_ci return true; 196bf215546Sopenharmony_ci 197bf215546Sopenharmony_ci /* This GPU supports texturing from linear textures? */ 198bf215546Sopenharmony_ci if (res->layout == ETNA_LAYOUT_LINEAR && VIV_FEATURE(screen, chipMinorFeatures1, LINEAR_TEXTURE_SUPPORT)) 199bf215546Sopenharmony_ci return true; 200bf215546Sopenharmony_ci 201bf215546Sopenharmony_ci /* Otherwise, only support tiled layouts */ 202bf215546Sopenharmony_ci if (res->layout != ETNA_LAYOUT_TILED) 203bf215546Sopenharmony_ci return false; 204bf215546Sopenharmony_ci 205bf215546Sopenharmony_ci /* If we have HALIGN support, we can allow for the RS padding */ 206bf215546Sopenharmony_ci if (VIV_FEATURE(screen, chipMinorFeatures1, TEXTURE_HALIGN)) 207bf215546Sopenharmony_ci return true; 208bf215546Sopenharmony_ci 209bf215546Sopenharmony_ci /* Non-HALIGN GPUs only accept 4x4 tile-aligned textures */ 210bf215546Sopenharmony_ci if (res->halign != TEXTURE_HALIGN_FOUR) 211bf215546Sopenharmony_ci return false; 212bf215546Sopenharmony_ci 213bf215546Sopenharmony_ci return true; 214bf215546Sopenharmony_ci} 215bf215546Sopenharmony_ci 216bf215546Sopenharmony_cistruct etna_resource * 217bf215546Sopenharmony_cietna_texture_handle_incompatible(struct pipe_context *pctx, struct pipe_resource *prsc) 218bf215546Sopenharmony_ci{ 219bf215546Sopenharmony_ci struct etna_resource *res = etna_resource(prsc); 220bf215546Sopenharmony_ci if (!etna_resource_sampler_compatible(res)) { 221bf215546Sopenharmony_ci /* The original resource is not compatible with the sampler. 222bf215546Sopenharmony_ci * Allocate an appropriately tiled texture. */ 223bf215546Sopenharmony_ci if (!res->texture) { 224bf215546Sopenharmony_ci struct pipe_resource templat = *prsc; 225bf215546Sopenharmony_ci 226bf215546Sopenharmony_ci templat.bind &= ~(PIPE_BIND_DEPTH_STENCIL | PIPE_BIND_RENDER_TARGET | 227bf215546Sopenharmony_ci PIPE_BIND_BLENDABLE); 228bf215546Sopenharmony_ci res->texture = 229bf215546Sopenharmony_ci etna_resource_alloc(pctx->screen, ETNA_LAYOUT_TILED, 230bf215546Sopenharmony_ci DRM_FORMAT_MOD_LINEAR, &templat); 231bf215546Sopenharmony_ci } 232bf215546Sopenharmony_ci 233bf215546Sopenharmony_ci if (!res->texture) { 234bf215546Sopenharmony_ci return NULL; 235bf215546Sopenharmony_ci } 236bf215546Sopenharmony_ci res = etna_resource(res->texture); 237bf215546Sopenharmony_ci } 238bf215546Sopenharmony_ci return res; 239bf215546Sopenharmony_ci} 240bf215546Sopenharmony_ci 241bf215546Sopenharmony_cistatic void 242bf215546Sopenharmony_ciset_sampler_views(struct etna_context *ctx, unsigned start, unsigned end, 243bf215546Sopenharmony_ci unsigned nr, bool take_ownership, struct pipe_sampler_view **views) 244bf215546Sopenharmony_ci{ 245bf215546Sopenharmony_ci unsigned i, j; 246bf215546Sopenharmony_ci uint32_t mask = 1 << start; 247bf215546Sopenharmony_ci uint32_t prev_active_sampler_views = ctx->active_sampler_views; 248bf215546Sopenharmony_ci 249bf215546Sopenharmony_ci for (i = start, j = 0; j < nr; i++, j++, mask <<= 1) { 250bf215546Sopenharmony_ci struct pipe_sampler_view *view = views ? views[j] : NULL; 251bf215546Sopenharmony_ci 252bf215546Sopenharmony_ci if (take_ownership) { 253bf215546Sopenharmony_ci pipe_sampler_view_reference(&ctx->sampler_view[i], NULL); 254bf215546Sopenharmony_ci ctx->sampler_view[i] = view; 255bf215546Sopenharmony_ci } else { 256bf215546Sopenharmony_ci pipe_sampler_view_reference(&ctx->sampler_view[i], view); 257bf215546Sopenharmony_ci } 258bf215546Sopenharmony_ci if (view) { 259bf215546Sopenharmony_ci ctx->active_sampler_views |= mask; 260bf215546Sopenharmony_ci ctx->dirty_sampler_views |= mask; 261bf215546Sopenharmony_ci } else 262bf215546Sopenharmony_ci ctx->active_sampler_views &= ~mask; 263bf215546Sopenharmony_ci } 264bf215546Sopenharmony_ci 265bf215546Sopenharmony_ci for (; i < end; i++, mask <<= 1) { 266bf215546Sopenharmony_ci pipe_sampler_view_reference(&ctx->sampler_view[i], NULL); 267bf215546Sopenharmony_ci ctx->active_sampler_views &= ~mask; 268bf215546Sopenharmony_ci } 269bf215546Sopenharmony_ci 270bf215546Sopenharmony_ci /* sampler views that changed state (even to inactive) are also dirty */ 271bf215546Sopenharmony_ci ctx->dirty_sampler_views |= ctx->active_sampler_views ^ prev_active_sampler_views; 272bf215546Sopenharmony_ci} 273bf215546Sopenharmony_ci 274bf215546Sopenharmony_cistatic inline void 275bf215546Sopenharmony_cietna_fragtex_set_sampler_views(struct etna_context *ctx, unsigned nr, 276bf215546Sopenharmony_ci bool take_ownership, 277bf215546Sopenharmony_ci struct pipe_sampler_view **views) 278bf215546Sopenharmony_ci{ 279bf215546Sopenharmony_ci struct etna_screen *screen = ctx->screen; 280bf215546Sopenharmony_ci unsigned start = 0; 281bf215546Sopenharmony_ci unsigned end = start + screen->specs.fragment_sampler_count; 282bf215546Sopenharmony_ci 283bf215546Sopenharmony_ci set_sampler_views(ctx, start, end, nr, take_ownership, views); 284bf215546Sopenharmony_ci ctx->num_fragment_sampler_views = nr; 285bf215546Sopenharmony_ci} 286bf215546Sopenharmony_ci 287bf215546Sopenharmony_ci 288bf215546Sopenharmony_cistatic inline void 289bf215546Sopenharmony_cietna_vertex_set_sampler_views(struct etna_context *ctx, unsigned nr, 290bf215546Sopenharmony_ci bool take_ownership, 291bf215546Sopenharmony_ci struct pipe_sampler_view **views) 292bf215546Sopenharmony_ci{ 293bf215546Sopenharmony_ci struct etna_screen *screen = ctx->screen; 294bf215546Sopenharmony_ci unsigned start = screen->specs.vertex_sampler_offset; 295bf215546Sopenharmony_ci unsigned end = start + screen->specs.vertex_sampler_count; 296bf215546Sopenharmony_ci 297bf215546Sopenharmony_ci set_sampler_views(ctx, start, end, nr, take_ownership, views); 298bf215546Sopenharmony_ci} 299bf215546Sopenharmony_ci 300bf215546Sopenharmony_cistatic void 301bf215546Sopenharmony_cietna_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader, 302bf215546Sopenharmony_ci unsigned start_slot, unsigned num_views, 303bf215546Sopenharmony_ci unsigned unbind_num_trailing_slots, 304bf215546Sopenharmony_ci bool take_ownership, 305bf215546Sopenharmony_ci struct pipe_sampler_view **views) 306bf215546Sopenharmony_ci{ 307bf215546Sopenharmony_ci struct etna_context *ctx = etna_context(pctx); 308bf215546Sopenharmony_ci assert(start_slot == 0); 309bf215546Sopenharmony_ci 310bf215546Sopenharmony_ci ctx->dirty |= ETNA_DIRTY_SAMPLER_VIEWS | ETNA_DIRTY_TEXTURE_CACHES; 311bf215546Sopenharmony_ci 312bf215546Sopenharmony_ci switch (shader) { 313bf215546Sopenharmony_ci case PIPE_SHADER_FRAGMENT: 314bf215546Sopenharmony_ci etna_fragtex_set_sampler_views(ctx, num_views, take_ownership, views); 315bf215546Sopenharmony_ci break; 316bf215546Sopenharmony_ci case PIPE_SHADER_VERTEX: 317bf215546Sopenharmony_ci etna_vertex_set_sampler_views(ctx, num_views, take_ownership, views); 318bf215546Sopenharmony_ci break; 319bf215546Sopenharmony_ci default:; 320bf215546Sopenharmony_ci } 321bf215546Sopenharmony_ci} 322bf215546Sopenharmony_ci 323bf215546Sopenharmony_cistatic void 324bf215546Sopenharmony_cietna_texture_barrier(struct pipe_context *pctx, unsigned flags) 325bf215546Sopenharmony_ci{ 326bf215546Sopenharmony_ci struct etna_context *ctx = etna_context(pctx); 327bf215546Sopenharmony_ci /* clear color and texture cache to make sure that texture unit reads 328bf215546Sopenharmony_ci * what has been written */ 329bf215546Sopenharmony_ci etna_set_state(ctx->stream, VIVS_GL_FLUSH_CACHE, VIVS_GL_FLUSH_CACHE_COLOR | VIVS_GL_FLUSH_CACHE_TEXTURE); 330bf215546Sopenharmony_ci} 331bf215546Sopenharmony_ci 332bf215546Sopenharmony_ciuint32_t 333bf215546Sopenharmony_ciactive_samplers_bits(struct etna_context *ctx) 334bf215546Sopenharmony_ci{ 335bf215546Sopenharmony_ci return ctx->active_sampler_views & ctx->active_samplers; 336bf215546Sopenharmony_ci} 337bf215546Sopenharmony_ci 338bf215546Sopenharmony_civoid 339bf215546Sopenharmony_cietna_texture_init(struct pipe_context *pctx) 340bf215546Sopenharmony_ci{ 341bf215546Sopenharmony_ci struct etna_context *ctx = etna_context(pctx); 342bf215546Sopenharmony_ci struct etna_screen *screen = ctx->screen; 343bf215546Sopenharmony_ci 344bf215546Sopenharmony_ci pctx->bind_sampler_states = etna_bind_sampler_states; 345bf215546Sopenharmony_ci pctx->set_sampler_views = etna_set_sampler_views; 346bf215546Sopenharmony_ci pctx->texture_barrier = etna_texture_barrier; 347bf215546Sopenharmony_ci 348bf215546Sopenharmony_ci if (screen->specs.halti >= 5) { 349bf215546Sopenharmony_ci u_suballocator_init(&ctx->tex_desc_allocator, pctx, 4096, 0, 350bf215546Sopenharmony_ci PIPE_USAGE_IMMUTABLE, 0, true); 351bf215546Sopenharmony_ci etna_texture_desc_init(pctx); 352bf215546Sopenharmony_ci } else { 353bf215546Sopenharmony_ci etna_texture_state_init(pctx); 354bf215546Sopenharmony_ci } 355bf215546Sopenharmony_ci} 356bf215546Sopenharmony_ci 357bf215546Sopenharmony_civoid 358bf215546Sopenharmony_cietna_texture_fini(struct pipe_context *pctx) 359bf215546Sopenharmony_ci{ 360bf215546Sopenharmony_ci struct etna_context *ctx = etna_context(pctx); 361bf215546Sopenharmony_ci struct etna_screen *screen = ctx->screen; 362bf215546Sopenharmony_ci 363bf215546Sopenharmony_ci if (screen->specs.halti >= 5) 364bf215546Sopenharmony_ci u_suballocator_destroy(&ctx->tex_desc_allocator); 365bf215546Sopenharmony_ci} 366