Rendering target view implementation method and first-level cache of graphics processor
By processing the coordinate information and resource type of the rendering target view in the first-level cache of the graphics processor, calculating the byte address, and splitting read and write requests, the hardware implementation complexity problem of buffer RTV is solved and the graphics processor is improved. applicability and efficiency.
Patent Information
- Application Number
- CN202410494780.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-23
- Publication Date
- 2024-08-23
AI Technical Summary
When existing graphics processors bind buffers to rendering target views, the hardware implementation is highly complex, applicable scenarios are limited, and complex offset calculations are required, affecting efficiency.
By receiving the coordinate information of the rendering target view transmitted by the output merging unit in the first-level cache of the graphics processor, obtaining the resource type, calculating the byte address according to the data layout, splitting read and write requests and merging data, reducing the complexity of hardware implementation. degree, supporting non-aligned operations of buffer RTV.
It simplifies the hardware implementation, reduces the complexity of the buffer RTV, improves the hardware applicability and flexibility of the graphics processor, and reduces the special processing requirements for the output merging unit.
Smart Images

Figure CN118537205A
Abstract
Description
Technical Field
[0001] The present application relates to the field of graphics processor technology, and in particular to a method for implementing a rendering target view, a computer device, a storage medium, a computer program product, and a first-level cache of a graphics processor. Background Art
[0002] GPU (Graphics Processing Unit) is called a graphics processor. It is a dedicated chip for graphics and image processing on computers, workstations, game consoles, mobile devices and other devices. GPU is often used in scenarios such as Windows desktop display, image editing, game entertainment, movie special effects, and 3D modeling. As the parallel computing capabilities of GPUs become more and more powerful, the application of GPUs has expanded to emerging fields such as scientific computing, artificial intelligence, and autonomous driving. Early GPUs were fixed pipelines that mainly switched various special effects through switches. They could only complete fixed functions such as field of view transformation, rasterization, and cropping, and the drawing effects were relatively simple. With the development of technology, users need to be able to program on GPUs to obtain better customized effects.
[0003] According to various standard specifications, the render target view (RTV) can select any resource type from buffer / Texture1D / Texture1DArray / Texture2D / Texture2DArray / Texture3D. Although the driver can ensure that resource allocation is aligned according to the hardware cache granularity, when binding the buffer as a render target, the API can specify any reasonable ElementOffset, which makes the starting address of the RTV part of the buffer no longer aligned according to the hardware internal granularity. In the general hardware implementation, the processing of ElementOffset is placed in the output merging unit (OutputMerger) of the fixed pipeline. This not only requires the output merging unit to perform offset calculations when reading data from the cache, but also adjusts the data offset according to the ElementOffset after receiving the color data from the pixel shader (PixelShader) and writes it into the cache. The implementation scheme is relatively complicated.
[0004] The current buffer RTV is limited by the hardware architecture and has high hardware implementation complexity, so its applicable scenarios are very limited. Summary of the invention
[0005] Based on this, it is necessary to provide a rendering target view implementation method, a computer device, a computer-readable storage medium, a computer program product and a first-level cache of a graphics processor that can improve the applicability of graphics processor hardware in response to the above technical problems.
[0006] In a first aspect, the present application provides a method for implementing a rendering target view, which is applied to a first-level cache of a graphics processor, wherein the first-level cache is provided with a data cache, and the graphics processor is provided with an output merging unit; the method comprises:
[0007] Receive the coordinate information of the rendering target view transmitted by the output merging unit;
[0008] Get the resource type of the rendering target view. When the resource type of the rendering target view is buffer, get the byte address of the coordinate information according to the data layout of the output merging unit.
[0009] Based on the byte address, the read request is split and the returned data is merged to write the data in the memory into the data cache.
[0010] In one embodiment, obtaining the byte address of the coordinate information according to the data layout of the output merging unit includes:
[0011] Align the coordinate information with the cache granularity of the output merging unit to obtain new coordinate information;
[0012] The byte address is calculated based on the new coordinate information and the element offset, element stride and base address corresponding to the coordinate information.
[0013] In one embodiment, splitting a read request and merging returned data are performed according to a byte address to write data in a memory into a data cache, including:
[0014] Initialize the read counter and determine the total number of read requests based on the byte address;
[0015] Obtain the count of the read counter, and if the count of the read counter does not reach the total number of read requests, generate a read request and three corresponding read variables according to the byte address, and send the read request and the three corresponding read variables to the memory; the three read variables are respectively used to represent the starting byte in the read-back data, the number of bytes written to the data cache starting from the starting byte in the read-back data, and the starting byte in the data cache for starting to write the read-back data;
[0016] Get the cache line number, the corresponding three read variables and the read-back data returned by the memory, and write the read-back data into the corresponding position in the data cache according to the cache line number and the corresponding three read variables;
[0017] The count of the read counter is increased by 1, and the step of obtaining the count of the read counter is returned to be executed until the count of the read counter reaches the total number of read requests.
[0018] In one embodiment, the method further comprises:
[0019] Based on the byte address, write request splitting is performed to write the data in the data cache to the memory.
[0020] In one embodiment, splitting a write request according to a byte address to write data in a data cache into a memory includes:
[0021] Initialize the write counter and determine the total number of write requests based on the byte address;
[0022] Get the count of the write counter. If the count of the write counter does not reach the total number of write requests, generate a write request and a corresponding write variable according to the byte address and the current count of the write counter, and send the write request and the corresponding write variable to the memory; the write variable is used to mark the data to be written.
[0023] The count of the write counter is increased by 1, and the step of obtaining the count of the write counter is returned to be executed until the count of the write counter reaches the total number of write requests.
[0024] In one of the embodiments, the first-level cache is further provided with an information cache, the address bit width of the information cache is configured according to the bit width of the byte address, and each cache line in the data cache is used to store the data of the corresponding output merging unit.
[0025] In a second aspect, the present application further provides a first-level cache of a graphics processor, wherein the first-level cache is provided with a data cache, and the graphics processor is provided with an output merging unit; the first-level cache includes:
[0026] An address calculation unit, used for receiving coordinate information of a rendering target view transmitted by an output merging unit;
[0027] The address calculation unit is further used to obtain the resource type of the rendering target view, and when the resource type of the rendering target view is buffer, obtain the byte address of the coordinate information according to the data layout of the output merging unit;
[0028] A read memory control unit, used to split the read request and merge the returned data according to the byte address, so as to write the data in the memory into the data cache;
[0029] The write memory control unit is used to split the write request according to the byte address to write the data in the data cache into the memory.
[0030] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0031] Receive the coordinate information of the rendering target view transmitted by the output merging unit;
[0032] Get the resource type of the rendering target view. When the resource type of the rendering target view is buffer, get the byte address of the coordinate information according to the data layout of the output merging unit.
[0033] Based on the byte address, the read request is split and the returned data is merged to write the data in the memory into the data cache.
[0034] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0035] Receive the coordinate information of the rendering target view transmitted by the output merging unit;
[0036] Get the resource type of the rendering target view. When the resource type of the rendering target view is buffer, get the byte address of the coordinate information according to the data layout of the output merging unit.
[0037] Based on the byte address, the read request is split and the returned data is merged to write the data in the memory into the data cache.
[0038] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0039] Receive the coordinate information of the rendering target view transmitted by the output merging unit;
[0040] Get the resource type of the rendering target view. When the resource type of the rendering target view is buffer, get the byte address of the coordinate information according to the data layout of the output merging unit.
[0041] Based on the byte address, the read request is split and the returned data is merged to write the data in the memory into the data cache.
[0042] The above-mentioned rendering target view implementation method, computer device, storage medium, computer program product and first-level cache of the graphics processor, the first-level cache receives the coordinate information of the rendering target view transmitted by the output merging unit, and obtains the resource type of the rendering target view. When the resource type of the rendering target view is buffer, the byte address of the coordinate information is obtained according to the data layout of the output merging unit, and the read request is split and the returned data is merged according to the byte address to write the data in the memory into the data cache. Through the bridge of the first-level cache, the cache granularity data of the output merging unit angle is mapped to the cache granularity data in the storage unit, and the buffer ElementOffset is concentrated in the first-level cache for processing. The output merging unit no longer performs special processing for the buffer RTV, and supports the buffer RTV in the hardware with minimal changes, which greatly reduces the complexity of hardware implementation, makes the use scenario of the graphics processor more flexible, and improves the hardware applicability of the graphics processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0044] FIG1 is a diagram of an application environment of a method for implementing a rendering target view in one embodiment;
[0045] FIG2 is a diagram of an internal cache structure of a first-level cache in one embodiment;
[0046] FIG3 is a schematic diagram of a first-level cache workflow in one embodiment;
[0047] FIG4 is a schematic diagram of a general hardware implementation solution that can support buffer RTV in one embodiment;
[0048] FIG5 is a schematic diagram of a flow chart of a method for implementing a rendering target view in one embodiment;
[0049] FIG6 is a schematic diagram of the Nkb mapping relationship between the output merging unit and the memory in the case of bufferRTV in one embodiment;
[0050] FIG7 is a schematic diagram of a work flow considering a bufferRTV address calculation unit in one embodiment;
[0051] FIG8 is a schematic diagram of a working process of a memory read control unit without considering buffer RTV in one embodiment;
[0052] FIG9 is a schematic diagram of a working process of a buffer RTV read memory control unit in one embodiment;
[0053] FIG10 is a schematic diagram of a work flow of a memory control unit without considering buffer RTV in one embodiment;
[0054] FIG11 is a schematic diagram of a work flow of a memory control unit considering buffer RTV write in one embodiment;
[0055] FIG12 is a schematic diagram of a process of writing a cache line of data into a memory during bufferRTV in one embodiment;
[0056] FIG13 is a block diagram of a GPU L1 cache in one embodiment;
[0057] FIG. 14 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0058] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0059] The rendering target view implementation method provided by the embodiment of the present application can be applied to the first-level cache in the GPU as shown in Figure 1. Figure 1 shows the internal structure of the first-level cache between the output merging unit and the memory, which mainly includes four control units: "address calculation unit", "hit detection unit", "read memory control unit", "write memory control unit"; and two caches "data cache" and "information cache". The structure of the "data cache" and "information cache" in the first-level cache is shown in Figure 2. Each row is recorded as a cache line, including a data part and an information part. The "data cache" is used to store data, and the size of each row depends on the specific hardware design (for example, 512bit / 1024bit / 2048bit / 4096bit, etc.), that is, the cache granularity of the first-level cache; and the "information cache" mainly stores the information corresponding to this row of data, such as the virtual address Addr (virtual address) in the memory. The traditional work of the first-level cache includes processing read requests, processing write requests, and writing data to the memory. The traditional workflow is shown in Figure 3.
[0060] DirectX / OpenGL / Vulkan and other standard specifications point out that the render target view RTV can select any resource type from buffer / Texture1D / Texture1DArray / Texture2D / Texture2DArray / Texture3D. When the driver allocates memory for various resources, it will ensure that the starting address and resource size are aligned according to the cache granularity inside the hardware, so as to facilitate the address calculation in the hardware. At the same time, for xxArray and Texture3D, they are composed of multiple Texture2Ds in the storage space, and the starting address and size of each Texture2D are also aligned. According to the description of the spec, each Texture2D here is called a slice. In addition to several resources other than buffer, the API stipulates that several slices can be selected as the render target view. For example, for Texture2DArray, the structure when it is bound to RTV is as follows. The starting addresses of these resources when used as RTV are still aligned according to the hardware cache granularity, which is more convenient for hardware processing. When binding the buffer as RTV, it is necessary to specify starting from the element at "ElementOffset" and selecting consecutive "ElementWidth" elements to bind as RTV.
[0061] In traditional technology, the coordinates of primitives seen in the raster stage are calculated for the starting point of RTV. When buffer is selected as RTV, the coordinates of the element at ElementOffset are (x, y) = (0, 0) in the raster. The byte address of the point with coordinates (0, 0) must be aligned according to the hardware cache granularity, so that when the functional unit (such as DepthProcessor / OutputMerger) splits the primitives according to the cache granularity to access the cache, it can easily calculate based on the coordinates. This rule applies to all resources except buffer, with the exception of buffer. The size of each element in Buffer (denoted as ElementStride) is specified by the corresponding format, which can be one of 8 / 16 / 32 / 64 / 128bpe (bit per element). Regardless of the format, ElementOffset can be any value that does not exceed the size of the resource itself. At this time, the byte address of the element at coordinates (x, y) = (0, 0) may be any value and no longer meet the alignment requirements. For buffer RTV, the general hardware implementation solution is to support it in the output merge unit (OutputMerge), which has minor changes and is not very universal. The general solution is shown in Figure 4, which mainly configures multiple functional units in the output merge unit to target buffer RTV. The configured multiple functional units include:
[0062] Input data adjustment unit: adjusts the position of pixel shader input data according to ElementOffset;
[0063] Memory data adjustment unit: adjusts the position of data read from the first-level cache according to ElementOffset;
[0064] Read / write coordinate adjustment unit: adjusts the x coordinate of the rendering view obtained from the parent module according to ElementOffset.
[0065] In an exemplary embodiment, as shown in FIG5 , a method for implementing a rendering target view is provided, which is described by taking the method applied to the first-level cache in FIG1 as an example, and includes the following steps 502 to 506 . Among them:
[0066] Step 502: Receive coordinate information of the rendering target view transmitted by the output merging unit.
[0067] Optionally, the address calculation unit in the first-level cache receives the coordinate information (x, y) of the RTV transmitted by the output merging unit.
[0068] It should be noted that the output merging unit no longer makes special changes for buffer RTV. It only adjusts the "address calculation unit", "read memory control unit", and "write memory control unit" in the first-level cache, and fine-tunes the "information cache". Because the driver will align the size and starting address of the resource according to the cache granularity when creating the resource. When buffer RTV is not considered, the output merging unit can easily split the primitives according to the coordinates, thereby ensuring that the address Addr corresponding to the read / write request sent to the first-level cache has been aligned according to the cache granularity. The first-level cache also reads data from the memory in an aligned manner and stores it in the "data cache" part. In this way, the "Addr" in the "information cache" part only needs to retain the high bit. Take the example of each row of data in the first-level cache being 1024 bits: the resource size and starting address allocated by the driver are aligned to 1024 bits; for the rendering view RTV with a linear layout and 64bpe, the coordinates (16i, j)~(16i+15, j) belong to the same 1024 bits, so the output merge unit splits the primitives in the manner of "width=16, height=1"; each time the first-level cache reads 1024 bits from the memory, it will be stored in one row, and the byte address of these 1024 bits is different except for the lower 7 bits (from 0x0 to 0x3f from the front to the back), and the high bits are the same. Therefore, "Addr" only needs to store the high bit information of the byte address.
[0069] In a feasible implementation, the first-level cache is further provided with an information cache, the address bit width of the information cache is configured according to the bit width of the byte address, and each cache line in the data cache is used to store the corresponding data of the output merging unit.
[0070] Specifically, in order to support buffer RTV, the definition of the "cache data" part in the first-level cache can be adjusted: the data in each cache line becomes a piece of data seen by the output merging unit, and is no longer data whose starting address is aligned to the cache granularity in the memory sense. To support the above changes, the first-level cache needs to be modified as follows: expand the Addr bit width recorded in the "information cache" so that it accurately represents the virtual address of the first byte in the "data cache"; update the "address calculation unit" to support buffer RTV address calculation with ElementOffset; update the "read memory control unit" to split unaligned read requests and merge the returned data; update the "write memory control unit" to split unaligned write requests.
[0071] Step 504 , obtaining the resource type of the rendering target view. When the resource type of the rendering target view is buffer, obtaining the byte address of the coordinate information according to the data layout of the output merging unit.
[0072] Among them, RTV resource types include but are not limited to buffer, Texture1D, Texture1DArray, Texture2D, Texture2DArray and Texture3D.
[0073] Optionally, the first-level cache can obtain the resource type of RTV. If the current processing is not a buffer RTV resource, the byte address addr is calculated according to the original logic of the first-level cache. If the current processing is a buffer RTV resource, the coordinate information (x, y) is aligned to Nkb (here is Nkb seen from the output merging unit angle), and the new coordinate (x', y) is obtained. Then, the byte address Addr is calculated according to the coordinate (x', y): Addr=(x'+ElementOffset) *ElementStride + Base_Address.
[0074] Step 506: split the read request and merge the returned data according to the byte address, so as to write the data in the memory into the data cache.
[0075] Optionally, after the first-level cache obtains the read request from the output merging unit, the address calculation unit uses the coordinates to calculate the address information Addr. The hit detection unit uses Addr to perform a hit detection to determine whether the current request hits in the cache. If it does not hit, the hit detection unit allocates a cache space for the current request and updates the "information cache" part. The read memory control unit generates a read request to the memory unit according to Addr, writes the read data returned by the memory unit into the "data cache", reads the corresponding data from the cache and returns it to the output merging unit; if it hits, the read memory control unit directly reads the corresponding data from the cache and returns it to the output merging unit.
[0076] In the above rendering target view implementation method, the first-level cache receives the coordinate information of the rendering target view transmitted by the output merging unit, and obtains the resource type of the rendering target view. When the resource type of the rendering target view is buffer, the byte address of the coordinate information is obtained according to the data layout of the output merging unit, and the read request is split and the returned data is merged according to the byte address to write the data in the memory into the data cache. Through the bridge of the first-level cache, the cache granularity data from the perspective of the output merging unit is mapped to the cache granularity data in the storage unit, and the buffer ElementOffset is concentrated in the first-level cache for processing. The output merging unit no longer performs special processing for buffer RTV, and supports buffer RTV in hardware with minimal changes, which greatly reduces the complexity of hardware implementation, makes the use scenarios of the graphics processor more flexible, and improves the hardware applicability of the graphics processor.
[0077] In one embodiment, the byte address of the coordinate information is obtained according to the data layout of the output merging unit, including: aligning the coordinate information with the cache granularity of the output merging unit to obtain new coordinate information; and calculating the byte address according to the new coordinate information, and the element offset, element stride and base address corresponding to the coordinate information.
[0078] Optionally, the ElementOffset of Buffer RTV is transparent to the output merging unit, so the cache granularity data from the perspective of the output merging unit is no longer necessarily aligned by address in the memory, as shown in Figure 6. In Figure 6, it is assumed that the amount of data in each "data cache" in the cache is Nkb (that is, the cache granularity is Nkb), and the first group of Nkb data on the Buffer RTV from the perspective of the output merging unit spans two consecutive groups of Nkb data in the memory. The data layout in the first-level cache is consistent with the output merging unit, so the Nkb data of each "data cache" must also span two consecutive groups of Nkb data in the memory.
[0079] In order to determine the correct starting address, after receiving the coordinate information sent by the output merging unit, the first-level cache needs to accurately calculate the starting byte address of the first element in the current "data cache" from the perspective of the output merging unit. The process of the "address calculation unit" is modified as shown in the process on the right side of Figure 7. For the first step of the buffer RTV address calculation, assuming that the cache granularity is 1024 bits, for a linear layout and a 64bpe render target, the x coordinate needs to be aligned to 16, that is, x'= (x>> 4) << 4. In addition, buffer RTV is a one-dimensional linear resource, and the y in the coordinate is always 0, which does not affect the address calculation. At this point, the starting byte address of the first element is obtained and updated to the Addr in the "information cache".
[0080] In this embodiment, the address calculation unit in the first-level cache is updated so that the first-level cache supports buffer RTV address calculation with ElementOffset.
[0081] In one embodiment, read request splitting and returned data merging are performed according to byte addresses to write data in a memory into a data cache, including: initializing a read counter and determining the total number of read requests according to the byte address; obtaining the count of the read counter, and generating a read request and corresponding three read variables according to the byte address when the read counter count does not reach the total number of read requests, and sending the read request and the corresponding three read variables to the memory; the three read variables are respectively used to represent the starting byte in the read-back data, the number of bytes written to the data cache starting from the starting byte in the read-back data, and the starting byte in the data cache for starting to write the read-back data; obtaining the cache line number returned by the memory, the corresponding three read variables, and the read-back data, and writing the read-back data into the corresponding position in the data cache according to the cache line number and the corresponding three read variables; the read counter count is increased by 1, and the step of obtaining the read counter count is returned until the read counter count reaches the total number of read requests.
[0082] Optionally, the read / write bit width between the first-level cache and the memory unit generally does not exceed the cache granularity. In order to obtain the data in a cache line, the first-level cache needs to read from the memory unit several times, the number of reads is recorded as M, and each segment of data read is recorded as ReadSlot; and the number of writes required to write the data in a cache line to the memory unit is recorded as K, and each segment of data written is recorded as WriteSlot. In order to maximize the read / write efficiency, in the design without considering buffer RTV, the cache granularity needs to be able to divide M or K, that is, ReadSlot*M=NKb; WriteSlot*K=NKb. If the current processing is not a buffer RTV resource, the workflow of the "read memory control unit" in the first-level cache is shown in Figure 8.
[0083] If the buffer RTV resource is currently being processed, the workflow of the "read memory control unit" in the first-level cache is shown in Figure 9. To support buffer RTV while maintaining the read bit width as ReadSlot, for a total of NKb of data in a cache line, it is necessary to read data from "M+1" ReadSlots at most and select the appropriate data to fill in the cache line. In order to select the required data from each ReadSlot read back and fill it in the corresponding position of the cache line "data cache", the following three variables are used to replace the "read sequence number i" in the original read request:
[0084] Byte_Offset_Src: indicates which byte in the read-back ReadSlot data is used first;
[0085] Byte_Number: indicates how many bytes of the read data need to be filled into the current cache line "data cache" starting from the "Byte_Offset_Src" byte;
[0086] Byte_Offset_Dst: Indicates which byte in the cache line "data cache" the read data should be filled into to start processing.
[0087] In this embodiment, the read memory control unit in the first-level cache is updated so that the first-level cache supports splitting of unaligned read requests and merging of returned data.
[0088] In one embodiment, the method further includes: splitting the write request according to the byte address to write the data in the data cache into the memory.
[0089] Specifically, according to the byte address, the write request is split to write the data in the data cache into the memory, including: initializing a write counter and determining the total number of write requests according to the byte address; obtaining the count of the write counter, and when the count of the write counter does not reach the total number of write requests, generating a write request and a corresponding write variable according to the byte address and the current count of the write counter, and sending the write request and the corresponding write variable to the memory; the write variable is used to mark the data to be written; incrementing the count of the write counter by 1, and returning to the step of obtaining the count of the write counter until the count of the write counter reaches the total number of write requests.
[0090] Optionally, on the premise that the write bit width still remains WriteSlot, buffer RTV is supported. For a cache line data, it is necessary to split it into "K + 1" write requests at most to write all the data into the memory. If the currently processed resource is not buffer RTV, the process of the "write memory control unit" in the first-level cache writing the data in a cache line into the memory is shown in FIG. 10.
[0091] If the currently processed resource is buffer RTV, the process of the "write memory control unit" in the first-level cache writing the data in a cache line into the memory is shown in FIG. 11. When the calculated byte address is aligned to WriteSlot, each time Read WriteSlot from the "data cache" part and then write it into the memory. However, when the address is not aligned, although the data bandwidth of the first and last write requests is still WriteSlot, only part of the data is valid, and a mask needs to be set for the valid data. As shown in FIG. 12, for the first write, only a small part in the front of the "data cache" (data volume < WriteSlot) needs to be written into the memory, so only set the mask of this small part to valid; for the last write, only a small part at the end of the "data cache" (data volume < WriteSlot) needs to be written into the memory, and only set the mask of this small part to valid; for other intermediate write requests, the sent data is all valid, and the mask can be set to valid.
[0092] In an exemplary embodiment, a method for implementing a render target view is applied to the first-level cache of a graphics processor as shown in FIG. 1. The first-level cache is provided with a data cache and an information cache. The address bit width of the information cache is configured according to the bit width of the byte address. Each cache line in the data cache is used to store the data of the output merge unit correspondingly. The graphics processor is provided with an output merge unit; the method includes:
[0093] Receiving the coordinate information of the render target view transmitted by the output merge unit;
[0094] Get the resource type of the rendering target view. When the resource type of the rendering target view is buffer, align the coordinate information with the cache granularity of the output merging unit to obtain new coordinate information; calculate the byte address based on the new coordinate information and the element offset, element stride, and base address corresponding to the coordinate information.
[0095] When a read request is received, a read counter is initialized, and the total number of read requests is determined according to the byte address; the count of the read counter is obtained, and when the count of the read counter does not reach the total number of read requests, a read request and three corresponding read variables are generated according to the byte address, and the read request and the three corresponding read variables are sent to the memory; the three read variables are respectively used to represent the starting byte in the read-back data, the number of bytes written to the data cache starting from the starting byte in the read-back data, and the starting byte in the data cache for starting to write the read-back data; the cache line number returned by the memory, the corresponding three read variables and the read-back data are obtained, and the read-back data is written to the corresponding position in the data cache according to the cache line number and the corresponding three read variables; the count of the read counter is increased by 1, and the step of obtaining the count of the read counter is returned to execute until the read counter count reaches the total number of read requests.
[0096] When a write request is received, the write counter is initialized, and the total number of write requests is determined according to the byte address; the count of the write counter is obtained, and when the count of the write counter has not reached the total number of write requests, a write request and a corresponding write variable are generated according to the byte address and the current count of the write counter, and the write request and the corresponding write variable are sent to the memory; the write variable is used to mark the data to be written; the count of the write counter is increased by 1, and the step of obtaining the count of the write counter is returned to execute until the count of the write counter reaches the total number of write requests.
[0097] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0098] Based on the same inventive concept, the embodiment of the present application also provides a GPU level 1 cache for implementing the above-mentioned rendering target view implementation method. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above-mentioned method, so the specific limitations in one or more GPU level 1 cache embodiments provided below can refer to the limitations of the rendering target view implementation method above, and will not be repeated here.
[0099] In an exemplary embodiment, as shown in FIG13 , a GPU level 1 cache 1300 is provided, comprising: an address calculation unit 1301, a read memory control unit 1302, a write memory control unit 1303, a data cache 1304, and an information cache 1305, wherein:
[0100] The address calculation unit 1301 is used to receive the coordinate information of the rendering target view transmitted by the output merging unit.
[0101] The address calculation unit 1301 is further configured to obtain a resource type of the rendering target view, and when the resource type of the rendering target view is a buffer, obtain a byte address of the coordinate information according to a data layout of the output merging unit.
[0102] The read memory control unit 1302 is used to split the read request and merge the returned data according to the byte address, so as to write the data in the memory into the data cache.
[0103] The write memory control unit 1303 is used to split the write request according to the byte address to write the data in the data cache into the memory.
[0104] Each cache line in the data cache 1304 is used to store the data of the corresponding output merging unit, and the address bit width of the information cache 1305 is configured according to the bit width of the byte address.
[0105] In one embodiment, the address calculation unit 1301 is also used to align the coordinate information with the cache granularity of the output merging unit to obtain new coordinate information; and calculate the byte address based on the new coordinate information and the element offset, element stride and base address corresponding to the coordinate information.
[0106] In one embodiment, the read memory control unit 1302 is also used to initialize a read counter and determine the total number of read requests based on the byte address; obtain the count of the read counter, and when the read counter count does not reach the total number of read requests, generate a read request and corresponding three read variables based on the byte address, and send the read request and the corresponding three read variables to the memory; the three read variables are used to represent the starting byte in the read-back data, the number of bytes written to the data cache starting from the starting byte in the read-back data, and the starting byte in the data cache for starting to write the read-back data; obtain the cache line number returned by the memory, the corresponding three read variables, and the read-back data, and write the read-back data to the corresponding position in the data cache based on the cache line number and the corresponding three read variables; the read counter count is increased by 1, and the step of obtaining the read counter count is returned to execute until the read counter count reaches the total number of read requests.
[0107] In one embodiment, the write memory control unit 1303 is also used to initialize the write counter and determine the total number of write requests based on the byte address; obtain the count of the write counter, and when the write counter count has not reached the total number of write requests, generate a write request and a corresponding write variable based on the byte address and the current count of the write counter, and send the write request and the corresponding write variable to the memory; the write variable is used to mark the data that needs to be written; the write counter count is increased by 1, and the step of obtaining the write counter count is returned to execute until the write counter count reaches the total number of write requests.
[0108] Each unit in the GPU L1 cache can be implemented in whole or in part by software, hardware, or a combination thereof. Each unit can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each unit.
[0109] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG14. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store RTV data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for implementing a rendering target view is implemented.
[0110] Those skilled in the art will understand that the structure shown in FIG. 14 is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0111] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the following steps when executing the computer program: receiving coordinate information of a rendering target view transmitted by an output merging unit; obtaining a resource type of the rendering target view, and when the resource type of the rendering target view is a buffer, obtaining a byte address of the coordinate information according to a data layout of the output merging unit; and performing read request splitting and returned data merging according to the byte address to write data in the memory into a data cache.
[0112] In one embodiment, when the processor executes the computer program, the following steps are also implemented: aligning the coordinate information with the cache granularity of the output merging unit to obtain new coordinate information; calculating the byte address based on the new coordinate information and the element offset, element stride and base address corresponding to the coordinate information.
[0113] In one embodiment, when the processor executes the computer program, the following steps are also implemented: initializing a read counter and determining the total number of read requests according to the byte address; obtaining the count of the read counter, and generating a read request and corresponding three read variables according to the byte address when the count of the read counter does not reach the total number of read requests, and sending the read request and the corresponding three read variables to the memory; the three read variables are respectively used to represent the starting byte in the read-back data, the number of bytes written to the data cache starting from the starting byte in the read-back data, and the starting byte in the data cache for starting to write the read-back data; obtaining the cache line number returned by the memory, the corresponding three read variables, and the read-back data, and writing the read-back data to the corresponding position in the data cache according to the cache line number and the corresponding three read variables; the count of the read counter is increased by 1, and the step of obtaining the count of the read counter is returned until the count of the read counter reaches the total number of read requests.
[0114] In one embodiment, when the processor executes the computer program, the processor further implements the following steps: splitting the write request according to the byte address to write the data in the data cache into the memory.
[0115] In one embodiment, when the processor executes the computer program, the following steps are also implemented: initializing a write counter, and determining the total number of write requests based on the byte address; obtaining the count of the write counter, and when the count of the write counter has not reached the total number of write requests, generating a write request and a corresponding write variable based on the byte address and the current count of the write counter, and sending the write request and the corresponding write variable to the memory; the write variable is used to mark the data to be written; the count of the write counter is increased by 1, and the step of obtaining the count of the write counter is returned to execute until the count of the write counter reaches the total number of write requests.
[0116] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: receiving coordinate information of a rendering target view transmitted by an output merging unit; obtaining a resource type of the rendering target view, and when the resource type of the rendering target view is a buffer, obtaining a byte address of the coordinate information according to a data layout of the output merging unit; and performing read request splitting and returned data merging according to the byte address to write data in a memory into a data cache.
[0117] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: aligning the coordinate information with the cache granularity of the output merging unit to obtain new coordinate information; calculating the byte address based on the new coordinate information and the element offset, element stride and base address corresponding to the coordinate information.
[0118] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: initializing a read counter and determining the total number of read requests based on the byte address; obtaining the count of the read counter, and generating a read request and corresponding three read variables based on the byte address when the count of the read counter does not reach the total number of read requests, and sending the read request and the corresponding three read variables to the memory; the three read variables are respectively used to represent the starting byte in the read-back data, the number of bytes written to the data cache starting from the starting byte in the read-back data, and the starting byte in the data cache for starting to write the read-back data; obtaining the cache line number returned by the memory, the corresponding three read variables and the read-back data, and writing the read-back data to the corresponding position in the data cache based on the cache line number and the corresponding three read variables; the count of the read counter is increased by 1, and the step of obtaining the count of the read counter is returned until the count of the read counter reaches the total number of read requests.
[0119] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: write request splitting is performed according to the byte address to write the data in the data cache into the memory.
[0120] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: initializing a write counter, and determining the total number of write requests based on the byte address; obtaining the count of the write counter, and when the count of the write counter has not reached the total number of write requests, generating a write request and a corresponding write variable based on the byte address and the current count of the write counter, and sending the write request and the corresponding write variable to the memory; the write variable is used to mark the data to be written; the count of the write counter is increased by 1, and the step of obtaining the count of the write counter is returned to execute until the count of the write counter reaches the total number of write requests.
[0121] In one embodiment, a computer program product is provided, including a computer program, which implements the following steps when executed by a processor: receiving coordinate information of a rendering target view transmitted by an output merging unit; obtaining a resource type of the rendering target view, and when the resource type of the rendering target view is a buffer, obtaining a byte address of the coordinate information according to a data layout of the output merging unit; and performing read request splitting and returned data merging according to the byte address to write data in a memory into a data cache.
[0122] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: aligning the coordinate information with the cache granularity of the output merging unit to obtain new coordinate information; calculating the byte address based on the new coordinate information and the element offset, element stride and base address corresponding to the coordinate information.
[0123] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: initializing a read counter and determining the total number of read requests based on the byte address; obtaining the count of the read counter, and generating a read request and corresponding three read variables based on the byte address when the count of the read counter does not reach the total number of read requests, and sending the read request and the corresponding three read variables to the memory; the three read variables are respectively used to represent the starting byte in the read-back data, the number of bytes written to the data cache starting from the starting byte in the read-back data, and the starting byte in the data cache for starting to write the read-back data; obtaining the cache line number returned by the memory, the corresponding three read variables and the read-back data, and writing the read-back data to the corresponding position in the data cache based on the cache line number and the corresponding three read variables; the count of the read counter is increased by 1, and the step of obtaining the count of the read counter is returned until the count of the read counter reaches the total number of read requests.
[0124] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: write request splitting is performed according to the byte address to write the data in the data cache into the memory.
[0125] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: initializing a write counter, and determining the total number of write requests based on the byte address; obtaining the count of the write counter, and when the count of the write counter has not reached the total number of write requests, generating a write request and a corresponding write variable based on the byte address and the current count of the write counter, and sending the write request and the corresponding write variable to the memory; the write variable is used to mark the data to be written; the count of the write counter is increased by 1, and the step of obtaining the count of the write counter is returned to execute until the count of the write counter reaches the total number of write requests.
[0126] 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, stored data, displayed data, 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 relevant data must comply with relevant regulations.
[0127] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile 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), magnetoresistive 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. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0128] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, 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 specification.
[0129] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the present application. It should be noted that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for implementing a rendering target view, characterized in that: A first-level cache applied to a graphics processor, wherein the first-level cache is provided with a data cache, and the graphics processor is provided with an output merging unit; the method comprises: Receiving coordinate information of the rendering target view transmitted by the output merging unit; Acquire the resource type of the rendering target view, and when the resource type of the rendering target view is buffer, acquire the byte address of the coordinate information according to the data layout of the output merging unit; According to the byte address, the read request is split and the returned data is merged to write the data in the memory into the data cache.
2. The method according to claim 1, characterized in that The step of obtaining the byte address of the coordinate information according to the data layout of the output merging unit includes: Aligning the coordinate information with the cache granularity of the output merging unit to obtain new coordinate information; The byte address is calculated according to the new coordinate information, and the element offset, element stride and base address corresponding to the coordinate information.
3. The method according to claim 1, characterized in that The splitting of the read request and merging of the returned data according to the byte address to write the data in the memory into the data cache includes: Initializing a read counter and determining a total number of read requests based on the byte address; Obtaining the count of the read counter, and if the count of the read counter does not reach the total number of the read requests, generating a read request and three corresponding read variables according to the byte address, and sending the read request and the three corresponding read variables to the memory; the three read variables are respectively used to represent the starting byte in the read-back data, the number of bytes written to the data cache starting from the starting byte in the read-back data, and the starting byte in the data cache for starting to write the read-back data; Obtaining the cache line number, the corresponding three read variables and the read-back data returned by the memory, and writing the read-back data into the corresponding position in the data cache according to the cache line number and the corresponding three read variables; The count of the read counter is increased by 1, and the step of obtaining the count of the read counter is returned to be executed until the count of the read counter reaches the total number of read requests.
4. The method according to claim 1, characterized in that: The method further comprises: The write request is split according to the byte address to write the data in the data cache into the memory.
5. The method according to claim 1, characterized in that The step of splitting the write request according to the byte address to write the data in the data cache into the memory includes: Initializing a write counter, and determining a total number of write requests based on the byte address; Obtaining the count of the write counter, and if the count of the write counter does not reach the total number of write requests, generating a write request and a corresponding write variable according to the byte address and the current count of the write counter, and sending the write request and the corresponding write variable to the memory; the write variable is used to mark the data to be written; The count of the write counter is increased by 1, and the step of obtaining the count of the write counter is returned to be executed until the count of the write counter reaches the total number of write requests.
6. The method according to claim 1, characterized in that The first-level cache is further provided with an information cache, the address bit width of the information cache is configured according to the bit width of the byte address, and each cache line in the data cache is used to store the data of the output merging unit.
7. A level 1 cache of a graphics processor, characterized in that: The first-level cache is provided with a data cache, and the graphics processor is provided with an output merging unit; the first-level cache includes: An address calculation unit, configured to receive coordinate information of a rendering target view transmitted by the output merging unit; The address calculation unit is further used to obtain the resource type of the rendering target view, and when the resource type of the rendering target view is buffer, obtain the byte address of the coordinate information according to the data layout of the output merging unit; A read memory control unit, used to split the read request and merge the returned data according to the byte address, so as to write the data in the memory into the data cache; A write memory control unit is used to split the write request according to the byte address so as to write the data in the data cache into the memory.
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, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Start control method and device of system on chip, storage medium and electronic equipment
CN121233183A
System-on-chip startup control method and device, storage medium and electronic equipment
CN121233183B
Output merging unit, data processing method, processor and electronic equipment
CN121788637A
