WO2023279993A1 - 图形渲染方法、装置、电子设备与存储介质 - Google Patents

图形渲染方法、装置、电子设备与存储介质 Download PDF

Info

Publication number
WO2023279993A1
WO2023279993A1 PCT/CN2022/101315 CN2022101315W WO2023279993A1 WO 2023279993 A1 WO2023279993 A1 WO 2023279993A1 CN 2022101315 W CN2022101315 W CN 2022101315W WO 2023279993 A1 WO2023279993 A1 WO 2023279993A1
Authority
WO
WIPO (PCT)
Prior art keywords
rendering
graphics
instruction
data
pipeline
Prior art date
Application number
PCT/CN2022/101315
Other languages
English (en)
French (fr)
Inventor
沙斌
Original Assignee
北京字节跳动网络技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京字节跳动网络技术有限公司 filed Critical 北京字节跳动网络技术有限公司
Publication of WO2023279993A1 publication Critical patent/WO2023279993A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present invention relates to the technical field of graphics processing, in particular to a graphics rendering method, device, electronic equipment, storage medium, computer program product and computer program.
  • the hardware platform usually provides drivers for the Android (Android) operating system, such as graphics rendering-related drivers supporting the graphics rendering interface EGL/GLES in the Android operating system.
  • Android Android
  • the Linux operating system may run on these hardware platforms.
  • the graphics rendering interface Open Graphics Library Open Graphics Library, OpenGL
  • the rendering instructions and rendering data sent through the graphics rendering interface OpenGL need to be transmitted to the graphics rendering interface EGL/GLES, and the The rendering instructions in the OpenGL format are converted into rendering instructions that can be understood by the graphics rendering interface EGL/GLES, and image rendering is finally realized.
  • the invention provides a graphics rendering method, device, electronic equipment, storage medium, computer program product and computer program.
  • the present invention provides a graphics rendering method, including:
  • the rendering process of the EGL/GLES obtains the first rendering context state information in a mapping manner, and calls the EGL/GLES graphics driver of the hardware platform according to the first rendering instruction, the first rendering data, and the first rendering context state information Generate image frames to achieve graphic rendering of the target object.
  • the construction of the rendering pipeline includes:
  • the construction of a rendering pipeline that does not depend on a specific operating system library and a specific software version includes:
  • the memory blocks in the rendering instruction queue are shared memory blocks
  • the transmitting the first rendering instruction and the first rendering data from the rendering pipeline to the rendering process of EGL/GLES through the rendering instruction queue running in user space includes:
  • the rendering pipeline writes the first rendering instruction and the first rendering data into a first memory block of the rendering instruction queue
  • the rendering process of the EGL/GLES reads the first rendering instruction and the first rendering data according to the address of the first memory block.
  • the first rendering instruction and the first rendering data are transmitted from the rendering pipeline to the rendering process of EGL/GLES through the rendering instruction queue running in user space ,include:
  • the first rendering instruction and the first rendering data are asynchronously transmitted from the rendering pipeline to the rendering process of EGL/GLES through a rendering instruction queue running in user space through a bucket mechanism.
  • the calling the EGL/GLES graphics driver of the hardware platform to generate the image frame according to the first rendering instruction, the first rendering data and the first rendering context state information includes:
  • the EGL/GLES graphics driver of the hardware platform to convert the first rendering instruction into a second rendering instruction;
  • the second rendering instruction is a rendering instruction in EGL/GLES format;
  • An image frame is generated according to the second rendering instruction, the first rendering data and the first rendering context state information.
  • the method before the construction of the rendering pipeline, the method further includes:
  • the present invention also provides a graphics rendering device, including:
  • a rendering pipeline construction module configured to construct a rendering pipeline, and obtain a first rendering instruction, first rendering data, and first rendering context state information through the rendering pipeline; wherein, the first rendering instruction is a Linux application requesting a rendering target The rendering instruction in OpenGL format generated by the graphics of the object; the first rendering data is the texture data required when rendering the graphics of the target object; the first rendering context state information is required when rendering the graphics of the target object context state information;
  • a transmission module configured to transmit the first rendering instruction and the first rendering data from the rendering pipeline to an EGL/GLES rendering process through a rendering instruction queue running in user space;
  • the graphics rendering module is used for the rendering process of the EGL/GLES to obtain the first rendering context state information in a mapping manner, and call the hardware platform according to the first rendering instruction, the first rendering data and the first rendering context state information
  • the EGL/GLES graphics driver generates image frames to realize the graphics rendering of the target object.
  • the present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and operable on the processor, when the processor executes the program, the graphics rendering method steps.
  • the present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the graphics rendering method are implemented.
  • the present invention also provides a computer program product, including a computer program, the computer program implements the steps of the graphics rendering method when executed by a processor.
  • the present invention also provides a computer program, which implements the steps of the graphics rendering method when the computer program is executed by a processor.
  • the graphics rendering method, device, electronic equipment and storage medium provided by the present invention can realize the commands and data required for image rendering by constructing a rendering pipeline independent of the system platform and transmitting commands and data through a rendering command queue in the form of a fast message queue Efficient transmission, and can reduce the number of process scheduling, which helps to reduce the occupation of CPU resources.
  • Fig. 1 is a flow chart of the graphics rendering method provided by the present invention
  • FIG. 2 is a schematic diagram of the connection among the rendering pipeline, the rendering instruction queue and the rendering process in the image processor involved in the present invention
  • Fig. 3 is a schematic structural diagram of a graphics rendering device provided by the present invention.
  • Fig. 4 is a schematic structural diagram of an electronic device provided by the present invention.
  • Fig. 1 is the flowchart of the graphic rendering method provided by the present invention, as shown in Fig. 1, the graphic rendering method provided by the present invention comprises:
  • Step 101 Build a rendering pipeline, and obtain a first rendering instruction, first rendering data, and first rendering context state information through the rendering pipeline.
  • the graphics rendering method provided by the present invention can realize the support of the graphics rendering interface EGL/GLES in the Android operating system to the graphics rendering interface OpenGL in the Linux operating system. Therefore, the Linux application program running on the hardware platform installed with the driver program of the Android operating system will call the method of the present invention when performing a drawing operation.
  • the Linux application program When the Linux application program requests to render the graphics of the target object, it will issue a rendering instruction in OpenGL format.
  • the rendering instruction is called a first rendering instruction.
  • the rendering process of the target object graphics can be started through the rendering instruction.
  • the target object When rendering the target object, there should be data required for rendering.
  • the target object is a building.
  • data Before rendering the graphics of the building, there should be data such as the shape, color, and size of the building.
  • the data required for rendering the graphics of the target object is referred to as first rendering data.
  • the first rendering data includes vertex data, such as information about vertex attributes such as vertex coordinates, texture coordinates, vertex normals, and vertex colors, and also includes primitive information, which is used to describe the type of primitives composed of vertex data .
  • vertex data such as information about vertex attributes such as vertex coordinates, texture coordinates, vertex normals, and vertex colors
  • primitive information which is used to describe the type of primitives composed of vertex data .
  • Common primitive types include: points (GL_POINTS), lines (GL_LINES), lines (GL_LINE_STRIP), and triangles (GL_TRIANGLES).
  • the first rendering data is the data required by multiple target objects during rendering.
  • OpenGL's rendering context is a data structure in which OpenGL stores rendering information. It stores various state information in the context, including vertex information, texture information, and compiled shader information. Context information that holds state information is context state information.
  • Context information that holds state information is context state information.
  • the context state information required for rendering the graphics of the target object is referred to as first rendering context state information.
  • the first rendering context state information usually includes an off-screen drawing buffer or a resource object without a drawing surface.
  • the aforementioned first rendering instruction, first rendering data, and first rendering context state information are all generated by the graphics rendering interface OpenGL when the Linux application program requests to render the graphics of the target object.
  • these data need to be delivered to the rendering process of EGL/GLES in the graphics processing unit GPU.
  • the first rendering instruction, the first rendering data, and the first rendering context state information are collected and acquired by the rendering pipeline.
  • the rendering pipeline is built according to the OpenGL Pipeline mechanism, which has nothing to do with the system platform, that is, it does not depend on a specific operating system library and a specific software version.
  • the rendering pipeline is recorded as virglPipeline.
  • a graphics processing unit generally includes multiple hardware rendering pipelines, and these hardware rendering pipelines are usually scheduled and maintained by independent GPU threads.
  • these hardware rendering pipelines in the GPU are referred to as physical rendering pipelines.
  • the rendering pipeline built using the OpenGL Pipeline mechanism has a unique correspondence with the physical rendering pipeline in the graphics processor.
  • the rendering pipelines constructed using the OpenGL Pipeline mechanism include A, B, and C.
  • Rendering pipeline A corresponds to physical rendering pipeline a
  • rendering pipeline B corresponds to physical rendering pipeline b
  • rendering pipeline C corresponds to physical rendering pipeline c.
  • OpenGL Pipeline mechanism refers to the graphics information (vertex, texture, material, camera position, etc.) that the image has in OpenGL. ) is processed by the corresponding Shader in a series of stages such as the geometry stage and the rasterization stage, and finally converted into image pixels on the screen.
  • Step 102 Transmit the first rendering instruction and the first rendering data from the rendering pipeline to an EGL/GLES rendering process through a rendering instruction queue running in user space.
  • the virtIO-GPU architecture based on the QEMU virtual machine runs in the kernel state, and the transfer of GPU instructions and data needs to go through multiple memory copies, resulting in more performance loss.
  • the rendering instruction queue virtIO-GPU-Fmq running in the user space is used to realize the data transmission between the rendering pipeline virglPipeline and the rendering process of EGL/GLES in the graphics processor GPU.
  • FIG. 2 is a schematic diagram of the connection among the rendering pipeline, the rendering instruction queue and the rendering process in the image processor involved in the present invention.
  • the rendering instruction queue virtIO-GPU-Fmq running in user space is a bridge between the rendering pipeline virglPipeline in the OpenGL driver and the rendering process of EGL/GLES in the graphics processor GPU.
  • the rendering pipeline virglPipeline is used as the sending end of the data, and (via virglCmdWritter) sends the first rendering instruction and the first rendering data to the rendering instruction queue virtIO-GPU-Fmq; GLES physical rendering pipeline (part of the rendering process of EGL/GLES) As the receiving end of data, it obtains data from the rendering instruction queue virtIO-GPU-Fmq.
  • the rendering instruction queue virtIO-GPU-Fmq adopts Fast Message Queue (Fast Message Queue, FMQ), aiming at the need to transfer rendering instructions and rendering data in two processes in real time, FMQ is more efficient than traditional communication mechanisms Fast, with lower performance overhead.
  • Step 103 the rendering process of the EGL/GLES obtains the first rendering context state information in a mapping manner, and calls the EGL/GLES of the hardware platform according to the first rendering instruction, the first rendering data, and the first rendering context state information.
  • the GLES graphics driver generates image frames to realize the graphics rendering of the target object.
  • the first rendering instruction and the first rendering data have been transmitted from the rendering pipeline to the rendering process of EGL/GLES through the rendering instruction queue.
  • the rendering process of EGL/GLES can obtain the first rendering context state information through the mapping mechanism, and then call the EGL/GLES of the hardware platform according to the first rendering instruction, the first rendering data and the first rendering context state information.
  • the GLES graphics driver generates image frames to realize the graphics rendering of the target object.
  • the rendering process of EGL/GLES refers to the rendering process implemented on the graphics processing unit GPU according to the EGL/GLES protocol standard. In this embodiment, it can be called virtIO-GPU Device Process.
  • the process includes a physical rendering pipeline and a renderer (virglrender).
  • the renderer has a format conversion function and can call the EGL/GLES graphics driver of the hardware platform to generate image frames.
  • the EGL/GLES graphics driver first needs to convert the first rendering instruction into a second rendering instruction; the second rendering instruction is a rendering instruction in EGL/GLES format; Then, an image frame is generated according to the second rendering instruction, the first rendering data, and the first rendering context state information, finally realizing the graphics rendering of the target object.
  • the graphics rendering method provided by the present invention can realize efficient transmission of instructions and data required for image rendering, and can reduce process scheduling by constructing a rendering pipeline independent of the system platform and transmitting instructions and data through a rendering instruction queue in the form of a fast message queue The number of times helps to reduce the CPU resource usage.
  • building a rendering pipeline includes:
  • multiple virtual pipelines virtualPipeline are created for one rendering pipeline virglPipeline, and different virtual pipelines can be used to bind context state information such as graphics buffers in different scenarios.
  • multiple types of texture data are required in the rendering process.
  • multiple virtual pipelines can be set, and one virtual pipeline manages one type of texture data.
  • GPU resources such as video memory and GPU threads
  • switching through lightweight virtual pipelines has the advantages of fast and efficient.
  • the graphics rendering method provided by the present invention can reduce performance overhead caused by physical rendering pipeline switching by creating a virtual pipeline for binding context state information in different scenarios for the rendering pipeline, and has the advantages of fast and efficient.
  • the construction of a rendering pipeline that does not depend on a specific operating system library and a specific software version includes:
  • virglPipeline maps independently to a physical rendering pipeline.
  • the graphic to be rendered is a building.
  • it can be divided into walls, doors, windows, and roofs according to the architectural structure of the building; then the walls, doors, windows, and roofs of the building are assigned to different rendering pipelines virglPipeline . Since there is a one-to-one mapping relationship between the rendering pipeline virglPipeline and the physical rendering pipeline, the rendering instructions and rendering data corresponding to each part of the building can be transmitted from different rendering pipelines virglPipeline to the corresponding physical rendering pipeline, and then the physical rendering Each pipeline completes the rendering of the corresponding part.
  • Scheduling maintenance between multiple rendering pipelines virglPipeline can be implemented by multiple threads in the CPU. For example, when there are multiple rendering pipelines virglPipeline, the switching binding of different rendering pipelines virglPipeline is usually done in the GLMakeCurrent() interface.
  • the graphics rendering method provided by the present invention utilizes multiple physical rendering pipelines of a graphics processor to construct multiple rendering pipelines corresponding to the physical rendering pipelines, so that the resources of the physical rendering pipelines can be fully utilized and rendering efficiency is improved.
  • the memory block in the rendering instruction queue is a shared memory block
  • the transmitting the first rendering instruction and the first rendering data from the rendering pipeline to the rendering process of EGL/GLES through the rendering instruction queue running in user space includes:
  • the rendering pipeline writes the first rendering instruction and the first rendering data into a first memory block of the rendering instruction queue
  • the rendering process of the EGL/GLES reads the first rendering instruction and the first rendering data according to the address of the first memory block.
  • the first rendering instruction and the first rendering data can be transmitted in a read-write zero-copy manner through the rendering instruction queue.
  • a memory abstraction service MemoryBlock is established for the rendering instruction queue, which allows memory blocks of different service processes to share a single memory heap.
  • a ring buffer is used to save the first rendering command and the first rendering data, and the memory block in the ring buffer is read and written through the aforementioned memory abstraction service MemoryBlock. Since the memory abstraction service MemoryBlock allows memory blocks of different service processes to share a single memory heap, the sender can directly access the memory block and address pointer when writing the first rendering instruction and first rendering data. The address of the shared memory block storing the rendering instruction and data is transmitted from the sending end to the receiving end. When the receiving end needs to read out the first rendering instruction and the first rendering data, it can directly read the first rendering instruction and the first rendering data from the shared memory block according to the address of the memory block, avoiding the memory copy operation.
  • the first rendering command and the first rendering data can be transmitted by reading and writing zero-copy mode, and no need to make multiple memory copies , which can save the overhead of a single memory allocation with maximum efficiency.
  • the first rendering instruction and the first rendering data are transmitted from the rendering pipeline to the EGL/GLES through the rendering instruction queue running in the user space.
  • Rendering process including:
  • the first rendering instruction and the first rendering data are asynchronously transmitted from the rendering pipeline to the rendering process of EGL/GLES through a rendering instruction queue running in user space through a bucket mechanism.
  • the scale of the first rendering data is large, for example, the vertex array includes a large amount of vertex information, and the texture object includes a large amount of pixel data.
  • the rendering instruction queue designs a bucket mechanism (bucket) on the basis of the memory block to complete the asynchronous data transmission, so as to achieve the role of data transmission current limit , to prevent excessive memory block consumption caused by the large amount of transmitted data, and a large amount of performance loss caused by receiving and parsing data.
  • the design of the bucket mechanism can be implemented using the classic token bucket mechanism method. That is, send tokens to a bucket data structure at a constant current-limiting rate. When drawing instructions need to send vertex or texture data, you need to obtain tokens from the bucket structure first. If you succeed, you can send the data to the peer through FMQ. If the acquisition fails, the data will be cached, and when the number of tokens in the bucket is sufficient, the cached data will be sent to the peer to achieve the effect of current-limited asynchronous transmission.
  • the graphics rendering method provided by the present invention completes the asynchronous data transfer through the bucket mechanism, which can achieve the function of data transmission current limit, prevent excessive memory block consumption caused by excessive data transmission, and a large amount of performance loss caused by receiving and parsing data.
  • the method before the construction of the rendering pipeline, the method further includes:
  • libEGL and libGLX are mainly responsible for the management and initialization of window buffer textures and other operations
  • libGL is mainly responsible for specific rendering operations such as sending rendering instructions to the underlying canvas and rendering pipeline.
  • the graphics rendering method provided by the present invention provides a necessary basis for subsequent rendering operations by loading a rendering library based on the OpenGL rendering standard.
  • the graphics rendering device provided by the present invention is described below, and the graphics rendering device described below and the graphics rendering method described above can be referred to in correspondence.
  • Fig. 3 is a structural diagram of a graphics rendering device provided by the present invention. As shown in Fig. 3, the graphics rendering device provided by the present invention includes:
  • the rendering pipeline construction module 301 is configured to construct a rendering pipeline, and obtain a first rendering instruction, first rendering data, and first rendering context state information through the rendering pipeline; wherein, the first rendering instruction is a Linux application requesting rendering The rendering instruction in OpenGL format generated when the graphics of the target object; the first rendering data is the texture data required when rendering the graphics of the target object; the first rendering context state information is required when rendering the graphics of the target object context state information for
  • a transmission module 302 configured to transmit the first rendering instruction and the first rendering data from the rendering pipeline to an EGL/GLES rendering process through a rendering instruction queue running in user space;
  • the graphics rendering module 303 is used for the rendering process of the EGL/GLES to obtain the first rendering context state information in a mapping manner, and call the hardware according to the first rendering instruction, the first rendering data and the first rendering context state information
  • the EGL/GLES graphics driver of the platform generates image frames to realize the graphics rendering of the target object.
  • the graphics rendering device provided by the present invention can realize efficient transmission of instructions and data required for image rendering by constructing a rendering pipeline independent of the system platform, and transmitting instructions and data through a rendering instruction queue in the form of a fast message queue, and can reduce process scheduling The number of times helps to reduce the CPU resource usage.
  • FIG. 4 illustrates a schematic diagram of the physical structure of an electronic device.
  • the electronic device may include: a processor (processor) 410, a communication interface (Communications Interface) 420, a memory (memory) 430 and a communication bus 440, Wherein, the processor 410 , the communication interface 420 , and the memory 430 communicate with each other through the communication bus 440 .
  • the processor 410 can invoke logic instructions in the memory 430 to execute a graphics rendering method, the method comprising:
  • the rendering process of the EGL/GLES obtains the first rendering context state information in a mapping manner, and calls the EGL/GLES graphics driver of the hardware platform according to the first rendering instruction, the first rendering data, and the first rendering context state information Generate image frames to achieve graphic rendering of the target object.
  • the above logic instructions in the memory 430 may be implemented in the form of software functional units and may be stored in a computer-readable storage medium when sold or used as an independent product.
  • the essence of the technical solution of the present invention or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present invention.
  • the aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc., which can store program codes. .
  • the present invention also provides a computer program product
  • the computer program product includes a computer program stored on a non-transitory computer-readable storage medium
  • the computer program includes program instructions, and when the program instructions are executed by a computer
  • the computer can execute the graphics rendering method provided by the above-mentioned embodiments, and the method includes:
  • the rendering process of the EGL/GLES obtains the first rendering context state information in a mapping manner, and calls the EGL/GLES graphics driver of the hardware platform according to the first rendering instruction, the first rendering data, and the first rendering context state information Generate image frames to achieve graphic rendering of the target object.
  • the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the graphics rendering method provided by the above-mentioned embodiments is implemented, and the method includes :
  • the rendering process of the EGL/GLES obtains the first rendering context state information in a mapping manner, and calls the EGL/GLES graphics driver of the hardware platform according to the first rendering instruction, the first rendering data, and the first rendering context state information Generate image frames to achieve graphic rendering of the target object.
  • the present invention also provides a computer program.
  • the computer program is executed by a processor, the graphics rendering method provided by the above-mentioned embodiments is implemented, and the method includes:
  • the rendering process of the EGL/GLES obtains the first rendering context state information in a mapping manner, and calls the EGL/GLES graphics driver of the hardware platform according to the first rendering instruction, the first rendering data, and the first rendering context state information Generate image frames to achieve graphic rendering of the target object.
  • the device embodiments described above are only illustrative, and the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in One place, or it can be distributed to multiple network elements. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. It can be understood and implemented by those skilled in the art without any creative efforts.
  • each implementation can be implemented by means of software plus a necessary general-purpose hardware platform, and of course also by hardware.
  • the essence of the above technical solution or the part that contributes to the prior art can be embodied in the form of software products, and the computer software products can be stored in computer-readable storage media, such as ROM/RAM, magnetic discs, optical discs, etc., including several instructions to make a computer device (which may be a personal computer, server, or network device, etc.) execute the methods described in various embodiments or some parts of the embodiments.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Image Generation (AREA)
  • Image Processing (AREA)

Abstract

本发明提供一种图形渲染方法、装置、电子设备与存储介质,方法包括:构建渲染管线,通过所述渲染管线获取第一渲染指令、第一渲染数据以及第一渲染上下文状态信息;将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程;所述EGL/GLES的渲染进程以映射的方式获取所述第一渲染上下文状态信息,根据所述第一渲染指令、第一渲染数据以及第一渲染上下文状态信息调用硬件平台的EGL/GLES图形驱动生成图像帧,实现目标对象的图形渲染。

Description

图形渲染方法、装置、电子设备与存储介质
本申请要求于2021年07月09日提交中国专利局、申请号为202110777324.6、申请名称为“图形渲染方法、装置、电子设备与存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及图形处理技术领域,尤其涉及一种图形渲染方法、装置、电子设备、存储介质、计算机程序产品及计算机程序。
背景技术
作为流行的移动操作系统,硬件平台通常为安卓(Android)操作系统提供驱动程序,如与图形渲染有关的驱动支持安卓操作系统中的图形渲染接口EGL/GLES。
在实际应用中,在这些硬件平台上可能会运行Linux操作系统。在Linux操作系统上进行图形渲染时会调用图形渲染接口开放图形库(Open Graphics Library,OpenGL)。由于Linux操作系统的图形渲染接口OpenGL与安卓操作系统中的图形渲染接口EGL/GLES并不兼容,因此通过图形渲染接口OpenGL发出的渲染指令与渲染数据需要传递到图形渲染接口EGL/GLES,并将OpenGL格式的渲染指令转换为图形渲染接口EGL/GLES所能理解的渲染指令,最终实现图像渲染。
在相关技术中,在传递渲染指令与渲染数据时,需要进行较为频繁地跨设备、跨容器的传递,导致中央处理器(Central Processing Unit,CPU)跨进程调度切换较为频繁,消耗了大量CPU资源。
发明内容
本发明提供一种图形渲染方法、装置、电子设备、存储介质、计算机程序产品及计算机程序。
本发明提供一种图形渲染方法,包括:
构建渲染管线,通过所述渲染管线获取第一渲染指令、第一渲染数据以及第一渲染上下文状态信息;其中,所述第一渲染指令是Linux应用程序在请求渲染目标对象的图形时 所生成的OpenGL格式的渲染指令;所述第一渲染数据是渲染目标对象的图形时所需要的数据;所述第一渲染上下文状态信息是渲染目标对象的图形时所需要的上下文状态信息;
将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程;
所述EGL/GLES的渲染进程以映射的方式获取所述第一渲染上下文状态信息,根据所述第一渲染指令、第一渲染数据以及第一渲染上下文状态信息调用硬件平台的EGL/GLES图形驱动生成图像帧,实现目标对象的图形渲染。
根据本发明提供的一种图形渲染方法,所述构建渲染管线包括:
构建不依赖于特定操作系统库与特定软件版本的渲染管线;将所述渲染管线唯一地映射到图形处理器中的一个物理渲染管线;
为所述渲染管线创建多个虚拟管线,所述虚拟管线用于绑定不同场景下的上下文状态信息。
根据本发明提供的一种图形渲染方法,所述构建不依赖于特定操作系统库与特定软件版本的渲染管线,包括:
构建不依赖于特定操作系统库与特定软件版本的多个渲染管线。
根据本发明提供的一种图形渲染方法,所述渲染指令队列中的内存块为共享内存块;
相应的,所述将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程,包括:
所述渲染管线将所述第一渲染指令与所述第一渲染数据写入所述渲染指令队列的第一内存块;
将所述第一内存块的地址传递给所述EGL/GLES的渲染进程;
所述EGL/GLES的渲染进程根据所述第一内存块的地址读取所述第一渲染指令与所述第一渲染数据。
根据本发明提供的一种图形渲染方法,所述将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程,包括:
通过桶机制将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线异步传输到EGL/GLES的渲染进程。
根据本发明提供的一种图形渲染方法,所述根据所述第一渲染指令、第一渲染数据以及第一渲染上下文状态信息调用硬件平台的EGL/GLES图形驱动生成图像帧,包括:
调用硬件平台的EGL/GLES图形驱动,将所述第一渲染指令转换为第二渲染指令;所述第二渲染指令为EGL/GLES格式的渲染指令;
根据所述第二渲染指令、第一渲染数据以及第一渲染上下文状态信息生成图像帧。
根据本发明提供的一种图形渲染方法,在所述构建渲染管线之前,方法还包括:
加载基于OpenGL渲染标准的渲染库。
本发明还提供了一种图形渲染装置,包括:
渲染管线构建模块,用于构建渲染管线,通过所述渲染管线获取第一渲染指令、第一渲染数据以及第一渲染上下文状态信息;其中,所述第一渲染指令是Linux应用程序在请求渲染目标对象的图形时所生成的OpenGL格式的渲染指令;所述第一渲染数据是渲染目标对象的图形时所需要的纹理数据;所述第一渲染上下文状态信息是渲染目标对象的图形时所需要的上下文状态信息;
传输模块,用于将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程;
图形渲染模块,用于所述EGL/GLES的渲染进程以映射的方式获取所述第一渲染上下文状态信息,根据所述第一渲染指令、第一渲染数据以及第一渲染上下文状态信息调用硬件平台的EGL/GLES图形驱动生成图像帧,实现目标对象的图形渲染。
本发明还提供了一种电子设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述程序时实现如所述图形渲染方法的步骤。
本发明还提供了一种非暂态计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如所述图形渲染方法的步骤。
本发明还提供了一种计算机程序产品,包括计算机程序,所述计算机程序在被处理器执行时实现如所述图形渲染方法的步骤。
本发明还提供了一种计算机程序,所述计算机程序在被处理器执行时实现如所述图形渲染方法的步骤。
本发明提供的图形渲染方法、装置、电子设备与存储介质,通过构建与系统平台无关的渲染管线,以及通过快速消息队列形式的渲染指令队列传输指令与数据,可实现图像渲染所需指令与数据的高效传输,且能减少进程调度的次数,有助于降低对CPU资源的占用。
附图说明
为了更清楚地说明本发明的技术方案,下面将对实施例描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本发明提供的图形渲染方法的流程图;
图2是本发明所涉及的渲染管线、渲染指令队列以及图像处理器中的渲染进程之间的连接示意图;
图3是本发明提供的图形渲染装置的结构示意图;
图4是本发明提供的电子设备的结构示意图。
具体实施方式
为使本发明的目的、技术方案和优点更加清楚,下面将结合本发明中的附图,对本发明中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
下面结合图1-图4描述本发明的图形渲染方法、装置、电子设备与存储介质。
图1为本发明提供的图形渲染方法的流程图,如图1所示,本发明提供的图形渲染方法包括:
步骤101、构建渲染管线,通过所述渲染管线获取第一渲染指令、第一渲染数据以及第一渲染上下文状态信息。
本发明提供的图形渲染方法能够实现安卓操作系统中的图形渲染接口EGL/GLES对Linux操作系统中的图形渲染接口OpenGL的支持。因此,安装有安卓操作系统的驱动程序的硬件平台上所运行的Linux应用程序在执行绘图操作时,将会调用本发明的方法。
当Linux应用程序请求渲染目标对象的图形时,会发出OpenGL格式的渲染指令,在本实施例中,将该渲染指令称为第一渲染指令。本领域技术人员很容易理解,通过渲染指令可以启动对目标对象图形的渲染过程。
在渲染目标对象时,应当有渲染时所需要的数据。例如,目标对象为一幢大楼,在渲染大楼的图形前,应当有大楼的形状、颜色、大小等数据。
在本实施例中,将渲染目标对象的图形时所需要的数据称为第一渲染数据。第一渲染数据包括顶点数据,如顶点坐标、纹理坐标、顶点法线和顶点颜色等顶点属性的信息,还包括图元信息,所述图元信息用于描述顶点数据所构成的图元的类型。常见的图元类型包括:点(GL_POINTS)、线(GL_LINES)、线条(GL_LINE_STRIP)、三角面(GL_TRIANGLES)。
本领域技术人员容易理解,目标对象可以不止一个,如目标对象是一个建筑群,那么第一渲染数据为多个目标对象在渲染时所需要的数据。
OpenGL的渲染上下文是OpenGL在其中存储渲染信息的一个数据结构,它会将各种状态信息保存在上下文中,包括顶点信息、纹理信息、编译好的着色器信息等。保存有状态信息的上下文信息即为上下文状态信息。在本实施例中,将渲染目标对象的图形时所需要的上下文状态信息称为第一渲染上下文状态信息。第一渲染上下文状态信息通常包括离屏类型的绘图缓冲区或无绘图表面的资源对象。
前述的第一渲染指令、第一渲染数据以及第一渲染上下文状态信息都是Linux应用程序请求渲染目标对象的图形时,由图形渲染接口OpenGL所生成的。在本发明中,需要将这些数据传递给图形处理器GPU中的EGL/GLES的渲染进程。为此,首先由渲染管线采集并获取第一渲染指令、第一渲染数据以及第一渲染上下文状态信息。
所述渲染管线是根据OpenGL Pipeline机制所构建的,其与系统平台无关,即不依赖于特定操作系统库与特定软件版本。在本实施例中,将所述渲染管线记为virglPipeline。
如本领域技术人员所知,图形处理器GPU一般包含有多个硬件渲染管线,这些硬件渲染管线通常由独立的GPU线程负责调度维护。在本实施例中,将这些GPU内的硬件渲染管线称为物理渲染管线。利用OpenGL Pipeline机制所构建的渲染管线与图形处理器中的物理渲染管线具有唯一的对应关系。例如,图形处理器GPU中有物理渲染管线a、b、c;利用OpenGL Pipeline机制所构建的渲染管线有A、B、C。渲染管线A与物理渲染管线a相对应;渲染管线B与物理渲染管线b相对应;渲染管线C与物理渲染管线c相对应。
在本发明中,尽管没有明确定义的,本领域技术人员容易理解,所描述的“OpenGL Pipeline机制”指的是在OpenGL中,将图像所具备的图形信息(顶点、纹理、材质、摄像机位置等)经过几何阶段、光栅化阶段等一系列阶段相应Shader的处理,最终转换成屏幕上的图像像素的过程。
步骤102、将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程。
在申请人所知的一种技术中,基于QEMU虚拟机的virtIO-GPU架构运行于内核态,GPU指令以及数据的传递需要经过多次内存拷贝,有较多的性能损耗。在本发明中,采用运行在用户空间的渲染指令队列virtIO-GPU-Fmq来实现渲染管线virglPipeline与图形处理器GPU中的EGL/GLES的渲染进程之间的数据传输。
图2为本发明所涉及的渲染管线、渲染指令队列以及图像处理器中的渲染进程之间的连接示意图。如图2所示,运行在用户空间的渲染指令队列virtIO-GPU-Fmq是OpenGL驱动中的渲染管线virglPipeline与图形处理器GPU中的EGL/GLES的渲染进程之间的桥梁。渲染管线virglPipeline作为数据的发送端,(通过virglCmdWritter)将第一渲染指令与所述第一渲染数据发送到渲染指令队列virtIO-GPU-Fmq;GLES物理渲染管线(EGL/GLES的渲染进程的一部分)作为数据的接收端,从渲染指令队列virtIO-GPU-Fmq获取数据。在本实施例中,渲染指令队列virtIO-GPU-Fmq采用快速消息队列(Fast Message Queue,FMQ),针对在在两个进程内部实时传递渲染指令以及渲染数据的需要,FMQ比传统的通信机制更快速,性能开销更低。
步骤103、所述EGL/GLES的渲染进程以映射的方式获取所述第一渲染上下文状态信息,根据所述第一渲染指令、第一渲染数据以及第一渲染上下文状态信息调用硬件平台的EGL/GLES图形驱动生成图像帧,实现目标对象的图形渲染。
在之前的步骤中,已经通过渲染指令队列将第一渲染指令与所述第一渲染数据从所述渲染管线传输到EGL/GLES的渲染进程。
在本步骤中,EGL/GLES的渲染进程可通过映射机制获取第一渲染上下文状态信息,然后根据所述第一渲染指令、第一渲染数据以及第一渲染上下文状态信息,调用硬件平台的EGL/GLES图形驱动生成图像帧,实现目标对象的图形渲染。
EGL/GLES的渲染进程是指图形处理器GPU上按照EGL/GLES协议标准实现的渲染进程,在本实施例中,可将其称为virtIO-GPU Device Process。该进程包括物理渲染管线,还包括渲染器(virglrender),渲染器具有格式转换的功能,并可调用硬件平台的EGL/GLES图形驱动生成图像帧。
需要说明的是,由于第一渲染指令是OpenGL格式的渲染指令,因此EGL/GLES图形驱动首先需要将第一渲染指令转换为第二渲染指令;第二渲染指令为EGL/GLES 格式的渲染指令;然后再根据所述第二渲染指令、第一渲染数据以及第一渲染上下文状态信息生成图像帧,最终实现目标对象的图形渲染。
本发明提供的图形渲染方法通过构建与系统平台无关的渲染管线,以及通过快速消息队列形式的渲染指令队列传输指令与数据,可实现图像渲染所需指令与数据的高效传输,且能减少进程调度的次数,有助于降低对CPU资源的占用。
基于上述任一实施例,在本实施例中,构建渲染管线包括:
构建不依赖于特定操作系统库与特定软件版本的渲染管线;将所述渲染管线唯一地映射到图形处理器中的一个物理渲染管线;
为所述渲染管线创建多个虚拟管线,所述虚拟管线用于绑定不同场景下的上下文状态信息。
在本实施例中,为了提高上下文切换时的性能,为一个渲染管线virglPipeline创建多个虚拟管线virtualPipeline,不同的虚拟管线可用于绑定不同场景下的图形缓冲区等上下文状态信息。
例如,在渲染过程中需要多种类型的纹理数据,此时可设置多个虚拟管线,一个虚拟管线管理其中的一种纹理数据。考虑到GPU资源(如显存以及GPU线程)的有限性,以及物理渲染管线切换带来的性能开销,通过轻量级的虚拟管线切换具有快捷高效的优点。
本发明提供的图形渲染方法通过为渲染管线创建用于绑定不同场景下的上下文状态信息的虚拟管线,能够降低物理渲染管线切换带来的性能开销,具有快捷高效的优点。
基于上述任一实施例,在本实施例中,所述构建不依赖于特定操作系统库与特定软件版本的渲染管线,包括:
构建不依赖于特定操作系统库与特定软件版本的多个渲染管线。
如本领域技术人员所知,图形处理器GPU内一般有多个物理渲染管线。为了提高渲染效率,充分利用图形处理器GPU内的多个物理渲染管线,在本实施例中,在构建渲染管线virglPipeline时,同时构建并维护多个virglPipeline。从逻辑上,一个virglPipeline会独立地映射到一个物理渲染pipeline。
例如,所要渲染的图形是一幢大楼,为了提高渲染效率,可按照大楼的建筑结构将其分为墙体、门窗和屋顶;然后将大楼的墙体、门窗、屋顶分配给不同的渲染管线virglPipeline。由于渲染管线virglPipeline与物理渲染管线存在一一对应的映射关系, 因此,大楼中的各个部分所对应的渲染指令与渲染数据可由不同的渲染管线virglPipeline传输到与其对应的物理渲染管线,进而由物理渲染管线各自完成对应部分的渲染。
多个渲染管线virglPipeline之间的调度维护可由CPU中的多个线程实现。如当渲染管线virglPipeline有多个时,不同渲染管线virglPipeline的切换绑定通常在GLMakeCurrent()接口中完成。
本发明提供的图形渲染方法利用图形处理器所具有的多个物理渲染管线,构建与物理渲染管线一一对应的多个渲染管线,使得能够充分利用物理渲染管线的资源,提高渲染效率。
基于上述任一实施例,在本实施例中,所述渲染指令队列中的内存块为共享内存块;
相应的,所述将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程,包括:
所述渲染管线将所述第一渲染指令与所述第一渲染数据写入所述渲染指令队列的第一内存块;
将所述第一内存块的地址传递给所述EGL/GLES的渲染进程;
所述EGL/GLES的渲染进程根据所述第一内存块的地址读取所述第一渲染指令与所述第一渲染数据。
在本实施例中,通过渲染指令队列可实现以读写零拷贝的方式传输第一渲染指令与第一渲染数据。
具体的说,首先为渲染指令队列建立内存抽象服务MemoryBlock,该内存抽象服务允许不同服务进程的内存块共享单个内存堆。
然后在渲染指令队列的发送端采用环形缓冲区保存第一渲染指令与第一渲染数据,该环形缓冲区中的内存块通过前述的内存抽象服务MemoryBlock进行读写操作。由于内存抽象服务MemoryBlock允许不同服务进程的内存块共享单个内存堆,因此发送端在写入第一渲染指令及第一渲染数据时,可通过直接访问内存块及地址指针完成。保存有渲染指令及数据的共享内存块的地址由发送端传输给接收端。当接收端需要读出第一渲染指令及第一渲染数据时,可根据内存块的地址从共享的内存块中直接读取第一渲染指令及第一渲染数据,避免了内存拷贝操作。
从上述描述可以看出,通过渲染指令队列将第一渲染指令与第一渲染数据从渲染管线virglPipeline传输到硬件平台的EGL/GLES的渲染进程的过程中,只需要完成将第一渲染指令与第一渲染数据写入渲染指令队列的操作以及从渲染指令队列读出第一渲染指令与第一渲染数据的操作,不再需要做多次内存拷贝,能够最大效率地节省单次内存分配的开销。
本发明提供的图形渲染方法通过将渲染指令队列中的内存块设置为共享内存块,可实现以读写零拷贝的方式传输第一渲染指令与第一渲染数据,不再需要做多次内存拷贝,能够最大效率地节省单次内存分配的开销。
基于上述任一实施例,在本实施例中,所述将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程,包括:
通过桶机制将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线异步传输到EGL/GLES的渲染进程。
在一些情况下,第一渲染数据的规模较大,如顶点数组包括大量的顶点信息,纹理对象包括大量的像素数据。此时,传输第一渲染数据需要花费大量的时间,因此,在本实施例中,渲染指令队列在内存块基础之上设计桶机制(bucket)完成异步数据传递,以达到传输数据限流的作用,防止传输数据量过大造成的过大内存块消耗,以及接收解析数据造成的大量性能损耗。
具体的说,桶机制的设计可以采用经典的令牌桶机制方法来实现。即以一个恒定的限流速率向一个桶数据结构中发送令牌,当绘图指令需要发送顶点或者纹理数据时,需要先从桶结构中获取令牌,获取成功,可将数据通过FMQ发送给对端,获取失败,则将数据缓存,当桶中的令牌数量足够时,再将缓存的数据发送给对端,达到限流异步传输的作用。
本发明提供的图形渲染方法通过桶机制完成异步数据传递,可达到传输数据限流的作用,防止传输数据量过大造成的过大内存块消耗,以及接收解析数据造成的大量性能损耗。
基于上述任一实施例,在本实施例中,在所述构建渲染管线之前,方法还包括:
加载基于OpenGL渲染标准的渲染库。
当Linux应用程序请求渲染目标对象的图形时,会通过动态链接加载libEGL/libGLX/libGL等基于OpenGL绘图标准的渲染库,调用OpenGL相关接口,完 成画布等渲染操作。其中libEGL和libGLX主要负责窗口缓冲区纹理的管理与初始化创建等操作,libGL主要负责向底层画布以及渲染管线发送渲染指令等具体渲染操作。
本发明提供的图形渲染方法通过加载基于OpenGL渲染标准的渲染库,为后续的渲染操作提供了必要的基础。
下面对本发明提供的图形渲染装置进行描述,下文描述的图形渲染装置与上文描述的图形渲染方法可相互对应参照。
图3为本发明提供的图形渲染装置的结构图,如图3所示,本发明提供的图形渲染装置包括:
渲染管线构建模块301,用于构建渲染管线,通过所述渲染管线获取第一渲染指令、第一渲染数据以及第一渲染上下文状态信息;其中,所述第一渲染指令是Linux应用程序在请求渲染目标对象的图形时所生成的OpenGL格式的渲染指令;所述第一渲染数据是渲染目标对象的图形时所需要的纹理数据;所述第一渲染上下文状态信息是渲染目标对象的图形时所需要的上下文状态信息;
传输模块302,用于将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程;
图形渲染模块303,用于所述EGL/GLES的渲染进程以映射的方式获取所述第一渲染上下文状态信息,根据所述第一渲染指令、第一渲染数据以及第一渲染上下文状态信息调用硬件平台的EGL/GLES图形驱动生成图像帧,实现目标对象的图形渲染。
本发明提供的图形渲染装置通过构建与系统平台无关的渲染管线,以及通过快速消息队列形式的渲染指令队列传输指令与数据,可实现图像渲染所需指令与数据的高效传输,且能减少进程调度的次数,有助于降低对CPU资源的占用。
图4示例了一种电子设备的实体结构示意图,如图4所示,该电子设备可以包括:处理器(processor)410、通信接口(Communications Interface)420、存储器(memory)430和通信总线440,其中,处理器410,通信接口420,存储器430通过通信总线440完成相互间的通信。处理器410可以调用存储器430中的逻辑指令,以执行图形渲染方法,该方法包括:
构建渲染管线,通过所述渲染管线获取第一渲染指令、第一渲染数据以及第一渲染上下文状态信息;其中,所述第一渲染指令是Linux应用程序在请求渲染目标对象的图形时所生成的OpenGL格式的渲染指令;所述第一渲染数据是渲染目标对象的图 形时所需要的数据;所述第一渲染上下文状态信息是渲染目标对象的图形时所需要的上下文状态信息;
将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程;
所述EGL/GLES的渲染进程以映射的方式获取所述第一渲染上下文状态信息,根据所述第一渲染指令、第一渲染数据以及第一渲染上下文状态信息调用硬件平台的EGL/GLES图形驱动生成图像帧,实现目标对象的图形渲染。
此外,上述的存储器430中的逻辑指令可以通过软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
另一方面,本发明还提供一种计算机程序产品,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,计算机能够执行上述各实施例所提供的图形渲染方法,该方法包括:
构建渲染管线,通过所述渲染管线获取第一渲染指令、第一渲染数据以及第一渲染上下文状态信息;其中,所述第一渲染指令是Linux应用程序在请求渲染目标对象的图形时所生成的OpenGL格式的渲染指令;所述第一渲染数据是渲染目标对象的图形时所需要的数据;所述第一渲染上下文状态信息是渲染目标对象的图形时所需要的上下文状态信息;
将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程;
所述EGL/GLES的渲染进程以映射的方式获取所述第一渲染上下文状态信息,根据所述第一渲染指令、第一渲染数据以及第一渲染上下文状态信息调用硬件平台的EGL/GLES图形驱动生成图像帧,实现目标对象的图形渲染。
又一方面,本发明还提供一种非暂态计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现以执行上述各实施例提供的图形渲染方法,该方法包括:
构建渲染管线,通过所述渲染管线获取第一渲染指令、第一渲染数据以及第一渲染上下文状态信息;其中,所述第一渲染指令是Linux应用程序在请求渲染目标对象的图形时所生成的OpenGL格式的渲染指令;所述第一渲染数据是渲染目标对象的图形时所需要的数据;所述第一渲染上下文状态信息是渲染目标对象的图形时所需要的上下文状态信息;
将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程;
所述EGL/GLES的渲染进程以映射的方式获取所述第一渲染上下文状态信息,根据所述第一渲染指令、第一渲染数据以及第一渲染上下文状态信息调用硬件平台的EGL/GLES图形驱动生成图像帧,实现目标对象的图形渲染。
又一方面,本发明还提供一种计算机程序,所述计算机程序在被处理器执行时实现上述各实施例所提供的图形渲染方法,该方法包括:
构建渲染管线,通过所述渲染管线获取第一渲染指令、第一渲染数据以及第一渲染上下文状态信息;其中,所述第一渲染指令是Linux应用程序在请求渲染目标对象的图形时所生成的OpenGL格式的渲染指令;所述第一渲染数据是渲染目标对象的图形时所需要的数据;所述第一渲染上下文状态信息是渲染目标对象的图形时所需要的上下文状态信息;
将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程;
所述EGL/GLES的渲染进程以映射的方式获取所述第一渲染上下文状态信息,根据所述第一渲染指令、第一渲染数据以及第一渲染上下文状态信息调用硬件平台的EGL/GLES图形驱动生成图像帧,实现目标对象的图形渲染。
以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分所述的方法。
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。

Claims (12)

  1. 一种图形渲染方法,其特征在于,包括:
    构建渲染管线,通过所述渲染管线获取第一渲染指令、第一渲染数据以及第一渲染上下文状态信息;其中,所述第一渲染指令是Linux应用程序在请求渲染目标对象的图形时所生成的OpenGL格式的渲染指令;所述第一渲染数据是渲染目标对象的图形时所需要的数据;所述第一渲染上下文状态信息是渲染目标对象的图形时所需要的上下文状态信息;
    将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程;
    所述EGL/GLES的渲染进程以映射的方式获取所述第一渲染上下文状态信息,根据所述第一渲染指令、第一渲染数据以及第一渲染上下文状态信息调用硬件平台的EGL/GLES图形驱动生成图像帧,实现目标对象的图形渲染。
  2. 根据权利要求1所述的图形渲染方法,其特征在于,所述构建渲染管线,包括:
    构建不依赖于特定操作系统库与特定软件版本的渲染管线;将所述渲染管线唯一地映射到图形处理器中的一个物理渲染管线;
    为所述渲染管线创建多个虚拟管线,所述虚拟管线用于绑定不同场景下的上下文状态信息。
  3. 根据权利要求2所述的图形渲染方法,其特征在于,所述构建不依赖于特定操作系统库与特定软件版本的渲染管线,包括:
    构建不依赖于特定操作系统库与特定软件版本的多个渲染管线。
  4. 根据权利要求1-3任一项所述的图形渲染方法,其特征在于,所述渲染指令队列中的内存块为共享内存块;
    相应的,所述将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程,包括:
    所述渲染管线将所述第一渲染指令与所述第一渲染数据写入所述渲染指令队列的第一内存块;
    将所述第一内存块的地址传递给所述EGL/GLES的渲染进程;
    所述EGL/GLES的渲染进程根据所述第一内存块的地址读取所述第一渲染指令与所述第一渲染数据。
  5. 根据权利要求1-3任一项所述的图形渲染方法,其特征在于,所述将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程,包括:
    通过桶机制将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲 染指令队列,从所述渲染管线异步传输到EGL/GLES的渲染进程。
  6. 根据权利要求1-5任一项所述的图形渲染方法,其特征在于,所述根据所述第一渲染指令、第一渲染数据以及第一渲染上下文状态信息调用硬件平台的EGL/GLES图形驱动生成图像帧,包括:
    调用硬件平台的EGL/GLES图形驱动,将所述第一渲染指令转换为第二渲染指令;所述第二渲染指令为EGL/GLES格式的渲染指令;
    根据所述第二渲染指令、第一渲染数据以及第一渲染上下文状态信息生成图像帧。
  7. 根据权利要求1-6任一项所述的图形渲染方法,其特征在于,在所述构建渲染管线之前,方法还包括:
    加载基于OpenGL渲染标准的渲染库。
  8. 一种图形渲染装置,其特征在于,包括:
    渲染管线构建模块,用于构建渲染管线,通过所述渲染管线获取第一渲染指令、第一渲染数据以及第一渲染上下文状态信息;其中,所述第一渲染指令是Linux应用程序在请求渲染目标对象的图形时所生成的OpenGL格式的渲染指令;所述第一渲染数据是渲染目标对象的图形时所需要的纹理数据;所述第一渲染上下文状态信息是渲染目标对象的图形时所需要的上下文状态信息;
    传输模块,用于将所述第一渲染指令与所述第一渲染数据通过运行在用户空间的渲染指令队列,从所述渲染管线传输到EGL/GLES的渲染进程;
    图形渲染模块,用于所述EGL/GLES的渲染进程以映射的方式获取所述第一渲染上下文状态信息,根据所述第一渲染指令、第一渲染数据以及第一渲染上下文状态信息调用硬件平台的EGL/GLES图形驱动生成图像帧,实现目标对象的图形渲染。
  9. 一种电子设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述程序时实现如权利要求1-7任一项所述图形渲染方法的步骤。
  10. 一种非暂态计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1-7任一项所述图形渲染方法的步骤。
  11. 一种计算机程序产品,其特征在于,包括计算机程序,所述计算机程序在被处理器执行时实现如权利要求1-7任一项所述图形渲染方法的步骤。
  12. 一种计算机程序,所述计算机程序在被处理器执行时实现如权利要求1-7任一项所述的媒体文件处理方法。
PCT/CN2022/101315 2021-07-09 2022-06-24 图形渲染方法、装置、电子设备与存储介质 WO2023279993A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110777324.6A CN113515396B (zh) 2021-07-09 2021-07-09 图形渲染方法、装置、电子设备与存储介质
CN202110777324.6 2021-07-09

Publications (1)

Publication Number Publication Date
WO2023279993A1 true WO2023279993A1 (zh) 2023-01-12

Family

ID=78066523

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/101315 WO2023279993A1 (zh) 2021-07-09 2022-06-24 图形渲染方法、装置、电子设备与存储介质

Country Status (2)

Country Link
CN (1) CN113515396B (zh)
WO (1) WO2023279993A1 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115983047A (zh) * 2023-03-14 2023-04-18 北京科技大学 一种适用于多图形接口的跨平台的仿真系统
CN116797707A (zh) * 2023-06-26 2023-09-22 成都中科合迅科技有限公司 基于操作系统适配的界面图形渲染方法和系统
CN116991600A (zh) * 2023-06-15 2023-11-03 上海一谈网络科技有限公司 图形调用指令的处理方法、装置、设备及存储介质
CN118037923A (zh) * 2024-04-09 2024-05-14 北京趋动智能科技有限公司 图像渲染方法、装置、存储介质及电子设备

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113515396B (zh) * 2021-07-09 2024-01-30 北京字节跳动网络技术有限公司 图形渲染方法、装置、电子设备与存储介质
CN113822962B (zh) * 2021-11-19 2022-03-18 北京鲸鲮信息系统技术有限公司 窗口信息处理方法、装置、电子设备及存储介质
CN114257867A (zh) * 2021-12-22 2022-03-29 统信软件技术有限公司 视频图像显示方法和装置,计算设备和可读存储介质
CN115016957B (zh) * 2022-05-26 2024-03-22 湖南三一智能控制设备有限公司 一种跨进程内存共享的方法、装置、终端及车辆

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170116702A1 (en) * 2015-10-21 2017-04-27 Stephen Viggers Systems and methods for using an opengl api with a vulkan graphics driver
CN109213607A (zh) * 2017-06-30 2019-01-15 武汉斗鱼网络科技有限公司 一种多线程渲染的方法和装置
US10649790B1 (en) * 2017-08-24 2020-05-12 Amazon Technologies, Inc. Multithreaded rendering for virtualized graphics processing
CN111274044A (zh) * 2020-01-13 2020-06-12 奇安信科技集团股份有限公司 Gpu虚拟化资源限制处理方法及装置
CN111488196A (zh) * 2020-04-13 2020-08-04 西安万像电子科技有限公司 渲染方法及装置、存储介质、处理器
CN112023402A (zh) * 2020-09-02 2020-12-04 腾讯科技(深圳)有限公司 游戏数据处理方法、装置、设备以及介质
CN112269603A (zh) * 2020-10-16 2021-01-26 北京技德系统技术有限公司 一种在Linux上兼容运行Android应用的图形显示方法与装置
CN113515396A (zh) * 2021-07-09 2021-10-19 北京鲸鲮信息系统技术有限公司 图形渲染方法、装置、电子设备与存储介质

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103713891B (zh) * 2012-10-09 2017-11-24 阿里巴巴集团控股有限公司 一种在移动设备上进行图形渲染的方法和装置
CN106997610B (zh) * 2016-01-26 2020-08-25 阿里巴巴集团控股有限公司 一种图像渲染方法、装置及电子设备
CN110825467B (zh) * 2018-08-09 2023-10-24 北京微播视界科技有限公司 渲染方法、装置、硬件装置和计算机可读存储介质
CN112348732B (zh) * 2019-08-08 2023-11-17 华为技术有限公司 基于图形渲染管线的模型推理方法、装置及存储介质

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170116702A1 (en) * 2015-10-21 2017-04-27 Stephen Viggers Systems and methods for using an opengl api with a vulkan graphics driver
CN109213607A (zh) * 2017-06-30 2019-01-15 武汉斗鱼网络科技有限公司 一种多线程渲染的方法和装置
US10649790B1 (en) * 2017-08-24 2020-05-12 Amazon Technologies, Inc. Multithreaded rendering for virtualized graphics processing
CN111274044A (zh) * 2020-01-13 2020-06-12 奇安信科技集团股份有限公司 Gpu虚拟化资源限制处理方法及装置
CN111488196A (zh) * 2020-04-13 2020-08-04 西安万像电子科技有限公司 渲染方法及装置、存储介质、处理器
CN112023402A (zh) * 2020-09-02 2020-12-04 腾讯科技(深圳)有限公司 游戏数据处理方法、装置、设备以及介质
CN112269603A (zh) * 2020-10-16 2021-01-26 北京技德系统技术有限公司 一种在Linux上兼容运行Android应用的图形显示方法与装置
CN113515396A (zh) * 2021-07-09 2021-10-19 北京鲸鲮信息系统技术有限公司 图形渲染方法、装置、电子设备与存储介质

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115983047A (zh) * 2023-03-14 2023-04-18 北京科技大学 一种适用于多图形接口的跨平台的仿真系统
CN116991600A (zh) * 2023-06-15 2023-11-03 上海一谈网络科技有限公司 图形调用指令的处理方法、装置、设备及存储介质
CN116991600B (zh) * 2023-06-15 2024-05-10 上海一谈网络科技有限公司 图形调用指令的处理方法、装置、设备及存储介质
CN116797707A (zh) * 2023-06-26 2023-09-22 成都中科合迅科技有限公司 基于操作系统适配的界面图形渲染方法和系统
CN116797707B (zh) * 2023-06-26 2024-01-30 成都中科合迅科技有限公司 基于操作系统适配的界面图形渲染方法和系统
CN118037923A (zh) * 2024-04-09 2024-05-14 北京趋动智能科技有限公司 图像渲染方法、装置、存储介质及电子设备

Also Published As

Publication number Publication date
CN113515396B (zh) 2024-01-30
CN113515396A (zh) 2021-10-19

Similar Documents

Publication Publication Date Title
WO2023279993A1 (zh) 图形渲染方法、装置、电子设备与存储介质
US8773443B2 (en) Compression for co-processing techniques on heterogeneous graphics processing units
CN1251155C (zh) 用于实现全景图形保真过采样的方法和装置
US9026745B2 (en) Cross process memory management
CN105122210B (zh) Gpu虚拟化的实现方法及相关装置和系统
US10002403B2 (en) Command remoting
US8780122B2 (en) Techniques for transferring graphics data from system memory to a discrete GPU
US20110169844A1 (en) Content Protection Techniques on Heterogeneous Graphics Processing Units
WO2022095808A1 (zh) 基于Vulkan实现图形渲染的方法及相关装置
US10558496B2 (en) Techniques for accessing a graphical processing unit memory by an application
CN108762934B (zh) 远程图形传输系统、方法及云服务器
US20060061578A1 (en) Information processing apparatus for efficient image processing
CN114741044A (zh) 一种基于异构渲染的跨运行环境显示输出共享方法
CN112801855A (zh) 基于图元的渲染任务调度的方法、装置及存储介质
CN115350479B (zh) 渲染处理方法、装置、设备及介质
EP1255227A1 (en) Vertices index processor
WO2023143280A1 (zh) 渲染图像的方法和相关装置
CN114968152B (zh) 减少virtio-gpu额外性能损耗的方法
CN114741081A (zh) 一种基于异构缓存访问的跨运行环境显示输出共享方法
US8203567B2 (en) Graphics processing method and apparatus implementing window system
CN111402349B (zh) 渲染方法、渲染装置和渲染引擎
US11094032B2 (en) Out of order wave slot release for a terminated wave
US20240189720A1 (en) Performing rendering processing by a graphics processing unit and a central processing unit
WO2019079940A1 (zh) 图形处理方法及相关装置和设备
CN118037531A (zh) 一种基于UE5、Windows内存的纹理共享的方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22836747

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE