* Michel Dänzer
*/
+#include "main/errors.h"
#include "main/glheader.h"
#include "main/accum.h"
#include "main/formats.h"
+#include "main/framebuffer.h"
#include "main/macros.h"
#include "main/glformats.h"
#include "program/prog_instruction.h"
#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"
const struct gl_framebuffer *fb = ctx->DrawBuffer;
const GLfloat fb_width = (GLfloat) fb->Width;
const GLfloat fb_height = (GLfloat) fb->Height;
+
+ _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin / fb_width * 2.0f - 1.0f;
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__,
x1, y1);
*/
- cso_save_blend(cso);
- cso_save_stencil_ref(cso);
- cso_save_depth_stencil_alpha(cso);
- cso_save_rasterizer(cso);
- cso_save_sample_mask(cso);
- cso_save_min_samples(cso);
- cso_save_viewport(cso);
- cso_save_fragment_shader(cso);
- cso_save_stream_outputs(cso);
- cso_save_vertex_shader(cso);
- cso_save_tessctrl_shader(cso);
- cso_save_tesseval_shader(cso);
- cso_save_geometry_shader(cso);
- cso_save_vertex_elements(cso);
- cso_save_aux_vertex_buffer_slot(cso);
+ cso_save_state(cso, (CSO_BIT_BLEND |
+ CSO_BIT_STENCIL_REF |
+ CSO_BIT_DEPTH_STENCIL_ALPHA |
+ CSO_BIT_RASTERIZER |
+ CSO_BIT_SAMPLE_MASK |
+ CSO_BIT_MIN_SAMPLES |
+ CSO_BIT_VIEWPORT |
+ CSO_BIT_STREAM_OUTPUTS |
+ CSO_BIT_VERTEX_ELEMENTS |
+ CSO_BIT_AUX_VERTEX_BUFFER_SLOT |
+ CSO_BIT_PAUSE_QUERIES |
+ CSO_BITS_ALL_SHADERS));
/* blend state: RGBA masking */
{
if (!(clear_buffers & (PIPE_CLEAR_COLOR0 << i)))
continue;
- if (ctx->Color.ColorMask[i][0])
- blend.rt[i].colormask |= PIPE_MASK_R;
- if (ctx->Color.ColorMask[i][1])
- blend.rt[i].colormask |= PIPE_MASK_G;
- if (ctx->Color.ColorMask[i][2])
- blend.rt[i].colormask |= PIPE_MASK_B;
- if (ctx->Color.ColorMask[i][3])
- blend.rt[i].colormask |= PIPE_MASK_A;
+ blend.rt[i].colormask = GET_COLORMASK(ctx->Color.ColorMask, i);
}
- if (st->ctx->Color.DitherFlag)
+ if (ctx->Color.DitherFlag)
blend.dither = 1;
}
cso_set_blend(cso, &blend);
cso_set_rasterizer(cso, &st->clear.raster);
/* viewport state: viewport matching window dims */
- {
- const GLboolean invert = (st_fb_orientation(fb) == Y_0_TOP);
- struct pipe_viewport_state vp;
- vp.scale[0] = 0.5f * fb_width;
- vp.scale[1] = fb_height * (invert ? -0.5f : 0.5f);
- vp.scale[2] = 0.5f;
- vp.translate[0] = 0.5f * fb_width;
- vp.translate[1] = 0.5f * fb_height;
- vp.translate[2] = 0.5f;
- cso_set_viewport(cso, &vp);
- }
+ cso_set_viewport_dims(st->cso_context, fb_width, fb_height,
+ st_fb_orientation(fb) == Y_0_TOP);
set_fragment_shader(st);
cso_set_tessctrl_shader_handle(cso, NULL);
}
/* Restore pipe state */
- cso_restore_blend(cso);
- cso_restore_stencil_ref(cso);
- cso_restore_depth_stencil_alpha(cso);
- cso_restore_rasterizer(cso);
- cso_restore_sample_mask(cso);
- cso_restore_min_samples(cso);
- cso_restore_viewport(cso);
- cso_restore_fragment_shader(cso);
- cso_restore_vertex_shader(cso);
- cso_restore_tessctrl_shader(cso);
- cso_restore_tesseval_shader(cso);
- cso_restore_geometry_shader(cso);
- cso_restore_vertex_elements(cso);
- cso_restore_aux_vertex_buffer_slot(cso);
- cso_restore_stream_outputs(cso);
+ cso_restore_state(cso);
}
static inline GLboolean
is_scissor_enabled(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
- return (ctx->Scissor.EnableFlags & 1) &&
- (ctx->Scissor.ScissorArray[0].X > 0 ||
- ctx->Scissor.ScissorArray[0].Y > 0 ||
- (unsigned) ctx->Scissor.ScissorArray[0].Width < rb->Width ||
- (unsigned) ctx->Scissor.ScissorArray[0].Height < rb->Height);
-}
-
+ const struct gl_scissor_rect *scissor = &ctx->Scissor.ScissorArray[0];
-/**
- * Return if all of the color channels are masked.
- */
-static inline GLboolean
-is_color_disabled(struct gl_context *ctx, int i)
-{
- return !ctx->Color.ColorMask[i][0] &&
- !ctx->Color.ColorMask[i][1] &&
- !ctx->Color.ColorMask[i][2] &&
- !ctx->Color.ColorMask[i][3];
+ return (ctx->Scissor.EnableFlags & 1) &&
+ (scissor->X > 0 ||
+ scissor->Y > 0 ||
+ scissor->X + scissor->Width < (int)rb->Width ||
+ scissor->Y + scissor->Height < (int)rb->Height);
}
-
/**
- * Return if any of the color channels are masked.
+ * Return if window rectangles must be enabled during the clear.
*/
-static inline GLboolean
-is_color_masked(struct gl_context *ctx, int i)
+static inline bool
+is_window_rectangle_enabled(struct gl_context *ctx)
{
- return !ctx->Color.ColorMask[i][0] ||
- !ctx->Color.ColorMask[i][1] ||
- !ctx->Color.ColorMask[i][2] ||
- !ctx->Color.ColorMask[i][3];
+ if (ctx->DrawBuffer == ctx->WinSysDrawBuffer)
+ return false;
+ return ctx->Scissor.NumWindowRects > 0 ||
+ ctx->Scissor.WindowRectMode == GL_INCLUSIVE_EXT;
}
GLuint i;
st_flush_bitmap_cache(st);
+ st_invalidate_readpix_cache(st);
/* This makes sure the pipe has the latest scissor, etc values */
- st_validate_state( st, ST_PIPELINE_RENDER );
+ st_validate_state(st, ST_PIPELINE_CLEAR);
if (mask & BUFFER_BITS_COLOR) {
for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
- GLint b = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
+ gl_buffer_index b = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
- if (b >= 0 && mask & (1 << b)) {
+ if (b != BUFFER_NONE && mask & (1 << b)) {
struct gl_renderbuffer *rb
= ctx->DrawBuffer->Attachment[b].Renderbuffer;
struct st_renderbuffer *strb = st_renderbuffer(rb);
if (!strb || !strb->surface)
continue;
- if (is_color_disabled(ctx, colormask_index))
+ if (!GET_COLORMASK(ctx->Color.ColorMask, colormask_index))
continue;
if (is_scissor_enabled(ctx, rb) ||
- is_color_masked(ctx, colormask_index))
+ is_window_rectangle_enabled(ctx) ||
+ GET_COLORMASK(ctx->Color.ColorMask, colormask_index) != 0xf)
quad_buffers |= PIPE_CLEAR_COLOR0 << i;
else
clear_buffers |= PIPE_CLEAR_COLOR0 << i;
struct st_renderbuffer *strb = st_renderbuffer(depthRb);
if (strb->surface && ctx->Depth.Mask) {
- if (is_scissor_enabled(ctx, depthRb))
+ if (is_scissor_enabled(ctx, depthRb) ||
+ is_window_rectangle_enabled(ctx))
quad_buffers |= PIPE_CLEAR_DEPTH;
else
clear_buffers |= PIPE_CLEAR_DEPTH;
if (strb->surface && !is_stencil_disabled(ctx, stencilRb)) {
if (is_scissor_enabled(ctx, stencilRb) ||
+ is_window_rectangle_enabled(ctx) ||
is_stencil_masked(ctx, stencilRb))
quad_buffers |= PIPE_CLEAR_STENCIL;
else