summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2019-01-08 10:44:29 -0500
committerMarek Olšák <[email protected]>2019-01-09 11:08:44 -0500
commit5da442338b24cb9ff1c07161a8ce584e9ad09b98 (patch)
tree06656e5d7623211a497391913293dc807d8219a4 /src/mesa/state_tracker
parent5e30e54e057300f65019c927482e633c367963fc (diff)
st/mesa: unify window-system renderbuffer initialization
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_cb_eglimage.c11
-rw-r--r--src/mesa/state_tracker/st_manager.c32
-rw-r--r--src/mesa/state_tracker/st_manager.h6
3 files changed, 28 insertions, 21 deletions
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 */