Subversion Repositories Kolibri OS

Rev

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

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
  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 TUNGSTEN GRAPHICS 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. #ifndef INTEL_FBO_H
  29. #define INTEL_FBO_H
  30.  
  31. #include <stdbool.h>
  32. #include <assert.h>
  33. #include "main/formats.h"
  34. #include "main/macros.h"
  35. #include "brw_context.h"
  36. #include "intel_mipmap_tree.h"
  37. #include "intel_screen.h"
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. struct intel_mipmap_tree;
  44. struct intel_texture_image;
  45.  
  46. /**
  47.  * Intel renderbuffer, derived from gl_renderbuffer.
  48.  */
  49. struct intel_renderbuffer
  50. {
  51.    struct swrast_renderbuffer Base;
  52.    struct intel_mipmap_tree *mt; /**< The renderbuffer storage. */
  53.  
  54.    /**
  55.     * \name Miptree view
  56.     * \{
  57.     *
  58.     * Multiple renderbuffers may simultaneously wrap a single texture and each
  59.     * provide a different view into that texture. The fields below indicate
  60.     * which miptree slice is wrapped by this renderbuffer.  The fields' values
  61.     * are consistent with the 'level' and 'layer' parameters of
  62.     * glFramebufferTextureLayer().
  63.     *
  64.     * For renderbuffers not created with glFramebufferTexture*(), mt_level and
  65.     * mt_layer are 0.
  66.     */
  67.    unsigned int mt_level;
  68.    unsigned int mt_layer;
  69.    /** \} */
  70.  
  71.    GLuint draw_x, draw_y; /**< Offset of drawing within the region */
  72. };
  73.  
  74.  
  75. /**
  76.  * gl_renderbuffer is a base class which we subclass.  The Class field
  77.  * is used for simple run-time type checking.
  78.  */
  79. #define INTEL_RB_CLASS 0x12345678
  80.  
  81.  
  82. /**
  83.  * Return a gl_renderbuffer ptr casted to intel_renderbuffer.
  84.  * NULL will be returned if the rb isn't really an intel_renderbuffer.
  85.  * This is determined by checking the ClassID.
  86.  */
  87. static INLINE struct intel_renderbuffer *
  88. intel_renderbuffer(struct gl_renderbuffer *rb)
  89. {
  90.    struct intel_renderbuffer *irb = (struct intel_renderbuffer *) rb;
  91.    if (irb && irb->Base.Base.ClassID == INTEL_RB_CLASS) {
  92.       /*_mesa_warning(NULL, "Returning non-intel Rb\n");*/
  93.       return irb;
  94.    }
  95.    else
  96.       return NULL;
  97. }
  98.  
  99.  
  100. /**
  101.  * \brief Return the framebuffer attachment specified by attIndex.
  102.  *
  103.  * If the framebuffer lacks the specified attachment, then return null.
  104.  *
  105.  * If the attached renderbuffer is a wrapper, then return wrapped
  106.  * renderbuffer.
  107.  */
  108. static INLINE struct intel_renderbuffer *
  109. intel_get_renderbuffer(struct gl_framebuffer *fb, gl_buffer_index attIndex)
  110. {
  111.    struct gl_renderbuffer *rb;
  112.  
  113.    assert((unsigned)attIndex < ARRAY_SIZE(fb->Attachment));
  114.  
  115.    rb = fb->Attachment[attIndex].Renderbuffer;
  116.    if (!rb)
  117.       return NULL;
  118.  
  119.    return intel_renderbuffer(rb);
  120. }
  121.  
  122.  
  123. static INLINE gl_format
  124. intel_rb_format(const struct intel_renderbuffer *rb)
  125. {
  126.    return rb->Base.Base.Format;
  127. }
  128.  
  129. extern struct intel_renderbuffer *
  130. intel_create_renderbuffer(gl_format format, unsigned num_samples);
  131.  
  132. struct intel_renderbuffer *
  133. intel_create_private_renderbuffer(gl_format format, unsigned num_samples);
  134.  
  135. struct gl_renderbuffer*
  136. intel_create_wrapped_renderbuffer(struct gl_context * ctx,
  137.                                   int width, int height,
  138.                                   gl_format format);
  139.  
  140. extern void
  141. intel_fbo_init(struct brw_context *brw);
  142.  
  143. void
  144. intel_renderbuffer_set_draw_offset(struct intel_renderbuffer *irb);
  145.  
  146. static inline uint32_t
  147. intel_renderbuffer_get_tile_offsets(struct intel_renderbuffer *irb,
  148.                                     uint32_t *tile_x,
  149.                                     uint32_t *tile_y)
  150. {
  151.    return intel_miptree_get_tile_offsets(irb->mt, irb->mt_level, irb->mt_layer,
  152.                                          tile_x, tile_y);
  153. }
  154.  
  155. void
  156. intel_renderbuffer_set_needs_downsample(struct intel_renderbuffer *irb);
  157.  
  158. bool
  159. intel_renderbuffer_has_hiz(struct intel_renderbuffer *irb);
  160.  
  161. void
  162. intel_renderbuffer_set_needs_hiz_resolve(struct intel_renderbuffer *irb);
  163.  
  164. void
  165. intel_renderbuffer_set_needs_depth_resolve(struct intel_renderbuffer *irb);
  166.  
  167.  
  168. /**
  169.  * \brief Perform a HiZ resolve on the renderbuffer.
  170.  *
  171.  * It is safe to call this function on a renderbuffer without HiZ. In that
  172.  * case, the function is a no-op.
  173.  *
  174.  * \return false if no resolve was needed
  175.  */
  176. bool
  177. intel_renderbuffer_resolve_hiz(struct brw_context *brw,
  178.                                struct intel_renderbuffer *irb);
  179.  
  180. /**
  181.  * \brief Perform a depth resolve on the renderbuffer.
  182.  *
  183.  * It is safe to call this function on a renderbuffer without HiZ. In that
  184.  * case, the function is a no-op.
  185.  *
  186.  * \return false if no resolve was needed
  187.  */
  188. bool
  189. intel_renderbuffer_resolve_depth(struct brw_context *brw,
  190.                                  struct intel_renderbuffer *irb);
  191.  
  192. void intel_renderbuffer_move_to_temp(struct brw_context *brw,
  193.                                      struct intel_renderbuffer *irb,
  194.                                      bool invalidate);
  195.  
  196. unsigned
  197. intel_quantize_num_samples(struct intel_screen *intel, unsigned num_samples);
  198.  
  199. #ifdef __cplusplus
  200. }
  201. #endif
  202.  
  203. #endif /* INTEL_FBO_H */
  204.