Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  
  3. Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
  4. Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
  5.                      VA Linux Systems Inc., Fremont, California.
  6.  
  7. The Weather Channel (TM) funded Tungsten Graphics to develop the
  8. initial release of the Radeon 8500 driver under the XFree86 license.
  9. This notice must be preserved.
  10.  
  11. All Rights Reserved.
  12.  
  13. Permission is hereby granted, free of charge, to any person obtaining
  14. a copy of this software and associated documentation files (the
  15. "Software"), to deal in the Software without restriction, including
  16. without limitation the rights to use, copy, modify, merge, publish,
  17. distribute, sublicense, and/or sell copies of the Software, and to
  18. permit persons to whom the Software is furnished to do so, subject to
  19. the following conditions:
  20.  
  21. The above copyright notice and this permission notice (including the
  22. next paragraph) shall be included in all copies or substantial
  23. portions of the Software.
  24.  
  25. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  28. IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
  29. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  30. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  31. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  32.  
  33. **************************************************************************/
  34.  
  35. /*
  36.  * Authors:
  37.  *   Kevin E. Martin <martin@valinux.com>
  38.  *   Gareth Hughes <gareth@valinux.com>
  39.  *   Keith Whitwell <keith@tungstengraphics.com>
  40.  *
  41.  */
  42.  
  43. #include "main/glheader.h"
  44. #include "main/texformat.h"
  45. #include "main/renderbuffer.h"
  46. #include "main/samplerobj.h"
  47. #include "swrast/swrast.h"
  48. #include "swrast/s_renderbuffer.h"
  49.  
  50. #include "radeon_common.h"
  51. #include "radeon_span.h"
  52.  
  53.  
  54. static void
  55. radeon_renderbuffer_map(struct gl_context *ctx, struct gl_renderbuffer *rb)
  56. {
  57.         struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
  58.         GLubyte *map;
  59.         int stride;
  60.  
  61.         if (!rb || !rrb)
  62.                 return;
  63.  
  64.         ctx->Driver.MapRenderbuffer(ctx, rb, 0, 0, rb->Width, rb->Height,
  65.                                     GL_MAP_READ_BIT | GL_MAP_WRITE_BIT,
  66.                                     &map, &stride);
  67.  
  68.         rrb->base.Map = map;
  69.         rrb->base.RowStride = stride;
  70.         /* No floating point color buffers, use GLubytes */
  71.         rrb->base.ColorType = GL_UNSIGNED_BYTE;
  72. }
  73.  
  74. static void
  75. radeon_renderbuffer_unmap(struct gl_context *ctx, struct gl_renderbuffer *rb)
  76. {
  77.         struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
  78.         if (!rb || !rrb)
  79.                 return;
  80.  
  81.         ctx->Driver.UnmapRenderbuffer(ctx, rb);
  82.  
  83.         rrb->base.Map = NULL;
  84.         rrb->base.RowStride = 0;
  85. }
  86.  
  87. static void
  88. radeon_map_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
  89. {
  90.         GLuint i;
  91.  
  92.         radeon_print(RADEON_MEMORY, RADEON_TRACE,
  93.                 "%s( %p , fb %p )\n",
  94.                      __func__, ctx, fb);
  95.  
  96.         /* check for render to textures */
  97.         for (i = 0; i < BUFFER_COUNT; i++)
  98.                 radeon_renderbuffer_map(ctx, fb->Attachment[i].Renderbuffer);
  99.  
  100.         radeon_check_front_buffer_rendering(ctx);
  101. }
  102.  
  103. static void
  104. radeon_unmap_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
  105. {
  106.         GLuint i;
  107.  
  108.         radeon_print(RADEON_MEMORY, RADEON_TRACE,
  109.                 "%s( %p , fb %p)\n",
  110.                      __func__, ctx, fb);
  111.  
  112.         /* check for render to textures */
  113.         for (i = 0; i < BUFFER_COUNT; i++)
  114.                 radeon_renderbuffer_unmap(ctx, fb->Attachment[i].Renderbuffer);
  115.  
  116.         radeon_check_front_buffer_rendering(ctx);
  117. }
  118.  
  119. static void radeonSpanRenderStart(struct gl_context * ctx)
  120. {
  121.         radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
  122.  
  123.         radeon_firevertices(rmesa);
  124.  
  125.         _swrast_map_textures(ctx);
  126.  
  127.         radeon_map_framebuffer(ctx, ctx->DrawBuffer);
  128.         if (ctx->ReadBuffer != ctx->DrawBuffer)
  129.                 radeon_map_framebuffer(ctx, ctx->ReadBuffer);
  130. }
  131.  
  132. static void radeonSpanRenderFinish(struct gl_context * ctx)
  133. {
  134.         _swrast_flush(ctx);
  135.         _swrast_unmap_textures(ctx);
  136.  
  137.         radeon_unmap_framebuffer(ctx, ctx->DrawBuffer);
  138.         if (ctx->ReadBuffer != ctx->DrawBuffer)
  139.                 radeon_unmap_framebuffer(ctx, ctx->ReadBuffer);
  140. }
  141.  
  142. void radeonInitSpanFuncs(struct gl_context * ctx)
  143. {
  144.         struct swrast_device_driver *swdd =
  145.             _swrast_GetDeviceDriverReference(ctx);
  146.         swdd->SpanRenderStart = radeonSpanRenderStart;
  147.         swdd->SpanRenderFinish = radeonSpanRenderFinish;
  148. }
  149.  
  150.