From: Chia-I Wu Date: Thu, 2 Jul 2020 18:06:15 +0000 (-0700) Subject: virgl: move protocol headers to a common place X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=42e29feb8bdaf2854da69f9b5d779a891ffa5d71;p=mesa.git virgl: move protocol headers to a common place Tested with meson. Android.mk changes are not tested. Signed-off-by: Chia-I Wu Reviewed-by: Gurchetan Singh Part-of: --- diff --git a/src/gallium/drivers/virgl/Android.mk b/src/gallium/drivers/virgl/Android.mk index c06c16558c3..31b8a5b0292 100644 --- a/src/gallium/drivers/virgl/Android.mk +++ b/src/gallium/drivers/virgl/Android.mk @@ -31,6 +31,9 @@ LOCAL_SRC_FILES := \ LOCAL_MODULE := libmesa_pipe_virgl LOCAL_MODULE_CLASS := STATIC_LIBRARIES + +LOCAL_C_INCLUDES := $(MESA_TOP)/src/virtio + intermediates := $(call local-generated-sources-dir) LOCAL_GENERATED_SOURCES := $(intermediates)/virgl/virgl_driinfo.h diff --git a/src/gallium/drivers/virgl/Makefile.sources b/src/gallium/drivers/virgl/Makefile.sources index 6730568033b..c8372677f70 100644 --- a/src/gallium/drivers/virgl/Makefile.sources +++ b/src/gallium/drivers/virgl/Makefile.sources @@ -4,8 +4,6 @@ C_SOURCES := \ virgl_context.h \ virgl_encode.c \ virgl_encode.h \ - virgl_hw.h \ - virgl_protocol.h \ virgl_public.h \ virgl_query.c \ virgl_resource.c \ diff --git a/src/gallium/drivers/virgl/meson.build b/src/gallium/drivers/virgl/meson.build index f94099bc200..00cde5f3fe1 100644 --- a/src/gallium/drivers/virgl/meson.build +++ b/src/gallium/drivers/virgl/meson.build @@ -47,7 +47,7 @@ libvirgl = static_library( 'virgl', [ files_libvirgl, virgl_driinfo_h ], gnu_symbol_visibility : 'hidden', - include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], + include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_virtio], dependencies : dep_libdrm ) diff --git a/src/gallium/drivers/virgl/tests/meson.build b/src/gallium/drivers/virgl/tests/meson.build index ec538c9e0b0..53c68f9ee3d 100644 --- a/src/gallium/drivers/virgl/tests/meson.build +++ b/src/gallium/drivers/virgl/tests/meson.build @@ -24,7 +24,7 @@ test( 'virgl_staging_mgr_test', files('virgl_staging_mgr_test.cpp'), dependencies : [dep_thread, idep_gtest], - include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, include_directories('..')], + include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_virtio, include_directories('..')], link_with : [libvirgl, libgallium], ), suite : ['virgl'], diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c index e2698b9845e..4fabc89b1bd 100644 --- a/src/gallium/drivers/virgl/virgl_context.c +++ b/src/gallium/drivers/virgl/virgl_context.c @@ -44,7 +44,7 @@ #include "virgl_encode.h" #include "virgl_context.h" -#include "virgl_protocol.h" +#include "virtio-gpu/virgl_protocol.h" #include "virgl_resource.h" #include "virgl_screen.h" #include "virgl_staging_mgr.h" diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c index 8e65a90d40d..2d1b91a4300 100644 --- a/src/gallium/drivers/virgl/virgl_encode.c +++ b/src/gallium/drivers/virgl/virgl_encode.c @@ -33,7 +33,7 @@ #include "virgl_context.h" #include "virgl_encode.h" -#include "virgl_protocol.h" +#include "virtio-gpu/virgl_protocol.h" #include "virgl_resource.h" #include "virgl_screen.h" diff --git a/src/gallium/drivers/virgl/virgl_encode.h b/src/gallium/drivers/virgl/virgl_encode.h index 385b8ed262e..2b87fb943b0 100644 --- a/src/gallium/drivers/virgl/virgl_encode.h +++ b/src/gallium/drivers/virgl/virgl_encode.h @@ -27,7 +27,7 @@ #include "pipe/p_state.h" #include "virgl_winsys.h" -#include "virgl_protocol.h" +#include "virtio-gpu/virgl_protocol.h" struct tgsi_token; diff --git a/src/gallium/drivers/virgl/virgl_hw.h b/src/gallium/drivers/virgl/virgl_hw.h deleted file mode 100644 index bbf5f5f7519..00000000000 --- a/src/gallium/drivers/virgl/virgl_hw.h +++ /dev/null @@ -1,510 +0,0 @@ -/* - * Copyright 2014, 2015 Red Hat. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -#ifndef VIRGL_HW_H -#define VIRGL_HW_H - -#include - -struct virgl_box { - uint32_t x, y, z; - uint32_t w, h, d; -}; - -/* formats known by the HW device - based on gallium subset */ -enum virgl_formats { - VIRGL_FORMAT_B8G8R8A8_UNORM = 1, - VIRGL_FORMAT_B8G8R8X8_UNORM = 2, - VIRGL_FORMAT_A8R8G8B8_UNORM = 3, - VIRGL_FORMAT_X8R8G8B8_UNORM = 4, - VIRGL_FORMAT_B5G5R5A1_UNORM = 5, - VIRGL_FORMAT_B4G4R4A4_UNORM = 6, - VIRGL_FORMAT_B5G6R5_UNORM = 7, - VIRGL_FORMAT_R10G10B10A2_UNORM = 8, - VIRGL_FORMAT_L8_UNORM = 9, /**< ubyte luminance */ - VIRGL_FORMAT_A8_UNORM = 10, /**< ubyte alpha */ - VIRGL_FORMAT_L8A8_UNORM = 12, /**< ubyte alpha, luminance */ - VIRGL_FORMAT_L16_UNORM = 13, /**< ushort luminance */ - - VIRGL_FORMAT_Z16_UNORM = 16, - VIRGL_FORMAT_Z32_UNORM = 17, - VIRGL_FORMAT_Z32_FLOAT = 18, - VIRGL_FORMAT_Z24_UNORM_S8_UINT = 19, - VIRGL_FORMAT_S8_UINT_Z24_UNORM = 20, - VIRGL_FORMAT_Z24X8_UNORM = 21, - VIRGL_FORMAT_X8Z24_UNORM = 22, - VIRGL_FORMAT_S8_UINT = 23, /**< ubyte stencil */ - VIRGL_FORMAT_R64_FLOAT = 24, - VIRGL_FORMAT_R64G64_FLOAT = 25, - VIRGL_FORMAT_R64G64B64_FLOAT = 26, - VIRGL_FORMAT_R64G64B64A64_FLOAT = 27, - VIRGL_FORMAT_R32_FLOAT = 28, - VIRGL_FORMAT_R32G32_FLOAT = 29, - VIRGL_FORMAT_R32G32B32_FLOAT = 30, - VIRGL_FORMAT_R32G32B32A32_FLOAT = 31, - - VIRGL_FORMAT_R32_UNORM = 32, - VIRGL_FORMAT_R32G32_UNORM = 33, - VIRGL_FORMAT_R32G32B32_UNORM = 34, - VIRGL_FORMAT_R32G32B32A32_UNORM = 35, - VIRGL_FORMAT_R32_USCALED = 36, - VIRGL_FORMAT_R32G32_USCALED = 37, - VIRGL_FORMAT_R32G32B32_USCALED = 38, - VIRGL_FORMAT_R32G32B32A32_USCALED = 39, - VIRGL_FORMAT_R32_SNORM = 40, - VIRGL_FORMAT_R32G32_SNORM = 41, - VIRGL_FORMAT_R32G32B32_SNORM = 42, - VIRGL_FORMAT_R32G32B32A32_SNORM = 43, - VIRGL_FORMAT_R32_SSCALED = 44, - VIRGL_FORMAT_R32G32_SSCALED = 45, - VIRGL_FORMAT_R32G32B32_SSCALED = 46, - VIRGL_FORMAT_R32G32B32A32_SSCALED = 47, - - VIRGL_FORMAT_R16_UNORM = 48, - VIRGL_FORMAT_R16G16_UNORM = 49, - VIRGL_FORMAT_R16G16B16_UNORM = 50, - VIRGL_FORMAT_R16G16B16A16_UNORM = 51, - - VIRGL_FORMAT_R16_USCALED = 52, - VIRGL_FORMAT_R16G16_USCALED = 53, - VIRGL_FORMAT_R16G16B16_USCALED = 54, - VIRGL_FORMAT_R16G16B16A16_USCALED = 55, - - VIRGL_FORMAT_R16_SNORM = 56, - VIRGL_FORMAT_R16G16_SNORM = 57, - VIRGL_FORMAT_R16G16B16_SNORM = 58, - VIRGL_FORMAT_R16G16B16A16_SNORM = 59, - - VIRGL_FORMAT_R16_SSCALED = 60, - VIRGL_FORMAT_R16G16_SSCALED = 61, - VIRGL_FORMAT_R16G16B16_SSCALED = 62, - VIRGL_FORMAT_R16G16B16A16_SSCALED = 63, - - VIRGL_FORMAT_R8_UNORM = 64, - VIRGL_FORMAT_R8G8_UNORM = 65, - VIRGL_FORMAT_R8G8B8_UNORM = 66, - VIRGL_FORMAT_R8G8B8A8_UNORM = 67, - - VIRGL_FORMAT_R8_USCALED = 69, - VIRGL_FORMAT_R8G8_USCALED = 70, - VIRGL_FORMAT_R8G8B8_USCALED = 71, - VIRGL_FORMAT_R8G8B8A8_USCALED = 72, - - VIRGL_FORMAT_R8_SNORM = 74, - VIRGL_FORMAT_R8G8_SNORM = 75, - VIRGL_FORMAT_R8G8B8_SNORM = 76, - VIRGL_FORMAT_R8G8B8A8_SNORM = 77, - - VIRGL_FORMAT_R8_SSCALED = 82, - VIRGL_FORMAT_R8G8_SSCALED = 83, - VIRGL_FORMAT_R8G8B8_SSCALED = 84, - VIRGL_FORMAT_R8G8B8A8_SSCALED = 85, - - VIRGL_FORMAT_R16_FLOAT = 91, - VIRGL_FORMAT_R16G16_FLOAT = 92, - VIRGL_FORMAT_R16G16B16_FLOAT = 93, - VIRGL_FORMAT_R16G16B16A16_FLOAT = 94, - - VIRGL_FORMAT_L8_SRGB = 95, - VIRGL_FORMAT_L8A8_SRGB = 96, - VIRGL_FORMAT_R8G8B8_SRGB = 97, - VIRGL_FORMAT_A8B8G8R8_SRGB = 98, - VIRGL_FORMAT_X8B8G8R8_SRGB = 99, - VIRGL_FORMAT_B8G8R8A8_SRGB = 100, - VIRGL_FORMAT_B8G8R8X8_SRGB = 101, - VIRGL_FORMAT_A8R8G8B8_SRGB = 102, - VIRGL_FORMAT_X8R8G8B8_SRGB = 103, - VIRGL_FORMAT_R8G8B8A8_SRGB = 104, - - /* compressed formats */ - VIRGL_FORMAT_DXT1_RGB = 105, - VIRGL_FORMAT_DXT1_RGBA = 106, - VIRGL_FORMAT_DXT3_RGBA = 107, - VIRGL_FORMAT_DXT5_RGBA = 108, - - /* sRGB, compressed */ - VIRGL_FORMAT_DXT1_SRGB = 109, - VIRGL_FORMAT_DXT1_SRGBA = 110, - VIRGL_FORMAT_DXT3_SRGBA = 111, - VIRGL_FORMAT_DXT5_SRGBA = 112, - - /* rgtc compressed */ - VIRGL_FORMAT_RGTC1_UNORM = 113, - VIRGL_FORMAT_RGTC1_SNORM = 114, - VIRGL_FORMAT_RGTC2_UNORM = 115, - VIRGL_FORMAT_RGTC2_SNORM = 116, - - VIRGL_FORMAT_A8B8G8R8_UNORM = 121, - VIRGL_FORMAT_B5G5R5X1_UNORM = 122, - VIRGL_FORMAT_R10G10B10A2_USCALED = 123, - VIRGL_FORMAT_R11G11B10_FLOAT = 124, - VIRGL_FORMAT_R9G9B9E5_FLOAT = 125, - VIRGL_FORMAT_Z32_FLOAT_S8X24_UINT = 126, - - VIRGL_FORMAT_B10G10R10A2_UNORM = 131, - VIRGL_FORMAT_R8G8B8X8_UNORM = 134, - VIRGL_FORMAT_B4G4R4X4_UNORM = 135, - VIRGL_FORMAT_X24S8_UINT = 136, - VIRGL_FORMAT_S8X24_UINT = 137, - VIRGL_FORMAT_X32_S8X24_UINT = 138, - VIRGL_FORMAT_B2G3R3_UNORM = 139, - - VIRGL_FORMAT_L16A16_UNORM = 140, - VIRGL_FORMAT_A16_UNORM = 141, - VIRGL_FORMAT_I16_UNORM = 142, - - VIRGL_FORMAT_LATC1_UNORM = 143, - VIRGL_FORMAT_LATC1_SNORM = 144, - VIRGL_FORMAT_LATC2_UNORM = 145, - VIRGL_FORMAT_LATC2_SNORM = 146, - - VIRGL_FORMAT_A8_SNORM = 147, - VIRGL_FORMAT_L8_SNORM = 148, - VIRGL_FORMAT_L8A8_SNORM = 149, - - VIRGL_FORMAT_A16_SNORM = 151, - VIRGL_FORMAT_L16_SNORM = 152, - VIRGL_FORMAT_L16A16_SNORM = 153, - - VIRGL_FORMAT_A16_FLOAT = 155, - VIRGL_FORMAT_L16_FLOAT = 156, - VIRGL_FORMAT_L16A16_FLOAT = 157, - - VIRGL_FORMAT_A32_FLOAT = 159, - VIRGL_FORMAT_L32_FLOAT = 160, - VIRGL_FORMAT_L32A32_FLOAT = 161, - - VIRGL_FORMAT_YV12 = 163, - VIRGL_FORMAT_YV16 = 164, - VIRGL_FORMAT_IYUV = 165, /**< aka I420 */ - VIRGL_FORMAT_NV12 = 166, - VIRGL_FORMAT_NV21 = 167, - - VIRGL_FORMAT_R10G10B10A2_SSCALED = 172, - VIRGL_FORMAT_R10G10B10A2_SNORM = 173, - VIRGL_FORMAT_B10G10R10A2_SNORM = 176, - - VIRGL_FORMAT_R8_UINT = 177, - VIRGL_FORMAT_R8G8_UINT = 178, - VIRGL_FORMAT_R8G8B8_UINT = 179, - VIRGL_FORMAT_R8G8B8A8_UINT = 180, - - VIRGL_FORMAT_R8_SINT = 181, - VIRGL_FORMAT_R8G8_SINT = 182, - VIRGL_FORMAT_R8G8B8_SINT = 183, - VIRGL_FORMAT_R8G8B8A8_SINT = 184, - - VIRGL_FORMAT_R16_UINT = 185, - VIRGL_FORMAT_R16G16_UINT = 186, - VIRGL_FORMAT_R16G16B16_UINT = 187, - VIRGL_FORMAT_R16G16B16A16_UINT = 188, - - VIRGL_FORMAT_R16_SINT = 189, - VIRGL_FORMAT_R16G16_SINT = 190, - VIRGL_FORMAT_R16G16B16_SINT = 191, - VIRGL_FORMAT_R16G16B16A16_SINT = 192, - VIRGL_FORMAT_R32_UINT = 193, - VIRGL_FORMAT_R32G32_UINT = 194, - VIRGL_FORMAT_R32G32B32_UINT = 195, - VIRGL_FORMAT_R32G32B32A32_UINT = 196, - - VIRGL_FORMAT_R32_SINT = 197, - VIRGL_FORMAT_R32G32_SINT = 198, - VIRGL_FORMAT_R32G32B32_SINT = 199, - VIRGL_FORMAT_R32G32B32A32_SINT = 200, - - VIRGL_FORMAT_A8_UINT = 201, - VIRGL_FORMAT_L8_UINT = 203, - VIRGL_FORMAT_L8A8_UINT = 204, - - VIRGL_FORMAT_A8_SINT = 205, - VIRGL_FORMAT_L8_SINT = 207, - VIRGL_FORMAT_L8A8_SINT = 208, - - VIRGL_FORMAT_A16_UINT = 209, - VIRGL_FORMAT_L16_UINT = 211, - VIRGL_FORMAT_L16A16_UINT = 212, - - VIRGL_FORMAT_A16_SINT = 213, - VIRGL_FORMAT_L16_SINT = 215, - VIRGL_FORMAT_L16A16_SINT = 216, - - VIRGL_FORMAT_A32_UINT = 217, - VIRGL_FORMAT_L32_UINT = 219, - VIRGL_FORMAT_L32A32_UINT = 220, - - VIRGL_FORMAT_A32_SINT = 221, - VIRGL_FORMAT_L32_SINT = 223, - VIRGL_FORMAT_L32A32_SINT = 224, - - VIRGL_FORMAT_B10G10R10A2_UINT = 225, - VIRGL_FORMAT_R8G8B8X8_SNORM = 229, - - VIRGL_FORMAT_R8G8B8X8_SRGB = 230, - - VIRGL_FORMAT_R8G8B8X8_UINT = 231, - VIRGL_FORMAT_R8G8B8X8_SINT = 232, - VIRGL_FORMAT_B10G10R10X2_UNORM = 233, - VIRGL_FORMAT_R16G16B16X16_UNORM = 234, - VIRGL_FORMAT_R16G16B16X16_SNORM = 235, - VIRGL_FORMAT_R16G16B16X16_FLOAT = 236, - VIRGL_FORMAT_R16G16B16X16_UINT = 237, - VIRGL_FORMAT_R16G16B16X16_SINT = 238, - VIRGL_FORMAT_R32G32B32X32_FLOAT = 239, - VIRGL_FORMAT_R32G32B32X32_UINT = 240, - VIRGL_FORMAT_R32G32B32X32_SINT = 241, - - VIRGL_FORMAT_R10G10B10A2_UINT = 253, - - VIRGL_FORMAT_BPTC_RGBA_UNORM = 255, - VIRGL_FORMAT_BPTC_SRGBA = 256, - VIRGL_FORMAT_BPTC_RGB_FLOAT = 257, - VIRGL_FORMAT_BPTC_RGB_UFLOAT = 258, - - /* etc2 compressed */ - VIRGL_FORMAT_ETC2_RGB8 = 269, - VIRGL_FORMAT_ETC2_SRGB8 = 270, - VIRGL_FORMAT_ETC2_RGB8A1 = 271, - VIRGL_FORMAT_ETC2_SRGB8A1 = 272, - VIRGL_FORMAT_ETC2_RGBA8 = 273, - VIRGL_FORMAT_ETC2_SRGBA8 = 274, - VIRGL_FORMAT_ETC2_R11_UNORM = 275, - VIRGL_FORMAT_ETC2_R11_SNORM = 276, - VIRGL_FORMAT_ETC2_RG11_UNORM = 277, - VIRGL_FORMAT_ETC2_RG11_SNORM = 278, - - VIRGL_FORMAT_R10G10B10X2_UNORM = 308, - VIRGL_FORMAT_A4B4G4R4_UNORM = 311, - - VIRGL_FORMAT_R8_SRGB = 312, - VIRGL_FORMAT_MAX /* = PIPE_FORMAT_COUNT */, - - /* Below formats must not be used in the guest. */ - VIRGL_FORMAT_B8G8R8X8_UNORM_EMULATED, - VIRGL_FORMAT_B8G8R8A8_UNORM_EMULATED, - VIRGL_FORMAT_MAX_EXTENDED -}; - -/* These are used by the capability_bits field in virgl_caps_v2. */ -#define VIRGL_CAP_NONE 0 -#define VIRGL_CAP_TGSI_INVARIANT (1 << 0) -#define VIRGL_CAP_TEXTURE_VIEW (1 << 1) -#define VIRGL_CAP_SET_MIN_SAMPLES (1 << 2) -#define VIRGL_CAP_COPY_IMAGE (1 << 3) -#define VIRGL_CAP_TGSI_PRECISE (1 << 4) -#define VIRGL_CAP_TXQS (1 << 5) -#define VIRGL_CAP_MEMORY_BARRIER (1 << 6) -#define VIRGL_CAP_COMPUTE_SHADER (1 << 7) -#define VIRGL_CAP_FB_NO_ATTACH (1 << 8) -#define VIRGL_CAP_ROBUST_BUFFER_ACCESS (1 << 9) -#define VIRGL_CAP_TGSI_FBFETCH (1 << 10) -#define VIRGL_CAP_SHADER_CLOCK (1 << 11) -#define VIRGL_CAP_TEXTURE_BARRIER (1 << 12) -#define VIRGL_CAP_TGSI_COMPONENTS (1 << 13) -#define VIRGL_CAP_GUEST_MAY_INIT_LOG (1 << 14) -#define VIRGL_CAP_SRGB_WRITE_CONTROL (1 << 15) -#define VIRGL_CAP_QBO (1 << 16) -#define VIRGL_CAP_TRANSFER (1 << 17) -#define VIRGL_CAP_FBO_MIXED_COLOR_FORMATS (1 << 18) -#define VIRGL_CAP_FAKE_FP64 (1 << 19) -#define VIRGL_CAP_BIND_COMMAND_ARGS (1 << 20) -#define VIRGL_CAP_MULTI_DRAW_INDIRECT (1 << 21) -#define VIRGL_CAP_INDIRECT_PARAMS (1 << 22) -#define VIRGL_CAP_TRANSFORM_FEEDBACK3 (1 << 23) -#define VIRGL_CAP_3D_ASTC (1 << 24) -#define VIRGL_CAP_INDIRECT_INPUT_ADDR (1 << 25) -#define VIRGL_CAP_COPY_TRANSFER (1 << 26) -#define VIRGL_CAP_CLIP_HALFZ (1 << 27) -#define VIRGL_CAP_APP_TWEAK_SUPPORT (1 << 28) -#define VIRGL_CAP_BGRA_SRGB_IS_EMULATED (1 << 29) -#define VIRGL_CAP_CLEAR_TEXTURE (1 << 30) -/* Reserved for VIRGL_CAP_ARB_BUFFER_STORAGE */ - -/* These are used by the capability_bits_v2 field in virgl_caps_v2. */ -#define VIRGL_CAP_V2_BLEND_EQUATION (1 << 0) - -/* virgl bind flags - these are compatible with mesa 10.5 gallium. - * but are fixed, no other should be passed to virgl either. - */ -#define VIRGL_BIND_DEPTH_STENCIL (1 << 0) -#define VIRGL_BIND_RENDER_TARGET (1 << 1) -#define VIRGL_BIND_SAMPLER_VIEW (1 << 3) -#define VIRGL_BIND_VERTEX_BUFFER (1 << 4) -#define VIRGL_BIND_INDEX_BUFFER (1 << 5) -#define VIRGL_BIND_CONSTANT_BUFFER (1 << 6) -#define VIRGL_BIND_DISPLAY_TARGET (1 << 7) -#define VIRGL_BIND_COMMAND_ARGS (1 << 8) -#define VIRGL_BIND_STREAM_OUTPUT (1 << 11) -#define VIRGL_BIND_SHADER_BUFFER (1 << 14) -#define VIRGL_BIND_QUERY_BUFFER (1 << 15) -#define VIRGL_BIND_CURSOR (1 << 16) -#define VIRGL_BIND_CUSTOM (1 << 17) -#define VIRGL_BIND_SCANOUT (1 << 18) -/* Used for buffers that are backed by guest storage and - * are only read by the host. - */ -#define VIRGL_BIND_STAGING (1 << 19) -#define VIRGL_BIND_SHARED (1 << 20) - -/* Extra flags that may be passed */ -#define VIRGL_BIND_PREFER_EMULATED_BGRA (1 << 21) - -struct virgl_caps_bool_set1 { - unsigned indep_blend_enable:1; - unsigned indep_blend_func:1; - unsigned cube_map_array:1; - unsigned shader_stencil_export:1; - unsigned conditional_render:1; - unsigned start_instance:1; - unsigned primitive_restart:1; - unsigned blend_eq_sep:1; - unsigned instanceid:1; - unsigned vertex_element_instance_divisor:1; - unsigned seamless_cube_map:1; - unsigned occlusion_query:1; - unsigned timer_query:1; - unsigned streamout_pause_resume:1; - unsigned texture_multisample:1; - unsigned fragment_coord_conventions:1; - unsigned depth_clip_disable:1; - unsigned seamless_cube_map_per_texture:1; - unsigned ubo:1; - unsigned color_clamping:1; /* not in GL 3.1 core profile */ - unsigned poly_stipple:1; /* not in GL 3.1 core profile */ - unsigned mirror_clamp:1; - unsigned texture_query_lod:1; - unsigned has_fp64:1; - unsigned has_tessellation_shaders:1; - unsigned has_indirect_draw:1; - unsigned has_sample_shading:1; - unsigned has_cull:1; - unsigned conditional_render_inverted:1; - unsigned derivative_control:1; - unsigned polygon_offset_clamp:1; - unsigned transform_feedback_overflow_query:1; - /* DO NOT ADD ANYMORE MEMBERS - need to add another 32-bit to v2 caps */ -}; - -/* endless expansion capabilites - current gallium has 252 formats */ -struct virgl_supported_format_mask { - uint32_t bitmask[16]; -}; -/* capabilities set 2 - version 1 - 32-bit and float values */ -struct virgl_caps_v1 { - uint32_t max_version; - struct virgl_supported_format_mask sampler; - struct virgl_supported_format_mask render; - struct virgl_supported_format_mask depthstencil; - struct virgl_supported_format_mask vertexbuffer; - struct virgl_caps_bool_set1 bset; - uint32_t glsl_level; - uint32_t max_texture_array_layers; - uint32_t max_streamout_buffers; - uint32_t max_dual_source_render_targets; - uint32_t max_render_targets; - uint32_t max_samples; - uint32_t prim_mask; - uint32_t max_tbo_size; - uint32_t max_uniform_blocks; - uint32_t max_viewports; - uint32_t max_texture_gather_components; -}; - -/* - * This struct should be growable when used in capset 2, - * so we shouldn't have to add a v3 ever. - */ -struct virgl_caps_v2 { - struct virgl_caps_v1 v1; - float min_aliased_point_size; - float max_aliased_point_size; - float min_smooth_point_size; - float max_smooth_point_size; - float min_aliased_line_width; - float max_aliased_line_width; - float min_smooth_line_width; - float max_smooth_line_width; - float max_texture_lod_bias; - uint32_t max_geom_output_vertices; - uint32_t max_geom_total_output_components; - uint32_t max_vertex_outputs; - uint32_t max_vertex_attribs; - uint32_t max_shader_patch_varyings; - int32_t min_texel_offset; - int32_t max_texel_offset; - int32_t min_texture_gather_offset; - int32_t max_texture_gather_offset; - uint32_t texture_buffer_offset_alignment; - uint32_t uniform_buffer_offset_alignment; - uint32_t shader_buffer_offset_alignment; - uint32_t capability_bits; - uint32_t sample_locations[8]; - uint32_t max_vertex_attrib_stride; - uint32_t max_shader_buffer_frag_compute; - uint32_t max_shader_buffer_other_stages; - uint32_t max_shader_image_frag_compute; - uint32_t max_shader_image_other_stages; - uint32_t max_image_samples; - uint32_t max_compute_work_group_invocations; - uint32_t max_compute_shared_memory_size; - uint32_t max_compute_grid_size[3]; - uint32_t max_compute_block_size[3]; - uint32_t max_texture_2d_size; - uint32_t max_texture_3d_size; - uint32_t max_texture_cube_size; - uint32_t max_combined_shader_buffers; - uint32_t max_atomic_counters[6]; - uint32_t max_atomic_counter_buffers[6]; - uint32_t max_combined_atomic_counters; - uint32_t max_combined_atomic_counter_buffers; - uint32_t host_feature_check_version; - struct virgl_supported_format_mask supported_readback_formats; - struct virgl_supported_format_mask scanout; - uint32_t capability_bits_v2; -}; - -union virgl_caps { - uint32_t max_version; - struct virgl_caps_v1 v1; - struct virgl_caps_v2 v2; -}; - -enum virgl_errors { - VIRGL_ERROR_NONE, - VIRGL_ERROR_UNKNOWN, - VIRGL_ERROR_UNKNOWN_RESOURCE_FORMAT, -}; - -enum virgl_ctx_errors { - VIRGL_ERROR_CTX_NONE, - VIRGL_ERROR_CTX_UNKNOWN, - VIRGL_ERROR_CTX_ILLEGAL_SHADER, - VIRGL_ERROR_CTX_ILLEGAL_HANDLE, - VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, - VIRGL_ERROR_CTX_ILLEGAL_SURFACE, - VIRGL_ERROR_CTX_ILLEGAL_VERTEX_FORMAT, - VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, - VIRGL_ERROR_CTX_GLES_HAVE_TES_BUT_MISS_TCS, -}; - -#define VIRGL_RESOURCE_Y_0_TOP (1 << 0) -#endif diff --git a/src/gallium/drivers/virgl/virgl_protocol.h b/src/gallium/drivers/virgl/virgl_protocol.h deleted file mode 100644 index 0139abd825b..00000000000 --- a/src/gallium/drivers/virgl/virgl_protocol.h +++ /dev/null @@ -1,617 +0,0 @@ -/* - * Copyright 2014, 2015 Red Hat. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -#ifndef VIRGL_PROTOCOL_H -#define VIRGL_PROTOCOL_H - -#define VIRGL_QUERY_STATE_NEW 0 -#define VIRGL_QUERY_STATE_DONE 1 -#define VIRGL_QUERY_STATE_WAIT_HOST 2 - -struct virgl_host_query_state { - uint32_t query_state; - uint32_t result_size; - uint64_t result; -}; - -enum virgl_object_type { - VIRGL_OBJECT_NULL, - VIRGL_OBJECT_BLEND, - VIRGL_OBJECT_RASTERIZER, - VIRGL_OBJECT_DSA, - VIRGL_OBJECT_SHADER, - VIRGL_OBJECT_VERTEX_ELEMENTS, - VIRGL_OBJECT_SAMPLER_VIEW, - VIRGL_OBJECT_SAMPLER_STATE, - VIRGL_OBJECT_SURFACE, - VIRGL_OBJECT_QUERY, - VIRGL_OBJECT_STREAMOUT_TARGET, - VIRGL_MAX_OBJECTS, -}; - -/* context cmds to be encoded in the command stream */ -enum virgl_context_cmd { - VIRGL_CCMD_NOP = 0, - VIRGL_CCMD_CREATE_OBJECT = 1, - VIRGL_CCMD_BIND_OBJECT, - VIRGL_CCMD_DESTROY_OBJECT, - VIRGL_CCMD_SET_VIEWPORT_STATE, - VIRGL_CCMD_SET_FRAMEBUFFER_STATE, - VIRGL_CCMD_SET_VERTEX_BUFFERS, - VIRGL_CCMD_CLEAR, - VIRGL_CCMD_DRAW_VBO, - VIRGL_CCMD_RESOURCE_INLINE_WRITE, - VIRGL_CCMD_SET_SAMPLER_VIEWS, - VIRGL_CCMD_SET_INDEX_BUFFER, - VIRGL_CCMD_SET_CONSTANT_BUFFER, - VIRGL_CCMD_SET_STENCIL_REF, - VIRGL_CCMD_SET_BLEND_COLOR, - VIRGL_CCMD_SET_SCISSOR_STATE, - VIRGL_CCMD_BLIT, - VIRGL_CCMD_RESOURCE_COPY_REGION, - VIRGL_CCMD_BIND_SAMPLER_STATES, - VIRGL_CCMD_BEGIN_QUERY, - VIRGL_CCMD_END_QUERY, - VIRGL_CCMD_GET_QUERY_RESULT, - VIRGL_CCMD_SET_POLYGON_STIPPLE, - VIRGL_CCMD_SET_CLIP_STATE, - VIRGL_CCMD_SET_SAMPLE_MASK, - VIRGL_CCMD_SET_STREAMOUT_TARGETS, - VIRGL_CCMD_SET_RENDER_CONDITION, - VIRGL_CCMD_SET_UNIFORM_BUFFER, - - VIRGL_CCMD_SET_SUB_CTX, - VIRGL_CCMD_CREATE_SUB_CTX, - VIRGL_CCMD_DESTROY_SUB_CTX, - VIRGL_CCMD_BIND_SHADER, - VIRGL_CCMD_SET_TESS_STATE, - VIRGL_CCMD_SET_MIN_SAMPLES, - VIRGL_CCMD_SET_SHADER_BUFFERS, - VIRGL_CCMD_SET_SHADER_IMAGES, - VIRGL_CCMD_MEMORY_BARRIER, - VIRGL_CCMD_LAUNCH_GRID, - VIRGL_CCMD_SET_FRAMEBUFFER_STATE_NO_ATTACH, - VIRGL_CCMD_TEXTURE_BARRIER, - VIRGL_CCMD_SET_ATOMIC_BUFFERS, - VIRGL_CCMD_SET_DEBUG_FLAGS, - VIRGL_CCMD_GET_QUERY_RESULT_QBO, - VIRGL_CCMD_TRANSFER3D, - VIRGL_CCMD_END_TRANSFERS, - VIRGL_CCMD_COPY_TRANSFER3D, - VIRGL_CCMD_SET_TWEAKS, - VIRGL_CCMD_CLEAR_TEXTURE, -}; - -/* - 8-bit cmd headers - 8-bit object type - 16-bit length -*/ - -#define VIRGL_CMD0(cmd, obj, len) ((cmd) | ((obj) << 8) | ((len) << 16)) -#define VIRGL_CMD0_MAX_DWORDS (((1ULL << 16) - 1) / 4) * 4 - -/* hw specification */ -#define VIRGL_MAX_COLOR_BUFS 8 -#define VIRGL_MAX_CLIP_PLANES 8 - -#define VIRGL_OBJ_CREATE_HEADER 0 -#define VIRGL_OBJ_CREATE_HANDLE 1 - -#define VIRGL_OBJ_BIND_HEADER 0 -#define VIRGL_OBJ_BIND_HANDLE 1 - -#define VIRGL_OBJ_DESTROY_HANDLE 1 - -/* some of these defines are a specification - not used in the code */ -/* bit offsets for blend state object */ -#define VIRGL_OBJ_BLEND_SIZE (VIRGL_MAX_COLOR_BUFS + 3) -#define VIRGL_OBJ_BLEND_HANDLE 1 -#define VIRGL_OBJ_BLEND_S0 2 -#define VIRGL_OBJ_BLEND_S0_INDEPENDENT_BLEND_ENABLE(x) ((x) & 0x1 << 0) -#define VIRGL_OBJ_BLEND_S0_LOGICOP_ENABLE(x) (((x) & 0x1) << 1) -#define VIRGL_OBJ_BLEND_S0_DITHER(x) (((x) & 0x1) << 2) -#define VIRGL_OBJ_BLEND_S0_ALPHA_TO_COVERAGE(x) (((x) & 0x1) << 3) -#define VIRGL_OBJ_BLEND_S0_ALPHA_TO_ONE(x) (((x) & 0x1) << 4) -#define VIRGL_OBJ_BLEND_S1 3 -#define VIRGL_OBJ_BLEND_S1_LOGICOP_FUNC(x) (((x) & 0xf) << 0) -/* repeated once per number of cbufs */ - -#define VIRGL_OBJ_BLEND_S2(cbuf) (4 + (cbuf)) -#define VIRGL_OBJ_BLEND_S2_RT_BLEND_ENABLE(x) (((x) & 0x1) << 0) -#define VIRGL_OBJ_BLEND_S2_RT_RGB_FUNC(x) (((x) & 0x7) << 1) -#define VIRGL_OBJ_BLEND_S2_RT_RGB_SRC_FACTOR(x) (((x) & 0x1f) << 4) -#define VIRGL_OBJ_BLEND_S2_RT_RGB_DST_FACTOR(x) (((x) & 0x1f) << 9) -#define VIRGL_OBJ_BLEND_S2_RT_ALPHA_FUNC(x) (((x) & 0x7) << 14) -#define VIRGL_OBJ_BLEND_S2_RT_ALPHA_SRC_FACTOR(x) (((x) & 0x1f) << 17) -#define VIRGL_OBJ_BLEND_S2_RT_ALPHA_DST_FACTOR(x) (((x) & 0x1f) << 22) -#define VIRGL_OBJ_BLEND_S2_RT_COLORMASK(x) (((x) & 0xf) << 27) - -/* bit offsets for DSA state */ -#define VIRGL_OBJ_DSA_SIZE 5 -#define VIRGL_OBJ_DSA_HANDLE 1 -#define VIRGL_OBJ_DSA_S0 2 -#define VIRGL_OBJ_DSA_S0_DEPTH_ENABLE(x) (((x) & 0x1) << 0) -#define VIRGL_OBJ_DSA_S0_DEPTH_WRITEMASK(x) (((x) & 0x1) << 1) -#define VIRGL_OBJ_DSA_S0_DEPTH_FUNC(x) (((x) & 0x7) << 2) -#define VIRGL_OBJ_DSA_S0_ALPHA_ENABLED(x) (((x) & 0x1) << 8) -#define VIRGL_OBJ_DSA_S0_ALPHA_FUNC(x) (((x) & 0x7) << 9) -#define VIRGL_OBJ_DSA_S1 3 -#define VIRGL_OBJ_DSA_S2 4 -#define VIRGL_OBJ_DSA_S1_STENCIL_ENABLED(x) (((x) & 0x1) << 0) -#define VIRGL_OBJ_DSA_S1_STENCIL_FUNC(x) (((x) & 0x7) << 1) -#define VIRGL_OBJ_DSA_S1_STENCIL_FAIL_OP(x) (((x) & 0x7) << 4) -#define VIRGL_OBJ_DSA_S1_STENCIL_ZPASS_OP(x) (((x) & 0x7) << 7) -#define VIRGL_OBJ_DSA_S1_STENCIL_ZFAIL_OP(x) (((x) & 0x7) << 10) -#define VIRGL_OBJ_DSA_S1_STENCIL_VALUEMASK(x) (((x) & 0xff) << 13) -#define VIRGL_OBJ_DSA_S1_STENCIL_WRITEMASK(x) (((x) & 0xff) << 21) -#define VIRGL_OBJ_DSA_ALPHA_REF 5 - -/* offsets for rasterizer state */ -#define VIRGL_OBJ_RS_SIZE 9 -#define VIRGL_OBJ_RS_HANDLE 1 -#define VIRGL_OBJ_RS_S0 2 -#define VIRGL_OBJ_RS_S0_FLATSHADE(x) (((x) & 0x1) << 0) -#define VIRGL_OBJ_RS_S0_DEPTH_CLIP(x) (((x) & 0x1) << 1) -#define VIRGL_OBJ_RS_S0_CLIP_HALFZ(x) (((x) & 0x1) << 2) -#define VIRGL_OBJ_RS_S0_RASTERIZER_DISCARD(x) (((x) & 0x1) << 3) -#define VIRGL_OBJ_RS_S0_FLATSHADE_FIRST(x) (((x) & 0x1) << 4) -#define VIRGL_OBJ_RS_S0_LIGHT_TWOSIZE(x) (((x) & 0x1) << 5) -#define VIRGL_OBJ_RS_S0_SPRITE_COORD_MODE(x) (((x) & 0x1) << 6) -#define VIRGL_OBJ_RS_S0_POINT_QUAD_RASTERIZATION(x) (((x) & 0x1) << 7) -#define VIRGL_OBJ_RS_S0_CULL_FACE(x) (((x) & 0x3) << 8) -#define VIRGL_OBJ_RS_S0_FILL_FRONT(x) (((x) & 0x3) << 10) -#define VIRGL_OBJ_RS_S0_FILL_BACK(x) (((x) & 0x3) << 12) -#define VIRGL_OBJ_RS_S0_SCISSOR(x) (((x) & 0x1) << 14) -#define VIRGL_OBJ_RS_S0_FRONT_CCW(x) (((x) & 0x1) << 15) -#define VIRGL_OBJ_RS_S0_CLAMP_VERTEX_COLOR(x) (((x) & 0x1) << 16) -#define VIRGL_OBJ_RS_S0_CLAMP_FRAGMENT_COLOR(x) (((x) & 0x1) << 17) -#define VIRGL_OBJ_RS_S0_OFFSET_LINE(x) (((x) & 0x1) << 18) -#define VIRGL_OBJ_RS_S0_OFFSET_POINT(x) (((x) & 0x1) << 19) -#define VIRGL_OBJ_RS_S0_OFFSET_TRI(x) (((x) & 0x1) << 20) -#define VIRGL_OBJ_RS_S0_POLY_SMOOTH(x) (((x) & 0x1) << 21) -#define VIRGL_OBJ_RS_S0_POLY_STIPPLE_ENABLE(x) (((x) & 0x1) << 22) -#define VIRGL_OBJ_RS_S0_POINT_SMOOTH(x) (((x) & 0x1) << 23) -#define VIRGL_OBJ_RS_S0_POINT_SIZE_PER_VERTEX(x) (((x) & 0x1) << 24) -#define VIRGL_OBJ_RS_S0_MULTISAMPLE(x) (((x) & 0x1) << 25) -#define VIRGL_OBJ_RS_S0_LINE_SMOOTH(x) (((x) & 0x1) << 26) -#define VIRGL_OBJ_RS_S0_LINE_STIPPLE_ENABLE(x) (((x) & 0x1) << 27) -#define VIRGL_OBJ_RS_S0_LINE_LAST_PIXEL(x) (((x) & 0x1) << 28) -#define VIRGL_OBJ_RS_S0_HALF_PIXEL_CENTER(x) (((x) & 0x1) << 29) -#define VIRGL_OBJ_RS_S0_BOTTOM_EDGE_RULE(x) (((x) & 0x1) << 30) -#define VIRGL_OBJ_RS_S0_FORCE_PERSAMPLE_INTERP(x) (((x) & 0x1) << 31) - -#define VIRGL_OBJ_RS_POINT_SIZE 3 -#define VIRGL_OBJ_RS_SPRITE_COORD_ENABLE 4 -#define VIRGL_OBJ_RS_S3 5 - -#define VIRGL_OBJ_RS_S3_LINE_STIPPLE_PATTERN(x) (((x) & 0xffff) << 0) -#define VIRGL_OBJ_RS_S3_LINE_STIPPLE_FACTOR(x) (((x) & 0xff) << 16) -#define VIRGL_OBJ_RS_S3_CLIP_PLANE_ENABLE(x) (((x) & 0xff) << 24) -#define VIRGL_OBJ_RS_LINE_WIDTH 6 -#define VIRGL_OBJ_RS_OFFSET_UNITS 7 -#define VIRGL_OBJ_RS_OFFSET_SCALE 8 -#define VIRGL_OBJ_RS_OFFSET_CLAMP 9 - -#define VIRGL_OBJ_CLEAR_SIZE 8 -#define VIRGL_OBJ_CLEAR_BUFFERS 1 -#define VIRGL_OBJ_CLEAR_COLOR_0 2 /* color is 4 * u32/f32/i32 */ -#define VIRGL_OBJ_CLEAR_COLOR_1 3 -#define VIRGL_OBJ_CLEAR_COLOR_2 4 -#define VIRGL_OBJ_CLEAR_COLOR_3 5 -#define VIRGL_OBJ_CLEAR_DEPTH_0 6 /* depth is a double precision float */ -#define VIRGL_OBJ_CLEAR_DEPTH_1 7 -#define VIRGL_OBJ_CLEAR_STENCIL 8 - -/* shader object */ -#define VIRGL_OBJ_SHADER_HDR_SIZE(nso) (5 + ((nso) ? (2 * nso) + 4 : 0)) -#define VIRGL_OBJ_SHADER_HANDLE 1 -#define VIRGL_OBJ_SHADER_TYPE 2 -#define VIRGL_OBJ_SHADER_OFFSET 3 -#define VIRGL_OBJ_SHADER_OFFSET_VAL(x) (((x) & 0x7fffffff) << 0) -/* start contains full length in VAL - also implies continuations */ -/* continuation contains offset in VAL */ -#define VIRGL_OBJ_SHADER_OFFSET_CONT (0x1u << 31) -#define VIRGL_OBJ_SHADER_NUM_TOKENS 4 -#define VIRGL_OBJ_SHADER_SO_NUM_OUTPUTS 5 -#define VIRGL_OBJ_SHADER_SO_STRIDE(x) (6 + (x)) -#define VIRGL_OBJ_SHADER_SO_OUTPUT0(x) (10 + (x * 2)) -#define VIRGL_OBJ_SHADER_SO_OUTPUT_REGISTER_INDEX(x) (((x) & 0xff) << 0) -#define VIRGL_OBJ_SHADER_SO_OUTPUT_START_COMPONENT(x) (((x) & 0x3) << 8) -#define VIRGL_OBJ_SHADER_SO_OUTPUT_NUM_COMPONENTS(x) (((x) & 0x7) << 10) -#define VIRGL_OBJ_SHADER_SO_OUTPUT_BUFFER(x) (((x) & 0x7) << 13) -#define VIRGL_OBJ_SHADER_SO_OUTPUT_DST_OFFSET(x) (((x) & 0xffff) << 16) -#define VIRGL_OBJ_SHADER_SO_OUTPUT0_SO(x) (11 + (x * 2)) -#define VIRGL_OBJ_SHADER_SO_OUTPUT_STREAM(x) (((x) & 0x03) << 0) - -/* viewport state */ -#define VIRGL_SET_VIEWPORT_STATE_SIZE(num_viewports) ((6 * num_viewports) + 1) -#define VIRGL_SET_VIEWPORT_START_SLOT 1 -#define VIRGL_SET_VIEWPORT_STATE_SCALE_0(x) (2 + (x * 6)) -#define VIRGL_SET_VIEWPORT_STATE_SCALE_1(x) (3 + (x * 6)) -#define VIRGL_SET_VIEWPORT_STATE_SCALE_2(x) (4 + (x * 6)) -#define VIRGL_SET_VIEWPORT_STATE_TRANSLATE_0(x) (5 + (x * 6)) -#define VIRGL_SET_VIEWPORT_STATE_TRANSLATE_1(x) (6 + (x * 6)) -#define VIRGL_SET_VIEWPORT_STATE_TRANSLATE_2(x) (7 + (x * 6)) - -/* framebuffer state */ -#define VIRGL_SET_FRAMEBUFFER_STATE_SIZE(nr_cbufs) (nr_cbufs + 2) -#define VIRGL_SET_FRAMEBUFFER_STATE_NR_CBUFS 1 -#define VIRGL_SET_FRAMEBUFFER_STATE_NR_ZSURF_HANDLE 2 -#define VIRGL_SET_FRAMEBUFFER_STATE_CBUF_HANDLE(x) ((x) + 3) - -/* vertex elements object */ -#define VIRGL_OBJ_VERTEX_ELEMENTS_SIZE(num_elements) (((num_elements) * 4) + 1) -#define VIRGL_OBJ_VERTEX_ELEMENTS_HANDLE 1 -#define VIRGL_OBJ_VERTEX_ELEMENTS_V0_SRC_OFFSET(x) (((x) * 4) + 2) /* repeated per VE */ -#define VIRGL_OBJ_VERTEX_ELEMENTS_V0_INSTANCE_DIVISOR(x) (((x) * 4) + 3) -#define VIRGL_OBJ_VERTEX_ELEMENTS_V0_VERTEX_BUFFER_INDEX(x) (((x) * 4) + 4) -#define VIRGL_OBJ_VERTEX_ELEMENTS_V0_SRC_FORMAT(x) (((x) * 4) + 5) - -/* vertex buffers */ -#define VIRGL_SET_VERTEX_BUFFERS_SIZE(num_buffers) ((num_buffers) * 3) -#define VIRGL_SET_VERTEX_BUFFER_STRIDE(x) (((x) * 3) + 1) -#define VIRGL_SET_VERTEX_BUFFER_OFFSET(x) (((x) * 3) + 2) -#define VIRGL_SET_VERTEX_BUFFER_HANDLE(x) (((x) * 3) + 3) - -/* index buffer */ -#define VIRGL_SET_INDEX_BUFFER_SIZE(ib) (((ib) ? 2 : 0) + 1) -#define VIRGL_SET_INDEX_BUFFER_HANDLE 1 -#define VIRGL_SET_INDEX_BUFFER_INDEX_SIZE 2 /* only if sending an IB handle */ -#define VIRGL_SET_INDEX_BUFFER_OFFSET 3 /* only if sending an IB handle */ - -/* constant buffer */ -#define VIRGL_SET_CONSTANT_BUFFER_SHADER_TYPE 1 -#define VIRGL_SET_CONSTANT_BUFFER_INDEX 2 -#define VIRGL_SET_CONSTANT_BUFFER_DATA_START 3 - -#define VIRGL_SET_UNIFORM_BUFFER_SIZE 5 -#define VIRGL_SET_UNIFORM_BUFFER_SHADER_TYPE 1 -#define VIRGL_SET_UNIFORM_BUFFER_INDEX 2 -#define VIRGL_SET_UNIFORM_BUFFER_OFFSET 3 -#define VIRGL_SET_UNIFORM_BUFFER_LENGTH 4 -#define VIRGL_SET_UNIFORM_BUFFER_RES_HANDLE 5 - -/* draw VBO */ -#define VIRGL_DRAW_VBO_SIZE 12 -#define VIRGL_DRAW_VBO_SIZE_TESS 14 -#define VIRGL_DRAW_VBO_SIZE_INDIRECT 20 -#define VIRGL_DRAW_VBO_START 1 -#define VIRGL_DRAW_VBO_COUNT 2 -#define VIRGL_DRAW_VBO_MODE 3 -#define VIRGL_DRAW_VBO_INDEXED 4 -#define VIRGL_DRAW_VBO_INSTANCE_COUNT 5 -#define VIRGL_DRAW_VBO_INDEX_BIAS 6 -#define VIRGL_DRAW_VBO_START_INSTANCE 7 -#define VIRGL_DRAW_VBO_PRIMITIVE_RESTART 8 -#define VIRGL_DRAW_VBO_RESTART_INDEX 9 -#define VIRGL_DRAW_VBO_MIN_INDEX 10 -#define VIRGL_DRAW_VBO_MAX_INDEX 11 -#define VIRGL_DRAW_VBO_COUNT_FROM_SO 12 -/* tess packet */ -#define VIRGL_DRAW_VBO_VERTICES_PER_PATCH 13 -#define VIRGL_DRAW_VBO_DRAWID 14 -/* indirect packet */ -#define VIRGL_DRAW_VBO_INDIRECT_HANDLE 15 -#define VIRGL_DRAW_VBO_INDIRECT_OFFSET 16 -#define VIRGL_DRAW_VBO_INDIRECT_STRIDE 17 -#define VIRGL_DRAW_VBO_INDIRECT_DRAW_COUNT 18 -#define VIRGL_DRAW_VBO_INDIRECT_DRAW_COUNT_OFFSET 19 -#define VIRGL_DRAW_VBO_INDIRECT_DRAW_COUNT_HANDLE 20 - -/* create surface */ -#define VIRGL_OBJ_SURFACE_SIZE 5 -#define VIRGL_OBJ_SURFACE_HANDLE 1 -#define VIRGL_OBJ_SURFACE_RES_HANDLE 2 -#define VIRGL_OBJ_SURFACE_FORMAT 3 -#define VIRGL_OBJ_SURFACE_BUFFER_FIRST_ELEMENT 4 -#define VIRGL_OBJ_SURFACE_BUFFER_LAST_ELEMENT 5 -#define VIRGL_OBJ_SURFACE_TEXTURE_LEVEL 4 -#define VIRGL_OBJ_SURFACE_TEXTURE_LAYERS 5 - -/* create streamout target */ -#define VIRGL_OBJ_STREAMOUT_SIZE 4 -#define VIRGL_OBJ_STREAMOUT_HANDLE 1 -#define VIRGL_OBJ_STREAMOUT_RES_HANDLE 2 -#define VIRGL_OBJ_STREAMOUT_BUFFER_OFFSET 3 -#define VIRGL_OBJ_STREAMOUT_BUFFER_SIZE 4 - -/* sampler state */ -#define VIRGL_OBJ_SAMPLER_STATE_SIZE 9 -#define VIRGL_OBJ_SAMPLER_STATE_HANDLE 1 -#define VIRGL_OBJ_SAMPLER_STATE_S0 2 -#define VIRGL_OBJ_SAMPLE_STATE_S0_WRAP_S(x) (((x) & 0x7) << 0) -#define VIRGL_OBJ_SAMPLE_STATE_S0_WRAP_T(x) (((x) & 0x7) << 3) -#define VIRGL_OBJ_SAMPLE_STATE_S0_WRAP_R(x) (((x) & 0x7) << 6) -#define VIRGL_OBJ_SAMPLE_STATE_S0_MIN_IMG_FILTER(x) (((x) & 0x3) << 9) -#define VIRGL_OBJ_SAMPLE_STATE_S0_MIN_MIP_FILTER(x) (((x) & 0x3) << 11) -#define VIRGL_OBJ_SAMPLE_STATE_S0_MAG_IMG_FILTER(x) (((x) & 0x3) << 13) -#define VIRGL_OBJ_SAMPLE_STATE_S0_COMPARE_MODE(x) (((x) & 0x1) << 15) -#define VIRGL_OBJ_SAMPLE_STATE_S0_COMPARE_FUNC(x) (((x) & 0x7) << 16) -#define VIRGL_OBJ_SAMPLE_STATE_S0_SEAMLESS_CUBE_MAP(x) (((x) & 0x1) << 19) - -#define VIRGL_OBJ_SAMPLER_STATE_LOD_BIAS 3 -#define VIRGL_OBJ_SAMPLER_STATE_MIN_LOD 4 -#define VIRGL_OBJ_SAMPLER_STATE_MAX_LOD 5 -#define VIRGL_OBJ_SAMPLER_STATE_BORDER_COLOR(x) ((x) + 6) /* 6 - 9 */ - - -/* sampler view */ -#define VIRGL_OBJ_SAMPLER_VIEW_SIZE 6 -#define VIRGL_OBJ_SAMPLER_VIEW_HANDLE 1 -#define VIRGL_OBJ_SAMPLER_VIEW_RES_HANDLE 2 -#define VIRGL_OBJ_SAMPLER_VIEW_FORMAT 3 -#define VIRGL_OBJ_SAMPLER_VIEW_BUFFER_FIRST_ELEMENT 4 -#define VIRGL_OBJ_SAMPLER_VIEW_BUFFER_LAST_ELEMENT 5 -#define VIRGL_OBJ_SAMPLER_VIEW_TEXTURE_LAYER 4 -#define VIRGL_OBJ_SAMPLER_VIEW_TEXTURE_LEVEL 5 -#define VIRGL_OBJ_SAMPLER_VIEW_SWIZZLE 6 -#define VIRGL_OBJ_SAMPLER_VIEW_SWIZZLE_R(x) (((x) & 0x7) << 0) -#define VIRGL_OBJ_SAMPLER_VIEW_SWIZZLE_G(x) (((x) & 0x7) << 3) -#define VIRGL_OBJ_SAMPLER_VIEW_SWIZZLE_B(x) (((x) & 0x7) << 6) -#define VIRGL_OBJ_SAMPLER_VIEW_SWIZZLE_A(x) (((x) & 0x7) << 9) - -/* set sampler views */ -#define VIRGL_SET_SAMPLER_VIEWS_SIZE(num_views) ((num_views) + 2) -#define VIRGL_SET_SAMPLER_VIEWS_SHADER_TYPE 1 -#define VIRGL_SET_SAMPLER_VIEWS_START_SLOT 2 -#define VIRGL_SET_SAMPLER_VIEWS_V0_HANDLE 3 - -/* bind sampler states */ -#define VIRGL_BIND_SAMPLER_STATES(num_states) ((num_states) + 2) -#define VIRGL_BIND_SAMPLER_STATES_SHADER_TYPE 1 -#define VIRGL_BIND_SAMPLER_STATES_START_SLOT 2 -#define VIRGL_BIND_SAMPLER_STATES_S0_HANDLE 3 - -/* set stencil reference */ -#define VIRGL_SET_STENCIL_REF_SIZE 1 -#define VIRGL_SET_STENCIL_REF 1 -#define VIRGL_STENCIL_REF_VAL(f, s) ((f & 0xff) | (((s & 0xff) << 8))) - -/* set blend color */ -#define VIRGL_SET_BLEND_COLOR_SIZE 4 -#define VIRGL_SET_BLEND_COLOR(x) ((x) + 1) - -/* set scissor state */ -#define VIRGL_SET_SCISSOR_STATE_SIZE(x) (1 + 2 * x) -#define VIRGL_SET_SCISSOR_START_SLOT 1 -#define VIRGL_SET_SCISSOR_MINX_MINY(x) (2 + (x * 2)) -#define VIRGL_SET_SCISSOR_MAXX_MAXY(x) (3 + (x * 2)) - -/* resource copy region */ -#define VIRGL_CMD_RESOURCE_COPY_REGION_SIZE 13 -#define VIRGL_CMD_RCR_DST_RES_HANDLE 1 -#define VIRGL_CMD_RCR_DST_LEVEL 2 -#define VIRGL_CMD_RCR_DST_X 3 -#define VIRGL_CMD_RCR_DST_Y 4 -#define VIRGL_CMD_RCR_DST_Z 5 -#define VIRGL_CMD_RCR_SRC_RES_HANDLE 6 -#define VIRGL_CMD_RCR_SRC_LEVEL 7 -#define VIRGL_CMD_RCR_SRC_X 8 -#define VIRGL_CMD_RCR_SRC_Y 9 -#define VIRGL_CMD_RCR_SRC_Z 10 -#define VIRGL_CMD_RCR_SRC_W 11 -#define VIRGL_CMD_RCR_SRC_H 12 -#define VIRGL_CMD_RCR_SRC_D 13 - -/* blit */ -#define VIRGL_CMD_BLIT_SIZE 21 -#define VIRGL_CMD_BLIT_S0 1 -#define VIRGL_CMD_BLIT_S0_MASK(x) (((x) & 0xff) << 0) -#define VIRGL_CMD_BLIT_S0_FILTER(x) (((x) & 0x3) << 8) -#define VIRGL_CMD_BLIT_S0_SCISSOR_ENABLE(x) (((x) & 0x1) << 10) -#define VIRGL_CMD_BLIT_S0_RENDER_CONDITION_ENABLE(x) (((x) & 0x1) << 11) -#define VIRGL_CMD_BLIT_S0_ALPHA_BLEND(x) (((x) & 0x1) << 12) -#define VIRGL_CMD_BLIT_SCISSOR_MINX_MINY 2 -#define VIRGL_CMD_BLIT_SCISSOR_MAXX_MAXY 3 -#define VIRGL_CMD_BLIT_DST_RES_HANDLE 4 -#define VIRGL_CMD_BLIT_DST_LEVEL 5 -#define VIRGL_CMD_BLIT_DST_FORMAT 6 -#define VIRGL_CMD_BLIT_DST_X 7 -#define VIRGL_CMD_BLIT_DST_Y 8 -#define VIRGL_CMD_BLIT_DST_Z 9 -#define VIRGL_CMD_BLIT_DST_W 10 -#define VIRGL_CMD_BLIT_DST_H 11 -#define VIRGL_CMD_BLIT_DST_D 12 -#define VIRGL_CMD_BLIT_SRC_RES_HANDLE 13 -#define VIRGL_CMD_BLIT_SRC_LEVEL 14 -#define VIRGL_CMD_BLIT_SRC_FORMAT 15 -#define VIRGL_CMD_BLIT_SRC_X 16 -#define VIRGL_CMD_BLIT_SRC_Y 17 -#define VIRGL_CMD_BLIT_SRC_Z 18 -#define VIRGL_CMD_BLIT_SRC_W 19 -#define VIRGL_CMD_BLIT_SRC_H 20 -#define VIRGL_CMD_BLIT_SRC_D 21 - -/* query object */ -#define VIRGL_OBJ_QUERY_SIZE 4 -#define VIRGL_OBJ_QUERY_HANDLE 1 -#define VIRGL_OBJ_QUERY_TYPE_INDEX 2 -#define VIRGL_OBJ_QUERY_TYPE(x) (x & 0xffff) -#define VIRGL_OBJ_QUERY_INDEX(x) ((x & 0xffff) << 16) -#define VIRGL_OBJ_QUERY_OFFSET 3 -#define VIRGL_OBJ_QUERY_RES_HANDLE 4 - -#define VIRGL_QUERY_BEGIN_HANDLE 1 - -#define VIRGL_QUERY_END_HANDLE 1 - -#define VIRGL_QUERY_RESULT_SIZE 2 -#define VIRGL_QUERY_RESULT_HANDLE 1 -#define VIRGL_QUERY_RESULT_WAIT 2 - -/* render condition */ -#define VIRGL_RENDER_CONDITION_SIZE 3 -#define VIRGL_RENDER_CONDITION_HANDLE 1 -#define VIRGL_RENDER_CONDITION_CONDITION 2 -#define VIRGL_RENDER_CONDITION_MODE 3 - -/* resource inline write */ -#define VIRGL_RESOURCE_IW_RES_HANDLE 1 -#define VIRGL_RESOURCE_IW_LEVEL 2 -#define VIRGL_RESOURCE_IW_USAGE 3 -#define VIRGL_RESOURCE_IW_STRIDE 4 -#define VIRGL_RESOURCE_IW_LAYER_STRIDE 5 -#define VIRGL_RESOURCE_IW_X 6 -#define VIRGL_RESOURCE_IW_Y 7 -#define VIRGL_RESOURCE_IW_Z 8 -#define VIRGL_RESOURCE_IW_W 9 -#define VIRGL_RESOURCE_IW_H 10 -#define VIRGL_RESOURCE_IW_D 11 -#define VIRGL_RESOURCE_IW_DATA_START 12 - -/* set streamout targets */ -#define VIRGL_SET_STREAMOUT_TARGETS_APPEND_BITMASK 1 -#define VIRGL_SET_STREAMOUT_TARGETS_H0 2 - -/* set sample mask */ -#define VIRGL_SET_SAMPLE_MASK_SIZE 1 -#define VIRGL_SET_SAMPLE_MASK_MASK 1 - -/* set clip state */ -#define VIRGL_SET_CLIP_STATE_SIZE 32 -#define VIRGL_SET_CLIP_STATE_C0 1 - -/* polygon stipple */ -#define VIRGL_POLYGON_STIPPLE_SIZE 32 -#define VIRGL_POLYGON_STIPPLE_P0 1 - -#define VIRGL_BIND_SHADER_SIZE 2 -#define VIRGL_BIND_SHADER_HANDLE 1 -#define VIRGL_BIND_SHADER_TYPE 2 - -/* tess state */ -#define VIRGL_TESS_STATE_SIZE 6 - -/* set min samples */ -#define VIRGL_SET_MIN_SAMPLES_SIZE 1 -#define VIRGL_SET_MIN_SAMPLES_MASK 1 - -/* set shader buffers */ -#define VIRGL_SET_SHADER_BUFFER_ELEMENT_SIZE 3 -#define VIRGL_SET_SHADER_BUFFER_SIZE(x) (VIRGL_SET_SHADER_BUFFER_ELEMENT_SIZE * (x)) + 2 -#define VIRGL_SET_SHADER_BUFFER_SHADER_TYPE 1 -#define VIRGL_SET_SHADER_BUFFER_START_SLOT 2 -#define VIRGL_SET_SHADER_BUFFER_OFFSET(x) ((x) * VIRGL_SET_SHADER_BUFFER_ELEMENT_SIZE + 3) -#define VIRGL_SET_SHADER_BUFFER_LENGTH(x) ((x) * VIRGL_SET_SHADER_BUFFER_ELEMENT_SIZE + 4) -#define VIRGL_SET_SHADER_BUFFER_RES_HANDLE(x) ((x) * VIRGL_SET_SHADER_BUFFER_ELEMENT_SIZE + 5) - -/* set shader images */ -#define VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE 5 -#define VIRGL_SET_SHADER_IMAGE_SIZE(x) (VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE * (x)) + 2 -#define VIRGL_SET_SHADER_IMAGE_SHADER_TYPE 1 -#define VIRGL_SET_SHADER_IMAGE_START_SLOT 2 -#define VIRGL_SET_SHADER_IMAGE_FORMAT(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 3) -#define VIRGL_SET_SHADER_IMAGE_ACCESS(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 4) -#define VIRGL_SET_SHADER_IMAGE_LAYER_OFFSET(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 5) -#define VIRGL_SET_SHADER_IMAGE_LEVEL_SIZE(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 6) -#define VIRGL_SET_SHADER_IMAGE_RES_HANDLE(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 7) - -/* memory barrier */ -#define VIRGL_MEMORY_BARRIER_SIZE 1 -#define VIRGL_MEMORY_BARRIER_FLAGS 1 - -/* launch grid */ -#define VIRGL_LAUNCH_GRID_SIZE 8 -#define VIRGL_LAUNCH_BLOCK_X 1 -#define VIRGL_LAUNCH_BLOCK_Y 2 -#define VIRGL_LAUNCH_BLOCK_Z 3 -#define VIRGL_LAUNCH_GRID_X 4 -#define VIRGL_LAUNCH_GRID_Y 5 -#define VIRGL_LAUNCH_GRID_Z 6 -#define VIRGL_LAUNCH_INDIRECT_HANDLE 7 -#define VIRGL_LAUNCH_INDIRECT_OFFSET 8 - -/* framebuffer state no attachment */ -#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_SIZE 2 -#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_WIDTH_HEIGHT 1 -#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_WIDTH(x) (x & 0xffff) -#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_HEIGHT(x) ((x >> 16) & 0xffff) -#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_LAYERS_SAMPLES 2 -#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_LAYERS(x) (x & 0xffff) -#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_SAMPLES(x) ((x >> 16) & 0xff) - -/* texture barrier */ -#define VIRGL_TEXTURE_BARRIER_SIZE 1 -#define VIRGL_TEXTURE_BARRIER_FLAGS 1 - -/* hw atomics */ -#define VIRGL_SET_ATOMIC_BUFFER_ELEMENT_SIZE 3 -#define VIRGL_SET_ATOMIC_BUFFER_SIZE(x) (VIRGL_SET_ATOMIC_BUFFER_ELEMENT_SIZE * (x)) + 1 -#define VIRGL_SET_ATOMIC_BUFFER_START_SLOT 1 -#define VIRGL_SET_ATOMIC_BUFFER_OFFSET(x) ((x) * VIRGL_SET_ATOMIC_BUFFER_ELEMENT_SIZE + 2) -#define VIRGL_SET_ATOMIC_BUFFER_LENGTH(x) ((x) * VIRGL_SET_ATOMIC_BUFFER_ELEMENT_SIZE + 3) -#define VIRGL_SET_ATOMIC_BUFFER_RES_HANDLE(x) ((x) * VIRGL_SET_ATOMIC_BUFFER_ELEMENT_SIZE + 4) - -/* qbo */ -#define VIRGL_QUERY_RESULT_QBO_SIZE 6 -#define VIRGL_QUERY_RESULT_QBO_HANDLE 1 -#define VIRGL_QUERY_RESULT_QBO_QBO_HANDLE 2 -#define VIRGL_QUERY_RESULT_QBO_WAIT 3 -#define VIRGL_QUERY_RESULT_QBO_RESULT_TYPE 4 -#define VIRGL_QUERY_RESULT_QBO_OFFSET 5 -#define VIRGL_QUERY_RESULT_QBO_INDEX 6 - -#define VIRGL_TRANSFER_TO_HOST 1 -#define VIRGL_TRANSFER_FROM_HOST 2 - -/* Transfer */ -#define VIRGL_TRANSFER3D_SIZE 13 -/* The first 11 dwords are the same as VIRGL_RESOURCE_IW_* */ -#define VIRGL_TRANSFER3D_DATA_OFFSET 12 -#define VIRGL_TRANSFER3D_DIRECTION 13 - -/* Copy transfer */ -#define VIRGL_COPY_TRANSFER3D_SIZE 14 -/* The first 11 dwords are the same as VIRGL_RESOURCE_IW_* */ -#define VIRGL_COPY_TRANSFER3D_SRC_RES_HANDLE 12 -#define VIRGL_COPY_TRANSFER3D_SRC_RES_OFFSET 13 -#define VIRGL_COPY_TRANSFER3D_SYNCHRONIZED 14 - -/* set tweak flags */ -#define VIRGL_SET_TWEAKS_SIZE 2 -#define VIRGL_SET_TWEAKS_ID 1 -#define VIRGL_SET_TWEAKS_VALUE 2 - -enum vrend_tweak_type { - virgl_tweak_gles_brga_emulate, - virgl_tweak_gles_brga_apply_dest_swizzle, - virgl_tweak_gles_tf3_samples_passes_multiplier, - virgl_tweak_undefined -}; - -/* Clear texture */ -#define VIRGL_CLEAR_TEXTURE_SIZE 12 -#define VIRGL_TEXTURE_HANDLE 1 -#define VIRGL_TEXTURE_LEVEL 2 -#define VIRGL_TEXTURE_SRC_X 3 -#define VIRGL_TEXTURE_SRC_Y 4 -#define VIRGL_TEXTURE_SRC_Z 5 -#define VIRGL_TEXTURE_SRC_W 6 -#define VIRGL_TEXTURE_SRC_H 7 -#define VIRGL_TEXTURE_SRC_D 8 -#define VIRGL_TEXTURE_ARRAY_A 9 -#define VIRGL_TEXTURE_ARRAY_B 10 -#define VIRGL_TEXTURE_ARRAY_C 11 -#define VIRGL_TEXTURE_ARRAY_D 12 - -#endif diff --git a/src/gallium/drivers/virgl/virgl_query.c b/src/gallium/drivers/virgl/virgl_query.c index 9d6989c0ae3..8ff9aa5b835 100644 --- a/src/gallium/drivers/virgl/virgl_query.c +++ b/src/gallium/drivers/virgl/virgl_query.c @@ -25,7 +25,7 @@ #include "util/u_inlines.h" #include "virgl_context.h" #include "virgl_encode.h" -#include "virgl_protocol.h" +#include "virtio-gpu/virgl_protocol.h" #include "virgl_resource.h" #include "virgl_screen.h" diff --git a/src/gallium/drivers/virgl/virgl_resource.h b/src/gallium/drivers/virgl/virgl_resource.h index f17dac72a0e..ef9e0681a02 100644 --- a/src/gallium/drivers/virgl/virgl_resource.h +++ b/src/gallium/drivers/virgl/virgl_resource.h @@ -29,7 +29,7 @@ #include "util/list.h" #include "util/u_transfer.h" -#include "virgl_hw.h" +#include "virtio-gpu/virgl_hw.h" #include "virgl_screen.h" #define VR_MAX_TEXTURE_2D_LEVELS 15 diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c index fc2a403104a..b7cd406dbca 100644 --- a/src/gallium/drivers/virgl/virgl_screen.c +++ b/src/gallium/drivers/virgl/virgl_screen.c @@ -37,7 +37,7 @@ #include "virgl_resource.h" #include "virgl_public.h" #include "virgl_context.h" -#include "virgl_protocol.h" +#include "virtio-gpu/virgl_protocol.h" int virgl_debug = 0; static const struct debug_named_value debug_options[] = { diff --git a/src/gallium/drivers/virgl/virgl_streamout.c b/src/gallium/drivers/virgl/virgl_streamout.c index ba601f9fef1..6e4be7c3af8 100644 --- a/src/gallium/drivers/virgl/virgl_streamout.c +++ b/src/gallium/drivers/virgl/virgl_streamout.c @@ -24,7 +24,7 @@ #include "util/u_memory.h" #include "virgl_context.h" #include "virgl_encode.h" -#include "virgl_protocol.h" +#include "virtio-gpu/virgl_protocol.h" #include "virgl_resource.h" static struct pipe_stream_output_target *virgl_create_so_target( diff --git a/src/gallium/drivers/virgl/virgl_transfer_queue.c b/src/gallium/drivers/virgl/virgl_transfer_queue.c index 34ea5183fcc..2353ad5042e 100644 --- a/src/gallium/drivers/virgl/virgl_transfer_queue.c +++ b/src/gallium/drivers/virgl/virgl_transfer_queue.c @@ -24,7 +24,7 @@ #include "util/u_box.h" #include "util/u_inlines.h" -#include "virgl_protocol.h" +#include "virtio-gpu/virgl_protocol.h" #include "virgl_context.h" #include "virgl_screen.h" #include "virgl_encode.h" diff --git a/src/gallium/drivers/virgl/virgl_winsys.h b/src/gallium/drivers/virgl/virgl_winsys.h index 97885c99955..cdfeeaca96c 100644 --- a/src/gallium/drivers/virgl/virgl_winsys.h +++ b/src/gallium/drivers/virgl/virgl_winsys.h @@ -24,7 +24,7 @@ #define VIRGL_WINSYS_H #include "pipe/p_defines.h" -#include "virgl_hw.h" +#include "virtio-gpu/virgl_hw.h" struct pipe_box; struct pipe_fence_handle; diff --git a/src/gallium/winsys/virgl/drm/Android.mk b/src/gallium/winsys/virgl/drm/Android.mk index 5e2500774e7..f3d9df79c4f 100644 --- a/src/gallium/winsys/virgl/drm/Android.mk +++ b/src/gallium/winsys/virgl/drm/Android.mk @@ -29,6 +29,8 @@ LOCAL_SRC_FILES := $(C_SOURCES) LOCAL_MODULE := libmesa_winsys_virgl +LOCAL_C_INCLUDES := $(MESA_TOP)/src/virtio + LOCAL_STATIC_LIBRARIES := libmesa_winsys_virgl_common include $(GALLIUM_COMMON_MK) diff --git a/src/gallium/winsys/virgl/drm/meson.build b/src/gallium/winsys/virgl/drm/meson.build index cf15b78aff4..ba6439a5f41 100644 --- a/src/gallium/winsys/virgl/drm/meson.build +++ b/src/gallium/winsys/virgl/drm/meson.build @@ -21,7 +21,7 @@ libvirgldrm = static_library( 'virgldrm', 'virgl_drm_winsys.c', - include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_gallium_drivers], + include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_gallium_drivers, inc_virtio], dependencies : [dep_libdrm, dep_libvirglcommon], gnu_symbol_visibility : 'hidden', ) diff --git a/src/gallium/winsys/virgl/vtest/Android.mk b/src/gallium/winsys/virgl/vtest/Android.mk index 5b33f677114..454d830d042 100644 --- a/src/gallium/winsys/virgl/vtest/Android.mk +++ b/src/gallium/winsys/virgl/vtest/Android.mk @@ -29,6 +29,8 @@ LOCAL_SRC_FILES := $(C_SOURCES) LOCAL_MODULE := libmesa_winsys_virgl_vtest +LOCAL_C_INCLUDES := $(MESA_TOP)/src/virtio + LOCAL_STATIC_LIBRARIES := libmesa_winsys_virgl_common include $(GALLIUM_COMMON_MK) diff --git a/src/gallium/winsys/virgl/vtest/Makefile.sources b/src/gallium/winsys/virgl/vtest/Makefile.sources index 12370d96fa8..cda28e575a8 100644 --- a/src/gallium/winsys/virgl/vtest/Makefile.sources +++ b/src/gallium/winsys/virgl/vtest/Makefile.sources @@ -2,5 +2,4 @@ C_SOURCES := \ virgl_vtest_public.h \ virgl_vtest_socket.c \ virgl_vtest_winsys.c \ - virgl_vtest_winsys.h \ - vtest_protocol.h + virgl_vtest_winsys.h diff --git a/src/gallium/winsys/virgl/vtest/meson.build b/src/gallium/winsys/virgl/vtest/meson.build index f8b38b42d7a..caf81220f10 100644 --- a/src/gallium/winsys/virgl/vtest/meson.build +++ b/src/gallium/winsys/virgl/vtest/meson.build @@ -21,7 +21,7 @@ libvirglvtest = static_library( 'virglvtest', ['virgl_vtest_socket.c', 'virgl_vtest_winsys.c'], - include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_gallium_drivers], + include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_gallium_drivers, inc_virtio], dependencies : dep_libvirglcommon, gnu_symbol_visibility : 'hidden', ) diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h index 27b4172814b..4254a551f01 100644 --- a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h +++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h @@ -31,7 +31,7 @@ #include "os/os_thread.h" #include "virgl/virgl_winsys.h" -#include "vtest_protocol.h" +#include "vtest/vtest_protocol.h" #include "virgl_resource_cache.h" struct pipe_fence_handle; diff --git a/src/gallium/winsys/virgl/vtest/vtest_protocol.h b/src/gallium/winsys/virgl/vtest/vtest_protocol.h deleted file mode 100644 index 9360213ac45..00000000000 --- a/src/gallium/winsys/virgl/vtest/vtest_protocol.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2014, 2015 Red Hat. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -#ifndef VTEST_PROTOCOL -#define VTEST_PROTOCOL - -#define VTEST_DEFAULT_SOCKET_NAME "/tmp/.virgl_test" -#define VTEST_PROTOCOL_VERSION 2 - -/* 32-bit length field */ -/* 32-bit cmd field */ -#define VTEST_HDR_SIZE 2 -#define VTEST_CMD_LEN 0 /* length of data */ -#define VTEST_CMD_ID 1 -#define VTEST_CMD_DATA_START 2 - -/* vtest cmds */ -#define VCMD_GET_CAPS 1 - -#define VCMD_RESOURCE_CREATE 2 -#define VCMD_RESOURCE_UNREF 3 - -#define VCMD_TRANSFER_GET 4 -#define VCMD_TRANSFER_PUT 5 - -#define VCMD_SUBMIT_CMD 6 - -#define VCMD_RESOURCE_BUSY_WAIT 7 - -/* pass the process cmd line for debugging */ -#define VCMD_CREATE_RENDERER 8 - -#define VCMD_GET_CAPS2 9 -/* get caps */ -/* 0 length cmd */ -/* resp VCMD_GET_CAPS + caps */ - -#define VCMD_PING_PROTOCOL_VERSION 10 - -#define VCMD_PROTOCOL_VERSION 11 - -#define VCMD_RESOURCE_CREATE2 12 -#define VCMD_TRANSFER_GET2 13 -#define VCMD_TRANSFER_PUT2 14 - -#define VCMD_RES_CREATE_SIZE 10 -#define VCMD_RES_CREATE_RES_HANDLE 0 -#define VCMD_RES_CREATE_TARGET 1 -#define VCMD_RES_CREATE_FORMAT 2 -#define VCMD_RES_CREATE_BIND 3 -#define VCMD_RES_CREATE_WIDTH 4 -#define VCMD_RES_CREATE_HEIGHT 5 -#define VCMD_RES_CREATE_DEPTH 6 -#define VCMD_RES_CREATE_ARRAY_SIZE 7 -#define VCMD_RES_CREATE_LAST_LEVEL 8 -#define VCMD_RES_CREATE_NR_SAMPLES 9 - -#define VCMD_RES_CREATE2_SIZE 11 -#define VCMD_RES_CREATE2_RES_HANDLE 0 -#define VCMD_RES_CREATE2_TARGET 1 -#define VCMD_RES_CREATE2_FORMAT 2 -#define VCMD_RES_CREATE2_BIND 3 -#define VCMD_RES_CREATE2_WIDTH 4 -#define VCMD_RES_CREATE2_HEIGHT 5 -#define VCMD_RES_CREATE2_DEPTH 6 -#define VCMD_RES_CREATE2_ARRAY_SIZE 7 -#define VCMD_RES_CREATE2_LAST_LEVEL 8 -#define VCMD_RES_CREATE2_NR_SAMPLES 9 -#define VCMD_RES_CREATE2_DATA_SIZE 10 - -#define VCMD_RES_UNREF_SIZE 1 -#define VCMD_RES_UNREF_RES_HANDLE 0 - -#define VCMD_TRANSFER_HDR_SIZE 11 -#define VCMD_TRANSFER_RES_HANDLE 0 -#define VCMD_TRANSFER_LEVEL 1 -#define VCMD_TRANSFER_STRIDE 2 -#define VCMD_TRANSFER_LAYER_STRIDE 3 -#define VCMD_TRANSFER_X 4 -#define VCMD_TRANSFER_Y 5 -#define VCMD_TRANSFER_Z 6 -#define VCMD_TRANSFER_WIDTH 7 -#define VCMD_TRANSFER_HEIGHT 8 -#define VCMD_TRANSFER_DEPTH 9 -#define VCMD_TRANSFER_DATA_SIZE 10 - -#define VCMD_TRANSFER2_HDR_SIZE 10 -#define VCMD_TRANSFER2_RES_HANDLE 0 -#define VCMD_TRANSFER2_LEVEL 1 -#define VCMD_TRANSFER2_X 2 -#define VCMD_TRANSFER2_Y 3 -#define VCMD_TRANSFER2_Z 4 -#define VCMD_TRANSFER2_WIDTH 5 -#define VCMD_TRANSFER2_HEIGHT 6 -#define VCMD_TRANSFER2_DEPTH 7 -#define VCMD_TRANSFER2_DATA_SIZE 8 -#define VCMD_TRANSFER2_OFFSET 9 - -#define VCMD_BUSY_WAIT_FLAG_WAIT 1 - -#define VCMD_BUSY_WAIT_SIZE 2 -#define VCMD_BUSY_WAIT_HANDLE 0 -#define VCMD_BUSY_WAIT_FLAGS 1 - -#define VCMD_PING_PROTOCOL_VERSION_SIZE 1 - -#define VCMD_PROTOCOL_VERSION_SIZE 1 -#define VCMD_PROTOCOL_VERSION_VERSION 0 - -#endif diff --git a/src/meson.build b/src/meson.build index b16717193e9..1d8e7633369 100644 --- a/src/meson.build +++ b/src/meson.build @@ -85,6 +85,9 @@ endif if with_gallium_panfrost or with_gallium_lima subdir('panfrost') endif +if with_gallium_virgl + subdir('virtio') +endif if with_dri_i965 or with_intel_vk or with_gallium_iris subdir('intel') endif diff --git a/src/virtio/meson.build b/src/virtio/meson.build new file mode 100644 index 00000000000..1bd14feba91 --- /dev/null +++ b/src/virtio/meson.build @@ -0,0 +1,21 @@ +# Copyright © 2017 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +inc_virtio = include_directories('.') diff --git a/src/virtio/virtio-gpu/virgl_hw.h b/src/virtio/virtio-gpu/virgl_hw.h new file mode 100644 index 00000000000..bbf5f5f7519 --- /dev/null +++ b/src/virtio/virtio-gpu/virgl_hw.h @@ -0,0 +1,510 @@ +/* + * Copyright 2014, 2015 Red Hat. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef VIRGL_HW_H +#define VIRGL_HW_H + +#include + +struct virgl_box { + uint32_t x, y, z; + uint32_t w, h, d; +}; + +/* formats known by the HW device - based on gallium subset */ +enum virgl_formats { + VIRGL_FORMAT_B8G8R8A8_UNORM = 1, + VIRGL_FORMAT_B8G8R8X8_UNORM = 2, + VIRGL_FORMAT_A8R8G8B8_UNORM = 3, + VIRGL_FORMAT_X8R8G8B8_UNORM = 4, + VIRGL_FORMAT_B5G5R5A1_UNORM = 5, + VIRGL_FORMAT_B4G4R4A4_UNORM = 6, + VIRGL_FORMAT_B5G6R5_UNORM = 7, + VIRGL_FORMAT_R10G10B10A2_UNORM = 8, + VIRGL_FORMAT_L8_UNORM = 9, /**< ubyte luminance */ + VIRGL_FORMAT_A8_UNORM = 10, /**< ubyte alpha */ + VIRGL_FORMAT_L8A8_UNORM = 12, /**< ubyte alpha, luminance */ + VIRGL_FORMAT_L16_UNORM = 13, /**< ushort luminance */ + + VIRGL_FORMAT_Z16_UNORM = 16, + VIRGL_FORMAT_Z32_UNORM = 17, + VIRGL_FORMAT_Z32_FLOAT = 18, + VIRGL_FORMAT_Z24_UNORM_S8_UINT = 19, + VIRGL_FORMAT_S8_UINT_Z24_UNORM = 20, + VIRGL_FORMAT_Z24X8_UNORM = 21, + VIRGL_FORMAT_X8Z24_UNORM = 22, + VIRGL_FORMAT_S8_UINT = 23, /**< ubyte stencil */ + VIRGL_FORMAT_R64_FLOAT = 24, + VIRGL_FORMAT_R64G64_FLOAT = 25, + VIRGL_FORMAT_R64G64B64_FLOAT = 26, + VIRGL_FORMAT_R64G64B64A64_FLOAT = 27, + VIRGL_FORMAT_R32_FLOAT = 28, + VIRGL_FORMAT_R32G32_FLOAT = 29, + VIRGL_FORMAT_R32G32B32_FLOAT = 30, + VIRGL_FORMAT_R32G32B32A32_FLOAT = 31, + + VIRGL_FORMAT_R32_UNORM = 32, + VIRGL_FORMAT_R32G32_UNORM = 33, + VIRGL_FORMAT_R32G32B32_UNORM = 34, + VIRGL_FORMAT_R32G32B32A32_UNORM = 35, + VIRGL_FORMAT_R32_USCALED = 36, + VIRGL_FORMAT_R32G32_USCALED = 37, + VIRGL_FORMAT_R32G32B32_USCALED = 38, + VIRGL_FORMAT_R32G32B32A32_USCALED = 39, + VIRGL_FORMAT_R32_SNORM = 40, + VIRGL_FORMAT_R32G32_SNORM = 41, + VIRGL_FORMAT_R32G32B32_SNORM = 42, + VIRGL_FORMAT_R32G32B32A32_SNORM = 43, + VIRGL_FORMAT_R32_SSCALED = 44, + VIRGL_FORMAT_R32G32_SSCALED = 45, + VIRGL_FORMAT_R32G32B32_SSCALED = 46, + VIRGL_FORMAT_R32G32B32A32_SSCALED = 47, + + VIRGL_FORMAT_R16_UNORM = 48, + VIRGL_FORMAT_R16G16_UNORM = 49, + VIRGL_FORMAT_R16G16B16_UNORM = 50, + VIRGL_FORMAT_R16G16B16A16_UNORM = 51, + + VIRGL_FORMAT_R16_USCALED = 52, + VIRGL_FORMAT_R16G16_USCALED = 53, + VIRGL_FORMAT_R16G16B16_USCALED = 54, + VIRGL_FORMAT_R16G16B16A16_USCALED = 55, + + VIRGL_FORMAT_R16_SNORM = 56, + VIRGL_FORMAT_R16G16_SNORM = 57, + VIRGL_FORMAT_R16G16B16_SNORM = 58, + VIRGL_FORMAT_R16G16B16A16_SNORM = 59, + + VIRGL_FORMAT_R16_SSCALED = 60, + VIRGL_FORMAT_R16G16_SSCALED = 61, + VIRGL_FORMAT_R16G16B16_SSCALED = 62, + VIRGL_FORMAT_R16G16B16A16_SSCALED = 63, + + VIRGL_FORMAT_R8_UNORM = 64, + VIRGL_FORMAT_R8G8_UNORM = 65, + VIRGL_FORMAT_R8G8B8_UNORM = 66, + VIRGL_FORMAT_R8G8B8A8_UNORM = 67, + + VIRGL_FORMAT_R8_USCALED = 69, + VIRGL_FORMAT_R8G8_USCALED = 70, + VIRGL_FORMAT_R8G8B8_USCALED = 71, + VIRGL_FORMAT_R8G8B8A8_USCALED = 72, + + VIRGL_FORMAT_R8_SNORM = 74, + VIRGL_FORMAT_R8G8_SNORM = 75, + VIRGL_FORMAT_R8G8B8_SNORM = 76, + VIRGL_FORMAT_R8G8B8A8_SNORM = 77, + + VIRGL_FORMAT_R8_SSCALED = 82, + VIRGL_FORMAT_R8G8_SSCALED = 83, + VIRGL_FORMAT_R8G8B8_SSCALED = 84, + VIRGL_FORMAT_R8G8B8A8_SSCALED = 85, + + VIRGL_FORMAT_R16_FLOAT = 91, + VIRGL_FORMAT_R16G16_FLOAT = 92, + VIRGL_FORMAT_R16G16B16_FLOAT = 93, + VIRGL_FORMAT_R16G16B16A16_FLOAT = 94, + + VIRGL_FORMAT_L8_SRGB = 95, + VIRGL_FORMAT_L8A8_SRGB = 96, + VIRGL_FORMAT_R8G8B8_SRGB = 97, + VIRGL_FORMAT_A8B8G8R8_SRGB = 98, + VIRGL_FORMAT_X8B8G8R8_SRGB = 99, + VIRGL_FORMAT_B8G8R8A8_SRGB = 100, + VIRGL_FORMAT_B8G8R8X8_SRGB = 101, + VIRGL_FORMAT_A8R8G8B8_SRGB = 102, + VIRGL_FORMAT_X8R8G8B8_SRGB = 103, + VIRGL_FORMAT_R8G8B8A8_SRGB = 104, + + /* compressed formats */ + VIRGL_FORMAT_DXT1_RGB = 105, + VIRGL_FORMAT_DXT1_RGBA = 106, + VIRGL_FORMAT_DXT3_RGBA = 107, + VIRGL_FORMAT_DXT5_RGBA = 108, + + /* sRGB, compressed */ + VIRGL_FORMAT_DXT1_SRGB = 109, + VIRGL_FORMAT_DXT1_SRGBA = 110, + VIRGL_FORMAT_DXT3_SRGBA = 111, + VIRGL_FORMAT_DXT5_SRGBA = 112, + + /* rgtc compressed */ + VIRGL_FORMAT_RGTC1_UNORM = 113, + VIRGL_FORMAT_RGTC1_SNORM = 114, + VIRGL_FORMAT_RGTC2_UNORM = 115, + VIRGL_FORMAT_RGTC2_SNORM = 116, + + VIRGL_FORMAT_A8B8G8R8_UNORM = 121, + VIRGL_FORMAT_B5G5R5X1_UNORM = 122, + VIRGL_FORMAT_R10G10B10A2_USCALED = 123, + VIRGL_FORMAT_R11G11B10_FLOAT = 124, + VIRGL_FORMAT_R9G9B9E5_FLOAT = 125, + VIRGL_FORMAT_Z32_FLOAT_S8X24_UINT = 126, + + VIRGL_FORMAT_B10G10R10A2_UNORM = 131, + VIRGL_FORMAT_R8G8B8X8_UNORM = 134, + VIRGL_FORMAT_B4G4R4X4_UNORM = 135, + VIRGL_FORMAT_X24S8_UINT = 136, + VIRGL_FORMAT_S8X24_UINT = 137, + VIRGL_FORMAT_X32_S8X24_UINT = 138, + VIRGL_FORMAT_B2G3R3_UNORM = 139, + + VIRGL_FORMAT_L16A16_UNORM = 140, + VIRGL_FORMAT_A16_UNORM = 141, + VIRGL_FORMAT_I16_UNORM = 142, + + VIRGL_FORMAT_LATC1_UNORM = 143, + VIRGL_FORMAT_LATC1_SNORM = 144, + VIRGL_FORMAT_LATC2_UNORM = 145, + VIRGL_FORMAT_LATC2_SNORM = 146, + + VIRGL_FORMAT_A8_SNORM = 147, + VIRGL_FORMAT_L8_SNORM = 148, + VIRGL_FORMAT_L8A8_SNORM = 149, + + VIRGL_FORMAT_A16_SNORM = 151, + VIRGL_FORMAT_L16_SNORM = 152, + VIRGL_FORMAT_L16A16_SNORM = 153, + + VIRGL_FORMAT_A16_FLOAT = 155, + VIRGL_FORMAT_L16_FLOAT = 156, + VIRGL_FORMAT_L16A16_FLOAT = 157, + + VIRGL_FORMAT_A32_FLOAT = 159, + VIRGL_FORMAT_L32_FLOAT = 160, + VIRGL_FORMAT_L32A32_FLOAT = 161, + + VIRGL_FORMAT_YV12 = 163, + VIRGL_FORMAT_YV16 = 164, + VIRGL_FORMAT_IYUV = 165, /**< aka I420 */ + VIRGL_FORMAT_NV12 = 166, + VIRGL_FORMAT_NV21 = 167, + + VIRGL_FORMAT_R10G10B10A2_SSCALED = 172, + VIRGL_FORMAT_R10G10B10A2_SNORM = 173, + VIRGL_FORMAT_B10G10R10A2_SNORM = 176, + + VIRGL_FORMAT_R8_UINT = 177, + VIRGL_FORMAT_R8G8_UINT = 178, + VIRGL_FORMAT_R8G8B8_UINT = 179, + VIRGL_FORMAT_R8G8B8A8_UINT = 180, + + VIRGL_FORMAT_R8_SINT = 181, + VIRGL_FORMAT_R8G8_SINT = 182, + VIRGL_FORMAT_R8G8B8_SINT = 183, + VIRGL_FORMAT_R8G8B8A8_SINT = 184, + + VIRGL_FORMAT_R16_UINT = 185, + VIRGL_FORMAT_R16G16_UINT = 186, + VIRGL_FORMAT_R16G16B16_UINT = 187, + VIRGL_FORMAT_R16G16B16A16_UINT = 188, + + VIRGL_FORMAT_R16_SINT = 189, + VIRGL_FORMAT_R16G16_SINT = 190, + VIRGL_FORMAT_R16G16B16_SINT = 191, + VIRGL_FORMAT_R16G16B16A16_SINT = 192, + VIRGL_FORMAT_R32_UINT = 193, + VIRGL_FORMAT_R32G32_UINT = 194, + VIRGL_FORMAT_R32G32B32_UINT = 195, + VIRGL_FORMAT_R32G32B32A32_UINT = 196, + + VIRGL_FORMAT_R32_SINT = 197, + VIRGL_FORMAT_R32G32_SINT = 198, + VIRGL_FORMAT_R32G32B32_SINT = 199, + VIRGL_FORMAT_R32G32B32A32_SINT = 200, + + VIRGL_FORMAT_A8_UINT = 201, + VIRGL_FORMAT_L8_UINT = 203, + VIRGL_FORMAT_L8A8_UINT = 204, + + VIRGL_FORMAT_A8_SINT = 205, + VIRGL_FORMAT_L8_SINT = 207, + VIRGL_FORMAT_L8A8_SINT = 208, + + VIRGL_FORMAT_A16_UINT = 209, + VIRGL_FORMAT_L16_UINT = 211, + VIRGL_FORMAT_L16A16_UINT = 212, + + VIRGL_FORMAT_A16_SINT = 213, + VIRGL_FORMAT_L16_SINT = 215, + VIRGL_FORMAT_L16A16_SINT = 216, + + VIRGL_FORMAT_A32_UINT = 217, + VIRGL_FORMAT_L32_UINT = 219, + VIRGL_FORMAT_L32A32_UINT = 220, + + VIRGL_FORMAT_A32_SINT = 221, + VIRGL_FORMAT_L32_SINT = 223, + VIRGL_FORMAT_L32A32_SINT = 224, + + VIRGL_FORMAT_B10G10R10A2_UINT = 225, + VIRGL_FORMAT_R8G8B8X8_SNORM = 229, + + VIRGL_FORMAT_R8G8B8X8_SRGB = 230, + + VIRGL_FORMAT_R8G8B8X8_UINT = 231, + VIRGL_FORMAT_R8G8B8X8_SINT = 232, + VIRGL_FORMAT_B10G10R10X2_UNORM = 233, + VIRGL_FORMAT_R16G16B16X16_UNORM = 234, + VIRGL_FORMAT_R16G16B16X16_SNORM = 235, + VIRGL_FORMAT_R16G16B16X16_FLOAT = 236, + VIRGL_FORMAT_R16G16B16X16_UINT = 237, + VIRGL_FORMAT_R16G16B16X16_SINT = 238, + VIRGL_FORMAT_R32G32B32X32_FLOAT = 239, + VIRGL_FORMAT_R32G32B32X32_UINT = 240, + VIRGL_FORMAT_R32G32B32X32_SINT = 241, + + VIRGL_FORMAT_R10G10B10A2_UINT = 253, + + VIRGL_FORMAT_BPTC_RGBA_UNORM = 255, + VIRGL_FORMAT_BPTC_SRGBA = 256, + VIRGL_FORMAT_BPTC_RGB_FLOAT = 257, + VIRGL_FORMAT_BPTC_RGB_UFLOAT = 258, + + /* etc2 compressed */ + VIRGL_FORMAT_ETC2_RGB8 = 269, + VIRGL_FORMAT_ETC2_SRGB8 = 270, + VIRGL_FORMAT_ETC2_RGB8A1 = 271, + VIRGL_FORMAT_ETC2_SRGB8A1 = 272, + VIRGL_FORMAT_ETC2_RGBA8 = 273, + VIRGL_FORMAT_ETC2_SRGBA8 = 274, + VIRGL_FORMAT_ETC2_R11_UNORM = 275, + VIRGL_FORMAT_ETC2_R11_SNORM = 276, + VIRGL_FORMAT_ETC2_RG11_UNORM = 277, + VIRGL_FORMAT_ETC2_RG11_SNORM = 278, + + VIRGL_FORMAT_R10G10B10X2_UNORM = 308, + VIRGL_FORMAT_A4B4G4R4_UNORM = 311, + + VIRGL_FORMAT_R8_SRGB = 312, + VIRGL_FORMAT_MAX /* = PIPE_FORMAT_COUNT */, + + /* Below formats must not be used in the guest. */ + VIRGL_FORMAT_B8G8R8X8_UNORM_EMULATED, + VIRGL_FORMAT_B8G8R8A8_UNORM_EMULATED, + VIRGL_FORMAT_MAX_EXTENDED +}; + +/* These are used by the capability_bits field in virgl_caps_v2. */ +#define VIRGL_CAP_NONE 0 +#define VIRGL_CAP_TGSI_INVARIANT (1 << 0) +#define VIRGL_CAP_TEXTURE_VIEW (1 << 1) +#define VIRGL_CAP_SET_MIN_SAMPLES (1 << 2) +#define VIRGL_CAP_COPY_IMAGE (1 << 3) +#define VIRGL_CAP_TGSI_PRECISE (1 << 4) +#define VIRGL_CAP_TXQS (1 << 5) +#define VIRGL_CAP_MEMORY_BARRIER (1 << 6) +#define VIRGL_CAP_COMPUTE_SHADER (1 << 7) +#define VIRGL_CAP_FB_NO_ATTACH (1 << 8) +#define VIRGL_CAP_ROBUST_BUFFER_ACCESS (1 << 9) +#define VIRGL_CAP_TGSI_FBFETCH (1 << 10) +#define VIRGL_CAP_SHADER_CLOCK (1 << 11) +#define VIRGL_CAP_TEXTURE_BARRIER (1 << 12) +#define VIRGL_CAP_TGSI_COMPONENTS (1 << 13) +#define VIRGL_CAP_GUEST_MAY_INIT_LOG (1 << 14) +#define VIRGL_CAP_SRGB_WRITE_CONTROL (1 << 15) +#define VIRGL_CAP_QBO (1 << 16) +#define VIRGL_CAP_TRANSFER (1 << 17) +#define VIRGL_CAP_FBO_MIXED_COLOR_FORMATS (1 << 18) +#define VIRGL_CAP_FAKE_FP64 (1 << 19) +#define VIRGL_CAP_BIND_COMMAND_ARGS (1 << 20) +#define VIRGL_CAP_MULTI_DRAW_INDIRECT (1 << 21) +#define VIRGL_CAP_INDIRECT_PARAMS (1 << 22) +#define VIRGL_CAP_TRANSFORM_FEEDBACK3 (1 << 23) +#define VIRGL_CAP_3D_ASTC (1 << 24) +#define VIRGL_CAP_INDIRECT_INPUT_ADDR (1 << 25) +#define VIRGL_CAP_COPY_TRANSFER (1 << 26) +#define VIRGL_CAP_CLIP_HALFZ (1 << 27) +#define VIRGL_CAP_APP_TWEAK_SUPPORT (1 << 28) +#define VIRGL_CAP_BGRA_SRGB_IS_EMULATED (1 << 29) +#define VIRGL_CAP_CLEAR_TEXTURE (1 << 30) +/* Reserved for VIRGL_CAP_ARB_BUFFER_STORAGE */ + +/* These are used by the capability_bits_v2 field in virgl_caps_v2. */ +#define VIRGL_CAP_V2_BLEND_EQUATION (1 << 0) + +/* virgl bind flags - these are compatible with mesa 10.5 gallium. + * but are fixed, no other should be passed to virgl either. + */ +#define VIRGL_BIND_DEPTH_STENCIL (1 << 0) +#define VIRGL_BIND_RENDER_TARGET (1 << 1) +#define VIRGL_BIND_SAMPLER_VIEW (1 << 3) +#define VIRGL_BIND_VERTEX_BUFFER (1 << 4) +#define VIRGL_BIND_INDEX_BUFFER (1 << 5) +#define VIRGL_BIND_CONSTANT_BUFFER (1 << 6) +#define VIRGL_BIND_DISPLAY_TARGET (1 << 7) +#define VIRGL_BIND_COMMAND_ARGS (1 << 8) +#define VIRGL_BIND_STREAM_OUTPUT (1 << 11) +#define VIRGL_BIND_SHADER_BUFFER (1 << 14) +#define VIRGL_BIND_QUERY_BUFFER (1 << 15) +#define VIRGL_BIND_CURSOR (1 << 16) +#define VIRGL_BIND_CUSTOM (1 << 17) +#define VIRGL_BIND_SCANOUT (1 << 18) +/* Used for buffers that are backed by guest storage and + * are only read by the host. + */ +#define VIRGL_BIND_STAGING (1 << 19) +#define VIRGL_BIND_SHARED (1 << 20) + +/* Extra flags that may be passed */ +#define VIRGL_BIND_PREFER_EMULATED_BGRA (1 << 21) + +struct virgl_caps_bool_set1 { + unsigned indep_blend_enable:1; + unsigned indep_blend_func:1; + unsigned cube_map_array:1; + unsigned shader_stencil_export:1; + unsigned conditional_render:1; + unsigned start_instance:1; + unsigned primitive_restart:1; + unsigned blend_eq_sep:1; + unsigned instanceid:1; + unsigned vertex_element_instance_divisor:1; + unsigned seamless_cube_map:1; + unsigned occlusion_query:1; + unsigned timer_query:1; + unsigned streamout_pause_resume:1; + unsigned texture_multisample:1; + unsigned fragment_coord_conventions:1; + unsigned depth_clip_disable:1; + unsigned seamless_cube_map_per_texture:1; + unsigned ubo:1; + unsigned color_clamping:1; /* not in GL 3.1 core profile */ + unsigned poly_stipple:1; /* not in GL 3.1 core profile */ + unsigned mirror_clamp:1; + unsigned texture_query_lod:1; + unsigned has_fp64:1; + unsigned has_tessellation_shaders:1; + unsigned has_indirect_draw:1; + unsigned has_sample_shading:1; + unsigned has_cull:1; + unsigned conditional_render_inverted:1; + unsigned derivative_control:1; + unsigned polygon_offset_clamp:1; + unsigned transform_feedback_overflow_query:1; + /* DO NOT ADD ANYMORE MEMBERS - need to add another 32-bit to v2 caps */ +}; + +/* endless expansion capabilites - current gallium has 252 formats */ +struct virgl_supported_format_mask { + uint32_t bitmask[16]; +}; +/* capabilities set 2 - version 1 - 32-bit and float values */ +struct virgl_caps_v1 { + uint32_t max_version; + struct virgl_supported_format_mask sampler; + struct virgl_supported_format_mask render; + struct virgl_supported_format_mask depthstencil; + struct virgl_supported_format_mask vertexbuffer; + struct virgl_caps_bool_set1 bset; + uint32_t glsl_level; + uint32_t max_texture_array_layers; + uint32_t max_streamout_buffers; + uint32_t max_dual_source_render_targets; + uint32_t max_render_targets; + uint32_t max_samples; + uint32_t prim_mask; + uint32_t max_tbo_size; + uint32_t max_uniform_blocks; + uint32_t max_viewports; + uint32_t max_texture_gather_components; +}; + +/* + * This struct should be growable when used in capset 2, + * so we shouldn't have to add a v3 ever. + */ +struct virgl_caps_v2 { + struct virgl_caps_v1 v1; + float min_aliased_point_size; + float max_aliased_point_size; + float min_smooth_point_size; + float max_smooth_point_size; + float min_aliased_line_width; + float max_aliased_line_width; + float min_smooth_line_width; + float max_smooth_line_width; + float max_texture_lod_bias; + uint32_t max_geom_output_vertices; + uint32_t max_geom_total_output_components; + uint32_t max_vertex_outputs; + uint32_t max_vertex_attribs; + uint32_t max_shader_patch_varyings; + int32_t min_texel_offset; + int32_t max_texel_offset; + int32_t min_texture_gather_offset; + int32_t max_texture_gather_offset; + uint32_t texture_buffer_offset_alignment; + uint32_t uniform_buffer_offset_alignment; + uint32_t shader_buffer_offset_alignment; + uint32_t capability_bits; + uint32_t sample_locations[8]; + uint32_t max_vertex_attrib_stride; + uint32_t max_shader_buffer_frag_compute; + uint32_t max_shader_buffer_other_stages; + uint32_t max_shader_image_frag_compute; + uint32_t max_shader_image_other_stages; + uint32_t max_image_samples; + uint32_t max_compute_work_group_invocations; + uint32_t max_compute_shared_memory_size; + uint32_t max_compute_grid_size[3]; + uint32_t max_compute_block_size[3]; + uint32_t max_texture_2d_size; + uint32_t max_texture_3d_size; + uint32_t max_texture_cube_size; + uint32_t max_combined_shader_buffers; + uint32_t max_atomic_counters[6]; + uint32_t max_atomic_counter_buffers[6]; + uint32_t max_combined_atomic_counters; + uint32_t max_combined_atomic_counter_buffers; + uint32_t host_feature_check_version; + struct virgl_supported_format_mask supported_readback_formats; + struct virgl_supported_format_mask scanout; + uint32_t capability_bits_v2; +}; + +union virgl_caps { + uint32_t max_version; + struct virgl_caps_v1 v1; + struct virgl_caps_v2 v2; +}; + +enum virgl_errors { + VIRGL_ERROR_NONE, + VIRGL_ERROR_UNKNOWN, + VIRGL_ERROR_UNKNOWN_RESOURCE_FORMAT, +}; + +enum virgl_ctx_errors { + VIRGL_ERROR_CTX_NONE, + VIRGL_ERROR_CTX_UNKNOWN, + VIRGL_ERROR_CTX_ILLEGAL_SHADER, + VIRGL_ERROR_CTX_ILLEGAL_HANDLE, + VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, + VIRGL_ERROR_CTX_ILLEGAL_SURFACE, + VIRGL_ERROR_CTX_ILLEGAL_VERTEX_FORMAT, + VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, + VIRGL_ERROR_CTX_GLES_HAVE_TES_BUT_MISS_TCS, +}; + +#define VIRGL_RESOURCE_Y_0_TOP (1 << 0) +#endif diff --git a/src/virtio/virtio-gpu/virgl_protocol.h b/src/virtio/virtio-gpu/virgl_protocol.h new file mode 100644 index 00000000000..0139abd825b --- /dev/null +++ b/src/virtio/virtio-gpu/virgl_protocol.h @@ -0,0 +1,617 @@ +/* + * Copyright 2014, 2015 Red Hat. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef VIRGL_PROTOCOL_H +#define VIRGL_PROTOCOL_H + +#define VIRGL_QUERY_STATE_NEW 0 +#define VIRGL_QUERY_STATE_DONE 1 +#define VIRGL_QUERY_STATE_WAIT_HOST 2 + +struct virgl_host_query_state { + uint32_t query_state; + uint32_t result_size; + uint64_t result; +}; + +enum virgl_object_type { + VIRGL_OBJECT_NULL, + VIRGL_OBJECT_BLEND, + VIRGL_OBJECT_RASTERIZER, + VIRGL_OBJECT_DSA, + VIRGL_OBJECT_SHADER, + VIRGL_OBJECT_VERTEX_ELEMENTS, + VIRGL_OBJECT_SAMPLER_VIEW, + VIRGL_OBJECT_SAMPLER_STATE, + VIRGL_OBJECT_SURFACE, + VIRGL_OBJECT_QUERY, + VIRGL_OBJECT_STREAMOUT_TARGET, + VIRGL_MAX_OBJECTS, +}; + +/* context cmds to be encoded in the command stream */ +enum virgl_context_cmd { + VIRGL_CCMD_NOP = 0, + VIRGL_CCMD_CREATE_OBJECT = 1, + VIRGL_CCMD_BIND_OBJECT, + VIRGL_CCMD_DESTROY_OBJECT, + VIRGL_CCMD_SET_VIEWPORT_STATE, + VIRGL_CCMD_SET_FRAMEBUFFER_STATE, + VIRGL_CCMD_SET_VERTEX_BUFFERS, + VIRGL_CCMD_CLEAR, + VIRGL_CCMD_DRAW_VBO, + VIRGL_CCMD_RESOURCE_INLINE_WRITE, + VIRGL_CCMD_SET_SAMPLER_VIEWS, + VIRGL_CCMD_SET_INDEX_BUFFER, + VIRGL_CCMD_SET_CONSTANT_BUFFER, + VIRGL_CCMD_SET_STENCIL_REF, + VIRGL_CCMD_SET_BLEND_COLOR, + VIRGL_CCMD_SET_SCISSOR_STATE, + VIRGL_CCMD_BLIT, + VIRGL_CCMD_RESOURCE_COPY_REGION, + VIRGL_CCMD_BIND_SAMPLER_STATES, + VIRGL_CCMD_BEGIN_QUERY, + VIRGL_CCMD_END_QUERY, + VIRGL_CCMD_GET_QUERY_RESULT, + VIRGL_CCMD_SET_POLYGON_STIPPLE, + VIRGL_CCMD_SET_CLIP_STATE, + VIRGL_CCMD_SET_SAMPLE_MASK, + VIRGL_CCMD_SET_STREAMOUT_TARGETS, + VIRGL_CCMD_SET_RENDER_CONDITION, + VIRGL_CCMD_SET_UNIFORM_BUFFER, + + VIRGL_CCMD_SET_SUB_CTX, + VIRGL_CCMD_CREATE_SUB_CTX, + VIRGL_CCMD_DESTROY_SUB_CTX, + VIRGL_CCMD_BIND_SHADER, + VIRGL_CCMD_SET_TESS_STATE, + VIRGL_CCMD_SET_MIN_SAMPLES, + VIRGL_CCMD_SET_SHADER_BUFFERS, + VIRGL_CCMD_SET_SHADER_IMAGES, + VIRGL_CCMD_MEMORY_BARRIER, + VIRGL_CCMD_LAUNCH_GRID, + VIRGL_CCMD_SET_FRAMEBUFFER_STATE_NO_ATTACH, + VIRGL_CCMD_TEXTURE_BARRIER, + VIRGL_CCMD_SET_ATOMIC_BUFFERS, + VIRGL_CCMD_SET_DEBUG_FLAGS, + VIRGL_CCMD_GET_QUERY_RESULT_QBO, + VIRGL_CCMD_TRANSFER3D, + VIRGL_CCMD_END_TRANSFERS, + VIRGL_CCMD_COPY_TRANSFER3D, + VIRGL_CCMD_SET_TWEAKS, + VIRGL_CCMD_CLEAR_TEXTURE, +}; + +/* + 8-bit cmd headers + 8-bit object type + 16-bit length +*/ + +#define VIRGL_CMD0(cmd, obj, len) ((cmd) | ((obj) << 8) | ((len) << 16)) +#define VIRGL_CMD0_MAX_DWORDS (((1ULL << 16) - 1) / 4) * 4 + +/* hw specification */ +#define VIRGL_MAX_COLOR_BUFS 8 +#define VIRGL_MAX_CLIP_PLANES 8 + +#define VIRGL_OBJ_CREATE_HEADER 0 +#define VIRGL_OBJ_CREATE_HANDLE 1 + +#define VIRGL_OBJ_BIND_HEADER 0 +#define VIRGL_OBJ_BIND_HANDLE 1 + +#define VIRGL_OBJ_DESTROY_HANDLE 1 + +/* some of these defines are a specification - not used in the code */ +/* bit offsets for blend state object */ +#define VIRGL_OBJ_BLEND_SIZE (VIRGL_MAX_COLOR_BUFS + 3) +#define VIRGL_OBJ_BLEND_HANDLE 1 +#define VIRGL_OBJ_BLEND_S0 2 +#define VIRGL_OBJ_BLEND_S0_INDEPENDENT_BLEND_ENABLE(x) ((x) & 0x1 << 0) +#define VIRGL_OBJ_BLEND_S0_LOGICOP_ENABLE(x) (((x) & 0x1) << 1) +#define VIRGL_OBJ_BLEND_S0_DITHER(x) (((x) & 0x1) << 2) +#define VIRGL_OBJ_BLEND_S0_ALPHA_TO_COVERAGE(x) (((x) & 0x1) << 3) +#define VIRGL_OBJ_BLEND_S0_ALPHA_TO_ONE(x) (((x) & 0x1) << 4) +#define VIRGL_OBJ_BLEND_S1 3 +#define VIRGL_OBJ_BLEND_S1_LOGICOP_FUNC(x) (((x) & 0xf) << 0) +/* repeated once per number of cbufs */ + +#define VIRGL_OBJ_BLEND_S2(cbuf) (4 + (cbuf)) +#define VIRGL_OBJ_BLEND_S2_RT_BLEND_ENABLE(x) (((x) & 0x1) << 0) +#define VIRGL_OBJ_BLEND_S2_RT_RGB_FUNC(x) (((x) & 0x7) << 1) +#define VIRGL_OBJ_BLEND_S2_RT_RGB_SRC_FACTOR(x) (((x) & 0x1f) << 4) +#define VIRGL_OBJ_BLEND_S2_RT_RGB_DST_FACTOR(x) (((x) & 0x1f) << 9) +#define VIRGL_OBJ_BLEND_S2_RT_ALPHA_FUNC(x) (((x) & 0x7) << 14) +#define VIRGL_OBJ_BLEND_S2_RT_ALPHA_SRC_FACTOR(x) (((x) & 0x1f) << 17) +#define VIRGL_OBJ_BLEND_S2_RT_ALPHA_DST_FACTOR(x) (((x) & 0x1f) << 22) +#define VIRGL_OBJ_BLEND_S2_RT_COLORMASK(x) (((x) & 0xf) << 27) + +/* bit offsets for DSA state */ +#define VIRGL_OBJ_DSA_SIZE 5 +#define VIRGL_OBJ_DSA_HANDLE 1 +#define VIRGL_OBJ_DSA_S0 2 +#define VIRGL_OBJ_DSA_S0_DEPTH_ENABLE(x) (((x) & 0x1) << 0) +#define VIRGL_OBJ_DSA_S0_DEPTH_WRITEMASK(x) (((x) & 0x1) << 1) +#define VIRGL_OBJ_DSA_S0_DEPTH_FUNC(x) (((x) & 0x7) << 2) +#define VIRGL_OBJ_DSA_S0_ALPHA_ENABLED(x) (((x) & 0x1) << 8) +#define VIRGL_OBJ_DSA_S0_ALPHA_FUNC(x) (((x) & 0x7) << 9) +#define VIRGL_OBJ_DSA_S1 3 +#define VIRGL_OBJ_DSA_S2 4 +#define VIRGL_OBJ_DSA_S1_STENCIL_ENABLED(x) (((x) & 0x1) << 0) +#define VIRGL_OBJ_DSA_S1_STENCIL_FUNC(x) (((x) & 0x7) << 1) +#define VIRGL_OBJ_DSA_S1_STENCIL_FAIL_OP(x) (((x) & 0x7) << 4) +#define VIRGL_OBJ_DSA_S1_STENCIL_ZPASS_OP(x) (((x) & 0x7) << 7) +#define VIRGL_OBJ_DSA_S1_STENCIL_ZFAIL_OP(x) (((x) & 0x7) << 10) +#define VIRGL_OBJ_DSA_S1_STENCIL_VALUEMASK(x) (((x) & 0xff) << 13) +#define VIRGL_OBJ_DSA_S1_STENCIL_WRITEMASK(x) (((x) & 0xff) << 21) +#define VIRGL_OBJ_DSA_ALPHA_REF 5 + +/* offsets for rasterizer state */ +#define VIRGL_OBJ_RS_SIZE 9 +#define VIRGL_OBJ_RS_HANDLE 1 +#define VIRGL_OBJ_RS_S0 2 +#define VIRGL_OBJ_RS_S0_FLATSHADE(x) (((x) & 0x1) << 0) +#define VIRGL_OBJ_RS_S0_DEPTH_CLIP(x) (((x) & 0x1) << 1) +#define VIRGL_OBJ_RS_S0_CLIP_HALFZ(x) (((x) & 0x1) << 2) +#define VIRGL_OBJ_RS_S0_RASTERIZER_DISCARD(x) (((x) & 0x1) << 3) +#define VIRGL_OBJ_RS_S0_FLATSHADE_FIRST(x) (((x) & 0x1) << 4) +#define VIRGL_OBJ_RS_S0_LIGHT_TWOSIZE(x) (((x) & 0x1) << 5) +#define VIRGL_OBJ_RS_S0_SPRITE_COORD_MODE(x) (((x) & 0x1) << 6) +#define VIRGL_OBJ_RS_S0_POINT_QUAD_RASTERIZATION(x) (((x) & 0x1) << 7) +#define VIRGL_OBJ_RS_S0_CULL_FACE(x) (((x) & 0x3) << 8) +#define VIRGL_OBJ_RS_S0_FILL_FRONT(x) (((x) & 0x3) << 10) +#define VIRGL_OBJ_RS_S0_FILL_BACK(x) (((x) & 0x3) << 12) +#define VIRGL_OBJ_RS_S0_SCISSOR(x) (((x) & 0x1) << 14) +#define VIRGL_OBJ_RS_S0_FRONT_CCW(x) (((x) & 0x1) << 15) +#define VIRGL_OBJ_RS_S0_CLAMP_VERTEX_COLOR(x) (((x) & 0x1) << 16) +#define VIRGL_OBJ_RS_S0_CLAMP_FRAGMENT_COLOR(x) (((x) & 0x1) << 17) +#define VIRGL_OBJ_RS_S0_OFFSET_LINE(x) (((x) & 0x1) << 18) +#define VIRGL_OBJ_RS_S0_OFFSET_POINT(x) (((x) & 0x1) << 19) +#define VIRGL_OBJ_RS_S0_OFFSET_TRI(x) (((x) & 0x1) << 20) +#define VIRGL_OBJ_RS_S0_POLY_SMOOTH(x) (((x) & 0x1) << 21) +#define VIRGL_OBJ_RS_S0_POLY_STIPPLE_ENABLE(x) (((x) & 0x1) << 22) +#define VIRGL_OBJ_RS_S0_POINT_SMOOTH(x) (((x) & 0x1) << 23) +#define VIRGL_OBJ_RS_S0_POINT_SIZE_PER_VERTEX(x) (((x) & 0x1) << 24) +#define VIRGL_OBJ_RS_S0_MULTISAMPLE(x) (((x) & 0x1) << 25) +#define VIRGL_OBJ_RS_S0_LINE_SMOOTH(x) (((x) & 0x1) << 26) +#define VIRGL_OBJ_RS_S0_LINE_STIPPLE_ENABLE(x) (((x) & 0x1) << 27) +#define VIRGL_OBJ_RS_S0_LINE_LAST_PIXEL(x) (((x) & 0x1) << 28) +#define VIRGL_OBJ_RS_S0_HALF_PIXEL_CENTER(x) (((x) & 0x1) << 29) +#define VIRGL_OBJ_RS_S0_BOTTOM_EDGE_RULE(x) (((x) & 0x1) << 30) +#define VIRGL_OBJ_RS_S0_FORCE_PERSAMPLE_INTERP(x) (((x) & 0x1) << 31) + +#define VIRGL_OBJ_RS_POINT_SIZE 3 +#define VIRGL_OBJ_RS_SPRITE_COORD_ENABLE 4 +#define VIRGL_OBJ_RS_S3 5 + +#define VIRGL_OBJ_RS_S3_LINE_STIPPLE_PATTERN(x) (((x) & 0xffff) << 0) +#define VIRGL_OBJ_RS_S3_LINE_STIPPLE_FACTOR(x) (((x) & 0xff) << 16) +#define VIRGL_OBJ_RS_S3_CLIP_PLANE_ENABLE(x) (((x) & 0xff) << 24) +#define VIRGL_OBJ_RS_LINE_WIDTH 6 +#define VIRGL_OBJ_RS_OFFSET_UNITS 7 +#define VIRGL_OBJ_RS_OFFSET_SCALE 8 +#define VIRGL_OBJ_RS_OFFSET_CLAMP 9 + +#define VIRGL_OBJ_CLEAR_SIZE 8 +#define VIRGL_OBJ_CLEAR_BUFFERS 1 +#define VIRGL_OBJ_CLEAR_COLOR_0 2 /* color is 4 * u32/f32/i32 */ +#define VIRGL_OBJ_CLEAR_COLOR_1 3 +#define VIRGL_OBJ_CLEAR_COLOR_2 4 +#define VIRGL_OBJ_CLEAR_COLOR_3 5 +#define VIRGL_OBJ_CLEAR_DEPTH_0 6 /* depth is a double precision float */ +#define VIRGL_OBJ_CLEAR_DEPTH_1 7 +#define VIRGL_OBJ_CLEAR_STENCIL 8 + +/* shader object */ +#define VIRGL_OBJ_SHADER_HDR_SIZE(nso) (5 + ((nso) ? (2 * nso) + 4 : 0)) +#define VIRGL_OBJ_SHADER_HANDLE 1 +#define VIRGL_OBJ_SHADER_TYPE 2 +#define VIRGL_OBJ_SHADER_OFFSET 3 +#define VIRGL_OBJ_SHADER_OFFSET_VAL(x) (((x) & 0x7fffffff) << 0) +/* start contains full length in VAL - also implies continuations */ +/* continuation contains offset in VAL */ +#define VIRGL_OBJ_SHADER_OFFSET_CONT (0x1u << 31) +#define VIRGL_OBJ_SHADER_NUM_TOKENS 4 +#define VIRGL_OBJ_SHADER_SO_NUM_OUTPUTS 5 +#define VIRGL_OBJ_SHADER_SO_STRIDE(x) (6 + (x)) +#define VIRGL_OBJ_SHADER_SO_OUTPUT0(x) (10 + (x * 2)) +#define VIRGL_OBJ_SHADER_SO_OUTPUT_REGISTER_INDEX(x) (((x) & 0xff) << 0) +#define VIRGL_OBJ_SHADER_SO_OUTPUT_START_COMPONENT(x) (((x) & 0x3) << 8) +#define VIRGL_OBJ_SHADER_SO_OUTPUT_NUM_COMPONENTS(x) (((x) & 0x7) << 10) +#define VIRGL_OBJ_SHADER_SO_OUTPUT_BUFFER(x) (((x) & 0x7) << 13) +#define VIRGL_OBJ_SHADER_SO_OUTPUT_DST_OFFSET(x) (((x) & 0xffff) << 16) +#define VIRGL_OBJ_SHADER_SO_OUTPUT0_SO(x) (11 + (x * 2)) +#define VIRGL_OBJ_SHADER_SO_OUTPUT_STREAM(x) (((x) & 0x03) << 0) + +/* viewport state */ +#define VIRGL_SET_VIEWPORT_STATE_SIZE(num_viewports) ((6 * num_viewports) + 1) +#define VIRGL_SET_VIEWPORT_START_SLOT 1 +#define VIRGL_SET_VIEWPORT_STATE_SCALE_0(x) (2 + (x * 6)) +#define VIRGL_SET_VIEWPORT_STATE_SCALE_1(x) (3 + (x * 6)) +#define VIRGL_SET_VIEWPORT_STATE_SCALE_2(x) (4 + (x * 6)) +#define VIRGL_SET_VIEWPORT_STATE_TRANSLATE_0(x) (5 + (x * 6)) +#define VIRGL_SET_VIEWPORT_STATE_TRANSLATE_1(x) (6 + (x * 6)) +#define VIRGL_SET_VIEWPORT_STATE_TRANSLATE_2(x) (7 + (x * 6)) + +/* framebuffer state */ +#define VIRGL_SET_FRAMEBUFFER_STATE_SIZE(nr_cbufs) (nr_cbufs + 2) +#define VIRGL_SET_FRAMEBUFFER_STATE_NR_CBUFS 1 +#define VIRGL_SET_FRAMEBUFFER_STATE_NR_ZSURF_HANDLE 2 +#define VIRGL_SET_FRAMEBUFFER_STATE_CBUF_HANDLE(x) ((x) + 3) + +/* vertex elements object */ +#define VIRGL_OBJ_VERTEX_ELEMENTS_SIZE(num_elements) (((num_elements) * 4) + 1) +#define VIRGL_OBJ_VERTEX_ELEMENTS_HANDLE 1 +#define VIRGL_OBJ_VERTEX_ELEMENTS_V0_SRC_OFFSET(x) (((x) * 4) + 2) /* repeated per VE */ +#define VIRGL_OBJ_VERTEX_ELEMENTS_V0_INSTANCE_DIVISOR(x) (((x) * 4) + 3) +#define VIRGL_OBJ_VERTEX_ELEMENTS_V0_VERTEX_BUFFER_INDEX(x) (((x) * 4) + 4) +#define VIRGL_OBJ_VERTEX_ELEMENTS_V0_SRC_FORMAT(x) (((x) * 4) + 5) + +/* vertex buffers */ +#define VIRGL_SET_VERTEX_BUFFERS_SIZE(num_buffers) ((num_buffers) * 3) +#define VIRGL_SET_VERTEX_BUFFER_STRIDE(x) (((x) * 3) + 1) +#define VIRGL_SET_VERTEX_BUFFER_OFFSET(x) (((x) * 3) + 2) +#define VIRGL_SET_VERTEX_BUFFER_HANDLE(x) (((x) * 3) + 3) + +/* index buffer */ +#define VIRGL_SET_INDEX_BUFFER_SIZE(ib) (((ib) ? 2 : 0) + 1) +#define VIRGL_SET_INDEX_BUFFER_HANDLE 1 +#define VIRGL_SET_INDEX_BUFFER_INDEX_SIZE 2 /* only if sending an IB handle */ +#define VIRGL_SET_INDEX_BUFFER_OFFSET 3 /* only if sending an IB handle */ + +/* constant buffer */ +#define VIRGL_SET_CONSTANT_BUFFER_SHADER_TYPE 1 +#define VIRGL_SET_CONSTANT_BUFFER_INDEX 2 +#define VIRGL_SET_CONSTANT_BUFFER_DATA_START 3 + +#define VIRGL_SET_UNIFORM_BUFFER_SIZE 5 +#define VIRGL_SET_UNIFORM_BUFFER_SHADER_TYPE 1 +#define VIRGL_SET_UNIFORM_BUFFER_INDEX 2 +#define VIRGL_SET_UNIFORM_BUFFER_OFFSET 3 +#define VIRGL_SET_UNIFORM_BUFFER_LENGTH 4 +#define VIRGL_SET_UNIFORM_BUFFER_RES_HANDLE 5 + +/* draw VBO */ +#define VIRGL_DRAW_VBO_SIZE 12 +#define VIRGL_DRAW_VBO_SIZE_TESS 14 +#define VIRGL_DRAW_VBO_SIZE_INDIRECT 20 +#define VIRGL_DRAW_VBO_START 1 +#define VIRGL_DRAW_VBO_COUNT 2 +#define VIRGL_DRAW_VBO_MODE 3 +#define VIRGL_DRAW_VBO_INDEXED 4 +#define VIRGL_DRAW_VBO_INSTANCE_COUNT 5 +#define VIRGL_DRAW_VBO_INDEX_BIAS 6 +#define VIRGL_DRAW_VBO_START_INSTANCE 7 +#define VIRGL_DRAW_VBO_PRIMITIVE_RESTART 8 +#define VIRGL_DRAW_VBO_RESTART_INDEX 9 +#define VIRGL_DRAW_VBO_MIN_INDEX 10 +#define VIRGL_DRAW_VBO_MAX_INDEX 11 +#define VIRGL_DRAW_VBO_COUNT_FROM_SO 12 +/* tess packet */ +#define VIRGL_DRAW_VBO_VERTICES_PER_PATCH 13 +#define VIRGL_DRAW_VBO_DRAWID 14 +/* indirect packet */ +#define VIRGL_DRAW_VBO_INDIRECT_HANDLE 15 +#define VIRGL_DRAW_VBO_INDIRECT_OFFSET 16 +#define VIRGL_DRAW_VBO_INDIRECT_STRIDE 17 +#define VIRGL_DRAW_VBO_INDIRECT_DRAW_COUNT 18 +#define VIRGL_DRAW_VBO_INDIRECT_DRAW_COUNT_OFFSET 19 +#define VIRGL_DRAW_VBO_INDIRECT_DRAW_COUNT_HANDLE 20 + +/* create surface */ +#define VIRGL_OBJ_SURFACE_SIZE 5 +#define VIRGL_OBJ_SURFACE_HANDLE 1 +#define VIRGL_OBJ_SURFACE_RES_HANDLE 2 +#define VIRGL_OBJ_SURFACE_FORMAT 3 +#define VIRGL_OBJ_SURFACE_BUFFER_FIRST_ELEMENT 4 +#define VIRGL_OBJ_SURFACE_BUFFER_LAST_ELEMENT 5 +#define VIRGL_OBJ_SURFACE_TEXTURE_LEVEL 4 +#define VIRGL_OBJ_SURFACE_TEXTURE_LAYERS 5 + +/* create streamout target */ +#define VIRGL_OBJ_STREAMOUT_SIZE 4 +#define VIRGL_OBJ_STREAMOUT_HANDLE 1 +#define VIRGL_OBJ_STREAMOUT_RES_HANDLE 2 +#define VIRGL_OBJ_STREAMOUT_BUFFER_OFFSET 3 +#define VIRGL_OBJ_STREAMOUT_BUFFER_SIZE 4 + +/* sampler state */ +#define VIRGL_OBJ_SAMPLER_STATE_SIZE 9 +#define VIRGL_OBJ_SAMPLER_STATE_HANDLE 1 +#define VIRGL_OBJ_SAMPLER_STATE_S0 2 +#define VIRGL_OBJ_SAMPLE_STATE_S0_WRAP_S(x) (((x) & 0x7) << 0) +#define VIRGL_OBJ_SAMPLE_STATE_S0_WRAP_T(x) (((x) & 0x7) << 3) +#define VIRGL_OBJ_SAMPLE_STATE_S0_WRAP_R(x) (((x) & 0x7) << 6) +#define VIRGL_OBJ_SAMPLE_STATE_S0_MIN_IMG_FILTER(x) (((x) & 0x3) << 9) +#define VIRGL_OBJ_SAMPLE_STATE_S0_MIN_MIP_FILTER(x) (((x) & 0x3) << 11) +#define VIRGL_OBJ_SAMPLE_STATE_S0_MAG_IMG_FILTER(x) (((x) & 0x3) << 13) +#define VIRGL_OBJ_SAMPLE_STATE_S0_COMPARE_MODE(x) (((x) & 0x1) << 15) +#define VIRGL_OBJ_SAMPLE_STATE_S0_COMPARE_FUNC(x) (((x) & 0x7) << 16) +#define VIRGL_OBJ_SAMPLE_STATE_S0_SEAMLESS_CUBE_MAP(x) (((x) & 0x1) << 19) + +#define VIRGL_OBJ_SAMPLER_STATE_LOD_BIAS 3 +#define VIRGL_OBJ_SAMPLER_STATE_MIN_LOD 4 +#define VIRGL_OBJ_SAMPLER_STATE_MAX_LOD 5 +#define VIRGL_OBJ_SAMPLER_STATE_BORDER_COLOR(x) ((x) + 6) /* 6 - 9 */ + + +/* sampler view */ +#define VIRGL_OBJ_SAMPLER_VIEW_SIZE 6 +#define VIRGL_OBJ_SAMPLER_VIEW_HANDLE 1 +#define VIRGL_OBJ_SAMPLER_VIEW_RES_HANDLE 2 +#define VIRGL_OBJ_SAMPLER_VIEW_FORMAT 3 +#define VIRGL_OBJ_SAMPLER_VIEW_BUFFER_FIRST_ELEMENT 4 +#define VIRGL_OBJ_SAMPLER_VIEW_BUFFER_LAST_ELEMENT 5 +#define VIRGL_OBJ_SAMPLER_VIEW_TEXTURE_LAYER 4 +#define VIRGL_OBJ_SAMPLER_VIEW_TEXTURE_LEVEL 5 +#define VIRGL_OBJ_SAMPLER_VIEW_SWIZZLE 6 +#define VIRGL_OBJ_SAMPLER_VIEW_SWIZZLE_R(x) (((x) & 0x7) << 0) +#define VIRGL_OBJ_SAMPLER_VIEW_SWIZZLE_G(x) (((x) & 0x7) << 3) +#define VIRGL_OBJ_SAMPLER_VIEW_SWIZZLE_B(x) (((x) & 0x7) << 6) +#define VIRGL_OBJ_SAMPLER_VIEW_SWIZZLE_A(x) (((x) & 0x7) << 9) + +/* set sampler views */ +#define VIRGL_SET_SAMPLER_VIEWS_SIZE(num_views) ((num_views) + 2) +#define VIRGL_SET_SAMPLER_VIEWS_SHADER_TYPE 1 +#define VIRGL_SET_SAMPLER_VIEWS_START_SLOT 2 +#define VIRGL_SET_SAMPLER_VIEWS_V0_HANDLE 3 + +/* bind sampler states */ +#define VIRGL_BIND_SAMPLER_STATES(num_states) ((num_states) + 2) +#define VIRGL_BIND_SAMPLER_STATES_SHADER_TYPE 1 +#define VIRGL_BIND_SAMPLER_STATES_START_SLOT 2 +#define VIRGL_BIND_SAMPLER_STATES_S0_HANDLE 3 + +/* set stencil reference */ +#define VIRGL_SET_STENCIL_REF_SIZE 1 +#define VIRGL_SET_STENCIL_REF 1 +#define VIRGL_STENCIL_REF_VAL(f, s) ((f & 0xff) | (((s & 0xff) << 8))) + +/* set blend color */ +#define VIRGL_SET_BLEND_COLOR_SIZE 4 +#define VIRGL_SET_BLEND_COLOR(x) ((x) + 1) + +/* set scissor state */ +#define VIRGL_SET_SCISSOR_STATE_SIZE(x) (1 + 2 * x) +#define VIRGL_SET_SCISSOR_START_SLOT 1 +#define VIRGL_SET_SCISSOR_MINX_MINY(x) (2 + (x * 2)) +#define VIRGL_SET_SCISSOR_MAXX_MAXY(x) (3 + (x * 2)) + +/* resource copy region */ +#define VIRGL_CMD_RESOURCE_COPY_REGION_SIZE 13 +#define VIRGL_CMD_RCR_DST_RES_HANDLE 1 +#define VIRGL_CMD_RCR_DST_LEVEL 2 +#define VIRGL_CMD_RCR_DST_X 3 +#define VIRGL_CMD_RCR_DST_Y 4 +#define VIRGL_CMD_RCR_DST_Z 5 +#define VIRGL_CMD_RCR_SRC_RES_HANDLE 6 +#define VIRGL_CMD_RCR_SRC_LEVEL 7 +#define VIRGL_CMD_RCR_SRC_X 8 +#define VIRGL_CMD_RCR_SRC_Y 9 +#define VIRGL_CMD_RCR_SRC_Z 10 +#define VIRGL_CMD_RCR_SRC_W 11 +#define VIRGL_CMD_RCR_SRC_H 12 +#define VIRGL_CMD_RCR_SRC_D 13 + +/* blit */ +#define VIRGL_CMD_BLIT_SIZE 21 +#define VIRGL_CMD_BLIT_S0 1 +#define VIRGL_CMD_BLIT_S0_MASK(x) (((x) & 0xff) << 0) +#define VIRGL_CMD_BLIT_S0_FILTER(x) (((x) & 0x3) << 8) +#define VIRGL_CMD_BLIT_S0_SCISSOR_ENABLE(x) (((x) & 0x1) << 10) +#define VIRGL_CMD_BLIT_S0_RENDER_CONDITION_ENABLE(x) (((x) & 0x1) << 11) +#define VIRGL_CMD_BLIT_S0_ALPHA_BLEND(x) (((x) & 0x1) << 12) +#define VIRGL_CMD_BLIT_SCISSOR_MINX_MINY 2 +#define VIRGL_CMD_BLIT_SCISSOR_MAXX_MAXY 3 +#define VIRGL_CMD_BLIT_DST_RES_HANDLE 4 +#define VIRGL_CMD_BLIT_DST_LEVEL 5 +#define VIRGL_CMD_BLIT_DST_FORMAT 6 +#define VIRGL_CMD_BLIT_DST_X 7 +#define VIRGL_CMD_BLIT_DST_Y 8 +#define VIRGL_CMD_BLIT_DST_Z 9 +#define VIRGL_CMD_BLIT_DST_W 10 +#define VIRGL_CMD_BLIT_DST_H 11 +#define VIRGL_CMD_BLIT_DST_D 12 +#define VIRGL_CMD_BLIT_SRC_RES_HANDLE 13 +#define VIRGL_CMD_BLIT_SRC_LEVEL 14 +#define VIRGL_CMD_BLIT_SRC_FORMAT 15 +#define VIRGL_CMD_BLIT_SRC_X 16 +#define VIRGL_CMD_BLIT_SRC_Y 17 +#define VIRGL_CMD_BLIT_SRC_Z 18 +#define VIRGL_CMD_BLIT_SRC_W 19 +#define VIRGL_CMD_BLIT_SRC_H 20 +#define VIRGL_CMD_BLIT_SRC_D 21 + +/* query object */ +#define VIRGL_OBJ_QUERY_SIZE 4 +#define VIRGL_OBJ_QUERY_HANDLE 1 +#define VIRGL_OBJ_QUERY_TYPE_INDEX 2 +#define VIRGL_OBJ_QUERY_TYPE(x) (x & 0xffff) +#define VIRGL_OBJ_QUERY_INDEX(x) ((x & 0xffff) << 16) +#define VIRGL_OBJ_QUERY_OFFSET 3 +#define VIRGL_OBJ_QUERY_RES_HANDLE 4 + +#define VIRGL_QUERY_BEGIN_HANDLE 1 + +#define VIRGL_QUERY_END_HANDLE 1 + +#define VIRGL_QUERY_RESULT_SIZE 2 +#define VIRGL_QUERY_RESULT_HANDLE 1 +#define VIRGL_QUERY_RESULT_WAIT 2 + +/* render condition */ +#define VIRGL_RENDER_CONDITION_SIZE 3 +#define VIRGL_RENDER_CONDITION_HANDLE 1 +#define VIRGL_RENDER_CONDITION_CONDITION 2 +#define VIRGL_RENDER_CONDITION_MODE 3 + +/* resource inline write */ +#define VIRGL_RESOURCE_IW_RES_HANDLE 1 +#define VIRGL_RESOURCE_IW_LEVEL 2 +#define VIRGL_RESOURCE_IW_USAGE 3 +#define VIRGL_RESOURCE_IW_STRIDE 4 +#define VIRGL_RESOURCE_IW_LAYER_STRIDE 5 +#define VIRGL_RESOURCE_IW_X 6 +#define VIRGL_RESOURCE_IW_Y 7 +#define VIRGL_RESOURCE_IW_Z 8 +#define VIRGL_RESOURCE_IW_W 9 +#define VIRGL_RESOURCE_IW_H 10 +#define VIRGL_RESOURCE_IW_D 11 +#define VIRGL_RESOURCE_IW_DATA_START 12 + +/* set streamout targets */ +#define VIRGL_SET_STREAMOUT_TARGETS_APPEND_BITMASK 1 +#define VIRGL_SET_STREAMOUT_TARGETS_H0 2 + +/* set sample mask */ +#define VIRGL_SET_SAMPLE_MASK_SIZE 1 +#define VIRGL_SET_SAMPLE_MASK_MASK 1 + +/* set clip state */ +#define VIRGL_SET_CLIP_STATE_SIZE 32 +#define VIRGL_SET_CLIP_STATE_C0 1 + +/* polygon stipple */ +#define VIRGL_POLYGON_STIPPLE_SIZE 32 +#define VIRGL_POLYGON_STIPPLE_P0 1 + +#define VIRGL_BIND_SHADER_SIZE 2 +#define VIRGL_BIND_SHADER_HANDLE 1 +#define VIRGL_BIND_SHADER_TYPE 2 + +/* tess state */ +#define VIRGL_TESS_STATE_SIZE 6 + +/* set min samples */ +#define VIRGL_SET_MIN_SAMPLES_SIZE 1 +#define VIRGL_SET_MIN_SAMPLES_MASK 1 + +/* set shader buffers */ +#define VIRGL_SET_SHADER_BUFFER_ELEMENT_SIZE 3 +#define VIRGL_SET_SHADER_BUFFER_SIZE(x) (VIRGL_SET_SHADER_BUFFER_ELEMENT_SIZE * (x)) + 2 +#define VIRGL_SET_SHADER_BUFFER_SHADER_TYPE 1 +#define VIRGL_SET_SHADER_BUFFER_START_SLOT 2 +#define VIRGL_SET_SHADER_BUFFER_OFFSET(x) ((x) * VIRGL_SET_SHADER_BUFFER_ELEMENT_SIZE + 3) +#define VIRGL_SET_SHADER_BUFFER_LENGTH(x) ((x) * VIRGL_SET_SHADER_BUFFER_ELEMENT_SIZE + 4) +#define VIRGL_SET_SHADER_BUFFER_RES_HANDLE(x) ((x) * VIRGL_SET_SHADER_BUFFER_ELEMENT_SIZE + 5) + +/* set shader images */ +#define VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE 5 +#define VIRGL_SET_SHADER_IMAGE_SIZE(x) (VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE * (x)) + 2 +#define VIRGL_SET_SHADER_IMAGE_SHADER_TYPE 1 +#define VIRGL_SET_SHADER_IMAGE_START_SLOT 2 +#define VIRGL_SET_SHADER_IMAGE_FORMAT(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 3) +#define VIRGL_SET_SHADER_IMAGE_ACCESS(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 4) +#define VIRGL_SET_SHADER_IMAGE_LAYER_OFFSET(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 5) +#define VIRGL_SET_SHADER_IMAGE_LEVEL_SIZE(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 6) +#define VIRGL_SET_SHADER_IMAGE_RES_HANDLE(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 7) + +/* memory barrier */ +#define VIRGL_MEMORY_BARRIER_SIZE 1 +#define VIRGL_MEMORY_BARRIER_FLAGS 1 + +/* launch grid */ +#define VIRGL_LAUNCH_GRID_SIZE 8 +#define VIRGL_LAUNCH_BLOCK_X 1 +#define VIRGL_LAUNCH_BLOCK_Y 2 +#define VIRGL_LAUNCH_BLOCK_Z 3 +#define VIRGL_LAUNCH_GRID_X 4 +#define VIRGL_LAUNCH_GRID_Y 5 +#define VIRGL_LAUNCH_GRID_Z 6 +#define VIRGL_LAUNCH_INDIRECT_HANDLE 7 +#define VIRGL_LAUNCH_INDIRECT_OFFSET 8 + +/* framebuffer state no attachment */ +#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_SIZE 2 +#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_WIDTH_HEIGHT 1 +#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_WIDTH(x) (x & 0xffff) +#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_HEIGHT(x) ((x >> 16) & 0xffff) +#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_LAYERS_SAMPLES 2 +#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_LAYERS(x) (x & 0xffff) +#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_SAMPLES(x) ((x >> 16) & 0xff) + +/* texture barrier */ +#define VIRGL_TEXTURE_BARRIER_SIZE 1 +#define VIRGL_TEXTURE_BARRIER_FLAGS 1 + +/* hw atomics */ +#define VIRGL_SET_ATOMIC_BUFFER_ELEMENT_SIZE 3 +#define VIRGL_SET_ATOMIC_BUFFER_SIZE(x) (VIRGL_SET_ATOMIC_BUFFER_ELEMENT_SIZE * (x)) + 1 +#define VIRGL_SET_ATOMIC_BUFFER_START_SLOT 1 +#define VIRGL_SET_ATOMIC_BUFFER_OFFSET(x) ((x) * VIRGL_SET_ATOMIC_BUFFER_ELEMENT_SIZE + 2) +#define VIRGL_SET_ATOMIC_BUFFER_LENGTH(x) ((x) * VIRGL_SET_ATOMIC_BUFFER_ELEMENT_SIZE + 3) +#define VIRGL_SET_ATOMIC_BUFFER_RES_HANDLE(x) ((x) * VIRGL_SET_ATOMIC_BUFFER_ELEMENT_SIZE + 4) + +/* qbo */ +#define VIRGL_QUERY_RESULT_QBO_SIZE 6 +#define VIRGL_QUERY_RESULT_QBO_HANDLE 1 +#define VIRGL_QUERY_RESULT_QBO_QBO_HANDLE 2 +#define VIRGL_QUERY_RESULT_QBO_WAIT 3 +#define VIRGL_QUERY_RESULT_QBO_RESULT_TYPE 4 +#define VIRGL_QUERY_RESULT_QBO_OFFSET 5 +#define VIRGL_QUERY_RESULT_QBO_INDEX 6 + +#define VIRGL_TRANSFER_TO_HOST 1 +#define VIRGL_TRANSFER_FROM_HOST 2 + +/* Transfer */ +#define VIRGL_TRANSFER3D_SIZE 13 +/* The first 11 dwords are the same as VIRGL_RESOURCE_IW_* */ +#define VIRGL_TRANSFER3D_DATA_OFFSET 12 +#define VIRGL_TRANSFER3D_DIRECTION 13 + +/* Copy transfer */ +#define VIRGL_COPY_TRANSFER3D_SIZE 14 +/* The first 11 dwords are the same as VIRGL_RESOURCE_IW_* */ +#define VIRGL_COPY_TRANSFER3D_SRC_RES_HANDLE 12 +#define VIRGL_COPY_TRANSFER3D_SRC_RES_OFFSET 13 +#define VIRGL_COPY_TRANSFER3D_SYNCHRONIZED 14 + +/* set tweak flags */ +#define VIRGL_SET_TWEAKS_SIZE 2 +#define VIRGL_SET_TWEAKS_ID 1 +#define VIRGL_SET_TWEAKS_VALUE 2 + +enum vrend_tweak_type { + virgl_tweak_gles_brga_emulate, + virgl_tweak_gles_brga_apply_dest_swizzle, + virgl_tweak_gles_tf3_samples_passes_multiplier, + virgl_tweak_undefined +}; + +/* Clear texture */ +#define VIRGL_CLEAR_TEXTURE_SIZE 12 +#define VIRGL_TEXTURE_HANDLE 1 +#define VIRGL_TEXTURE_LEVEL 2 +#define VIRGL_TEXTURE_SRC_X 3 +#define VIRGL_TEXTURE_SRC_Y 4 +#define VIRGL_TEXTURE_SRC_Z 5 +#define VIRGL_TEXTURE_SRC_W 6 +#define VIRGL_TEXTURE_SRC_H 7 +#define VIRGL_TEXTURE_SRC_D 8 +#define VIRGL_TEXTURE_ARRAY_A 9 +#define VIRGL_TEXTURE_ARRAY_B 10 +#define VIRGL_TEXTURE_ARRAY_C 11 +#define VIRGL_TEXTURE_ARRAY_D 12 + +#endif diff --git a/src/virtio/vtest/vtest_protocol.h b/src/virtio/vtest/vtest_protocol.h new file mode 100644 index 00000000000..9360213ac45 --- /dev/null +++ b/src/virtio/vtest/vtest_protocol.h @@ -0,0 +1,129 @@ +/* + * Copyright 2014, 2015 Red Hat. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef VTEST_PROTOCOL +#define VTEST_PROTOCOL + +#define VTEST_DEFAULT_SOCKET_NAME "/tmp/.virgl_test" +#define VTEST_PROTOCOL_VERSION 2 + +/* 32-bit length field */ +/* 32-bit cmd field */ +#define VTEST_HDR_SIZE 2 +#define VTEST_CMD_LEN 0 /* length of data */ +#define VTEST_CMD_ID 1 +#define VTEST_CMD_DATA_START 2 + +/* vtest cmds */ +#define VCMD_GET_CAPS 1 + +#define VCMD_RESOURCE_CREATE 2 +#define VCMD_RESOURCE_UNREF 3 + +#define VCMD_TRANSFER_GET 4 +#define VCMD_TRANSFER_PUT 5 + +#define VCMD_SUBMIT_CMD 6 + +#define VCMD_RESOURCE_BUSY_WAIT 7 + +/* pass the process cmd line for debugging */ +#define VCMD_CREATE_RENDERER 8 + +#define VCMD_GET_CAPS2 9 +/* get caps */ +/* 0 length cmd */ +/* resp VCMD_GET_CAPS + caps */ + +#define VCMD_PING_PROTOCOL_VERSION 10 + +#define VCMD_PROTOCOL_VERSION 11 + +#define VCMD_RESOURCE_CREATE2 12 +#define VCMD_TRANSFER_GET2 13 +#define VCMD_TRANSFER_PUT2 14 + +#define VCMD_RES_CREATE_SIZE 10 +#define VCMD_RES_CREATE_RES_HANDLE 0 +#define VCMD_RES_CREATE_TARGET 1 +#define VCMD_RES_CREATE_FORMAT 2 +#define VCMD_RES_CREATE_BIND 3 +#define VCMD_RES_CREATE_WIDTH 4 +#define VCMD_RES_CREATE_HEIGHT 5 +#define VCMD_RES_CREATE_DEPTH 6 +#define VCMD_RES_CREATE_ARRAY_SIZE 7 +#define VCMD_RES_CREATE_LAST_LEVEL 8 +#define VCMD_RES_CREATE_NR_SAMPLES 9 + +#define VCMD_RES_CREATE2_SIZE 11 +#define VCMD_RES_CREATE2_RES_HANDLE 0 +#define VCMD_RES_CREATE2_TARGET 1 +#define VCMD_RES_CREATE2_FORMAT 2 +#define VCMD_RES_CREATE2_BIND 3 +#define VCMD_RES_CREATE2_WIDTH 4 +#define VCMD_RES_CREATE2_HEIGHT 5 +#define VCMD_RES_CREATE2_DEPTH 6 +#define VCMD_RES_CREATE2_ARRAY_SIZE 7 +#define VCMD_RES_CREATE2_LAST_LEVEL 8 +#define VCMD_RES_CREATE2_NR_SAMPLES 9 +#define VCMD_RES_CREATE2_DATA_SIZE 10 + +#define VCMD_RES_UNREF_SIZE 1 +#define VCMD_RES_UNREF_RES_HANDLE 0 + +#define VCMD_TRANSFER_HDR_SIZE 11 +#define VCMD_TRANSFER_RES_HANDLE 0 +#define VCMD_TRANSFER_LEVEL 1 +#define VCMD_TRANSFER_STRIDE 2 +#define VCMD_TRANSFER_LAYER_STRIDE 3 +#define VCMD_TRANSFER_X 4 +#define VCMD_TRANSFER_Y 5 +#define VCMD_TRANSFER_Z 6 +#define VCMD_TRANSFER_WIDTH 7 +#define VCMD_TRANSFER_HEIGHT 8 +#define VCMD_TRANSFER_DEPTH 9 +#define VCMD_TRANSFER_DATA_SIZE 10 + +#define VCMD_TRANSFER2_HDR_SIZE 10 +#define VCMD_TRANSFER2_RES_HANDLE 0 +#define VCMD_TRANSFER2_LEVEL 1 +#define VCMD_TRANSFER2_X 2 +#define VCMD_TRANSFER2_Y 3 +#define VCMD_TRANSFER2_Z 4 +#define VCMD_TRANSFER2_WIDTH 5 +#define VCMD_TRANSFER2_HEIGHT 6 +#define VCMD_TRANSFER2_DEPTH 7 +#define VCMD_TRANSFER2_DATA_SIZE 8 +#define VCMD_TRANSFER2_OFFSET 9 + +#define VCMD_BUSY_WAIT_FLAG_WAIT 1 + +#define VCMD_BUSY_WAIT_SIZE 2 +#define VCMD_BUSY_WAIT_HANDLE 0 +#define VCMD_BUSY_WAIT_FLAGS 1 + +#define VCMD_PING_PROTOCOL_VERSION_SIZE 1 + +#define VCMD_PROTOCOL_VERSION_SIZE 1 +#define VCMD_PROTOCOL_VERSION_VERSION 0 + +#endif