Home | History | Annotate | Download | only in i965
      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 "intel_buffers.h"
     28 #include "intel_fbo.h"
     29 #include "intel_mipmap_tree.h"
     30 
     31 #include "main/fbobject.h"
     32 #include "main/framebuffer.h"
     33 #include "main/renderbuffer.h"
     34 
     35 static void
     36 intelDrawBuffer(struct gl_context * ctx, GLenum mode)
     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       dri2InvalidateDrawable(brw->driContext->driDrawablePriv);
     46       intel_prepare_render(brw);
     47    }
     48 }
     49 
     50 
     51 static void
     52 intelReadBuffer(struct gl_context * ctx, GLenum mode)
     53 {
     54    if (_mesa_is_front_buffer_reading(ctx->ReadBuffer)) {
     55       struct brw_context *const brw = brw_context(ctx);
     56 
     57       /* If we might be front-buffer reading on this buffer for the first
     58        * time, invalidate our DRI drawable so we'll ask for new buffers
     59        * (including the fake front) before we start reading again.
     60        */
     61       dri2InvalidateDrawable(brw->driContext->driReadablePriv);
     62       intel_prepare_render(brw);
     63    }
     64 }
     65 
     66 
     67 void
     68 intelInitBufferFuncs(struct dd_function_table *functions)
     69 {
     70    functions->DrawBuffer = intelDrawBuffer;
     71    functions->ReadBuffer = intelReadBuffer;
     72 }
     73