#include "util/u_math.h"
#include "util/u_inlines.h"
#include "util/u_format.h"
+#include "util/u_framebuffer.h"
#include "main/framebuffer.h"
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;
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) {
}
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--;
}
/*
/* 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);
/* 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);
}
}
/* 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);
{
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;
/* 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;