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 VIRGL_FORMAT_ASTC_4x4 = 279, 362 VIRGL_FORMAT_ASTC_5x4 = 280, 363 VIRGL_FORMAT_ASTC_5x5 = 281, 364 VIRGL_FORMAT_ASTC_6x5 = 282, 365 VIRGL_FORMAT_ASTC_6x6 = 283, 366 VIRGL_FORMAT_ASTC_8x5 = 284, 367 VIRGL_FORMAT_ASTC_8x6 = 285, 368 VIRGL_FORMAT_ASTC_8x8 = 286, 369 VIRGL_FORMAT_ASTC_10x5 = 287, 370 VIRGL_FORMAT_ASTC_10x6 = 288, 371 VIRGL_FORMAT_ASTC_10x8 = 289, 372 VIRGL_FORMAT_ASTC_10x10 = 290, 373 VIRGL_FORMAT_ASTC_12x10 = 291, 374 VIRGL_FORMAT_ASTC_12x12 = 292, 375 VIRGL_FORMAT_ASTC_4x4_SRGB = 293, 376 VIRGL_FORMAT_ASTC_5x4_SRGB = 294, 377 VIRGL_FORMAT_ASTC_5x5_SRGB = 295, 378 VIRGL_FORMAT_ASTC_6x5_SRGB = 296, 379 VIRGL_FORMAT_ASTC_6x6_SRGB = 297, 380 VIRGL_FORMAT_ASTC_8x5_SRGB = 298, 381 VIRGL_FORMAT_ASTC_8x6_SRGB = 299, 382 VIRGL_FORMAT_ASTC_8x8_SRGB = 300, 383 VIRGL_FORMAT_ASTC_10x5_SRGB = 301, 384 VIRGL_FORMAT_ASTC_10x6_SRGB = 302, 385 VIRGL_FORMAT_ASTC_10x8_SRGB = 303, 386 VIRGL_FORMAT_ASTC_10x10_SRGB = 304, 387 VIRGL_FORMAT_ASTC_12x10_SRGB = 305, 388 VIRGL_FORMAT_ASTC_12x12_SRGB = 306, 389 390 VIRGL_FORMAT_R10G10B10X2_UNORM = 308, 391 VIRGL_FORMAT_A4B4G4R4_UNORM = 311, 392 393 VIRGL_FORMAT_R8_SRGB = 312, 394 VIRGL_FORMAT_MAX /* = PIPE_FORMAT_COUNT */, 395 396 /* Below formats must not be used in the guest. */ 397 VIRGL_FORMAT_B8G8R8X8_UNORM_EMULATED, 398 VIRGL_FORMAT_B8G8R8A8_UNORM_EMULATED, 399 VIRGL_FORMAT_MAX_EXTENDED 400 }; 401 402 /* These are used by the capability_bits field in virgl_caps_v2. */ 403 #define VIRGL_CAP_NONE 0 404 #define VIRGL_CAP_TGSI_INVARIANT (1 << 0) 405 #define VIRGL_CAP_TEXTURE_VIEW (1 << 1) 406 #define VIRGL_CAP_SET_MIN_SAMPLES (1 << 2) 407 #define VIRGL_CAP_COPY_IMAGE (1 << 3) 408 #define VIRGL_CAP_TGSI_PRECISE (1 << 4) 409 #define VIRGL_CAP_TXQS (1 << 5) 410 #define VIRGL_CAP_MEMORY_BARRIER (1 << 6) 411 #define VIRGL_CAP_COMPUTE_SHADER (1 << 7) 412 #define VIRGL_CAP_FB_NO_ATTACH (1 << 8) 413 #define VIRGL_CAP_ROBUST_BUFFER_ACCESS (1 << 9) 414 #define VIRGL_CAP_TGSI_FBFETCH (1 << 10) 415 #define VIRGL_CAP_SHADER_CLOCK (1 << 11) 416 #define VIRGL_CAP_TEXTURE_BARRIER (1 << 12) 417 #define VIRGL_CAP_TGSI_COMPONENTS (1 << 13) 418 #define VIRGL_CAP_GUEST_MAY_INIT_LOG (1 << 14) 419 #define VIRGL_CAP_SRGB_WRITE_CONTROL (1 << 15) 420 #define VIRGL_CAP_QBO (1 << 16) 421 #define VIRGL_CAP_TRANSFER (1 << 17) 422 #define VIRGL_CAP_FBO_MIXED_COLOR_FORMATS (1 << 18) 423 #define VIRGL_CAP_FAKE_FP64 (1 << 19) 424 #define VIRGL_CAP_BIND_COMMAND_ARGS (1 << 20) 425 #define VIRGL_CAP_MULTI_DRAW_INDIRECT (1 << 21) 426 #define VIRGL_CAP_INDIRECT_PARAMS (1 << 22) 427 #define VIRGL_CAP_TRANSFORM_FEEDBACK3 (1 << 23) 428 #define VIRGL_CAP_3D_ASTC (1 << 24) 429 #define VIRGL_CAP_INDIRECT_INPUT_ADDR (1 << 25) 430 #define VIRGL_CAP_COPY_TRANSFER (1 << 26) 431 #define VIRGL_CAP_CLIP_HALFZ (1 << 27) 432 #define VIRGL_CAP_APP_TWEAK_SUPPORT (1 << 28) 433 #define VIRGL_CAP_BGRA_SRGB_IS_EMULATED (1 << 29) 434 #define VIRGL_CAP_CLEAR_TEXTURE (1 << 30) 435 #define VIRGL_CAP_ARB_BUFFER_STORAGE (1 << 31) 436 437 /* These are used by the capability_bits_v2 field in virgl_caps_v2. */ 438 #define VIRGL_CAP_V2_BLEND_EQUATION (1 << 0) 439 #define VIRGL_CAP_V2_UNTYPED_RESOURCE (1 << 1) 440 #define VIRGL_CAP_V2_VIDEO_MEMORY (1 << 2) 441 #define VIRGL_CAP_V2_MEMINFO (1 << 3) 442 443 /* virgl bind flags - these are compatible with mesa 10.5 gallium. 444 * but are fixed, no other should be passed to virgl either. 445 */ 446 #define VIRGL_BIND_DEPTH_STENCIL (1 << 0) 447 #define VIRGL_BIND_RENDER_TARGET (1 << 1) 448 #define VIRGL_BIND_SAMPLER_VIEW (1 << 3) 449 #define VIRGL_BIND_VERTEX_BUFFER (1 << 4) 450 #define VIRGL_BIND_INDEX_BUFFER (1 << 5) 451 #define VIRGL_BIND_CONSTANT_BUFFER (1 << 6) 452 #define VIRGL_BIND_DISPLAY_TARGET (1 << 7) 453 #define VIRGL_BIND_COMMAND_ARGS (1 << 8) 454 #define VIRGL_BIND_STREAM_OUTPUT (1 << 11) 455 #define VIRGL_BIND_SHADER_BUFFER (1 << 14) 456 #define VIRGL_BIND_QUERY_BUFFER (1 << 15) 457 #define VIRGL_BIND_CURSOR (1 << 16) 458 #define VIRGL_BIND_CUSTOM (1 << 17) 459 #define VIRGL_BIND_SCANOUT (1 << 18) 460 /* Used for buffers that are backed by guest storage and 461 * are only read by the host. 462 */ 463 #define VIRGL_BIND_STAGING (1 << 19) 464 #define VIRGL_BIND_SHARED (1 << 20) 465 466 #define VIRGL_BIND_PREFER_EMULATED_BGRA (1 << 21) 467 468 #define VIRGL_BIND_LINEAR (1 << 22) 469 470 #define VIRGL_BIND_SHARED_SUBFLAGS (0xff << 24) 471 472 #define VIRGL_BIND_MINIGBM_CAMERA_WRITE (1 << 24) 473 #define VIRGL_BIND_MINIGBM_CAMERA_READ (1 << 25) 474 #define VIRGL_BIND_MINIGBM_HW_VIDEO_DECODER (1 << 26) 475 #define VIRGL_BIND_MINIGBM_HW_VIDEO_ENCODER (1 << 27) 476 #define VIRGL_BIND_MINIGBM_SW_READ_OFTEN (1 << 28) 477 #define VIRGL_BIND_MINIGBM_SW_READ_RARELY (1 << 29) 478 #define VIRGL_BIND_MINIGBM_SW_WRITE_OFTEN (1 << 30) 479 #define VIRGL_BIND_MINIGBM_SW_WRITE_RARELY (1 << 31) 480 #define VIRGL_BIND_MINIGBM_PROTECTED (0xf << 28) // Mutually exclusive with SW_ flags 481 482 struct virgl_caps_bool_set1 { 483 unsigned indep_blend_enable:1; 484 unsigned indep_blend_func:1; 485 unsigned cube_map_array:1; 486 unsigned shader_stencil_export:1; 487 unsigned conditional_render:1; 488 unsigned start_instance:1; 489 unsigned primitive_restart:1; 490 unsigned blend_eq_sep:1; 491 unsigned instanceid:1; 492 unsigned vertex_element_instance_divisor:1; 493 unsigned seamless_cube_map:1; 494 unsigned occlusion_query:1; 495 unsigned timer_query:1; 496 unsigned streamout_pause_resume:1; 497 unsigned texture_multisample:1; 498 unsigned fragment_coord_conventions:1; 499 unsigned depth_clip_disable:1; 500 unsigned seamless_cube_map_per_texture:1; 501 unsigned ubo:1; 502 unsigned color_clamping:1; /* not in GL 3.1 core profile */ 503 unsigned poly_stipple:1; /* not in GL 3.1 core profile */ 504 unsigned mirror_clamp:1; 505 unsigned texture_query_lod:1; 506 unsigned has_fp64:1; 507 unsigned has_tessellation_shaders:1; 508 unsigned has_indirect_draw:1; 509 unsigned has_sample_shading:1; 510 unsigned has_cull:1; 511 unsigned conditional_render_inverted:1; 512 unsigned derivative_control:1; 513 unsigned polygon_offset_clamp:1; 514 unsigned transform_feedback_overflow_query:1; 515 /* DO NOT ADD ANYMORE MEMBERS - need to add another 32-bit to v2 caps */ 516 }; 517 518 /* endless expansion capabilites - current gallium has 252 formats */ 519 struct virgl_supported_format_mask { 520 uint32_t bitmask[16]; 521 }; 522 /* capabilities set 2 - version 1 - 32-bit and float values */ 523 struct virgl_caps_v1 { 524 uint32_t max_version; 525 struct virgl_supported_format_mask sampler; 526 struct virgl_supported_format_mask render; 527 struct virgl_supported_format_mask depthstencil; 528 struct virgl_supported_format_mask vertexbuffer; 529 struct virgl_caps_bool_set1 bset; 530 uint32_t glsl_level; 531 uint32_t max_texture_array_layers; 532 uint32_t max_streamout_buffers; 533 uint32_t max_dual_source_render_targets; 534 uint32_t max_render_targets; 535 uint32_t max_samples; 536 uint32_t prim_mask; 537 uint32_t max_tbo_size; 538 uint32_t max_uniform_blocks; 539 uint32_t max_viewports; 540 uint32_t max_texture_gather_components; 541 }; 542 543 /* 544 * This struct should be growable when used in capset 2, 545 * so we shouldn't have to add a v3 ever. 546 */ 547 struct virgl_caps_v2 { 548 struct virgl_caps_v1 v1; 549 float min_aliased_point_size; 550 float max_aliased_point_size; 551 float min_smooth_point_size; 552 float max_smooth_point_size; 553 float min_aliased_line_width; 554 float max_aliased_line_width; 555 float min_smooth_line_width; 556 float max_smooth_line_width; 557 float max_texture_lod_bias; 558 uint32_t max_geom_output_vertices; 559 uint32_t max_geom_total_output_components; 560 uint32_t max_vertex_outputs; 561 uint32_t max_vertex_attribs; 562 uint32_t max_shader_patch_varyings; 563 int32_t min_texel_offset; 564 int32_t max_texel_offset; 565 int32_t min_texture_gather_offset; 566 int32_t max_texture_gather_offset; 567 uint32_t texture_buffer_offset_alignment; 568 uint32_t uniform_buffer_offset_alignment; 569 uint32_t shader_buffer_offset_alignment; 570 uint32_t capability_bits; 571 uint32_t sample_locations[8]; 572 uint32_t max_vertex_attrib_stride; 573 uint32_t max_shader_buffer_frag_compute; 574 uint32_t max_shader_buffer_other_stages; 575 uint32_t max_shader_image_frag_compute; 576 uint32_t max_shader_image_other_stages; 577 uint32_t max_image_samples; 578 uint32_t max_compute_work_group_invocations; 579 uint32_t max_compute_shared_memory_size; 580 uint32_t max_compute_grid_size[3]; 581 uint32_t max_compute_block_size[3]; 582 uint32_t max_texture_2d_size; 583 uint32_t max_texture_3d_size; 584 uint32_t max_texture_cube_size; 585 uint32_t max_combined_shader_buffers; 586 uint32_t max_atomic_counters[6]; 587 uint32_t max_atomic_counter_buffers[6]; 588 uint32_t max_combined_atomic_counters; 589 uint32_t max_combined_atomic_counter_buffers; 590 uint32_t host_feature_check_version; 591 struct virgl_supported_format_mask supported_readback_formats; 592 struct virgl_supported_format_mask scanout; 593 uint32_t max_video_memory; 594 uint32_t capability_bits_v2; 595 }; 596 597 union virgl_caps { 598 uint32_t max_version; 599 struct virgl_caps_v1 v1; 600 struct virgl_caps_v2 v2; 601 }; 602 603 enum virgl_errors { 604 VIRGL_ERROR_NONE, 605 VIRGL_ERROR_UNKNOWN, 606 VIRGL_ERROR_UNKNOWN_RESOURCE_FORMAT, 607 }; 608 609 enum virgl_ctx_errors { 610 VIRGL_ERROR_CTX_NONE, 611 VIRGL_ERROR_CTX_UNKNOWN, 612 VIRGL_ERROR_CTX_ILLEGAL_SHADER, 613 VIRGL_ERROR_CTX_ILLEGAL_HANDLE, 614 VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, 615 VIRGL_ERROR_CTX_ILLEGAL_SURFACE, 616 VIRGL_ERROR_CTX_ILLEGAL_VERTEX_FORMAT, 617 VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, 618 VIRGL_ERROR_CTX_GLES_HAVE_TES_BUT_MISS_TCS, 619 VIRGL_ERROR_GL_ANY_SAMPLES_PASSED, 620 VIRGL_ERROR_CTX_ILLEGAL_FORMAT, 621 VIRGL_ERROR_CTX_ILLEGAL_SAMPLER_VIEW_TARGET, 622 VIRGL_ERROR_CTX_TRANSFER_IOV_BOUNDS, 623 VIRGL_ERROR_CTX_ILLEGAL_DUAL_SRC_BLEND 624 }; 625 626 /** 627 * Flags for the driver about resource behaviour: 628 */ 629 #define VIRGL_RESOURCE_Y_0_TOP (1 << 0) 630 #define VIRGL_RESOURCE_FLAG_MAP_PERSISTENT (1 << 1) 631 #define VIRGL_RESOURCE_FLAG_MAP_COHERENT (1 << 2) 632 633 #endif 634