1bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt/************************************************************************** 26b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 36b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Copyright 2005 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_BUFFEROBJ_H 296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define INTEL_BUFFEROBJ_H 306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 31ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/mtypes.h" 326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstruct intel_context; 346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstruct gl_buffer_object; 356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/** 386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Intel vertex/pixel buffer object, derived from Mesa's gl_buffer_object. 396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstruct intel_buffer_object 416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct gl_buffer_object Base; 4334474fa4119378ef9fbb9fb557cc19c0a1ca1f7eEric Anholt drm_intel_bo *buffer; /* the low-level buffer manager's buffer handle */ 44e476e122207e6195a16a8c7d2cab90eeba227934Chris Wilson GLuint offset; /* any offset into that buffer */ 45e476e122207e6195a16a8c7d2cab90eeba227934Chris Wilson 46a945e203d4fe254593bc0c5c5d6caca45e65f9f7Eric Anholt /** System memory buffer data, if not using a BO to store the data. */ 47a945e203d4fe254593bc0c5c5d6caca45e65f9f7Eric Anholt void *sys_buffer; 486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 492d5c74fac3cc0f9d45a9e11b2fcdea1bc67928c4Eric Anholt drm_intel_bo *range_map_bo; 50ec32ef12b3a496008cc982acfefca570a88e92ebEric Anholt void *range_map_buffer; 512d5c74fac3cc0f9d45a9e11b2fcdea1bc67928c4Eric Anholt unsigned int range_map_offset; 522d5c74fac3cc0f9d45a9e11b2fcdea1bc67928c4Eric Anholt GLsizei range_map_size; 532d5c74fac3cc0f9d45a9e11b2fcdea1bc67928c4Eric Anholt 542e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke bool source; 556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}; 566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* Get the bm buffer associated with a GL bufferobject: 596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 6034474fa4119378ef9fbb9fb557cc19c0a1ca1f7eEric Anholtdrm_intel_bo *intel_bufferobj_buffer(struct intel_context *intel, 6134474fa4119378ef9fbb9fb557cc19c0a1ca1f7eEric Anholt struct intel_buffer_object *obj, 6234474fa4119378ef9fbb9fb557cc19c0a1ca1f7eEric Anholt GLuint flag); 63e476e122207e6195a16a8c7d2cab90eeba227934Chris Wilsondrm_intel_bo *intel_bufferobj_source(struct intel_context *intel, 64e476e122207e6195a16a8c7d2cab90eeba227934Chris Wilson struct intel_buffer_object *obj, 651546291e5b8d3ac02f5bee38252f9d479bcf95ccChris Wilson GLuint align, 66e476e122207e6195a16a8c7d2cab90eeba227934Chris Wilson GLuint *offset); 676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 68abb37861d9f3310fe2d16194d893682092f41087Chris Wilsonvoid intel_upload_data(struct intel_context *intel, 69a07e4811794051dc65187d17b7f85e340e61854eChris Wilson const void *ptr, GLuint size, GLuint align, 70abb37861d9f3310fe2d16194d893682092f41087Chris Wilson drm_intel_bo **return_bo, 71abb37861d9f3310fe2d16194d893682092f41087Chris Wilson GLuint *return_offset); 72abb37861d9f3310fe2d16194d893682092f41087Chris Wilson 73abb37861d9f3310fe2d16194d893682092f41087Chris Wilsonvoid *intel_upload_map(struct intel_context *intel, 74a07e4811794051dc65187d17b7f85e340e61854eChris Wilson GLuint size, GLuint align); 753630d5b69afcecc3142d2c4897835175886f4bd8Chris Wilsonvoid intel_upload_unmap(struct intel_context *intel, 76a07e4811794051dc65187d17b7f85e340e61854eChris Wilson const void *ptr, GLuint size, GLuint align, 773630d5b69afcecc3142d2c4897835175886f4bd8Chris Wilson drm_intel_bo **return_bo, 783630d5b69afcecc3142d2c4897835175886f4bd8Chris Wilson GLuint *return_offset); 79abb37861d9f3310fe2d16194d893682092f41087Chris Wilson 808a9e67b8df9836408270a4bc3660ec45b622ae56Chris Wilsonvoid intel_upload_finish(struct intel_context *intel); 818a9e67b8df9836408270a4bc3660ec45b622ae56Chris Wilson 82abb37861d9f3310fe2d16194d893682092f41087Chris Wilson/* Hook the bufferobject implementation into mesa: 836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 84dd26899ca39111e0866afed9df94bfb1618dd363Michel Dänzervoid intelInitBufferObjectFuncs(struct dd_function_table *functions); 856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 86d58a3182b1e680105731897fe2d84928daf89fceEric Anholtstatic inline struct intel_buffer_object * 876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellintel_buffer_object(struct gl_buffer_object *obj) 886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 89dd26899ca39111e0866afed9df94bfb1618dd363Michel Dänzer return (struct intel_buffer_object *) obj; 906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} 916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#endif 93