Go to the source code of this file.
Functions | |
static boolean | pipe_clip_tile (uint x, uint y, uint *w, uint *h, const struct pipe_surface *ps) |
Clip tile against surface dims. | |
void | pipe_get_tile_raw (struct pipe_surface *ps, uint x, uint y, uint w, uint h, void *p, int dst_stride) |
RGBA/float tile get/put functions. | |
void | pipe_put_tile_raw (struct pipe_surface *ps, uint x, uint y, uint w, uint h, const void *p, int src_stride) |
Move raw block of pixels from user memory to surface. | |
void | pipe_get_tile_rgba (struct pipe_surface *ps, uint x, uint y, uint w, uint h, float *p) |
void | pipe_put_tile_rgba (struct pipe_surface *ps, uint x, uint y, uint w, uint h, const float *p) |
void | pipe_get_tile_z (struct pipe_surface *ps, uint x, uint y, uint w, uint h, uint *z) |
Get a block of Z values, converted to 32-bit range. | |
void | pipe_put_tile_z (struct pipe_surface *ps, uint x, uint y, uint w, uint h, const uint *z) |
void | pipe_tile_raw_to_rgba (enum pipe_format format, void *src, uint w, uint h, float *dst, unsigned dst_stride) |
static boolean pipe_clip_tile | ( | uint | x, | |
uint | y, | |||
uint * | w, | |||
uint * | h, | |||
const struct pipe_surface * | ps | |||
) | [static] |
Clip tile against surface dims.
Definition at line 41 of file u_tile.h.
References FALSE, pipe_surface::height, TRUE, and pipe_surface::width.
00042 { 00043 if (x >= ps->width) 00044 return TRUE; 00045 if (y >= ps->height) 00046 return TRUE; 00047 if (x + *w > ps->width) 00048 *w = ps->width - x; 00049 if (y + *h > ps->height) 00050 *h = ps->height - y; 00051 return FALSE; 00052 }
void pipe_get_tile_raw | ( | struct pipe_surface * | ps, | |
uint | x, | |||
uint | y, | |||
uint | w, | |||
uint | h, | |||
void * | dst, | |||
int | dst_stride | |||
) |
RGBA/float tile get/put functions.
Usable both by drivers and state trackers. Surfaces should already be in a mapped state. Move raw block of pixels from surface to user memory. This should be usable by any hw driver that has mappable surfaces.
Definition at line 49 of file u_tile.c.
References assert, pipe_surface::block, pf_get_nblocksx(), PIPE_BUFFER_USAGE_CPU_READ, pipe_clip_tile(), pipe_copy_rect(), pipe_surface_map(), pipe_surface_unmap(), pipe_format_block::size, and pipe_surface::stride.
00052 { 00053 const void *src; 00054 00055 if (dst_stride == 0) 00056 dst_stride = pf_get_nblocksx(&ps->block, w) * ps->block.size; 00057 00058 if (pipe_clip_tile(x, y, &w, &h, ps)) 00059 return; 00060 00061 src = pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_READ); 00062 assert(src); 00063 if(!src) 00064 return; 00065 00066 pipe_copy_rect(dst, &ps->block, dst_stride, 0, 0, w, h, src, ps->stride, x, y); 00067 00068 pipe_surface_unmap(ps); 00069 }
void pipe_get_tile_rgba | ( | struct pipe_surface * | ps, | |
uint | x, | |||
uint | y, | |||
uint | w, | |||
uint | h, | |||
float * | p | |||
) |
Definition at line 980 of file u_tile.c.
References assert, pipe_surface::block, pipe_surface::format, FREE, MALLOC, pf_get_nblocks(), pipe_clip_tile(), PIPE_FORMAT_YCBCR, PIPE_FORMAT_YCBCR_REV, pipe_get_tile_raw(), pipe_tile_raw_to_rgba(), and pipe_format_block::size.
00983 { 00984 unsigned dst_stride = w * 4; 00985 void *packed; 00986 00987 if (pipe_clip_tile(x, y, &w, &h, ps)) 00988 return; 00989 00990 packed = MALLOC(pf_get_nblocks(&ps->block, w, h) * ps->block.size); 00991 00992 if (!packed) 00993 return; 00994 00995 if(ps->format == PIPE_FORMAT_YCBCR || ps->format == PIPE_FORMAT_YCBCR_REV) 00996 assert((x & 1) == 0); 00997 00998 pipe_get_tile_raw(ps, x, y, w, h, packed, 0); 00999 01000 pipe_tile_raw_to_rgba(ps->format, packed, w, h, p, dst_stride); 01001 01002 FREE(packed); 01003 }
Get a block of Z values, converted to 32-bit range.
Definition at line 1089 of file u_tile.c.
References assert, pipe_surface::format, PIPE_BUFFER_USAGE_CPU_READ, pipe_clip_tile(), PIPE_FORMAT_S8Z24_UNORM, PIPE_FORMAT_X8Z24_UNORM, PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_Z32_UNORM, pipe_surface_map(), pipe_surface_unmap(), and pipe_surface::stride.
01092 { 01093 const uint dstStride = w; 01094 ubyte *map; 01095 uint *pDest = z; 01096 uint i, j; 01097 01098 if (pipe_clip_tile(x, y, &w, &h, ps)) 01099 return; 01100 01101 map = (ubyte *)pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_READ); 01102 if (!map) { 01103 assert(0); 01104 return; 01105 } 01106 01107 switch (ps->format) { 01108 case PIPE_FORMAT_Z32_UNORM: 01109 { 01110 const uint *pSrc 01111 = (const uint *)(map + y * ps->stride + x*4); 01112 for (i = 0; i < h; i++) { 01113 memcpy(pDest, pSrc, 4 * w); 01114 pDest += dstStride; 01115 pSrc += ps->stride/4; 01116 } 01117 } 01118 break; 01119 case PIPE_FORMAT_S8Z24_UNORM: 01120 case PIPE_FORMAT_X8Z24_UNORM: 01121 { 01122 const uint *pSrc 01123 = (const uint *)(map + y * ps->stride + x*4); 01124 for (i = 0; i < h; i++) { 01125 for (j = 0; j < w; j++) { 01126 /* convert 24-bit Z to 32-bit Z */ 01127 pDest[j] = (pSrc[j] << 8) | (pSrc[j] & 0xff); 01128 } 01129 pDest += dstStride; 01130 pSrc += ps->stride/4; 01131 } 01132 } 01133 break; 01134 case PIPE_FORMAT_Z16_UNORM: 01135 { 01136 const ushort *pSrc 01137 = (const ushort *)(map + y * ps->stride + x*2); 01138 for (i = 0; i < h; i++) { 01139 for (j = 0; j < w; j++) { 01140 /* convert 16-bit Z to 32-bit Z */ 01141 pDest[j] = (pSrc[j] << 16) | pSrc[j]; 01142 } 01143 pDest += dstStride; 01144 pSrc += ps->stride/2; 01145 } 01146 } 01147 break; 01148 default: 01149 assert(0); 01150 } 01151 01152 pipe_surface_unmap(ps); 01153 }
void pipe_put_tile_raw | ( | struct pipe_surface * | ps, | |
uint | x, | |||
uint | y, | |||
uint | w, | |||
uint | h, | |||
const void * | src, | |||
int | src_stride | |||
) |
Move raw block of pixels from user memory to surface.
This should be usable by any hw driver that has mappable surfaces.
Definition at line 77 of file u_tile.c.
References assert, pipe_surface::block, pf_get_nblocksx(), PIPE_BUFFER_USAGE_CPU_WRITE, pipe_clip_tile(), pipe_copy_rect(), pipe_surface_map(), pipe_surface_unmap(), pipe_format_block::size, and pipe_surface::stride.
00080 { 00081 void *dst; 00082 00083 if (src_stride == 0) 00084 src_stride = pf_get_nblocksx(&ps->block, w) * ps->block.size; 00085 00086 if (pipe_clip_tile(x, y, &w, &h, ps)) 00087 return; 00088 00089 dst = pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_WRITE); 00090 assert(dst); 00091 if(!dst) 00092 return; 00093 00094 pipe_copy_rect(dst, &ps->block, ps->stride, x, y, w, h, src, src_stride, 0, 0); 00095 00096 pipe_surface_unmap(ps); 00097 }
void pipe_put_tile_rgba | ( | struct pipe_surface * | ps, | |
uint | x, | |||
uint | y, | |||
uint | w, | |||
uint | h, | |||
const float * | p | |||
) |
Definition at line 1007 of file u_tile.c.
References a1r5g5b5_put_tile_rgba(), a4r4g4b4_put_tile_rgba(), a8_put_tile_rgba(), a8l8_put_tile_rgba(), a8r8g8b8_put_tile_rgba(), assert, b8g8r8a8_put_tile_rgba(), pipe_surface::block, debug_printf(), pipe_surface::format, FREE, i8_put_tile_rgba(), l8_put_tile_rgba(), MALLOC, pf_get_nblocks(), pf_name(), pipe_clip_tile(), PIPE_FORMAT_A1R5G5B5_UNORM, PIPE_FORMAT_A4R4G4B4_UNORM, PIPE_FORMAT_A8_UNORM, PIPE_FORMAT_A8L8_UNORM, PIPE_FORMAT_A8R8G8B8_UNORM, PIPE_FORMAT_B8G8R8A8_UNORM, PIPE_FORMAT_I8_UNORM, PIPE_FORMAT_L8_UNORM, PIPE_FORMAT_R16_SNORM, PIPE_FORMAT_R16G16B16A16_SNORM, PIPE_FORMAT_R5G6B5_UNORM, PIPE_FORMAT_R8G8B8A8_UNORM, PIPE_FORMAT_S8Z24_UNORM, PIPE_FORMAT_X8R8G8B8_UNORM, PIPE_FORMAT_X8Z24_UNORM, PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_Z24S8_UNORM, PIPE_FORMAT_Z32_UNORM, pipe_put_tile_raw(), r16_put_tile_rgba(), r16g16b16a16_put_tile_rgba(), r5g6b5_put_tile_rgba(), pipe_format_block::size, and x8r8g8b8_put_tile_rgba().
01010 { 01011 unsigned src_stride = w * 4; 01012 void *packed; 01013 01014 if (pipe_clip_tile(x, y, &w, &h, ps)) 01015 return; 01016 01017 packed = MALLOC(pf_get_nblocks(&ps->block, w, h) * ps->block.size); 01018 01019 if (!packed) 01020 return; 01021 01022 switch (ps->format) { 01023 case PIPE_FORMAT_A8R8G8B8_UNORM: 01024 a8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); 01025 break; 01026 case PIPE_FORMAT_X8R8G8B8_UNORM: 01027 x8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); 01028 break; 01029 case PIPE_FORMAT_B8G8R8A8_UNORM: 01030 b8g8r8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); 01031 break; 01032 case PIPE_FORMAT_A1R5G5B5_UNORM: 01033 a1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride); 01034 break; 01035 case PIPE_FORMAT_R5G6B5_UNORM: 01036 r5g6b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride); 01037 break; 01038 case PIPE_FORMAT_R8G8B8A8_UNORM: 01039 assert(0); 01040 break; 01041 case PIPE_FORMAT_A4R4G4B4_UNORM: 01042 a4r4g4b4_put_tile_rgba((ushort *) packed, w, h, p, src_stride); 01043 break; 01044 case PIPE_FORMAT_L8_UNORM: 01045 l8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride); 01046 break; 01047 case PIPE_FORMAT_A8_UNORM: 01048 a8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride); 01049 break; 01050 case PIPE_FORMAT_I8_UNORM: 01051 i8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride); 01052 break; 01053 case PIPE_FORMAT_A8L8_UNORM: 01054 a8l8_put_tile_rgba((ushort *) packed, w, h, p, src_stride); 01055 break; 01056 case PIPE_FORMAT_R16_SNORM: 01057 r16_put_tile_rgba((short *) packed, w, h, p, src_stride); 01058 break; 01059 case PIPE_FORMAT_R16G16B16A16_SNORM: 01060 r16g16b16a16_put_tile_rgba((short *) packed, w, h, p, src_stride); 01061 break; 01062 case PIPE_FORMAT_Z16_UNORM: 01063 /*z16_put_tile_rgba((ushort *) packed, w, h, p, src_stride);*/ 01064 break; 01065 case PIPE_FORMAT_Z32_UNORM: 01066 /*z32_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ 01067 break; 01068 case PIPE_FORMAT_S8Z24_UNORM: 01069 case PIPE_FORMAT_X8Z24_UNORM: 01070 /*s8z24_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ 01071 break; 01072 case PIPE_FORMAT_Z24S8_UNORM: 01073 /*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ 01074 break; 01075 default: 01076 debug_printf("%s: unsupported format %s\n", __FUNCTION__, pf_name(ps->format)); 01077 } 01078 01079 pipe_put_tile_raw(ps, x, y, w, h, packed, 0); 01080 01081 FREE(packed); 01082 }
Definition at line 1157 of file u_tile.c.
References assert, pipe_surface::format, PIPE_BUFFER_USAGE_CPU_WRITE, pipe_clip_tile(), PIPE_FORMAT_S8Z24_UNORM, PIPE_FORMAT_X8Z24_UNORM, PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_Z32_UNORM, pipe_surface_map(), pipe_surface_unmap(), and pipe_surface::stride.
01160 { 01161 const uint srcStride = w; 01162 const uint *pSrc = zSrc; 01163 ubyte *map; 01164 uint i, j; 01165 01166 if (pipe_clip_tile(x, y, &w, &h, ps)) 01167 return; 01168 01169 map = (ubyte *)pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_WRITE); 01170 if (!map) { 01171 assert(0); 01172 return; 01173 } 01174 01175 switch (ps->format) { 01176 case PIPE_FORMAT_Z32_UNORM: 01177 { 01178 uint *pDest = (uint *) (map + y * ps->stride + x*4); 01179 for (i = 0; i < h; i++) { 01180 memcpy(pDest, pSrc, 4 * w); 01181 pDest += ps->stride/4; 01182 pSrc += srcStride; 01183 } 01184 } 01185 break; 01186 case PIPE_FORMAT_S8Z24_UNORM: 01187 case PIPE_FORMAT_X8Z24_UNORM: 01188 { 01189 uint *pDest = (uint *) (map + y * ps->stride + x*4); 01190 for (i = 0; i < h; i++) { 01191 for (j = 0; j < w; j++) { 01192 /* convert 32-bit Z to 24-bit Z (0 stencil) */ 01193 pDest[j] = pSrc[j] >> 8; 01194 } 01195 pDest += ps->stride/4; 01196 pSrc += srcStride; 01197 } 01198 } 01199 break; 01200 case PIPE_FORMAT_Z16_UNORM: 01201 { 01202 ushort *pDest = (ushort *) (map + y * ps->stride + x*2); 01203 for (i = 0; i < h; i++) { 01204 for (j = 0; j < w; j++) { 01205 /* convert 32-bit Z to 16-bit Z */ 01206 pDest[j] = pSrc[j] >> 16; 01207 } 01208 pDest += ps->stride/2; 01209 pSrc += srcStride; 01210 } 01211 } 01212 break; 01213 default: 01214 assert(0); 01215 } 01216 01217 pipe_surface_unmap(ps); 01218 }
void pipe_tile_raw_to_rgba | ( | enum pipe_format | format, | |
void * | src, | |||
uint | w, | |||
uint | h, | |||
float * | dst, | |||
unsigned | dst_stride | |||
) |
Definition at line 908 of file u_tile.c.
References a1r5g5b5_get_tile_rgba(), a4r4g4b4_get_tile_rgba(), a8_get_tile_rgba(), a8l8_get_tile_rgba(), a8r8g8b8_get_tile_rgba(), b8g8r8a8_get_tile_rgba(), debug_printf(), fake_get_tile_rgba(), FALSE, i8_get_tile_rgba(), l8_get_tile_rgba(), pf_name(), PIPE_FORMAT_A1R5G5B5_UNORM, PIPE_FORMAT_A4R4G4B4_UNORM, PIPE_FORMAT_A8_UNORM, PIPE_FORMAT_A8L8_UNORM, PIPE_FORMAT_A8R8G8B8_UNORM, PIPE_FORMAT_B8G8R8A8_UNORM, PIPE_FORMAT_I8_UNORM, PIPE_FORMAT_L8_UNORM, PIPE_FORMAT_R16_SNORM, PIPE_FORMAT_R16G16B16A16_SNORM, PIPE_FORMAT_R5G6B5_UNORM, PIPE_FORMAT_S8Z24_UNORM, PIPE_FORMAT_X8R8G8B8_UNORM, PIPE_FORMAT_X8Z24_UNORM, PIPE_FORMAT_YCBCR, PIPE_FORMAT_YCBCR_REV, PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_Z24S8_UNORM, PIPE_FORMAT_Z32_FLOAT, PIPE_FORMAT_Z32_UNORM, r16_get_tile_rgba(), r16g16b16a16_get_tile_rgba(), r5g6b5_get_tile_rgba(), s8z24_get_tile_rgba(), TRUE, x8r8g8b8_get_tile_rgba(), ycbcr_get_tile_rgba(), z16_get_tile_rgba(), z24s8_get_tile_rgba(), z32_get_tile_rgba(), and z32f_get_tile_rgba().
00912 { 00913 switch (format) { 00914 case PIPE_FORMAT_A8R8G8B8_UNORM: 00915 a8r8g8b8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); 00916 break; 00917 case PIPE_FORMAT_X8R8G8B8_UNORM: 00918 x8r8g8b8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); 00919 break; 00920 case PIPE_FORMAT_B8G8R8A8_UNORM: 00921 b8g8r8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); 00922 break; 00923 case PIPE_FORMAT_A1R5G5B5_UNORM: 00924 a1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); 00925 break; 00926 case PIPE_FORMAT_A4R4G4B4_UNORM: 00927 a4r4g4b4_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); 00928 break; 00929 case PIPE_FORMAT_R5G6B5_UNORM: 00930 r5g6b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); 00931 break; 00932 case PIPE_FORMAT_L8_UNORM: 00933 l8_get_tile_rgba((ubyte *) src, w, h, dst, dst_stride); 00934 break; 00935 case PIPE_FORMAT_A8_UNORM: 00936 a8_get_tile_rgba((ubyte *) src, w, h, dst, dst_stride); 00937 break; 00938 case PIPE_FORMAT_I8_UNORM: 00939 i8_get_tile_rgba((ubyte *) src, w, h, dst, dst_stride); 00940 break; 00941 case PIPE_FORMAT_A8L8_UNORM: 00942 a8l8_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); 00943 break; 00944 case PIPE_FORMAT_R16_SNORM: 00945 r16_get_tile_rgba((short *) src, w, h, dst, dst_stride); 00946 break; 00947 case PIPE_FORMAT_R16G16B16A16_SNORM: 00948 r16g16b16a16_get_tile_rgba((short *) src, w, h, dst, dst_stride); 00949 break; 00950 case PIPE_FORMAT_Z16_UNORM: 00951 z16_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); 00952 break; 00953 case PIPE_FORMAT_Z32_UNORM: 00954 z32_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); 00955 break; 00956 case PIPE_FORMAT_S8Z24_UNORM: 00957 case PIPE_FORMAT_X8Z24_UNORM: 00958 s8z24_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); 00959 break; 00960 case PIPE_FORMAT_Z24S8_UNORM: 00961 z24s8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); 00962 break; 00963 case PIPE_FORMAT_Z32_FLOAT: 00964 z32f_get_tile_rgba((float *) src, w, h, dst, dst_stride); 00965 break; 00966 case PIPE_FORMAT_YCBCR: 00967 ycbcr_get_tile_rgba((ushort *) src, w, h, dst, dst_stride, FALSE); 00968 break; 00969 case PIPE_FORMAT_YCBCR_REV: 00970 ycbcr_get_tile_rgba((ushort *) src, w, h, dst, dst_stride, TRUE); 00971 break; 00972 default: 00973 debug_printf("%s: unsupported format %s\n", __FUNCTION__, pf_name(format)); 00974 fake_get_tile_rgba(src, w, h, dst, dst_stride); 00975 } 00976 }