1 // Copyright 2022 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef VIRTGPU_GFXSTREAM_PROTOCOL_H 16 #define VIRTGPU_GFXSTREAM_PROTOCOL_H 17 18 #include <stdint.h> 19 #include "virgl_hw.h" 20 21 namespace gfxstream { 22 23 // See definitions in rutabaga_gfx_ffi.h 24 #define VIRTGPU_CAPSET_VIRGL 1 25 #define VIRTGPU_CAPSET_VIRGL2 2 26 #define VIRTGPU_CAPSET_GFXSTREAM_VULKAN 3 27 #define VIRTGPU_CAPSET_VENUS 4 28 #define VIRTGPU_CAPSET_CROSS_DOMAIN 5 29 #define VIRTGPU_CAPSET_DRM 6 30 #define VIRTGPU_CAPSET_GFXSTREAM_MAGMA 7 31 #define VIRTGPU_CAPSET_GFXSTREAM_GLES 8 32 #define VIRTGPU_CAPSET_GFXSTREAM_COMPOSER 9 33 34 // Address Space Graphics contexts 35 #define GFXSTREAM_CONTEXT_CREATE 0x1001 36 #define GFXSTREAM_CONTEXT_PING 0x1002 37 #define GFXSTREAM_CONTEXT_PING_WITH_RESPONSE 0x1003 38 39 // Native Sync FD 40 #define GFXSTREAM_CREATE_EXPORT_SYNC 0x9000 41 #define GFXSTREAM_CREATE_IMPORT_SYNC 0x9001 42 43 // Vulkan related 44 #define GFXSTREAM_CREATE_EXPORT_SYNC_VK 0xa000 45 #define GFXSTREAM_CREATE_IMPORT_SYNC_VK 0xa001 46 #define GFXSTREAM_CREATE_QSRI_EXPORT_VK 0xa002 47 #define GFXSTREAM_RESOURCE_CREATE_3D 0xa003 48 #define GFXSTREAM_ACQUIRE_SYNC 0xa004 49 50 // clang-format off 51 // A placeholder command to ensure virtio-gpu completes 52 #define GFXSTREAM_PLACEHOLDER_COMMAND_VK 0xf002 53 // clang-format on 54 55 struct gfxstreamHeader { 56 uint32_t opCode; 57 }; 58 59 struct gfxstreamContextCreate { 60 struct gfxstreamHeader hdr; 61 uint32_t resourceId; 62 }; 63 64 struct gfxstreamContextPing { 65 struct gfxstreamHeader hdr; 66 uint32_t resourceId; 67 }; 68 69 struct gfxstreamCreateExportSync { 70 struct gfxstreamHeader hdr; 71 uint32_t syncHandleLo; 72 uint32_t syncHandleHi; 73 }; 74 75 struct gfxstreamCreateExportSyncVK { 76 struct gfxstreamHeader hdr; 77 uint32_t deviceHandleLo; 78 uint32_t deviceHandleHi; 79 uint32_t fenceHandleLo; 80 uint32_t fenceHandleHi; 81 }; 82 83 struct gfxstreamCreateQSRIExportVK { 84 struct gfxstreamHeader hdr; 85 uint32_t imageHandleLo; 86 uint32_t imageHandleHi; 87 }; 88 89 struct gfxstreamPlaceholderCommandVk { 90 struct gfxstreamHeader hdr; 91 uint32_t pad; 92 uint32_t padding; 93 }; 94 95 struct gfxstreamResourceCreate3d { 96 struct gfxstreamHeader hdr; 97 uint32_t target; 98 uint32_t format; 99 uint32_t bind; 100 uint32_t width; 101 uint32_t height; 102 uint32_t depth; 103 uint32_t arraySize; 104 uint32_t lastLevel; 105 uint32_t nrSamples; 106 uint32_t flags; 107 uint32_t pad; 108 uint64_t blobId; 109 }; 110 111 struct gfxstreamAcquireSync { 112 struct gfxstreamHeader hdr; 113 uint32_t padding; 114 uint64_t syncId; 115 }; 116 117 struct vulkanCapset { 118 uint32_t protocolVersion; 119 120 // ASG Ring Parameters 121 uint32_t ringSize; 122 uint32_t bufferSize; 123 124 uint32_t colorBufferMemoryIndex; 125 uint32_t deferredMapping; 126 uint32_t blobAlignment; 127 uint32_t noRenderControlEnc; 128 uint32_t alwaysBlob; 129 uint32_t externalSync; 130 uint32_t virglSupportedFormats[16]; 131 uint32_t vulkanBatchedDescriptorSetUpdate; 132 }; 133 134 struct magmaCapset { 135 uint32_t protocolVersion; 136 // ASG Ring Parameters 137 uint32_t ringSize; 138 uint32_t bufferSize; 139 uint32_t blobAlignment; 140 }; 141 142 struct glesCapset { 143 uint32_t protocolVersion; 144 // ASG Ring Parameters 145 uint32_t ringSize; 146 uint32_t bufferSize; 147 uint32_t blobAlignment; 148 }; 149 150 struct composerCapset { 151 uint32_t protocolVersion; 152 // ASG Ring Parameters 153 uint32_t ringSize; 154 uint32_t bufferSize; 155 uint32_t blobAlignment; 156 }; 157 158 } // namespace gfxstream 159 160 #endif 161