intel_regions.h revision f8377b411dfe3c879eaab11bb86f509178796bd1
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_REGIONS_H 29#define INTEL_REGIONS_H 30 31/** @file intel_regions.h 32 * 33 * Structure definitions and prototypes for intel_region handling, 34 * which is the basic structure for rectangular collections of pixels 35 * stored in a drm_intel_bo. 36 */ 37 38#include <stdbool.h> 39#include <xf86drm.h> 40 41#include "main/mtypes.h" 42#include "intel_bufmgr.h" 43 44struct intel_context; 45struct intel_buffer_object; 46 47/** 48 * A layer on top of the bufmgr buffers that adds a few useful things: 49 * 50 * - Refcounting for local buffer references. 51 * - Refcounting for buffer maps 52 * - Buffer dimensions - pitch and height. 53 * - Blitter commands for copying 2D regions between buffers. (really???) 54 */ 55struct intel_region 56{ 57 drm_intel_bo *bo; /**< buffer manager's buffer */ 58 GLuint refcount; /**< Reference count for region */ 59 GLuint cpp; /**< bytes per pixel */ 60 GLuint width; /**< in pixels */ 61 GLuint height; /**< in pixels */ 62 GLuint pitch; /**< in pixels */ 63 GLubyte *map; /**< only non-NULL when region is actually mapped */ 64 GLuint map_refcount; /**< Reference count for mapping */ 65 66 uint32_t tiling; /**< Which tiling mode the region is in */ 67 68 uint32_t name; /**< Global name for the bo */ 69 struct intel_screen *screen; 70}; 71 72 73/* Allocate a refcounted region. Pointers to regions should only be 74 * copied by calling intel_reference_region(). 75 */ 76struct intel_region *intel_region_alloc(struct intel_screen *screen, 77 uint32_t tiling, 78 GLuint cpp, GLuint width, 79 GLuint height, 80 bool expect_accelerated_upload); 81 82struct intel_region * 83intel_region_alloc_for_handle(struct intel_screen *screen, 84 GLuint cpp, 85 GLuint width, GLuint height, GLuint pitch, 86 unsigned int handle, const char *name); 87 88bool 89intel_region_flink(struct intel_region *region, uint32_t *name); 90 91void intel_region_reference(struct intel_region **dst, 92 struct intel_region *src); 93 94void intel_region_release(struct intel_region **ib); 95 96void intel_recreate_static_regions(struct intel_context *intel); 97 98/** 99 * Map/unmap regions. This is refcounted also: 100 * 101 * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT 102 */ 103GLubyte *intel_region_map(struct intel_context *intel, 104 struct intel_region *ib, 105 GLbitfield mode); 106 107void intel_region_unmap(struct intel_context *intel, struct intel_region *ib); 108 109/* Copy rectangular sub-regions 110 */ 111bool 112intel_region_copy(struct intel_context *intel, 113 struct intel_region *dest, 114 GLuint dest_offset, 115 GLuint destx, GLuint desty, 116 struct intel_region *src, 117 GLuint src_offset, 118 GLuint srcx, GLuint srcy, GLuint width, GLuint height, 119 bool flip, 120 GLenum logicop); 121 122void _mesa_copy_rect(GLubyte * dst, 123 GLuint cpp, 124 GLuint dst_pitch, 125 GLuint dst_x, 126 GLuint dst_y, 127 GLuint width, 128 GLuint height, 129 const GLubyte * src, 130 GLuint src_pitch, GLuint src_x, GLuint src_y); 131 132struct __DRIimageRec { 133 struct intel_region *region; 134 GLenum internal_format; 135 GLuint format; 136 GLenum data_type; 137 void *data; 138}; 139 140#endif 141