Image rendering method and electronic device
By performing normal and shadow rendering in the on-chip storage area of the graphics processing module of the electronic device, the problem of shadow rendering delay is solved and the display quality of the shadow effect is improved.
Patent Information
- Application Number
- CN202210929017.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-03
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2042-08-03
AI Technical Summary
In the existing technology, the data read and write bandwidth between the GPU and the memory during the shadow rendering process is high, which leads to problems of delayed shadow rendering and poor shadow effects.
By performing the rendering of normals and shadows in the on-chip storage area of the graphics processing module of the electronic device, a large amount of data reading and writing between the GPU and the memory is avoided. The on-chip storage area is used to store the depth and normal rendering results, and the results are stored through the preset Ray tracing algorithms handle shadow rendering results.
It reduces the data reading and writing overhead between the GPU and memory, improves the efficiency of shadow rendering, and improves the display quality of shadow effects.
Smart Images

Figure CN117557701B
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of image processing, and in particular to an image rendering method and an electronic device. Background Art
[0002] In order to provide users with a more realistic display effect, some images displayed by the electronic device may include a shadow effect, which may be displayed based on a shadow rendering result obtained by shadow rendering.
[0003] In the current rendering mechanism, during shadow rendering, the graphics processor needs to read depth information, normal information, etc. from the memory as input. As the number of image display frames and image quality continue to increase, the amount of data such as normal information that the GPU needs to read from the memory has also increased significantly. This places high demands on the read and write bandwidth between the GPU and the memory.
[0004] If the read and write bandwidth cannot meet the demand, it may cause delays in shadow rendering and poor display of shadow effects in the image. Summary of the invention
[0005] The embodiments of the present application provide an image rendering method and an electronic device, which realize efficient execution of shadow rendering through on-chip storage, avoid large amounts of data reading and writing between the GPU and the memory during the shadow rendering process, and thus reduce the pressure of data reading and writing between the GPU and the memory.
[0006] In order to achieve the above purpose, the embodiment of the present application adopts the following technical solution:
[0007] In a first aspect, an image rendering method is provided, which is applied to an electronic device, wherein a first application is running in the electronic device, and the first application instructs the electronic device to perform rendering processing on a first frame image by issuing a rendering instruction stream, wherein the first frame image includes a shadow area. The rendering instruction stream includes a first rendering instruction and a second rendering instruction, and the method includes: rendering according to the first rendering instruction to obtain a depth rendering result of the first frame image. The depth rendering result is stored in the memory of the electronic device. Rendering according to the second rendering instruction to obtain a normal rendering result of the first frame image. The normal rendering result is stored in an on-chip storage area of a graphics processing module of the electronic device. According to the depth rendering result and the normal rendering result, a shadow rendering result matching the shadow area is obtained. The shadow area is an area in the first frame image that is displayed as a shadow effect. The shadow rendering result matching the shadow area can be understood as that the display of the shadow area can be performed according to the shadow rendering result. In this way, by performing the rendering of normals and shadows in the on-chip storage, the read and write overhead between the GPU and the memory can be avoided. For example, after the GPU performs normal rendering, it is not necessary to write the normal rendering result into the memory. For example, when the GPU performs shadow rendering, it does not need to read the normal rendering results from the memory.
[0008] Optionally, the rendering instruction stream also includes a third rendering instruction, which is used to instruct the electronic device to create a first frame buffer in the memory. The first frame buffer is used to store the depth rendering result. Before rendering and obtaining the depth rendering result of the first frame image according to the first rendering instruction, the method also includes: creating a first frame buffer in the memory according to the third rendering instruction. The depth rendering result is stored in the memory of the electronic device, including: the depth rendering result is stored on the first frame buffer. In this way, in response to the third rendering instruction, the electronic device can create a frame buffer for depth rendering in the memory.
[0009] Optionally, the rendering instruction stream also includes a fourth rendering instruction, which is used to instruct the electronic device to create a second frame buffer. The second frame buffer is used to store the normal rendering result. Before rendering and obtaining the normal rendering result of the first frame image according to the second rendering instruction, the method also includes: creating the second frame buffer in the on-chip storage area of the graphics processing module according to the fourth rendering instruction. The normal rendering result is stored in the on-chip storage area of the graphics processing module of the electronic device, including: the normal rendering result is stored on the second frame buffer. In this way, based on the fourth rendering instruction, the electronic device can perform a normal rendering process in the on-chip storage area and store the normal rendering result in the on-chip storage. As a result, the GPU can save the overhead of writing to the memory in normal rendering. At the same time, if the normal rendering result needs to be called in the subsequent process, the GPU does not need to read it from the memory.
[0010] Optionally, the rendering instruction stream also includes a fifth rendering instruction, which is used to instruct the electronic device to perform the rendering operation on the shadow information. The shadow rendering result is obtained based on the depth rendering result and the normal rendering result, including: in response to the fifth rendering instruction, the depth rendering result is read from the memory, and the normal rendering result is obtained from the on-chip storage area of the graphics processing module. According to a preset ray tracing algorithm, the shadow rendering result is obtained by processing. In this way, based on the fifth instruction, the electronic device can perform shadow rendering. It can be understood that shadow rendering can use depth information and normal information as input. Since the rendering process of normal information is performed on-chip, the GPU does not need to interact with the memory to obtain the normal information.
[0011] Optionally, the shadow rendering result is obtained according to the depth rendering result and the normal rendering result, including: when the normal rendering operation is completed, triggering to instruct the graphics processing module to perform the shadow rendering operation. The shadow rendering operation includes: reading the depth rendering result from the memory, and obtaining the normal rendering result from the on-chip storage area of the graphics processing module. According to a preset ray tracing algorithm, the shadow rendering result is processed and obtained. In this way, an example of a solution for an electronic device to spontaneously perform shadow rendering is provided. In this way, the electronic device can complete the shadow rendering without relying on the rendering instructions issued by the upper-level application. In some implementations, after the upper-level application issues the shadow rendering instruction, if the electronic device has completed the shadow rendering, the relevant information (such as the address, etc.) storing the shadow rendering result can be directly fed back to the application.
[0012] Optionally, before the trigger instructs the graphics processing module to perform the shadow rendering operation, the method further includes: generating a first message when the normal rendering operation is completed, and the first message is used to indicate that the normal rendering operation is completed. The trigger instructs the graphics processing module to perform the shadow rendering operation, including: when the first message is generated, triggering the graphics processing module to perform the shadow rendering operation. In this way, an example of a solution for an electronic device to determine that normal rendering has been completed is given. This can trigger the shadow rendering process based on the electronic device.
[0013] Optionally, the rendering according to the second rendering instruction to obtain the normal rendering result of the first frame image includes: according to the second rendering instruction, issuing a sixth rendering instruction to the graphics processing module, the sixth rendering instruction is used to instruct the graphics processing module to perform the normal rendering operation of the first frame image on the first deferred rendering pipeline SubPass, and the graphics processing module executes the sixth rendering instruction on the first SubPass to obtain the normal rendering result. The sixth rendering instruction may correspond to the second rendering instruction. In some implementations, the function of the sixth rendering instruction may be the same as the second rendering instruction, such as instructing the GPU to perform normal rendering through SubPass. In other implementations, the sixth rendering instruction may be a variation based on the second rendering instruction. For example, when the second rendering instruction instructs the electronic device to perform normal rendering, the sixth rendering instruction obtained by the GPU can be used to instruct normal rendering on SubPass.
[0014] Optionally, the shadow rendering result is obtained according to the depth rendering result and the normal rendering result, including: creating a second SubPass in the on-chip cache of the graphics processing module, and the second SubPass is used to perform the shadow rendering operation. The rendering result of the first SubPass is obtained and input into the second SubPass, and the rendering result of the first SubPass includes the normal rendering result. The depth rendering result is read from the memory and input into the second SubPass, and the normal rendering result and the depth rendering result are processed according to a preset ray tracing algorithm to obtain the shadow rendering result. In this way, the shadow rendering operation based on SubPass can be implemented on the chip. It can be understood that SubPass provides the ability to directly obtain the rendering result of the previous SubPass. Then, the shadow rendering process executed on the second SubPass can directly obtain the normal rendering result executed on the previous SubPass. Thereby, the efficiency of obtaining the normal rendering result is improved, while saving the reading and writing overhead between the GPU and the memory.
[0015] Optionally, the shadow rendering result includes: first normal information, second normal information, shadow information, and distance information. The first normal information and the second normal information may be normal information corresponding to different directions in the normal information. For example, the first normal information may be normal information in the x-direction, and the second normal information may be normal information in the y-direction.
[0016] Optionally, after obtaining the shadow rendering result, the method further includes: outputting the shadow rendering result to a third frame buffer on the memory, the third frame buffer including a map in the first format, the map in the first format including at least four channels. In this way, the shadow rendering results including multiple sets of data can be stored in the same location, such as on the same map. As a result, in subsequent calls, the full amount of shadow rendering results can be obtained by only reading the data once. This saves unnecessary reading and writing overhead.
[0017] Optionally, the shadow rendering result is output to a third frame buffer on the memory, including: outputting the first normal information, the second normal information, the shadow information, and the distance information to different channels of the first format map respectively. In this way, a specific storage solution for shadow rendering results is provided. Optionally, the first format is RGBA16F.
[0018] Optionally, the graphics processing module is a graphics processor GPU. Of course, in some other implementations, the function of the graphics processing module can also be implemented by other components or circuits with image rendering capabilities.
[0019] In a second aspect, an electronic device is provided, comprising one or more processors and one or more memories; the one or more memories are coupled to the one or more processors, and the one or more memories store computer instructions; when the one or more processors execute the computer instructions, the electronic device executes an image rendering method as described in the first aspect above and any one of various possible designs.
[0020] In a third aspect, a chip system is provided, which includes an interface circuit and a processor; the interface circuit and the processor are interconnected through lines; the interface circuit is used to receive signals from a memory and send signals to the processor, and the signals include computer instructions stored in the memory; when the processor executes the computer instructions, the chip system executes an image rendering method as described in the first aspect above and any one of various possible designs.
[0021] In a fourth aspect, a computer-readable storage medium is provided, the computer-readable storage medium comprising computer instructions, and when the computer instructions are executed, an image rendering method as described in the first aspect and any one of various possible designs is executed.
[0022] In a fifth aspect, a computer program product is provided, which includes instructions. When the computer program product runs on a computer, the computer can execute an image rendering method such as the first aspect and any one of various possible designs according to the instructions.
[0023] It should be understood that the technical solutions provided in the above-mentioned second aspect, third aspect, fourth aspect, and fifth aspect, and their technical features can all correspond to the image rendering method provided in the first aspect and its possible design, so the beneficial effects that can be achieved are similar and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 A logical diagram rendered as an image;
[0025] Figure 2 A logical diagram rendered as a depth information;
[0026] Figure 3 A logical diagram for rendering normal information;
[0027] Figure 4 A schematic diagram of a shadow;
[0028] Figure 5 A schematic diagram of shadow rendering by ray tracing in an image rendering process;
[0029] Figure 6 A schematic diagram rendered as one shade;
[0030] Figure 7 A logical schematic diagram of shadow rendering provided in an embodiment of the present application;
[0031] Figure 8 A schematic diagram of software composition of an electronic device provided in an embodiment of the present application;
[0032] Fig. 9 A schematic diagram of module interaction of an image rendering method provided in an embodiment of the present application;
[0033] Fig.10 A schematic diagram of module interaction of another image rendering method provided in an embodiment of the present application;
[0034] Fig.11 A schematic diagram of module interaction of another image rendering method provided in an embodiment of the present application;
[0035] Fig.12 A schematic diagram of module interaction of another image rendering method provided in an embodiment of the present application;
[0036] Fig.13 A schematic diagram of a storage solution for shadow rendering results provided in an embodiment of the present application;
[0037] Fig.14 A schematic diagram of module interaction of another image rendering method provided in an embodiment of the present application;
[0038] Fig.15 A flowchart of another image rendering method provided in an embodiment of the present application;
[0039] Fig.16 A schematic diagram of the composition of an electronic device provided in an embodiment of the present application;
[0040] Fig.17 A schematic diagram of the composition of a chip system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] Currently, most electronic devices can provide image display functions to users.
[0042] For example, an application (Application, APP) may be installed in the electronic device. When the application needs to display an image through the electronic device, an instruction may be sent to the electronic device so that the electronic device renders the corresponding image according to the instruction, and then the rendered image is displayed on the display screen of the electronic device.
[0043] Combination Figure 1 , which is a flowchart of an image rendering process. In this example, the electronic device may be provided with a central processing unit (CPU), a graphics processing unit (GPU), and a memory. Among them, the CPU can be used for instruction processing and control. The GPU can render an image under the control of the CPU. The memory can be used to provide a storage function, such as storing the rendering results obtained by the GPU rendering.
[0044] like Figure 1 As shown, the application can issue a rendering instruction to instruct the electronic device to render a frame of image. The rendering instruction can correspond to a drawing command (i.e., Drawcall). The CPU can receive the rendering instruction and call the corresponding graphics drawing application programming interface (Application Programming Interface, API) to instruct the GPU to perform the rendering operation corresponding to the rendering instruction. The GPU can then execute the rendering instruction and store the rendering result in the memory.
[0045] It should be noted that in drawing a frame of image, the application can control the electronic device to render the depth information, normal information, etc. of the frame image through rendering instructions, thereby obtaining complete frame image information. In the following example, the application is taken as an example of a game application. It is understandable that the game application can display the video screen to the user through the electronic device during operation. The video screen can be composed of multiple frame images played continuously.
[0046] Take drawing the depth information of a frame of image as an example. Figure 1 ,like Figure 2 As shown. The game application can issue a rendering instruction 21 to instruct the electronic device to render the depth information of the current frame image. According to the rendering instruction 21, the CPU can call the corresponding API interface to instruct the GPU to perform a rendering operation corresponding to the depth information. The GPU can perform the rendering operation and store the rendering result (i.e., the depth rendering result) in the memory. In this example, the memory may include multiple pre-created frame buffers (FrameBuffer, FB), such as frame buffer 21, frame buffer 22, frame buffer 23, etc. Different frame buffers can be used to store different information in the image rendering process. For example, in this example, the GPU can store the depth rendering result in frame buffer 21.
[0047] Take drawing the normal information of a frame of image as an example. Figure 3 As shown, the game application can issue a rendering instruction 22 to instruct the electronic device to render the normal information of the current frame image. The CPU can call the corresponding API interface according to the rendering instruction 22 to instruct the GPU to perform a rendering operation corresponding to the normal information. The GPU can perform the rendering operation and store the rendering result (i.e., the normal rendering result) in the memory. For example, the GPU can store the normal rendering result in the frame buffer 22.
[0048] It should be understood that in some scenes, due to changes in scene light, objects in the scene may have shadows. Figure 4 As shown, the scene may include an object 41. When the light source is located obliquely above the object 41, the object 41 may cast a shadow on the ground.
[0049] Then, in order to provide users with a more realistic viewing experience, the game application may also instruct the electronic device to render the shadow of the object in the current frame image, so that the shadow of the object can be included in the displayed frame image, which is more realistic.
[0050] For example, Figure 5 FIG. 1 is an example of a shadow rendering solution. In this example, the electronic device can render the shadow by using a visualization tracking algorithm to obtain display information of the frame image including the shadow (ie, the rendering result).
[0051] As an implementation, the GPU can use the ray tracing algorithm to split the rendering task of a scene into several rays starting from the camera (such as Figure 5The effect of the view ray shown in the figure on the scene. Each view ray will intersect with the scene in parallel, and obtain the material, texture and other information of the object to be displayed (scene object) according to the intersection position, and calculate the illumination in combination with the light source information. In this way, by calculating the information of each pixel point on the image of the view ray, the projection of the object on the image can be determined. In addition, in this scene, the light source can shine on the object to form a shadow (such as through Figure 5 The shadow ray shown in FIG. 1 is irradiated onto the object to form a shadow). Then, through the above ray tracing algorithm, the position of the pixel point corresponding to the shadow of the object on the image and related information can also be determined. Thus, the display information of the object and the shadow can be obtained on the image.
[0052] Combination Figure 1-Figure 3 For example, let's take drawing the shadow information of a frame of image as an example. Figure 6 As shown, the game application can issue a rendering instruction 23 to instruct the electronic device to render the shadow information of the current frame image. The CPU can call the corresponding API interface according to the rendering instruction 23 to instruct the GPU to perform the rendering operation corresponding to the shadow information. Generally speaking, the rendering of the shadow needs to be combined with the depth information and normal information of the current frame image. Then, in this example, the GPU can read the depth rendering result from the frame buffer 21, read the normal rendering result from the frame buffer 22, and based on this, render and obtain the shadow information (i.e., the shadow rendering result) through the ray tracing algorithm. The GPU can store the shadow rendering result in the frame buffer 23 of the memory.
[0053] At present, in order to realize ray tracing, it can be realized through the forward rendering mechanism. That is to say, the shadow rendering process corresponding to the ray tracing algorithm can be executed in the forward rendering pipeline. In the forward rendering pipeline, the geometric information of the scene including the objects is completed by drawing each object in the scene separately. Then, in the actual implementation process, in order to balance the overhead in the rendering process, it is necessary to minimize the drawing calls of each object. Therefore, the geometric information obtained during the rendering process of each object is very limited. The shadow rendering process (such as the acquisition of shadow rendering results, and the denoising optimization processing for the shadow rendering results, etc.) needs to rely on the geometric information of each object. Then, the limited geometric information will cause the quality of shadow rendering to decline.
[0054] In addition, ray tracing can also be achieved through a deferred rendering mechanism. That is, the shadow rendering process is performed on a deferred rendering pipeline. In a deferred rendering pipeline, the geometric information of the object can be processed first, and then the shadow calculation process of each pixel covered by the light source can be performed based on the geometric information. Thus, the shadow rendering result is obtained.
[0055] As an example, in combination with the above description, the electronic device can be configured as follows: Figure 2 as well as Figure 3 The scheme shown in the figure obtains geometric information of the object. For example, the geometric information may include depth information and normal information. The depth information may be obtained from the depth rendering result, and the normal information may be obtained from the normal rendering result. Then, the GPU of the electronic device may execute the following steps: Figure 6 The method shown, for example, reads the depth rendering result from the frame buffer 21 set in the memory, and reads the normal rendering result from the frame buffer 22. The GPU can execute the ray tracing algorithm according to the depth rendering result and the normal rendering result, and obtain the shadow rendering result and store it in the frame buffer 23 of the memory.
[0056] The ray tracing based on the deferred rendering pipeline can separate the object geometry data and shadow calculation process, thereby obtaining richer geometry information of the object, thereby avoiding the problem of insufficient shadow rendering results caused by less geometry information in the forward rendering pipeline.
[0057] However, in the deferred rendering pipeline, high requirements are placed on the data read and write bandwidth between the GPU (i.e. the computing entity) and the memory. For example, the GPU needs to first write the depth rendering results and normal rendering results to the memory, then read the depth rendering results and normal rendering results from the memory, and the GPU also needs to write the calculated shadow rendering results to the memory.
[0058] Then, when the data reading and writing bandwidth between the GPU and the memory is limited, it will cause delays in shadow calculations, thereby extending the rendering time.
[0059] In order to solve the above problems, an embodiment of the present application provides an image rendering method, which can reduce the data reading and writing between the GPU and the memory and improve the shadow rendering efficiency during the process of performing shadow rendering based on the deferred rendering pipeline.
[0060] Based on the solution provided in the embodiment of the present application, take the example of a game application sending a rendering instruction 23 to instruct an electronic device to perform shadow rendering. Figure 7As shown, the CPU can call the corresponding API in response to the rendering instruction 23 to instruct the GPU to perform shadow rendering. Correspondingly, the GPU can read the rendered normal rendering result from the newly created frame buffer G1 set in its on-chip storage space. Figure 6 The existing normal rendering result acquisition mechanism shown in the figure does not require the GPU to obtain the normal rendering result through read and write interaction with the memory, thereby saving time and read and write bandwidth overhead. Take shadow rendering performed on the newly created frame buffer G2 on the GPU as an example. The GPU can also read the depth rendering result from the frame buffer 21 in the memory. The GPU can render and obtain the shadow rendering result based on the ray tracing algorithm according to the acquired depth rendering result and normal rendering result. In this example, the normal information, shadow information, and distance information included in the shadow rendering result can be stored in different channels on a map included in a frame buffer in the memory. In other words, the shadow rendering result can be saved to a map. Thereby, the effect of streamlining the storage overhead of the shadow rendering result is achieved.
[0061] In addition, in some embodiments, the normal rendering process can also be performed on the newly created frame buffer G1 of the GPU. Figure 3 After normal rendering is completed, the normal rendering result can be directly stored in the newly created frame buffer G1 of the GPU without being written into the frame buffer 22 of the memory. Therefore, the storage process of the normal rendering result can also save the latency between the GPU and the memory and the overhead of the read and write bandwidth.
[0062] The solution provided in the embodiments of the present application is described in detail below with reference to the accompanying drawings.
[0063] It should be noted that the image rendering method provided in the embodiment of the present application can be applied to the user's electronic device. For example, the electronic device can be a portable mobile device such as a mobile phone, a tablet computer, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, a media player, etc. The electronic device can also be a wearable electronic device that can provide display capabilities, such as a smart watch. The embodiment of the present application does not impose any special restrictions on the specific form of the device.
[0064] In different embodiments, the electronic device may have different compositions.
[0065] Exemplarily, in some embodiments, from the perspective of hardware composition, the electronic device involved in the embodiment of the present application may include a processor, an external memory interface, an internal memory, a universal serial bus (USB) interface, a charging management module, a power management module, a battery, an antenna 1, an antenna 2, a mobile communication module, a wireless communication module, an audio module, a speaker, a receiver, a microphone, an earphone interface, a sensor module, a button, a motor, an indicator, a camera, a display screen, and a subscriber identification module (SIM) card interface, etc. Among them, the sensor module may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc. As a possible implementation, the processor may include multiple processors such as a CPU and a GPU. Among them, the GPU may be provided with an on-chip storage space. During the operation of the GPU, the data in its on-chip storage space can be quickly called. The frame buffer set in the GPU on-chip storage space can also be called TileBuffer.
[0066] It should be noted that the above hardware components do not constitute a specific limitation on the electronic device. In other embodiments, the electronic device may include more or fewer components, or combine certain components, or separate certain components, or arrange the components differently.
[0067] In some other embodiments, the electronic device involved in the embodiments of the present application may also have software partitioning. Take the (Android) operating system as an example. In the Android operating system, there may be a hierarchical software partition.
[0068] For example, Figure 8 A schematic diagram of the software composition of an electronic device provided in an embodiment of the present application. Figure 8 As shown, the electronic device may include an application (Application, APP) layer, a framework (Framework) layer, a system library, and a hardware (HardWare) layer, etc.
[0069] Among them, the application layer can also be called the application program layer. In some implementations, the application program layer may include a series of application packages. The application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, etc. In an embodiment of the present application, the application package may also include an application that needs to display images or videos to users by rendering images. Among them, the video can be understood as the continuous playback of multiple frames of images. The image that needs to be rendered may include a frame image with a shadow. Exemplarily, the application that needs to render an image may include a game application, such as wait.
[0070] The framework layer can also be called the application framework layer. The framework layer can provide an application programming interface (API) and a programming framework for the application layer. The framework layer includes some predefined functions. Exemplarily, the framework layer may include a window manager, a content provider, a view system, a resource manager, a notification manager, an activity manager, an input manager, and the like. The window manager provides a window management service (WMS), which can be used for window management, window animation management, surface management, and as a transfer station for the input system. The content provider is used to store and obtain data and make the data accessible to the application. The data may include video, images, audio, dialed and received calls, browsing history and bookmarks, phone books, and the like. The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, and the like. The view system can be used to build applications. The display interface may be composed of one or more views. For example, a display interface including a text notification icon may include a view for displaying text and a view for displaying pictures. The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, and the like. The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, prompting text information in the status bar, issuing a prompt sound, vibrating electronic devices, flashing indicator lights, etc. The activity manager can provide the activity management service (Activity Manager Service, AMS), which can be used to start, switch, and schedule system components (such as activities, services, content providers, and broadcast receivers) and manage and schedule application processes. The input manager can provide the input management service (Input Manager Service, IMS), which can be used to manage system input, such as touch screen input, key input, sensor input, etc. IMS takes events from input device nodes and distributes events to appropriate windows through interaction with WMS.
[0071] In the embodiment of the present application, one or more functional modules may be provided in the framework layer to implement the solution provided in the embodiment of the present application. For example, the framework layer may include a creation module, a processing module, and a shadow rendering module.
[0072] The creation module can be used to create a frame buffer in the memory and the GPU on-chip storage space. For example, a frame buffer is created in the memory for storing the depth rendering result. Another example is to create a TileBuffer on the GPU for normal rendering and shadow rendering.
[0073] The processing module can be used to process the rendering commands issued by the application, and call the corresponding API to instruct the GPU to perform rendering operations. For example, when the application issues a rendering command instructing depth rendering, the processing module can control the GPU to perform a rendering operation on the depth information of the current frame image, and store the depth rendering result in the memory. For another example, when the application issues a rendering command instructing normal rendering, the processing module can control the GPU to perform a rendering operation on the normal information of the current frame image, and store the normal rendering result in the GPU's TileBuffer. For another example, when the application issues a rendering command instructing shadow rendering, the processing module can control the GPU to obtain the depth rendering result from the memory and the normal rendering result from the TileBuffer, thereby performing a rendering operation according to the ray tracing algorithm to obtain the corresponding shadow rendering result.
[0074] It can be seen that the creation module and the processing module can respond to the rendering command issued by the application. In the embodiment of the present application, in order to enable the creation module and the processing module to successfully obtain the rendering command issued by the application, such as Figure 8 As shown, an interception module may also be provided at the framework layer. In the present application, the interception module may be used to receive a rendering command issued by an application program, and send the corresponding rendering command to a corresponding module for processing according to the information indicated by the rendering command.
[0075] In some embodiments, the interception module may send a command for instructing to create a frame buffer to the creation module for processing. As a possible implementation, the command for instructing to create a frame buffer may include: glCreateFrameBuffer function.
[0076] In other embodiments, the interception module may also send a command for instructing a rendering operation to the processing module for processing. As a possible implementation, the command for instructing a rendering operation may include a command for instructing a rendering operation for depth information, a command for instructing a rendering operation for normal information, and a command for instructing a rendering operation for shadow rendering. Similar to the above-mentioned interception mechanism for commands for creating a frame buffer, the interception module may determine the content indicated by the rendering command based on the instructions carried in the rendering command. For example, a command for instructing a rendering operation for depth information may include the keyword depthMap, and a command for instructing a rendering operation for normal information may include the keywords Vertex or Vertex and Normal. It is understandable that normal information may be included in vertex information, and in some implementations, relevant data of the normal vector is included in the Vertex command, identified by Normal. In addition, a command for instructing shadow rendering may include the keyword shadow.
[0077] Continue to refer Figure 8 In the embodiment of the present application, a shadow rendering module may also be provided in the framework layer. As a possible implementation, the shadow rendering module may instruct the GPU to render the shadow information after the GPU completes the rendering of the normal information and obtains the normal rendering result.
[0078] Combination Figure 7 As shown in the embodiment of the present application, the rendering pipeline of the normal information can be set in the TileBuffer of the GPU. Exemplarily, the rendering pipeline that executes the normal information can be based on the SubPass system. It should be understood that the SubPass system, as a rendering pipeline mechanism provided by most current rendering platforms, is different from the traditional MultiPass system, and enables the next SubPass to directly obtain the rendering result of the current SubPass during execution. Instead of needing to store the rendering result in the memory after the rendering of the current pipeline is completed, as in the MultiPass system, the next pipeline needs to read the result from the memory to obtain the rendering result obtained in the current pipeline.
[0079] Then, in this example, the shadow rendering pipeline instructed by the shadow rendering module to be executed by the GPU can also be based on the SubPass system. The shadow rendering pipeline can be set in the TileBuffer of the GPU, and the shadow rendering pipeline can be the corresponding instruction of the next rendering command of the normal rendering pipeline. For example, Drawcall A instructs the GPU to perform normal rendering based on SubPass. After Drawcall A is executed, the next Drawcall B can be a rendering command issued by the shadow rendering module, instructing the GPU to perform shadow rendering based on SubPass.
[0080] In this way, after the GPU completes the rendering of Drawcall A and obtains the normal rendering result, it can execute DrawcallB. Since Drawcall B is also based on the SubPass system, when the GPU executes the shadow rendering indicated by Drawcall B, it can directly obtain the rendering result (that is, the normal rendering result) of the previous SubPass (that is, the rendering operation corresponding to Drawcall A, that is, the rendering operation of the normal rendering pipeline). In this way, the GPU can obtain the normal rendering result without reading and writing with the memory. In addition, the GPU can read the depth rendering result from the memory according to Drawcall B, and then perform rendering operations according to the ray tracing algorithm to obtain the shadow rendering result of the current frame image.
[0081] It should be noted that in some embodiments of the present application, as described above for the shadow rendering module, the shadow rendering module can directly instruct the GPU to perform shadow rendering after the normal rendering operation is completed. That is to say, in this example, the electronic device can complete the shadow rendering by itself without receiving the rendering instruction issued by the application program to instruct the shadow rendering. After the application program issues the rendering instruction to instruct the shadow rendering, the electronic device can directly call back the shadow rendering result executed by the GPU and feed it back to the application program.
[0082] In some other embodiments of the present application, the application may also sequentially perform shadow rendering operations based on SubPass after instructing the electronic device to perform normal rendering. Then, the GPU of the electronic device may also directly obtain the rendering result of the previous SubPass during the shadow rendering process, that is, directly obtain the normal rendering result. In this example, the shadow rendering module may no longer be set in the electronic device.
[0083] Therefore, in different implementations, based on the solution provided by the embodiment of the present application, for the rendering command issuing mechanism of different applications, the effect of directly obtaining the normal rendering result through the shadow rendering process of SubPass can be achieved. This can save the data reading and writing overhead between the GPU and the memory when obtaining the normal rendering result during the shadow rendering process.
[0084] like Figure 8 As shown, the electronic device may also be provided with a system library including a graphics library. In different implementations, the graphics library may include at least one of the following: Open Graphics Library (OpenGL), OpenGL for Embedded Systems (OpenGL ES), Vulkan, etc. In some embodiments, the system library may also include other modules. For example: surface manager, media framework (MediaFramework), standard C library (Standard C library, libc), SQLite, Webkit, etc.
[0085] Among them, the surface manager is used to manage the display subsystem and provide the fusion of two-dimensional (2D) and three-dimensional (3D) layers for multiple applications. The media framework supports playback and recording of multiple commonly used audio and video formats, as well as static image files, etc. The media library can support multiple audio and video encoding formats, such as: Moving Pictures Experts Group 4 (MPEG4), H.264, Moving Picture Experts Group Audio Layer 3 (MP3), Advanced Audio Coding (AAC), Adaptive Multi-Rate (AMR), Joint Photographic Experts Group (JPEG, or JPG), Portable Network Graphics (PNG), etc. OpenGL ES and / or Vulkan provide drawing and operation of 2D graphics and 3D graphics in applications. SQLite provides a lightweight relational database for applications of electronic device 400.
[0086] After the application sends the rendering command, each module in the framework layer can call the corresponding API in the graphics library to instruct the GPU to perform the corresponding rendering operation.
[0087] In such Figure 8 In the example, the electronic device may also include a hardware layer. The hardware layer may include a CPU, a GPU, and a storage device (such as a memory) with a storage function. In some implementations, the CPU may be used to control each module in the framework layer to implement its respective functions, and the GPU may be used to perform corresponding rendering processing according to an API in a graphics library (such as OpenGL ES) called by instructions processed by each module in the framework layer.
[0088] The solutions provided in the embodiments of the present application can be applied to Figure 8 In the electronic device shown. It should be noted that, Figure 8 The examples do not constitute a limitation on the electronic device. In other embodiments, the electronic device may also include more or fewer components. The embodiments of the present application do not limit the specific composition of the electronic device.
[0089] In the following description, an electronic device is assumed to have Figure 8 The software division described above is that the application is a game application (corresponding to the first application), and the game application sends a rendering instruction stream to instruct the electronic device to perform rendering processing on the first frame image (or the Nth frame image). Taking the first frame image as an example, the shadow rendering scheme involved in the scheme provided in the embodiment of the present application is described in detail. The shadow rendering result obtained by the shadow rendering scheme provided in the embodiment of the present application can be used to display the shadow area in the first frame image. It should be understood that based on Figure 8 As described in the description of the graphics library, it can be understood that when the CPU needs to instruct the GPU to perform a rendering operation, it can convey the rendering instruction to the GPU by calling the API in the graphics library. In the following description, the process of calling the API in the rendering process is no longer described in detail.
[0090] As an example, see Fig. 9 , is a schematic diagram of module interaction of an image rendering method provided in an embodiment of the present application. Fig. 9 The scheme shown can be used for frame buffer creation.
[0091] For example, Fig. 9 After the game application starts running, for example, when the game application is in a loading screen, a rendering command 901 may be issued. The rendering command 901 may include at least one glCreateFrameBuffer function, which is used to instruct the electronic device to perform the frame buffer required in the subsequent image rendering process.
[0092] For example, the rendering command 901 may include a third rendering instruction (corresponding to the third rendering instruction) for instructing to create a first frame buffer on the memory of the electronic device, and the first frame buffer may be used to store the depth rendering result. The first frame buffer may correspond to the frame buffer 93 described later.
[0093] For another example, the rendering command 901 may include a fourth rendering instruction for instructing to create a second frame buffer on the on-chip storage space of the GPU of the electronic device, and the second frame buffer may be used to store normal rendering results. The second frame buffer may correspond to the frame buffer 91 described later.
[0094] The interception module set in the framework layer of the electronic device can intercept the rendering command 901, and determine that the rendering command 901 is used to instruct the electronic device to create a frame buffer according to the glCreateFrameBuffer function carried therein. Then, the interception module can transmit the rendering command 901 to the creation module for subsequent processing.
[0095] The creation module may create a corresponding frame buffer in response to the rendering command 901 .
[0096] In the embodiment of the present application, the creation module can create multiple frame buffers simultaneously or in batches. Among them, these frame buffers can include frame buffers set in the memory and frame buffers set in the GPU on-chip storage space, that is, TileBuffer in the above description.
[0097] As an example, Fig. 9 As shown, the creation module can create a frame buffer 91 on the cache of the GPU. The creation module can also create a frame buffer 92 on the cache of the GPU. The frame buffer 91 and the frame buffer 92 can be caches set on the GPU slice, which are used to perform normal rendering and shadow rendering in the subsequent rendering process. In the subsequent description, the frame buffer 91 for normal rendering can also be called G-Buffer.
[0098] The creation module may also create a frame buffer 93 and a frame buffer 94 in the memory. The frame buffer set in the memory may be used to render and store depth information. For example, depth rendering may be performed on the frame buffer 93. In order to facilitate the call of other pipelines to the shadow rendering result, after the shadow rendering is completed, the GPU may also store the shadow rendering result in the memory. For example, the frame buffer 94 may include a texture, which may be in RGBA16F format, for storing shadow rendering results in different channels.
[0099] In this way, in the subsequent rendering process of each frame image, the corresponding frame buffer that has been created can be called through the ID of the above frame buffer 91-frame buffer 94 to perform the corresponding rendering operation.
[0100] For example, taking the rendering of the Nth frame image as an example, the game application can instruct the electronic device to render the depth information in the Nth frame image by issuing a rendering command.
[0101] like Fig.10 As shown, it is a schematic diagram of the module interaction of another image rendering method provided in an embodiment of the present application. Fig.10 The solution shown can be used to render depth information, that is, perform depth rendering and obtain depth information (or referred to as depth rendering result).
[0102] like Fig.10 As shown, when the game application needs to render the Nth frame image, it can send a rendering command 902 (corresponding to the first rendering instruction) to the electronic device. The rendering command 902 may include the keyword depthMap, which is used to instruct the electronic device to render the depth information of the current frame image (i.e., the Nth frame image). In this application, the rendering command 902 may also be referred to as the first rendering instruction.
[0103] Correspondingly, the interception module can determine, based on the carried keyword depthMap, that the rendering command 902 is used to instruct rendering of depth information. Then, the interception module can transmit the rendering command 902 to the processing module for subsequent processing.
[0104] The processing module may instruct the GPU to render the depth information according to the rendering command 902. It should be understood that, in combination with the foregoing description of the system library, in some embodiments, the processing module may instruct the GPU to render the depth information of the Nth frame image by calling an API corresponding to the rendering command 902 in the system library.
[0105] It should be noted that, in the embodiment of the present application, when the processing module instructs the GPU to perform depth rendering, it can also instruct the GPU to store the depth rendering result in the memory. For example, when the processing module instructs the GPU to perform depth rendering, the frame buffer ID of the frame buffer 93 can be carried so that the GPU can store the depth information obtained by rendering on the frame buffer 93. Among them, the frame buffer ID of the frame buffer 93 can be sent to the processing module after the creation module completes the creation of the frame buffer.
[0106] Then, under the control of the processing module, the GPU can perform the depth rendering operation and store the acquired depth rendering result in the frame buffer 93 in the memory.
[0107] In addition, the game application can also instruct the electronic device to render the normal information in the Nth frame image by issuing a rendering command.
[0108] For example, please refer to Fig.11, which is a schematic diagram of module interaction of another image rendering method provided in an embodiment of the present application. Fig.11 The solution shown can be used to render normal information, that is, to perform normal rendering and obtain normal information (or called normal rendering result).
[0109] like Fig.11 As shown, when the game application needs to render the Nth frame image, it can send a rendering command 903 (corresponding to the second rendering instruction) to the electronic device. The rendering command 903 may include the keyword Vertex, which is used to instruct the electronic device to render the geometric information including depth information of the current frame image (i.e., the Nth frame image). In this application, the rendering command 903 may also be referred to as the second rendering instruction.
[0110] It is understandable that, in some cases, the normal information can be rendered together with other geometric information of the model. The rendering process of the geometric information can be performed according to the vertex data (Vertex) sent by the game application.
[0111] Correspondingly, the interception module can determine that the rendering command 903 is used to instruct the rendering of normal information according to the carried keyword Vertex. Then, the interception module can transmit the rendering command 903 to the processing module for subsequent processing.
[0112] The processing module may instruct the GPU to render the normal information according to the rendering command 903. It should be understood that, in combination with the foregoing description of the system library, in some embodiments, the processing module may instruct the GPU to render the normal information of the Nth frame image by calling an API corresponding to the rendering command 903 in the system library.
[0113] It should be noted that, unlike the storage of depth rendering results in memory, in an embodiment of the present application, the normal rendering pipeline can be set on the TileBuffer of the GPU. In some implementations, the normal rendering pipeline on the TileBuffer may be indicated by the second rendering instruction. Then, the sixth rendering instruction generated according to the second rendering instruction received by the GPU may be the same as or similar to the second rendering instruction. In other implementations, the second rendering instruction may instruct the execution of the normal rendering pipeline in memory. Then, in the present application, the processing module may generate a sixth rendering instruction according to the second rendering instruction, and the sixth rendering instruction may instruct the GPU to perform the operation of the normal rendering pipeline on the TileBuffer. The rendering pipeline that performs normal rendering operations on the TileBuffer may also be referred to as the first SubPass.
[0114] Exemplarily, when instructing the GPU to perform normal rendering, the processing module may also instruct the normal rendering process to be bound (Bind) to the frame buffer 91. The frame buffer ID of the frame buffer 91 may be sent to the processing module by the creation module after the frame buffer is created. Then, the GPU can execute the normal rendering pipeline on the frame buffer 91. In some embodiments, the normal rendering pipeline that the processing module instructs the GPU to execute may be a SubPass-based rendering pipeline. This allows the subsequent SubPass pipeline to directly obtain the normal rendering result.
[0115] At some angles, after the SubPass-based normal rendering process executed on the frame buffer 91 is executed, the normal rendering result obtained can be temporarily stored on the frame buffer 91. Then, the subsequent SubPass pipeline can read data from the GPU on-chip cache (i.e., the frame buffer 91) to quickly obtain the normal rendering result.
[0116] So, if Fig.11 As shown, after the normal rendering operation is completed, the normal rendering result can be stored in the frame buffer 91.
[0117] In some embodiments of the present application, after completing normal rendering, the GPU can perform a callback to the upper layer so that the upper layer knows that the normal has been rendered. For example, after completing the normal rendering operation to obtain the normal rendering result, the GPU can call back a message (such as a first message) to the processing module to indicate that the normal rendering has been completed. In this way, each module in the framework layer of the electronic device can know the current rendering progress. In the present application, in combination with the above-mentioned description of the characteristics of the SubPass-based rendering pipeline, the normal rendering pipeline executed on the frame buffer 91 can be based on SubPass. Then, in order to quickly call the rendering result of the SubPass when the subsequent rendering process needs to use the normal rendering result (such as the shadow rendering process), the electronic device can control the GPU to perform SubPass-based shadow rendering after knowing that the normal rendering has been completed, so that the SubPass-based shadow rendering pipeline can directly and quickly obtain the normal rendering result.
[0118] As a first example, the normal rendering pipeline is SubPass-G (i.e., the first SubPass) and the shadow rendering pipeline is SubPass-Shadow (or the second SubPass). The electronic device can be based on the following example: Fig.11The scheme shown in the figure completes the rendering of SubPass-G and obtains the normal rendering result. Then, the electronic device can control the GPU to perform the shadow rendering operation. For example, after determining that the GPU has completed the rendering of SubPass-G, the electronic device can instruct the GPU to perform the rendering operation of SubPass-Shadow. Then, since SubPass-Shadow is the SubPass that is executed sequentially after SubPass-G is completed, when the GPU performs the shadow rendering in SubPass-Shadow, it can directly obtain the rendering result of SubPass-G, that is, the normal rendering result. Combined with Figure 6 As shown in the figure, compared with the current solution of reading normal rendering results from memory, this example uses the characteristics of SubPass to save the GPU's reading and writing overhead of reading normal rendering results from memory.
[0119] In different implementations of the present application, the electronic device may spontaneously perform shadow rendering after the GPU completes normal rendering; or, the electronic device may perform shadow rendering according to a rendering command issued by a game application after the GPU completes normal rendering.
[0120] For example, please refer to Fig.12 , which is a schematic diagram of module interaction of another image rendering method provided in an embodiment of the present application. Fig.12 The solution shown can be used for shadow rendering. In this example, an electronic device spontaneously performs shadow rendering after the GPU completes normal rendering.
[0121] like Fig.12 As shown, after the GPU completes normal rendering, the processing module can indicate the current rendering progress of the shadow rendering module as: normal rendering has been completed. Fig.11 , the processing module can determine whether the current GPU has completed normal rendering based on the message of completed normal rendering called back by the GPU.
[0122] Correspondingly, the shadow rendering module can send a shadow rendering instruction to the GPU. The instruction can be bound to the GPU's TileBuffer so that the GPU can perform the shadow rendering operation on the TileBuffer. For example, the shadow rendering instruction can be bound to the frame buffer 92 so that the GPU can run the shadow rendering pipeline on the frame buffer 92 and perform the shadow rendering operation.
[0123] The shadow rendering instruction may also carry a frame buffer ID storing a depth rendering result, a frame buffer ID storing a normal rendering result, and a frame buffer ID storing a shadow rendering result. These frame buffer IDs may be obtained from the creation module via the processing module, or the shadow rendering module may directly obtain these frame buffer IDs from the creation module.
[0124] In the embodiment of the present application, the instruction for performing shadow rendering may also instruct a GPU, and the shadow rendering pipeline may be based on a SubPass system.
[0125] For example, the shadow rendering module may send the frame buffer ID of frame buffer 91 , the frame buffer ID of frame buffer 93 , and the frame buffer ID of frame buffer 92 to the GPU, so that the GPU can obtain the input data required for the shadow rendering process from frame buffer 91 and frame buffer 93 .
[0126] In response to the shadow rendering instruction, the GPU may run a SubPass-based shadow rendering pipeline, obtain a normal rendering result, read a depth rendering result, and perform a shadow rendering operation.
[0127] Exemplarily, the GPU can obtain the normal rendering result from the frame buffer 91. Combined with the foregoing description, the shadow rendering pipeline (such as SubPass-Shadow) can be a SubPass after SubPass-G, so the normal rendering result can be directly obtained. In the present application, since SubPass-G is executed on the frame buffer 91, it can also be considered that the normal rendering result is obtained by SubPass-Shadow from the frame buffer 91. In addition, the GPU can also read the depth rendering result from the frame buffer 93 in the memory. In this way, the GPU can perform shadow rendering operations in SubPass-Shadow on the frame buffer 92. In some implementations, the shadow rendering operation performed in SubPass-Shadow can be performed according to a ray tracing algorithm preset in the electronic device.
[0128] As a result, the GPU only needs to interact with the memory once to read data to perform shadow rendering operations.
[0129] In this application, after completing the shadow rendering operation, the GPU can store the shadow rendering result in the memory for other pipeline calls. For example, the electronic device can perform a noise reduction (denoising) operation on the shadow rendering result to obtain a better shadow rendering result.
[0130] For example, Fig.12 As shown, after completing the shadow rendering operation, the GPU can store the shadow rendering result in the frame buffer 94 of the memory.
[0131] As a possible implementation, the shadow rendering result may include the normal information of the shadow, the shadow information of each pixel (ShadowMask), and the distance information (Distance) of the shadow. The normal information may include the normal information in the x and y directions. That is, the normal information may include two parts: normal information (x) and normal information (y). The normal information (x) may also be referred to as Normal(x), and the normal information (y) may also be referred to as Normal(y).
[0132] In the present application, when the GPU stores the shadow rendering results in the frame buffer 94 of the memory, all the shadow rendering results can be stored in a map of a preset format on the frame buffer 94. The map of the preset format can include at least 4 channels. Two of the channels can be used to store normal information, another channel can be used to store shadow information, and another channel can be used to store distance information.
[0133] As a possible implementation, the preset format may be RGBA16F format. Fig.13 After the GPU completes the shadow rendering operation on the frame buffer 92, the shadow rendering pipeline can output the shadow rendering result to the RGBA16F format map on the frame buffer 94. For example, the normal information (x) can be output and stored in the R channel of the RGBA16F format on the frame buffer 94; the normal information (x) (i.e., Normal(x)) can be output and stored in the R channel of the RGBA16F format on the frame buffer 94; the normal information (y) (i.e., Normal(y)) can be output and stored in the G channel of the RGBA16F format on the frame buffer 94; the shadow information (ShadowMask) can be output and stored in the B channel of the RGBA16F format on the frame buffer 94; the distance information (Distance) can be output and stored in the A channel of the RGBA16F format on the frame buffer 94. In the present application, the normal information (x) can also be referred to as the first normal information. The normal information (y) can also be referred to as the second normal information.
[0134] In this way, the purpose of saving shadow rendering results on the same map is achieved. Compared with storing shadow rendering results on two or more maps, the solution provided by this example can save memory storage overhead and make it more convenient for other pipelines to call shadow rendering results.
[0135] As you can see, Fig.12In the example, the electronic device can trigger shadow rendering by itself after the GPU completes normal rendering and store it in the memory. Then, the game application can also instruct the electronic device to perform shadow rendering operations in the subsequent rendering command stream. For example, the game application can issue a rendering command 904 (corresponding to the fifth rendering instruction) to instruct the electronic device to perform shadow rendering of the current frame image. The rendering command 904 may include the keyword Shadow. Correspondingly, the interception module can intercept the rendering command 904 according to the keyword Shadow, and send the rendering command 904 to the processing module. After receiving the rendering command 904, the processing module can call back the frame buffer ID of the frame buffer 94 to the game application. It can be understood that due to the following Fig.12 The electronic device shown performs shadow rendering by itself. Before the game application issues the rendering command 904, the shadow rendering result may have been stored in the frame buffer 94. Then, after receiving the rendering command 904, the processing module may directly call back the frame buffer ID of the frame buffer 94 storing the shadow rendering result to the game application, so that the game application knows and uses the shadow rendering result. In the present application, the rendering command 904 may also be referred to as the fifth rendering instruction.
[0136] It should be noted that the above Fig.12 In the example, the electronic device performs shadow rendering by itself after the GPU completes normal rendering. In other embodiments of the present application, the shadow rendering process may also be performed under the instruction of the game application.
[0137] For some game applications, the internal mechanism is similar to Fig.12 The logic shown in the figure is that after instructing the electronic device to perform normal rendering based on SubPass, a rendering instruction can be issued to instruct the electronic device to continue the shadow rendering operation based on SubPass. In this way, when the electronic device uses the SubPass-Shadow pipeline for shadow rendering, it can also directly obtain the rendering result of the previous SubPass (that is, the normal rendering result of SubPass-G), thereby achieving the same effect as in the example above. Fig.12 The scheme shown has a similar effect.
[0138] For example, please refer to Fig.14 , which is a schematic diagram of module interaction of another image rendering method provided in an embodiment of the present application. Fig.14 The solution shown can be used for shadow rendering. In this example, the electronic device sends a SubPass-based normal rendering instruction and a SubPass-based shadow rendering instruction according to the game application sequence as an example.
[0139] like Fig.14As shown, the game application can issue a rendering command 904 to instruct the electronic device to perform shadow rendering of the current frame image. The rendering command 904 may include the keyword Shadow. The interception module can intercept the rendering command 904 according to the keyword Shadow, and send the rendering command 904 to the processing module. The processing module can instruct the GPU to perform shadow rendering according to the rendering command 904. Fig.12 In the example in FIG. 1 , the instruction for instructing the GPU to perform shadow rendering may indicate that the shadow rendering pipeline may be based on the SubPass system. In addition, the instruction for instructing the GPU to perform shadow rendering may also include the frame buffer ID of frame buffer 91, the frame buffer ID of frame buffer 93, and the frame buffer ID of frame buffer 92. This allows the GPU to obtain input data required for the shadow rendering process from frame buffer 91 and frame buffer 93. The instruction for instructing the GPU to perform shadow rendering may also include the frame buffer ID of frame buffer 92 for performing shadow rendering, and the frame buffer ID of frame buffer 94 for storing shadow rendering results.
[0140] Correspondingly, the GPU can obtain the normal rendering result from the frame buffer 91 and read the depth rendering result from the frame buffer 93. The GPU can run the shadow rendering pipeline on the frame buffer 92 and store the shadow rendering result obtained by rendering according to the ray tracing algorithm on the frame buffer 94. The storage mechanism of the shadow rendering result on the frame buffer 94 can be referred to Fig.13 The examples are not repeated here.
[0141] Thus, based on the above Figure 9-14 According to the description, the electronic device can perform SubPass-based normal rendering in the GPU's TileBuffer. There is no need to store the normal rendering results in the memory, thereby saving the read and write overhead of the process. The electronic device can also perform SubPass-based shadow rendering in the GPU's TileBuffer, so that the normal rendering results can be directly obtained without reading from the memory, thereby saving the read and write overhead of the process. The electronic device can also store all shadow rendering results on a preset format map in the memory, thereby saving the storage overhead of the memory.
[0142] The above example Figure 9-14 The example of is to illustrate the rendering method provided by the embodiment of the present application from the perspective of interaction between modules. Fig.15 The module interaction flow chart shown continues to explain the solution provided by the embodiment of the present application. Take the electronic device performing shadow rendering after completing normal rendering as an example.
[0143] like Fig.15 As shown, the process may include:
[0144] S1501. After the game application starts running, a rendering command 901 is issued.
[0145] Exemplarily, the rendering command 901 may include at least one glCreateFrameBuffer function, which is used to instruct the electronic device to perform a frame buffer required in a subsequent image rendering process.
[0146] S1502: The interception module intercepts the rendering command 901 and determines that the rendering command 901 instructs to create a frame buffer.
[0147] The interception module may determine, based on the glCreateFrameBuffer function included in the rendering command 901 , that the rendering command 901 indicates to create a frame buffer.
[0148] S1503. The interception module sends a rendering command 901 to the creation module.
[0149] S1504 . The creation module creates frame buffer 91 and frame buffer 92 on the cache of the GPU.
[0150] S1505 , create frame buffer 91 and frame buffer 92 on the GPU on-chip cache.
[0151] Thus, the frame buffer 91 and the frame buffer 92 may be TileBuffers in the GPU on-chip storage space, wherein the frame buffer 91 may be used for normal rendering, and the frame buffer 92 may be used for shadow rendering.
[0152] S1506. The creation module creates frame buffer 93 and frame buffer 94 in the memory.
[0153] S1507: Create frame buffer 93 and frame buffer 94 in the memory.
[0154] Thus, the frame buffer 93 and the frame buffer 94 may be frame buffers in the memory, wherein the frame buffer 93 may be used for depth rendering, and the frame buffer 94 may be used for storing shadow rendering results.
[0155] It should be noted that the execution order of S1504-S1505 and S1506-S1507 may not be limited. For example, in some embodiments, S1504-S1505 may be executed earlier than S1506-S1507. In other embodiments, S1504-S1505 may be executed later than S1506-S1507. In some embodiments, S1504-S1505 may be executed synchronously with S1506-S1507.
[0156] S1508. The creation module sends the frame buffer ID of the newly created frame buffer to the processing module.
[0157] The newly created frame buffer may include frame buffers 91 to 94. Then, the frame buffer ID of the newly created frame buffer may include the frame buffer IDs of frame buffers 91 to 94.
[0158] This completes the creation of the frame buffer, so that it can be called at any time during the subsequent rendering process of the frame image.
[0159] S1509 , the game application issues a rendering command 902 .
[0160] Exemplarily, the rendering command 902 may include a keyword depthMap, which is used to instruct the electronic device to render the depth information of the current frame image (such as the Nth frame image).
[0161] S1510. The interception module intercepts the rendering command 902 and determines that the rendering command 902 indicates to perform depth rendering.
[0162] The interception module may determine, based on the keyword depthMap, that the rendering command 902 indicates depth rendering.
[0163] S1511. The interception module sends a rendering command 902 to the processing module.
[0164] S1512. The processing module sends a depth rendering instruction to the GPU.
[0165] Exemplarily, the processing module may generate the depth rendering instruction according to the rendering command 902. In some embodiments, the depth rendering instruction may include a frame buffer ID of the frame buffer 93 to instruct the GPU to store the depth rendering result in the frame buffer 93.
[0166] It should be noted that, similar to the above description, the specific implementation of the depth rendering instruction can be that the processing module calls the API in the graphics library through the depth rendering instruction to instruct the GPU to perform the corresponding depth rendering operation.
[0167] S1513. The GPU performs a depth rendering operation according to the depth rendering instruction.
[0168] S1514. GPU sends the depth rendering result to the memory.
[0169] S1515 . The memory stores the depth rendering result in the frame buffer 93 .
[0170] In this way, the depth rendering process is completed.
[0171] S1516. The game application sends a rendering command 903.
[0172] Exemplarily, the rendering command 903 may include a keyword Vertex, which is used to instruct the electronic device to render geometric information including depth information of the current frame image (ie, the Nth frame image).
[0173] S1517: The interception module intercepts the rendering command 903 and determines that the rendering command 903 instructs to perform normal rendering.
[0174] The interception module may determine, based on the keyword Vertex, that the rendering command 903 indicates normal rendering.
[0175] S1518. The interception module sends a rendering command 903 to the processing module.
[0176] S1519. The processing module sends a normal rendering instruction to the GPU.
[0177] Exemplarily, the processing module may generate the normal rendering instruction according to the rendering command 903. In some embodiments, the depth rendering instruction may include a frame buffer ID of the frame buffer 91 to instruct the GPU to perform normal rendering on the frame buffer 91. In addition, the depth rendering instruction may also include a first identifier for instructing the GPU to perform a SubPass-based rendering operation.
[0178] It should be noted that, similar to the above description, the specific implementation of the normal rendering instruction can be that the processing module calls the API corresponding to SubPass in the graphics library through the normal rendering instruction, and based on the Vertex data carried in the rendering command 903, instructs the GPU to perform corresponding geometric rendering operations including normals.
[0179] S1520. The GPU performs a normal rendering operation according to the normal rendering instruction.
[0180] Exemplarily, the GPU may run SubPass-G on the frame buffer 91 according to the normal rendering instruction to perform the normal rendering operation. Correspondingly, after completing the normal rendering in SubPass-G, the normal rendering result may be obtained on the frame buffer 91. The process from completing the normal rendering to obtaining the normal rendering result in the on-chip cache may be shown as S1521-S1522.
[0181] S1521. The GPU sends the normal rendering result to the GPU on-chip cache.
[0182] S1522 , obtaining the normal rendering result in the frame buffer 91 .
[0183] In this way, the normal rendering result can be obtained in SubPass-G. The normal rendering result can be directly obtained by the next SubPass pipeline.
[0184] In this example, the GPU may also feedback that the normal rendering is completed after completing the normal rendering operation, for example, as shown in S1523.
[0185] S1523. The GPU sends a normal rendering completion indication to the processing module.
[0186] S1524. The processing module sends a normal rendering completion indication to the shadow rendering module.
[0187] This triggers the shadow rendering module to control the GPU to perform shadow rendering.
[0188] In some other embodiments of the present application, the GPU may directly feed back a normal rendering completion indication to the shadow rendering module, so as to trigger the shadow rendering module to control the GPU to perform shadow rendering on its own.
[0189] S1525: The shadow rendering module generates a shadow rendering instruction.
[0190] Exemplarily, the shadow rendering instruction may be used to instruct the GPU to perform shadow rendering. In this example, the shadow rendering instruction may also carry a first identifier, which is used to instruct the GPU to perform a rendering operation based on a SubPass.
[0191] It should be noted that, similar to the above description, the specific implementation of the shadow rendering instruction can be that the shadow rendering module calls the API corresponding to SubPass in the graphics library through the shadow rendering instruction to instruct the GPU to perform the corresponding shadow rendering operation.
[0192] S1526. The shadow rendering module sends a shadow rendering instruction to the GPU.
[0193] S1527. The GPU obtains the normal rendering result from the GPU on-chip cache.
[0194] Exemplarily, the GPU can obtain the normal rendering result from the frame buffer 91. It can be understood that since the shadow rendering pipeline (such as SubPass-Shadow) is a SubPass after SubPass-G, the rendering result of SubPass-G, that is, the normal rendering result, can be directly obtained.
[0195] S1528. GPU reads the depth rendering result from the memory.
[0196] Exemplarily, the GPU may read the depth rendering result from the frame buffer 93 .
[0197] S1529: The GPU performs a shadow rendering operation. For example, the GPU may calculate and obtain a shadow rendering result based on a preset ray tracing algorithm and the obtained normal rendering result and depth rendering result.
[0198] S1530. GPU sends the shadow rendering result to the memory.
[0199] S1531 . Store the shadow rendering result in the frame buffer 94 .
[0200] For example, the method of storing the shadow rendering result on the frame buffer 94 can refer to Fig.13 The scheme shown will not be described in detail here.
[0201] In this way, electronic devices can implement shadow rendering based on TileBuffer. Since there is no need to store the normal rendering results in memory, there is no need to read the normal rendering results during the shadow rendering process. Therefore, the read and write overhead can be reduced and the shadow rendering efficiency can be improved.
[0202] When a subsequent game application needs to use the shadow rendering result, the electronic device can directly call back the shadow rendering result to the game application.
[0203] Exemplarily, as shown in S1532, the game application can issue a rendering command 904 to instruct the electronic device to perform shadow rendering of the current frame image. The rendering command 904 may include the keyword Shadow. Next, in S1533, the interception module can determine that the rendering command 904 instructs to perform shadow rendering based on the keyword Shadow. The interception module can send the rendering command 904 to the processing module (such as executing S1534). Correspondingly, the processing module can directly send the frame buffer ID of the frame buffer 94 to the game application (such as executing S1535), so that the game application can directly obtain the shadow rendering result in the frame buffer 94.
[0204] In other embodiments of the present application, the electronic device may also perform shadow rendering of SubPass-Shadow after performing normal rendering of SubPass-G according to the rendering command issued by the game application. Fig.14 The specific implementation process will not be described in detail.
[0205] The above mainly introduces the scheme provided by the embodiment of the present application from the perspective of each service module. In order to realize the above functions, it includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application. It should be noted that the division of modules in the embodiment of the present application is schematic, which is only a logical function division, and there may be other division methods in actual implementation.
[0206] Fig.16 FIG. 1 is a schematic diagram showing the composition of an electronic device 1600. Fig.16 As shown, the electronic device 1600 may include: a processor 1601 and a memory 1602. The memory 1602 is used to store computer-executable instructions. Exemplarily, in some embodiments, when the processor 1601 executes the instructions stored in the memory 1602, the electronic device 1600 may execute any of the image rendering methods shown in the above embodiments.
[0207] It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module and will not be repeated here.
[0208] Fig.17 A schematic diagram of the composition of a chip system 1700 is shown. The chip system 1700 may include: a processor 1701 and a communication interface 1702, which are used to support related devices to implement the functions involved in the above embodiments. In a possible design, the chip system also includes a memory for storing program instructions and data necessary for the terminal. The chip system may be composed of chips, or may include chips and other discrete devices. It should be noted that in some implementations of the present application, the communication interface 1702 may also be referred to as an interface circuit.
[0209] It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module and will not be repeated here.
[0210] The functions or actions or operations or steps in the above embodiments can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using a software program, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or may include one or more servers, data centers and other data storage devices that can be integrated with the medium. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (eg, a solid state disk (SSD)).
[0211] Although the present application has been described in conjunction with specific features and embodiments thereof, it is obvious that various modifications and combinations may be made thereto without departing from the spirit and scope of the present application. Accordingly, this specification and the drawings are merely exemplary illustrations of the present application as defined by the appended claims, and are deemed to have covered any and all modifications, variations, combinations or equivalents within the scope of the present application. Obviously, those skilled in the art may make various modifications and variations to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. An image rendering method, characterized in that: The method is applied to an electronic device, wherein a first application is running in the electronic device, and the first application instructs the electronic device to perform rendering processing on a first frame image by issuing a rendering instruction stream, wherein the first frame image includes a shadow area; The rendering instruction stream includes a first rendering instruction and a second rendering instruction, and the method includes: Obtaining a depth rendering result of the first frame image by rendering according to the first rendering instruction; storing the depth rendering result in a memory of the electronic device; According to the second rendering instruction, a sixth rendering instruction is issued to the graphics processing module, wherein the sixth rendering instruction is used to instruct the graphics processing module to perform a normal rendering operation on the first frame image on the first SubPass, and the graphics processing module executes the sixth rendering instruction on the first SubPass to obtain a normal rendering result; the normal rendering result is stored in an on-chip storage area of the graphics processing module of the electronic device; A shadow rendering result matching the shadow area is obtained according to the depth rendering result and the normal rendering result.
2. The method according to claim 1, characterized in that The rendering instruction stream further includes a third rendering instruction, wherein the third rendering instruction is used to instruct the electronic device to create a first frame buffer in the memory; The first frame buffer is used to store the depth rendering result; Before obtaining a depth rendering result of the first frame image by rendering according to the first rendering instruction, the method further includes: Creating a first frame buffer in the memory according to the third rendering instruction; The depth rendering result is stored in the memory of the electronic device, including: The depth rendering result is stored in the first frame buffer.
3. The method according to claim 1 or 2, characterized in that: The rendering instruction stream further includes a fourth rendering instruction, wherein the fourth rendering instruction is used to instruct the electronic device to create a second frame buffer; The second frame buffer is used to store the normal rendering result; Before obtaining the normal rendering result of the first frame image by rendering according to the second rendering instruction, the method further includes: creating the second frame buffer in an on-chip storage area of the graphics processing module according to the fourth rendering instruction; The normal rendering result is stored in an on-chip storage area of a graphics processing module of the electronic device, including: The normal rendering result is stored in the second frame buffer.
4. The method according to claim 1 or 2, characterized in that: The rendering instruction stream further includes a fifth rendering instruction, wherein the fifth rendering instruction is used to instruct the electronic device to perform a rendering operation on the shadow information; The shadow information corresponds to the shadow rendering result; The obtaining of the shadow rendering result according to the depth rendering result and the normal rendering result includes: In response to the fifth rendering instruction, read the depth rendering result from the memory, and obtain the normal rendering result from an on-chip storage area of the graphics processing module; According to a preset ray tracing algorithm, the shadow rendering result is obtained.
5. The method according to claim 1 or 2, characterized in that: The obtaining of the shadow rendering result according to the depth rendering result and the normal rendering result includes: When the normal rendering operation is completed, triggering and instructing the graphics processing module to perform a shadow rendering operation; The shadow rendering operation includes: reading the depth rendering result from the memory, obtaining the normal rendering result from the on-chip storage area of the graphics processing module; and processing and obtaining the shadow rendering result according to a preset ray tracing algorithm.
6. The method according to claim 5, characterized in that Before the trigger instructs the graphics processing module to perform a shadow rendering operation, the method further includes: When the normal rendering operation is completed, generating a first message, wherein the first message is used to indicate that the normal rendering operation is completed; The trigger instructs the graphics processing module to perform a shadow rendering operation, including: When the first message is generated, the trigger instructs the graphics processing module to perform a shadow rendering operation.
7. The method according to claim 1, characterized in that The obtaining of the shadow rendering result according to the depth rendering result and the normal rendering result includes: Creating a second SubPass in an on-chip cache of the graphics processing module, the second SubPass being used to perform a shadow rendering operation; Obtaining a rendering result of the first SubPass and inputting it into the second SubPass, wherein the rendering result of the first SubPass includes the normal rendering result; Read the depth rendering result from the memory and input it into the second SubPass, The normal rendering result and the depth rendering result are processed according to a preset ray tracing algorithm to obtain the shadow rendering result.
8. The method according to claim 1 or 2 or 6 or 7, characterized in that: The shadow rendering result includes: first normal information, second normal information, shadow information, and distance information.
9. The method according to claim 8, characterized in that After obtaining the shadow rendering result, the method further includes: The shadow rendering result is output to a third frame buffer on the memory, wherein the third frame buffer includes a texture in a first format, and the texture in the first format includes at least four channels.
10. The method according to claim 9, characterized in that Outputting the shadow rendering result to the third frame buffer on the memory includes: The first normal information, the second normal information, the shadow information, and the distance information are respectively output to different channels of the map in the first format.
11. The method according to claim 9 or 10, characterized in that: The first format is RGBA16F.
12. The method according to claim 1 or 2 or 6 or 7 or 9 or 10, characterized in that: The graphics processing module is a graphics processor GPU.
13. An electronic device, characterized in that: The electronic device comprises one or more processors and one or more memories; the one or more memories are coupled to the one or more processors, and the one or more memories store computer instructions; When the one or more processors execute the computer instructions, the electronic device executes the image rendering method according to any one of claims 1 to 12.
14. A computer-readable storage medium, characterized in that: The method comprises computer instructions, which, when executed on an electronic device, enable the electronic device to execute the image rendering method according to any one of claims 1 to 12.
15. A chip system, characterized in that: The chip system includes an interface circuit and a processor; the interface circuit and the processor are interconnected via lines; the interface circuit is used to receive signals from a memory and send signals to the processor, the signals including computer instructions stored in the memory; when the processor executes the computer instructions, the chip system executes the image rendering method as described in any one of claims 1-12.
