st/mesa: don't keep framebuffer state in st_context
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -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 */
|
||||
|
@@ -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;
|
||||
|
@@ -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__,
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user