2 * Copyright 2003 VMware, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 #include "brw_context.h"
27 #include "intel_buffers.h"
28 #include "intel_fbo.h"
29 #include "intel_mipmap_tree.h"
31 #include "main/fbobject.h"
32 #include "main/framebuffer.h"
33 #include "main/renderbuffer.h"
37 brw_is_front_buffer_reading(struct gl_framebuffer
*fb
)
39 if (!fb
|| _mesa_is_user_fbo(fb
))
42 return fb
->_ColorReadBufferIndex
== BUFFER_FRONT_LEFT
;
46 brw_is_front_buffer_drawing(struct gl_framebuffer
*fb
)
48 if (!fb
|| _mesa_is_user_fbo(fb
))
51 return (fb
->_NumColorDrawBuffers
>= 1 &&
52 fb
->_ColorDrawBufferIndexes
[0] == BUFFER_FRONT_LEFT
);
56 intelDrawBuffer(struct gl_context
* ctx
, GLenum mode
)
58 if (brw_is_front_buffer_drawing(ctx
->DrawBuffer
)) {
59 struct brw_context
*const brw
= brw_context(ctx
);
61 /* If we might be front-buffer rendering on this buffer for the first
62 * time, invalidate our DRI drawable so we'll ask for new buffers
63 * (including the fake front) before we start rendering again.
65 dri2InvalidateDrawable(brw
->driContext
->driDrawablePriv
);
66 intel_prepare_render(brw
);
72 intelReadBuffer(struct gl_context
* ctx
, GLenum mode
)
74 if (brw_is_front_buffer_reading(ctx
->ReadBuffer
)) {
75 struct brw_context
*const brw
= brw_context(ctx
);
77 /* If we might be front-buffer reading on this buffer for the first
78 * time, invalidate our DRI drawable so we'll ask for new buffers
79 * (including the fake front) before we start reading again.
81 dri2InvalidateDrawable(brw
->driContext
->driReadablePriv
);
82 intel_prepare_render(brw
);
88 intelInitBufferFuncs(struct dd_function_table
*functions
)
90 functions
->DrawBuffer
= intelDrawBuffer
;
91 functions
->ReadBuffer
= intelReadBuffer
;