intel_regions.h revision 8f81a6468fdbc7320800ea497791e3e1b8f782ca
16b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/************************************************************************** 26b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 36b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas. 46b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * All Rights Reserved. 56b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 66b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 76b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * copy of this software and associated documentation files (the 86b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * "Software"), to deal in the Software without restriction, including 96b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * without limitation the rights to use, copy, modify, merge, publish, 106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * distribute, sub license, and/or sell copies of the Software, and to 116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * permit persons to whom the Software is furnished to do so, subject to 126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * the following conditions: 136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * The above copyright notice and this permission notice (including the 156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * next paragraph) shall be included in all copies or substantial portions 166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * of the Software. 176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell **************************************************************************/ 276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#ifndef INTEL_REGIONS_H 296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define INTEL_REGIONS_H 306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 31f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie/** @file intel_regions.h 32f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie * 33f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie * Structure definitions and prototypes for intel_region handling, which is 34f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie * the basic structure for rectangular collections of pixels stored in a dri_bo. 35f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie */ 36f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie 373628185f566e178a12b493fb89abf52b4b281f99Eric Anholt#include <xf86drm.h> 383628185f566e178a12b493fb89abf52b4b281f99Eric Anholt 39ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/mtypes.h" 403628185f566e178a12b493fb89abf52b4b281f99Eric Anholt#include "intel_bufmgr.h" 416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstruct intel_context; 436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstruct intel_buffer_object; 446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/** 466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * A layer on top of the bufmgr buffers that adds a few useful things: 476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * - Refcounting for local buffer references. 496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * - Refcounting for buffer maps 506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * - Buffer dimensions - pitch and height. 516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * - Blitter commands for copying 2D regions between buffers. (really???) 526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstruct intel_region 546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 55cfc21190af1038f204d38ab4764a9c731b0323a5Eric Anholt dri_bo *buffer; /**< buffer manager's buffer */ 566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint refcount; /**< Reference count for region */ 576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint cpp; /**< bytes per pixel */ 588db761409dadc2e899d4e7107eff3aa07b07aa11Eric Anholt GLuint width; /**< in pixels */ 596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint height; /**< in pixels */ 608db761409dadc2e899d4e7107eff3aa07b07aa11Eric Anholt GLuint pitch; /**< in pixels */ 616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLubyte *map; /**< only non-NULL when region is actually mapped */ 626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint map_refcount; /**< Reference count for mapping */ 636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint draw_offset; /**< Offset of drawing address within the region */ 65f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie uint32_t tiling; /**< Which tiling mode the region is in */ 66f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie uint32_t bit_6_swizzle; /**< GEM flag for address swizzling requirement */ 67f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie drmAddress classic_map; /**< drmMap of the region when not in GEM mode */ 686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct intel_buffer_object *pbo; /* zero-copy uploads */ 696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}; 706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* Allocate a refcounted region. Pointers to regions should only be 736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * copied by calling intel_reference_region(). 746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 757c71ef3a3d0cf2620525f468960cdc76a0fb0d33Eric Anholtstruct intel_region *intel_region_alloc(struct intel_context *intel, 761ba96651e12b3c74fb9c8f5a61b183ef36a27b1eEric Anholt uint32_t tiling, 771ba96651e12b3c74fb9c8f5a61b183ef36a27b1eEric Anholt GLuint cpp, GLuint width, 7840dd024be618d805b3744e15d25e115018641324Eric Anholt GLuint height, GLuint pitch, 7940dd024be618d805b3744e15d25e115018641324Eric Anholt GLboolean expect_accelerated_upload); 806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 81c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsbergstruct intel_region * 82c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsbergintel_region_alloc_for_handle(struct intel_context *intel, 838db761409dadc2e899d4e7107eff3aa07b07aa11Eric Anholt GLuint cpp, 848db761409dadc2e899d4e7107eff3aa07b07aa11Eric Anholt GLuint width, GLuint height, GLuint pitch, 85f56b569e9af356c11869ee49a4669bb01b75397eKristian Høgsberg unsigned int handle, const char *name); 86c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg 876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellvoid intel_region_reference(struct intel_region **dst, 886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct intel_region *src); 896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellvoid intel_region_release(struct intel_region **ib); 916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 927c71ef3a3d0cf2620525f468960cdc76a0fb0d33Eric Anholtvoid intel_recreate_static_regions(struct intel_context *intel); 937c71ef3a3d0cf2620525f468960cdc76a0fb0d33Eric Anholt 946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* Map/unmap regions. This is refcounted also: 956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 967c71ef3a3d0cf2620525f468960cdc76a0fb0d33Eric AnholtGLubyte *intel_region_map(struct intel_context *intel, 976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct intel_region *ib); 986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 997c71ef3a3d0cf2620525f468960cdc76a0fb0d33Eric Anholtvoid intel_region_unmap(struct intel_context *intel, struct intel_region *ib); 1006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* Upload data to a rectangular sub-region 1036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 1047c71ef3a3d0cf2620525f468960cdc76a0fb0d33Eric Anholtvoid intel_region_data(struct intel_context *intel, 1056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct intel_region *dest, 1066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint dest_offset, 1076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint destx, GLuint desty, 1085cd30a2b202d12240eac60825f9882838fd66779Brian const void *src, GLuint src_stride, 1096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint srcx, GLuint srcy, GLuint width, GLuint height); 1106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* Copy rectangular sub-regions 1126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 1138f81a6468fdbc7320800ea497791e3e1b8f782caEric AnholtGLboolean 1148f81a6468fdbc7320800ea497791e3e1b8f782caEric Anholtintel_region_copy(struct intel_context *intel, 1158f81a6468fdbc7320800ea497791e3e1b8f782caEric Anholt struct intel_region *dest, 1168f81a6468fdbc7320800ea497791e3e1b8f782caEric Anholt GLuint dest_offset, 1178f81a6468fdbc7320800ea497791e3e1b8f782caEric Anholt GLuint destx, GLuint desty, 1188f81a6468fdbc7320800ea497791e3e1b8f782caEric Anholt struct intel_region *src, 1198f81a6468fdbc7320800ea497791e3e1b8f782caEric Anholt GLuint src_offset, 1208f81a6468fdbc7320800ea497791e3e1b8f782caEric Anholt GLuint srcx, GLuint srcy, GLuint width, GLuint height, 1218f81a6468fdbc7320800ea497791e3e1b8f782caEric Anholt GLenum logicop); 1226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* Helpers for zerocopy uploads, particularly texture image uploads: 1246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 1257c71ef3a3d0cf2620525f468960cdc76a0fb0d33Eric Anholtvoid intel_region_attach_pbo(struct intel_context *intel, 1266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct intel_region *region, 1276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct intel_buffer_object *pbo); 1287c71ef3a3d0cf2620525f468960cdc76a0fb0d33Eric Anholtvoid intel_region_release_pbo(struct intel_context *intel, 1296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct intel_region *region); 1307c71ef3a3d0cf2620525f468960cdc76a0fb0d33Eric Anholtvoid intel_region_cow(struct intel_context *intel, 1316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct intel_region *region); 1326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1337c71ef3a3d0cf2620525f468960cdc76a0fb0d33Eric Anholtdri_bo *intel_region_buffer(struct intel_context *intel, 134cfc21190af1038f204d38ab4764a9c731b0323a5Eric Anholt struct intel_region *region, 135cfc21190af1038f204d38ab4764a9c731b0323a5Eric Anholt GLuint flag); 1366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 137a9a483b43ec090408148d069bc184c0a21323654Zou Nan haivoid _mesa_copy_rect(GLubyte * dst, 138a9a483b43ec090408148d069bc184c0a21323654Zou Nan hai GLuint cpp, 139a9a483b43ec090408148d069bc184c0a21323654Zou Nan hai GLuint dst_pitch, 140a9a483b43ec090408148d069bc184c0a21323654Zou Nan hai GLuint dst_x, 141a9a483b43ec090408148d069bc184c0a21323654Zou Nan hai GLuint dst_y, 142a9a483b43ec090408148d069bc184c0a21323654Zou Nan hai GLuint width, 143a9a483b43ec090408148d069bc184c0a21323654Zou Nan hai GLuint height, 144a9a483b43ec090408148d069bc184c0a21323654Zou Nan hai const GLubyte * src, 145a9a483b43ec090408148d069bc184c0a21323654Zou Nan hai GLuint src_pitch, GLuint src_x, GLuint src_y); 146a9a483b43ec090408148d069bc184c0a21323654Zou Nan hai 1476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#endif 148