Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2003 VMware, Inc.
  4.  * All Rights Reserved.
  5.  *
  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:
  13.  *
  14.  * The above copyright notice and this permission notice (including the
  15.  * next paragraph) shall be included in all copies or substantial portions
  16.  * of the Software.
  17.  *
  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.
  25.  *
  26.  **************************************************************************/
  27.  
  28. #include "brw_context.h"
  29. #include "intel_buffers.h"
  30. #include "intel_fbo.h"
  31. #include "intel_mipmap_tree.h"
  32.  
  33. #include "main/fbobject.h"
  34. #include "main/framebuffer.h"
  35. #include "main/renderbuffer.h"
  36.  
  37.  
  38. bool
  39. brw_is_front_buffer_reading(struct gl_framebuffer *fb)
  40. {
  41.    if (!fb || _mesa_is_user_fbo(fb))
  42.       return false;
  43.  
  44.    return fb->_ColorReadBufferIndex == BUFFER_FRONT_LEFT;
  45. }
  46.  
  47. bool
  48. brw_is_front_buffer_drawing(struct gl_framebuffer *fb)
  49. {
  50.    if (!fb || _mesa_is_user_fbo(fb))
  51.       return false;
  52.  
  53.    return (fb->_NumColorDrawBuffers >= 1 &&
  54.            fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT);
  55. }
  56.  
  57. static void
  58. intelDrawBuffer(struct gl_context * ctx, GLenum mode)
  59. {
  60.    if (brw_is_front_buffer_drawing(ctx->DrawBuffer)) {
  61.       struct brw_context *const brw = brw_context(ctx);
  62.  
  63.       /* If we might be front-buffer rendering on this buffer for the first
  64.        * time, invalidate our DRI drawable so we'll ask for new buffers
  65.        * (including the fake front) before we start rendering again.
  66.        */
  67.       dri2InvalidateDrawable(brw->driContext->driDrawablePriv);
  68.       intel_prepare_render(brw);
  69.    }
  70. }
  71.  
  72.  
  73. static void
  74. intelReadBuffer(struct gl_context * ctx, GLenum mode)
  75. {
  76.    if (brw_is_front_buffer_reading(ctx->ReadBuffer)) {
  77.       struct brw_context *const brw = brw_context(ctx);
  78.  
  79.       /* If we might be front-buffer reading on this buffer for the first
  80.        * time, invalidate our DRI drawable so we'll ask for new buffers
  81.        * (including the fake front) before we start reading again.
  82.        */
  83.       dri2InvalidateDrawable(brw->driContext->driReadablePriv);
  84.       intel_prepare_render(brw);
  85.    }
  86. }
  87.  
  88.  
  89. void
  90. intelInitBufferFuncs(struct dd_function_table *functions)
  91. {
  92.    functions->DrawBuffer = intelDrawBuffer;
  93.    functions->ReadBuffer = intelReadBuffer;
  94. }
  95.