mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 15:10:10 +01:00
nouveau: move util_framebuffer_init into the driver
It will get cleaned up later. Maybe. Also stop setting the context or the reference. It's all dead code now. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35806>
This commit is contained in:
parent
5a91e04fa4
commit
facb048cdb
19 changed files with 108 additions and 41 deletions
|
|
@ -119,4 +119,49 @@ nouveau_context_update_frame_stats(struct nouveau_context *nv)
|
|||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
nv_framebuffer_init(struct pipe_context *pctx,
|
||||
const struct pipe_framebuffer_state *fb,
|
||||
struct pipe_surface **cbufs,
|
||||
struct pipe_surface **zsbuf,
|
||||
struct pipe_surface *(*create)(struct pipe_context *pipe,
|
||||
struct pipe_resource *pt,
|
||||
const struct pipe_surface *tmpl),
|
||||
void (*del)(struct pipe_context *pipe, struct pipe_surface *ps))
|
||||
{
|
||||
if (fb) {
|
||||
for (unsigned i = 0; i < fb->nr_cbufs; i++) {
|
||||
if (cbufs[i] && pipe_surface_equal(&fb->cbufs[i], cbufs[i]))
|
||||
continue;
|
||||
|
||||
struct pipe_surface *psurf = fb->cbufs[i].texture ? create(pctx, fb->cbufs[i].texture, &fb->cbufs[i]) : NULL;
|
||||
if (cbufs[i])
|
||||
del(pctx, cbufs[i]);
|
||||
cbufs[i] = psurf;
|
||||
}
|
||||
|
||||
for (unsigned i = fb->nr_cbufs; i < PIPE_MAX_COLOR_BUFS; i++) {
|
||||
if (cbufs[i])
|
||||
del(pctx, cbufs[i]);
|
||||
cbufs[i] = NULL;
|
||||
}
|
||||
|
||||
if (*zsbuf && pipe_surface_equal(&fb->zsbuf, *zsbuf))
|
||||
return;
|
||||
struct pipe_surface *zsurf = fb->zsbuf.texture ? create(pctx, fb->zsbuf.texture, &fb->zsbuf) : NULL;
|
||||
if (*zsbuf)
|
||||
del(pctx, *zsbuf);
|
||||
*zsbuf = zsurf;
|
||||
} else {
|
||||
for (unsigned i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
|
||||
if (cbufs[i])
|
||||
del(pctx, cbufs[i]);
|
||||
cbufs[i] = NULL;
|
||||
}
|
||||
if (*zsbuf)
|
||||
del(pctx, *zsbuf);
|
||||
*zsbuf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ nv30_context_destroy(struct pipe_context *pipe)
|
|||
if (nv30->blit_fp)
|
||||
pipe_resource_reference(&nv30->blit_fp, NULL);
|
||||
|
||||
util_framebuffer_init(pipe, NULL, nv30->fb_cbufs, &nv30->fb_zsbuf);
|
||||
nv30_framebuffer_init(pipe, NULL, nv30->fb_cbufs, &nv30->fb_zsbuf);
|
||||
util_unreference_framebuffer_state(&nv30->framebuffer);
|
||||
|
||||
nouveau_bufctx_del(&nv30->bufctx);
|
||||
|
|
|
|||
|
|
@ -99,7 +99,8 @@ struct nv30_context {
|
|||
unsigned dirty_samplers;
|
||||
} fragprog;
|
||||
|
||||
PIPE_FB_SURFACES; //STOP USING THIS
|
||||
struct pipe_surface *fb_cbufs[PIPE_MAX_COLOR_BUFS];
|
||||
struct pipe_surface *fb_zsbuf;
|
||||
struct pipe_framebuffer_state framebuffer;
|
||||
struct pipe_blend_color blend_colour;
|
||||
struct pipe_stencil_ref stencil_ref;
|
||||
|
|
|
|||
|
|
@ -541,7 +541,7 @@ nv30_miptree_from_handle(struct pipe_screen *pscreen,
|
|||
return &mt->base.base;
|
||||
}
|
||||
|
||||
struct pipe_surface *
|
||||
static struct pipe_surface *
|
||||
nv30_miptree_surface_new(struct pipe_context *pipe,
|
||||
struct pipe_resource *pt,
|
||||
const struct pipe_surface *tmpl)
|
||||
|
|
@ -556,7 +556,6 @@ nv30_miptree_surface_new(struct pipe_context *pipe,
|
|||
return NULL;
|
||||
ps = &ns->base;
|
||||
|
||||
pipe_reference_init(&ps->reference, 1);
|
||||
pipe_resource_reference(&ps->texture, pt);
|
||||
ps->context = pipe;
|
||||
ps->format = tmpl->format;
|
||||
|
|
@ -576,11 +575,19 @@ nv30_miptree_surface_new(struct pipe_context *pipe,
|
|||
return ps;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
nv30_miptree_surface_del(struct pipe_context *pipe, struct pipe_surface *ps)
|
||||
{
|
||||
struct nv30_surface *ns = nv30_surface(ps);
|
||||
|
||||
pipe_resource_reference(&ps->texture, NULL);
|
||||
FREE(ns);
|
||||
FREE(ps);
|
||||
}
|
||||
|
||||
void
|
||||
nv30_framebuffer_init(struct pipe_context *pctx,
|
||||
const struct pipe_framebuffer_state *fb,
|
||||
struct pipe_surface **cbufs,
|
||||
struct pipe_surface **zsbuf)
|
||||
{
|
||||
return nv_framebuffer_init(pctx, fb, cbufs, zsbuf,
|
||||
nv30_miptree_surface_new,
|
||||
nv30_miptree_surface_del);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,8 +99,6 @@ nv30_resource_init(struct pipe_context *pipe)
|
|||
pipe->texture_unmap = nv30_miptree_transfer_unmap;
|
||||
pipe->buffer_subdata = u_default_buffer_subdata;
|
||||
pipe->texture_subdata = u_default_texture_subdata;
|
||||
pipe->create_surface = nv30_miptree_surface_new;
|
||||
pipe->surface_destroy = nv30_miptree_surface_del;
|
||||
pipe->resource_copy_region = nv30_resource_copy_region;
|
||||
pipe->blit = nv30_blit;
|
||||
pipe->flush_resource = nv30_flush_resource;
|
||||
|
|
|
|||
|
|
@ -51,12 +51,11 @@ struct pipe_resource *
|
|||
nv30_miptree_from_handle(struct pipe_screen *, const struct pipe_resource *,
|
||||
struct winsys_handle *);
|
||||
|
||||
struct pipe_surface *
|
||||
nv30_miptree_surface_new(struct pipe_context *, struct pipe_resource *,
|
||||
const struct pipe_surface *);
|
||||
|
||||
void
|
||||
nv30_miptree_surface_del(struct pipe_context *, struct pipe_surface *);
|
||||
nv30_framebuffer_init(struct pipe_context *pctx,
|
||||
const struct pipe_framebuffer_state *fb,
|
||||
struct pipe_surface **cbufs,
|
||||
struct pipe_surface **zsbuf);
|
||||
|
||||
bool
|
||||
nv30_miptree_get_handle(struct pipe_screen *pscreen,
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ nv30_set_framebuffer_state(struct pipe_context *pipe,
|
|||
debug_printf("Mismatched color and zeta formats, ignoring zeta.\n");
|
||||
}
|
||||
}
|
||||
util_framebuffer_init(pipe, &nv30->framebuffer, nv30->fb_cbufs, &nv30->fb_zsbuf);
|
||||
nv30_framebuffer_init(pipe, &nv30->framebuffer, nv30->fb_cbufs, &nv30->fb_zsbuf);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -195,7 +195,8 @@ struct nv50_context {
|
|||
*/
|
||||
uint32_t so_used[4];
|
||||
|
||||
PIPE_FB_SURFACES; //STOP USING THIS
|
||||
struct pipe_surface *fb_cbufs[PIPE_MAX_COLOR_BUFS];
|
||||
struct pipe_surface *fb_zsbuf;
|
||||
struct pipe_framebuffer_state framebuffer;
|
||||
struct pipe_blend_color blend_colour;
|
||||
struct pipe_stencil_ref stencil_ref;
|
||||
|
|
|
|||
|
|
@ -500,7 +500,6 @@ nv50_miptree_surface_new(struct pipe_context *pipe,
|
|||
struct nv50_surface *ns = nv50_surface_from_miptree(mt, templ);
|
||||
if (!ns)
|
||||
return NULL;
|
||||
ns->base.context = pipe;
|
||||
|
||||
if (ns->base.first_layer) {
|
||||
const unsigned l = ns->base.level;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "util/u_inlines.h"
|
||||
#include "util/format/u_format.h"
|
||||
|
||||
#include "nouveau_context.h"
|
||||
#include "nouveau_screen.h"
|
||||
|
||||
#include "nv50/nv50_resource.h"
|
||||
|
|
@ -40,14 +41,6 @@ nv50_resource_from_handle(struct pipe_screen * screen,
|
|||
return nv50_miptree_from_handle(screen, templ, whandle);
|
||||
}
|
||||
|
||||
static struct pipe_surface *
|
||||
nv50_surface_create(struct pipe_context *pipe,
|
||||
struct pipe_resource *pres,
|
||||
const struct pipe_surface *templ)
|
||||
{
|
||||
return nv50_miptree_surface_new(pipe, pres, templ);
|
||||
}
|
||||
|
||||
void
|
||||
nv50_surface_destroy(struct pipe_context *pipe, struct pipe_surface *ps)
|
||||
{
|
||||
|
|
@ -58,6 +51,17 @@ nv50_surface_destroy(struct pipe_context *pipe, struct pipe_surface *ps)
|
|||
FREE(s);
|
||||
}
|
||||
|
||||
void
|
||||
nv50_framebuffer_init(struct pipe_context *pctx,
|
||||
const struct pipe_framebuffer_state *fb,
|
||||
struct pipe_surface **cbufs,
|
||||
struct pipe_surface **zsbuf)
|
||||
{
|
||||
return nv_framebuffer_init(pctx, fb, cbufs, zsbuf,
|
||||
nv50_miptree_surface_new,
|
||||
nv50_surface_destroy);
|
||||
}
|
||||
|
||||
void
|
||||
nv50_invalidate_resource(struct pipe_context *pipe, struct pipe_resource *res)
|
||||
{
|
||||
|
|
@ -142,7 +146,6 @@ nv50_init_resource_functions(struct pipe_context *pcontext)
|
|||
pcontext->texture_unmap = nv50_miptree_transfer_unmap;
|
||||
pcontext->buffer_subdata = u_default_buffer_subdata;
|
||||
pcontext->texture_subdata = u_default_texture_subdata;
|
||||
pcontext->create_surface = nv50_surface_create;
|
||||
pcontext->surface_destroy = nv50_surface_destroy;
|
||||
pcontext->invalidate_resource = nv50_invalidate_resource;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,6 +156,12 @@ nv50_surface_from_miptree(struct nv50_miptree *mt,
|
|||
void
|
||||
nv50_surface_destroy(struct pipe_context *, struct pipe_surface *);
|
||||
|
||||
void
|
||||
nv50_framebuffer_init(struct pipe_context *pctx,
|
||||
const struct pipe_framebuffer_state *fb,
|
||||
struct pipe_surface **cbufs,
|
||||
struct pipe_surface **zsbuf);
|
||||
|
||||
void
|
||||
nv50_invalidate_resource(struct pipe_context *, struct pipe_resource *);
|
||||
|
||||
|
|
|
|||
|
|
@ -1298,7 +1298,7 @@ nv50_blitctx_post_blit(struct nv50_blitctx *blit)
|
|||
struct nv50_context *nv50 = blit->nv50;
|
||||
int s;
|
||||
|
||||
pipe_surface_reference(&nv50->fb_cbufs[0], NULL);
|
||||
nv50_surface_destroy(&nv50->base.pipe, nv50->fb_cbufs[0]);
|
||||
|
||||
nv50->framebuffer.width = blit->saved.fb.width;
|
||||
nv50->framebuffer.height = blit->saved.fb.height;
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ nvc0_context_unreference_resources(struct nvc0_context *nvc0)
|
|||
nouveau_bufctx_del(&nvc0->bufctx);
|
||||
nouveau_bufctx_del(&nvc0->bufctx_cp);
|
||||
|
||||
util_framebuffer_init(&nvc0->base.pipe, NULL, nvc0->fb_cbufs, &nvc0->fb_zsbuf);
|
||||
nvc0_framebuffer_init(&nvc0->base.pipe, NULL, nvc0->fb_cbufs, &nvc0->fb_zsbuf);
|
||||
util_unreference_framebuffer_state(&nvc0->framebuffer);
|
||||
|
||||
for (i = 0; i < nvc0->num_vtxbufs; ++i)
|
||||
|
|
|
|||
|
|
@ -237,7 +237,8 @@ struct nvc0_context {
|
|||
struct list_head tex_head;
|
||||
struct list_head img_head;
|
||||
|
||||
PIPE_FB_SURFACES; //STOP USING THIS
|
||||
struct pipe_surface *fb_cbufs[PIPE_MAX_COLOR_BUFS];
|
||||
struct pipe_surface *fb_zsbuf;
|
||||
struct pipe_framebuffer_state framebuffer;
|
||||
bool sample_locations_enabled;
|
||||
uint8_t sample_locations[2 * 4 * 8];
|
||||
|
|
|
|||
|
|
@ -585,6 +585,5 @@ nvc0_miptree_surface_new(struct pipe_context *pipe,
|
|||
struct nv50_surface *ns = nv50_surface_from_miptree(nv50_miptree(pt), templ);
|
||||
if (!ns)
|
||||
return NULL;
|
||||
ns->base.context = pipe;
|
||||
return &ns->base;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "pipe/p_context.h"
|
||||
#include "nvc0/nvc0_resource.h"
|
||||
#include "nouveau_context.h"
|
||||
#include "nouveau_screen.h"
|
||||
|
||||
|
||||
|
|
@ -126,12 +127,15 @@ nvc0_resource_from_handle(struct pipe_screen * screen,
|
|||
}
|
||||
}
|
||||
|
||||
static struct pipe_surface *
|
||||
nvc0_surface_create(struct pipe_context *pipe,
|
||||
struct pipe_resource *pres,
|
||||
const struct pipe_surface *templ)
|
||||
void
|
||||
nvc0_framebuffer_init(struct pipe_context *pctx,
|
||||
const struct pipe_framebuffer_state *fb,
|
||||
struct pipe_surface **cbufs,
|
||||
struct pipe_surface **zsbuf)
|
||||
{
|
||||
return nvc0_miptree_surface_new(pipe, pres, templ);
|
||||
return nv_framebuffer_init(pctx, fb, cbufs, zsbuf,
|
||||
nvc0_miptree_surface_new,
|
||||
nv50_surface_destroy);
|
||||
}
|
||||
|
||||
static struct pipe_resource *
|
||||
|
|
@ -155,8 +159,6 @@ nvc0_init_resource_functions(struct pipe_context *pcontext)
|
|||
pcontext->texture_unmap = nvc0_miptree_transfer_unmap;
|
||||
pcontext->buffer_subdata = u_default_buffer_subdata;
|
||||
pcontext->texture_subdata = u_default_texture_subdata;
|
||||
pcontext->create_surface = nvc0_surface_create;
|
||||
pcontext->surface_destroy = nv50_surface_destroy;
|
||||
pcontext->invalidate_resource = nv50_invalidate_resource;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,12 @@ nvc0_miptree_surface_new(struct pipe_context *,
|
|||
struct pipe_resource *,
|
||||
const struct pipe_surface *templ);
|
||||
|
||||
void
|
||||
nvc0_framebuffer_init(struct pipe_context *pctx,
|
||||
const struct pipe_framebuffer_state *fb,
|
||||
struct pipe_surface **cbufs,
|
||||
struct pipe_surface **zsbuf);
|
||||
|
||||
unsigned
|
||||
nvc0_mt_zslice_offset(const struct nv50_miptree *, unsigned l, unsigned z);
|
||||
|
||||
|
|
|
|||
|
|
@ -910,7 +910,7 @@ nvc0_set_framebuffer_state(struct pipe_context *pipe,
|
|||
|
||||
nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_3D_FB);
|
||||
|
||||
util_framebuffer_init(pipe, fb, nvc0->fb_cbufs, &nvc0->fb_zsbuf);
|
||||
nvc0_framebuffer_init(pipe, fb, nvc0->fb_cbufs, &nvc0->fb_zsbuf);
|
||||
util_copy_framebuffer_state(&nvc0->framebuffer, fb);
|
||||
|
||||
nvc0->dirty_3d |= NVC0_NEW_3D_FRAMEBUFFER | NVC0_NEW_3D_SAMPLE_LOCATIONS |
|
||||
|
|
|
|||
|
|
@ -1165,7 +1165,7 @@ nvc0_blitctx_post_blit(struct nvc0_blitctx *blit)
|
|||
struct nvc0_context *nvc0 = blit->nvc0;
|
||||
int s;
|
||||
|
||||
pipe_surface_reference(&nvc0->fb_cbufs[0], NULL);
|
||||
nv50_surface_destroy(&nvc0->base.pipe, nvc0->fb_cbufs[0]);
|
||||
|
||||
nvc0->framebuffer.width = blit->saved.fb.width;
|
||||
nvc0->framebuffer.height = blit->saved.fb.height;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue