From: Marek Olšák Date: Tue, 8 Jan 2019 15:44:29 +0000 (-0500) Subject: st/mesa: unify window-system renderbuffer initialization X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5da442338b24cb9ff1c07161a8ce584e9ad09b98;p=mesa.git st/mesa: unify window-system renderbuffer initialization Reviewed-by: Brian Paul --- diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c index d6b93c3dbe8..f79df5a38ca 100644 --- a/src/mesa/state_tracker/st_cb_eglimage.c +++ b/src/mesa/state_tracker/st_cb_eglimage.c @@ -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); } } diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 73729d74545..7a3d9777101 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -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; } diff --git a/src/mesa/state_tracker/st_manager.h b/src/mesa/state_tracker/st_manager.h index 162dcc2ca57..581e858229b 100644 --- a/src/mesa/state_tracker/st_manager.h +++ b/src/mesa/state_tracker/st_manager.h @@ -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 */