svga3d_surfacedefs.h 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. /**************************************************************************
  2. *
  3. * Copyright © 2008-2015 VMware, Inc., Palo Alto, CA., USA
  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 OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  21. * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
  22. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  23. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  24. * USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. **************************************************************************/
  27. #ifdef __KERNEL__
  28. #include <drm/vmwgfx_drm.h>
  29. #define surf_size_struct struct drm_vmw_size
  30. #else /* __KERNEL__ */
  31. #ifndef ARRAY_SIZE
  32. #define ARRAY_SIZE(_A) (sizeof(_A) / sizeof((_A)[0]))
  33. #endif /* ARRAY_SIZE */
  34. #define DIV_ROUND_UP(x, y) (((x) + (y) - 1) / (y))
  35. #define max_t(type, x, y) ((x) > (y) ? (x) : (y))
  36. #define surf_size_struct SVGA3dSize
  37. #define u32 uint32
  38. #endif /* __KERNEL__ */
  39. #include "svga3d_reg.h"
  40. /*
  41. * enum svga3d_block_desc describes the active data channels in a block.
  42. *
  43. * There can be at-most four active channels in a block:
  44. * 1. Red, bump W, luminance and depth are stored in the first channel.
  45. * 2. Green, bump V and stencil are stored in the second channel.
  46. * 3. Blue and bump U are stored in the third channel.
  47. * 4. Alpha and bump Q are stored in the fourth channel.
  48. *
  49. * Block channels can be used to store compressed and buffer data:
  50. * 1. For compressed formats, only the data channel is used and its size
  51. * is equal to that of a singular block in the compression scheme.
  52. * 2. For buffer formats, only the data channel is used and its size is
  53. * exactly one byte in length.
  54. * 3. In each case the bit depth represent the size of a singular block.
  55. *
  56. * Note: Compressed and IEEE formats do not use the bitMask structure.
  57. */
  58. enum svga3d_block_desc {
  59. SVGA3DBLOCKDESC_NONE = 0, /* No channels are active */
  60. SVGA3DBLOCKDESC_BLUE = 1 << 0, /* Block with red channel
  61. data */
  62. SVGA3DBLOCKDESC_U = 1 << 0, /* Block with bump U channel
  63. data */
  64. SVGA3DBLOCKDESC_UV_VIDEO = 1 << 7, /* Block with alternating video
  65. U and V */
  66. SVGA3DBLOCKDESC_GREEN = 1 << 1, /* Block with green channel
  67. data */
  68. SVGA3DBLOCKDESC_V = 1 << 1, /* Block with bump V channel
  69. data */
  70. SVGA3DBLOCKDESC_STENCIL = 1 << 1, /* Block with a stencil
  71. channel */
  72. SVGA3DBLOCKDESC_RED = 1 << 2, /* Block with blue channel
  73. data */
  74. SVGA3DBLOCKDESC_W = 1 << 2, /* Block with bump W channel
  75. data */
  76. SVGA3DBLOCKDESC_LUMINANCE = 1 << 2, /* Block with luminance channel
  77. data */
  78. SVGA3DBLOCKDESC_Y = 1 << 2, /* Block with video luminance
  79. data */
  80. SVGA3DBLOCKDESC_DEPTH = 1 << 2, /* Block with depth channel */
  81. SVGA3DBLOCKDESC_ALPHA = 1 << 3, /* Block with an alpha
  82. channel */
  83. SVGA3DBLOCKDESC_Q = 1 << 3, /* Block with bump Q channel
  84. data */
  85. SVGA3DBLOCKDESC_BUFFER = 1 << 4, /* Block stores 1 byte of
  86. data */
  87. SVGA3DBLOCKDESC_COMPRESSED = 1 << 5, /* Block stores n bytes of
  88. data depending on the
  89. compression method used */
  90. SVGA3DBLOCKDESC_IEEE_FP = 1 << 6, /* Block stores data in an IEEE
  91. floating point
  92. representation in
  93. all channels */
  94. SVGA3DBLOCKDESC_PLANAR_YUV = 1 << 8, /* Three separate blocks store
  95. data. */
  96. SVGA3DBLOCKDESC_U_VIDEO = 1 << 9, /* Block with U video data */
  97. SVGA3DBLOCKDESC_V_VIDEO = 1 << 10, /* Block with V video data */
  98. SVGA3DBLOCKDESC_EXP = 1 << 11, /* Shared exponent */
  99. SVGA3DBLOCKDESC_SRGB = 1 << 12, /* Data is in sRGB format */
  100. SVGA3DBLOCKDESC_2PLANAR_YUV = 1 << 13, /* 2 planes of Y, UV,
  101. e.g., NV12. */
  102. SVGA3DBLOCKDESC_3PLANAR_YUV = 1 << 14, /* 3 planes of separate
  103. Y, U, V, e.g., YV12. */
  104. SVGA3DBLOCKDESC_RG = SVGA3DBLOCKDESC_RED |
  105. SVGA3DBLOCKDESC_GREEN,
  106. SVGA3DBLOCKDESC_RGB = SVGA3DBLOCKDESC_RG |
  107. SVGA3DBLOCKDESC_BLUE,
  108. SVGA3DBLOCKDESC_RGB_SRGB = SVGA3DBLOCKDESC_RGB |
  109. SVGA3DBLOCKDESC_SRGB,
  110. SVGA3DBLOCKDESC_RGBA = SVGA3DBLOCKDESC_RGB |
  111. SVGA3DBLOCKDESC_ALPHA,
  112. SVGA3DBLOCKDESC_RGBA_SRGB = SVGA3DBLOCKDESC_RGBA |
  113. SVGA3DBLOCKDESC_SRGB,
  114. SVGA3DBLOCKDESC_UV = SVGA3DBLOCKDESC_U |
  115. SVGA3DBLOCKDESC_V,
  116. SVGA3DBLOCKDESC_UVL = SVGA3DBLOCKDESC_UV |
  117. SVGA3DBLOCKDESC_LUMINANCE,
  118. SVGA3DBLOCKDESC_UVW = SVGA3DBLOCKDESC_UV |
  119. SVGA3DBLOCKDESC_W,
  120. SVGA3DBLOCKDESC_UVWA = SVGA3DBLOCKDESC_UVW |
  121. SVGA3DBLOCKDESC_ALPHA,
  122. SVGA3DBLOCKDESC_UVWQ = SVGA3DBLOCKDESC_U |
  123. SVGA3DBLOCKDESC_V |
  124. SVGA3DBLOCKDESC_W |
  125. SVGA3DBLOCKDESC_Q,
  126. SVGA3DBLOCKDESC_LA = SVGA3DBLOCKDESC_LUMINANCE |
  127. SVGA3DBLOCKDESC_ALPHA,
  128. SVGA3DBLOCKDESC_R_FP = SVGA3DBLOCKDESC_RED |
  129. SVGA3DBLOCKDESC_IEEE_FP,
  130. SVGA3DBLOCKDESC_RG_FP = SVGA3DBLOCKDESC_R_FP |
  131. SVGA3DBLOCKDESC_GREEN,
  132. SVGA3DBLOCKDESC_RGB_FP = SVGA3DBLOCKDESC_RG_FP |
  133. SVGA3DBLOCKDESC_BLUE,
  134. SVGA3DBLOCKDESC_RGBA_FP = SVGA3DBLOCKDESC_RGB_FP |
  135. SVGA3DBLOCKDESC_ALPHA,
  136. SVGA3DBLOCKDESC_DS = SVGA3DBLOCKDESC_DEPTH |
  137. SVGA3DBLOCKDESC_STENCIL,
  138. SVGA3DBLOCKDESC_YUV = SVGA3DBLOCKDESC_UV_VIDEO |
  139. SVGA3DBLOCKDESC_Y,
  140. SVGA3DBLOCKDESC_AYUV = SVGA3DBLOCKDESC_ALPHA |
  141. SVGA3DBLOCKDESC_Y |
  142. SVGA3DBLOCKDESC_U_VIDEO |
  143. SVGA3DBLOCKDESC_V_VIDEO,
  144. SVGA3DBLOCKDESC_RGBE = SVGA3DBLOCKDESC_RGB |
  145. SVGA3DBLOCKDESC_EXP,
  146. SVGA3DBLOCKDESC_COMPRESSED_SRGB = SVGA3DBLOCKDESC_COMPRESSED |
  147. SVGA3DBLOCKDESC_SRGB,
  148. SVGA3DBLOCKDESC_NV12 = SVGA3DBLOCKDESC_PLANAR_YUV |
  149. SVGA3DBLOCKDESC_2PLANAR_YUV,
  150. SVGA3DBLOCKDESC_YV12 = SVGA3DBLOCKDESC_PLANAR_YUV |
  151. SVGA3DBLOCKDESC_3PLANAR_YUV,
  152. };
  153. /*
  154. * SVGA3dSurfaceDesc describes the actual pixel data.
  155. *
  156. * This structure provides the following information:
  157. * 1. Block description.
  158. * 2. Dimensions of a block in the surface.
  159. * 3. Size of block in bytes.
  160. * 4. Bit depth of the pixel data.
  161. * 5. Channel bit depths and masks (if applicable).
  162. */
  163. struct svga3d_channel_def {
  164. union {
  165. u8 blue;
  166. u8 u;
  167. u8 uv_video;
  168. u8 u_video;
  169. };
  170. union {
  171. u8 green;
  172. u8 v;
  173. u8 stencil;
  174. u8 v_video;
  175. };
  176. union {
  177. u8 red;
  178. u8 w;
  179. u8 luminance;
  180. u8 y;
  181. u8 depth;
  182. u8 data;
  183. };
  184. union {
  185. u8 alpha;
  186. u8 q;
  187. u8 exp;
  188. };
  189. };
  190. struct svga3d_surface_desc {
  191. SVGA3dSurfaceFormat format;
  192. enum svga3d_block_desc block_desc;
  193. surf_size_struct block_size;
  194. u32 bytes_per_block;
  195. u32 pitch_bytes_per_block;
  196. u32 total_bit_depth;
  197. struct svga3d_channel_def bit_depth;
  198. struct svga3d_channel_def bit_offset;
  199. };
  200. static const struct svga3d_surface_desc svga3d_surface_descs[] = {
  201. {SVGA3D_FORMAT_INVALID, SVGA3DBLOCKDESC_NONE,
  202. {1, 1, 1}, 0, 0,
  203. 0, {{0}, {0}, {0}, {0}},
  204. {{0}, {0}, {0}, {0}}},
  205. {SVGA3D_X8R8G8B8, SVGA3DBLOCKDESC_RGB,
  206. {1, 1, 1}, 4, 4,
  207. 24, {{8}, {8}, {8}, {0}},
  208. {{0}, {8}, {16}, {24}}},
  209. {SVGA3D_A8R8G8B8, SVGA3DBLOCKDESC_RGBA,
  210. {1, 1, 1}, 4, 4,
  211. 32, {{8}, {8}, {8}, {8}},
  212. {{0}, {8}, {16}, {24}}},
  213. {SVGA3D_R5G6B5, SVGA3DBLOCKDESC_RGB,
  214. {1, 1, 1}, 2, 2,
  215. 16, {{5}, {6}, {5}, {0}},
  216. {{0}, {5}, {11}, {0}}},
  217. {SVGA3D_X1R5G5B5, SVGA3DBLOCKDESC_RGB,
  218. {1, 1, 1}, 2, 2,
  219. 15, {{5}, {5}, {5}, {0}},
  220. {{0}, {5}, {10}, {0}}},
  221. {SVGA3D_A1R5G5B5, SVGA3DBLOCKDESC_RGBA,
  222. {1, 1, 1}, 2, 2,
  223. 16, {{5}, {5}, {5}, {1}},
  224. {{0}, {5}, {10}, {15}}},
  225. {SVGA3D_A4R4G4B4, SVGA3DBLOCKDESC_RGBA,
  226. {1, 1, 1}, 2, 2,
  227. 16, {{4}, {4}, {4}, {4}},
  228. {{0}, {4}, {8}, {12}}},
  229. {SVGA3D_Z_D32, SVGA3DBLOCKDESC_DEPTH,
  230. {1, 1, 1}, 4, 4,
  231. 32, {{0}, {0}, {32}, {0}},
  232. {{0}, {0}, {0}, {0}}},
  233. {SVGA3D_Z_D16, SVGA3DBLOCKDESC_DEPTH,
  234. {1, 1, 1}, 2, 2,
  235. 16, {{0}, {0}, {16}, {0}},
  236. {{0}, {0}, {0}, {0}}},
  237. {SVGA3D_Z_D24S8, SVGA3DBLOCKDESC_DS,
  238. {1, 1, 1}, 4, 4,
  239. 32, {{0}, {8}, {24}, {0}},
  240. {{0}, {24}, {0}, {0}}},
  241. {SVGA3D_Z_D15S1, SVGA3DBLOCKDESC_DS,
  242. {1, 1, 1}, 2, 2,
  243. 16, {{0}, {1}, {15}, {0}},
  244. {{0}, {15}, {0}, {0}}},
  245. {SVGA3D_LUMINANCE8, SVGA3DBLOCKDESC_LUMINANCE,
  246. {1, 1, 1}, 1, 1,
  247. 8, {{0}, {0}, {8}, {0}},
  248. {{0}, {0}, {0}, {0}}},
  249. {SVGA3D_LUMINANCE4_ALPHA4, SVGA3DBLOCKDESC_LA,
  250. {1 , 1, 1}, 1, 1,
  251. 8, {{0}, {0}, {4}, {4}},
  252. {{0}, {0}, {0}, {4}}},
  253. {SVGA3D_LUMINANCE16, SVGA3DBLOCKDESC_LUMINANCE,
  254. {1, 1, 1}, 2, 2,
  255. 16, {{0}, {0}, {16}, {0}},
  256. {{0}, {0}, {0}, {0}}},
  257. {SVGA3D_LUMINANCE8_ALPHA8, SVGA3DBLOCKDESC_LA,
  258. {1, 1, 1}, 2, 2,
  259. 16, {{0}, {0}, {8}, {8}},
  260. {{0}, {0}, {0}, {8}}},
  261. {SVGA3D_DXT1, SVGA3DBLOCKDESC_COMPRESSED,
  262. {4, 4, 1}, 8, 8,
  263. 64, {{0}, {0}, {64}, {0}},
  264. {{0}, {0}, {0}, {0}}},
  265. {SVGA3D_DXT2, SVGA3DBLOCKDESC_COMPRESSED,
  266. {4, 4, 1}, 16, 16,
  267. 128, {{0}, {0}, {128}, {0}},
  268. {{0}, {0}, {0}, {0}}},
  269. {SVGA3D_DXT3, SVGA3DBLOCKDESC_COMPRESSED,
  270. {4, 4, 1}, 16, 16,
  271. 128, {{0}, {0}, {128}, {0}},
  272. {{0}, {0}, {0}, {0}}},
  273. {SVGA3D_DXT4, SVGA3DBLOCKDESC_COMPRESSED,
  274. {4, 4, 1}, 16, 16,
  275. 128, {{0}, {0}, {128}, {0}},
  276. {{0}, {0}, {0}, {0}}},
  277. {SVGA3D_DXT5, SVGA3DBLOCKDESC_COMPRESSED,
  278. {4, 4, 1}, 16, 16,
  279. 128, {{0}, {0}, {128}, {0}},
  280. {{0}, {0}, {0}, {0}}},
  281. {SVGA3D_BUMPU8V8, SVGA3DBLOCKDESC_UV,
  282. {1, 1, 1}, 2, 2,
  283. 16, {{0}, {0}, {8}, {8}},
  284. {{0}, {0}, {0}, {8}}},
  285. {SVGA3D_BUMPL6V5U5, SVGA3DBLOCKDESC_UVL,
  286. {1, 1, 1}, 2, 2,
  287. 16, {{5}, {5}, {6}, {0}},
  288. {{11}, {6}, {0}, {0}}},
  289. {SVGA3D_BUMPX8L8V8U8, SVGA3DBLOCKDESC_UVL,
  290. {1, 1, 1}, 4, 4,
  291. 32, {{8}, {8}, {8}, {0}},
  292. {{16}, {8}, {0}, {0}}},
  293. {SVGA3D_BUMPL8V8U8, SVGA3DBLOCKDESC_UVL,
  294. {1, 1, 1}, 3, 3,
  295. 24, {{8}, {8}, {8}, {0}},
  296. {{16}, {8}, {0}, {0}}},
  297. {SVGA3D_ARGB_S10E5, SVGA3DBLOCKDESC_RGBA_FP,
  298. {1, 1, 1}, 8, 8,
  299. 64, {{16}, {16}, {16}, {16}},
  300. {{32}, {16}, {0}, {48}}},
  301. {SVGA3D_ARGB_S23E8, SVGA3DBLOCKDESC_RGBA_FP,
  302. {1, 1, 1}, 16, 16,
  303. 128, {{32}, {32}, {32}, {32}},
  304. {{64}, {32}, {0}, {96}}},
  305. {SVGA3D_A2R10G10B10, SVGA3DBLOCKDESC_RGBA,
  306. {1, 1, 1}, 4, 4,
  307. 32, {{10}, {10}, {10}, {2}},
  308. {{0}, {10}, {20}, {30}}},
  309. {SVGA3D_V8U8, SVGA3DBLOCKDESC_UV,
  310. {1, 1, 1}, 2, 2,
  311. 16, {{8}, {8}, {0}, {0}},
  312. {{8}, {0}, {0}, {0}}},
  313. {SVGA3D_Q8W8V8U8, SVGA3DBLOCKDESC_UVWQ,
  314. {1, 1, 1}, 4, 4,
  315. 32, {{8}, {8}, {8}, {8}},
  316. {{24}, {16}, {8}, {0}}},
  317. {SVGA3D_CxV8U8, SVGA3DBLOCKDESC_UV,
  318. {1, 1, 1}, 2, 2,
  319. 16, {{8}, {8}, {0}, {0}},
  320. {{8}, {0}, {0}, {0}}},
  321. {SVGA3D_X8L8V8U8, SVGA3DBLOCKDESC_UVL,
  322. {1, 1, 1}, 4, 4,
  323. 24, {{8}, {8}, {8}, {0}},
  324. {{16}, {8}, {0}, {0}}},
  325. {SVGA3D_A2W10V10U10, SVGA3DBLOCKDESC_UVWA,
  326. {1, 1, 1}, 4, 4,
  327. 32, {{10}, {10}, {10}, {2}},
  328. {{0}, {10}, {20}, {30}}},
  329. {SVGA3D_ALPHA8, SVGA3DBLOCKDESC_ALPHA,
  330. {1, 1, 1}, 1, 1,
  331. 8, {{0}, {0}, {0}, {8}},
  332. {{0}, {0}, {0}, {0}}},
  333. {SVGA3D_R_S10E5, SVGA3DBLOCKDESC_R_FP,
  334. {1, 1, 1}, 2, 2,
  335. 16, {{0}, {0}, {16}, {0}},
  336. {{0}, {0}, {0}, {0}}},
  337. {SVGA3D_R_S23E8, SVGA3DBLOCKDESC_R_FP,
  338. {1, 1, 1}, 4, 4,
  339. 32, {{0}, {0}, {32}, {0}},
  340. {{0}, {0}, {0}, {0}}},
  341. {SVGA3D_RG_S10E5, SVGA3DBLOCKDESC_RG_FP,
  342. {1, 1, 1}, 4, 4,
  343. 32, {{0}, {16}, {16}, {0}},
  344. {{0}, {16}, {0}, {0}}},
  345. {SVGA3D_RG_S23E8, SVGA3DBLOCKDESC_RG_FP,
  346. {1, 1, 1}, 8, 8,
  347. 64, {{0}, {32}, {32}, {0}},
  348. {{0}, {32}, {0}, {0}}},
  349. {SVGA3D_BUFFER, SVGA3DBLOCKDESC_BUFFER,
  350. {1, 1, 1}, 1, 1,
  351. 8, {{0}, {0}, {8}, {0}},
  352. {{0}, {0}, {0}, {0}}},
  353. {SVGA3D_Z_D24X8, SVGA3DBLOCKDESC_DEPTH,
  354. {1, 1, 1}, 4, 4,
  355. 32, {{0}, {0}, {24}, {0}},
  356. {{0}, {24}, {0}, {0}}},
  357. {SVGA3D_V16U16, SVGA3DBLOCKDESC_UV,
  358. {1, 1, 1}, 4, 4,
  359. 32, {{16}, {16}, {0}, {0}},
  360. {{16}, {0}, {0}, {0}}},
  361. {SVGA3D_G16R16, SVGA3DBLOCKDESC_RG,
  362. {1, 1, 1}, 4, 4,
  363. 32, {{0}, {16}, {16}, {0}},
  364. {{0}, {0}, {16}, {0}}},
  365. {SVGA3D_A16B16G16R16, SVGA3DBLOCKDESC_RGBA,
  366. {1, 1, 1}, 8, 8,
  367. 64, {{16}, {16}, {16}, {16}},
  368. {{32}, {16}, {0}, {48}}},
  369. {SVGA3D_UYVY, SVGA3DBLOCKDESC_YUV,
  370. {1, 1, 1}, 2, 2,
  371. 16, {{8}, {0}, {8}, {0}},
  372. {{0}, {0}, {8}, {0}}},
  373. {SVGA3D_YUY2, SVGA3DBLOCKDESC_YUV,
  374. {1, 1, 1}, 2, 2,
  375. 16, {{8}, {0}, {8}, {0}},
  376. {{8}, {0}, {0}, {0}}},
  377. {SVGA3D_NV12, SVGA3DBLOCKDESC_NV12,
  378. {2, 2, 1}, 6, 2,
  379. 48, {{0}, {0}, {48}, {0}},
  380. {{0}, {0}, {0}, {0}}},
  381. {SVGA3D_AYUV, SVGA3DBLOCKDESC_AYUV,
  382. {1, 1, 1}, 4, 4,
  383. 32, {{8}, {8}, {8}, {8}},
  384. {{0}, {8}, {16}, {24}}},
  385. {SVGA3D_R32G32B32A32_TYPELESS, SVGA3DBLOCKDESC_RGBA,
  386. {1, 1, 1}, 16, 16,
  387. 128, {{32}, {32}, {32}, {32}},
  388. {{64}, {32}, {0}, {96}}},
  389. {SVGA3D_R32G32B32A32_UINT, SVGA3DBLOCKDESC_RGBA,
  390. {1, 1, 1}, 16, 16,
  391. 128, {{32}, {32}, {32}, {32}},
  392. {{64}, {32}, {0}, {96}}},
  393. {SVGA3D_R32G32B32A32_SINT, SVGA3DBLOCKDESC_UVWQ,
  394. {1, 1, 1}, 16, 16,
  395. 128, {{32}, {32}, {32}, {32}},
  396. {{64}, {32}, {0}, {96}}},
  397. {SVGA3D_R32G32B32_TYPELESS, SVGA3DBLOCKDESC_RGB,
  398. {1, 1, 1}, 12, 12,
  399. 96, {{32}, {32}, {32}, {0}},
  400. {{64}, {32}, {0}, {0}}},
  401. {SVGA3D_R32G32B32_FLOAT, SVGA3DBLOCKDESC_RGB_FP,
  402. {1, 1, 1}, 12, 12,
  403. 96, {{32}, {32}, {32}, {0}},
  404. {{64}, {32}, {0}, {0}}},
  405. {SVGA3D_R32G32B32_UINT, SVGA3DBLOCKDESC_RGB,
  406. {1, 1, 1}, 12, 12,
  407. 96, {{32}, {32}, {32}, {0}},
  408. {{64}, {32}, {0}, {0}}},
  409. {SVGA3D_R32G32B32_SINT, SVGA3DBLOCKDESC_UVW,
  410. {1, 1, 1}, 12, 12,
  411. 96, {{32}, {32}, {32}, {0}},
  412. {{64}, {32}, {0}, {0}}},
  413. {SVGA3D_R16G16B16A16_TYPELESS, SVGA3DBLOCKDESC_RGBA,
  414. {1, 1, 1}, 8, 8,
  415. 64, {{16}, {16}, {16}, {16}},
  416. {{32}, {16}, {0}, {48}}},
  417. {SVGA3D_R16G16B16A16_UINT, SVGA3DBLOCKDESC_RGBA,
  418. {1, 1, 1}, 8, 8,
  419. 64, {{16}, {16}, {16}, {16}},
  420. {{32}, {16}, {0}, {48}}},
  421. {SVGA3D_R16G16B16A16_SNORM, SVGA3DBLOCKDESC_UVWQ,
  422. {1, 1, 1}, 8, 8,
  423. 64, {{16}, {16}, {16}, {16}},
  424. {{32}, {16}, {0}, {48}}},
  425. {SVGA3D_R16G16B16A16_SINT, SVGA3DBLOCKDESC_UVWQ,
  426. {1, 1, 1}, 8, 8,
  427. 64, {{16}, {16}, {16}, {16}},
  428. {{32}, {16}, {0}, {48}}},
  429. {SVGA3D_R32G32_TYPELESS, SVGA3DBLOCKDESC_RG,
  430. {1, 1, 1}, 8, 8,
  431. 64, {{0}, {32}, {32}, {0}},
  432. {{0}, {32}, {0}, {0}}},
  433. {SVGA3D_R32G32_UINT, SVGA3DBLOCKDESC_RG,
  434. {1, 1, 1}, 8, 8,
  435. 64, {{0}, {32}, {32}, {0}},
  436. {{0}, {32}, {0}, {0}}},
  437. {SVGA3D_R32G32_SINT, SVGA3DBLOCKDESC_UV,
  438. {1, 1, 1}, 8, 8,
  439. 64, {{0}, {32}, {32}, {0}},
  440. {{0}, {32}, {0}, {0}}},
  441. {SVGA3D_R32G8X24_TYPELESS, SVGA3DBLOCKDESC_RG,
  442. {1, 1, 1}, 8, 8,
  443. 64, {{0}, {8}, {32}, {0}},
  444. {{0}, {32}, {0}, {0}}},
  445. {SVGA3D_D32_FLOAT_S8X24_UINT, SVGA3DBLOCKDESC_DS,
  446. {1, 1, 1}, 8, 8,
  447. 64, {{0}, {8}, {32}, {0}},
  448. {{0}, {32}, {0}, {0}}},
  449. {SVGA3D_R32_FLOAT_X8X24_TYPELESS, SVGA3DBLOCKDESC_R_FP,
  450. {1, 1, 1}, 8, 8,
  451. 64, {{0}, {0}, {32}, {0}},
  452. {{0}, {0}, {0}, {0}}},
  453. {SVGA3D_X32_TYPELESS_G8X24_UINT, SVGA3DBLOCKDESC_GREEN,
  454. {1, 1, 1}, 8, 8,
  455. 64, {{0}, {8}, {0}, {0}},
  456. {{0}, {32}, {0}, {0}}},
  457. {SVGA3D_R10G10B10A2_TYPELESS, SVGA3DBLOCKDESC_RGBA,
  458. {1, 1, 1}, 4, 4,
  459. 32, {{10}, {10}, {10}, {2}},
  460. {{0}, {10}, {20}, {30}}},
  461. {SVGA3D_R10G10B10A2_UINT, SVGA3DBLOCKDESC_RGBA,
  462. {1, 1, 1}, 4, 4,
  463. 32, {{10}, {10}, {10}, {2}},
  464. {{0}, {10}, {20}, {30}}},
  465. {SVGA3D_R11G11B10_FLOAT, SVGA3DBLOCKDESC_RGB_FP,
  466. {1, 1, 1}, 4, 4,
  467. 32, {{10}, {11}, {11}, {0}},
  468. {{0}, {10}, {21}, {0}}},
  469. {SVGA3D_R8G8B8A8_TYPELESS, SVGA3DBLOCKDESC_RGBA,
  470. {1, 1, 1}, 4, 4,
  471. 32, {{8}, {8}, {8}, {8}},
  472. {{16}, {8}, {0}, {24}}},
  473. {SVGA3D_R8G8B8A8_UNORM, SVGA3DBLOCKDESC_RGBA,
  474. {1, 1, 1}, 4, 4,
  475. 32, {{8}, {8}, {8}, {8}},
  476. {{16}, {8}, {0}, {24}}},
  477. {SVGA3D_R8G8B8A8_UNORM_SRGB, SVGA3DBLOCKDESC_RGBA_SRGB,
  478. {1, 1, 1}, 4, 4,
  479. 32, {{8}, {8}, {8}, {8}},
  480. {{16}, {8}, {0}, {24}}},
  481. {SVGA3D_R8G8B8A8_UINT, SVGA3DBLOCKDESC_RGBA,
  482. {1, 1, 1}, 4, 4,
  483. 32, {{8}, {8}, {8}, {8}},
  484. {{16}, {8}, {0}, {24}}},
  485. {SVGA3D_R8G8B8A8_SINT, SVGA3DBLOCKDESC_RGBA,
  486. {1, 1, 1}, 4, 4,
  487. 32, {{8}, {8}, {8}, {8}},
  488. {{16}, {8}, {0}, {24}}},
  489. {SVGA3D_R16G16_TYPELESS, SVGA3DBLOCKDESC_RG,
  490. {1, 1, 1}, 4, 4,
  491. 32, {{0}, {16}, {16}, {0}},
  492. {{0}, {16}, {0}, {0}}},
  493. {SVGA3D_R16G16_UINT, SVGA3DBLOCKDESC_RG_FP,
  494. {1, 1, 1}, 4, 4,
  495. 32, {{0}, {16}, {16}, {0}},
  496. {{0}, {16}, {0}, {0}}},
  497. {SVGA3D_R16G16_SINT, SVGA3DBLOCKDESC_UV,
  498. {1, 1, 1}, 4, 4,
  499. 32, {{0}, {16}, {16}, {0}},
  500. {{0}, {16}, {0}, {0}}},
  501. {SVGA3D_R32_TYPELESS, SVGA3DBLOCKDESC_RED,
  502. {1, 1, 1}, 4, 4,
  503. 32, {{0}, {0}, {32}, {0}},
  504. {{0}, {0}, {0}, {0}}},
  505. {SVGA3D_D32_FLOAT, SVGA3DBLOCKDESC_DEPTH,
  506. {1, 1, 1}, 4, 4,
  507. 32, {{0}, {0}, {32}, {0}},
  508. {{0}, {0}, {0}, {0}}},
  509. {SVGA3D_R32_UINT, SVGA3DBLOCKDESC_RED,
  510. {1, 1, 1}, 4, 4,
  511. 32, {{0}, {0}, {32}, {0}},
  512. {{0}, {0}, {0}, {0}}},
  513. {SVGA3D_R32_SINT, SVGA3DBLOCKDESC_RED,
  514. {1, 1, 1}, 4, 4,
  515. 32, {{0}, {0}, {32}, {0}},
  516. {{0}, {0}, {0}, {0}}},
  517. {SVGA3D_R24G8_TYPELESS, SVGA3DBLOCKDESC_RG,
  518. {1, 1, 1}, 4, 4,
  519. 32, {{0}, {8}, {24}, {0}},
  520. {{0}, {24}, {0}, {0}}},
  521. {SVGA3D_D24_UNORM_S8_UINT, SVGA3DBLOCKDESC_DS,
  522. {1, 1, 1}, 4, 4,
  523. 32, {{0}, {8}, {24}, {0}},
  524. {{0}, {24}, {0}, {0}}},
  525. {SVGA3D_R24_UNORM_X8_TYPELESS, SVGA3DBLOCKDESC_RED,
  526. {1, 1, 1}, 4, 4,
  527. 32, {{0}, {0}, {24}, {0}},
  528. {{0}, {0}, {0}, {0}}},
  529. {SVGA3D_X24_TYPELESS_G8_UINT, SVGA3DBLOCKDESC_GREEN,
  530. {1, 1, 1}, 4, 4,
  531. 32, {{0}, {8}, {0}, {0}},
  532. {{0}, {24}, {0}, {0}}},
  533. {SVGA3D_R8G8_TYPELESS, SVGA3DBLOCKDESC_RG,
  534. {1, 1, 1}, 2, 2,
  535. 16, {{0}, {8}, {8}, {0}},
  536. {{0}, {8}, {0}, {0}}},
  537. {SVGA3D_R8G8_UNORM, SVGA3DBLOCKDESC_RG,
  538. {1, 1, 1}, 2, 2,
  539. 16, {{0}, {8}, {8}, {0}},
  540. {{0}, {8}, {0}, {0}}},
  541. {SVGA3D_R8G8_UINT, SVGA3DBLOCKDESC_RG,
  542. {1, 1, 1}, 2, 2,
  543. 16, {{0}, {8}, {8}, {0}},
  544. {{0}, {8}, {0}, {0}}},
  545. {SVGA3D_R8G8_SINT, SVGA3DBLOCKDESC_UV,
  546. {1, 1, 1}, 2, 2,
  547. 16, {{0}, {8}, {8}, {0}},
  548. {{0}, {8}, {0}, {0}}},
  549. {SVGA3D_R16_TYPELESS, SVGA3DBLOCKDESC_RED,
  550. {1, 1, 1}, 2, 2,
  551. 16, {{0}, {0}, {16}, {0}},
  552. {{0}, {0}, {0}, {0}}},
  553. {SVGA3D_R16_UNORM, SVGA3DBLOCKDESC_RED,
  554. {1, 1, 1}, 2, 2,
  555. 16, {{0}, {0}, {16}, {0}},
  556. {{0}, {0}, {0}, {0}}},
  557. {SVGA3D_R16_UINT, SVGA3DBLOCKDESC_RED,
  558. {1, 1, 1}, 2, 2,
  559. 16, {{0}, {0}, {16}, {0}},
  560. {{0}, {0}, {0}, {0}}},
  561. {SVGA3D_R16_SNORM, SVGA3DBLOCKDESC_U,
  562. {1, 1, 1}, 2, 2,
  563. 16, {{0}, {0}, {16}, {0}},
  564. {{0}, {0}, {0}, {0}}},
  565. {SVGA3D_R16_SINT, SVGA3DBLOCKDESC_U,
  566. {1, 1, 1}, 2, 2,
  567. 16, {{0}, {0}, {16}, {0}},
  568. {{0}, {0}, {0}, {0}}},
  569. {SVGA3D_R8_TYPELESS, SVGA3DBLOCKDESC_RED,
  570. {1, 1, 1}, 1, 1,
  571. 8, {{0}, {0}, {8}, {0}},
  572. {{0}, {0}, {0}, {0}}},
  573. {SVGA3D_R8_UNORM, SVGA3DBLOCKDESC_RED,
  574. {1, 1, 1}, 1, 1,
  575. 8, {{0}, {0}, {8}, {0}},
  576. {{0}, {0}, {0}, {0}}},
  577. {SVGA3D_R8_UINT, SVGA3DBLOCKDESC_RED,
  578. {1, 1, 1}, 1, 1,
  579. 8, {{0}, {0}, {8}, {0}},
  580. {{0}, {0}, {0}, {0}}},
  581. {SVGA3D_R8_SNORM, SVGA3DBLOCKDESC_U,
  582. {1, 1, 1}, 1, 1,
  583. 8, {{0}, {0}, {8}, {0}},
  584. {{0}, {0}, {0}, {0}}},
  585. {SVGA3D_R8_SINT, SVGA3DBLOCKDESC_U,
  586. {1, 1, 1}, 1, 1,
  587. 8, {{0}, {0}, {8}, {0}},
  588. {{0}, {0}, {0}, {0}}},
  589. {SVGA3D_P8, SVGA3DBLOCKDESC_RED,
  590. {1, 1, 1}, 1, 1,
  591. 8, {{0}, {0}, {8}, {0}},
  592. {{0}, {0}, {0}, {0}}},
  593. {SVGA3D_R9G9B9E5_SHAREDEXP, SVGA3DBLOCKDESC_RGBE,
  594. {1, 1, 1}, 4, 4,
  595. 32, {{9}, {9}, {9}, {5}},
  596. {{18}, {9}, {0}, {27}}},
  597. {SVGA3D_R8G8_B8G8_UNORM, SVGA3DBLOCKDESC_RG,
  598. {1, 1, 1}, 2, 2,
  599. 16, {{0}, {8}, {8}, {0}},
  600. {{0}, {8}, {0}, {0}}},
  601. {SVGA3D_G8R8_G8B8_UNORM, SVGA3DBLOCKDESC_RG,
  602. {1, 1, 1}, 2, 2,
  603. 16, {{0}, {8}, {8}, {0}},
  604. {{0}, {8}, {0}, {0}}},
  605. {SVGA3D_BC1_TYPELESS, SVGA3DBLOCKDESC_COMPRESSED,
  606. {4, 4, 1}, 8, 8,
  607. 64, {{0}, {0}, {64}, {0}},
  608. {{0}, {0}, {0}, {0}}},
  609. {SVGA3D_BC1_UNORM_SRGB, SVGA3DBLOCKDESC_COMPRESSED_SRGB,
  610. {4, 4, 1}, 8, 8,
  611. 64, {{0}, {0}, {64}, {0}},
  612. {{0}, {0}, {0}, {0}}},
  613. {SVGA3D_BC2_TYPELESS, SVGA3DBLOCKDESC_COMPRESSED,
  614. {4, 4, 1}, 16, 16,
  615. 128, {{0}, {0}, {128}, {0}},
  616. {{0}, {0}, {0}, {0}}},
  617. {SVGA3D_BC2_UNORM_SRGB, SVGA3DBLOCKDESC_COMPRESSED_SRGB,
  618. {4, 4, 1}, 16, 16,
  619. 128, {{0}, {0}, {128}, {0}},
  620. {{0}, {0}, {0}, {0}}},
  621. {SVGA3D_BC3_TYPELESS, SVGA3DBLOCKDESC_COMPRESSED,
  622. {4, 4, 1}, 16, 16,
  623. 128, {{0}, {0}, {128}, {0}},
  624. {{0}, {0}, {0}, {0}}},
  625. {SVGA3D_BC3_UNORM_SRGB, SVGA3DBLOCKDESC_COMPRESSED_SRGB,
  626. {4, 4, 1}, 16, 16,
  627. 128, {{0}, {0}, {128}, {0}},
  628. {{0}, {0}, {0}, {0}}},
  629. {SVGA3D_BC4_TYPELESS, SVGA3DBLOCKDESC_COMPRESSED,
  630. {4, 4, 1}, 8, 8,
  631. 64, {{0}, {0}, {64}, {0}},
  632. {{0}, {0}, {0}, {0}}},
  633. {SVGA3D_ATI1, SVGA3DBLOCKDESC_COMPRESSED,
  634. {4, 4, 1}, 8, 8,
  635. 64, {{0}, {0}, {64}, {0}},
  636. {{0}, {0}, {0}, {0}}},
  637. {SVGA3D_BC4_SNORM, SVGA3DBLOCKDESC_COMPRESSED,
  638. {4, 4, 1}, 8, 8,
  639. 64, {{0}, {0}, {64}, {0}},
  640. {{0}, {0}, {0}, {0}}},
  641. {SVGA3D_BC5_TYPELESS, SVGA3DBLOCKDESC_COMPRESSED,
  642. {4, 4, 1}, 16, 16,
  643. 128, {{0}, {0}, {128}, {0}},
  644. {{0}, {0}, {0}, {0}}},
  645. {SVGA3D_ATI2, SVGA3DBLOCKDESC_COMPRESSED,
  646. {4, 4, 1}, 16, 16,
  647. 128, {{0}, {0}, {128}, {0}},
  648. {{0}, {0}, {0}, {0}}},
  649. {SVGA3D_BC5_SNORM, SVGA3DBLOCKDESC_COMPRESSED,
  650. {4, 4, 1}, 16, 16,
  651. 128, {{0}, {0}, {128}, {0}},
  652. {{0}, {0}, {0}, {0}}},
  653. {SVGA3D_R10G10B10_XR_BIAS_A2_UNORM, SVGA3DBLOCKDESC_RGBA,
  654. {1, 1, 1}, 4, 4,
  655. 32, {{10}, {10}, {10}, {2}},
  656. {{0}, {10}, {20}, {30}}},
  657. {SVGA3D_B8G8R8A8_TYPELESS, SVGA3DBLOCKDESC_RGBA,
  658. {1, 1, 1}, 4, 4,
  659. 32, {{8}, {8}, {8}, {8}},
  660. {{0}, {8}, {16}, {24}}},
  661. {SVGA3D_B8G8R8A8_UNORM_SRGB, SVGA3DBLOCKDESC_RGBA_SRGB,
  662. {1, 1, 1}, 4, 4,
  663. 32, {{8}, {8}, {8}, {8}},
  664. {{0}, {8}, {16}, {24}}},
  665. {SVGA3D_B8G8R8X8_TYPELESS, SVGA3DBLOCKDESC_RGB,
  666. {1, 1, 1}, 4, 4,
  667. 24, {{8}, {8}, {8}, {0}},
  668. {{0}, {8}, {16}, {24}}},
  669. {SVGA3D_B8G8R8X8_UNORM_SRGB, SVGA3DBLOCKDESC_RGB_SRGB,
  670. {1, 1, 1}, 4, 4,
  671. 24, {{8}, {8}, {8}, {0}},
  672. {{0}, {8}, {16}, {24}}},
  673. {SVGA3D_Z_DF16, SVGA3DBLOCKDESC_DEPTH,
  674. {1, 1, 1}, 2, 2,
  675. 16, {{0}, {0}, {16}, {0}},
  676. {{0}, {0}, {0}, {0}}},
  677. {SVGA3D_Z_DF24, SVGA3DBLOCKDESC_DEPTH,
  678. {1, 1, 1}, 4, 4,
  679. 32, {{0}, {8}, {24}, {0}},
  680. {{0}, {24}, {0}, {0}}},
  681. {SVGA3D_Z_D24S8_INT, SVGA3DBLOCKDESC_DS,
  682. {1, 1, 1}, 4, 4,
  683. 32, {{0}, {8}, {24}, {0}},
  684. {{0}, {24}, {0}, {0}}},
  685. {SVGA3D_YV12, SVGA3DBLOCKDESC_YV12,
  686. {2, 2, 1}, 6, 2,
  687. 48, {{0}, {0}, {48}, {0}},
  688. {{0}, {0}, {0}, {0}}},
  689. {SVGA3D_R32G32B32A32_FLOAT, SVGA3DBLOCKDESC_RGBA_FP,
  690. {1, 1, 1}, 16, 16,
  691. 128, {{32}, {32}, {32}, {32}},
  692. {{64}, {32}, {0}, {96}}},
  693. {SVGA3D_R16G16B16A16_FLOAT, SVGA3DBLOCKDESC_RGBA_FP,
  694. {1, 1, 1}, 8, 8,
  695. 64, {{16}, {16}, {16}, {16}},
  696. {{32}, {16}, {0}, {48}}},
  697. {SVGA3D_R16G16B16A16_UNORM, SVGA3DBLOCKDESC_RGBA,
  698. {1, 1, 1}, 8, 8,
  699. 64, {{16}, {16}, {16}, {16}},
  700. {{32}, {16}, {0}, {48}}},
  701. {SVGA3D_R32G32_FLOAT, SVGA3DBLOCKDESC_RG_FP,
  702. {1, 1, 1}, 8, 8,
  703. 64, {{0}, {32}, {32}, {0}},
  704. {{0}, {32}, {0}, {0}}},
  705. {SVGA3D_R10G10B10A2_UNORM, SVGA3DBLOCKDESC_RGBA,
  706. {1, 1, 1}, 4, 4,
  707. 32, {{10}, {10}, {10}, {2}},
  708. {{0}, {10}, {20}, {30}}},
  709. {SVGA3D_R8G8B8A8_SNORM, SVGA3DBLOCKDESC_RGBA,
  710. {1, 1, 1}, 4, 4,
  711. 32, {{8}, {8}, {8}, {8}},
  712. {{24}, {16}, {8}, {0}}},
  713. {SVGA3D_R16G16_FLOAT, SVGA3DBLOCKDESC_RG_FP,
  714. {1, 1, 1}, 4, 4,
  715. 32, {{0}, {16}, {16}, {0}},
  716. {{0}, {16}, {0}, {0}}},
  717. {SVGA3D_R16G16_UNORM, SVGA3DBLOCKDESC_RG,
  718. {1, 1, 1}, 4, 4,
  719. 32, {{0}, {16}, {16}, {0}},
  720. {{0}, {0}, {16}, {0}}},
  721. {SVGA3D_R16G16_SNORM, SVGA3DBLOCKDESC_RG,
  722. {1, 1, 1}, 4, 4,
  723. 32, {{16}, {16}, {0}, {0}},
  724. {{16}, {0}, {0}, {0}}},
  725. {SVGA3D_R32_FLOAT, SVGA3DBLOCKDESC_R_FP,
  726. {1, 1, 1}, 4, 4,
  727. 32, {{0}, {0}, {32}, {0}},
  728. {{0}, {0}, {0}, {0}}},
  729. {SVGA3D_R8G8_SNORM, SVGA3DBLOCKDESC_RG,
  730. {1, 1, 1}, 2, 2,
  731. 16, {{8}, {8}, {0}, {0}},
  732. {{8}, {0}, {0}, {0}}},
  733. {SVGA3D_R16_FLOAT, SVGA3DBLOCKDESC_R_FP,
  734. {1, 1, 1}, 2, 2,
  735. 16, {{0}, {0}, {16}, {0}},
  736. {{0}, {0}, {0}, {0}}},
  737. {SVGA3D_D16_UNORM, SVGA3DBLOCKDESC_DEPTH,
  738. {1, 1, 1}, 2, 2,
  739. 16, {{0}, {0}, {16}, {0}},
  740. {{0}, {0}, {0}, {0}}},
  741. {SVGA3D_A8_UNORM, SVGA3DBLOCKDESC_ALPHA,
  742. {1, 1, 1}, 1, 1,
  743. 8, {{0}, {0}, {0}, {8}},
  744. {{0}, {0}, {0}, {0}}},
  745. {SVGA3D_BC1_UNORM, SVGA3DBLOCKDESC_COMPRESSED,
  746. {4, 4, 1}, 8, 8,
  747. 64, {{0}, {0}, {64}, {0}},
  748. {{0}, {0}, {0}, {0}}},
  749. {SVGA3D_BC2_UNORM, SVGA3DBLOCKDESC_COMPRESSED,
  750. {4, 4, 1}, 16, 16,
  751. 128, {{0}, {0}, {128}, {0}},
  752. {{0}, {0}, {0}, {0}}},
  753. {SVGA3D_BC3_UNORM, SVGA3DBLOCKDESC_COMPRESSED,
  754. {4, 4, 1}, 16, 16,
  755. 128, {{0}, {0}, {128}, {0}},
  756. {{0}, {0}, {0}, {0}}},
  757. {SVGA3D_B5G6R5_UNORM, SVGA3DBLOCKDESC_RGB,
  758. {1, 1, 1}, 2, 2,
  759. 16, {{5}, {6}, {5}, {0}},
  760. {{0}, {5}, {11}, {0}}},
  761. {SVGA3D_B5G5R5A1_UNORM, SVGA3DBLOCKDESC_RGBA,
  762. {1, 1, 1}, 2, 2,
  763. 16, {{5}, {5}, {5}, {1}},
  764. {{0}, {5}, {10}, {15}}},
  765. {SVGA3D_B8G8R8A8_UNORM, SVGA3DBLOCKDESC_RGBA,
  766. {1, 1, 1}, 4, 4,
  767. 32, {{8}, {8}, {8}, {8}},
  768. {{0}, {8}, {16}, {24}}},
  769. {SVGA3D_B8G8R8X8_UNORM, SVGA3DBLOCKDESC_RGB,
  770. {1, 1, 1}, 4, 4,
  771. 24, {{8}, {8}, {8}, {0}},
  772. {{0}, {8}, {16}, {24}}},
  773. {SVGA3D_BC4_UNORM, SVGA3DBLOCKDESC_COMPRESSED,
  774. {4, 4, 1}, 8, 8,
  775. 64, {{0}, {0}, {64}, {0}},
  776. {{0}, {0}, {0}, {0}}},
  777. {SVGA3D_BC5_UNORM, SVGA3DBLOCKDESC_COMPRESSED,
  778. {4, 4, 1}, 16, 16,
  779. 128, {{0}, {0}, {128}, {0}},
  780. {{0}, {0}, {0}, {0}}},
  781. };
  782. static inline u32 clamped_umul32(u32 a, u32 b)
  783. {
  784. uint64_t tmp = (uint64_t) a*b;
  785. return (tmp > (uint64_t) ((u32) -1)) ? (u32) -1 : tmp;
  786. }
  787. static inline const struct svga3d_surface_desc *
  788. svga3dsurface_get_desc(SVGA3dSurfaceFormat format)
  789. {
  790. if (format < ARRAY_SIZE(svga3d_surface_descs))
  791. return &svga3d_surface_descs[format];
  792. return &svga3d_surface_descs[SVGA3D_FORMAT_INVALID];
  793. }
  794. /*
  795. *----------------------------------------------------------------------
  796. *
  797. * svga3dsurface_get_mip_size --
  798. *
  799. * Given a base level size and the mip level, compute the size of
  800. * the mip level.
  801. *
  802. * Results:
  803. * See above.
  804. *
  805. * Side effects:
  806. * None.
  807. *
  808. *----------------------------------------------------------------------
  809. */
  810. static inline surf_size_struct
  811. svga3dsurface_get_mip_size(surf_size_struct base_level, u32 mip_level)
  812. {
  813. surf_size_struct size;
  814. size.width = max_t(u32, base_level.width >> mip_level, 1);
  815. size.height = max_t(u32, base_level.height >> mip_level, 1);
  816. size.depth = max_t(u32, base_level.depth >> mip_level, 1);
  817. return size;
  818. }
  819. static inline void
  820. svga3dsurface_get_size_in_blocks(const struct svga3d_surface_desc *desc,
  821. const surf_size_struct *pixel_size,
  822. surf_size_struct *block_size)
  823. {
  824. block_size->width = DIV_ROUND_UP(pixel_size->width,
  825. desc->block_size.width);
  826. block_size->height = DIV_ROUND_UP(pixel_size->height,
  827. desc->block_size.height);
  828. block_size->depth = DIV_ROUND_UP(pixel_size->depth,
  829. desc->block_size.depth);
  830. }
  831. static inline bool
  832. svga3dsurface_is_planar_surface(const struct svga3d_surface_desc *desc)
  833. {
  834. return (desc->block_desc & SVGA3DBLOCKDESC_PLANAR_YUV) != 0;
  835. }
  836. static inline u32
  837. svga3dsurface_calculate_pitch(const struct svga3d_surface_desc *desc,
  838. const surf_size_struct *size)
  839. {
  840. u32 pitch;
  841. surf_size_struct blocks;
  842. svga3dsurface_get_size_in_blocks(desc, size, &blocks);
  843. pitch = blocks.width * desc->pitch_bytes_per_block;
  844. return pitch;
  845. }
  846. /*
  847. *-----------------------------------------------------------------------------
  848. *
  849. * svga3dsurface_get_image_buffer_size --
  850. *
  851. * Return the number of bytes of buffer space required to store
  852. * one image of a surface, optionally using the specified pitch.
  853. *
  854. * If pitch is zero, it is assumed that rows are tightly packed.
  855. *
  856. * This function is overflow-safe. If the result would have
  857. * overflowed, instead we return MAX_UINT32.
  858. *
  859. * Results:
  860. * Byte count.
  861. *
  862. * Side effects:
  863. * None.
  864. *
  865. *-----------------------------------------------------------------------------
  866. */
  867. static inline u32
  868. svga3dsurface_get_image_buffer_size(const struct svga3d_surface_desc *desc,
  869. const surf_size_struct *size,
  870. u32 pitch)
  871. {
  872. surf_size_struct image_blocks;
  873. u32 slice_size, total_size;
  874. svga3dsurface_get_size_in_blocks(desc, size, &image_blocks);
  875. if (svga3dsurface_is_planar_surface(desc)) {
  876. total_size = clamped_umul32(image_blocks.width,
  877. image_blocks.height);
  878. total_size = clamped_umul32(total_size, image_blocks.depth);
  879. total_size = clamped_umul32(total_size, desc->bytes_per_block);
  880. return total_size;
  881. }
  882. if (pitch == 0)
  883. pitch = svga3dsurface_calculate_pitch(desc, size);
  884. slice_size = clamped_umul32(image_blocks.height, pitch);
  885. total_size = clamped_umul32(slice_size, image_blocks.depth);
  886. return total_size;
  887. }
  888. static inline u32
  889. svga3dsurface_get_serialized_size(SVGA3dSurfaceFormat format,
  890. surf_size_struct base_level_size,
  891. u32 num_mip_levels,
  892. u32 num_layers)
  893. {
  894. const struct svga3d_surface_desc *desc = svga3dsurface_get_desc(format);
  895. u32 total_size = 0;
  896. u32 mip;
  897. for (mip = 0; mip < num_mip_levels; mip++) {
  898. surf_size_struct size =
  899. svga3dsurface_get_mip_size(base_level_size, mip);
  900. total_size += svga3dsurface_get_image_buffer_size(desc,
  901. &size, 0);
  902. }
  903. return total_size * num_layers;
  904. }
  905. /**
  906. * svga3dsurface_get_pixel_offset - Compute the offset (in bytes) to a pixel
  907. * in an image (or volume).
  908. *
  909. * @width: The image width in pixels.
  910. * @height: The image height in pixels
  911. */
  912. static inline u32
  913. svga3dsurface_get_pixel_offset(SVGA3dSurfaceFormat format,
  914. u32 width, u32 height,
  915. u32 x, u32 y, u32 z)
  916. {
  917. const struct svga3d_surface_desc *desc = svga3dsurface_get_desc(format);
  918. const u32 bw = desc->block_size.width, bh = desc->block_size.height;
  919. const u32 bd = desc->block_size.depth;
  920. const u32 rowstride = DIV_ROUND_UP(width, bw) * desc->bytes_per_block;
  921. const u32 imgstride = DIV_ROUND_UP(height, bh) * rowstride;
  922. const u32 offset = (z / bd * imgstride +
  923. y / bh * rowstride +
  924. x / bw * desc->bytes_per_block);
  925. return offset;
  926. }
  927. static inline u32
  928. svga3dsurface_get_image_offset(SVGA3dSurfaceFormat format,
  929. surf_size_struct baseLevelSize,
  930. u32 numMipLevels,
  931. u32 face,
  932. u32 mip)
  933. {
  934. u32 offset;
  935. u32 mipChainBytes;
  936. u32 mipChainBytesToLevel;
  937. u32 i;
  938. const struct svga3d_surface_desc *desc;
  939. surf_size_struct mipSize;
  940. u32 bytes;
  941. desc = svga3dsurface_get_desc(format);
  942. mipChainBytes = 0;
  943. mipChainBytesToLevel = 0;
  944. for (i = 0; i < numMipLevels; i++) {
  945. mipSize = svga3dsurface_get_mip_size(baseLevelSize, i);
  946. bytes = svga3dsurface_get_image_buffer_size(desc, &mipSize, 0);
  947. mipChainBytes += bytes;
  948. if (i < mip)
  949. mipChainBytesToLevel += bytes;
  950. }
  951. offset = mipChainBytes * face + mipChainBytesToLevel;
  952. return offset;
  953. }
  954. /**
  955. * svga3dsurface_is_gb_screen_target_format - Is the specified format usable as
  956. * a ScreenTarget?
  957. * (with just the GBObjects cap-bit
  958. * set)
  959. * @format: format to queried
  960. *
  961. * RETURNS:
  962. * true if queried format is valid for screen targets
  963. */
  964. static inline bool
  965. svga3dsurface_is_gb_screen_target_format(SVGA3dSurfaceFormat format)
  966. {
  967. return (format == SVGA3D_X8R8G8B8 ||
  968. format == SVGA3D_A8R8G8B8 ||
  969. format == SVGA3D_R5G6B5 ||
  970. format == SVGA3D_X1R5G5B5 ||
  971. format == SVGA3D_A1R5G5B5 ||
  972. format == SVGA3D_P8);
  973. }
  974. /**
  975. * svga3dsurface_is_dx_screen_target_format - Is the specified format usable as
  976. * a ScreenTarget?
  977. * (with DX10 enabled)
  978. *
  979. * @format: format to queried
  980. *
  981. * Results:
  982. * true if queried format is valid for screen targets
  983. */
  984. static inline bool
  985. svga3dsurface_is_dx_screen_target_format(SVGA3dSurfaceFormat format)
  986. {
  987. return (format == SVGA3D_R8G8B8A8_UNORM ||
  988. format == SVGA3D_B8G8R8A8_UNORM ||
  989. format == SVGA3D_B8G8R8X8_UNORM);
  990. }
  991. /**
  992. * svga3dsurface_is_screen_target_format - Is the specified format usable as a
  993. * ScreenTarget?
  994. * (for some combination of caps)
  995. *
  996. * @format: format to queried
  997. *
  998. * Results:
  999. * true if queried format is valid for screen targets
  1000. */
  1001. static inline bool
  1002. svga3dsurface_is_screen_target_format(SVGA3dSurfaceFormat format)
  1003. {
  1004. if (svga3dsurface_is_gb_screen_target_format(format)) {
  1005. return true;
  1006. }
  1007. return svga3dsurface_is_dx_screen_target_format(format);
  1008. }