A graphics rendering method and its related apparatus
By using the CPU to identify and remove vertex data outside the user's viewpoint, the GPU load is optimized, solving the performance degradation problem caused by excessive GPU load and improving graphics rendering performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-30
- Publication Date
- 2026-03-24
AI Technical Summary
When the GPU load is too high, traditional graphics rendering methods cause the GPU performance to degrade, especially in cases of heavy graphics display or simultaneous scientific computing, where computing resources cannot be effectively allocated.
The CPU determines the GPU load, removes vertex data outside the user's field of view, and only transmits vertex data visible within the user's field of view to the GPU for rendering. The model mesh is also optimized through a culling algorithm to reduce the GPU load.
It reduces the rendering load on the GPU, improves the game frame rate, reduces the overhead of vertex culling operations on the CPU side, and improves overall performance.
Smart Images

Figure CN114529658B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, and more particularly, to a graphics rendering method and device and a computer readable storage medium. BACKGROUND
[0002] A graphics processing unit (GPU) is a microprocessor specially used for image operation, and is often used for graphics rendering.
[0003] In the prior art, the GPU performs the entire process of image rendering when performing graphics rendering. However, in the case of a large load of the GPU, for example, in the case of a large amount of operation of graphics rendering (such as heavy graphics display) or in the case of a large amount of other operation that needs to be processed by the GPU (such as the GPU participating in large-scale scientific calculation while performing graphics rendering), the prior method of performing graphics rendering will cause a high load of the GPU, thereby affecting the performance of the GPU when performing image rendering. SUMMARY
[0004] The present application provides a graphics rendering method, device and computer readable storage medium to reduce the load of the GPU when performing graphics rendering.
[0005] In a first aspect, the present application provides a graphics rendering method, which is applied to a terminal device including a graphics processing unit (GPU), and the method includes: obtaining vertex data of N vertices to be rendered; in the present application, a central processing unit (CPU) in the terminal device can obtain a plurality of first draw commands (draw calls), and the plurality of first draw calls are used to call the vertex data of the N vertices to be rendered, and the vertex data of the vertices to be rendered can include, but is not limited to, vertex positions, normals, UV coordinates, indices, etc.; wherein the draw call instruction refers to a graphics program interface instruction, the number of draw call instructions is the same as the number of graphics rendering times of a cross-platform graphics program interface, and the draw call instruction can specifically include, but is not limited to, glDrawArrays, glDrawElements, etc.
[0006] If the GPU load exceeds a preset value, then based on the vertex data of the N vertices to be rendered, M vertices to be rendered are obtained from the N vertices to be rendered, wherein the M vertices to be rendered are vertices visible within the user's field of view; M is a positive integer less than N; the CPU can first determine the current GPU load, wherein the GPU load can be related to at least one of the following: the number of draw calls that the GPU needs to process when rendering one frame of an image, the number of vertices to be rendered that the GPU needs to process when rendering one frame of an image, the number of textures to be rendered that the GPU needs to process when rendering one frame of an image, and the GPU's frequency occupancy. In this embodiment, the vertex data of the vertices to be rendered can be all or part of the vertex data required to draw a single frame of graphics. The vertex data of the vertices to be rendered can include vertex data within the user's field of view as well as vertex data outside the user's field of view. The CPU processes the vertex data of the vertices to be rendered to obtain the vertex data within the user's field of view, which is equivalent to removing the vertex data outside the user's field of view from the vertex data to be processed, thereby obtaining the vertex data within the user's field of view.
[0007] It should be understood that vertex data within the user's field of view can be the vertex position information of an object image visible within the user's field of view. By processing the vertex data within the user's field of view, an object image visible within the user's field of view can ultimately be obtained.
[0008] The vertex data of the M vertices to be rendered is passed to the GPU so that the GPU can perform graphics rendering.
[0009] In this embodiment, the CPU can update the plurality of first draw calls based on the vertex data of the M vertices to be rendered to obtain a plurality of second draw calls. The plurality of second draw calls are used to call the vertex data of the M vertices to be rendered and to pass the plurality of second draw calls to the GPU.
[0010] After vertices are clipped, their vertex data can be updated. Specifically, after clipping, the corresponding vertex and index data can be updated, and this data is used as input for draw call instructions, which are then fed into the GPU's rendering pipeline.
[0011] By using the above method, when the GPU load is high, the number of vertices that are not visible in the user's field of view are reduced, thereby reducing the GPU load.
[0012] In a possible implementation, the N vertices to be rendered are used to constitute a plurality of model meshes to be rendered, each model mesh to be rendered including a plurality of triangular networks, and each triangular network being composed of a plurality of vertices to be rendered from the N vertices to be rendered. The M vertices to be rendered are obtained from the N vertices to be rendered according to vertex data of vertices of the triangular networks in each model mesh to be rendered, including:
[0013] According to vertex data of vertices of the triangular networks in each model mesh to be rendered, the model meshes in which all or part of the vertices are not visible in a user's view range are culled from the plurality of model meshes to be rendered, to obtain a plurality of culled model meshes, and the plurality of culled model meshes include the M vertices to be rendered.
[0014] In an embodiment of the present application, culling can refer to culling of model meshes that are not visible in a scene, and finally only the visible model meshes participate in rendering calculation. The culling can include at least one of back-face culling, view frustum culling, and occlusion culling. A CPU can obtain a plurality of model meshes to be rendered from a vertex buffer. A model mesh can be represented by a triangular mesh (or triangular network). Each triangular network is composed of three vertices. Vertex data of a vertex can include, but is not limited to, position, normal, UV coordinate, and the like. One vertex can be shared by a plurality of adjacent triangles. The more complex a model mesh is, the greater the number of triangular vertices is.
[0015] In a possible implementation, the method further includes:
[0016] obtaining computing resources available to a current central processing unit (CPU);
[0017] determining, based on the computing resources, a number of triangular networks included in each model mesh to be rendered from the plurality of model meshes to be rendered; and wherein the more the computing resources are, the more the number of triangular networks included in each model mesh to be rendered is, and the less the computing resources are, the less the number of triangular networks included in each model mesh to be rendered is.
[0018] In the embodiments of the present application, the CPU can adjust the number of triangle networks included in each model mesh. If the number of triangle networks included in the model mesh is large, the load of the CPU side performing culling is small (the number of times of performing the culling operation is reduced), but the probability of the model mesh being culled is reduced, resulting in the load of the GPU side becoming large (the probability of the model mesh being culled is reduced, so that the number of remaining vertices to be rendered is increased, and then the load of the GPU side is increased). If the number of triangle networks included in the model mesh is small, the load of the CPU side performing culling is large (the number of times of performing the culling operation is increased), and the probability of the model mesh being culled is high, resulting in the load of the GPU side becoming small (the probability of the model mesh being culled is increased, so that the number of remaining vertices to be rendered is reduced, and then the load of the GPU side is reduced).
[0019] Specifically, the CPU can first determine that the number of triangle networks included in each model mesh is 1, and evaluate the loads of the CPU and the GPU. If the load of the CPU side is too heavy, the number of triangle networks included in each model mesh is adjusted upwards, so as to dynamically adjust the loads between the CPU and the GPU.
[0020] In the embodiments, the CPU can dynamically set the number of triangle networks included in the model mesh based on the actual load of the CPU, and then the mobile device with different CPU computing power can be adapted.
[0021] In a possible implementation, the culling of all or part of the model meshes in which all or part of the vertices are not visible in the user's visual angle range according to the vertex data of the vertices of the triangle networks in each model mesh to be rendered comprises:
[0022] The culling of all or part of the model meshes in which all or part of the vertices are not visible in the user's visual angle range according to the vertex data of the vertices of the triangle networks in each model mesh to be rendered comprises at least one of back-face culling, view frustum culling and occlusion culling.
[0023] In the embodiments of the present application, the CPU can perform view frustum culling according to the Bounding Box of each model mesh, and back face culling according to the Safe space cone area information and the current camera Camera position. The view frustum culling refers to removing the model network falling outside the view frustum, so as to avoid unnecessary rendering of the objects. Specifically, if the camera is located within the Bounding Box of the model mesh in the World space, the model mesh is retained; the eight points of the model mesh are converted to the Clip space by using a model-view-projection matrix (MVP) matrix for spatial conversion, wherein the Clip space refers to the coordinate space of the model vertex after the MVP transformation; if any of the mapped points in the Clip space is located within the view frustum space, the model mesh is retained; if none of the points is located within the view frustum space, the eight mapped points are calculated again to form a Bounding Box based on the Clip space, and then the minimum point and the maximum point of the Bounding Box are marked by bits; if the model mesh is on one side of the view frustum plane, the model mesh is removed, otherwise the model mesh is retained.
[0024] In the embodiments of the present application, the back face culling refers to that a closed model mesh can always be divided into front and back parts with respect to the camera view direction, the back part is occluded by the front part, and the back part can be removed and does not need to participate in rendering. Specifically, the CPU can convert the obtained camera position Camera Position in the World space to the Local space, and compare it with the Safe Space Cone in the model mesh; if the camera Camera is located within the Safe Space Cone, the model mesh is retained, otherwise the model mesh is removed.
[0025] In a possible implementation, the load of the GPU is related to at least one of the following:
[0026] the number of draw calls that need to be processed by the GPU when rendering an image frame;
[0027] the number of vertices to be rendered that need to be processed by the GPU when rendering an image frame;
[0028] the number of textures to be rendered that need to be processed by the GPU when rendering an image frame; and
[0029] the frequency point occupation of the GPU.
[0030] In a possible implementation, the obtaining the vertex data of the N vertices to be rendered comprises: obtaining a plurality of first draw calls, the plurality of first draw calls being used to call the vertex data of the N vertices to be rendered; and correspondingly, the delivering the vertex data of the M vertices to be rendered to the GPU comprises:
[0031] updating the plurality of first draw calls according to the vertex data of the M vertices to be rendered to obtain a plurality of second draw calls, the plurality of second draw calls being used to call the vertex data of the M vertices to be rendered;
[0032] delivering the plurality of second draw calls to the GPU.
[0033] In a second aspect, the present application provides a graphics rendering method, the method being applied to a terminal device, the terminal device comprising a CPU and a GPU, and the method comprising:
[0034] the CPU obtaining a plurality of first draw calls, the plurality of first draw calls being used to call vertex data of N vertices to be rendered; if a load amount of the CPU is greater than a preset value, the CPU delivering the plurality of first draw calls to the GPU; the GPU obtaining M vertices to be rendered from the N vertices to be rendered according to the vertex data of the N vertices to be rendered, wherein the M vertices to be rendered are vertices that are visible within a user visual angle range; the M is a positive integer smaller than the N; the GPU updating the plurality of first draw calls according to the vertex data of the M vertices to be rendered to obtain a plurality of second draw calls, the plurality of second draw calls being used to call the vertex data of the M vertices to be rendered; and the GPU performing graphics rendering according to the plurality of second draw calls.
[0035] In the case that the load amount of the CPU is large, the present application triggers the GPU to cull vertices that are not visible within the user visual angle range, thereby reducing the overhead of the vertex culling operation on the CPU side, and also reducing the overhead of the GPU due to the greatly reduced number of vertices participating in rendering after the vertex culling by the GPU, so that the game frame rate is improved.
[0036] In a possible implementation, each first draw call comprises a function name, and the method further comprises:
[0037] The CPU generates P target draw calls according to the function names of the N draw calls and vertex data of vertices to be rendered by the N draw calls, wherein the P target draw calls are used to represent the N draw calls, and each target draw call is used to represent a part of the N draw calls, and the function names of the part of the N draw calls and the vertex data of vertices to be rendered by the part of the N draw calls are the same;
[0038] The CPU passes each target draw call to a first buffer, and triggers the GPU to obtain the P target draw calls from the P first buffers based on a compute shader call, wherein each time the compute shader call triggers the GPU to obtain one target draw call from one first buffer.
[0039] In the embodiments of the present application, the CPU can record the associated data of each first draw call, and group the first draw calls according to the function names (or called Shader program names) used by each draw call, vertex data of vertices to be rendered by each draw call and uniform data (the uniform data refers to input data of the Shader program other than the vertex data, such as camera parameters, model transformation matrix, etc.). The first draw calls with the same vertex data and Shader program are divided into the same group, and the uniform data used by different first draw calls in the same group can be recorded in a first buffer (for example, an instance buffer).
[0040] In the embodiments of the present application, the multiple first draw call invocations are combined into one Compute shader and Indirect draw call, so that the number of draw calls to be processed is reduced, and the overhead required by the CPU side graphics driver is reduced. At the same time, since the number of vertices participating in rendering after vertex culling by the GPU is greatly reduced, the overhead of the GPU is reduced, and the game frame rate is improved.
[0041] In a possible implementation, the method further includes:
[0042] The GPU writes vertex data of the M vertices to be rendered into an indirect draw buffer; accordingly, the GPU performs graphics rendering according to the plurality of second draw calls, including that the CPU triggers the GPU to obtain the vertex data of the M vertices to be rendered from the indirect draw buffer based on an indirect draw call, so that the CPU performs graphics rendering according to the plurality of second draw calls. The indirect draw call refers to that when a draw command is executed, parameters required by the command are not directly passed in when an API is called, but an address of a memory region is specified, and the address contains parameter data required by the draw call. In the embodiment of the application, the compute shader is used to perform the vertex culling operation on the GPU side, so as to reduce the load on the CPU side. In order to avoid the delay caused by reading the culling result from the GPU to the CPU after execution, the indirect draw call is used to enable the GPU side to perform the graphics rendering operation.
[0043] In a possible implementation, the N vertices to be rendered are used to constitute a plurality of model meshes to be rendered, each model mesh to be rendered includes a plurality of triangular networks, and each triangular network is composed of a plurality of vertices to be rendered in the N vertices to be rendered. The M vertices to be rendered are obtained from the N vertices to be rendered according to the vertex data of the vertices of the triangular networks in each model mesh to be rendered, including: removing, according to the vertex data of the vertices of the triangular networks in each model mesh to be rendered, model meshes in which all or part of the vertices in the plurality of model meshes to be rendered are not visible in a user perspective range, to obtain a plurality of removed model meshes, and the plurality of removed model meshes include the M vertices to be rendered.
[0044] In a possible implementation, the removing, according to the vertex data of the vertices of the triangular networks in each model mesh to be rendered, model meshes in which all or part of the vertices in the plurality of model meshes to be rendered are not visible in a user perspective range, includes: removing, according to the vertex data of the vertices of the triangular networks in each model mesh to be rendered, model meshes in which all or part of the vertices in the plurality of model meshes to be rendered are not visible in a user perspective range, by at least one of back face culling, view frustum culling, and occlusion culling.
[0045] In a possible implementation, the load amount of the CPU is related to at least one of the following:
[0046] a time required by the CPU for performing rendering processing of one frame of image.
[0047] a number of API calls needed to be processed by the CPU when rendering a frame of image;
[0048] a frequency point occupancy of the CPU.
[0049] In a third aspect, the present application provides a graphics rendering device, which is applied to a terminal device, the terminal device comprising a graphics processing unit (GPU), and the device comprises:
[0050] an obtaining module, configured to obtain vertex data of N vertices to be rendered;
[0051] a vertex culling module, configured to, if a load of the GPU is greater than a preset value, obtain M vertices to be rendered from the N vertices to be rendered according to the vertex data of the N vertices to be rendered, wherein the M vertices to be rendered are vertices visible within a user visual angle range, the M is a positive integer less than the N, and
[0052] a graphics rendering module, configured to transmit the vertex data of the M vertices to be rendered to the GPU, so that the GPU performs graphics rendering.
[0053] In a possible implementation, the N vertices to be rendered are used to constitute a plurality of model meshes to be rendered, each model mesh to be rendered comprises a plurality of triangular networks, and each triangular network is composed of a plurality of vertices to be rendered in the N vertices to be rendered.
[0054] According to the vertex data of the vertices of the triangular networks in each model mesh to be rendered, the vertex culling module is configured to:
[0055] In a possible implementation, the obtaining module is configured to obtain computing resources available to a current central processing unit (CPU).
[0056] a triangular network number determining module, configured to determine a number of triangular networks included in each model mesh to be rendered in the plurality of model meshes to be rendered based on the computing resources, wherein the more the computing resources, the more the number of triangular networks included in each model mesh to be rendered, and the less the computing resources, the less the number of triangular networks included in each model mesh to be rendered.
[0057] In a possible implementation, the vertex culling module is configured to perform at least one of back-face culling, view frustum culling, and occlusion culling on the vertex data of the vertices of the triangular network in each of the plurality of model meshes to be rendered, to remove model meshes in which all or part of the vertices of the plurality of model meshes to be rendered are not visible within a user perspective range.
[0058] In a possible implementation, the load of the GPU is related to at least one of:
[0059] a number of draw calls that need to be processed by the GPU when rendering an image frame;
[0060] a number of vertices to be rendered that need to be processed by the GPU when rendering an image frame;
[0061] a number of textures to be rendered that need to be processed by the GPU when rendering an image frame; and
[0062] a frequency point occupancy of the GPU.
[0063] In a possible implementation, the obtaining module is configured to obtain a plurality of first draw calls, the plurality of first draw calls being used to call vertex data of N vertices to be rendered; and the graphics rendering module is configured to update the plurality of first draw calls according to the vertex data of the M vertices to be rendered, to obtain a plurality of second draw calls, the plurality of second draw calls being used to call the vertex data of the M vertices to be rendered, and to deliver the plurality of second draw calls to the GPU.
[0064] In a third aspect, the present application provides a graphics rendering device, the device being applied to a terminal device, the terminal device including a CPU and a GPU, and the CPU including:
[0065] an obtaining module, configured to obtain, by the CPU, a plurality of first draw calls, the plurality of first draw calls being used to call vertex data of N vertices to be rendered;
[0066] a command delivering module, configured to, if a load of the CPU is greater than a preset value, deliver, by the CPU, the plurality of first draw calls to the GPU;
[0067] the GPU including:
[0068] a vertex culling module, configured to obtain, according to the vertex data of the N vertices to be rendered, M vertices to be rendered from the N vertices to be rendered, wherein the M vertices to be rendered are vertices that are visible within a user perspective range, and the M is a positive integer smaller than the N.
[0069] updating the plurality of first draw calls according to vertex data of the M vertices to be rendered to obtain a plurality of second draw calls, the plurality of second draw calls being used to call the vertex data of the M vertices to be rendered; and
[0070] a graphics rendering module, configured to perform graphics rendering according to the plurality of second draw calls.
[0071] In a possible implementation, each first draw call includes a function name, and the CPU further includes:
[0072] a command merging module, configured to generate P target draw calls according to the function names of the N draw calls and the vertex data of the vertices to be rendered, wherein the P target draw calls are used to represent the N draw calls, and each target draw call is used to represent a part of draw calls in the N draw calls, the function names of the part of draw calls and the vertex data of the vertices to be rendered being the same;
[0073] each target draw call is transmitted to a first buffer, and a compute shader call is triggered based on the target draw call, so that the GPU obtains the P target draw calls from the P first buffers, wherein each time the compute shader call can trigger the GPU to obtain one target draw call from one first buffer.
[0074] In a possible implementation, the GPU further includes:
[0075] a data writing module, configured to write the vertex data of the M vertices to be rendered into an indirect draw buffer; correspondingly, the graphics rendering module is configured to trigger the GPU to obtain the vertex data of the M vertices to be rendered from the indirect draw buffer based on an indirect draw call, so that the CPU performs graphics rendering according to the plurality of second draw calls.
[0076] In a possible implementation, the N vertices to be rendered are used to constitute a plurality of model meshes to be rendered, each model mesh to be rendered including a plurality of triangular networks, and each triangular network being composed of a plurality of vertices to be rendered from the N vertices to be rendered. The vertex culling module is configured to: according to vertex data of vertices of the triangular networks in each model mesh to be rendered, cull, by at least one of back-face culling, view frustum culling, and occlusion culling, a model mesh in which all or part of vertices of the plurality of model meshes to be rendered are not visible in a user perspective range, to obtain a plurality of model meshes after culling, and the plurality of model meshes after culling include M vertices to be rendered.
[0077] In a possible implementation, the vertex culling module is configured to: according to vertex data of vertices of the triangular networks in each model mesh to be rendered, cull, by at least one of back-face culling, view frustum culling, and occlusion culling, a model mesh in which all or part of vertices of the plurality of model meshes to be rendered are not visible in a user perspective range.
[0078] In a possible implementation, the load amount of the CPU is related to at least one of:
[0079] a time required for the CPU to perform rendering processing of one frame of image;
[0080] a number of API invocations required for the CPU to perform rendering processing of one frame of image;
[0081] a frequency point occupation of the CPU.
[0082] In a fifth aspect, a computer-readable storage medium is provided, and the computer-readable storage medium stores program code. The program code includes instructions for performing part or all of the operations in the method described in the first aspect.
[0083] Optionally, the computer-readable storage medium is located in an electronic device, and the electronic device can be a device capable of performing graphic rendering.
[0084] In a sixth aspect, an embodiment of the present application provides a computer program product, which, when running on a communication device, causes the communication device to perform part or all of the operations in the method described in the first aspect.
[0085] In a seventh aspect, a chip is provided, and the chip includes a processor configured to perform part or all of the operations in the method described in the first aspect. BRIEF DESCRIPTION OF DRAWINGS
[0086] Figure 1 FIG. 1 is a structural schematic diagram of an electronic device according to an embodiment of the present application;
[0087] Figure 2A structural schematic diagram of an electronic device of an embodiment of the present application;
[0088] Figure 3 A structural schematic diagram of an electronic device of an embodiment of the present application;
[0089] Figure 4 A flowchart of a graphics rendering method provided by an embodiment of the present application;
[0090] Figure 5 A flowchart of a graphics rendering method provided by an embodiment of the present application;
[0091] Figure 6 A flowchart of a graphics rendering method provided by an embodiment of the present application;
[0092] Figure 7 A flowchart of a graphics rendering method provided by an embodiment of the present application;
[0093] Figure 8 A flowchart of a graphics rendering method provided by an embodiment of the present application;
[0094] Figure 9 A flowchart of a graphics rendering method provided by an embodiment of the present application;
[0095] Figure 10 A schematic diagram of a graphics rendering apparatus provided by an embodiment of the present application;
[0096] Figure 11 A schematic diagram of a graphics rendering apparatus provided by an embodiment of the present application;
[0097] Figure 12 A schematic diagram of a graphics rendering apparatus provided by an embodiment of the present application;
[0098] Figure 13 A structural schematic diagram of an electronic device of an embodiment of the present application. DETAILED DESCRIPTION
[0099] The technical solutions in the present application will be described below with reference to the drawings.
[0100] The graphics rendering method in the embodiments of the present application can be executed by an electronic device. The electronic device can be a mobile terminal (for example, a smart phone), a computer, a personal digital assistant, a wearable device, a vehicle-mounted device, an Internet of Things device, or other devices capable of image rendering processing. The electronic device can be a device running an Android system, an IOS system, a windows system, and other systems.
[0101] The graphics rendering method of the embodiments of the present application can be executed by an electronic device, and the specific structure of the electronic device can be as shown in Figure 1 the following will be described in combination withFigure 1 The specific structure of the electronic device is described in detail.
[0102] In one embodiment, as shown in FIG. 1, Figure 1 The electronic device 1000 can include a central processing unit (CPU) 1001, a graphics processing unit (GPU) 1002, a display device 1003, and a memory 1004. Optionally, the electronic device 1000 can further include at least one communication bus 1100 (not shown in FIG. 1) for realizing connection and communication between various components. Figure 1
[0103] It should be understood that various components in the electronic device 1000 can also be coupled through other connectors, which can include various interfaces, transmission lines, or buses, etc. Various components in the electronic device 1000 can also be in a radial connection mode centered on the processor 1001. In various embodiments of the present application, coupling refers to connection or communication with each other, including direct connection or indirect connection through other devices.
[0104] The connection mode of the central processing unit 1001 and the graphics processing unit 1002 can also be various, and is not limited to the mode shown in FIG. 1. The central processing unit 1001 and the graphics processing unit 1002 in the electronic device 1000 can be located on the same chip, or can be independent chips. Figure 1
[0105] The functions of the central processing unit 1001, the graphics processing unit 1002, the display device 1003, and the memory 1004 are briefly introduced as follows.
[0106] The central processing unit 1001 is used to run an operating system 1005 and an application 1007. The application 1007 can be a graphics application, such as a game, a video player, etc. The operating system 1005 provides a system graphics library interface, and the application 1007 generates an instruction stream for rendering graphics or image frames and the required related rendering data through the system graphics library interface and a driver provided by the operating system 1005, such as a graphics library user mode driver and / or a graphics library kernel mode driver. The system graphics library includes but is not limited to a system graphics library such as an open graphics library for embedded systems (OpenGL ES), a khronos platform graphics interface, or Vulkan (a cross-platform drawing application programming interface). The instruction stream contains a series of instructions, which are usually call instructions for the system graphics library interface.
[0107] Optionally, the central processor 1001 can include at least one of the following types of processors: an application processor, one or more microprocessors, a digital signal processor (DSP), a microcontroller unit (MCU), an artificial intelligence processor, or the like.
[0108] The central processor 1001 can further include necessary hardware accelerators, such as an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or an integrated circuit for implementing logical operations. The processor 1001 can be coupled to one or more data buses for transmitting data and instructions between various components of the electronic device 10.
[0109] The graphics processor 1002 is configured to receive a stream of graphics instructions sent by the processor 1001, generate a rendering target through a rendering pipeline, and display the rendering target to the display device 1003 through a layer composition display module of the operating system.
[0110] Optionally, the graphics processor 1002 can include a general-purpose graphics processor that executes software, such as a GPU or other types of specialized graphics processing units, and the like.
[0111] The display device 1003 is configured to display various images generated by the electronic device 10, which can be a graphical user interface (GUI) of the operating system or image data processed by the graphics processor 1002, including still images and video data.
[0112] Optionally, the display device 1003 can include any suitable type of display screen, such as a liquid crystal display (LCD) or a plasma display or an organic light-emitting diode (OLED) display, and the like.
[0113] The memory 1004 is a transmission channel between the central processor 1001 and the graphics processor 1002, which can be a double data rate synchronous dynamic random access memory (DDR SDRAM) or other types of cache.
[0114] A rendering pipeline is a series of operations performed sequentially by the graphics processor 1002 in the process of rendering a graphics or image frame, typical operations include vertex processing, primitive processing, rasterization, fragment processing, etc.
[0115] With the rapid growth of communication and chip technology, mobile devices have become the most important terminal platform for games. Currently, large games with high quality and high frame rate have higher requirements for the overall performance of mobile phones, especially the graphics processing performance.
[0116] In recent years, the scene of mobile games has become larger and more detailed, which has led to an increasing computational load on the entire rendering process. When the game performance experience is not good, it is often that the supply of computing power or data bandwidth resources cannot meet the demand of game business load, and the performance bottleneck may exist in the CPU or GPU.
[0117] First, the application scenario of the present application is introduced.
[0118] As shown in Figure 2 , the architecture to which the present application is applied can include an application layer, a graphics API layer, an OS kernel, and an implementation layer of the present application. The implementation layer of the present application is below the graphics API layer (such as OpenGL and Vulkan) and above the OS kernel and driver. The implementation layer of the present application can intercept graphics API calls, cache rendering instruction streams and associated data, and process the intercepted data.
[0119] The product implementation form of the present application can be program code contained in a GT framework (full name: GPU Turbo, a graphics acceleration framework in a mobile phone system) and running on terminal hardware. As shown in Figure 3 , the program code of the present application exists in the GT framework of the terminal system, below the graphics API and above the OS kernel. At runtime, the program code of the present application runs within an application process.
[0120] Specifically, reference can be made to Figure 4 , Figure 4 A flowchart of a graphics rendering method provided by an embodiment of the present application is provided. The graphics rendering method can be applied to a terminal device, and the terminal device includes a graphics processing unit (GPU). As shown in Figure 4 , the graphics rendering method provided by the embodiment of the present application can include the following steps.
[0121] 401. Obtain vertex data of N vertices to be rendered.
[0122] In the embodiments of the present application, the CPU in the terminal device can obtain a plurality of first draw calls, which are used to call vertex data of N vertices to be rendered. The vertex data of vertices to be rendered can include but is not limited to vertex positions, normals, UV coordinates, indices, and the like.
[0123] The CPU can be located inside the terminal device. The vertex data of vertices to be rendered can be vertex data obtained by the CPU from a cache module of the terminal device, and the vertex data of vertices to be rendered is vertex data for graphics rendering processing by the GPU. The vertex data of vertices to be rendered obtained by the CPU can be vertex data obtained by a draw call, wherein the vertex data obtained by the draw call can be vertex data required for rendering a graphics once.
[0124] The draw call instruction refers to a graphics program interface instruction, the number of draw call instructions is the same as the number of graphics rendering times of the cross-platform graphics program interface, and the draw call instruction can specifically include but is not limited to glDrawArrays, glDrawElements, and the like.
[0125] Optionally, the CPU can obtain the vertex data of N vertices to be rendered from a storage module. The storage module of the terminal device caches the vertex data of N vertices to be rendered for graphics rendering processing by the GPU. When the graphics rendering method is executed by the terminal device, the storage module can be a DDR SDRAM located inside the terminal device, and when the graphics rendering method is executed by the computer device, the storage module can be a video memory located inside the computer device.
[0126] For example, reference can be made to Figure 5 In the perception cache stage, the instruction stream block module can obtain the vertex data of N vertices to be rendered from the cache data.
[0127] 402. If the load of the GPU is greater than a preset value, M vertices to be rendered are obtained from the N vertices to be rendered according to the vertex data of the N vertices to be rendered, wherein the M vertices to be rendered are vertices visible within the user's view range, and M is a positive integer less than N.
[0128] In the embodiments of the present application, the CPU can first determine the load of the current GPU, wherein the load of the GPU can be related to at least one of the following: the number of draw calls required to be processed by the GPU when rendering an image, the number of vertices to be rendered required to be processed by the GPU when rendering an image, the number of textures to be rendered required to be processed by the GPU when rendering an image, and the frequency point occupation of the GPU.
[0129] In one implementation, the CPU can evaluate the load of the GPU based on the intercepted draw calls, the CPU can take the number of draw calls required to be processed by the GPU when rendering an image, the number of vertices to be rendered required to be processed by the GPU when rendering an image, and the number of textures to be rendered required to be processed by the GPU when rendering an image as the basis for determining the load of the GPU, and at the same time, query the current frequency point of the GPU, and take the frequency point occupation of the GPU as the basis for determining the load of the GPU.
[0130] For example, when the number of draw calls required to be processed by the GPU when rendering an image exceeds a certain threshold (for example, 500), the number of vertices to be rendered required to be processed by the GPU when rendering an image exceeds a certain threshold (for example, 500k), the number of textures to be rendered required to be processed by the GPU when rendering an image exceeds a certain threshold (for example, 200), and the current frequency point occupation of the GPU exceeds a certain threshold (for example, more than 80% of the highest frequency point), the CPU can determine that the load of the GPU is greater than a preset value.
[0131] It should be understood that the above-mentioned preset value can be configured based on actual conditions, and the embodiments of the present application are not limited.
[0132] In the embodiments of the present application, if it is determined that the load of the GPU is greater than the preset value, the algorithm operation of culling can be performed on the CPU side to reduce the calculation amount of the GPU, thereby reducing the load of the GPU.
[0133] In the embodiments of the present application, the vertex data of the vertex to be rendered can be all or part of the vertex data required to draw one image. In addition to the vertex data within the user's perspective range, the vertex data of the vertex to be rendered can also include vertex data outside the user's perspective range. The CPU processes the vertex data of the vertex to be rendered to obtain the vertex data within the user's perspective range, which is equivalent to removing the vertex data outside the user's perspective range from the vertex data to be processed, thereby obtaining the vertex data within the user's perspective range.
[0134] It should be understood that the vertex data in the user perspective range can be vertex position information of an object image visible in the user perspective range, and through processing of the vertex data in the user perspective range, an object image visible in the user perspective range can be finally obtained.
[0135] In the embodiment of the application, the CPU can obtain M to-be-rendered vertices from the N to-be-rendered vertices according to the vertex data of the N to-be-rendered vertices, wherein the M to-be-rendered vertices are vertices visible in the user perspective range.
[0136] Specifically, the N to-be-rendered vertices are used to constitute a plurality of to-be-rendered model meshes, each to-be-rendered model mesh includes a plurality of triangular networks, and the vertices of each triangular network are composed of a plurality of to-be-rendered vertices in the N to-be-rendered vertices. Correspondingly, the CPU can remove, according to the vertex data of the vertices of the triangular networks in each to-be-rendered model mesh, all or part of the model meshes in the plurality of to-be-rendered model meshes that are not visible in the user perspective range, to obtain a plurality of removed model meshes, and the plurality of removed model meshes include M to-be-rendered vertices.
[0137] In the embodiment of the application, culling can refer to removing model meshes that are not visible in the scene, and finally only visible model meshes participate in rendering calculation. Culling can include at least one of back face culling, frustum culling, and occlusion culling. The CPU can obtain a plurality of to-be-rendered model meshes mesh from a vertex buffer. The model mesh can be represented by a triangular mesh (or triangular network). Each triangular network is composed of three vertices. The vertex data of the vertex can include but is not limited to position, normal, UV coordinate, etc. One vertex can be shared by multiple adjacent triangles. The more complex the model mesh, the greater the number of triangular vertices.
[0138] In the embodiment of the application, the triangular networks can be grouped into a plurality of small to-be-rendered model meshes, and each model mesh can be composed of a certain number of triangular networks. In some cases, the index order of the triangular networks of the game is continuous, and grouping of the triangular networks can be performed on this continuous index to establish a model mesh. The grouping number can be selected as 8, 16, 32, etc.
[0139] In the embodiment of the application, the CPU can remove, according to the vertex data of the vertices of the triangular networks in each to-be-rendered model mesh, all or part of the model meshes in the plurality of to-be-rendered model meshes that are not visible in the user perspective range through at least one of back face culling, frustum culling, and occlusion culling.
[0140] Next described is how the CPU culls all or part of the model meshes whose vertices are not visible in the user's perspective range through at least one of backface culling, view frustum culling, and occlusion culling.
[0141] In the embodiments of the present application, the CPU can cull all or part of the model meshes whose vertices are not visible in the user's perspective range according to the vertex data of the vertices of the triangular network in each model mesh to be rendered, to obtain the plurality of cull model meshes, which include M vertices to be rendered. The CPU can calculate the model bounding box of each model mesh, where the model bounding box refers to the smallest three-dimensional square box including all the vertices in the model mesh. Specifically, the CPU can traverse each triangular mesh in the model mesh, find the minimum and maximum values on the X-axis, Y-axis, and Z-axis respectively, and record the values as Box Min and Box Max, to obtain the model bounding box of each model mesh. The CPU can also calculate the Safe space cone area of each model mesh, which can be used as a data structure for quickly calculating whether a model mesh is subjected to backface culling. When the camera position is located in the space area defined by the safe space cone, the model mesh will be subjected to backface culling. Specifically, for any triangular network, the vertical vector (i.e., the normal vector of the triangular network) of the triangular network can be calculated using two edges of the triangular network. The central axis is obtained by accumulating and inverting the normal vectors of all the triangular networks in a model mesh, and the farthest intersection point is taken as the center point by traversing all the triangular networks in the model network and performing intersection with the central axis.
[0142] In the embodiments of the present application, the CPU can perform view frustum culling according to the Bounding Box of each model mesh, and back face culling according to the Safe space cone area information and the current camera Camera position. The view frustum culling refers to removing the model network falling outside the view frustum, so as to avoid unnecessary rendering of the objects. Specifically, if the camera is located within the Bounding Box of the model mesh in the World space, the model mesh is retained; the eight points of the model mesh are converted to the Clip space (where the Clip space refers to the coordinate space of the model vertex after the MVP transformation) by using the model-view-projection matrix (MVP) matrix for space conversion; if any of the mapped points in the Clip space is located within the view frustum space, the model mesh is retained; if none of the points is located within the view frustum space, the eight mapped points are calculated again to form a Bounding Box based on the Clip space, and then the minimum point and the maximum point of the Bounding Box are marked by bit, and if the model mesh is on one side of the view frustum plane, the model mesh is removed, otherwise the model mesh is retained.
[0143] In the embodiments of the present application, the back face culling refers to that a closed model mesh can always be divided into front and back parts with respect to the camera view direction, the back part is occluded by the front part, and the back part can be removed and does not need to participate in rendering. Specifically, the CPU can convert the obtained camera position Camera Position in the World space to the Local space, and compare it with the Safe Space Cone in the model mesh; if the camera Camera is located within the Safe Space Cone, the model mesh is retained, otherwise the model mesh is removed.
[0144] In the embodiments of the present application, the CPU can also dynamically set the number of triangular networks included in the model mesh according to the actual CPU load, specifically, the CPU can obtain the computing resources available to the central processing unit CPU, and determine the number of triangular networks included in each of the plurality of model meshes to be rendered based on the computing resources; wherein the more the computing resources, the more the number of triangular networks included in each of the model meshes to be rendered, and the less the computing resources, the less the number of triangular networks included in each of the model meshes to be rendered.
[0145] In this embodiment, the CPU can adjust the number of triangle networks included in each model mesh. If the model mesh includes a large number of triangle networks, the CPU load on culling is small (the number of culling operations is reduced), but the probability of the model mesh being culled is reduced, resulting in a larger load on the GPU (the probability of the model mesh being culled is reduced, resulting in a larger number of vertices to be rendered, which in turn increases the load on the GPU). If the model mesh includes a small number of triangle networks, the CPU load on culling is large (the number of culling operations is increased), and the probability of the model mesh being culled is higher, resulting in a smaller load on the GPU (the probability of the model mesh being culled is higher, resulting in a smaller number of vertices to be rendered, which in turn decreases the load on the GPU).
[0146] Specifically, the CPU can first determine that the number of triangle networks included in each model mesh is 1, and evaluate the CPU and GPU load. If the CPU load is too heavy, the number of triangle networks included in each model mesh is increased, thereby dynamically adjusting the load between the CPU and GPU.
[0147] In this embodiment, the CPU can dynamically set the number of triangles in the model mesh based on the actual CPU load, thereby adapting to mobile devices with different CPU computing power.
[0148] For example, you can refer to Figure 5 During the culling process (or vertex culling), the draw call instruction undergoes perspective division, coordinate transformation, and culling algorithms to remove vertex data from vertices invisible to the user. During the game data update phase, preset key data and frame-by-frame update data can be updated based on the culled vertex data.
[0149] 403. Transfer the vertex data of the M vertices to be rendered to the GPU so that the GPU can perform graphics rendering.
[0150] In this embodiment, the CPU can update the plurality of first draw calls based on the vertex data of the M vertices to be rendered to obtain a plurality of second draw calls. The plurality of second draw calls are used to call the vertex data of the M vertices to be rendered and to pass the plurality of second draw calls to the GPU.
[0151] After the clipping of the vertices is completed, the vertex data of the clipped vertices can be updated. Specifically, after the clipping is completed, the corresponding vertex data and index data can be updated and input as data of a draw call instruction into a rendering pipeline of a GPU.
[0152] In the embodiments of the present application, the CPU can send the vertex data of the M vertices to be rendered within the user perspective range into the GPU for rendering processing.
[0153] Optionally, the CPU and the GPU can be located in the same terminal device or can be located in different terminal devices. For example, the CPU and the GPU are located in the same terminal device, and the rendering of the graphics can be realized through the cooperation of the CPU and the GPU. For another example, the CPU is located in a client device (for example, a terminal device), and the GPU is located in a cloud device (for example, a server in the cloud), and the rendering of the graphics can be realized through the cooperation of the CPU in the client device and the cloud device. The CPU in the client device can first acquire the vertex data, process the vertex data, and then send the vertex data within the user perspective range obtained finally into the GPU for rendering processing. Next, the client device can acquire the graphics processed by the cloud device and display the graphics.
[0154] Optionally, the CPU can store the vertex data of the M vertices to be rendered within the user perspective range into a storage module, so that the GPU acquires the vertex data within the user perspective range from the storage module and performs image rendering processing.
[0155] The embodiments of the present application provide a graphics rendering method, which is applied to a terminal device including a graphics processing unit (GPU). The method includes the following steps: acquiring vertex data of N vertices to be rendered; if a load of the GPU is greater than a preset value, acquiring M vertices to be rendered from the N vertices to be rendered according to the vertex data of the N vertices to be rendered, wherein the M vertices to be rendered are vertices that are visible within a user perspective range, the M is a positive integer less than the N, and the vertex data of the M vertices to be rendered is transmitted to the GPU, so that the GPU performs graphics rendering. Through the above method, in the case that the load of the GPU is large, the vertices that are not visible within the user perspective range are removed, the number of vertices that need to be rendered by the GPU is reduced, and the load of the GPU is reduced.
[0156] Referring to Figure 6 The embodiments of the present application also provide a flowchart of a graphics rendering method, as shown in Figure 6As shown, the graphic rendering method can be applied to a terminal device including a CPU and a GPU, and the graphic rendering method provided in the embodiments of the present application includes:
[0157] 601, the CPU obtains a plurality of first draw calls, and the plurality of first draw calls are used to call vertex data of N vertices to be rendered.
[0158] In the embodiments of the present application, the CPU in the terminal device can obtain a plurality of first draw commands (draw calls), and the plurality of first draw calls are used to call vertex data of N vertices to be rendered. The vertex data of the vertices to be rendered can include but is not limited to vertex positions, normals, UV coordinates, indices, and the like.
[0159] The CPU can be located inside the terminal device. The vertex data of the vertices to be rendered can be vertex data obtained by the CPU from a cache module of the terminal device, and the vertex data of the vertices to be rendered is vertex data for graphic rendering processing by the GPU. The vertex data of the vertices to be rendered obtained by the CPU can be vertex data obtained by a draw call, wherein the vertex data obtained by the draw call can refer to vertex data required for rendering a graphic once.
[0160] The draw call instruction refers to a graphic program interface instruction, the number of draw call instructions is the same as the number of graphic rendering times of the cross-platform graphic program interface, and the draw call instruction can specifically include but is not limited to glDrawArrays, glDrawElements, and the like.
[0161] Optionally, the CPU can obtain the vertex data of the N vertices to be rendered from a storage module. The storage module of the terminal device caches the vertex data of the N vertices to be rendered for graphic rendering processing by the GPU. When the graphic rendering method is executed by the terminal device, the storage module can be a DDR SDRAM located inside the terminal device, and when the graphic rendering method is executed by the computer device, the storage module can be a video memory located inside the computer device.
[0162] 602, if the load of the CPU is greater than a preset value, the CPU transmits the plurality of first draw calls to the GPU.
[0163] In the embodiments of the present application, the CPU can first determine the load of the CPU, wherein the load of the CPU can be related to at least one of the following: the time required for the CPU to perform rendering processing of one frame of image, the number of API calls required for the CPU to perform rendering processing of one frame of image, and the frequency point occupation of the CPU.
[0164] In one implementation, the CPU can perform a load evaluation of the CPU based on the intercepted draw calls, and the CPU can use the time required for the CPU to perform rendering processing of a frame of image, the number of API calls required for the CPU to perform rendering processing of a frame of image, and the frequency point occupation of the CPU as a basis for determining the load of the CPU.
[0165] For example, when the time required for the CPU to perform rendering processing of a frame of image exceeds a certain threshold (e.g., 500), the number of API calls required for the CPU to perform rendering processing of a frame of image exceeds a certain threshold (e.g., 500k), and the frequency point occupation of the CPU exceeds a certain threshold (e.g., more than 80% of the highest frequency point), the CPU can determine that the load of the CPU is greater than a preset value.
[0166] In the embodiments of the present application, in order to reduce the overhead of the CPU, a part of the first draw calls can also be combined into one call. Specifically, each first draw call includes a function name, and the CPU can generate P target draw calls according to the function names of the N draw calls and the vertex data of the vertices to be rendered by the calls, wherein the P target draw calls are used to represent the N draw calls, and each target draw call is used to represent a part of the N draw calls, and the function names of the part of the draw calls and the vertex data of the vertices to be rendered by the calls are the same.
[0167] In the embodiments of the present application, the CPU can record the associated data of each first draw call, and group the first draw calls according to the function name (or called Shader program name) used by each draw call, the vertex data of the vertices to be rendered by the call, and the uniform data (the uniform data refers to the input data of the Shader program other than the vertex data, such as camera parameters, model transformation matrix, etc.). The first draw calls with the same vertex data and Shader program are divided into the same group, and the uniform data used by different first draw calls in the same group can be recorded in one first buffer (e.g., instance buffer).
[0168] The CPU can pass each target draw call to a first buffer, and the CPU can use the instance buffer corresponding to each target draw call as input data of a compute shader on the GPU side. The compute shader is a program segment executed on the GPU and can be used for calculations other than graphics rendering. Modern GPU hardware generally provides support. The game can send the compute shader to the GPU for execution through OpenGL ES or Vulkan API. Specifically, the CPU can trigger the GPU to obtain the P target draw calls from the P first buffers based on a compute shader call. Each compute shader call can trigger the GPU to obtain one target draw call from one first buffer.
[0169] In the embodiments of the present application, the GPU can write the vertex data of the M vertices to be rendered into an indirect rendering buffer. Correspondingly, the CPU can trigger the GPU to obtain the vertex data of the M vertices to be rendered from the indirect rendering buffer based on an indirect draw call, so that the CPU performs graphics rendering according to the second draw calls. The indirect draw call refers to that when a draw command is executed, the parameters required by the command are not directly passed in when the API is called, but an address of a memory region is specified, which contains the parameter data required by the draw call. In the embodiments of the present application, the compute shader is used to perform the vertex culling operation on the GPU side, so as to reduce the load on the CPU side. In order to avoid the delay caused by reading the culling result from the GPU to the CPU after execution, the indirect draw call is used to let the GPU side implement the operation of graphics rendering.
[0170] 603、The GPU obtains M vertices to be rendered from the N vertices to be rendered according to the vertex data of the N vertices to be rendered, wherein the M vertices to be rendered are vertices visible in the user's view range, and the M is a positive integer less than the N.
[0171] In the embodiments of the present application, the N vertices to be rendered are used to form a plurality of model meshes to be rendered, each model mesh to be rendered includes a plurality of triangular networks, and each triangular network is composed of a plurality of vertices to be rendered in the N vertices to be rendered. The GPU can perform culling on all or part of the model meshes in the plurality of model meshes to be rendered, which are not visible in the user's visual angle range, according to the vertex data of the vertices of the triangular networks in each model mesh to be rendered, to obtain a plurality of culling model meshes, and the plurality of culling model meshes include M vertices to be rendered.
[0172] In one implementation, the GPU can perform culling on all or part of the model meshes in the plurality of model meshes to be rendered, which are not visible in the user's visual angle range, by at least one of back culling, view frustum culling, and occlusion culling, according to the vertex data of the vertices of the triangular networks in each model mesh to be rendered.
[0173] 604. The GPU updates the plurality of first draw calls according to the vertex data of the M vertices to be rendered, to obtain a plurality of second draw calls, and the plurality of second draw calls are used to call the vertex data of the M vertices to be rendered.
[0174] In the embodiments of the present application, the GPU can write the vertex data of the M vertices to be rendered into an indirect draw buffer, and the CPU can trigger the GPU to obtain the vertex data of the M vertices to be rendered from the indirect draw buffer based on an indirect draw call, so that the CPU performs graphics rendering according to the plurality of second draw calls. The indirect draw buffer is a block of video memory area used to save parameters required by the indirect draw.
[0175] 605. The GPU performs graphics rendering according to the plurality of second draw calls.
[0176] In the embodiments of the present application, the compute shader in the GPU can use the data in the instance buffer to perform view frustum culling and occlusion culling on the model. After performing the vertex culling operation in step 603, the GPU writes the vertex data of the remaining vertices to be rendered into an indirect draw buffer, and calls an indirect draw command, which drives the GPU to obtain the data required for drawing from the indirect draw buffer after completing the vertex culling culling, to perform graphics rendering.
[0177] Referring to Figure 7 In the embodiments of the present application, the plurality of first draw call invocations are merged into one Compute shader and Indirect draw invocation, so that the number of draw calls to be processed is reduced, and the overhead required by the CPU side graphics driver is reduced. At the same time, since the number of vertices participating in rendering after vertex culling by the GPU is greatly reduced, the overhead of the GPU is reduced, and the game frame rate is improved.
[0178] The embodiments of the present application provide a graphics rendering method, which is applied to a terminal device including a CPU and a GPU. The method includes: the CPU acquires a plurality of first draw calls, the plurality of first draw calls being used to invoke vertex data of N vertices to be rendered; if the load of the CPU is greater than a preset value, the CPU transmits the plurality of first draw calls to the GPU; the GPU acquires M vertices to be rendered from the N vertices to be rendered according to the vertex data of the N vertices to be rendered, wherein the M vertices to be rendered are vertices visible within a user perspective range; the M is a positive integer less than the N; the GPU updates the plurality of first draw calls according to the vertex data of the M vertices to be rendered to obtain a plurality of second draw calls, the plurality of second draw calls being used to invoke the vertex data of the M vertices to be rendered; and the GPU performs graphics rendering according to the plurality of second draw calls. In the case that the load of the CPU is large, the embodiments of the present application trigger the GPU to cull vertices invisible within the user perspective range, reduce the overhead of the CPU side required to perform vertex culling operation, and also reduce the overhead of the GPU since the number of vertices participating in rendering after vertex culling by the GPU is greatly reduced, so that the game frame rate is improved.
[0179] It should be understood that the above Figure 4 The corresponding embodiments and Figure 6 The corresponding embodiments can be executed in parallel and cooperate with each other to reduce the overhead of the CPU and the GPU in the terminal device. For example, reference can be made to Figure 8 After the terminal device runs a game, the CPU can intercept a cache graphics instruction stream, collect and evaluate game load data, and then can first determine the CPU load, and execute the Figure 6 After the graphics rendering method in the corresponding embodiments, the GPU load can be determined, and when the GPU load is determined to be greater than a preset value, the Figure 4the graphics rendering method in the corresponding embodiment; or, the GPU load amount determination can be performed first, and the graphics rendering method in the corresponding embodiment can be executed when it is determined that the GPU load amount exceeds the preset value Figure 4 the graphics rendering method in the corresponding embodiment, and then the CPU load amount determination can be performed, and the graphics rendering method in the corresponding embodiment can be executed when it is determined that the CPU load amount exceeds the preset value Figure 6 the graphics rendering method in the corresponding embodiment.
[0180] More specifically, reference can be made to Figure 9 The draw call of the graphics API layer (for example, OpenGL, Vulkan) can be intercepted through the GT framework, the necessary associated data is obtained, and the subsequent module is analyzed and strategy enabled. The load judgment decision module evaluates the GPU load according to the intercepted draw call and data. For a scene in which the rendering instruction exceeds a certain threshold value and the rendering vertex exceeds a certain threshold value, the scene can be determined as one of the necessary conditions of GPU overload. Meanwhile, the frequency points of the system CPU and GPU are inquired, which are important bases for the GPU and CPU load states. If the GPU driver overhead is large and the CPU side load is heavy, the compute shader is called, and the vertex culling Culling algorithm operation is performed on the GPU side to reduce the load of the CPU side. If the GPU load is heavy, the vertex culling Culling algorithm operation is performed on the CPU side to reduce the calculation amount of the GPU shading.
[0181] Reference can be made to Figure 10 The application further provides a graphics rendering device. The device 1000 is applied to a terminal equipment, the terminal equipment includes a graphics processing unit (GPU), and the device 1000 includes:
[0182] An acquisition module 1001 is configured to acquire vertex data of N to-be-rendered vertices.
[0183] A vertex culling module 1002 is configured to acquire, if the load amount of the GPU is greater than a preset value, M to-be-rendered vertices from the N to-be-rendered vertices according to the vertex data of the N to-be-rendered vertices, wherein the M to-be-rendered vertices are vertices that are visible within a user visual angle range, and the M is a positive integer less than the N.
[0184] A graphics rendering module 1003 is configured to transmit the vertex data of the M to-be-rendered vertices to the GPU, so that the GPU performs graphics rendering.
[0185] In a possible implementation, the N to-be-rendered vertices are used to constitute a plurality of to-be-rendered model meshes, each to-be-rendered model mesh includes a plurality of triangular networks, and the vertices of each triangular network are composed of a plurality of to-be-rendered vertices in the N to-be-rendered vertices. The vertex culling module 1002 is configured to:
[0186] According to vertex data of vertices of a triangular network in each model grid to be rendered, cull model grids in which all or part of vertices in the plurality of model grids to be rendered are not visible in a user perspective range, to obtain a plurality of cull model grids, the plurality of cull model grids including M vertices to be rendered.
[0187] In a possible implementation, the obtaining module 1001 is configured to obtain computing resources available to a current central processing unit (CPU).
[0188] The triangular network quantity determination module is configured to determine a number of triangular networks included in each model grid to be rendered in the plurality of model grids to be rendered based on the computing resources; and if the computing resources are more, the number of triangular networks included in each model grid to be rendered is more, and if the computing resources are less, the number of triangular networks included in each model grid to be rendered is less.
[0189] In a possible implementation, the vertex culling module 1002 is configured to cull, according to vertex data of vertices of a triangular network in each model grid to be rendered, model grids in which all or part of vertices in the plurality of model grids to be rendered are not visible in a user perspective range by at least one of back face culling, view frustum culling, and occlusion culling.
[0190] In a possible implementation, the load of the GPU is related to at least one of the following:
[0191] A number of draw commands draw call needed to be processed by the GPU when rendering an image frame;
[0192] A number of vertices to be rendered needed to be processed by the GPU when rendering an image frame;
[0193] A number of textures to be rendered needed to be processed by the GPU when rendering an image frame; and
[0194] A frequency point occupation of the GPU.
[0195] In a possible implementation, the obtaining module 1001 is configured to obtain a plurality of first draw commands draw call, the plurality of first draw call being used to call vertex data of N vertices to be rendered; and correspondingly, the graphics rendering module is configured to update the plurality of first draw call according to the vertex data of the M vertices to be rendered, to obtain a plurality of second draw call, the plurality of second draw call being used to call the vertex data of the M vertices to be rendered; and deliver the plurality of second draw call to the GPU.
[0196] Referring to Figure 11 The application further provides a graphics rendering device 1100, which is applied to a terminal device, and the terminal device comprises a CPU and a GPU, and the CPU comprises:
[0197] an acquisition module 1101 configured to acquire a plurality of first draw calls by the CPU, wherein the plurality of first draw calls are used to call vertex data of N vertices to be rendered;
[0198] a command transmission module 1102 configured to transmit the plurality of first draw calls to the GPU by the CPU if a load of the CPU is greater than a preset value;
[0199] the GPU comprises:
[0200] a vertex culling module 1103 configured to acquire M vertices to be rendered from the N vertices to be rendered according to the vertex data of the N vertices to be rendered, wherein the M vertices to be rendered are vertices that are visible within a user visual angle range, and the M is a positive integer less than the N;
[0201] update the plurality of first draw calls according to the vertex data of the M vertices to be rendered to obtain a plurality of second draw calls, wherein the plurality of second draw calls are used to call the vertex data of the M vertices to be rendered; and
[0202] a graphics rendering module 1104 configured to perform graphics rendering according to the plurality of second draw calls.
[0203] In a possible implementation, each first draw call comprises a function name, and the CPU further comprises:
[0204] a command merging module configured to generate P target draw calls according to the function names of the N draw calls and the vertex data of the vertices to be rendered, wherein the P target draw calls are used to represent the N draw calls, and each target draw call is used to represent a part of draw calls in the N draw calls, and the function names of the part of draw calls and the vertex data of the vertices to be rendered are the same;
[0205] Each target draw call is passed to a first buffer, and a compute shader call is invoked to trigger the GPU to fetch the P target draw calls from the P first buffers, wherein each compute shader call can trigger the GPU to fetch one target draw call from one first buffer.
[0206] In a possible implementation, the GPU further includes:
[0207] The data writing module is configured to write vertex data of the M to-be-rendered vertices to an indirect draw buffer, and the graphics rendering module is configured to trigger the GPU to fetch the vertex data of the M to-be-rendered vertices from the indirect draw buffer based on an indirect draw call, so that the CPU performs graphics rendering according to the plurality of second draw calls.
[0208] In a possible implementation, the N to-be-rendered vertices are used to constitute a plurality of to-be-rendered model meshes, each to-be-rendered model mesh includes a plurality of triangular networks, and each triangular network is composed of a plurality of to-be-rendered vertices in the N to-be-rendered vertices. The vertex culling module is configured to cull, according to vertex data of vertices of triangular networks in each to-be-rendered model mesh, a to-be-rendered model mesh in which all or part of vertices of the plurality of to-be-rendered model meshes are not visible in a user perspective range, to obtain a plurality of culled model meshes, and the plurality of culled model meshes include M to-be-rendered vertices.
[0209] In a possible implementation, the vertex culling module is configured to cull, according to vertex data of vertices of triangular networks in each to-be-rendered model mesh, a to-be-rendered model mesh in which all or part of vertices of the plurality of to-be-rendered model meshes are not visible in a user perspective range, by at least one of back-face culling, view frustum culling, and occlusion culling.
[0210] In a possible implementation, the load amount of the CPU is related to at least one of:
[0211] Time required for the CPU to perform rendering processing of one frame of image;
[0212] Number of API calls required for the CPU to perform rendering processing of one frame of image;
[0213] Frequency point occupation of the CPU.
[0214] Further, the present application provides a graphics rendering device, Figure 12 is a schematic block diagram of the graphics rendering device of the embodiment of the present application. Figure 12 The device 1200 shown includes an input / output interface, a memory and a CPU.
[0215] The memory is configured to store a program, and the CPU is configured to execute the program stored in the memory, and specifically configured to:
[0216] The input / output interface is configured to acquire vertex data of N vertices to be rendered; and the CPU is configured to acquire M vertices to be rendered from the N vertices to be rendered according to the vertex data of the N vertices to be rendered, if a load of the GPU is greater than a preset value, wherein the M vertices to be rendered are vertices visible within a user visual angle range, the M is a positive integer less than the N, and the vertex data of the M vertices to be rendered is transmitted to the GPU, so that the GPU performs graphics rendering. The device 1200 can further include the GPU.
[0217] Figure 13 is a structural schematic diagram of the terminal device of the embodiment of the present application.
[0218] It should be understood that the specific structure of the device 1000 shown above can be as shown in Figure 12 . Figure 13 .
[0219] Figure 13 The terminal device in the embodiment of the present application includes a communication module 3010, a sensor 3020, a user input module 3030, an output module 3040, a processor 3050, a memory 3070 and a power supply 3080. The processor 3050 can include one or more CPUs.
[0220] Figure 13 The terminal device shown can perform each step of the graphics rendering method of the embodiment of the present application, and specifically, one or more CPUs in the processor 3050 can perform each step of the graphics rendering method of the embodiment of the present application.
[0221] The various modules of the terminal device in the embodiment of the present application will be described in detail below. Figure 13
[0222] The communication module 3010 can include at least one module enabling the terminal device to communicate with other terminal devices. For example, the communication module 3010 can include one or more of a wired network interface, a broadcast receiving module, a mobile communication module, a wireless Internet module, a local area communication module and a location (or positioning) information module.
[0223] For example, the communication module 3010 can acquire a game screen in real time from a game server end.
[0224] The sensor 3020 can sense some operations of a user. The sensor 3020 can include a distance sensor, a touch sensor, and the like. The sensor 3020 can sense an operation of a user touching a screen or approaching the screen. For example, the sensor 3020 can sense some operations of a user on a game interface.
[0225] The user input module 3030 receives inputted digital information, character information, or contact touch operation / non-contact gesture, and receives a signal input related to a user setting of the system and a function control, and the like. The user input module 3030 includes a touch panel and / or other input device. For example, a user can control a game through the user input module 3030.
[0226] The output module 3040 includes a display panel for displaying information inputted by a user, information provided to a user, or various menu interfaces of the system, and the like.
[0227] Optionally, the display panel can be configured in the form of a liquid crystal display (LCD) or an organic light-emitting diode (OLED), and the like. In some other embodiments, a touch panel can be overlaid on the display panel to form a touch display screen.
[0228] In addition, the output module 3040 can further include a video output module, an alarm, a haptic module, and the like. The video output module can display a game screen after graphic rendering.
[0229] The power supply 3080 can receive external power and internal power under the control of the processor 3050, and provide power required for the operation of each module of the entire terminal device.
[0230] The processor 3050 includes one or more CPUs. The processor 3050 can further include one or more GPUs.
[0231] When the processor 3050 includes a plurality of CPUs, the plurality of CPUs can be integrated on the same chip or can be respectively integrated on different chips.
[0232] When the processor 3050 includes a plurality of GPUs, the plurality of GPUs can be integrated on the same chip or can be respectively integrated on different chips.
[0233] When the processor 3050 includes both a CPU and a GPU, the CPU and the GPU can be integrated on the same chip.
[0234] For example, when Figure 13 When the terminal device shown in the figure is a smartphone, the processor inside the smartphone is generally an CPU and a GPU related to image processing. Both the CPU and the GPU here can contain multiple cores.
[0235] The memory 3070 can store a computer program, including an operating system program 3072 and an application program 3071, etc. Among them, typical operating systems such as Microsoft's Windows, Apple's MacOS, etc. are used for desktop or notebook systems.
[0236] The memory 3070 can be one or more of the following types: flash memory, hard disk type memory, micro multi-media card type memory, card type memory (such as SD or XD memory), random access memory (RAM), static random access memory (SRAM), read only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable ROM (PROM), magnetic memory, magnetic disk or optical disk. In some other embodiments, the memory 3070 can also be a network storage device on the Internet, and the system can perform updating or reading, etc. operations on the memory 3070 on the Internet.
[0237] For example, the above-mentioned memory 3070 can store a computer program (which is the program corresponding to the graphic rendering method of the embodiments of the present application), and when the processor 3050 executes the computer program, the processor 3050 can execute the graphic rendering method of the embodiments of the present application.
[0238] The memory 3070 also stores other data 3073 in addition to the computer program, for example, the memory 3070 can store data in the process of the graphic rendering method of the present application.
[0239] Figure 13 The connection relationship of each module in the figure is only an example, and the terminal device provided by any embodiment of the present application can also be applied to a terminal device with other connection modes, for example, all modules are connected through a bus.
[0240] Those skilled in the art can clearly understand that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0241] Those skilled in the art can clearly understand that, for the convenience and brevity of the description, the specific working processes of the above-described system, device and unit can refer to the corresponding processes in the foregoing method embodiments, which will not be repeated here.
[0242] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other ways. For example, the above-described device embodiments are only schematic, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, device or unit, and can be electrical, mechanical or other forms.
[0243] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0244] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically, or two or more units can be integrated into one unit.
[0245] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the parts that contribute to the prior art or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0246] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A graphics rendering method, characterized in that, The method is applied to a terminal device, the terminal device including a graphics processing unit (GPU), and the method includes: Obtain vertex data for N vertices to be rendered, where N is a positive integer; the N vertices to be rendered are used to form multiple model meshes to be rendered, each model mesh to be rendered includes multiple triangle networks, and the vertices of each triangle network are composed of multiple vertices to be rendered from the N vertices to be rendered; obtain the computing resources currently available to the CPU; determine the number of triangle networks included in each model mesh to be rendered based on the computing resources; wherein, if the computing resources are more, the number of triangle networks included in each model mesh to be rendered is more, and if the computing resources are less, the number of triangle networks included in each model mesh to be rendered is less. If the GPU load exceeds a preset value, then based on the vertex data of the N vertices to be rendered, M vertices to be rendered are obtained from the N vertices to be rendered, wherein the M vertices to be rendered are vertices visible within the user's field of view; M is a positive integer less than N; the GPU load is related to at least one of the following: the number of draw calls that the GPU needs to process when rendering one frame of an image; the number of vertices to be rendered that the GPU needs to process when rendering one frame of an image; the number of textures to be rendered that the GPU needs to process when rendering one frame of an image; or the GPU's frequency occupancy; as well as, The vertex data of the M vertices to be rendered is passed to the GPU so that the GPU can perform graphics rendering.
2. The method according to claim 1, characterized in that, The step of obtaining M vertices to be rendered from the N vertices to be rendered based on the vertex data of the N vertices to be rendered includes: Based on the vertex data of the triangle network in each model mesh to be rendered, model meshes whose vertices are not visible within the user's field of view are removed, resulting in multiple model meshes after removal. The multiple model meshes after removal include the M vertices to be rendered.
3. The method according to claim 2, characterized in that, The step of removing model meshes whose vertices are not visible to the user's viewpoint, based on the vertex data of the triangle network in each model mesh to be rendered, includes: Based on the vertex data of the triangle network in each model mesh to be rendered, model meshes whose vertices are not visible within the user's view range are removed by at least one of backface culling, frustum culling, and occlusion culling.
4. The method according to claim 1, characterized in that, The step of obtaining vertex data for N vertices to be rendered includes: obtaining multiple first drawing calls, wherein the multiple first drawing calls are used to invoke the vertex data for the N vertices to be rendered; correspondingly, the step of transferring the vertex data for M vertices to be rendered to the GPU includes: Based on the vertex data of the M vertices to be rendered, the plurality of first draw calls are updated to obtain a plurality of second draw calls, which are used to call the vertex data of the M vertices to be rendered; The plurality of second draw calls are passed to the GPU.
5. A graphics rendering method, characterized in that, The method is applied to a terminal device, the terminal device including a CPU and a GPU, and the method includes: The CPU acquires multiple first draw calls, which are used to call vertex data for N vertices to be rendered. If the CPU load exceeds a preset value, the CPU will transfer the plurality of first draw calls to the GPU; the CPU load is related to at least one of the following: the time required for the CPU to render one frame of an image; the number of API calls that the CPU needs to process when rendering one frame of an image; and the CPU's frequency occupancy. The GPU obtains M vertices to be rendered from the N vertices to be rendered based on the vertex data of the N vertices to be rendered, wherein the M vertices to be rendered are vertices visible within the user's field of view; M is a positive integer less than N; the GPU writes the vertex data of the M vertices to be rendered to the indirect drawbuffer. The GPU updates the plurality of first draw calls based on the vertex data of the M vertices to be rendered, thereby obtaining a plurality of second draw calls, the plurality of second draw calls being used to invoke the vertex data of the M vertices to be rendered; and the GPU performs graphics rendering based on the plurality of second draw calls, including: the CPU triggers the GPU to obtain the vertex data of the M vertices to be rendered from the indirect draw buffer based on the indirect draw call, so that the CPU performs graphics rendering based on the plurality of second draw calls.
6. The method according to claim 5, characterized in that, Each first draw call includes a function name, and the method further includes: The CPU generates P target draw calls based on the function names of the N draw calls and the vertex data of the vertex to be rendered. The P target draw calls represent the N draw calls, and each target draw call represents a part of the N draw calls. The function names and vertex data of the vertex to be rendered are the same for the part of the draw calls. The CPU passes each target draw call to a first buffer and triggers the GPU to retrieve the P target draw calls from the P first buffers based on compute shader calls, wherein each compute shader call can trigger the GPU to retrieve one target draw call from a first buffer.
7. The method according to claim 5, characterized in that, The N vertices to be rendered are used to form multiple model meshes to be rendered. Each model mesh to be rendered includes multiple triangle networks, and the vertices of each triangle network are composed of multiple vertices to be rendered from the N vertices to be rendered. The step of obtaining M vertices to be rendered from the N vertices to be rendered based on the vertex data of the N vertices to be rendered includes: Based on the vertex data of the triangle network in each model mesh to be rendered, model meshes whose vertices are not visible within the user's field of view are removed, resulting in multiple model meshes after removal. The multiple model meshes after removal include M vertices to be rendered.
8. The method according to claim 7, characterized in that, The step of removing model meshes whose vertices are not visible to the user's viewpoint, based on the vertex data of the triangle network in each model mesh to be rendered, includes: Based on the vertex data of the triangle network in each model mesh to be rendered, model meshes whose vertices are not visible within the user's view range are removed by at least one of backface culling, frustum culling, and occlusion culling.
9. A graphics rendering apparatus, characterized in that, The device is applied to a terminal device, the terminal device including a graphics processing unit (GPU), and the device includes: The acquisition module is used to acquire vertex data of N vertices to be rendered. The N vertices to be rendered are used to form multiple model meshes to be rendered. Each model mesh to be rendered includes multiple triangle networks. The vertices of each triangle network are composed of multiple vertices to be rendered from the N vertices to be rendered. The acquisition module is further configured to acquire the computing resources currently available to the central processing unit (CPU); the triangle network number determination module is configured to determine the number of triangle networks included in each of the plurality of model meshes to be rendered based on the computing resources; wherein, if the computing resources are more abundant, the number of triangle networks included in each model mesh to be rendered is greater, and if the computing resources are less abundant, the number of triangle networks included in each model mesh to be rendered is less. A vertex culling module is used to, if the GPU load exceeds a preset value, obtain M vertices to be rendered from the N vertices to be rendered based on the vertex data of the N vertices to be rendered, wherein the M vertices to be rendered are vertices visible within the user's viewpoint; M is a positive integer less than N; the GPU load is related to at least one of the following: the number of draw calls that the GPU needs to process when rendering one frame of an image; the number of vertices to be rendered that the GPU needs to process when rendering one frame of an image; the number of textures to be rendered that the GPU needs to process when rendering one frame of an image; and the GPU's frequency occupancy; and, The graphics rendering module is used to transfer the vertex data of the M vertices to be rendered to the GPU so that the GPU can perform graphics rendering.
10. The apparatus according to claim 9, characterized in that, The vertex culling module is used for: Based on the vertex data of the triangle network in each model mesh to be rendered, model meshes whose vertices are not visible within the user's field of view are removed, resulting in multiple model meshes after removal. The multiple model meshes after removal include M vertices to be rendered.
11. The apparatus according to claim 10, characterized in that, The vertex culling module is used to remove model meshes whose vertices are not visible to the user's viewpoint by using at least one of backface culling, view frustum culling, and occlusion culling, based on the vertex data of the triangle network in each model mesh to be rendered.
12. The apparatus according to claim 9, characterized in that, The acquisition module is used to acquire multiple first drawing commands (draw calls), which are used to call the vertex data of the N vertices to be rendered; correspondingly, the graphics rendering module is used to update the multiple first draw calls according to the vertex data of the M vertices to be rendered, so as to obtain multiple second draw calls, which are used to call the vertex data of the M vertices to be rendered. The plurality of second draw calls are passed to the GPU.
13. A graphics rendering apparatus, characterized in that, The device is applied to a terminal device, the terminal device including a CPU and a GPU, the CPU including: The acquisition module is used by the CPU to acquire multiple first draw calls, which are used to call vertex data of N vertices to be rendered; A command passing module is used to pass the plurality of first drawcalls to the GPU if the CPU load is greater than a preset value; the CPU load is related to at least one of the following: the time required for the CPU to render one frame of image; the number of API calls that the CPU needs to process when rendering one frame of image; and the CPU frequency occupancy. The GPU includes: The vertex culling module is used to obtain M vertices to be rendered from the N vertices to be rendered based on the vertex data of the N vertices to be rendered, wherein the M vertices to be rendered are vertices visible within the user's field of view; and M is a positive integer less than N. Based on the vertex data of the M vertices to be rendered, the plurality of first draw calls are updated to obtain a plurality of second draw calls, which are used to call the vertex data of the M vertices to be rendered; The data writing module is used to write the vertex data of the M vertices to be rendered to the indirect draw buffer; and, The graphics rendering module is used to perform graphics rendering based on the plurality of second draw calls; The graphics rendering module is specifically used for: the CPU triggering the GPU to obtain the vertex data of the M vertices to be rendered from the indirect draw buffer based on the indirect draw call, so that the CPU can perform graphics rendering according to the multiple second draw calls.
14. The apparatus according to claim 13, characterized in that, Each first draw call includes a function name, and the CPU also includes: The command merging module is used to generate P target draw calls based on the function names of the N draw calls and the vertex data of the vertex to be rendered called. The P target draw calls are used to represent the N draw calls, and each target draw call is used to represent a part of the N draw calls. The function names of the part of the draw calls and the vertex data of the vertex to be rendered called are the same. Each target draw call is passed to a first buffer, and the compute shader is called based on the compute shader to trigger the GPU to retrieve the P target draw calls from the P first buffers. Each compute shader call can trigger the GPU to retrieve one target draw call from a first buffer.
15. The apparatus according to claim 13, characterized in that, The N vertices to be rendered are used to form multiple model meshes to be rendered. Each model mesh to be rendered includes multiple triangle networks. The vertices of each triangle network are composed of multiple vertices to be rendered from the N vertices to be rendered. The vertex culling module is used to cull model meshes whose vertices are not visible to the user's view based on the vertex data of the triangle networks in each model mesh to be rendered, so as to obtain multiple model meshes after culling. The multiple model meshes after culling include M vertices to be rendered.
16. The apparatus according to claim 15, characterized in that, The vertex culling module is used to remove model meshes whose vertices are not visible to the user's viewpoint by using at least one of backface culling, view frustum culling, and occlusion culling, based on the vertex data of the triangle network in each model mesh to be rendered.
17. A non-volatile computer-readable storage medium, characterized in that, The non-volatile computer-readable storage medium contains computer instructions for performing the graphics rendering method according to any one of claims 1 to 8.
18. A computer device, characterized in that, The computer device includes a memory and a processor, the memory storing code, and the processor being configured to retrieve the code to execute the graphics rendering method according to any one of claims 1 to 8.
19. A computer program product, characterized in that, Includes computer instructions, which, when executed by one or more processors, are used to implement the graphics rendering method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Graph rendering method and device, and computer readable storage medium
CN111754381A