X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fnouveau%2Fnv50%2Fnv50_miptree.c;h=745011977b3d3d317f9f197b4a28f0819760b010;hb=59a692916ca251db995050f7fc0bb7b4e6e4780b;hp=2e410912acb56a6b5b446f9b2c566895db101fd2;hpb=1f8c0be27e1aa09e39d3016b6aae96c3ac228e17;p=mesa.git diff --git a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c index 2e410912acb..745011977b3 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c @@ -29,7 +29,8 @@ #include "nv50/nv50_resource.h" uint32_t -nv50_tex_choose_tile_dims_helper(unsigned nx, unsigned ny, unsigned nz) +nv50_tex_choose_tile_dims_helper(unsigned nx, unsigned ny, unsigned nz, + bool is_3d) { uint32_t tile_mode = 0x000; @@ -41,7 +42,7 @@ nv50_tex_choose_tile_dims_helper(unsigned nx, unsigned ny, unsigned nz) else if (ny > 8) tile_mode = 0x010; /* height 16 tiles */ - if (nz == 1) + if (!is_3d) return tile_mode; else if (tile_mode > 0x020) @@ -52,18 +53,19 @@ nv50_tex_choose_tile_dims_helper(unsigned nx, unsigned ny, unsigned nz) if (nz > 8) return tile_mode | 0x400; /* depth 16 tiles */ if (nz > 4) return tile_mode | 0x300; /* depth 8 tiles */ if (nz > 2) return tile_mode | 0x200; /* depth 4 tiles */ + if (nz > 1) return tile_mode | 0x100; /* depth 2 tiles */ - return tile_mode | 0x100; + return tile_mode; } static uint32_t -nv50_tex_choose_tile_dims(unsigned nx, unsigned ny, unsigned nz) +nv50_tex_choose_tile_dims(unsigned nx, unsigned ny, unsigned nz, bool is_3d) { - return nv50_tex_choose_tile_dims_helper(nx, ny * 2, nz); + return nv50_tex_choose_tile_dims_helper(nx, ny * 2, nz, is_3d); } static uint32_t -nv50_mt_choose_storage_type(struct nv50_miptree *mt, boolean compressed) +nv50_mt_choose_storage_type(struct nv50_miptree *mt, bool compressed) { const unsigned ms = util_logbase2(mt->base.base.nr_samples); uint32_t tile_flags; @@ -161,7 +163,10 @@ nv50_miptree_destroy(struct pipe_screen *pscreen, struct pipe_resource *pt) { struct nv50_miptree *mt = nv50_miptree(pt); - nouveau_bo_ref(NULL, &mt->base.bo); + if (mt->base.fence && mt->base.fence->state < NOUVEAU_FENCE_STATE_FLUSHED) + nouveau_fence_work(mt->base.fence, nouveau_fence_unref_bo, mt->base.bo); + else + nouveau_bo_ref(NULL, &mt->base.bo); nouveau_fence_ref(NULL, &mt->base.fence); nouveau_fence_ref(NULL, &mt->base.fence_wr); @@ -182,7 +187,7 @@ nv50_miptree_get_handle(struct pipe_screen *pscreen, unsigned stride; if (!mt || !mt->base.bo) - return FALSE; + return false; stride = mt->level[0].pitch; @@ -202,7 +207,7 @@ const struct u_resource_vtbl nv50_miptree_vtbl = u_default_transfer_inline_write /* transfer_inline_write */ }; -static INLINE boolean +static inline bool nv50_miptree_init_ms_mode(struct nv50_miptree *mt) { switch (mt->base.base.nr_samples) { @@ -226,12 +231,12 @@ nv50_miptree_init_ms_mode(struct nv50_miptree *mt) break; default: NOUVEAU_ERR("invalid nr_samples: %u\n", mt->base.base.nr_samples); - return FALSE; + return false; } - return TRUE; + return true; } -boolean +bool nv50_miptree_init_layout_linear(struct nv50_miptree *mt, unsigned pitch_align) { struct pipe_resource *pt = &mt->base.base; @@ -239,12 +244,12 @@ nv50_miptree_init_layout_linear(struct nv50_miptree *mt, unsigned pitch_align) unsigned h = pt->height0; if (util_format_is_depth_or_stencil(pt->format)) - return FALSE; + return false; if ((pt->last_level > 0) || (pt->depth0 > 1) || (pt->array_size > 1)) - return FALSE; + return false; if (mt->ms_x | mt->ms_y) - return FALSE; + return false; mt->level[0].pitch = align(pt->width0 * blocksize, pitch_align); @@ -254,7 +259,7 @@ nv50_miptree_init_layout_linear(struct nv50_miptree *mt, unsigned pitch_align) mt->total_size = mt->level[0].pitch * h; - return TRUE; + return true; } static void @@ -304,7 +309,7 @@ nv50_miptree_init_layout_tiled(struct nv50_miptree *mt) lvl->offset = mt->total_size; - lvl->tile_mode = nv50_tex_choose_tile_dims(nbx, nby, d); + lvl->tile_mode = nv50_tex_choose_tile_dims(nbx, nby, d, mt->layout_3d); tsx = NV50_TILE_SIZE_X(lvl->tile_mode); /* x is tile row pitch in bytes */ tsy = NV50_TILE_SIZE_Y(lvl->tile_mode); @@ -331,9 +336,10 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_resource *templ) { struct nouveau_device *dev = nouveau_screen(pscreen)->device; + struct nouveau_drm *drm = nouveau_screen(pscreen)->drm; struct nv50_miptree *mt = CALLOC_STRUCT(nv50_miptree); struct pipe_resource *pt = &mt->base.base; - boolean compressed = dev->drm_version >= 0x01000101; + bool compressed = drm->version >= 0x01000101; int ret; union nouveau_bo_config bo_config; uint32_t bo_flags; @@ -375,7 +381,7 @@ nv50_miptree_create(struct pipe_screen *pscreen, if (!bo_config.nv50.memtype && (pt->bind & PIPE_BIND_SHARED)) mt->base.domain = NOUVEAU_BO_GART; else - mt->base.domain = NOUVEAU_BO_VRAM; + mt->base.domain = NV_VRAM_DOMAIN(nouveau_screen(pscreen)); bo_flags = mt->base.domain | NOUVEAU_BO_NOSNOOP; if (mt->base.base.bind & (PIPE_BIND_CURSOR | PIPE_BIND_DISPLAY_TARGET)) @@ -417,7 +423,7 @@ nv50_miptree_from_handle(struct pipe_screen *pscreen, FREE(mt); return NULL; } - mt->base.domain = NOUVEAU_BO_VRAM; + mt->base.domain = mt->base.bo->flags & NOUVEAU_BO_APER; mt->base.address = mt->base.bo->offset; mt->base.base = *templ; @@ -436,7 +442,7 @@ nv50_miptree_from_handle(struct pipe_screen *pscreen, /* Offset of zslice @z from start of level @l. */ -INLINE unsigned +inline unsigned nv50_mt_zslice_offset(const struct nv50_miptree *mt, unsigned l, unsigned z) { const struct pipe_resource *pt = &mt->base.base;