Programmable color mixing method, device, equipment, medium and program product
By introducing a programmable color blending method into the graphics processor and utilizing unordered access to the loading instructions in the view to write back the rendered object data, the problem of increased hardware costs from advanced color blending operations is solved, resulting in reduced hardware costs and increased operational versatility.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-30
- Publication Date
- 2026-03-27
AI Technical Summary
Existing technologies for implementing advanced color blending operations in graphics processors require the addition of complex hardware processing units and control logic, leading to increased hardware design difficulty and cost.
By introducing a programmable color blending method into the graphics processor and utilizing the loading instructions in the unordered access view, the function of writing back the rendered object data is realized, reducing the number of hardware logic gates and lowering hardware costs.
It improves the diversity and scalability of color mixing operations, adapts to the new feature requirements of future graphics libraries, meets customer customization needs, and reduces hardware costs.
Smart Images

Figure CN121753073A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a programmable color mixing method, apparatus, device, medium, and program product. Background Technology
[0002] Blending is a technique that merges the currently rasterized pixel (the source pixel) with a previously rasterized pixel stored in the back buffer (the target pixel). It allows application developers to render semi-transparent objects, such as fog and glass, within a scene. The formula for a typical color blending operation is shown below:
[0003]
[0004] Where srcColor represents the color value of the source pixel; srcFactor represents the weight of the color value of the source pixel; dstColor represents the color value of the target pixel; and dstFactor represents the weight of the color value of the target pixel. This indicates the opcode, including addition, subtraction, maximum value, and minimum value.
[0005] Graphics processing units (GPUs) can perform the aforementioned conventional color blending operations through a fixed pipeline. However, some graphics APIs require hardware support for more complex blending formulas. For example, OpenGL requires support for advanced blending. These blending formulas are numerous and involve complex mathematical calculations, such as calculating square roots in the SOFTLIGHT_KHR blending mode. Implementing advanced blending operations through a fixed pipeline requires adding complex computational units and control logic to the hardware, which increases the design complexity and cost. Summary of the Invention
[0006] Therefore, it is necessary to provide a programmable color mixing method, apparatus, device, medium, and program product that can reduce hardware costs in response to the above-mentioned technical problems.
[0007] In a first aspect, this application provides a programmable color mixing method, the method comprising:
[0008] After receiving the hybrid operation start signal at the back end of the execution unit, an instruction to load the rendering object is sent to the loading storage unit;
[0009] The first register information corresponding to the rendered object is sent to the register information conversion unit through the loading storage unit;
[0010] The register information conversion unit converts the first register information into second register information of an out-of-order access attempt, and returns the second register information to the load memory unit.
[0011] The loading storage unit reads the rendering object based on the second register information and sends the read rendering object to the execution unit backend so that the execution unit backend performs a hybrid operation.
[0012] In one embodiment, the method further includes:
[0013] The thread assembly unit receives the first triangle to be assembled sent by the thread assembly unit, detects whether there is pixel overlap between the first triangle and the second triangle being assembled, and instructs the thread assembly unit to perform thread allocation based on the first detection result of pixel overlap.
[0014] The inter-thread overlap detection unit receives first thread information sent by the thread assembly unit. Based on the triangle information in the first thread information and the triangle information in the running thread, it detects whether there is pixel overlap. Based on the second detection result of pixel overlap, it decides whether to send a mixed operation start signal to the back end of the execution unit.
[0015] In one embodiment, the step of receiving the first triangle to be assembled sent by the thread assembly unit through the intra-thread overlap detection unit, detecting whether there is pixel overlap between the first triangle and the second triangle being assembled, obtaining a first detection result, and instructing the thread assembly unit to perform thread allocation based on the first detection result includes:
[0016] The first triangle to be assembled, sent by the thread assembly unit, is detected by the intra-thread overlap detection unit.
[0017] Obtain the second triangle being assembled in the thread assembly unit;
[0018] Based on the detection of whether there are overlapping pixels using the first triangle and the second triangle, the first detection result is obtained and returned to the thread assembly unit;
[0019] If the first detection result indicates that there are no overlapping pixels, the first triangle to be assembled is added to the thread being assembled by the thread assembly unit.
[0020] If the first detection result indicates the presence of overlapping pixels, a new thread is assigned to the first triangle to be assembled by the thread assembly unit.
[0021] In one embodiment, the step of receiving triangle information from a first thread sent by a thread assembly unit through an inter-thread overlap detection unit, detecting pixel overlap based on the triangle information in the first thread and the triangle information in the currently running thread, obtaining a second detection result, and determining whether to send a hybrid operation start signal to the execution unit backend based on the second detection result includes:
[0022] The inter-thread overlap detection unit receives the first thread information and the triangle information in the first thread sent by the thread assembly unit.
[0023] Based on the triangles in the first thread and the triangles in the pre-stored running threads, the system detects whether there is pixel overlap between the threads and obtains the second detection result.
[0024] If the second detection result indicates that there is no pixel overlap, a mixing operation start signal is sent to the back end of the execution unit.
[0025] If the second detection result indicates that pixel overlap exists, the process continues to execute the step of detecting whether there is pixel overlap between threads based on the triangle information in the first thread and the triangle information in the pre-stored running thread, and obtaining the second detection result, until the second detection result indicates that there is no pixel overlap, at which point a mixing operation start signal is sent to the back end of the execution unit.
[0026] In one embodiment, the method further includes:
[0027] The output merging unit receives the result of the back-end mixing operation of the execution unit and stores the result of the mixing operation in the cache unit. After the output merging unit receives the write success instruction from the cache unit, it sends a mixing end signal to the inter-thread overlap detection unit. The mixing end signal is used to instruct the inter-thread overlap detection unit to release the second triangle information of the thread corresponding to the result of the mixing operation.
[0028] In one embodiment, after sending the instruction to load the rendering object to the loading storage unit, the method further includes:
[0029] The register information of the instruction is determined based on the identifier bits of the instruction;
[0030] If the register information of the instruction is determined to be the first register information based on the identifier bit of the instruction, the execution continues to send the first register information corresponding to the rendering object to the register information conversion unit through the loading storage unit;
[0031] If the identifier bit of the instruction determines that the register information of the instruction is the second register information, the step of reading the rendering object based on the second register information through the loading storage unit continues.
[0032] Secondly, this application also provides a programmable color mixing device, the device comprising:
[0033] The execution unit backend is used to send instructions to the loading and storage unit to load the rendering object after receiving the mixed operation start signal;
[0034] A loading storage unit is used to send the first register information corresponding to the rendered object to the register information conversion unit;
[0035] The register information conversion unit is used to convert the first register information into second register information of an out-of-order access attempt, and return the second register information to the load memory unit;
[0036] The loading storage unit is also used to read the rendering object based on the second register information and send the read rendering object to the execution unit backend so that the execution unit backend performs a hybrid operation.
[0037] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method in any of the above embodiments.
[0038] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the methods in any of the above embodiments.
[0039] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the method in any of the above embodiments.
[0040] The aforementioned programmable color mixing method, apparatus, device, medium, and program product, upon receiving a mixing operation start signal at the execution unit's backend, sends an instruction to load the rendering object to the loading storage unit; the loading storage unit sends the first register information corresponding to the rendering object to the register information conversion unit; the register information conversion unit converts the first register information into second register information in an out-of-order access view, and returns the second register information to the loading storage unit; the loading storage unit reads the rendering object based on the second register information and sends the read rendering object to the execution unit's backend, enabling the execution unit's backend to perform the mixing operation. Thus, during the smoothing operation, the loading instruction in the out-of-order access view enables the write-back of the rendering object data, thereby saving the number of hardware logic gates and reducing hardware costs. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in the embodiments of this application or the conventional technology, the drawings used in the description of the embodiments or the conventional technology will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the disclosed drawings without creative effort.
[0042] Figure 1 This is a schematic diagram of the water supply pipeline in one embodiment;
[0043] Figure 2 This is a flowchart illustrating a programmable color mixing method in one embodiment;
[0044] Figure 3 This is a flowchart of the register information conversion unit in one embodiment;
[0045] Figure 4 This is a flowchart of the processing of the intra-thread overlap detection unit in one embodiment;
[0046] Figure 5 This is a flowchart of the inter-thread overlap detection unit in one embodiment;
[0047] Figure 6 This is a schematic diagram of a scene where triangles are drawn in one embodiment;
[0048] Figure 7 A flowchart of a programmable color mixing method in another embodiment;
[0049] Figure 8 This is a schematic diagram of the drawing result in one embodiment;
[0050] Figure 9This is a structural block diagram of a programmable color mixing device in one embodiment;
[0051] Figure 10 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0052] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0053] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.
[0054] The programmable color mixing method provided in this application embodiment can be applied to, for example... Figure 1 The pipeline shown is as follows. The function of the Execution Unit is to execute the instructions in the shader. It receives input values from external modules and outputs the final calculation results to the external fixed function module. The unit consists of two parts: the front end of the execution unit is responsible for vertex shading, and the back end of the execution unit is responsible for pixel shading.
[0055] The function of the rasterization unit is to rasterize triangles, that is, to determine which integer raster areas in screen coordinates are occupied by triangles.
[0056] The Warp Assembling Unit (WAU) assembles warps, and its workflow is as follows: First, it counts the number of valid quads (2x2 pixel blocks) in a triangle, denoted as QUAD_NUM. If QUAD_NUM is greater than or equal to the maximum number of quads that a single warp can hold, or if other boundary conditions are met (such as the current triangle being the last triangle in the drawing command), it sends a thread request to the execution unit backend. The execution unit backend allocates resources for this thread and returns the thread information to the Warp Assembling Unit, which then sends the triangle and thread information to the interpolation unit.
[0057] The function of the Interpolation Unit is pixel attribute interpolation. The workflow is as follows: First, it receives and parses the triangle and thread information sent by the thread assembly unit; then, it selects the interpolation method according to the interpolation mode of the input attribute of the pixel shader, and sends the interpolation result to the execution unit backend.
[0058] The workflow of the Load and Store Unit is as follows: First, it receives and parses the access requests sent by the execution unit backend; then it calculates the access address and sends read / write requests to the storage system (cache unit); for load requests, it assembles the data returned by the storage system (cache unit) and sends it to the execution unit backend.
[0059] The workflow of the Output Merger Unit is as follows: First, it receives the depth, mask, and color information output by the PS (Pixel Shader); then, it performs depth and stencil tests and updates the mask information of the pixels; finally, it performs a blending operation on the pixels with valid masks and writes the final result to the cache unit or video memory.
[0060] The function of the Cache Unit is to cache recently accessed data from the Load Storage Unit and the Output Merge Unit. Its workflow is as follows: First, it receives read / write requests from upstream modules (e.g., the Load Storage Unit or the Output Merge Unit); then, it calculates the Virtual Address (VA) based on the coordinate information in the read / write request; third, it performs a hit / miss test; if the hit / miss test result is a miss, a cache line needs to be allocated and the corresponding tag information updated; for read requests, the cache unit needs to read the corresponding data from memory, write it to the cache line, and return it to the upstream module; for write requests, it needs to write the data to the cache line and update the dirty byte mask. If the hit / miss test result is a hit, for read requests, data is read from the cache line and returned to the upstream module; for write requests, data is directly written to the cache line and the dirty byte mask is updated.
[0061] Secondly, in order to support programmable blending operations in the GPU and implement programmable color blending operations in the graphics pipeline, this application mainly adds three modules and corresponding interfaces compared to the conventional graphics pipeline:
[0062] The overlap detection unit within the Warp is used to detect whether there is an overlap between the input triangle and the thread being assembled during the hardware thread (Warp) assembly process. The purpose is to ensure that there are no identical pixels between different channels within the Warp.
[0063] The Warp overlap detection unit detects whether there are overlapping pixels between a Warp waiting to be started and a Warp that is currently running. The purpose is to adjust the execution order of the Warps to be consistent with the primitive submission order. It also needs to send a mixing operation start signal to the back end of the execution unit and receive a mixing end signal sent by the output merging unit.
[0064] The register layout conversion unit converts the RT register layout to the UAV register layout, with the aim of making the load memory unit transparent to the RT load instruction.
[0065] In addition to the three new hardware modules mentioned above, this application also extends the loading instructions in the ISA (Instruction Set Architecture) by adding a bit to the loading instructions to indicate whether the currently loaded object is an RT. If the bit is 1, it indicates that the loaded object is an RT; otherwise, the loaded object is a UAV.
[0066] In one exemplary embodiment, such as Figure 2 As shown, a programmable color mixing method is provided, which can be applied to... Figure 1 Taking the water supply pipeline as an example, the explanation includes the following steps S202 to S208. Wherein:
[0067] S202: After receiving the mixed operation start signal at the back end of the execution unit, send an instruction to load the rendering object to the loading storage unit.
[0068] The blending operation start signal is sent from the inter-thread overlap detection unit to the back end of the execution unit. The inter-thread overlap detection unit can send the blending operation start signal to the inter-thread overlap detection unit when it detects that there are no overlapping pixels between the input thread and the running thread.
[0069] After receiving the mixed operation start signal, the execution unit backend sends an instruction to the loading storage unit to load the rendering object.
[0070] The instruction for loading the rendered object includes a bit indicating whether the currently loaded object is a RT. If the bit is 1, it indicates that the loaded object is a RT (first register information); otherwise, the loaded object is a UAV (the loading instruction corresponding to the second register information, utilizing the Unordered Access View).
[0071] S204: The first register information corresponding to the rendered object is sent to the register information conversion unit by loading the storage unit.
[0072] S206: The first register information is converted into the second register information of the out-of-order access attempt through the register information conversion unit, and the second register information is returned to the load memory unit.
[0073] Among them, combined Figure 3 As shown, Figure 3 This is a flowchart of the register information conversion unit in one embodiment. In this embodiment, the register layout conversion unit performs register layout conversion. It receives the RT register (first register) from the load storage unit, and then extracts the RT information (first register information) stored therein according to the layout of the RT register, such as data format, resource type, and resource size. Then, according to the layout of the UAV register, it fills the extracted RT information (first register information) into the corresponding positions in the UAV register (second register). For positions in the UAV register that are not filled, default values will be filled according to the specific hardware implementation. After filling, the converted UAV register (second register information) will be sent to the load storage unit.
[0074] S208: The rendering object is read from the loading storage unit based on the information in the second register, and the read rendering object is sent to the execution unit backend so that the execution unit backend can perform the mixed operation.
[0075] The subsequent loading storage unit reads the rendering object based on the information in the second register and sends the read rendering object to the execution unit backend, so that the execution unit backend performs the blending operation to complete the blending process.
[0076] The aforementioned programmable color blending method, apparatus, device, medium, and program product, upon receiving a blending operation start signal at the execution unit's backend, sends an instruction to load the rendering object to the loading storage unit; the loading storage unit sends the first register information corresponding to the rendering object to the register information conversion unit; the register information conversion unit converts the first register information into second register information in an out-of-order access view and returns the second register information to the loading storage unit; the loading storage unit reads the rendering object based on the second register information and sends the read rendering object to the execution unit's backend, enabling the execution unit's backend to perform the blending operation. Thus, during the blending operation, the loading instruction in the out-of-order access view enables the write-back of the rendering object data, thereby saving the number of hardware logic gates and reducing hardware costs.
[0077] In some optional embodiments, the method further includes: receiving a first triangle to be assembled sent by a thread assembly unit through an intra-thread overlap detection unit, detecting whether there is pixel overlap between the first triangle and the second triangle being assembled, obtaining a first detection result, and instructing the thread assembly unit to perform thread allocation based on the first detection result; receiving triangle information in a first thread sent by a thread assembly unit through an inter-thread overlap detection unit, detecting whether there is pixel overlap based on the triangle information in the first thread and the triangle information in the running thread, obtaining a second detection result, and deciding whether to send a hybrid operation start signal to the execution unit backend based on the second detection result.
[0078] The intra-thread overlap detection unit receives the first triangle information from the thread assembly unit, then performs overlap detection with the second triangle in the currently assembling warp, and returns the detection result to the thread assembly unit. If the detection result is an overlap, the thread assembly unit directly starts the currently assembling thread; otherwise, it continues assembling the thread. The mixing operation start signal is generated by the inter-thread overlap detection unit. This unit receives the first triangle information and thread information sent by the thread assembly unit, sends a read request to the triangle information memory, and then performs a hit test between the triangles in the input warp and the triangles in the running thread. If the test result is a miss, the triangle in the current thread is written to memory, and a thread mixing start signal is sent to the execution unit; otherwise, it needs to wait for the next test.
[0079] In some optional embodiments, the thread assembly unit receives the first triangle to be assembled sent by the thread assembly unit, detects whether there is pixel overlap between the first triangle and the second triangle being assembled, obtains a first detection result, and instructs the thread assembly unit to perform thread allocation based on the first detection result. This includes: detecting the first triangle to be assembled sent by the thread assembly unit through the thread overlap detection unit; obtaining the second triangle being assembled in the thread assembly unit; detecting whether there are overlapping pixels between the first triangle and the second triangle, obtaining a first detection result, and returning the first detection result to the thread assembly unit; if the first detection result indicates that there are no overlapping pixels, adding the first triangle to be assembled to the thread being assembled through the thread assembly unit; and if the first detection result indicates that there are overlapping pixels, allocating a new thread for the first triangle to be assembled through the thread assembly unit.
[0080] Combination Figure 4 As shown, Figure 4This is a flowchart of the processing of the In-Thread Overlap Detection Unit in one embodiment. The function of the Overlap Check Unit Inner the Warp is to detect whether the input triangle (first triangle) and other triangles (second triangles) in the Warp overlap in screen space during the Warp assembly process.
[0081] Among them, the combination Figure 4 The in-thread overlap detection unit includes a triangle traversal unit, a triangle overlap detector, and an overlap detection unit. This unit receives triangle information from the thread assembly unit, performs overlap detection with the triangles in the currently being assembled warp, and returns the detection result to the thread assembly unit. If the detection result indicates overlap, the thread assembly unit directly starts the currently assembling thread; otherwise, it continues assembling the thread. The functions of each submodule in this in-thread overlap detection unit are as follows:
[0082] The function of the triangle traversal unit is to receive the input triangle (first triangle) sent by the thread assembly unit and send a read request to the thread assembly unit. The purpose is to traverse and read the triangle information (second triangle) in the thread being assembled.
[0083] The function of the triangle overlap detector is to receive the input triangle (the first triangle) and the triangle information in the current thread (the second triangle returned based on the read request sent by the triangle traversal unit), and determine whether there are overlapping pixels between the triangles by using the triangle coordinates and coverage information, and then return the detection result to the thread assembly unit.
[0084] In some optional embodiments, the inter-thread overlap detection unit receives triangle information from the first thread sent by the thread assembly unit, detects whether pixel overlap exists based on the triangle information in the first thread and the triangle information in the running thread, obtains a second detection result, and determines whether to send a blending operation start signal to the execution unit backend based on the second detection result. This includes: receiving first thread information and triangle information from the first thread sent by the thread assembly unit; detecting whether pixel overlap exists between threads based on the triangle information in the first thread and the pre-stored triangle information in the running thread, obtaining a second detection result; if the second detection result indicates no pixel overlap, sending a blending operation start signal to the execution unit backend; if the second detection result indicates pixel overlap, continuing to detect whether pixel overlap exists between threads based on the triangle information in the first thread and the pre-stored triangle information in the running thread, obtaining a second detection result, until the second detection result indicates no pixel overlap, at which point a blending operation start signal is sent to the execution unit backend.
[0085] Combination Figure 5 As shown, Figure 5 This is a flowchart of the processing of the inter-thread overlap detection unit in one embodiment. The main function of the inter-thread overlap detection unit is to detect whether there are overlapping pixels between the input thread and the running thread. If there is no overlap, it sends a mixing start signal to the back end of the executable unit and receives a mixing end signal from the output merging unit.
[0086] Among them, the combination Figure 5 The thread overlap detection unit includes a thread traversal unit, a thread name testing unit, a thread triangle memory, and a hit determination unit.
[0087] The inter-thread overlap detection unit receives triangles and thread information from the thread assembly unit, sends a read request to the triangle information memory, and then performs a match test between the triangles in the input warp and the triangles in the running threads. If the test result is a match, the triangle in the current thread is written to the memory, and a thread mixing start signal is sent to the execution unit; otherwise, it waits for the next test. If a mixing end signal is received, the triangle of the specific thread is released from the thread triangle memory. The functions of each submodule of this inter-thread overlap detection unit are as follows:
[0088] The function of the thread traversal unit is to receive the triangle information sent by the thread assembly unit and send a read request to the triangle information memory to obtain the triangle information contained in the currently running thread.
[0089] The function of the thread triangle memory is to store the triangle information contained in the running thread and to handle read and write requests from external modules; in addition, for release requests sent by external modules, the module will release the triangle contained in the thread according to the thread ID.
[0090] The function of the thread hit test unit is to perform a hit test between the triangle in the input thread and the triangle in the running thread. The markers used in the test process are the coordinates and coverage information of the triangle. If the result is a hit, the next test needs to be performed. Otherwise, the module will send a mixed operation start signal to the execution unit and write the triangle information in the input thread into the triangle information memory.
[0091] In some optional embodiments, the method further includes: receiving the result of the backend mixing operation of the execution unit through the output merging unit, storing the result of the mixing operation in the cache unit, and after the output merging unit receives the write success instruction from the cache unit, sending a mixing end signal to the inter-thread overlap detection unit, the mixing end signal being used to instruct the inter-thread overlap detection unit to release the second triangle information of the thread corresponding to the result of the mixing operation.
[0092] The output merging unit stores the result of the merging operation in the cache unit; and after receiving the write-done instruction signal sent by the cache unit, it sends a merging end signal to the inter-thread overlap detection unit; upon receiving the merging end signal, the inter-thread overlap detection unit releases the triangle in the thread from the thread triangle memory, that is, the inter-thread overlap detection unit releases the second triangle information of the thread corresponding to the result of the merging operation.
[0093] In some optional embodiments, after sending the instruction to load the rendering object to the loading storage unit, the method further includes: determining the register information of the instruction based on the identifier bit of the instruction; if the register information of the instruction is determined to be first register information based on the identifier bit of the instruction, continuing to execute the step of sending the first register information corresponding to the rendering object to the register information conversion unit through the loading storage unit; if the register information of the instruction is determined to be second register information based on the identifier bit of the instruction, continuing to execute the step of reading the rendering object based on the second register information through the loading storage unit.
[0094] The ASM form of a regular load instruction is defined as follows:
[0095] load_uav_typed dst0[.mask],srcAddress[.swizzle],srcUAV[.swizzle]
[0096] In this embodiment, the loading instruction has been extended by adding a bit to the instruction to indicate whether the object being loaded is an RT. If the bit is 0, it means that a UAV is being loaded; otherwise, it means that an RT is being loaded. The extended ASM instruction is defined as follows: load_uav_typed[.rt]dst0[.mask],srcAddress[.swizzle],srcUAV[.swizzle].
[0097] srcUAV represents u# declared in the shader; swizzle represents any combination of x / y / z / w channels; srcAddress represents the register address storing the access address; dst0 represents the register address where the loaded data is written; mask represents x / xy / xyz / xyzw; if the instruction contains .rt, it means that the currently loaded data is RT data, and srcUAV represents the index of RT.
[0098] Table 1 compares the differences between PS programs that support programmable blending operations and those that do not. PS programs that support programmable blending operations have six more instructions. The first instruction obtains the data of RT in memory through the RT load instruction, and the remaining five instructions perform blending operations on the input color data and the color data in memory.
[0099]
[0100] Combination Figure 6 As shown, Figure 6 This is a schematic diagram of a triangle drawing scene in one embodiment. The color format of the rendering object is RGBA8_UNORM, and the initial color value of the rendering object is (0, 0, 0, 255). Three triangles are drawn in sequence, where the color of triangle 1 is (255, 0, 0, 255), the color of triangle 2 is (0, 0, 255, 255), and the color of triangle 3 is (0, 255, 0, 128). Triangles 1 and 3 have overlapping pixels in screen space.
[0101] Assuming the rendered object is 8x8 in size, the tile is also 8x8 in size, and the color blending formula is as follows:
[0102] dst_color=src_color*src_alpha+dst_color*(1–src_alpha)
[0103] For ease of description, triangle 1, triangle 2, and triangle 3 will be named T0, T1, and T2 respectively. Figure 7 As shown, Figure 7This is a flowchart of a programmable color mixing method in another embodiment, which mainly includes:
[0104] (1) The rasterization unit rasterizes T0, T1, and T2 and sends the triangle coverage information to the thread assembly unit in sequence.
[0105] (2) T0, T1, and T2 enter the thread assembly unit respectively, and the thread assembly unit sends the T0, T1, and T2 information to the thread overlap detection unit in turn.
[0106] (3) The thread overlap detection unit receives T0 and then reads the triangles in the thread being assembled from the thread assembly unit. The number of triangles returned by the thread assembly unit is 0. Therefore, T0 passes the triangle overlap detection and sends the detection result to the thread assembly unit. The thread assembly unit adds T0 to the thread queue being assembled.
[0107] (4) When the thread overlap detection unit receives T1, it repeats step (3). The test results show that T0 and T1 do not overlap. The thread assembly unit adds T1 to the thread queue that is being assembled.
[0108] (5) When the thread overlap detection unit receives T2, it repeats step (3). The test results show that T2 and T0 overlap. The thread assembly unit will assemble T0 and T1 into a new thread, denoted as Warp0. It will assemble T2 into another thread, denoted as Warp1. It will send a request to the backend of the execution unit to request a thread. The thread assembly unit will send the triangle information and Warp ID in Warp0 and Warp1 to the thread overlap detection unit.
[0109] (6) The thread overlap detection unit will perform a hit test on Warp0. The number of threads in the current thread triangle memory is 0. Therefore, the test result is a miss. The thread overlap detection unit sends a Warp0 mixing start signal to the back end of the execution unit.
[0110] (7) The thread overlap detection unit performs a hit test on Warp1 and finds that Warp1 hits Warp0. Therefore, Warp1 needs to continue testing until the test result is a miss.
[0111] (8) The execution unit backend, i.e. the pixel shader PS, sends the LoadRt instruction to the load storage unit; the load storage unit sends the RT register to the register conversion unit.
[0112] (9) The register layout conversion unit converts the RT register into a UAV register and returns it to the load memory unit.
[0113] (10) The load memory unit receives the UAV register after the transfer sent by the register conversion unit, then calculates the corresponding VA address in combination with the access address in the LoadRt instruction, and sends a read request to the cache unit.
[0114] (11) The cache unit returns the initial color (0,0,0,255) of RT to the load storage unit, and the color of the load storage unit is returned to the pixel shader PS.
[0115] (12) After receiving the data sent by the loading storage unit, the pixel shader PS starts to perform the blending operation and sends the blending results of triangles T0 and T1 (255, 0, 0, 255) and (0, 255, 0, 255) to the output merging unit.
[0116] (13) The output merging unit writes the T0 and T1 colors to the buffer unit; and after receiving the write-done signal sent by the buffer unit, it sends a merging end signal to the inter-thread overlap detection unit;
[0117] (14) When the inter-thread overlap detection unit receives the mixing end signal, it will release the triangle in Warp0 from the thread triangle memory;
[0118] (15) Repeat step (7), the hit test result of Warp1 is a miss; the inter-thread overlap detection unit sends the Warp1 mixing start signal to the back end of the execution unit;
[0119] (16) The execution process of Warp1 is similar to steps (8)-(14), and will not be repeated here; the final drawing result is as follows Figure 8 As shown.
[0120] In the above embodiments, compared with conventional pixel blending methods, this method improves the diversity and scalability of pixel blending operation formulas. On the one hand, it can adapt to the new blending operation features required by future graphics libraries, and on the other hand, it can meet the customized needs of customers. In addition, this method reuses the UAV load data path in GPU hardware, further reducing the number of logic gates in the hardware.
[0121] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.
[0122] Based on the same inventive concept, this application also provides a programmable color mixing apparatus for implementing the programmable color mixing method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more programmable color mixing apparatus embodiments provided below can be found in the limitations of the programmable color mixing method described above, and will not be repeated here.
[0123] In one exemplary embodiment, such as Figure 9 As shown, a programmable color mixing device is provided, including: an execution unit backend 901, a loading and storage unit 902, and a register information conversion unit 903, wherein:
[0124] The execution unit backend 901 is used to send an instruction to load the rendering object to the loading storage unit after receiving the mixed operation start signal;
[0125] The loading storage unit 902 is used to send the first register information corresponding to the rendering object to the register information conversion unit;
[0126] The register information conversion unit 903 is used to convert the first register information into the second register information of the out-of-order access attempt, and return the second register information to the load memory unit;
[0127] The loading storage unit 901 is also used to read the rendering object based on the second register information and send the read rendering object to the execution unit backend so that the execution unit backend can perform the hybrid operation.
[0128] In one alternative embodiment, the above-described apparatus further includes:
[0129] The intra-thread overlap detection unit is used to receive the first triangle to be assembled sent by the thread assembly unit, detect whether there is pixel overlap between the first triangle and the second triangle being assembled, obtain a first detection result, and instruct the thread assembly unit to perform thread allocation based on the first detection result.
[0130] The inter-thread overlap detection unit is used to receive triangle information from the first thread sent by the thread assembly unit, detect whether there is pixel overlap based on the triangle information in the first thread and the triangle information in the running thread, obtain a second detection result, and decide whether to send a mixing operation start signal to the back end of the execution unit based on the second detection result.
[0131] In one optional embodiment, the intra-thread overlap detection unit is specifically used to detect the first triangle to be assembled sent by the thread assembly unit; obtain information about the second triangle being assembled in the thread assembly unit; detect whether there are overlapping pixels between the first triangle and the second triangle, obtain a first detection result, and return the first detection result to the thread assembly unit; if the first detection result is that there are no overlapping pixels, add the first triangle to be assembled to the thread being assembled through the thread assembly unit; if the first detection result is that there are overlapping pixels, allocate a new thread to the first triangle to be assembled through the thread assembly unit.
[0132] In one optional embodiment, the thread overlap detection unit is specifically configured to receive first thread information and triangle information in the first thread sent by the thread assembly unit; detect whether there is pixel overlap between the triangle information in the first thread and the triangle information in the pre-stored running thread, and obtain a second detection result; if the second detection result indicates that there is no pixel overlap, send a mixing operation start signal to the execution unit backend; if the second detection result indicates that there is pixel overlap, continue to execute based on the triangle information in the first thread and the triangle information in the pre-stored running thread to detect whether there is pixel overlap between threads, and obtain a second detection result, until the second detection result indicates that there is no pixel overlap, and then send a mixing operation start signal to the execution unit backend.
[0133] In one optional embodiment, the above apparatus further includes: an output merging unit, configured to receive the result of the back-end merging operation of the execution unit, store the result of the merging operation in a cache unit, and after the output merging unit receives a write success instruction from the cache unit, send a merging end signal to the inter-thread overlap detection unit, the merging end signal being used to instruct the inter-thread overlap detection unit to release the second triangle information of the thread corresponding to the result of the merging operation.
[0134] In one optional embodiment, the loading storage unit 901 is specifically used to determine the register information of the instruction based on the instruction's identifier bit; if the instruction's register information is determined to be first register information based on the instruction's identifier bit, the process continues to send the first register information corresponding to the rendering object to the register information conversion unit through the loading storage unit; if the instruction's register information is determined to be second register information based on the instruction's identifier bit, the process continues to read the rendering object based on the second register information through the loading storage unit.
[0135] Each module in the aforementioned programmable color mixing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0136] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 10 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When executed by the processor, the computer program implements a programmable color mixing method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0137] Those skilled in the art will understand that Figure 10The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0138] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0139] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0140] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0141] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0142] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0143] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0144] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A programmable color mixing method, wherein, The method includes: After receiving the hybrid operation start signal at the back end of the execution unit, an instruction to load the rendering object is sent to the loading storage unit; The first register information corresponding to the rendered object is sent to the register information conversion unit through the loading storage unit; The register information conversion unit converts the first register information into second register information of an out-of-order access attempt, and returns the second register information to the load memory unit. The loading storage unit reads the rendering object based on the second register information and sends the read rendering object to the execution unit backend so that the execution unit backend performs a hybrid operation.
2. The programmable color mixing method according to claim 1, wherein, The method further includes: The thread assembly unit receives the first triangle to be assembled sent by the thread assembly unit, detects whether there is pixel overlap between the first triangle and the second triangle being assembled, obtains a first detection result, and instructs the thread assembly unit to perform thread allocation based on the first detection result. The inter-thread overlap detection unit receives triangle information from the first thread sent by the thread assembly unit. Based on the triangle information in the first thread and the triangle information in the running thread, it detects whether there is pixel overlap, obtains a second detection result, and decides whether to send a mixed operation start signal to the back end of the execution unit based on the second detection result.
3. The programmable color mixing method according to claim 2, wherein, The step of receiving the first triangle to be assembled from the thread assembly unit via the intra-thread overlap detection unit, detecting whether there is pixel overlap between the first triangle and the second triangle being assembled, obtaining a first detection result, and instructing the thread assembly unit to perform thread allocation based on the first detection result includes: The first triangle to be assembled, sent by the thread assembly unit, is detected by the intra-thread overlap detection unit. Obtain the second triangle being assembled in the thread assembly unit; Based on the detection of whether there are overlapping pixels using the first triangle and the second triangle, the first detection result is obtained and returned to the thread assembly unit; If the first detection result indicates that there are no overlapping pixels, the first triangle to be assembled is added to the thread being assembled by the thread assembly unit. If the first detection result indicates the presence of overlapping pixels, a new thread is assigned to the first triangle to be assembled by the thread assembly unit.
4. The programmable color mixing method according to claim 2, wherein, The step of receiving triangle information from the first thread sent by the thread assembly unit through the inter-thread overlap detection unit, detecting whether pixel overlap exists based on the triangle information in the first thread and the triangle information in the currently running thread, obtaining a second detection result, and determining whether to send a mixing operation start signal to the backend of the execution unit based on the second detection result includes: The inter-thread overlap detection unit receives the first thread information and the triangle information in the first thread sent by the thread assembly unit. Based on the triangle information in the first thread and the triangle information in the pre-stored running thread, the system detects whether there is pixel overlap between threads and obtains the second detection result. If the second detection result indicates that there is no pixel overlap, a mixing operation start signal is sent to the back end of the execution unit. If the second detection result indicates that pixel overlap exists, the process continues to execute the step of detecting whether there is pixel overlap between threads based on the triangle information in the first thread and the triangle information in the pre-stored running thread, and obtaining the second detection result, until the second detection result indicates that there is no pixel overlap, at which point a mixing operation start signal is sent to the back end of the execution unit.
5. The programmable color mixing method according to claim 2, wherein, The method further includes: The output merging unit receives the result of the back-end mixing operation of the execution unit and stores the result of the mixing operation in the cache unit. After the output merging unit receives the write success instruction from the cache unit, it sends a mixing end signal to the inter-thread overlap detection unit. The mixing end signal is used to instruct the inter-thread overlap detection unit to release the second triangle information of the thread corresponding to the result of the mixing operation.
6. The programmable color mixing method according to any one of claims 1 to 5, wherein, After sending the instruction to load the rendering object to the loading storage unit, the method further includes: The register information of the instruction is determined based on the identifier bits of the instruction; If the register information of the instruction is determined to be the first register information based on the identifier bit of the instruction, the execution continues to send the first register information corresponding to the rendering object to the register information conversion unit through the loading storage unit; If the identifier bit of the instruction determines that the register information of the instruction is the second register information, the step of reading the rendering object based on the second register information through the loading storage unit continues.
7. A programmable color mixing device, wherein, The device includes: The execution unit backend is used to send instructions to the loading and storage unit to load the rendering object after receiving the mixed operation start signal; A loading storage unit is used to send the first register information corresponding to the rendered object to the register information conversion unit; The register information conversion unit is used to convert the first register information into second register information of an out-of-order access attempt, and return the second register information to the load memory unit; The loading storage unit is also used to read the rendering object based on the second register information and send the read rendering object to the execution unit backend so that the execution unit backend performs a hybrid operation.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein... When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, wherein, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product comprising a computer program, wherein, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.