1 /* 2 * Copyright 2014, 2015 Red Hat. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * on the rights to use, copy, modify, merge, publish, distribute, sub 8 * license, and/or sell copies of the Software, and to permit persons to whom 9 * the Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 21 * USE OR OTHER DEALINGS IN THE SOFTWARE. 22 */ 23 #ifndef VIRGL_HW_H 24 #define VIRGL_HW_H 25 26 #include <stdint.h> 27 28 struct virgl_box { 29 uint32_t x, y, z; 30 uint32_t w, h, d; 31 }; 32 33 /* formats known by the HW device - based on gallium subset */ 34 enum virgl_formats { 35 VIRGL_FORMAT_NONE = 0, 36 VIRGL_FORMAT_B8G8R8A8_UNORM = 1, 37 VIRGL_FORMAT_B8G8R8X8_UNORM = 2, 38 VIRGL_FORMAT_A8R8G8B8_UNORM = 3, 39 VIRGL_FORMAT_X8R8G8B8_UNORM = 4, 40 VIRGL_FORMAT_B5G5R5A1_UNORM = 5, 41 VIRGL_FORMAT_B4G4R4A4_UNORM = 6, 42 VIRGL_FORMAT_B5G6R5_UNORM = 7, 43 VIRGL_FORMAT_R10G10B10A2_UNORM = 8, 44 VIRGL_FORMAT_L8_UNORM = 9, /**< ubyte luminance */ 45 VIRGL_FORMAT_A8_UNORM = 10, /**< ubyte alpha */ 46 VIRGL_FORMAT_I8_UNORM = 11, 47 VIRGL_FORMAT_L8A8_UNORM = 12, /**< ubyte alpha, luminance */ 48 VIRGL_FORMAT_L16_UNORM = 13, /**< ushort luminance */ 49 VIRGL_FORMAT_UYVY = 14, 50 VIRGL_FORMAT_YUYV = 15, 51 VIRGL_FORMAT_Z16_UNORM = 16, 52 VIRGL_FORMAT_Z32_UNORM = 17, 53 VIRGL_FORMAT_Z32_FLOAT = 18, 54 VIRGL_FORMAT_Z24_UNORM_S8_UINT = 19, 55 VIRGL_FORMAT_S8_UINT_Z24_UNORM = 20, 56 VIRGL_FORMAT_Z24X8_UNORM = 21, 57 VIRGL_FORMAT_X8Z24_UNORM = 22, 58 VIRGL_FORMAT_S8_UINT = 23, /**< ubyte stencil */ 59 VIRGL_FORMAT_R64_FLOAT = 24, 60 VIRGL_FORMAT_R64G64_FLOAT = 25, 61 VIRGL_FORMAT_R64G64B64_FLOAT = 26, 62 VIRGL_FORMAT_R64G64B64A64_FLOAT = 27, 63 VIRGL_FORMAT_R32_FLOAT = 28, 64 VIRGL_FORMAT_R32G32_FLOAT = 29, 65 VIRGL_FORMAT_R32G32B32_FLOAT = 30, 66 VIRGL_FORMAT_R32G32B32A32_FLOAT = 31, 67 68 VIRGL_FORMAT_R32_UNORM = 32, 69 VIRGL_FORMAT_R32G32_UNORM = 33, 70 VIRGL_FORMAT_R32G32B32_UNORM = 34, 71 VIRGL_FORMAT_R32G32B32A32_UNORM = 35, 72 VIRGL_FORMAT_R32_USCALED = 36, 73 VIRGL_FORMAT_R32G32_USCALED = 37, 74 VIRGL_FORMAT_R32G32B32_USCALED = 38, 75 VIRGL_FORMAT_R32G32B32A32_USCALED = 39, 76 VIRGL_FORMAT_R32_SNORM = 40, 77 VIRGL_FORMAT_R32G32_SNORM = 41, 78 VIRGL_FORMAT_R32G32B32_SNORM = 42, 79 VIRGL_FORMAT_R32G32B32A32_SNORM = 43, 80 VIRGL_FORMAT_R32_SSCALED = 44, 81 VIRGL_FORMAT_R32G32_SSCALED = 45, 82 VIRGL_FORMAT_R32G32B32_SSCALED = 46, 83 VIRGL_FORMAT_R32G32B32A32_SSCALED = 47, 84 85 VIRGL_FORMAT_R16_UNORM = 48, 86 VIRGL_FORMAT_R16G16_UNORM = 49, 87 VIRGL_FORMAT_R16G16B16_UNORM = 50, 88 VIRGL_FORMAT_R16G16B16A16_UNORM = 51, 89 90 VIRGL_FORMAT_R16_USCALED = 52, 91 VIRGL_FORMAT_R16G16_USCALED = 53, 92 VIRGL_FORMAT_R16G16B16_USCALED = 54, 93 VIRGL_FORMAT_R16G16B16A16_USCALED = 55, 94 95 VIRGL_FORMAT_R16_SNORM = 56, 96 VIRGL_FORMAT_R16G16_SNORM = 57, 97 VIRGL_FORMAT_R16G16B16_SNORM = 58, 98 VIRGL_FORMAT_R16G16B16A16_SNORM = 59, 99 100 VIRGL_FORMAT_R16_SSCALED = 60, 101 VIRGL_FORMAT_R16G16_SSCALED = 61, 102 VIRGL_FORMAT_R16G16B16_SSCALED = 62, 103 VIRGL_FORMAT_R16G16B16A16_SSCALED = 63, 104 105 VIRGL_FORMAT_R8_UNORM = 64, 106 VIRGL_FORMAT_R8G8_UNORM = 65, 107 VIRGL_FORMAT_R8G8B8_UNORM = 66, 108 VIRGL_FORMAT_R8G8B8A8_UNORM = 67, 109 VIRGL_FORMAT_X8B8G8R8_UNORM = 68, 110 111 VIRGL_FORMAT_R8_USCALED = 69, 112 VIRGL_FORMAT_R8G8_USCALED = 70, 113 VIRGL_FORMAT_R8G8B8_USCALED = 71, 114 VIRGL_FORMAT_R8G8B8A8_USCALED = 72, 115 116 VIRGL_FORMAT_R8_SNORM = 74, 117 VIRGL_FORMAT_R8G8_SNORM = 75, 118 VIRGL_FORMAT_R8G8B8_SNORM = 76, 119 VIRGL_FORMAT_R8G8B8A8_SNORM = 77, 120 121 VIRGL_FORMAT_R8_SSCALED = 82, 122 VIRGL_FORMAT_R8G8_SSCALED = 83, 123 VIRGL_FORMAT_R8G8B8_SSCALED = 84, 124 VIRGL_FORMAT_R8G8B8A8_SSCALED = 85, 125 126 VIRGL_FORMAT_R32_FIXED = 87, 127 VIRGL_FORMAT_R32G32_FIXED = 88, 128 VIRGL_FORMAT_R32G32B32_FIXED = 89, 129 VIRGL_FORMAT_R32G32B32A32_FIXED = 90, 130 131 VIRGL_FORMAT_R16_FLOAT = 91, 132 VIRGL_FORMAT_R16G16_FLOAT = 92, 133 VIRGL_FORMAT_R16G16B16_FLOAT = 93, 134 VIRGL_FORMAT_R16G16B16A16_FLOAT = 94, 135 136 VIRGL_FORMAT_L8_SRGB = 95, 137 VIRGL_FORMAT_L8A8_SRGB = 96, 138 VIRGL_FORMAT_R8G8B8_SRGB = 97, 139 VIRGL_FORMAT_A8B8G8R8_SRGB = 98, 140 VIRGL_FORMAT_X8B8G8R8_SRGB = 99, 141 VIRGL_FORMAT_B8G8R8A8_SRGB = 100, 142 VIRGL_FORMAT_B8G8R8X8_SRGB = 101, 143 VIRGL_FORMAT_A8R8G8B8_SRGB = 102, 144 VIRGL_FORMAT_X8R8G8B8_SRGB = 103, 145 VIRGL_FORMAT_R8G8B8A8_SRGB = 104, 146 147 /* compressed formats */ 148 VIRGL_FORMAT_DXT1_RGB = 105, 149 VIRGL_FORMAT_DXT1_RGBA = 106, 150 VIRGL_FORMAT_DXT3_RGBA = 107, 151 VIRGL_FORMAT_DXT5_RGBA = 108, 152 153 /* sRGB, compressed */ 154 VIRGL_FORMAT_DXT1_SRGB = 109, 155 VIRGL_FORMAT_DXT1_SRGBA = 110, 156 VIRGL_FORMAT_DXT3_SRGBA = 111, 157 VIRGL_FORMAT_DXT5_SRGBA = 112, 158 159 /* rgtc compressed */ 160 VIRGL_FORMAT_RGTC1_UNORM = 113, 161 VIRGL_FORMAT_RGTC1_SNORM = 114, 162 VIRGL_FORMAT_RGTC2_UNORM = 115, 163 VIRGL_FORMAT_RGTC2_SNORM = 116, 164 165 VIRGL_FORMAT_R8G8_B8G8_UNORM = 117, 166 VIRGL_FORMAT_G8R8_G8B8_UNORM = 118, 167 168 VIRGL_FORMAT_R8SG8SB8UX8U_NORM = 119, 169 VIRGL_FORMAT_R5SG5SB6U_NORM = 120, 170 171 VIRGL_FORMAT_A8B8G8R8_UNORM = 121, 172 VIRGL_FORMAT_B5G5R5X1_UNORM = 122, 173 VIRGL_FORMAT_R10G10B10A2_USCALED = 123, 174 VIRGL_FORMAT_R11G11B10_FLOAT = 124, 175 VIRGL_FORMAT_R9G9B9E5_FLOAT = 125, 176 VIRGL_FORMAT_Z32_FLOAT_S8X24_UINT = 126, 177 VIRGL_FORMAT_R1_UNORM = 127, 178 VIRGL_FORMAT_R10G10B10X2_USCALED = 128, 179 VIRGL_FORMAT_R10G10B10X2_SNORM = 129, 180 181 VIRGL_FORMAT_L4A4_UNORM = 130, 182 VIRGL_FORMAT_B10G10R10A2_UNORM = 131, 183 VIRGL_FORMAT_R10SG10SB10SA2U_NORM = 132, 184 VIRGL_FORMAT_R8G8Bx_SNORM = 133, 185 VIRGL_FORMAT_R8G8B8X8_UNORM = 134, 186 VIRGL_FORMAT_B4G4R4X4_UNORM = 135, 187 VIRGL_FORMAT_X24S8_UINT = 136, 188 VIRGL_FORMAT_S8X24_UINT = 137, 189 VIRGL_FORMAT_X32_S8X24_UINT = 138, 190 VIRGL_FORMAT_B2G3R3_UNORM = 139, 191 192 VIRGL_FORMAT_L16A16_UNORM = 140, 193 VIRGL_FORMAT_A16_UNORM = 141, 194 VIRGL_FORMAT_I16_UNORM = 142, 195 196 VIRGL_FORMAT_LATC1_UNORM = 143, 197 VIRGL_FORMAT_LATC1_SNORM = 144, 198 VIRGL_FORMAT_LATC2_UNORM = 145, 199 VIRGL_FORMAT_LATC2_SNORM = 146, 200 201 VIRGL_FORMAT_A8_SNORM = 147, 202 VIRGL_FORMAT_L8_SNORM = 148, 203 VIRGL_FORMAT_L8A8_SNORM = 149, 204 VIRGL_FORMAT_I8_SNORM = 150, 205 VIRGL_FORMAT_A16_SNORM = 151, 206 VIRGL_FORMAT_L16_SNORM = 152, 207 VIRGL_FORMAT_L16A16_SNORM = 153, 208 VIRGL_FORMAT_I16_SNORM = 154, 209 210 VIRGL_FORMAT_A16_FLOAT = 155, 211 VIRGL_FORMAT_L16_FLOAT = 156, 212 VIRGL_FORMAT_L16A16_FLOAT = 157, 213 VIRGL_FORMAT_I16_FLOAT = 158, 214 VIRGL_FORMAT_A32_FLOAT = 159, 215 VIRGL_FORMAT_L32_FLOAT = 160, 216 VIRGL_FORMAT_L32A32_FLOAT = 161, 217 VIRGL_FORMAT_I32_FLOAT = 162, 218 219 VIRGL_FORMAT_YV12 = 163, 220 VIRGL_FORMAT_YV16 = 164, 221 VIRGL_FORMAT_IYUV = 165, /**< aka I420 */ 222 VIRGL_FORMAT_NV12 = 166, 223 VIRGL_FORMAT_NV21 = 167, 224 225 VIRGL_FORMAT_A4R4_UNORM = 168, 226 VIRGL_FORMAT_R4A4_UNORM = 169, 227 VIRGL_FORMAT_R8A8_UNORM = 170, 228 VIRGL_FORMAT_A8R8_UNORM = 171, 229 230 VIRGL_FORMAT_R10G10B10A2_SSCALED = 172, 231 VIRGL_FORMAT_R10G10B10A2_SNORM = 173, 232 VIRGL_FORMAT_B10G10R10A2_USCALED = 174, 233 VIRGL_FORMAT_B10G10R10A2_SSCALED = 175, 234 VIRGL_FORMAT_B10G10R10A2_SNORM = 176, 235 236 VIRGL_FORMAT_R8_UINT = 177, 237 VIRGL_FORMAT_R8G8_UINT = 178, 238 VIRGL_FORMAT_R8G8B8_UINT = 179, 239 VIRGL_FORMAT_R8G8B8A8_UINT = 180, 240 241 VIRGL_FORMAT_R8_SINT = 181, 242 VIRGL_FORMAT_R8G8_SINT = 182, 243 VIRGL_FORMAT_R8G8B8_SINT = 183, 244 VIRGL_FORMAT_R8G8B8A8_SINT = 184, 245 246 VIRGL_FORMAT_R16_UINT = 185, 247 VIRGL_FORMAT_R16G16_UINT = 186, 248 VIRGL_FORMAT_R16G16B16_UINT = 187, 249 VIRGL_FORMAT_R16G16B16A16_UINT = 188, 250 251 VIRGL_FORMAT_R16_SINT = 189, 252 VIRGL_FORMAT_R16G16_SINT = 190, 253 VIRGL_FORMAT_R16G16B16_SINT = 191, 254 VIRGL_FORMAT_R16G16B16A16_SINT = 192, 255 VIRGL_FORMAT_R32_UINT = 193, 256 VIRGL_FORMAT_R32G32_UINT = 194, 257 VIRGL_FORMAT_R32G32B32_UINT = 195, 258 VIRGL_FORMAT_R32G32B32A32_UINT = 196, 259 260 VIRGL_FORMAT_R32_SINT = 197, 261 VIRGL_FORMAT_R32G32_SINT = 198, 262 VIRGL_FORMAT_R32G32B32_SINT = 199, 263 VIRGL_FORMAT_R32G32B32A32_SINT = 200, 264 265 VIRGL_FORMAT_A8_UINT = 201, 266 VIRGL_FORMAT_I8_UINT = 202, 267 VIRGL_FORMAT_L8_UINT = 203, 268 VIRGL_FORMAT_L8A8_UINT = 204, 269 270 VIRGL_FORMAT_A8_SINT = 205, 271 VIRGL_FORMAT_I8_SINT = 206, 272 VIRGL_FORMAT_L8_SINT = 207, 273 VIRGL_FORMAT_L8A8_SINT = 208, 274 275 VIRGL_FORMAT_A16_UINT = 209, 276 VIRGL_FORMAT_I16_UINT = 210, 277 VIRGL_FORMAT_L16_UINT = 211, 278 VIRGL_FORMAT_L16A16_UINT = 212, 279 280 VIRGL_FORMAT_A16_SINT = 213, 281 VIRGL_FORMAT_I16_SINT = 214, 282 VIRGL_FORMAT_L16_SINT = 215, 283 VIRGL_FORMAT_L16A16_SINT = 216, 284 285 VIRGL_FORMAT_A32_UINT = 217, 286 VIRGL_FORMAT_I32_UINT = 218, 287 VIRGL_FORMAT_L32_UINT = 219, 288 VIRGL_FORMAT_L32A32_UINT = 220, 289 290 VIRGL_FORMAT_A32_SINT = 221, 291 VIRGL_FORMAT_I32_SINT = 222, 292 VIRGL_FORMAT_L32_SINT = 223, 293 VIRGL_FORMAT_L32A32_SINT = 224, 294 295 VIRGL_FORMAT_B10G10R10A2_UINT = 225, 296 VIRGL_FORMAT_ETC1_RGB8 = 226, 297 VIRGL_FORMAT_R8G8_R8B8_UNORM = 227, 298 VIRGL_FORMAT_G8R8_B8R8_UNORM = 228, 299 VIRGL_FORMAT_R8G8B8X8_SNORM = 229, 300 301 VIRGL_FORMAT_R8G8B8X8_SRGB = 230, 302 303 VIRGL_FORMAT_R8G8B8X8_UINT = 231, 304 VIRGL_FORMAT_R8G8B8X8_SINT = 232, 305 VIRGL_FORMAT_B10G10R10X2_UNORM = 233, 306 VIRGL_FORMAT_R16G16B16X16_UNORM = 234, 307 VIRGL_FORMAT_R16G16B16X16_SNORM = 235, 308 VIRGL_FORMAT_R16G16B16X16_FLOAT = 236, 309 VIRGL_FORMAT_R16G16B16X16_UINT = 237, 310 VIRGL_FORMAT_R16G16B16X16_SINT = 238, 311 VIRGL_FORMAT_R32G32B32X32_FLOAT = 239, 312 VIRGL_FORMAT_R32G32B32X32_UINT = 240, 313 VIRGL_FORMAT_R32G32B32X32_SINT = 241, 314 VIRGL_FORMAT_R8A8_SNORM = 242, 315 VIRGL_FORMAT_R16A16_UNORM = 243, 316 VIRGL_FORMAT_R16A16_SNORM = 244, 317 VIRGL_FORMAT_R16A16_FLOAT = 245, 318 VIRGL_FORMAT_R32A32_FLOAT = 246, 319 VIRGL_FORMAT_R8A8_UINT = 247, 320 VIRGL_FORMAT_R8A8_SINT = 248, 321 VIRGL_FORMAT_R16A16_UINT = 249, 322 VIRGL_FORMAT_R16A16_SINT = 250, 323 VIRGL_FORMAT_R32A32_UINT = 251, 324 VIRGL_FORMAT_R32A32_SINT = 252, 325 326 VIRGL_FORMAT_R10G10B10A2_UINT = 253, 327 VIRGL_FORMAT_B5G6R5_SRGB = 254, 328 329 VIRGL_FORMAT_BPTC_RGBA_UNORM = 255, 330 VIRGL_FORMAT_BPTC_SRGBA = 256, 331 VIRGL_FORMAT_BPTC_RGB_FLOAT = 257, 332 VIRGL_FORMAT_BPTC_RGB_UFLOAT = 258, 333 334 VIRGL_FORMAT_A16L16_UNORM = 262, 335 336 VIRGL_FORMAT_G8R8_UNORM = 263, 337 VIRGL_FORMAT_G8R8_SNORM = 264, 338 VIRGL_FORMAT_G16R16_UNORM = 265, 339 VIRGL_FORMAT_G16R16_SNORM = 266, 340 VIRGL_FORMAT_A8B8G8R8_SNORM = 267, 341 342 VIRGL_FORMAT_A8L8_UNORM = 259, 343 VIRGL_FORMAT_A8L8_SNORM = 260, 344 VIRGL_FORMAT_A8L8_SRGB = 261, 345 346 VIRGL_FORMAT_X8B8G8R8_SNORM = 268, 347 348 349 /* etc2 compressed */ 350 VIRGL_FORMAT_ETC2_RGB8 = 269, 351 VIRGL_FORMAT_ETC2_SRGB8 = 270, 352 VIRGL_FORMAT_ETC2_RGB8A1 = 271, 353 VIRGL_FORMAT_ETC2_SRGB8A1 = 272, 354 VIRGL_FORMAT_ETC2_RGBA8 = 273, 355 VIRGL_FORMAT_ETC2_SRGBA8 = 274, 356 VIRGL_FORMAT_ETC2_R11_UNORM = 275, 357 VIRGL_FORMAT_ETC2_R11_SNORM = 276, 358 VIRGL_FORMAT_ETC2_RG11_UNORM = 277, 359 VIRGL_FORMAT_ETC2_RG11_SNORM = 278, 360 361 /* astc compressed */ 362 VIRGL_FORMAT_ASTC_4x4 = 279, 363 VIRGL_FORMAT_ASTC_5x4 = 280, 364 VIRGL_FORMAT_ASTC_5x5 = 281, 365 VIRGL_FORMAT_ASTC_6x5 = 282, 366 VIRGL_FORMAT_ASTC_6x6 = 283, 367 VIRGL_FORMAT_ASTC_8x5 = 284, 368 VIRGL_FORMAT_ASTC_8x6 = 285, 369 VIRGL_FORMAT_ASTC_8x8 = 286, 370 VIRGL_FORMAT_ASTC_10x5 = 287, 371 VIRGL_FORMAT_ASTC_10x6 = 288, 372 VIRGL_FORMAT_ASTC_10x8 = 289, 373 VIRGL_FORMAT_ASTC_10x10 = 290, 374 VIRGL_FORMAT_ASTC_12x10 = 291, 375 VIRGL_FORMAT_ASTC_12x12 = 292, 376 VIRGL_FORMAT_ASTC_4x4_SRGB = 293, 377 VIRGL_FORMAT_ASTC_5x4_SRGB = 294, 378 VIRGL_FORMAT_ASTC_5x5_SRGB = 295, 379 VIRGL_FORMAT_ASTC_6x5_SRGB = 296, 380 VIRGL_FORMAT_ASTC_6x6_SRGB = 297, 381 VIRGL_FORMAT_ASTC_8x5_SRGB = 298, 382 VIRGL_FORMAT_ASTC_8x6_SRGB = 299, 383 VIRGL_FORMAT_ASTC_8x8_SRGB = 300, 384 VIRGL_FORMAT_ASTC_10x5_SRGB = 301, 385 VIRGL_FORMAT_ASTC_10x6_SRGB = 302, 386 VIRGL_FORMAT_ASTC_10x8_SRGB = 303, 387 VIRGL_FORMAT_ASTC_10x10_SRGB = 304, 388 VIRGL_FORMAT_ASTC_12x10_SRGB = 305, 389 VIRGL_FORMAT_ASTC_12x12_SRGB = 306, 390 391 VIRGL_FORMAT_R10G10B10X2_UNORM = 308, 392 VIRGL_FORMAT_A4B4G4R4_UNORM = 311, 393 394 VIRGL_FORMAT_R8_SRGB = 312, 395 VIRGL_FORMAT_R8G8_SRGB = 313, 396 VIRGL_FORMAT_MAX /* = PIPE_FORMAT_COUNT */, 397 398 /* Below formats must not be used in the guest. */ 399 VIRGL_FORMAT_B8G8R8X8_UNORM_EMULATED, 400 VIRGL_FORMAT_B8G8R8A8_UNORM_EMULATED, 401 VIRGL_FORMAT_MAX_EXTENDED 402 }; 403 404 /* These are used by the capability_bits field in virgl_caps_v2. */ 405 #define VIRGL_CAP_NONE 0 406 #define VIRGL_CAP_TGSI_INVARIANT (1 << 0) 407 #define VIRGL_CAP_TEXTURE_VIEW (1 << 1) 408 #define VIRGL_CAP_SET_MIN_SAMPLES (1 << 2) 409 #define VIRGL_CAP_COPY_IMAGE (1 << 3) 410 #define VIRGL_CAP_TGSI_PRECISE (1 << 4) 411 #define VIRGL_CAP_TXQS (1 << 5) 412 #define VIRGL_CAP_MEMORY_BARRIER (1 << 6) 413 #define VIRGL_CAP_COMPUTE_SHADER (1 << 7) 414 #define VIRGL_CAP_FB_NO_ATTACH (1 << 8) 415 #define VIRGL_CAP_ROBUST_BUFFER_ACCESS (1 << 9) 416 #define VIRGL_CAP_TGSI_FBFETCH (1 << 10) 417 #define VIRGL_CAP_SHADER_CLOCK (1 << 11) 418 #define VIRGL_CAP_TEXTURE_BARRIER (1 << 12) 419 #define VIRGL_CAP_TGSI_COMPONENTS (1 << 13) 420 #define VIRGL_CAP_GUEST_MAY_INIT_LOG (1 << 14) 421 #define VIRGL_CAP_SRGB_WRITE_CONTROL (1 << 15) 422 #define VIRGL_CAP_QBO (1 << 16) 423 #define VIRGL_CAP_TRANSFER (1 << 17) 424 #define VIRGL_CAP_FBO_MIXED_COLOR_FORMATS (1 << 18) 425 #define VIRGL_CAP_FAKE_FP64 (1 << 19) 426 #define VIRGL_CAP_BIND_COMMAND_ARGS (1 << 20) 427 #define VIRGL_CAP_MULTI_DRAW_INDIRECT (1 << 21) 428 #define VIRGL_CAP_INDIRECT_PARAMS (1 << 22) 429 #define VIRGL_CAP_TRANSFORM_FEEDBACK3 (1 << 23) 430 #define VIRGL_CAP_3D_ASTC (1 << 24) 431 #define VIRGL_CAP_INDIRECT_INPUT_ADDR (1 << 25) 432 #define VIRGL_CAP_COPY_TRANSFER (1 << 26) 433 #define VIRGL_CAP_CLIP_HALFZ (1 << 27) 434 #define VIRGL_CAP_APP_TWEAK_SUPPORT (1 << 28) 435 #define VIRGL_CAP_BGRA_SRGB_IS_EMULATED (1 << 29) 436 #define VIRGL_CAP_CLEAR_TEXTURE (1 << 30) 437 #define VIRGL_CAP_ARB_BUFFER_STORAGE (1 << 31) 438 439 /* These are used by the capability_bits_v2 field in virgl_caps_v2. */ 440 #define VIRGL_CAP_V2_BLEND_EQUATION (1 << 0) 441 #define VIRGL_CAP_V2_UNTYPED_RESOURCE (1 << 1) 442 #define VIRGL_CAP_V2_VIDEO_MEMORY (1 << 2) 443 #define VIRGL_CAP_V2_MEMINFO (1 << 3) 444 #define VIRGL_CAP_V2_STRING_MARKER (1 << 4) 445 #define VIRGL_CAP_V2_IMPLICIT_MSAA (1 << 6) 446 #define VIRGL_CAP_V2_COPY_TRANSFER_BOTH_DIRECTIONS (1 << 7) 447 #define VIRGL_CAP_V2_SCANOUT_USES_GBM (1 << 8) 448 #define VIRGL_CAP_V2_SSO (1 << 9) 449 /* virgl bind flags - these are compatible with mesa 10.5 gallium. 450 * but are fixed, no other should be passed to virgl either. 451 */ 452 #define VIRGL_BIND_DEPTH_STENCIL (1 << 0) 453 #define VIRGL_BIND_RENDER_TARGET (1 << 1) 454 #define VIRGL_BIND_SAMPLER_VIEW (1 << 3) 455 #define VIRGL_BIND_VERTEX_BUFFER (1 << 4) 456 #define VIRGL_BIND_INDEX_BUFFER (1 << 5) 457 #define VIRGL_BIND_CONSTANT_BUFFER (1 << 6) 458 #define VIRGL_BIND_DISPLAY_TARGET (1 << 7) 459 #define VIRGL_BIND_COMMAND_ARGS (1 << 8) 460 #define VIRGL_BIND_STREAM_OUTPUT (1 << 11) 461 #define VIRGL_BIND_SHADER_BUFFER (1 << 14) 462 #define VIRGL_BIND_QUERY_BUFFER (1 << 15) 463 #define VIRGL_BIND_CURSOR (1 << 16) 464 #define VIRGL_BIND_CUSTOM (1 << 17) 465 #define VIRGL_BIND_SCANOUT (1 << 18) 466 /* Used for buffers that are backed by guest storage and 467 * are only read by the host. 468 */ 469 #define VIRGL_BIND_STAGING (1 << 19) 470 #define VIRGL_BIND_SHARED (1 << 20) 471 472 #define VIRGL_BIND_PREFER_EMULATED_BGRA (1 << 21) 473 474 #define VIRGL_BIND_LINEAR (1 << 22) 475 476 #define VIRGL_BIND_SHARED_SUBFLAGS (0xff << 24) 477 478 #define VIRGL_BIND_MINIGBM_CAMERA_WRITE (1 << 24) 479 #define VIRGL_BIND_MINIGBM_CAMERA_READ (1 << 25) 480 #define VIRGL_BIND_MINIGBM_HW_VIDEO_DECODER (1 << 26) 481 #define VIRGL_BIND_MINIGBM_HW_VIDEO_ENCODER (1 << 27) 482 #define VIRGL_BIND_MINIGBM_SW_READ_OFTEN (1 << 28) 483 #define VIRGL_BIND_MINIGBM_SW_READ_RARELY (1 << 29) 484 #define VIRGL_BIND_MINIGBM_SW_WRITE_OFTEN (1 << 30) 485 #define VIRGL_BIND_MINIGBM_SW_WRITE_RARELY (1 << 31) 486 #define VIRGL_BIND_MINIGBM_PROTECTED (0xf << 28) // Mutually exclusive with SW_ flags 487 488 struct virgl_caps_bool_set1 { 489 unsigned indep_blend_enable:1; 490 unsigned indep_blend_func:1; 491 unsigned cube_map_array:1; 492 unsigned shader_stencil_export:1; 493 unsigned conditional_render:1; 494 unsigned start_instance:1; 495 unsigned primitive_restart:1; 496 unsigned blend_eq_sep:1; 497 unsigned instanceid:1; 498 unsigned vertex_element_instance_divisor:1; 499 unsigned seamless_cube_map:1; 500 unsigned occlusion_query:1; 501 unsigned timer_query:1; 502 unsigned streamout_pause_resume:1; 503 unsigned texture_multisample:1; 504 unsigned fragment_coord_conventions:1; 505 unsigned depth_clip_disable:1; 506 unsigned seamless_cube_map_per_texture:1; 507 unsigned ubo:1; 508 unsigned color_clamping:1; /* not in GL 3.1 core profile */ 509 unsigned poly_stipple:1; /* not in GL 3.1 core profile */ 510 unsigned mirror_clamp:1; 511 unsigned texture_query_lod:1; 512 unsigned has_fp64:1; 513 unsigned has_tessellation_shaders:1; 514 unsigned has_indirect_draw:1; 515 unsigned has_sample_shading:1; 516 unsigned has_cull:1; 517 unsigned conditional_render_inverted:1; 518 unsigned derivative_control:1; 519 unsigned polygon_offset_clamp:1; 520 unsigned transform_feedback_overflow_query:1; 521 /* DO NOT ADD ANYMORE MEMBERS - need to add another 32-bit to v2 caps */ 522 }; 523 524 /* endless expansion capabilites - current gallium has 252 formats */ 525 struct virgl_supported_format_mask { 526 uint32_t bitmask[16]; 527 }; 528 /* capabilities set 2 - version 1 - 32-bit and float values */ 529 struct virgl_caps_v1 { 530 uint32_t max_version; 531 struct virgl_supported_format_mask sampler; 532 struct virgl_supported_format_mask render; 533 struct virgl_supported_format_mask depthstencil; 534 struct virgl_supported_format_mask vertexbuffer; 535 struct virgl_caps_bool_set1 bset; 536 uint32_t glsl_level; 537 uint32_t max_texture_array_layers; 538 uint32_t max_streamout_buffers; 539 uint32_t max_dual_source_render_targets; 540 uint32_t max_render_targets; 541 uint32_t max_samples; 542 uint32_t prim_mask; 543 uint32_t max_tbo_size; 544 uint32_t max_uniform_blocks; 545 uint32_t max_viewports; 546 uint32_t max_texture_gather_components; 547 }; 548 549 /* 550 * This struct should be growable when used in capset 2, 551 * so we shouldn't have to add a v3 ever. 552 */ 553 struct virgl_caps_v2 { 554 struct virgl_caps_v1 v1; 555 float min_aliased_point_size; 556 float max_aliased_point_size; 557 float min_smooth_point_size; 558 float max_smooth_point_size; 559 float min_aliased_line_width; 560 float max_aliased_line_width; 561 float min_smooth_line_width; 562 float max_smooth_line_width; 563 float max_texture_lod_bias; 564 uint32_t max_geom_output_vertices; 565 uint32_t max_geom_total_output_components; 566 uint32_t max_vertex_outputs; 567 uint32_t max_vertex_attribs; 568 uint32_t max_shader_patch_varyings; 569 int32_t min_texel_offset; 570 int32_t max_texel_offset; 571 int32_t min_texture_gather_offset; 572 int32_t max_texture_gather_offset; 573 uint32_t texture_buffer_offset_alignment; 574 uint32_t uniform_buffer_offset_alignment; 575 uint32_t shader_buffer_offset_alignment; 576 uint32_t capability_bits; 577 uint32_t sample_locations[8]; 578 uint32_t max_vertex_attrib_stride; 579 uint32_t max_shader_buffer_frag_compute; 580 uint32_t max_shader_buffer_other_stages; 581 uint32_t max_shader_image_frag_compute; 582 uint32_t max_shader_image_other_stages; 583 uint32_t max_image_samples; 584 uint32_t max_compute_work_group_invocations; 585 uint32_t max_compute_shared_memory_size; 586 uint32_t max_compute_grid_size[3]; 587 uint32_t max_compute_block_size[3]; 588 uint32_t max_texture_2d_size; 589 uint32_t max_texture_3d_size; 590 uint32_t max_texture_cube_size; 591 uint32_t max_combined_shader_buffers; 592 uint32_t max_atomic_counters[6]; 593 uint32_t max_atomic_counter_buffers[6]; 594 uint32_t max_combined_atomic_counters; 595 uint32_t max_combined_atomic_counter_buffers; 596 uint32_t host_feature_check_version; 597 struct virgl_supported_format_mask supported_readback_formats; 598 struct virgl_supported_format_mask scanout; 599 uint32_t capability_bits_v2; 600 uint32_t max_video_memory; 601 char renderer[64]; 602 float max_anisotropy; 603 uint32_t max_shader_sampler_views; 604 struct virgl_supported_format_mask supported_multisample_formats; 605 uint32_t max_const_buffer_size[6]; // PIPE_SHADER_TYPES 606 uint32_t max_uniform_block_size; 607 }; 608 609 union virgl_caps { 610 uint32_t max_version; 611 struct virgl_caps_v1 v1; 612 struct virgl_caps_v2 v2; 613 }; 614 615 enum virgl_errors { 616 VIRGL_ERROR_NONE, 617 VIRGL_ERROR_UNKNOWN, 618 VIRGL_ERROR_UNKNOWN_RESOURCE_FORMAT, 619 }; 620 621 enum virgl_ctx_errors { 622 VIRGL_ERROR_CTX_NONE, 623 VIRGL_ERROR_CTX_UNKNOWN, 624 VIRGL_ERROR_CTX_ILLEGAL_SHADER, 625 VIRGL_ERROR_CTX_ILLEGAL_HANDLE, 626 VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, 627 VIRGL_ERROR_CTX_ILLEGAL_SURFACE, 628 VIRGL_ERROR_CTX_ILLEGAL_VERTEX_FORMAT, 629 VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, 630 VIRGL_ERROR_CTX_GLES_HAVE_TES_BUT_MISS_TCS, 631 VIRGL_ERROR_GL_ANY_SAMPLES_PASSED, 632 VIRGL_ERROR_CTX_ILLEGAL_FORMAT, 633 VIRGL_ERROR_CTX_ILLEGAL_SAMPLER_VIEW_TARGET, 634 VIRGL_ERROR_CTX_TRANSFER_IOV_BOUNDS, 635 VIRGL_ERROR_CTX_ILLEGAL_DUAL_SRC_BLEND 636 }; 637 638 /** 639 * Flags for the driver about resource behaviour: 640 */ 641 #define VIRGL_RESOURCE_Y_0_TOP (1 << 0) 642 #define VIRGL_RESOURCE_FLAG_MAP_PERSISTENT (1 << 1) 643 #define VIRGL_RESOURCE_FLAG_MAP_COHERENT (1 << 2) 644 645 #endif 646