Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

intel_fbo.h 5.8KB

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