intel_fbo.h revision 0c498467104e361e50bbb95adf2b2c0e799591dc
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 "intel_context.h" 35#include "intel_screen.h" 36 37struct intel_context; 38struct intel_mipmap_tree; 39struct intel_texture_image; 40 41/** 42 * Intel renderbuffer, derived from gl_renderbuffer. 43 */ 44struct intel_renderbuffer 45{ 46 struct gl_renderbuffer Base; 47 struct intel_mipmap_tree *mt; /**< The renderbuffer storage. */ 48 drm_intel_bo *map_bo; 49 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 67 GLuint draw_x, draw_y; /**< Offset of drawing within the region */ 68}; 69 70 71/** 72 * gl_renderbuffer is a base class which we subclass. The Class field 73 * is used for simple run-time type checking. 74 */ 75#define INTEL_RB_CLASS 0x12345678 76 77 78/** 79 * Return a gl_renderbuffer ptr casted to intel_renderbuffer. 80 * NULL will be returned if the rb isn't really an intel_renderbuffer. 81 * This is determined by checking the ClassID. 82 */ 83static INLINE struct intel_renderbuffer * 84intel_renderbuffer(struct gl_renderbuffer *rb) 85{ 86 struct intel_renderbuffer *irb = (struct intel_renderbuffer *) rb; 87 if (irb && irb->Base.ClassID == INTEL_RB_CLASS) { 88 /*_mesa_warning(NULL, "Returning non-intel Rb\n");*/ 89 return irb; 90 } 91 else 92 return NULL; 93} 94 95 96/** 97 * \brief Return the framebuffer attachment specified by attIndex. 98 * 99 * If the framebuffer lacks the specified attachment, then return null. 100 * 101 * If the attached renderbuffer is a wrapper, then return wrapped 102 * renderbuffer. 103 */ 104static INLINE struct intel_renderbuffer * 105intel_get_renderbuffer(struct gl_framebuffer *fb, gl_buffer_index attIndex) 106{ 107 struct gl_renderbuffer *rb; 108 109 assert((unsigned)attIndex < ARRAY_SIZE(fb->Attachment)); 110 111 rb = fb->Attachment[attIndex].Renderbuffer; 112 if (!rb) 113 return NULL; 114 115 return intel_renderbuffer(rb); 116} 117 118bool 119intel_framebuffer_has_hiz(struct gl_framebuffer *fb); 120 121extern struct intel_renderbuffer * 122intel_create_renderbuffer(gl_format format); 123 124struct gl_renderbuffer* 125intel_create_wrapped_renderbuffer(struct gl_context * ctx, 126 int width, int height, 127 gl_format format); 128 129GLboolean 130intel_alloc_renderbuffer_storage(struct gl_context * ctx, 131 struct gl_renderbuffer *rb, 132 GLenum internalFormat, 133 GLuint width, GLuint height); 134 135extern void 136intel_fbo_init(struct intel_context *intel); 137 138 139extern void 140intel_flip_renderbuffers(struct gl_framebuffer *fb); 141 142void 143intel_renderbuffer_set_draw_offset(struct intel_renderbuffer *irb); 144 145uint32_t 146intel_renderbuffer_tile_offsets(struct intel_renderbuffer *irb, 147 uint32_t *tile_x, 148 uint32_t *tile_y); 149 150struct intel_region* 151intel_get_rb_region(struct gl_framebuffer *fb, GLuint attIndex); 152 153void 154intel_renderbuffer_set_needs_hiz_resolve(struct intel_renderbuffer *irb); 155 156void 157intel_renderbuffer_set_needs_depth_resolve(struct intel_renderbuffer *irb); 158 159 160/** 161 * \brief Perform a HiZ resolve on the renderbuffer. 162 * 163 * It is safe to call this function on a renderbuffer without HiZ. In that 164 * case, the function is a no-op. 165 * 166 * \return false if no resolve was needed 167 */ 168bool 169intel_renderbuffer_resolve_hiz(struct intel_context *intel, 170 struct intel_renderbuffer *irb); 171 172/** 173 * \brief Perform a depth resolve on the renderbuffer. 174 * 175 * It is safe to call this function on a renderbuffer without HiZ. In that 176 * case, the function is a no-op. 177 * 178 * \return false if no resolve was needed 179 */ 180bool 181intel_renderbuffer_resolve_depth(struct intel_context *intel, 182 struct intel_renderbuffer *irb); 183 184#endif /* INTEL_FBO_H */ 185