st/mesa: unify window-system renderbuffer initialization

Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
Marek Olšák 2019-01-08 10:44:29 -05:00
parent 5e30e54e05
commit 5da442338b
3 changed files with 28 additions and 21 deletions

View file

@ -159,20 +159,11 @@ st_egl_image_target_renderbuffer_storage(struct gl_context *ctx,
if (!ps)
return;
strb->Base.Width = ps->width;
strb->Base.Height = ps->height;
strb->Base.Format = st_pipe_format_to_mesa_format(ps->format);
strb->Base._BaseFormat = st_pipe_format_to_base_format(ps->format);
strb->Base.InternalFormat = strb->Base._BaseFormat;
struct pipe_surface **psurf =
util_format_is_srgb(ps->format) ? &strb->surface_srgb :
&strb->surface_linear;
pipe_surface_reference(psurf, ps);
strb->surface = *psurf;
pipe_resource_reference(&strb->texture, ps->texture);
st_set_ws_renderbuffer_surface(strb, ps);
pipe_surface_reference(&ps, NULL);
}
}

View file

@ -173,6 +173,26 @@ st_context_validate(struct st_context *st,
}
void
st_set_ws_renderbuffer_surface(struct st_renderbuffer *strb,
struct pipe_surface *surf)
{
pipe_surface_reference(&strb->surface_srgb, NULL);
pipe_surface_reference(&strb->surface_linear, NULL);
if (util_format_is_srgb(surf->format))
pipe_surface_reference(&strb->surface_srgb, surf);
else
pipe_surface_reference(&strb->surface_linear, surf);
strb->surface = surf; /* just assign, don't ref */
pipe_resource_reference(&strb->texture, surf->texture);
strb->Base.Width = surf->width;
strb->Base.Height = surf->height;
}
/**
* Validate a framebuffer to make sure up-to-date pipe_textures are used.
* The context is only used for creating pipe surfaces and for calling
@ -234,21 +254,11 @@ st_framebuffer_validate(struct st_framebuffer *stfb,
u_surface_default_template(&surf_tmpl, textures[i]);
ps = st->pipe->create_surface(st->pipe, textures[i], &surf_tmpl);
if (ps) {
struct pipe_surface **psurf =
util_format_is_srgb(ps->format) ? &strb->surface_srgb :
&strb->surface_linear;
pipe_surface_reference(psurf, ps);
strb->surface = *psurf;
pipe_resource_reference(&strb->texture, ps->texture);
/* ownership transfered */
st_set_ws_renderbuffer_surface(strb, ps);
pipe_surface_reference(&ps, NULL);
changed = TRUE;
strb->Base.Width = strb->surface->width;
strb->Base.Height = strb->surface->height;
width = strb->Base.Width;
height = strb->Base.Height;
}

View file

@ -35,6 +35,8 @@
struct st_context;
struct st_framebuffer;
struct st_framebuffer_interface;
struct st_renderbuffer;
struct pipe_surface;
void
st_manager_flush_frontbuffer(struct st_context *st);
@ -56,4 +58,8 @@ st_framebuffer_interface_destroy(struct st_framebuffer_interface *stfbi);
void
st_manager_flush_swapbuffers(void);
void
st_set_ws_renderbuffer_surface(struct st_renderbuffer *strb,
struct pipe_surface *surf);
#endif /* ST_MANAGER_H */