summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-06-05 01:22:45 +0200
committerMarek Olšák <[email protected]>2017-06-07 18:46:21 +0200
commite003e3c4c058e69e3dcaee3d31493b27ffc0052c (patch)
treeb97ceee6eeec167bb94f24149fbf8a53cae243d0 /src/mesa
parentf34abf77e90355739038d0bab0d80b54eb4e5246 (diff)
st/mesa: don't keep framebuffer state in st_context
Reviewed-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_atom_framebuffer.c65
-rw-r--r--src/mesa/state_tracker/st_atom_list.h2
-rw-r--r--src/mesa/state_tracker/st_atom_msaa.c5
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c12
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c4
-rw-r--r--src/mesa/state_tracker/st_context.c6
-rw-r--r--src/mesa/state_tracker/st_context.h5
7 files changed, 48 insertions, 51 deletions
diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c
index 9b15c88d847..acbe9809034 100644
--- a/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -43,6 +43,7 @@
#include "util/u_math.h"
#include "util/u_inlines.h"
#include "util/u_format.h"
+#include "util/u_framebuffer.h"
#include "main/framebuffer.h"
@@ -107,7 +108,7 @@ framebuffer_quantize_num_samples(struct st_context *st, unsigned num_samples)
void
st_update_framebuffer_state( struct st_context *st )
{
- struct pipe_framebuffer_state *framebuffer = &st->state.framebuffer;
+ struct pipe_framebuffer_state framebuffer;
struct gl_framebuffer *fb = st->ctx->DrawBuffer;
struct st_renderbuffer *strb;
GLuint i;
@@ -128,19 +129,18 @@ st_update_framebuffer_state( struct st_context *st )
fb->DefaultGeometry._NumSamples =
framebuffer_quantize_num_samples(st, fb->DefaultGeometry.NumSamples);
- framebuffer->width = _mesa_geometric_width(fb);
- framebuffer->height = _mesa_geometric_height(fb);
- framebuffer->samples = _mesa_geometric_samples(fb);
- framebuffer->layers = _mesa_geometric_layers(fb);
+ framebuffer.width = _mesa_geometric_width(fb);
+ framebuffer.height = _mesa_geometric_height(fb);
+ framebuffer.samples = _mesa_geometric_samples(fb);
+ framebuffer.layers = _mesa_geometric_layers(fb);
/* Examine Mesa's ctx->DrawBuffer->_ColorDrawBuffers state
* to determine which surfaces to draw to
*/
- framebuffer->nr_cbufs = fb->_NumColorDrawBuffers;
+ framebuffer.nr_cbufs = fb->_NumColorDrawBuffers;
for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
- pipe_surface_reference(&framebuffer->cbufs[i], NULL);
-
+ framebuffer.cbufs[i] = NULL;
strb = st_renderbuffer(fb->_ColorDrawBuffers[i]);
if (strb) {
@@ -151,21 +151,21 @@ st_update_framebuffer_state( struct st_context *st )
}
if (strb->surface) {
- pipe_surface_reference(&framebuffer->cbufs[i], strb->surface);
- update_framebuffer_size(framebuffer, strb->surface);
+ framebuffer.cbufs[i] = strb->surface;
+ update_framebuffer_size(&framebuffer, strb->surface);
}
strb->defined = GL_TRUE; /* we'll be drawing something */
}
}
- for (i = framebuffer->nr_cbufs; i < PIPE_MAX_COLOR_BUFS; i++) {
- pipe_surface_reference(&framebuffer->cbufs[i], NULL);
+ for (i = framebuffer.nr_cbufs; i < PIPE_MAX_COLOR_BUFS; i++) {
+ framebuffer.cbufs[i] = NULL;
}
/* Remove trailing GL_NONE draw buffers. */
- while (framebuffer->nr_cbufs &&
- !framebuffer->cbufs[framebuffer->nr_cbufs-1]) {
- framebuffer->nr_cbufs--;
+ while (framebuffer.nr_cbufs &&
+ !framebuffer.cbufs[framebuffer.nr_cbufs-1]) {
+ framebuffer.nr_cbufs--;
}
/*
@@ -177,8 +177,8 @@ st_update_framebuffer_state( struct st_context *st )
/* rendering to a GL texture, may have to update surface */
st_update_renderbuffer_surface(st, strb);
}
- pipe_surface_reference(&framebuffer->zsbuf, strb->surface);
- update_framebuffer_size(framebuffer, strb->surface);
+ framebuffer.zsbuf = strb->surface;
+ update_framebuffer_size(&framebuffer, strb->surface);
}
else {
strb = st_renderbuffer(fb->Attachment[BUFFER_STENCIL].Renderbuffer);
@@ -187,28 +187,33 @@ st_update_framebuffer_state( struct st_context *st )
/* rendering to a GL texture, may have to update surface */
st_update_renderbuffer_surface(st, strb);
}
- pipe_surface_reference(&framebuffer->zsbuf, strb->surface);
- update_framebuffer_size(framebuffer, strb->surface);
+ framebuffer.zsbuf = strb->surface;
+ update_framebuffer_size(&framebuffer, strb->surface);
}
else
- pipe_surface_reference(&framebuffer->zsbuf, NULL);
+ framebuffer.zsbuf = NULL;
}
#ifdef DEBUG
/* Make sure the resource binding flags were set properly */
- for (i = 0; i < framebuffer->nr_cbufs; i++) {
- assert(!framebuffer->cbufs[i] ||
- framebuffer->cbufs[i]->texture->bind & PIPE_BIND_RENDER_TARGET);
+ for (i = 0; i < framebuffer.nr_cbufs; i++) {
+ assert(!framebuffer.cbufs[i] ||
+ framebuffer.cbufs[i]->texture->bind & PIPE_BIND_RENDER_TARGET);
}
- if (framebuffer->zsbuf) {
- assert(framebuffer->zsbuf->texture->bind & PIPE_BIND_DEPTH_STENCIL);
+ if (framebuffer.zsbuf) {
+ assert(framebuffer.zsbuf->texture->bind & PIPE_BIND_DEPTH_STENCIL);
}
#endif
- if (framebuffer->width == USHRT_MAX)
- framebuffer->width = 0;
- if (framebuffer->height == USHRT_MAX)
- framebuffer->height = 0;
+ if (framebuffer.width == USHRT_MAX)
+ framebuffer.width = 0;
+ if (framebuffer.height == USHRT_MAX)
+ framebuffer.height = 0;
+
+ cso_set_framebuffer(st->cso_context, &framebuffer);
- cso_set_framebuffer(st->cso_context, framebuffer);
+ st->state.fb_width = framebuffer.width;
+ st->state.fb_height = framebuffer.height;
+ st->state.fb_num_samples = util_framebuffer_get_num_samples(&framebuffer);
+ st->state.fb_num_layers = util_framebuffer_get_num_layers(&framebuffer);
}
diff --git a/src/mesa/state_tracker/st_atom_list.h b/src/mesa/state_tracker/st_atom_list.h
index ca997af1249..614ee9006e8 100644
--- a/src/mesa/state_tracker/st_atom_list.h
+++ b/src/mesa/state_tracker/st_atom_list.h
@@ -35,7 +35,7 @@ ST_STATE(ST_NEW_GS_IMAGES, st_bind_gs_images)
ST_STATE(ST_NEW_FS_IMAGES, st_bind_fs_images)
ST_STATE(ST_NEW_FB_STATE, st_update_framebuffer_state) /* depends on update_*_texture and bind_*_images */
-ST_STATE(ST_NEW_SAMPLE_MASK, st_update_sample_mask)
+ST_STATE(ST_NEW_SAMPLE_MASK, st_update_sample_mask) /* depends on update_framebuffer_state */
ST_STATE(ST_NEW_SAMPLE_SHADING, st_update_sample_shading)
ST_STATE(ST_NEW_VS_CONSTANTS, st_update_vs_constants)
diff --git a/src/mesa/state_tracker/st_atom_msaa.c b/src/mesa/state_tracker/st_atom_msaa.c
index c591faddd8b..dd065177ecc 100644
--- a/src/mesa/state_tracker/st_atom_msaa.c
+++ b/src/mesa/state_tracker/st_atom_msaa.c
@@ -33,7 +33,6 @@
#include "st_program.h"
#include "cso_cache/cso_context.h"
-#include "util/u_framebuffer.h"
/* Update the sample mask for MSAA.
@@ -41,9 +40,7 @@
void st_update_sample_mask( struct st_context *st )
{
unsigned sample_mask = 0xffffffff;
- struct pipe_framebuffer_state *framebuffer = &st->state.framebuffer;
- /* dependency here on bound surface (or rather, sample count) is worrying */
- unsigned sample_count = util_framebuffer_get_num_samples(framebuffer);
+ unsigned sample_count = st->state.fb_num_samples;
if (st->ctx->Multisample.Enabled && sample_count > 1) {
/* unlike in gallium/d3d10 the mask is only active if msaa is enabled */
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index ef3f64bc763..7ba6d825c12 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -249,8 +249,8 @@ setup_render_state(struct gl_context *ctx,
}
/* viewport state: viewport matching window dims */
- cso_set_viewport_dims(cso, st->state.framebuffer.width,
- st->state.framebuffer.height,
+ cso_set_viewport_dims(cso, st->state.fb_width,
+ st->state.fb_height,
st->state.fb_orientation == Y_0_TOP);
cso_set_vertex_elements(cso, 3, st->util_velems);
@@ -283,8 +283,8 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
- const float fb_width = (float) st->state.framebuffer.width;
- const float fb_height = (float) st->state.framebuffer.height;
+ const float fb_width = (float) st->state.fb_width;
+ const float fb_height = (float) st->state.fb_height;
const float x0 = (float) x;
const float x1 = (float) (x + width);
const float y0 = (float) y;
@@ -666,8 +666,8 @@ st_DrawAtlasBitmaps(struct gl_context *ctx,
/* convert Z from [0,1] to [-1,-1] to match viewport Z scale/bias */
const float z = ctx->Current.RasterPos[2] * 2.0f - 1.0f;
const float *color = ctx->Current.RasterColor;
- const float clip_x_scale = 2.0f / st->state.framebuffer.width;
- const float clip_y_scale = 2.0f / st->state.framebuffer.height;
+ const float clip_x_scale = 2.0f / st->state.fb_width;
+ const float clip_y_scale = 2.0f / st->state.fb_height;
const unsigned num_verts = count * 4;
const unsigned num_vert_bytes = num_verts * sizeof(struct st_util_vertex);
struct st_util_vertex *verts;
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index f507775da20..175e2e8a32c 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -53,7 +53,6 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "util/u_format.h"
-#include "util/u_framebuffer.h"
#include "util/u_inlines.h"
#include "util/u_simple_shaders.h"
@@ -184,8 +183,7 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax / fb_width * 2.0f - 1.0f;
const GLfloat y0 = (GLfloat) ctx->DrawBuffer->_Ymin / fb_height * 2.0f - 1.0f;
const GLfloat y1 = (GLfloat) ctx->DrawBuffer->_Ymax / fb_height * 2.0f - 1.0f;
- unsigned num_layers =
- util_framebuffer_get_num_layers(&st->state.framebuffer);
+ unsigned num_layers = st->state.fb_num_layers;
/*
printf("%s %s%s%s %f,%f %f,%f\n", __func__,
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 1a1d46c74ff..ba08e98b87d 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -580,7 +580,6 @@ destroy_tex_sampler_cb(GLuint id, void *data, void *userData)
void st_destroy_context( struct st_context *st )
{
struct gl_context *ctx = st->ctx;
- GLuint i;
/* This must be called first so that glthread has a chance to finish */
_mesa_glthread_destroy(ctx);
@@ -594,11 +593,6 @@ void st_destroy_context( struct st_context *st )
st_reference_prog(st, &st->tep, NULL);
st_reference_compprog(st, &st->cp, NULL);
- /* release framebuffer surfaces */
- for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
- pipe_surface_reference(&st->state.framebuffer.cbufs[i], NULL);
- }
- pipe_surface_reference(&st->state.framebuffer.zsbuf, NULL);
pipe_sampler_view_reference(&st->pixel_xfer.pixelmap_sampler_view, NULL);
pipe_resource_reference(&st->pixel_xfer.pixelmap_texture, NULL);
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 520cd8d4623..631c3aee0ac 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -139,7 +139,10 @@ struct st_context
void *ptr;
unsigned size;
} constants[PIPE_SHADER_TYPES];
- struct pipe_framebuffer_state framebuffer;
+ unsigned fb_width;
+ unsigned fb_height;
+ unsigned fb_num_samples;
+ unsigned fb_num_layers;
struct pipe_scissor_state scissor[PIPE_MAX_VIEWPORTS];
struct pipe_viewport_state viewport[PIPE_MAX_VIEWPORTS];
struct {