Graphics processor and graph drawing method
By introducing the culling module and the overdraw culling module into the graphics processor, the overdrawing problem of the graphics processor in the two-dimensional user interface is solved, the load of the shader processor is reduced, the performance is improved, and the power consumption is reduced.
Patent Information
- Application Number
- CN202310231313.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-27
- Publication Date
- 2024-08-27
AI Technical Summary
Existing graphics processors have overdrawing problems when performing drawing tasks, especially the lack of depth information and the inability to perform culling algorithms in 2D user interfaces, resulting in a high workload on the shader processor.
A graphics processor is designed, which includes a culling module and a shading processor. It determines the sub-regions involved in the overdraw culling operation through register storage indication information, and performs the overdraw culling operation in the overdraw culling module outside the shading processor. Includes depth testing and template testing modules to reduce unnecessary fragment processing.
It effectively reduces over-drawing, reduces the load on the shader processor, improves the performance of the graphics processor and reduces power consumption. It is suitable for various drawing scenarios, including two-dimensional scenes without depth information.
Smart Images

Figure CN118552631A
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of chip technology, and in particular to a graphics processor and a graphics drawing method. Background Art
[0002] At present, the three-dimensional scene processed by the graphics processing unit (GPU) is composed of multiple objects, each of which is composed of multiple basic primitives (such as triangles, lines, and points). When processing drawing tasks, objects are sent to the graphics processor in the order specified by the application, that is, the basic primitives of each object are sent to the graphics processor in the order in the object, and the graphics processor performs a series of processing to obtain the final pixel color. Among them, the fragment shader usually performs the most workload. In order to reduce the workload of the fragment shader, the graphics processor will perform a variety of algorithm processing, such as using the depth information of the object for depth culling to reduce the number of fragment shader tasks.
[0003] As the application scenarios of graphics processors continue to expand, in addition to 3D applications, 2D user interface (UI) applications also use graphics processors for drawing. In 2D user interface drawing, there may be no depth information, and the culling algorithm cannot be executed for scenes with special operations. As a result, the graphics processor still has the problem of overdrawing, resulting in a high workload for the shader processor. Summary of the invention
[0004] The embodiments of the present application provide a graphics processor and a graphics drawing method, which solve the problem of over-drawing when the existing graphics processor performs a drawing task.
[0005] In order to achieve the above-mentioned purpose, the embodiment of the present application adopts the following technical solution.
[0006] In the first aspect, an embodiment of the present application provides a graphics processor, which includes a culling module and a shading processor, the culling module includes a register and an over-drawing culling module, the output end of the over-drawing culling module is coupled to the input end of the shading processor; the register is used to store indication information, the indication information is used to indicate the sub-area in the graphics area of the drawing task that participates in the over-drawing culling operation; the over-drawing culling module is used to record the position information of multiple fragments of the drawing task in the graphics area and the sequence information when participating in the drawing, and based on the position information and sequence information, the over-drawing culling operation is performed on the fragments in the sub-area, and the fragments that need to be drawn among the multiple fragments are sent to the shading processor; the shading processor is used to perform shading processing on the fragments that need to be drawn among the multiple fragments. Among them, the sub-area participating in the over-drawing culling operation can be an area for performing a blending operation, a template comparison operation, and an instruction discarding operation.
[0007] Compared with the prior art, for the scene with blending operation, template comparison operation and instruction discarding operation, the problem that the shading processor in the graphics processor cannot execute the culling algorithm, the graphics processor in the embodiment of the present application first determines the sub-area involved in the over-drawing culling operation through the indication information stored in the register, and then before the shading processor performs shading processing on the fragment, the over-drawing culling module outside the shading processor performs the over-drawing culling operation on the sub-area involved in the over-drawing culling operation, even if there are fragments in the two-dimensional scene without depth information in the sub-area involved in the over-drawing culling operation, the over-drawing culling operation can also be performed on the fragments in the two-dimensional scene without depth information. In this way, not only can the problem that the shading processor cannot execute the culling algorithm for the scene with blending operation, template comparison operation and instruction discarding operation be avoided, but also the fragments that need to be drawn can be sent to the shading processor on the basis of culling the fragments that do not need to be drawn in the sub-area, which can effectively reduce the over-drawing situation, reduce the load of the shading processor, improve the performance of the graphics processor, and reduce power consumption.
[0008] In a possible design, the over-drawing culling operation is to cull fragments having the same position information and a previous order among multiple fragments.
[0009] In this design, when the position information is the same, the fragments in the later order can cover the fragments in the earlier order, and the fragments in the earlier order will be eliminated, which can reduce the instruction overhead of the fragments and achieve the purpose of reducing over-drawing.
[0010] In a possible design, the overdrawing culling module is further configured to send fragments outside the sub-region to the shading processor based on the position information and the order information.
[0011] In this design, for fragments outside the sub-area, the over-drawing culling module does not process the fragments, but only passes the fragments to the shading processor, thereby reducing the processing process of the fragments and improving the efficiency of the graphics processor.
[0012] In a possible design, the indication information includes an area range of the sub-area and a first identifier, and the first identifier is used to indicate that the area range inside the sub-area is an area range participating in the over-drawing culling operation.
[0013] In this design, the area range of the sub-area can be a closed curve described by a mathematical formula, or can be specified by an input image or texture. Through the first identifier, the area range participating in the over-drawing culling operation can be flexibly set, which is applicable to a variety of drawing scenarios.
[0014] In a possible design, the indication information includes an area range of the sub-area and a second identifier, and the second identifier is used to indicate that the area outside the area range of the sub-area is an area range participating in the over-drawing culling operation.
[0015] In this design, the area range of the sub-area can be a closed curve described by a mathematical formula, or can be specified by an input image or texture. Through the second identifier, the area range participating in the over-drawing culling operation can be flexibly set, which is applicable to a variety of drawing scenarios.
[0016] In a possible design, the culling module further includes a template testing module; the template testing module is used to receive a plurality of fragments, and determine whether to cull the fragments based on a comparison result between the template values of the plurality of fragments and the template reference value.
[0017] In this design, the template test module can perform preliminary culling processing on the fragments, culling the fragments that do not need to be drawn, effectively reducing over-drawing, reducing the load of the shading processor, improving the performance of the graphics processor, and reducing power consumption.
[0018] In one possible design, the culling module also includes a depth testing module, and the multiple fragments include a depth fragment; the depth testing module is used to determine whether to cull the fragment based on a comparison result between a depth value of the depth fragment among the multiple fragments and a value of the depth buffer.
[0019] In this design, the depth test module can perform preliminary culling processing on the fragments, culling the fragments that do not need to be drawn, effectively reducing over-drawing, reducing the load on the shading processor, improving the performance of the graphics processor, and reducing power consumption.
[0020] In a second aspect, an embodiment of the present application provides a graphics drawing method, which is applied to a graphics processor, the graphics processor including a culling module and a shading processor, the culling module including a register and an over-drawing culling module, the output end of the over-drawing culling module and the input end of the shading processor being coupled, the method including: storing indication information, the indication information being used to indicate a sub-area in a graphics area of a drawing task that participates in an over-drawing culling operation; recording position information of multiple fragments of the drawing task in the graphics area and sequence information when participating in the drawing, and performing an over-drawing culling operation on the fragments in the sub-area based on the position information and sequence information, and sending the fragments that need to be drawn among the multiple fragments to the shading processor; and performing shading processing on the fragments that need to be drawn among the multiple fragments.
[0021] For the beneficial effects of the second aspect, please refer to the beneficial effects of the first aspect.
[0022] In a possible design, the over-drawing culling operation is to cull fragments having the same position information and a previous order among multiple fragments.
[0023] In a possible design, before shading the fragments to be drawn among the multiple fragments, the method further includes: sending the fragments outside the sub-region to the shading processor based on the position information and the sequence information.
[0024] In a possible design, the indication information includes an area range of the sub-area and a first identifier, and the first identifier is used to indicate that the area range inside the sub-area is an area range participating in the over-drawing culling operation.
[0025] In a possible design, the indication information includes an area range of the sub-area and a second identifier, and the second identifier is used to indicate that the area outside the area range of the sub-area is an area range participating in the over-drawing culling operation.
[0026] In one possible design, the culling module also includes a template testing module, which records the position information of multiple fragments of the drawing task in the graphics area and the order information when participating in the drawing. The method also includes: receiving multiple fragments, and determining whether to cull the fragments based on the comparison results of the template values of the multiple fragments with the template reference values.
[0027] In one possible design, the culling module also includes a depth testing module, the multiple fragments include depth fragments, and the method also includes: determining whether to cull the fragment based on a comparison result between a depth value of the depth fragment among the multiple fragments and a value of the depth buffer.
[0028] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, including computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the graphics drawing method in any of the above aspects and any possible implementation methods.
[0029] In a fourth aspect, an embodiment of the present application provides a computer program product, which, when executed on a computer or a processor, enables the computer or the processor to execute the graphics drawing method in any of the above aspects and any possible implementation methods.
[0030] In a fifth aspect, an embodiment of the present application provides a chip system, which may include a wireless access device in any possible implementation of any of the above aspects and at least one electronic device. The electronic device and the wireless access device may execute the graphics drawing method in any of the above aspects and any possible implementation.
[0031] It can be understood that any of the graphics processors, chip systems, computer-readable storage media or computer program products provided above can be applied to the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods and will not be repeated here.
[0032] These and other aspects of the present application will become more apparent from the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 A schematic diagram of the structure of an execution device provided in an embodiment of the present application;
[0034] Figure 2 An internal architecture diagram of an execution device provided in an embodiment of the present application;
[0035] Figure 3 An internal architecture diagram of a graphics processor provided in an embodiment of the present application;
[0036] Figure 4 A schematic diagram of the structure of a graphics processor provided in an embodiment of the present application;
[0037] Figure 5 A schematic diagram of the area range of a sub-area provided in an embodiment of the present application;
[0038] Figure 6 A schematic diagram of the area range of another sub-area provided in an embodiment of the present application;
[0039] Figure 7 A schematic diagram of the structure of a rejection module provided in an embodiment of the present application;
[0040] Figure 8 A processing flow chart of a graphics processor provided in an embodiment of the present application;
[0041] Fig. 9 A flowchart of a graphics drawing method provided in an embodiment of the present application;
[0042] Fig.10 A flowchart of another graphics drawing method provided in an embodiment of the present application;
[0043] Fig.11 A processing flow chart of a graphics processor provided in an embodiment of the present application. DETAILED DESCRIPTION
[0044] For ease of understanding, some examples of concepts related to the embodiments of the present application are provided for reference, as shown below:
[0045] Graphics processing unit (GPU), also known as display core, visual processor and display chip, is a microprocessor that specializes in image computing on personal computers, workstations, game consoles and some mobile devices (such as tablets and smartphones). The graphics processor converts and drives the display information required by the computer system and provides scanning signals to the display to control the correct display of the display.
[0046] Blending operation is an operation that generates many special paths between two original paths. Blending operation can gradually transform one shape into another, thus obtaining a three-dimensional effect.
[0047] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0048] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.
[0049] At present, in order to reduce the workload of the fragment shader, the prior art provides a Mali GPU, which can solve the over-drawing problem through the forward pixel kill (FPK) technology. Among them, in the Mali GPU, the fragments that have passed the depth test and the template test enter the first-in-first-out queue (FIFO) of a shader processor for queueing before entering the shader processor to execute instructions. Among them, after the new fragment enters the queue, the queue will check the fragment in front of the queue. If the fragment that enters the queue later overlaps with the previous fragment in screen position and can cover the previous fragment in depth or order, the new fragment will replace the previous fragment. In this way, the instruction overhead of the previous fragment is reduced, and the purpose of reducing over-drawing is achieved.
[0050] However, FPK technology has strict requirements on the application scenarios. In scenarios where operations such as blending, template comparison, and shader discard exist, FPK technology cannot be applied, otherwise the graphics processor will have functional errors.
[0051] Therefore, considering the over-drawing problem existing in the prior art, that is, the problem that culling cannot be performed when the drawn objects include special operations such as blending operations, template comparison operations and instruction discarding, the workload of the fragment shader is high.
[0052] Therefore, the embodiment of the present application improves the graphics processor and adds an over-drawing culling module. The over-drawing culling module performs over-drawing culling operations in sub-areas where special operations such as blending operations, template comparison operations, and instruction discarding exist. It also performs over-drawing culling operations on fragments without depth information, thereby reducing the load on the shading processor, improving the performance of the graphics processor, and reducing power consumption.
[0053] The graphics processor provided in the embodiment of the present application can be applied to different devices, such as Figure 1 The execution device 10 shown, Figure 1 Schematic diagram of the structure of an execution device provided in an embodiment of the present application. The execution device 10 can be a terminal, such as a server 11, a mobile terminal 12, a tablet computer 13, a laptop computer 14, an augmented reality (AR) device ( Figure 1 ), virtual reality (VR) equipment ( Figure 1 Not shown) or vehicle-mounted terminal ( Figure 1 Not shown in the figure) etc.
[0054] like Figure 2 As shown, Figure 2 The internal architecture diagram of an execution device provided in an embodiment of the present application. The execution device 10 may include a graphics processor, a central processing unit (CPU), and a memory. The memory may include a read-only memory (ROM) and a random access memory (RAM). The execution device 10 may also be configured with an input / output (I / O) interface ( Figure 2), which is used to interact with external devices for data. For example, a user can input data to the I / O interface through an external device. The input data in the embodiment of the present application may include: an image to be drawn, which may be an image collected by the execution device 10 through a data acquisition device, an image in the database of the execution device 10, an image from a client device, etc.
[0055] like Figure 3 As shown, Figure 3 A structural block diagram of a graphics processor provided in an embodiment of the present application. The graphics processor may include: a task parser and scheduler, a plurality of shading task creators ( Figure 3 In the example, task creator 0 to task creator N, where N is a positive integer), a graphics processing cluster, a bus, and a cache (eg, an L2 cache), etc.
[0056] In some embodiments, the graphics driver is in the chip corresponding to the CPU, and the CPU can send the drawing task to the GPU. The task is parsed and scheduled according to the task priority by the task parser and scheduler of the GPU. Generally, graphics includes various types of shaders, such as vertex shaders, geometry shaders, and fragment shaders. When the task is sent to the task creator through the task parser and scheduler, the task creator can be used to create the task and send the task to the graphics processing cluster. Among them, the graphics processing cluster includes M graphics processing core units, where M is a positive integer. For example, the number of graphics processing core units is 4, 8, or 16. M graphics processing core units can execute different shader program instructions in parallel.
[0057] In some embodiments, a graphics processing cluster may also include a shader unit, a texture unit, a loader store unit, and a special function unit. Conventional instructions may be executed in the graphics processing core unit. More complex texture instructions, memory load and store instructions, and special function instructions are executed by independent coprocessors (including texture units, loader store units, and special function units). A graphics processing cluster may include N texture units, loader store units, and special function units.
[0058] For example, the shader unit is used to execute the shading program, where texture-related instructions are sent to the texture unit for processing, memory loading and storage instructions are sent to the load storage unit for processing, and special functions are sent to the special function unit for processing. Conventional arithmetic instructions, jump instructions, and logical operation instructions are processed by the arithmetic and logic unit (ALU) operation unit inside the shader unit. The texture unit obtains the texel, and after filtering, sends the filtering result back to the shader unit, which continues to complete the remaining instruction operations.
[0059] In some embodiments, the GPU may include S graphics processing clusters, for example, S may be 8, 16, etc. The texture unit and the load storage unit may load or store data to the memory. When an access request to the GPU is sent to the L2 cache through the bus, if the access request does not hit in the L2 cache, the access request is sent to the memory (DDR) through the memory interface for data reading or storage. When the access request is a read request, the read result will be returned to the corresponding module of the graphics processing cluster.
[0060] The embodiment of the present application improves the graphics processor and adds an over-drawing culling module in the graphics processing cluster. Before shading the fragments, the over-drawing culling module culls the fragments that do not need to be drawn and only sends the fragments that need to be drawn to the shading processor for processing.
[0061] The graphics processor provided in the embodiment of the present application receives the drawing task of the application (application, APP) and performs calculation operations. The graphics processor and the application cooperate to complete various real-time drawing tasks, such as games and application user interfaces. Among them, the application sets the sub-area participating in the over-drawing culling operation in the graphics area of the drawing task through the application program interface (application program interface, API), that is, the area for operations such as blending operations, template comparison operations and instruction discarding operations. The application sends the indication information of the sub-area to the graphics processor through the API, and the graphics processor processes the drawing task based on the indication information. Among them, on devices such as mobile phones or tablets, the application uses the API to enable the functions of the graphics processor, which can improve performance, reduce load and power consumption, and increase battery life.
[0062] The following is an introduction to the graphics processor provided in the embodiments of the present application.
[0063] The present application embodiment provides a graphics processor 40, such as Figure 4 As shown, Figure 4A schematic diagram of the structure of a graphics processor provided in an embodiment of the present application. The graphics processor 40 includes a culling module 41 and a shading processor 42. The culling module 41 includes a register 411 and an over-drawing culling module 412. The output terminal (e.g. Figure 4 The output terminal a) in the shader processor 42 and the input terminal (eg Figure 4 b) coupling at the input terminal.
[0064] The register 411 is used to store indication information, where the indication information is used to indicate a sub-region in the graphics region of the drawing task that participates in the over-drawing culling operation.
[0065] Exemplarily, the register 411 may be an interface register, and the register 411 may be accessed by the internal circuit and the external circuit or the application program at the same time. In one example, the register 411 may temporarily store the indication information sent by the application program.
[0066] For example, the indication information is generated by the application based on the drawing task. For the display interface of common UI applications on devices such as vehicle screens, mobile phones, tablets or computers, such as the product display page or album browsing page of a shopping platform, the application calls the API to set a special operation area, that is, an area for performing operations such as mixing operations, template comparison operations and instruction discarding operations, and generates indication information to send to register 411.
[0067] In addition, the graphics area of the drawing task can be understood as an area of the display interface, for example, it can be a display subsystem of a mobile phone or a display.
[0068] Among them, the over-drawing culling module 412 is used to record the position information of multiple fragments of the drawing task in the graphics area and the order information when participating in the drawing, and perform over-drawing culling operations on the fragments in the sub-area based on the position information and order information, and send the fragments that need to be drawn among the multiple fragments to the shading processor 42.
[0069] Exemplarily, a fragment is a point in a two-dimensional image that includes color, depth information, and texture data. The multiple fragments may include fragments with depth and fragments without depth. The fragments with depth are fragments with depth information, and the fragments without depth are fragments without depth information. The depth information may be the distance of each point in space relative to the camera.
[0070] Among them, the over-drawing removal module 412 can execute two processes, namely, the fragment interrelationship generation process and the over-drawing test process. The fragment interrelationship generation process may include: the over-drawing removal module 412 records the position information of the deep fragments and the non-depth fragments in the graphics area and the order information when participating in the drawing, and compares whether the position information of the fragments in the graphics area is located in the sub-area participating in the over-drawing removal operation. The over-drawing test process may include: the over-drawing removal module 412 performs an over-drawing removal operation, removes the fragments that do not need to be drawn in the sub-area, and sends the fragments that need to be drawn to the shading processor 42, wherein the fragments that do not need to be drawn can be understood as the fragments that do not contribute to the pixel color in the final display interface. For example, the over-drawing removal module 412 can remove the fragments corresponding to the background UI elements or the intermediate invalid layers in the layer superposition process, remove the fragments that do not contribute to the final pixel color, and only send the contributing fragments to the shading processor 42 for processing. As a result, the over-drawing situation can be effectively reduced, the load of the shading processor can be reduced, the performance of the graphics processor can be improved, and the power consumption can be reduced.
[0071] The shading processor 42 is used to perform shading processing on the fragments that need to be drawn among the multiple fragments.
[0072] Exemplarily, the shading processor 42 executes the shading instruction operation to perform shading processing on the fragments to be drawn among the multiple fragments. The shading processor 42 writes the final calculation result into the frame buffer after processing operation, and finally displays the result of the frame buffer on the display interface.
[0073] Therefore, compared with the FPK technology, the culling operation is performed in the FIFO queue of the shading processor. The graphics processor 40 provided in the embodiment of the present application performs the overdrawing culling operation in the overdrawing culling module 412 before the shading processor 42. Among them, the overdrawing culling module 412 can be understood as a buffer. The overdrawing culling module 412 can process more fragments than the FIFO queue, which can effectively reduce the overdrawing situation and reduce the load of the shading processor 42.
[0074] Optionally, the over-drawing culling operation is to cull fragments having the same position information and a preceding order among multiple fragments.
[0075] For example, for background UI elements and intermediate invalid layers in the process of layer overlay, it is assumed that there are fragment 1 and fragment 2, wherein the position information of fragment 1 and fragment 2 in the graphics area is the same, the sequence information of fragment 1 is the front sequence, and the sequence information of fragment 2 is the back sequence. Therefore, fragment 2 can be understood as being able to cover fragment 1, so fragment 1 is a fragment that does not need to be drawn. Removing fragment 1 can reduce the instruction overhead of fragment 1 and achieve the purpose of reducing overdrawing.
[0076] It is understandable that only two fragments are shown in this example, but the number of superimposed layers can be two or more, and the number of fragments with the same position information can also be two or more.
[0077] Optionally, the over-drawing elimination module 412 is further configured to send the fragments outside the sub-region to the shading processor 42 based on the position information and the sequence information.
[0078] Exemplarily, the area outside the sub-region can be understood as an area in the graphics area where no special operations are performed, that is, no operations such as blending operations, template comparison operations, and instruction discard operations are performed outside the sub-region. At this time, the over-drawing removal module 412 directly sends the fragments to the shading processor 42, that is, the over-drawing removal module 412 does not process the fragments, but only transmits the fragments to the shading processor 42. In this way, the processing process of the fragments can be reduced and the efficiency of the graphics processor 40 can be improved.
[0079] Optionally, the indication information includes an area range of the sub-area and a first identifier, and the first identifier is used to indicate that the area inside the area range of the sub-area is an area range participating in the over-drawing culling operation.
[0080] like Figure 5 As shown, Figure 5 A schematic diagram of the area range of a sub-area provided in an embodiment of the present application. The area range of the sub-area can be a closed curve that can be described by a mathematical formula, such as a rectangle, triangle, circle or ellipse. In a graphics area of a drawing task, multiple sub-areas can be set at the same time.
[0081] Among them, the first identifier can indicate that the interior of the closed curve is the area range participating in the over-drawing culling operation. In one example, the first identifier can be true. In the application, the definition of the blending operation is: *SetBlendRegions(Region*regions,bool exclusive), where *regions is the area range of the sub-region, and when exclusive is the first identifier, it means that the over-drawing culling operation is effective within the area range of the sub-region. In addition, the definition of the template comparison operation is: *SetStencilRegions(Region*regions,bool exclusive). The definition of the instruction discard operation is: *SetShaderDiscardRegions(Region*regions,boolexclusive). The definition of the special operation is: *SetSpecialOpRegions(Region*regions,boolexclusive).
[0082] It is understandable that the description of the area range of the sub-area can also be specified by using the input image or texture. In this way, the area that cannot be described by the general book sequence formula can be expressed. Figure 6 As shown, Figure 6 A schematic diagram of another area range of a sub-area provided in an embodiment of the present application, wherein the pixels of the image correspond to an area on the screen, such as 1x2, 2x1, 2x2, 2x4 and 4x4, so as to more flexibly control the area range of the sub-area.
[0083] Optionally, the indication information includes an area range of the sub-area and a second identifier, and the second identifier is used to indicate that the area outside the area range of the sub-area is an area range participating in the over-drawing culling operation.
[0084] For example, the second identifier may indicate that the area outside the closed curve is the area range participating in the overdrawing culling operation. Continuing with the definition of the operation in the application as an example, when exclusive is the second identifier, it means that the overdrawing culling operation is effective outside the area range of the sub-area.
[0085] Therefore, by setting the first identifier and the second identifier, the area range of the sub-area can be flexibly set, which is applicable to various drawing scenarios.
[0086] Optionally, the elimination module 41 further includes a template testing module 413, which is used to receive a plurality of fragments and determine whether to eliminate a fragment based on a comparison result between the template values of the plurality of fragments and the template reference value.
[0087] Exemplarily, the stencil test module 413 may perform a stencil test on the fragment. The process of the stencil test is as follows: the graphics processor 40 first reads the stencil value of the screen coordinate position of the fragment in the stencil buffer, and then compares the stencil value with the stencil reference value of the fragment, wherein the comparison function may be specified by a technician, for example, when the stencil value is greater than or equal to the stencil reference value, the fragment is removed, or when the stencil value is less than or equal to the stencil reference value, the fragment is removed.
[0088] Therefore, the template test module 413 can perform preliminary culling processing on the fragments, culling the fragments that do not need to be drawn, effectively reducing over-drawing, reducing the load of the shading processor 42, improving the performance of the graphics processor 40, and reducing power consumption.
[0089] Optionally, the culling module 41 further includes a depth testing module 414, and the multiple fragments include a depth fragment. The depth testing module 414 is used to determine whether to cull the fragment based on a comparison result between a depth value of the depth fragment among the multiple fragments and a value of the depth buffer.
[0090] Exemplarily, the depth test module 414 can perform a depth test on the fragment, wherein the process of the depth test is as follows: the graphics processor 40 compares the depth value of the fragment with the depth value already in the depth buffer, wherein the comparison function can be specified by a technician, for example, discarding the fragment when the depth value is greater than or equal to the depth value in the depth buffer, or discarding the fragment when the depth value is less than or equal to the depth value in the depth buffer.
[0091] Thus, the depth test module 414 can perform preliminary culling processing on the fragments, culling the fragments that do not need to be drawn, effectively reducing overdrawing, reducing the load of the shader processor 42, improving the performance of the graphics processor 40, and reducing power consumption. Among them, for the processing of the fragments, the module test can be performed first, and then the depth test. Among them, for the fragments without depth, the depth test module 414 does not perform culling processing, and transmits the fragments without depth to the overdrawing culling module 412.
[0092] Therefore, the structural diagram of the rejection module 41 is as follows: Figure 7 As shown, the culling module 41 includes a register 411, an over-drawing culling module 412, a template test module 413 and a depth test module 414. The processing flow of the culling module 41 is as follows: the fragment first undergoes a module test by the template test module 413, then undergoes a depth test by the depth test module 414, and finally the over-drawing culling module 412 performs an over-drawing culling operation based on the culling results of the template test module 413 and the depth test module 414, culling the fragments that do not need to be drawn, and only sending the fragments that need to be drawn to the shader processor 42.
[0093] In addition, the graphics processor 40 may also include a rasterization module 43, which is used to convert vertex data of the drawing task into multiple fragments. Each element in the fragment corresponds to a pixel in the frame buffer. Rasterization is essentially a process of converting the mathematical description of an object and the color information related to the object into pixels for corresponding positions on the screen and the colors used to fill the pixels.
[0094] In general, if Figure 8 As shown, Figure 8A processing flow chart of a graphics processor provided in an embodiment of the present application. The flow chart of the graphics processor is as follows: the vertex data in the drawing task is converted into multiple fragments through the rasterization module 43, the template test module 413 and the depth test module 414 in the culling module 41 perform preliminary culling processing, the over-drawing culling module 412 integrates the culling results of the template test module 413 and the depth test module 414, records the position information of all fragments in the graphics area and the order information when participating in the drawing, culls the fragments that do not contribute to the pixel color, identifies the fragments that ultimately affect the pixel color and sends them to the shading processor 42 for shading processing.
[0095] Application Figure 4 The graphics processor shown in , the embodiment of the present application provides a graphics drawing method, such as Fig. 9 As shown, Fig. 9 A flowchart of a method for drawing a graph provided in an embodiment of the present application. The method includes the following process.
[0096] Step 901: The graphics processor stores indication information, where the indication information is used to indicate a sub-region in a graphics region of a drawing task that participates in an over-drawing culling operation.
[0097] Step 902: The graphics processor records the position information of multiple fragments of the drawing task in the graphics area and the order information when participating in the drawing, and performs the over-drawing culling operation on the fragments in the sub-area based on the position information and the order information, and sends the fragments that need to be drawn among the multiple fragments to the shading processor.
[0098] Step 903: The graphics processor performs shading processing on the fragments to be drawn among the multiple fragments.
[0099] For the problem that the shading processor in the graphics processor cannot execute the culling algorithm in the scenario with the presence of blending operations, template comparison operations and instruction discarding operations, the graphics processor in the embodiment of the present application first determines the sub-area involved in the over-drawing culling operation through the indication information stored in the register, and then before the shading processor performs shading processing on the fragments, the over-drawing culling module outside the shading processor performs the over-drawing culling operation on the sub-area involved in the over-drawing culling operation, even if there are fragments in the two-dimensional scene without depth information in the sub-area involved in the over-drawing culling operation, the over-drawing culling operation can also be performed on the fragments in the two-dimensional scene without depth information. In this way, not only can the problem that the shading processor cannot execute the culling algorithm for the scenario with the presence of blending operations, template comparison operations and instruction discarding operations be avoided, but also the fragments that need to be drawn can be sent to the shading processor on the basis of culling the fragments that do not need to be drawn in the sub-area, which can effectively reduce the over-drawing situation, reduce the load of the shading processor, improve the performance of the graphics processor, and reduce power consumption.
[0100] Optional, such as Fig.10 As shown, Fig.10 A flowchart of another method for drawing graphics provided by an embodiment of the present application. Before step 903, the method may further include:
[0101] Step 904: The graphics processor sends the fragments outside the sub-region to the shading processor based on the position information and the order information.
[0102] For example, for the fragments outside the sub-region, the over-drawing elimination module does not process the fragments, but only transmits the fragments to the shader processor, thereby reducing the processing of the fragments and improving the efficiency of the graphics processor. The implementation of step 904 can refer to the introduction of the graphics processor in the above embodiment.
[0103] Optionally, before step 902, the method may further include:
[0104] Step 905: The graphics processor receives a plurality of fragments, and determines whether to remove a fragment based on a comparison result between the template values of the plurality of fragments and the template reference value.
[0105] Exemplarily, the template test module can perform preliminary culling processing on the fragments, culling the fragments that do not need to be drawn, effectively reducing over-drawing, reducing the load of the shader processor, improving the performance of the graphics processor, and reducing power consumption. The implementation of step 905 can refer to the introduction of the graphics processor in the above embodiment.
[0106] Optionally, after step 905 and before step 902, the method may further include:
[0107] Step 906: The graphics processor determines whether to cull a fragment based on a comparison result between a depth value of a depth fragment among the plurality of fragments and a value in the depth buffer.
[0108] Exemplarily, the depth test module can perform preliminary culling processing on the fragments, culling the fragments that do not need to be drawn, effectively reducing over-drawing, reducing the load of the shader processor, improving the performance of the graphics processor, and reducing power consumption. The implementation of step 906 can refer to the introduction of the graphics processor in the above embodiment.
[0109] In general, if Fig.11 As shown, Figure 11 is a processing flow chart of a graphics processor provided in an embodiment of the present application, which includes the following process.
[0110] (a) register stores indication information;
[0111] (b) The application sends a drawing task to the graphics processor;
[0112] (c) Graphics processor processes graphics primitives;
[0113] (d) The rasterization module processes the primitives to obtain fragments;
[0114] (e) Elimination module processes fragments;
[0115] (f) The shading processor executes shading instruction operations.
[0116] An embodiment of the present application further provides a computer storage medium, in which computer instructions are stored. When the computer instructions are executed on an electronic device, the electronic device executes the above-mentioned related method steps to implement the graphics drawing method in the above-mentioned embodiment.
[0117] The embodiments of the present application also provide a computer program product. When the computer program product is run on a computer, the computer is caused to execute the above-mentioned related steps to implement the graphics drawing method executed by the electronic device in the above-mentioned embodiments.
[0118] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer execution instructions, and when the device is running, the processor can execute the computer execution instructions stored in the memory so that the chip executes the graphics drawing method executed by the electronic device in the above-mentioned method embodiments.
[0119] Among them, the graphics processor, computer storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.
[0120] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0121] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0122] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0123] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0124] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0125] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A graphics processor, characterized in that: The graphics processor comprises a culling module and a shading processor, the culling module comprises a register and an over-drawing culling module, and an output end of the over-drawing culling module is coupled to an input end of the shading processor; The register is used to store indication information, where the indication information is used to indicate a sub-area in a graphics area of a drawing task that participates in an over-drawing culling operation; The over-drawing culling module is used to record the position information of the multiple fragments of the drawing task in the graphics area and the sequence information when participating in the drawing, and perform the over-drawing culling operation on the fragments in the sub-area based on the position information and the sequence information, and send the fragments that need to be drawn among the multiple fragments to the shading processor; The shading processor is used to perform shading processing on the fragments that need to be drawn among the multiple fragments.
2. The graphics processor according to claim 1, wherein: The over-drawing elimination operation is to eliminate the fragments whose position information is the same and whose order information is the previous order among the multiple fragments.
3. The graphics processor according to claim 1 or 2, characterized in that: The over-drawing elimination module is further used to send the fragments outside the sub-area to the shading processor based on the position information and the sequence information.
4. The graphics processor according to claim 1, wherein: The indication information includes an area range of the sub-area and a first identifier, where the first identifier is used to indicate that the area inside the area range of the sub-area is an area range participating in the over-drawing culling operation.
5. The graphics processor according to claim 1, characterized in that: The indication information includes an area range of the sub-area and a second identifier, where the second identifier is used to indicate that the area outside the area range of the sub-area is an area range participating in the over-drawing culling operation.
6. The graphics processor according to claim 1, characterized in that: The rejection module also includes a template testing module; The template testing module is used to receive a plurality of fragments and determine whether to remove the fragments based on the comparison results of the template values of the plurality of fragments and the template reference value.
7. The graphics processor according to claim 6, characterized in that: The culling module further includes a depth testing module, and the plurality of fragments include depth fragments; The depth test module is used to determine whether to discard the fragment based on a comparison result between a depth value of a depth fragment among the multiple fragments and a value of a depth buffer.
8. A graphics drawing method, characterized in that: The method is applied to a graphics processor, the graphics processor includes a culling module and a shading processor, the culling module includes a register and an over-drawing culling module, the output end of the over-drawing culling module is coupled to the input end of the shading processor, and the method includes: storing indication information, where the indication information is used to indicate a sub-region in a graphics region of a drawing task that participates in an over-drawing culling operation; Recording position information of multiple fragments of the drawing task in the graphics area and sequence information of the fragments when participating in the drawing, and performing the over-drawing culling operation on the fragments in the sub-area based on the position information and the sequence information, and sending the fragments that need to be drawn among the multiple fragments to the shading processor; The fragments that need to be drawn among the multiple fragments are shaded.
9. The method according to claim 8, characterized in that The over-drawing elimination operation is to eliminate the fragments whose position information is the same and whose order information is the previous order among the multiple fragments.
10. The method according to claim 8 or 9, characterized in that: Before the shading process is performed on the fragments to be drawn among the multiple fragments, the method further includes: The fragments outside the sub-region are sent to the shading processor based on the position information and the order information.
11. The method according to claim 8, characterized in that The indication information includes an area range of the sub-area and a first identifier, where the first identifier is used to indicate that the area inside the area range of the sub-area is an area range participating in the over-drawing culling operation.
12. The method according to claim 8, characterized in that The indication information includes an area range of the sub-area and a second identifier, where the second identifier is used to indicate that the area outside the area range of the sub-area is an area range participating in the over-drawing culling operation.
13. The method according to claim 8, characterized in that The culling module further includes a template testing module. Before recording the position information of the plurality of fragments of the drawing task in the graphics area and the sequence information of the plurality of fragments participating in the drawing, the method further includes: A plurality of fragments are received, and based on a comparison result of the template values of the plurality of fragments with a template reference value, it is determined whether to discard the fragments.
14. The method according to claim 9, characterized in that The culling module further includes a depth testing module, the plurality of fragments include depth fragments, and the method further includes: Whether to discard the fragment is determined based on a comparison result between a depth value of a depth fragment among the multiple fragments and a value of the depth buffer.
15. A computer-readable storage medium, characterized in that: The method comprises computer instructions, which, when executed on an electronic device, cause the electronic device to execute the method according to any one of claims 8 to 14.
Citation Information
Cited By
Rendering processing method and device, electronic equipment and storage medium
CN120823303A
Rendering processing method and apparatus, electronic device, storage medium
CN120823303B
Graphics processing unit and graphics drawing method
EP4660951A1
