svga3d_surfacedefs.h 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208
  1. /* SPDX-License-Identifier: GPL-2.0 OR MIT */
  2. /**************************************************************************
  3. *
  4. * Copyright 2008-2015 VMware, Inc., Palo Alto, CA., USA
  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. #include <linux/kernel.h>
  28. #ifdef __KERNEL__
  29. #include <drm/vmwgfx_drm.h>
  30. #define surf_size_struct struct drm_vmw_size
  31. #else /* __KERNEL__ */
  32. #ifndef ARRAY_SIZE
  33. #define ARRAY_SIZE(_A) (sizeof(_A) / sizeof((_A)[0]))
  34. #endif /* ARRAY_SIZE */
  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. size.pad64 = 0;
  818. return size;
  819. }
  820. static inline void
  821. svga3dsurface_get_size_in_blocks(const struct svga3d_surface_desc *desc,
  822. const surf_size_struct *pixel_size,
  823. surf_size_struct *block_size)
  824. {
  825. block_size->width = __KERNEL_DIV_ROUND_UP(pixel_size->width,
  826. desc->block_size.width);
  827. block_size->height = __KERNEL_DIV_ROUND_UP(pixel_size->height,
  828. desc->block_size.height);
  829. block_size->depth = __KERNEL_DIV_ROUND_UP(pixel_size->depth,
  830. desc->block_size.depth);
  831. }
  832. static inline bool
  833. svga3dsurface_is_planar_surface(const struct svga3d_surface_desc *desc)
  834. {
  835. return (desc->block_desc & SVGA3DBLOCKDESC_PLANAR_YUV) != 0;
  836. }
  837. static inline u32
  838. svga3dsurface_calculate_pitch(const struct svga3d_surface_desc *desc,
  839. const surf_size_struct *size)
  840. {
  841. u32 pitch;
  842. surf_size_struct blocks;
  843. svga3dsurface_get_size_in_blocks(desc, size, &blocks);
  844. pitch = blocks.width * desc->pitch_bytes_per_block;
  845. return pitch;
  846. }
  847. /*
  848. *-----------------------------------------------------------------------------
  849. *
  850. * svga3dsurface_get_image_buffer_size --
  851. *
  852. * Return the number of bytes of buffer space required to store
  853. * one image of a surface, optionally using the specified pitch.
  854. *
  855. * If pitch is zero, it is assumed that rows are tightly packed.
  856. *
  857. * This function is overflow-safe. If the result would have
  858. * overflowed, instead we return MAX_UINT32.
  859. *
  860. * Results:
  861. * Byte count.
  862. *
  863. * Side effects:
  864. * None.
  865. *
  866. *-----------------------------------------------------------------------------
  867. */
  868. static inline u32
  869. svga3dsurface_get_image_buffer_size(const struct svga3d_surface_desc *desc,
  870. const surf_size_struct *size,
  871. u32 pitch)
  872. {
  873. surf_size_struct image_blocks;
  874. u32 slice_size, total_size;
  875. svga3dsurface_get_size_in_blocks(desc, size, &image_blocks);
  876. if (svga3dsurface_is_planar_surface(desc)) {
  877. total_size = clamped_umul32(image_blocks.width,
  878. image_blocks.height);
  879. total_size = clamped_umul32(total_size, image_blocks.depth);
  880. total_size = clamped_umul32(total_size, desc->bytes_per_block);
  881. return total_size;
  882. }
  883. if (pitch == 0)
  884. pitch = svga3dsurface_calculate_pitch(desc, size);
  885. slice_size = clamped_umul32(image_blocks.height, pitch);
  886. total_size = clamped_umul32(slice_size, image_blocks.depth);
  887. return total_size;
  888. }
  889. static inline u32
  890. svga3dsurface_get_serialized_size(SVGA3dSurfaceFormat format,
  891. surf_size_struct base_level_size,
  892. u32 num_mip_levels,
  893. u32 num_layers)
  894. {
  895. const struct svga3d_surface_desc *desc = svga3dsurface_get_desc(format);
  896. u32 total_size = 0;
  897. u32 mip;
  898. for (mip = 0; mip < num_mip_levels; mip++) {
  899. surf_size_struct size =
  900. svga3dsurface_get_mip_size(base_level_size, mip);
  901. total_size += svga3dsurface_get_image_buffer_size(desc,
  902. &size, 0);
  903. }
  904. return total_size * num_layers;
  905. }
  906. /**
  907. * svga3dsurface_get_pixel_offset - Compute the offset (in bytes) to a pixel
  908. * in an image (or volume).
  909. *
  910. * @width: The image width in pixels.
  911. * @height: The image height in pixels
  912. */
  913. static inline u32
  914. svga3dsurface_get_pixel_offset(SVGA3dSurfaceFormat format,
  915. u32 width, u32 height,
  916. u32 x, u32 y, u32 z)
  917. {
  918. const struct svga3d_surface_desc *desc = svga3dsurface_get_desc(format);
  919. const u32 bw = desc->block_size.width, bh = desc->block_size.height;
  920. const u32 bd = desc->block_size.depth;
  921. const u32 rowstride = __KERNEL_DIV_ROUND_UP(width, bw) *
  922. desc->bytes_per_block;
  923. const u32 imgstride = __KERNEL_DIV_ROUND_UP(height, bh) * rowstride;
  924. const u32 offset = (z / bd * imgstride +
  925. y / bh * rowstride +
  926. x / bw * desc->bytes_per_block);
  927. return offset;
  928. }
  929. static inline u32
  930. svga3dsurface_get_image_offset(SVGA3dSurfaceFormat format,
  931. surf_size_struct baseLevelSize,
  932. u32 numMipLevels,
  933. u32 face,
  934. u32 mip)
  935. {
  936. u32 offset;
  937. u32 mipChainBytes;
  938. u32 mipChainBytesToLevel;
  939. u32 i;
  940. const struct svga3d_surface_desc *desc;
  941. surf_size_struct mipSize;
  942. u32 bytes;
  943. desc = svga3dsurface_get_desc(format);
  944. mipChainBytes = 0;
  945. mipChainBytesToLevel = 0;
  946. for (i = 0; i < numMipLevels; i++) {
  947. mipSize = svga3dsurface_get_mip_size(baseLevelSize, i);
  948. bytes = svga3dsurface_get_image_buffer_size(desc, &mipSize, 0);
  949. mipChainBytes += bytes;
  950. if (i < mip)
  951. mipChainBytesToLevel += bytes;
  952. }
  953. offset = mipChainBytes * face + mipChainBytesToLevel;
  954. return offset;
  955. }
  956. /**
  957. * svga3dsurface_is_gb_screen_target_format - Is the specified format usable as
  958. * a ScreenTarget?
  959. * (with just the GBObjects cap-bit
  960. * set)
  961. * @format: format to queried
  962. *
  963. * RETURNS:
  964. * true if queried format is valid for screen targets
  965. */
  966. static inline bool
  967. svga3dsurface_is_gb_screen_target_format(SVGA3dSurfaceFormat format)
  968. {
  969. return (format == SVGA3D_X8R8G8B8 ||
  970. format == SVGA3D_A8R8G8B8 ||
  971. format == SVGA3D_R5G6B5 ||
  972. format == SVGA3D_X1R5G5B5 ||
  973. format == SVGA3D_A1R5G5B5 ||
  974. format == SVGA3D_P8);
  975. }
  976. /**
  977. * svga3dsurface_is_dx_screen_target_format - Is the specified format usable as
  978. * a ScreenTarget?
  979. * (with DX10 enabled)
  980. *
  981. * @format: format to queried
  982. *
  983. * Results:
  984. * true if queried format is valid for screen targets
  985. */
  986. static inline bool
  987. svga3dsurface_is_dx_screen_target_format(SVGA3dSurfaceFormat format)
  988. {
  989. return (format == SVGA3D_R8G8B8A8_UNORM ||
  990. format == SVGA3D_B8G8R8A8_UNORM ||
  991. format == SVGA3D_B8G8R8X8_UNORM);
  992. }
  993. /**
  994. * svga3dsurface_is_screen_target_format - Is the specified format usable as a
  995. * ScreenTarget?
  996. * (for some combination of caps)
  997. *
  998. * @format: format to queried
  999. *
  1000. * Results:
  1001. * true if queried format is valid for screen targets
  1002. */
  1003. static inline bool
  1004. svga3dsurface_is_screen_target_format(SVGA3dSurfaceFormat format)
  1005. {
  1006. if (svga3dsurface_is_gb_screen_target_format(format)) {
  1007. return true;
  1008. }
  1009. return svga3dsurface_is_dx_screen_target_format(format);
  1010. }