Method, device and storage medium for using virtual GPU
By adding a new interface to the Windows virtual machine for direct communication between the client driver and the Virtio-GPU core mode driver, and obtaining and configuring the device characteristics of the virtual graphics card, the problems of insufficient OpenGL support and low rendering performance in the virtual machine are solved, and hardware-accelerated 3D rendering and improving user experience are achieved.
Patent Information
- Application Number
- CN202411648959.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-11-19
AI Technical Summary
In the prior art, the use of virtual graphics cards in Windows virtual machines cannot be supported by OpenGL, and the rendering cannot be accelerated with the physical graphics cards on the physical machine, resulting in poor 3D performance and system lag.
When the Windows virtual machine user space loads Virtio-GPU OpenGL to install the client driver, a new interface is added for direct communication between the client driver and the Virtio-GPU core mode driver, obtain the device characteristics of the Virtio-GPU in the kernel space, and pass it into the client driver to configure the virtual graphics card.
It realizes OpenGL support for the Virtio-GPU virtual graphics card in Windows virtual machines, and completes 3D rendering with the physical graphics card on the physical machine side, thereby improving the graphics performance of the virtual machine and improving the user experience.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of virtual machine technology, and in particular to a method, device and storage medium for using a virtual GPU. Background Art
[0002] The Linux operating system is an operating system widely used on servers. With the development in recent years, it has been widely used in networks and computer systems, and can provide database management and network services. However, some applications still cannot be effectively supported by the Linux operating system. At present, using Windows virtual machines in Linux systems to run applications that are not compatible with domestic operating systems is a good transitional solution with advantages such as high compatibility and good user experience.
[0003] In terms of graphics processing, most Windows virtual machines currently use virtual graphics cards such as QXL and Virtio-GPU, which only have pure display functions and do not support common 3D rendering functions such as OpenGL and Direct3D. When users use 3D modeling software or run 3D games, the virtual machine can only use the CPU to render 3D graphics, and cannot use the physical graphics card on the physical machine to accelerate the rendering. Not only does the 3D performance fail to meet user requirements, but it also causes the CPU usage in the virtual machine to increase significantly, increasing system freezes and seriously affecting the user experience. Summary of the invention
[0004] The embodiments of the present invention provide a method, device and storage medium for using a virtual GPU to solve the technical problems in the prior art that a virtual graphics card used in a Windows virtual machine cannot obtain OpenGL support and cannot perform accelerated rendering with the help of a physical graphics card on a physical machine.
[0005] In a first aspect, an embodiment of the present invention provides a method for using a virtual GPU, including:
[0006] When the Virtio-GPU OpenGL installable client driver is loaded in the Windows virtual machine user space, a new interface is added to the D3DKMT interface set, wherein the new interface is used to establish direct communication between the client driver and the Virtio-GPU kernel mode driver;
[0007] New interfaces are added to obtain kernel-space Virtio-GPU device characteristics using a direct interaction protocol between the client driver and the Virtio-GPU kernel-mode driver;
[0008] The device characteristics are passed as parameters to the client driver so that the client configures the Virtio-GPU device.
[0009] In a second aspect, an embodiment of the present invention further provides a device for using a virtual GPU, including:
[0010] A new module is added to add an interface to the D3DKMT interface set when the Virtio-GPU OpenGL installable client driver is loaded in the Windows virtual machine user space. The new interface is used to establish direct communication between the client driver and the Virtio-GPU kernel mode driver.
[0011] The acquisition module is used to obtain the device characteristics of the kernel space Virtio-GPU by using the direct interaction protocol between the client driver and the Virtio-GPU kernel mode driver through the newly added interface;
[0012] The input module is used to input the device characteristics as parameters to the client driver, so that the client can configure the Virtio-GPU device.
[0013] In a third aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute a method for using a virtual GPU as provided in the above embodiment.
[0014] The method, device and storage medium for using the virtual GPU provided by the embodiment of the present invention are as follows: when the Virtio-GPU OpenGL installable client driver is loaded in the user space of the Windows virtual machine, a new interface is added to the D3DKMT interface set, and the new interface is used to establish direct communication between the client driver and the Virtio-GPU kernel mode driver; the device characteristics of the kernel space Virtio-GPU are obtained by using the direct interaction protocol between the client driver and the Virtio-GPU kernel mode driver through the new interface; the device characteristics are passed as parameters to the client driver, so that the client can configure the Virtio-GPU device. OpenGL support can be added to the Virtio-GPU virtual graphics card in the Windows virtual machine, and the hardware acceleration function of 3D graphics rendering in the virtual machine can be realized. The Windows virtual machine can complete 3D rendering with the help of the physical graphics card on the physical machine side, thereby improving the graphics performance of the virtual machine and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0016] Figure 1 is a flowchart of a method for using a virtual GPU provided in Embodiment 1 of the present invention;
[0017] Figure 2 1. It is a schematic diagram of a Windows virtual machine Virtio-GPUOpenGL framework of a method for using a virtual GPU provided in Embodiment 1 of the present invention;
[0018] Figure 3 is a flowchart of a method for using a virtual GPU provided in Embodiment 2 of the present invention;
[0019] Figure 4 is a flowchart of a method for using a virtual GPU provided in Embodiment 3 of the present invention;
[0020] Figure 5 It is a structural diagram of a device for using a virtual GPU provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0021] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0022] Embodiment 1
[0023] Figure 1 1 is a flow chart of a method for using a virtual GPU provided in the first embodiment of the present invention. This embodiment is applicable to a Windows virtual machine provided in a Linux system that uses a virtual GPU to draw and render images with the help of a physical graphics card module. The method can be executed by a device for using a virtual GPU, and specifically includes the following steps:
[0024] Step 110, when the Virtio-GPU OpenGL installable client driver is loaded in the Windows virtual machine user space, a new interface is added to the D3DKMT interface set, and the new interface is used to establish direct communication between the client driver and the Virtio-GPU kernel mode driver.
[0025] The Windows operating system is a window operating system developed by Microsoft Corporation of the United States, mainly used in computers, smart phones and other devices. Since the Windows operating system is more widely used than the Linux system, it supports more applications. At present, in the field of information innovation, there are still many special and industry-customized applications that still cannot run perfectly on domestic operating systems. In order to smoothly solve this pain point and accelerate the localization process, the industry has proposed a transitional solution to use Windows virtual machines to run such incompatible programs.
[0026] When using Windows virtual machine solution, its display solution is usually implemented by Virtio virtualization. Virtual resources are usually allocated by CPU. Therefore, it cannot fully support OpenGL, which not only requires more CPU and memory resources, but also reduces graphics performance.
[0027] Therefore, in this embodiment, by modifying the client driver of the Windows virtual machine user space, illustratively, a newly added Virtio-GPU OpenGL installable client driver is provided in the virtual machine side user space to achieve better support for OpenGL by Virtio-GPU.
[0028] Exemplarily, a new interface can be added to the D3DKMT interface set, and the new interface is used to establish direct communication between the client driver and the newly added Virtio-GPU kernel mode driver. The D3DKMT interface set can be regarded as an interface provided by the graphics display interface subsystem, which can be used to communicate indirectly with the DirectX graphics kernel subsystem in the kernel space. Exemplarily, a Virtio-GPU Windows window subsystem module can be added to implement support for the Windows graphics display interface. Exemplarily, a new virgl_gdi_winsys subclass can be derived from the virgl_winsys class. The virgl_gdi_winsys class is an abstraction of the Virtio-GPU Windows window subsystem, which is responsible for interacting with the graphics display interface subsystem. The virgl_gdi_winsys class falls into the kernel layer and completes related functions by calling the D3DKMT interface function set provided by the graphics display interface subsystem.
[0029] Step 120: Obtain the device characteristics of the kernel space Virtio-GPU by using the direct interaction protocol between the client driver and the Virtio-GPU kernel mode driver through the newly added interface.
[0030] Figure 2 Schematic diagram of the Windows virtual machine Virtio-GPUOpenGL framework of the method for using the virtual GPU provided in the first embodiment of the present invention. Figure 2In this embodiment, a direct interaction protocol between a newly added client driver and a Virtio-GPU kernel mode driver can be used, and the protocol message can be transmitted through the D3DKMTEscape interface provided by the graphics display interface subsystem. Exemplarily, the VIRTGPU_ESCAPE_GET_CAPS_INFO protocol can be used to query the feature set supported by the device, and the VIRTGPU_ESCAPE_GET_CAPS protocol can be used to query all features under a certain feature set of the device. The device characteristics of the Virtio-GPU in the kernel space can be obtained through the above protocol. Thereby skipping the graphics display interface subsystem in the user space and jumping directly to the Virtio-GPU kernel mode driver. Correspondingly, the Virtio-GPU driver in the kernel space can access the Virtio-GPU device of the Linux physical machine, and then access the physical physical graphics card. Then the device characteristics of the physical physical graphics card are obtained, and used as the device characteristics of the Virtio-GPU in the kernel space.
[0031] Optionally, the method of obtaining the device characteristics of the kernel space Virtio-GPU by using a direct interaction protocol between a client driver and a Virtio-GPU kernel mode driver through a newly added interface may include: querying the characteristic set supported by the device by using a direct interaction protocol for querying the device characteristic set; and querying all characteristics by using a direct interaction protocol for querying all characteristics under the characteristic set. Thus, the complete device characteristics of the kernel space Virtio-GPU are obtained.
[0032] Step 130: passing the device characteristics as parameters to the client driver so that the client configures the Virtio-GPU device.
[0033] Exemplarily, the device characteristics may be some functional flags and performance parameters of the graphics card device, such as whether 3D is supported, the maximum length and width of 3D textures, the type of color format, etc. After obtaining the above parameters, the above parameters may be passed to the client driver in the user space, and the client driver may reasonably configure the Virtio-GPU device according to the above parameters, so that the client driver can better support OpenGL.
[0034] This embodiment adds a new interface to the D3DKMT interface set when loading the Virtio-GPU OpenGL installable client driver in the user space of the Windows virtual machine. The new interface is used to establish direct communication between the client driver and the Virtio-GPU kernel mode driver; the device characteristics of the kernel space Virtio-GPU are obtained by using the direct interaction protocol between the client driver and the Virtio-GPU kernel mode driver through the new interface; the device characteristics are passed as parameters to the client driver so that the client can configure the Virtio-GPU device. OpenGL support can be added to the Virtio-GPU virtual graphics card in the Windows virtual machine to realize the hardware acceleration function of 3D graphics rendering in the virtual machine. The Windows virtual machine can complete 3D rendering with the help of the physical graphics card on the physical machine side, thereby improving the graphics performance of the virtual machine and improving the user experience.
[0035] In a preferred implementation of this embodiment, the method may further add the following steps: obtaining resource information of the kernel space by using a direct interaction protocol between the client driver and the Virtio-GPU kernel mode driver through an interface. Exemplarily, the VIRTGPU_ESCAPE_GET_RESOURCE_INFO interaction protocol may be used to obtain resource information of the kernel space. In this way, the resources of the kernel space can be obtained, and corresponding resource allocation is performed in the client driver to realize various image drawing and rendering. Further, it may also include: creating an abstract object of the resource in the user space, calling a newly added interface to create a corresponding resource object in the kernel space; querying and saving the resource information of the kernel mode driver through a direct interaction protocol between the client driver and the Virtio-GPU kernel mode driver; returning the handle of the resource information to the abstract object. Using the above method, the corresponding allocation of the corresponding driver resource information in the kernel mode can be realized in the user space. It is convenient to support OpenGL and DirectX for image drawing and rendering in the user space later.
[0036] Embodiment 2
[0037] Figure 31 is a flow chart of a method for using a virtual GPU provided in Embodiment 2 of the present invention. This embodiment is optimized based on the above embodiment, and the method may further add the following steps: the Virtio-GPU kernel mode driver receives a device feature acquisition or resource information acquisition request from a user space client driver through a device callback function set; the Virtio-GPU kernel mode driver converts the device feature acquisition request or resource information acquisition request into a Virtio-GPU protocol message, and sends the converted Virtio-GPU protocol message to the Virtio-GPU device; the Virtio-GPU device calls an OpenGL interface, processes the converted Virtio-GPU using a physical GPU, and receives a processing result of the physical GPU; the Virtio-GPU device converts the processing result into a result Virtio-GPU protocol message, and returns the result Virtio-GPU protocol message to the Virtio-GPU kernel mode driver; the Virtio-GPU kernel mode driver converts the result Virtio-GPU protocol message into a request processing result, and returns the request processing result to the user space client driver using the callback function set.
[0038] See also Figure 3 , the method for using the virtual GPU includes:
[0039] Step 210, when the Virtio-GPU OpenGL installable client driver is loaded in the Windows virtual machine user space, a new interface is added to the D3DKMT interface set, and the new interface is used to establish direct communication between the client driver and the Virtio-GPU kernel mode driver.
[0040] Step 220, using a new interface to directly interact with the Virtio-GPU kernel mode driver to obtain the kernel space Virtio-GPU device characteristics, and pass the device characteristics as parameters to the client driver, so that the client configures the Virtio-GPU device.
[0041] Step 230: The Virtio-GPU kernel mode driver receives a device characteristic acquisition or resource information acquisition request from the user space client driver through a device callback function set.
[0042] In this embodiment, the user space realizes the abstraction of the Virtio-GPU Windows window subsystem and is responsible for interacting with the graphics display interface subsystem. The virgl_gdi_winsys class calls the D3DKMT interface function set provided by the graphics display interface subsystem.
[0043] The kernel mode driver is provided with a set of callback functions related to devices, which may include, for example, VirtGpuAddDevice, VirtGpuStartDevice, VirtGpuStopDevice, and VirtGpuRemoveDevice callback functions, which are respectively used to add, start, stop, and remove Virtio-GPU devices. It is also provided with a set of callback functions related to resources, which may include VirtGpuCreateAllocation and VirtGpuDestroyAllocation callback functions, which are respectively used to create and delete resource objects and associated storage spaces.
[0044] Step 240: The Virtio-GPU kernel mode driver converts the device characteristic acquisition request or the resource information acquisition request into a Virtio-GPU protocol message, and sends the converted Virtio-GPU protocol message to the Virtio-GPU device.
[0045] The callback function set then converts the function call into a specific Virtio-GPU protocol command and sends it to the backend Virtio-GPU device through the Virtio queue.
[0046] Step 250: The Virtio-GPU device calls the OpenGL interface of the driver of the physical GPU, processes the Virtio-GPU protocol message after the request conversion using the physical GPU, and receives the processing result of the physical GPU.
[0047] The backend Virtio-GPU device can call the OpenGL interface of the physical machine GPU driver, send the instructions corresponding to the protocol message to the physical GPU, complete the processing with the help of the physical GPU, and finally return the processing results to the virtual machine.
[0048] Step 260: The Virtio-GPU device converts the processing result into a result Virtio-GPU protocol message, and returns the result Virtio-GPU protocol message to the Virtio-GPU kernel mode driver.
[0049] The virtual machine converts the processing result into a result Virtio-GPU protocol message, and returns the result Virtio-GPU protocol message to the Virtio-GPU kernel mode driver.
[0050] Step 270 , the Virtio-GPU kernel mode driver converts the result Virtio-GPU protocol message into a request processing result, and returns the request processing result to the user space client driver using a callback function set.
[0051] The corresponding callback function set is used to convert the protocol message corresponding to the processing result into the request processing result, and the callback function set is used to return the request processing result to the user space client driver to complete the corresponding request reply.
[0052] This embodiment adds the following steps: the Virtio-GPU kernel mode driver receives the device feature acquisition or resource information acquisition request from the user space client driver through the device callback function set; the Virtio-GPU kernel mode driver converts the device feature acquisition request or resource information acquisition request into a Virtio-GPU protocol message, and sends the converted Virtio-GPU protocol message to the Virtio-GPU device; the Virtio-GPU device processes the converted Virtio-GPU protocol message using the physical GPU, and receives the processing result of the physical GPU; the Virtio-GPU device converts the processing result into a result Virtio-GPU protocol message, and returns the result Virtio-GPU protocol message to the Virtio-GPU kernel mode driver; the Virtio-GPU kernel mode driver converts the result Virtio-GPU protocol message into a request processing result, and returns the request processing result to the user space client driver using the callback function set. It can be realized that the user space request interacts with the Virtio-GPU kernel mode using the Virtio-GPU kernel mode driver and protocol message. The Virtio-GPU kernel mode is used to interact with the physical graphics card, so that the Windows virtual machine can use the Linux system's physical graphics card for drawing and rendering.
[0053] Embodiment 3
[0054] Figure 4 : This is a flow chart of the method for using the virtual GPU provided in Example 3 of the present invention. This embodiment is optimized based on the above embodiment, and the method can also add the following steps: when the OpenGL-related application in the user space of the Windows virtual machine is started, the user space OpenGL Runtime is called; the Virtio-GPU OpenGL installable client driver forwards the call request to the Virtio-GPU corresponding Virtio-GPU OpenGL installable client driver; the Virtio-GPU OpenGL installable client driver calls the D3DKMT class function interface of the Windows graphics display interface subsystem, and interacts with the DirectX graphics kernel subsystem and the Virtio-GPU kernel mode driver in the kernel space of the function interface.
[0055] See also Figure 4 , the method for using the virtual GPU includes:
[0056] Step 310, when the Virtio-GPU OpenGL installable client driver is loaded in the Windows virtual machine user space, a new interface is added to the D3DKMT interface set, and the new interface is used to establish direct communication between the client driver and the Virtio-GPU kernel mode driver.
[0057] Step 320, using the direct interaction protocol between the client driver and the Virtio-GPU kernel mode driver through the newly added interface to obtain the device characteristics and resource information of the kernel space Virtio-GPU, and pass the device characteristics as parameters to the client driver, so that the client can configure the Virtio-GPU device.
[0058] Step 330: When the Windows virtual machine user space OpenGL related application is started, the user space OpenGL Runtime is called.
[0059] In this embodiment, OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface for rendering 2D and 3D vector graphics. The OpenGL-related application can be a 3D drawing program, game, or other application that needs to call OpenGL to implement. The OpenGL Runtime that comes with the virtual machine Windows system is called to run, and for example, it can be the OpenGL32.dll dynamic library file.
[0060] Step 340: the user space OpenGL Runtime forwards the call request to the Virtio-GPU OpenGL installable client driver corresponding to the Virtio-GPU.
[0061] The OpenGL runtime of the virtual machine user space does not do much processing itself, and it forwards the call request to the OpenGL installable client driver corresponding to Virtio-GPU. For example, it can be forwarded to the virtiogpu_opengl.dll dynamic library file.
[0062] Step 350: The Virtio-GPU OpenGL installable client driver calls the D3DKMT class function interface of the Windows graphics display interface subsystem, and interacts with the DirectX graphics kernel subsystem and the Virtio-GPU kernel mode driver in the kernel space of the function interface.
[0063] Virtio-GPU OpenGL OpenGL can install the client driver to call the D3DKMT class function interface of the Windows graphics display interface subsystem, and use these interfaces to interact with the DirectX graphics kernel subsystem and the Virtio-GPU kernel mode driver in the kernel space.
[0064] Exemplarily, it may include: creating a command buffer in user space; the user space creates an event object according to the OpenGL image drawing operation, and encapsulates the event object as a synchronization object; the user space calls the D3DKMTRender interface of the graphics display interface subsystem to pass the command buffer to the kernel space; the kernel space calls the resource interface to reduce the index count of the resource object associated with the command buffer, and returns the synchronization object to the user space.
[0065] Taking rendering as an example, the rendering command stream related methods are implemented for the virgl_gdi_winsys class, which can be cmd_buf_create, cmd_buf_destroy, and submit_cmd methods, which correspond to methods such as creating a command buffer, destroying a command buffer, and submitting a command.
[0066] Optionally, taking the submit_cmd method as an example, the specific implementation steps are: call the Windows system interface CreateEventA to create an event object, and encapsulate the object as a synchronization object; use the D3DKMTRender interface of the graphics display interface subsystem to pass the command buffer to the kernel layer, call the resource interface resource_reference to reduce the index count of the resource object associated with the command buffer; return the synchronization object for the caller to track the execution completion of the command. Use the continuous reduction of the index count to determine whether the command has been completed, and destroy the command buffer when it is completed.
[0067] The DRIVER_INITIALIZATION_DATA callback function set required by the DirectX graphics kernel subsystem is implemented in the Virtio-GPU kernel mode driver, and the callback function set includes a callback function set related to the rendering command stream, which involves the VirtGpuRender and VirtGpuSubmitCommand callback functions. VirtGpuRender is responsible for building a DMA buffer according to the command buffer, and VirtGpuSubmitCommand is responsible for submitting the DMA buffer to the rendering queue of Virtio-GPU. Implement the direct interaction protocol callback function VirtGpuEscape. This function is used to receive and process the interactive protocol message passed in by the OpenGL installable client driver through the D3DKMTEscape interface. In the driver entry function DriverEntry, the DxgkInitialize function is called for initialization, and the implemented DRIVER_INITIALIZATION_DATA callback function set is passed to the DirectX graphics kernel subsystem through parameters. At the same time, the DXGKRNL_INTERFACE function set returned by the DirectX graphics kernel subsystem is saved for subsequent calls to the DirectX graphics kernel subsystem to call the DRIVER_INITIALIZATION_DATA callback function set to complete related functions. The callback function set then converts the function call into a specific Virtio-GPU protocol command and sends it to the backend Virtio-GPU device through the Virtio queue. The backend Virtio-GPU device continues to call the OpenGL interface of the physical machine, sends the rendering instructions to the physical GPU, completes the rendering operation with the help of the physical GPU, and finally returns the rendering results to the virtual machine in the original path. Using the above method, rendering interaction can be achieved.
[0068] In addition, it may also include: obtaining the handle of the event object from the synchronization object; setting a timeout threshold, and calling the Windows system interface WaitForSingleObject to wait for the event object to complete; judging whether the timeout threshold is exceeded, and returning the judgment result.
[0069] Exemplarily, the virgl_gdi_winsys class can be used to implement synchronization related methods, including fence_create, fence_wait and fence_reference methods. The above synchronization methods are used to prevent synchronization failures due to excessive time.
[0070] This embodiment adds the following steps: when the OpenGL-related application in the user space of the Windows virtual machine is started, the user space OpenGL Runtime is called; the user space OpenGL Runtime forwards the call request to the Virtio-GPU corresponding Virtio-GPU OpenGL installable client driver; the Virtio-GPU OpenGL installable client driver calls the D3DKMT class function interface of the Windows graphics display interface subsystem, and uses the DirectX graphics kernel subsystem in the kernel space of the function interface to interact with the Virtio-GPU kernel mode driver. Using the above method, it is possible to support OpenGL and DirectX in the user space for image drawing and rendering.
[0071] Embodiment 4
[0072] Figure 5 is a schematic diagram of the structure of the device for using the virtual GPU provided in the third embodiment of the present invention, see Figure 5 , the device for using the virtual GPU comprises:
[0073] A new module 410 is added, which is used to add a new interface to the D3DKMT interface set when the Virtio-GPU OpenGL installable client driver is loaded in the Windows virtual machine user space, and the new interface is used to establish direct communication between the client driver and the Virtio-GPU kernel mode driver;
[0074] An acquisition module 420 is used to acquire the device characteristics of the kernel space Virtio-GPU by using a direct interaction protocol between the client driver and the Virtio-GPU kernel mode driver through a newly added interface;
[0075] The input module 430 is used to input the device characteristics as parameters to the client driver, so that the client configures the Virtio-GPU device.
[0076] The device for using the virtual GPU provided in this embodiment adds a new interface to the D3DKMT interface set when loading the Virtio-GPU OpenGL installable client driver in the Windows virtual machine user space, and the new interface is used to establish direct communication between the client driver and the Virtio-GPU kernel mode driver; the device characteristics of the kernel space Virtio-GPU are obtained by using the direct interaction protocol between the client driver and the Virtio-GPU kernel mode driver through the new interface; the device characteristics are passed as parameters to the client driver, so that the client can configure the Virtio-GPU device. OpenGL support can be added to the Virtio-GPU virtual graphics card in the Windows virtual machine to realize the hardware acceleration function of 3D graphics rendering in the virtual machine. The Windows virtual machine can complete 3D rendering with the help of the physical graphics card on the physical machine side, thereby improving the graphics performance of the virtual machine and improving the user experience.
[0077] Based on the above embodiments, the device further includes:
[0078] The kernel resource acquisition module is used to obtain kernel space resource information by using a direct interaction protocol between a client driver and a Virtio-GPU kernel mode driver through an interface.
[0079] Based on the above embodiments, the acquisition module includes:
[0080] A feature set query unit, used to query the feature set supported by the device using a device feature set query direct interaction protocol;
[0081] The feature query unit is used to query all features using all feature direct interaction protocols under the query feature set.
[0082] Based on the above embodiments, the device further includes:
[0083] A calling module, used for calling the user space OpenGL Runtime when the Windows virtual machine user space OpenGL related application is started;
[0084] A request forwarding module, used to enable the user space OpenGL to forward the call request to the Virtio-GPU corresponding Virtio-GPU OpenGL installable client driver;
[0085] The module is used to enable the Virtio-GPU OpenGL installable client driver to call the D3DKMT class function interface of the Windows graphics display interface subsystem, and the DirectX graphics kernel subsystem in the kernel space of the function interface interacts with the Virtio-GPU kernel mode driver.
[0086] Based on the above embodiments, the device further includes:
[0087] A kernel mode driver acquisition module, used to enable the Virtio-GPU kernel mode driver to receive device feature acquisition or resource information acquisition requests from the user space client driver through a device callback function set;
[0088] A kernel mode driver conversion module, used to enable the Virtio-GPU kernel mode driver to convert a device feature acquisition request or a resource information acquisition request into a Virtio-GPU protocol message, and send the converted Virtio-GPU protocol message to the Virtio-GPU device;
[0089] The kernel mode driver sending module is used to make the Virtio-GPU device call the OpenGL interface of the physical GPU driver, process the converted Virtio-GPU using the physical GPU, and receive the processing result of the physical GPU;
[0090] A result conversion module, used to enable the Virtio-GPU device to convert the processing result into a result Virtio-GPU protocol message, and return the result Virtio-GPU protocol message to the Virtio-GPU kernel mode driver;
[0091] The return module is used to enable the Virtio-GPU kernel mode driver to convert the result Virtio-GPU protocol message into a request processing result, and return the request processing result to the user space client driver using a callback function set.
[0092] Based on the above embodiments, the utilization module includes:
[0093] The object creation unit is used to create abstract objects of resources in the user space and call the interface to create corresponding resource objects in the kernel space;
[0094] A storage unit, used for querying and saving resource information of the kernel mode driver through a direct interaction protocol between the client driver and the Virtio-GPU kernel mode driver;
[0095] The handle returning unit is used to return the handle of the resource information to the abstract object.
[0096] Based on the above embodiments, the utilization module further includes:
[0097] A buffer creation unit, used to create a command buffer in the user space;
[0098] An encapsulation unit, used to enable the user space to create an event object according to the image drawing operation of OpenGL, and encapsulate the event object into a synchronization object;
[0099] A transfer unit, used for enabling the user space to call the D3DKMTRender interface of the graphics display interface subsystem to transfer the command buffer to the kernel space;
[0100] The reduction unit is used to enable the kernel space to call the resource interface to reduce the index count of the resource object associated with the command buffer area and return the synchronization object to the user space.
[0101] Based on the above embodiments, the utilization module further includes:
[0102] A handle acquisition unit, used for acquiring the handle of the event object from the synchronization object;
[0103] The setting unit is used to set the timeout threshold and call the Windows system interface WaitForSingleObject to wait for the event object to complete;
[0104] The judgment unit is used to judge whether the timeout threshold is exceeded and return the judgment result.
[0105] The device for using a virtual GPU provided in the embodiment of the present invention can execute the method for using a virtual GPU provided in any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.
[0106] Embodiment 5
[0107] Embodiment 5 of the present invention further provides a storage medium including computer executable instructions, wherein the computer executable instructions, when executed by a computer processor, are used to execute the method for using the virtual GPU as described in any of the above embodiments.
[0108] The computer storage medium of the embodiment of the present invention may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device.
[0109] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0110] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0111] Computer program code for performing the operation of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or device. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0112] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A method for using a virtual GPU, characterized in that: include: When the Virtio-GPU OpenGL installable client driver is loaded in the Windows virtual machine user space, a new interface is added to the D3DKMT interface set, wherein the new interface is used to establish direct communication between the client driver and the Virtio-GPU kernel mode driver; New interfaces are added to obtain kernel-space Virtio-GPU device characteristics using a direct interaction protocol between the client driver and the Virtio-GPU kernel-mode driver; Passing the device characteristics as parameters to the client driver so that the client can configure the Virtio-GPU device; When the Windows virtual machine user space OpenGL related application is started, calling the user space OpenGLRuntime; The user space OpenGL Runtime forwards the call request to the Virtio-GPU corresponding Virtio-GPU OpenGL installable client driver; The Virtio-GPU OpenGL installable client driver calls the D3DKMT class function interface of the Windows graphics display interface subsystem, and interacts with the DirectX graphics kernel subsystem and the Virtio-GPU kernel mode driver in the kernel space of the function interface.
2. The method according to claim 1, characterized in that The method further comprises: The resource information of kernel space is obtained through the direct interaction protocol between the client driver and the Virtio-GPU kernel mode driver.
3. The method according to claim 1, characterized in that The method of obtaining the device characteristics of the kernel space Virtio-GPU by using a direct interaction protocol between the client driver and the Virtio-GPU kernel mode driver through a newly added interface includes: Use the device feature set query direct interaction protocol to query the feature set supported by the device; Use the query all features direct interaction protocol to query all features in a feature set.
4. The method according to claim 2, characterized in that The method further comprises: The Virtio-GPU kernel mode driver receives device feature acquisition or resource information acquisition requests from the user space client driver through the device callback function set; The Virtio-GPU kernel mode driver converts the device feature acquisition request or resource information acquisition request into a Virtio-GPU protocol message, and sends the converted Virtio-GPU protocol message to the Virtio-GPU device; The Virtio-GPU device calls the OpenGL interface of the physical GPU driver, processes the converted Virtio-GPU protocol message using the physical GPU, and receives the processing result of the physical GPU; The Virtio-GPU device converts the processing result into a result Virtio-GPU protocol message, and returns the result Virtio-GPU protocol message to the Virtio-GPU kernel mode driver; The Virtio-GPU kernel mode driver converts the resulting Virtio-GPU protocol message into a request processing result, and returns the request processing result to the user space client driver using a callback function set.
5. The method according to claim 2, characterized in that: The method of obtaining kernel space resource information by using a direct interaction protocol between a client driver and a Virtio-GPU kernel mode driver through an interface includes: Create an abstract object of resources in user space, and call the interface to create the corresponding resource object in kernel space; Query and save kernel mode driver resource information through direct interaction protocol between client driver and Virtio-GPU kernel mode driver; Returns a handle to the resource information to the abstract object.
6. The method according to claim 5, characterized in that The Virtio-GPU OpenGL installable client driver calls the D3DKMT class function interface of the Windows graphics display interface subsystem, and uses the DirectX graphics kernel subsystem in the kernel space of the function interface to interact with the Virtio-GPU kernel mode driver, including: Create a command buffer in user space; The user space creates an event object according to the image drawing operation of OpenGL, and encapsulates the event object as a synchronization object; The user space calls the D3DKMTRender interface of the graphics display interface subsystem to pass the command buffer to the kernel space; The kernel space calls the resource interface to reduce the index count of the resource object associated with the command buffer and returns the synchronization object to the user space.
7. The method according to claim 6, characterized in that The Virtio-GPU OpenGL installable client driver calls the D3DKMT class function interface of the Windows graphics display interface subsystem, and uses the DirectX graphics kernel subsystem in the kernel space of the function interface to interact with the Virtio-GPU kernel mode driver, and also includes: Get the handle of the event object from the synchronization object; Set the timeout threshold and call the Windows system interface WaitForSingleObject to wait for the event object to complete; Determine whether the timeout threshold is exceeded and return the result.
8. A device for using a virtual GPU, characterized in that: include: A new module is added to add an interface to the D3DKMT interface set when the Virtio-GPU OpenGL installable client driver is loaded in the Windows virtual machine user space. The new interface is used to establish direct communication between the client driver and the Virtio-GPU kernel mode driver. The acquisition module is used to obtain the device characteristics of the kernel space Virtio-GPU by using the direct interaction protocol between the client driver and the Virtio-GPU kernel mode driver through the newly added interface; An input module, used to input the device characteristics as parameters to a client driver, so that the client can configure the Virtio-GPU device; A calling module, used for calling the user space OpenGL Runtime when the Windows virtual machine user space OpenGL related application is started; A request forwarding module, used to enable the user space OpenGL to forward the call request to the Virtio-GPU corresponding Virtio-GPU OpenGL installable client driver; The module is used to enable the Virtio-GPU OpenGL installable client driver to call the D3DKMT class function interface of the Windows graphics display interface subsystem, and the DirectX graphics kernel subsystem in the kernel space of the function interface interacts with the Virtio-GPU kernel mode driver.
9. A storage medium containing computer executable instructions, characterized in that: When the computer executable instructions are executed by a computer processor, they are used to execute the method for using the virtual GPU as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Rendering API forwarding method based on virgl graphic technology stack
CN117992237A