14f25420bdd834e81a3e22733304efc5261c2998aBrian Paul/************************************************************************** 24f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * 34f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. 44f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * All Rights Reserved. 54f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * 64f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * Permission is hereby granted, free of charge, to any person obtaining a 74f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * copy of this software and associated documentation files (the 84f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * "Software"), to deal in the Software without restriction, including 94f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * without limitation the rights to use, copy, modify, merge, publish, 104f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * distribute, sub license, and/or sell copies of the Software, and to 114f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * permit persons to whom the Software is furnished to do so, subject to 124f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * the following conditions: 134f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * 144f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * The above copyright notice and this permission notice (including the 154f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * next paragraph) shall be included in all copies or substantial portions 164f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * of the Software. 174f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * 184f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 194f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 204f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 214f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 224f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 234f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 244f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 254f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * 264f25420bdd834e81a3e22733304efc5261c2998aBrian Paul **************************************************************************/ 274f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 284f25420bdd834e81a3e22733304efc5261c2998aBrian Paul#ifndef P_TILE_H 294f25420bdd834e81a3e22733304efc5261c2998aBrian Paul#define P_TILE_H 304f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 314f25420bdd834e81a3e22733304efc5261c2998aBrian Paul#include "pipe/p_compiler.h" 3258cfbd697d2a6ca8d00ce17b2783023bc3256019Vinson Lee#include "pipe/p_format.h" 3358cfbd697d2a6ca8d00ce17b2783023bc3256019Vinson Lee#include "pipe/p_state.h" 344f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 3558cfbd697d2a6ca8d00ce17b2783023bc3256019Vinson Leestruct pipe_context; 364617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzerstruct pipe_transfer; 374f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 384f25420bdd834e81a3e22733304efc5261c2998aBrian Paul/** 394617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer * Clip tile against transfer dims. 40287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 41287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * XXX: this only clips width and height! 42287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 434f25420bdd834e81a3e22733304efc5261c2998aBrian Paul * \return TRUE if tile is totally clipped, FALSE otherwise 444f25420bdd834e81a3e22733304efc5261c2998aBrian Paul */ 454f25420bdd834e81a3e22733304efc5261c2998aBrian Paulstatic INLINE boolean 46287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellu_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_box *box) 474f25420bdd834e81a3e22733304efc5261c2998aBrian Paul{ 48287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell if (x >= box->width) 494f25420bdd834e81a3e22733304efc5261c2998aBrian Paul return TRUE; 50287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell if (y >= box->height) 514f25420bdd834e81a3e22733304efc5261c2998aBrian Paul return TRUE; 52287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell if (x + *w > box->width) 53287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell *w = box->width - x; 54287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell if (y + *h > box->height) 55287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell *h = box->height - y; 564f25420bdd834e81a3e22733304efc5261c2998aBrian Paul return FALSE; 574f25420bdd834e81a3e22733304efc5261c2998aBrian Paul} 584f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 594f25420bdd834e81a3e22733304efc5261c2998aBrian Paul#ifdef __cplusplus 604f25420bdd834e81a3e22733304efc5261c2998aBrian Paulextern "C" { 614f25420bdd834e81a3e22733304efc5261c2998aBrian Paul#endif 624f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 634f25420bdd834e81a3e22733304efc5261c2998aBrian Paulvoid 64d35ecca5ee231c072687578642e0c22c6c0590b1Keith Whitwellpipe_get_tile_raw(struct pipe_context *pipe, 65d35ecca5ee231c072687578642e0c22c6c0590b1Keith Whitwell struct pipe_transfer *pt, 664f25420bdd834e81a3e22733304efc5261c2998aBrian Paul uint x, uint y, uint w, uint h, 674f25420bdd834e81a3e22733304efc5261c2998aBrian Paul void *p, int dst_stride); 684f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 694f25420bdd834e81a3e22733304efc5261c2998aBrian Paulvoid 70d35ecca5ee231c072687578642e0c22c6c0590b1Keith Whitwellpipe_put_tile_raw(struct pipe_context *pipe, 71d35ecca5ee231c072687578642e0c22c6c0590b1Keith Whitwell struct pipe_transfer *pt, 724f25420bdd834e81a3e22733304efc5261c2998aBrian Paul uint x, uint y, uint w, uint h, 734f25420bdd834e81a3e22733304efc5261c2998aBrian Paul const void *p, int src_stride); 744f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 754f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 764f25420bdd834e81a3e22733304efc5261c2998aBrian Paulvoid 77d35ecca5ee231c072687578642e0c22c6c0590b1Keith Whitwellpipe_get_tile_rgba(struct pipe_context *pipe, 78d35ecca5ee231c072687578642e0c22c6c0590b1Keith Whitwell struct pipe_transfer *pt, 794f25420bdd834e81a3e22733304efc5261c2998aBrian Paul uint x, uint y, uint w, uint h, 804f25420bdd834e81a3e22733304efc5261c2998aBrian Paul float *p); 814f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 824f25420bdd834e81a3e22733304efc5261c2998aBrian Paulvoid 8390671fcdda52a83e2bbba581e985d25c6bff961eBrian Paulpipe_get_tile_rgba_format(struct pipe_context *pipe, 8490671fcdda52a83e2bbba581e985d25c6bff961eBrian Paul struct pipe_transfer *pt, 8590671fcdda52a83e2bbba581e985d25c6bff961eBrian Paul uint x, uint y, uint w, uint h, 8690671fcdda52a83e2bbba581e985d25c6bff961eBrian Paul enum pipe_format format, 8790671fcdda52a83e2bbba581e985d25c6bff961eBrian Paul float *p); 885587097b53afbce52f7e26568d2dde11de96e1ecMichal Krol 895587097b53afbce52f7e26568d2dde11de96e1ecMichal Krolvoid 90d35ecca5ee231c072687578642e0c22c6c0590b1Keith Whitwellpipe_put_tile_rgba(struct pipe_context *pipe, 91d35ecca5ee231c072687578642e0c22c6c0590b1Keith Whitwell struct pipe_transfer *pt, 924f25420bdd834e81a3e22733304efc5261c2998aBrian Paul uint x, uint y, uint w, uint h, 934f25420bdd834e81a3e22733304efc5261c2998aBrian Paul const float *p); 944f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 95e75844b4e09cbbfca159a4e4709d3ca1249d784dBrian Paulvoid 96e75844b4e09cbbfca159a4e4709d3ca1249d784dBrian Paulpipe_put_tile_rgba_format(struct pipe_context *pipe, 97e75844b4e09cbbfca159a4e4709d3ca1249d784dBrian Paul struct pipe_transfer *pt, 98e75844b4e09cbbfca159a4e4709d3ca1249d784dBrian Paul uint x, uint y, uint w, uint h, 99e75844b4e09cbbfca159a4e4709d3ca1249d784dBrian Paul enum pipe_format format, 100e75844b4e09cbbfca159a4e4709d3ca1249d784dBrian Paul const float *p); 101e75844b4e09cbbfca159a4e4709d3ca1249d784dBrian Paul 1024f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 1034f25420bdd834e81a3e22733304efc5261c2998aBrian Paulvoid 104d35ecca5ee231c072687578642e0c22c6c0590b1Keith Whitwellpipe_get_tile_z(struct pipe_context *pipe, 105d35ecca5ee231c072687578642e0c22c6c0590b1Keith Whitwell struct pipe_transfer *pt, 1064f25420bdd834e81a3e22733304efc5261c2998aBrian Paul uint x, uint y, uint w, uint h, 1074f25420bdd834e81a3e22733304efc5261c2998aBrian Paul uint *z); 1084f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 1094f25420bdd834e81a3e22733304efc5261c2998aBrian Paulvoid 110d35ecca5ee231c072687578642e0c22c6c0590b1Keith Whitwellpipe_put_tile_z(struct pipe_context *pipe, 111d35ecca5ee231c072687578642e0c22c6c0590b1Keith Whitwell struct pipe_transfer *pt, 1124f25420bdd834e81a3e22733304efc5261c2998aBrian Paul uint x, uint y, uint w, uint h, 1134f25420bdd834e81a3e22733304efc5261c2998aBrian Paul const uint *z); 1144f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 1154f25420bdd834e81a3e22733304efc5261c2998aBrian Paulvoid 1164f25420bdd834e81a3e22733304efc5261c2998aBrian Paulpipe_tile_raw_to_rgba(enum pipe_format format, 1174f25420bdd834e81a3e22733304efc5261c2998aBrian Paul void *src, 1184f25420bdd834e81a3e22733304efc5261c2998aBrian Paul uint w, uint h, 1194f25420bdd834e81a3e22733304efc5261c2998aBrian Paul float *dst, unsigned dst_stride); 1204f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 121a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlievoid 122a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airliepipe_tile_raw_to_unsigned(enum pipe_format format, 123a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie void *src, 124a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie uint w, uint h, 125a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie unsigned *dst, unsigned dst_stride); 126a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie 127a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlievoid 128a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airliepipe_tile_raw_to_signed(enum pipe_format format, 129a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie void *src, 130a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie uint w, uint h, 131a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie int *dst, unsigned dst_stride); 132a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie 133a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlievoid 134a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airliepipe_get_tile_ui_format(struct pipe_context *pipe, 135a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie struct pipe_transfer *pt, 136a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie uint x, uint y, uint w, uint h, 137a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie enum pipe_format format, 138a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie unsigned int *p); 139a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie 140a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlievoid 141a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airliepipe_get_tile_i_format(struct pipe_context *pipe, 142a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie struct pipe_transfer *pt, 143a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie uint x, uint y, uint w, uint h, 144a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie enum pipe_format format, 145a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie int *p); 146a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie 147a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlievoid 148a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airliepipe_put_tile_ui_format(struct pipe_context *pipe, 149a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie struct pipe_transfer *pt, 150a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie uint x, uint y, uint w, uint h, 151a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie enum pipe_format format, 152a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie const unsigned *p); 153a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie 154a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlievoid 155a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airliepipe_put_tile_i_format(struct pipe_context *pipe, 156a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie struct pipe_transfer *pt, 157a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie uint x, uint y, uint w, uint h, 158a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie enum pipe_format format, 159a441feb757b1be4845ba378f0207dcdc5cc1a407Dave Airlie const int *p); 1604f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 1614f25420bdd834e81a3e22733304efc5261c2998aBrian Paul#ifdef __cplusplus 1624f25420bdd834e81a3e22733304efc5261c2998aBrian Paul} 1634f25420bdd834e81a3e22733304efc5261c2998aBrian Paul#endif 1644f25420bdd834e81a3e22733304efc5261c2998aBrian Paul 1654f25420bdd834e81a3e22733304efc5261c2998aBrian Paul#endif 166