1 /**************************************************************************
3 * Copyright 2003 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #include "intel_context.h"
29 #include "intel_buffers.h"
30 #include "intel_fbo.h"
31 #include "intel_mipmap_tree.h"
33 #include "main/fbobject.h"
34 #include "main/framebuffer.h"
35 #include "main/renderbuffer.h"
38 * Check if we're about to draw into the front color buffer.
39 * If so, set the intel->front_buffer_dirty field to true.
42 intel_check_front_buffer_rendering(struct intel_context *intel)
44 const struct gl_framebuffer *fb = intel->ctx.DrawBuffer;
45 if (_mesa_is_winsys_fbo(fb)) {
46 /* drawing to window system buffer */
47 if (fb->_NumColorDrawBuffers > 0) {
48 if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
49 intel->front_buffer_dirty = true;
56 intel_is_front_buffer_reading(struct gl_framebuffer *fb)
58 if (!fb || _mesa_is_user_fbo(fb))
61 return fb->_ColorReadBufferIndex == BUFFER_FRONT_LEFT;
65 intel_is_front_buffer_drawing(struct gl_framebuffer *fb)
67 if (!fb || _mesa_is_user_fbo(fb))
70 return (fb->_NumColorDrawBuffers >= 1 &&
71 fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT);
75 intelDrawBuffer(struct gl_context * ctx, GLenum mode)
77 if (intel_is_front_buffer_drawing(ctx->DrawBuffer)) {
78 struct intel_context *const intel = intel_context(ctx);
80 /* If we might be front-buffer rendering on this buffer for the first
81 * time, invalidate our DRI drawable so we'll ask for new buffers
82 * (including the fake front) before we start rendering again.
84 dri2InvalidateDrawable(intel->driContext->driDrawablePriv);
87 intel_draw_buffer(ctx);
92 intelReadBuffer(struct gl_context * ctx, GLenum mode)
94 if (intel_is_front_buffer_reading(ctx->ReadBuffer)) {
95 struct intel_context *const intel = intel_context(ctx);
97 /* If we might be front-buffer reading on this buffer for the first
98 * time, invalidate our DRI drawable so we'll ask for new buffers
99 * (including the fake front) before we start reading again.
101 dri2InvalidateDrawable(intel->driContext->driReadablePriv);
107 intelInitBufferFuncs(struct dd_function_table *functions)
109 functions->DrawBuffer = intelDrawBuffer;
110 functions->ReadBuffer = intelReadBuffer;