1 /*
2 * Copyright 2003 VMware, Inc.
3 * All Rights Reserved.
4 *
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, sublicense, 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:
12 *
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
15 * of the Software.
16 *
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 NONINFRINGEMENT.
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.
24 */
25
26 #include "brw_context.h"
27 #include "brw_buffers.h"
28 #include "brw_fbo.h"
29 #include "brw_mipmap_tree.h"
30
31 #include "main/fbobject.h"
32 #include "main/framebuffer.h"
33 #include "main/renderbuffer.h"
34
35 static void
brw_drawbuffer(struct gl_context * ctx)36 brw_drawbuffer(struct gl_context *ctx)
37 {
38 if (_mesa_is_front_buffer_drawing(ctx->DrawBuffer)) {
39 struct brw_context *const brw = brw_context(ctx);
40
41 /* If we might be front-buffer rendering on this buffer for the first
42 * time, invalidate our DRI drawable so we'll ask for new buffers
43 * (including the fake front) before we start rendering again.
44 */
45 if (brw->driContext->driDrawablePriv)
46 dri2InvalidateDrawable(brw->driContext->driDrawablePriv);
47 brw_prepare_render(brw);
48 }
49 }
50
51
52 static void
brw_readbuffer(struct gl_context * ctx,GLenum mode)53 brw_readbuffer(struct gl_context * ctx, GLenum mode)
54 {
55 if (_mesa_is_front_buffer_reading(ctx->ReadBuffer)) {
56 struct brw_context *const brw = brw_context(ctx);
57
58 /* If we might be front-buffer reading on this buffer for the first
59 * time, invalidate our DRI drawable so we'll ask for new buffers
60 * (including the fake front) before we start reading again.
61 */
62 if (brw->driContext->driDrawablePriv)
63 dri2InvalidateDrawable(brw->driContext->driReadablePriv);
64 brw_prepare_render(brw);
65 }
66 }
67
68
69 void
brw_init_buffer_functions(struct dd_function_table * functions)70 brw_init_buffer_functions(struct dd_function_table *functions)
71 {
72 functions->DrawBuffer = brw_drawbuffer;
73 functions->ReadBuffer = brw_readbuffer;
74 }
75