Texture sampling method and device based on texel request fusion processing
By creating a texel request fusion table, target texel requests in the same cache row are fused, which solves the problem of excessive cache hit tests in texture sampling and improves the speed and efficiency of texture sampling.
Patent Information
- Application Number
- CN202211265586.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-17
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2042-10-17
AI Technical Summary
In existing texture sampling methods, the number of cache hit tests for texel requests is too high, resulting in low texture sampling efficiency. In particular, when there is a cache miss, the next level of memory needs to be accessed frequently, which affects the overall performance.
By creating a texel request fusion table, target texel requests in the same cache line are fused, reducing the number of cache hit tests and optimizing the request pressure on the next level of memory, thereby improving texture sampling speed.
By reducing the number of cache hit tests and optimizing next-level memory requests, the speed and efficiency of texture sampling are significantly improved.
Smart Images

Figure CN115601566B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer vision technology, and in particular to a texture sampling method and apparatus based on texel request fusion processing. Background Technology
[0002] With the development of computer graphics technology, computers can achieve more three-dimensional and realistic graphics rendering through GPUs (Graphics Processing Units). Texture mapping is a technique that draws (maps) images (textures) onto the surface of a 3D scene, which can significantly increase the detail and realism of the drawn scene.
[0003] When performing texture mapping, the GPU needs to load texture pixels (texels) from memory into the cache before performing texture sampling. A common method for texture sampling is bilinear filtering. Bilinear filtering takes the texture coordinates corresponding to a pixel in the 3D scene as the center, collects the pixel values of the four surrounding texels, and then takes the average of the four pixel values as the sample value. Specifically, in bilinear filtering, one sampling requires 4 texels. Since the smallest working unit of a pixel shader is a 2*2 pixel quad (4 pixel blocks), when performing bilinear filtering, since each pixel block requires 4 texels, one mapping requires 2*2*4 = 16 texels. Therefore, 16 hit tests are needed on the texture cache. If a cache miss occurs, a request is sent to the next level of cache to obtain the required texels for each pixel for texture filtering to obtain the final sampling result.
[0004] In other words, in the current texture sampling, one sampling requires 16 texels. These 16 texels need to undergo 16 hit tests in the cache, which takes 16 clock cycles. In the worst case, if a cache miss occurs in every hit test, 16 miss requests will be sent to the next level of memory, waiting for the next level of memory to return the data one by one. It can be seen that the current sampling method is time-consuming and affects the texture sampling efficiency. Summary of the Invention
[0005] Therefore, it is necessary to provide a texture sampling method and apparatus based on texel request fusion processing to address the above-mentioned technical problems.
[0006] Firstly, this application provides a texture sampling method based on texel request fusion processing. The method includes:
[0007] Create a texture sampling request; the texture sampling request contains pixels to be processed;
[0008] Based on the pixel coordinates of the pixel to be processed, multiple target texel requests are obtained;
[0009] Based on preset rules, the multiple target texel requests are fused to obtain a texel request fusion table.
[0010] Based on the valid cache rows in the texel request fusion table, cache hit tests are performed on the multiple target texel requests in sequence to obtain the target texel.
[0011] In one embodiment, obtaining multiple target texel requests based on the pixel coordinates of the pixel to be processed includes:
[0012] Based on the pixel coordinates, calculate the texel coordinates of multiple target texels corresponding to the pixel coordinates;
[0013] Based on the texel coordinates, a target texel request is constructed; wherein each target texel request contains one target texel.
[0014] In one embodiment, the texel request fusion table includes a cache line identifier and a mask for the next-level cache block to be requested; the step of performing fusion processing on the multiple target texel requests based on preset rules to obtain the texel request fusion table includes:
[0015] For each target texel in the target texel request, calculate the texel identifier of the target texel;
[0016] Based on the comparison result between the texel identifier and the cache line identifier, the multiple target texel requests are written into the texel request fusion table.
[0017] In one embodiment, the texel request fusion table further includes a next-level cache block mask to be requested; the step of writing the plurality of target texel requests into the texel request fusion table based on the comparison result between the texel identifier and the cache line identifier includes:
[0018] Based on the comparison result, if the texel identifier already exists in the texel request fusion table, then the cache block mask corresponding to the texel identifier is ORed with the next-level cache block mask to be requested, so that the target texel is written into the texel request fusion table.
[0019] In one embodiment, the texel request fusion table further includes a next-level cache block mask to be requested; the step of writing the plurality of target texel requests into the texel request fusion table based on the comparison result of the texel identifier and the cache line identifier further includes:
[0020] If the texel identifier does not exist in the texel request fusion table, the cache block mask corresponding to the texel identifier is written into a new cache line, and the texel request fusion table is updated.
[0021] In one embodiment, the step of sequentially performing cache hit tests on the plurality of target texel requests based on the valid cache rows in the texel request fusion table to obtain the target texel includes:
[0022] The cache line corresponding to the texel identifier containing the target texel is taken as the valid cache line. Hit tests are performed on the valid cache lines in sequence. If a hit occurs, the target texel is obtained.
[0023] In one embodiment, the method further includes:
[0024] If missing, the cache block mask corresponding to the texel identifier containing the target texel will be sent to the next level cache space for a hit test.
[0025] In one embodiment, the texel identifier is used to identify a texel.
[0026] In one embodiment, the cache line identifier is used to uniquely identify a cache line.
[0027] Secondly, this application also provides a texture sampling device based on texel request fusion processing.
[0028] The device includes:
[0029] A texture sampling request creation module is used to create texture sampling requests; the texture sampling request contains pixels to be processed.
[0030] The target texel request acquisition module is used to obtain multiple target texel requests based on the pixel coordinates of the pixel to be processed.
[0031] The texture request fusion table processing module is used to perform fusion processing on the multiple target texture requests based on preset rules to obtain a texture request fusion table.
[0032] The hit test module is used to perform cache hit tests on the multiple target texel requests sequentially based on the valid cache rows in the texel request fusion table, so as to obtain the target texel.
[0033] The aforementioned texture sampling method, apparatus, computer device, and storage medium based on texel request fusion processing involve creating a texture sampling request; this request contains pixels to be processed; multiple target texel requests are obtained based on the pixel coordinates of the pixels to be processed; fusion processing is performed on the multiple target texel requests based on preset rules to obtain a texel request fusion table; and cache hit tests are performed sequentially on the multiple target texel requests according to the valid cache rows in the texel request fusion table to obtain the target texels. This application, by creating and updating the texel request fusion table, fuses target texel requests in the same cache row together, reducing the number of cache hit tests. Furthermore, for a large number of consecutive target texel requests, the fusion operation significantly reduces the pressure on the next-level memory to process the texel requests, thereby improving the texture sampling speed. Attached Figure Description
[0034] Figure 1 This is an organizational structure diagram of a texture sampling method based on texel request fusion processing in one embodiment;
[0035] Figure 2 This is a flowchart illustrating a texture sampling method based on texel request fusion processing in one embodiment;
[0036] Figure 3 This is a diagram illustrating the organization of the cache space in one embodiment;
[0037] Figure 4 This is a schematic diagram of the structure of a texel request fusion table in one embodiment;
[0038] Figure 5 This is a diagram illustrating an application example of the texel request fusion table in another embodiment;
[0039] Figure 6 This is a structural block diagram of a texture sampling method apparatus based on texel request fusion processing in one embodiment. Detailed Implementation
[0040] 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.
[0041] The texture sampling method based on texel request fusion processing provided in this application embodiment can be applied to GPUs (Graphics Processing Units). A GPU contains multiple processor cores, each of which can serve as a texture unit. Each texture unit contains an ALU (Arithmetic and Logic Unit), a texture cache, and a texel request fusion table. The texture cache is essentially an L1 cache. When performing texture mapping, the GPU needs to load texture pixels (texels) from memory into the L1 cache (i.e., the aforementioned texture cache) before performing texture sampling. A commonly used method for texture sampling is bilinear filtering. Bilinear filtering takes the texture coordinates corresponding to a certain pixel in the 3D scene to be processed as the center, collects the pixel values of the four surrounding texels, and then takes the average of the four pixel values as the sample value. Specifically, in bilinear filtering, one sampling requires 4 texels. Since the smallest working unit of a pixel shader is a 2*2 pixel quad (4 pixel blocks), during bilinear filtering, each pixel block requires 4 texels. Therefore, one mapping requires 2*2*4 = 16 texels, meaning 16 hit tests are needed on the texture cache. If a cache miss occurs, a request needs to be sent to the next level of memory. Figure 1 The L2 cache or main memory is used to obtain the required texels for each pixel for texture filtering, and the final sampling result is obtained.
[0042] In one embodiment, such as Figure 2 As shown, a texture sampling method based on texel request fusion processing is provided, which is then applied to... Figure 1 Taking the texture unit in the image as an example, the explanation includes the following steps:
[0043] Step S201: Create a texture sampling request; the texture sampling request contains pixels to be processed.
[0044] In computer graphics, texture encompasses both the surface texture of an object in the conventional sense (i.e., the unevenness and grooves on the surface) and colored patterns on a smooth surface, often referred to as designs. Texture sampling is a crucial step in texture mapping. A texture sampling request refers to a request to sample textures from a target scene; specifically, for the target scene to be created (currently a 2D image), a texture needs to be applied to a specific area. Specifically, it can be a response to a user's selection of a target area, creating a texture sampling request for that target area.
[0045] Specifically, for the target scene to be created (currently a 2D image), a texture needs to be applied to a specific area. For example, in response to the user's selection of a target area, a texture sampling request can be created for that target area. This target area includes multiple pixels to be processed.
[0046] Step S202: Based on the pixel coordinates of the pixel to be processed, obtain multiple target texel requests;
[0047] Specifically, taking the bilinear filtering method (a texture sampling method) as an example, the bilinear filtering method centers on the texture coordinates corresponding to a certain pixel in the 3D scene to be processed. The texture coordinates are the coordinates corresponding to the pixel in texture space after transformation. The method collects the pixel values of the four texels surrounding the texture coordinates, and then averages them as the sample value. Specifically, in bilinear filtering, one sampling requires four texels. Since the smallest working unit of a pixel shader is a 2*2 pixel quad (4 pixel blocks), when performing bilinear filtering, since each pixel block requires four texels, one mapping requires 2*2*4 = 16 texels. Therefore, for texel sampling of a pixel to be processed, 16 target texel requests need to be created.
[0048] Step S203: Based on preset rules, perform fusion processing on multiple target texel requests to obtain a texel request fusion table.
[0049] First, let's introduce the structure of the texture cache, which is... Figure 1 L1 cache in, such as Figure 3As shown, the size of the texture cache cache line and the minimum data transfer unit (block) between the cache and the next level of memory are determined by the designer. The relationship is: cache line size = n * block size, where n is an integer, meaning the cache line size is an integer multiple of the block size. Therefore, the texels required for a pixel quad may be distributed across different block sizes within a single cache line, requiring multiple block requests. A 2*2 pixel quad requires 16 texels, each of which needs a hit test on the cache, requiring 16 hit tests. If a miss occurs, a request is sent to the next level of memory. Taking a set-associative cache as an example, suppose the texture cache is 4KB, with a 128-byte line size and a 32-byte block size, for a total of 32 cache lines. Since the line size = 128 bytes = 4 * 32 bytes, each cache line consists of 4 blocks, denoted as B0 to B3. Because the next-level memory returns 1 block of data each time, each cache line uses a 4-bit block mask to record which blocks in the current cache line are needed. For example, block mask = 0x1 = (0001)2 indicates a request for B0, and block mask = 0x5 = (0101)2 indicates a request for both B0 and B2. 16 texels undergo 16 hit tests in the cache control, requiring 16 cycles. In the worst case, if a miss occurs in every hit test, 16 miss requests will be sent to the next-level memory, waiting for the next-level memory to return data one by one, which takes a long time and affects the texture sampling efficiency.
[0050] Specifically, in step S203, before each target texel request enters the texture cache for a hit, a fusion operation is performed on all 16 target texel requests sampled in this operation. This involves merging the block masks of multiple target texel requests located in the same cache line, ultimately forming a request set for hit testing. Since the texels required by a pixel quad have a high probability of being adjacent in the texture address, meaning they are likely in the same cache line (possibly in the same block or different blocks), this provides a basis for request merging. Therefore, this application organizes all the aforementioned target texel requests into a table—a texel request fusion table—and subsequently, multiple target texel requests can be simultaneously hit simply by querying the table for valid cache lines.
[0051] Step S204: Based on the valid cache rows in the texel request fusion table, perform cache hit tests on multiple target texel requests in sequence to obtain the target texel.
[0052] Specifically, based on the valid cache rows in the texel request fusion table, cache hit tests are performed sequentially on multiple target texel requests. Since the texels required by the pixel quad are highly likely to be adjacent in the texture address, meaning they are likely to be in the same cache line, possibly in the same block or in different blocks, performing a row-by-row hit test based on the already sorted valid cache rows in the texel request fusion table can reduce the number of hit tests and improve the texture sampling speed.
[0053] In the above embodiments, by creating and updating the texel request fusion table, target texel requests in the same cache line are fused together, reducing the number of cache hit tests. At the same time, for a large number of consecutive target texel requests, after the fusion operation, the pressure on the next level of memory to process texel requests can be significantly reduced, and the texture sampling speed can be improved.
[0054] In one embodiment, step S202 includes: calculating the texel coordinates of a plurality of target texels corresponding to the pixel coordinates; constructing a target texel request based on the texel coordinates; wherein each target texel request contains a target texel.
[0055] Among them, texel coordinates refer to the position coordinates of each texel in texel space.
[0056] Specifically, taking bilinear filtering (a texture sampling method) as an example, bilinear filtering centers on the texture coordinates corresponding to a pixel in the 3D scene to be processed. These texture coordinates are the coordinates of the pixel transformed to their corresponding coordinates on the texture buffer. The system samples the pixels surrounding these texture coordinates within a radius of four texels, then averages the results, using this average value as the sampled value. Specifically, in bilinear filtering, one sampling requires four texels. Since the smallest working unit of a pixel shader is a 2*2 pixel quad (four pixel blocks), during bilinear filtering, because each pixel block requires four texels, one mapping requires 2*2*4 = 16 texels. Therefore, sampling texels for a single pixel to be processed yields 16 target texel requests.
[0057] In the above embodiments, the texel coordinates of multiple target texels are calculated using pixel coordinates, and corresponding target texel requests are created, providing a computational basis for subsequent fusion processing.
[0058] In one embodiment, the texel request fusion table includes a cache line identifier and a next-level cache block mask; step S203 includes: calculating the texel identifier of the target texel in each target texel request; and writing multiple target texel requests into the texel request fusion table based on the comparison result between the texel identifier and the cache line identifier.
[0059] The texel tag is used to identify a texel. The cache line tag is used to uniquely identify each cache line.
[0060] Specifically, such as Figure 4 As shown, this embodiment requires maintaining a table to implement request merging. The number of rows is the same as the number of cache lines, let's say n = 32. An additional 32-bit `table_use_mask` is needed to indicate which rows in the table contain valid data. Each row in the table represents information for one cache line, containing two values: tag and block_mask. The block_mask is the number of blocks in the cache line that need to be stored in the next lower level, totaling 4 bits. Therefore, step S203 includes: for each texel entering the table, obtaining its tag; comparing its tag with the valid table lines in the table according to the `table_use_mask` to see if the tag already exists in the table; if it exists, updating the corresponding block mask; if it does not exist, occupying a new cache line in the table for writing the target texel request.
[0061] In the above embodiments, by creating a texel request fusion table and writing the target texel identifiers corresponding to multiple target texel requests into the table, since texels around the same pixel are very likely to be in the same block or the same row, this provides favorable conditions for improving the probability of subsequent hit testing.
[0062] In one embodiment, the texel request fusion table further includes a next-level cache block mask to be requested; step S203 further includes: based on the comparison result, if the texel identifier already exists in the texel request fusion table, then performing an OR operation between the cache block mask corresponding to the texel identifier and the next-level cache block mask to be requested, so that the target texel is written into the texel request fusion table. If the texel identifier does not exist in the texel request fusion table, then writing the cache block mask corresponding to the texel identifier into a new cache line and updating the texel request fusion table.
[0063] Specifically, the steps for request merging are as follows:
[0064] 1) For each texel entering the table, obtain its tag. Based on table_use_mask, compare its tag with the valid table lines in the table to see if the tag already exists in the table.
[0065] 2) If the tag already exists, perform an OR operation between the new texel block_mask and the existing table_block_mask in the table and write it to the table;
[0066] 3) If the tag does not exist, create a new line in the table, fill in the block_mask of the texel, and update table_use_mask;
[0067] 4) Repeat the above steps to add the item to the table for the next TeXEL request.
[0068] like Figure 5 As shown, Figure 5 A specific example is shown:
[0069] Texel 1: Since the table is empty, i.e., table_use_mask = 0x0, it occupies table_line_id = 1. Assuming its cache_tag = 0x1 and block_mask = (0001)2, update table_use_mask = 0x1;
[0070] Texel 2: Assume its tag = 0x2, block_mask = (0010)2; Since table_use_mask = 0x1, that is, the texel only needs to be compared with the content of table_line_id = 1, texel_tag = 0x2 ≠ table_cache_tag[1], then it cannot be merged, so the texel occupies a new line in the table, update table_line_id = 2, table_cache_tag[2] = 0x2, table_block_mask[2] = (0010)2, table_use_mask = 0x3;
[0071] Texel 3: Assume its tag = 0x2, block_mask = (0100)2; Compare with the valid lines in the table, and find that its tag is the same as the tag of table_line_id = 1, then merge the texel into the line, table_block_mask[1] = (0001)2|(0100)2 = (0101)2, table_use_mask remains unchanged;
[0072] The other texels are filled into the table in sequence.
[0073] The above embodiments, by maintaining and updating the texel request fusion table, provide favorable conditions for subsequently improving the probability of hit testing.
[0074] In one embodiment, step S204 includes: taking the cache line corresponding to the texel identifier containing the target texel as a valid cache line, and performing a hit test on each valid cache line in turn. If a hit occurs, the target texel is obtained. If a hit occurs, the cache block mask corresponding to the texel identifier containing the target texel is sent to the next-level cache space for a hit test.
[0075] Specifically, after merging 16 texels requests, a merge table is obtained. The number of valid lines in the table represents the number of hit tests performed on the cache. Valid lines in the table are hit-tested sequentially, and any table lines missed in the cache are sent to the next level of storage. Because quad texels are very likely to reside in the same cache line, or even the same block, the number of hit tests performed on merged texels requests will decrease, and the number of requests sent to the next level of storage will also decrease. Figure 5Taking three texels as an example, if the original texels request is not merged and preprocessed using the method of this invention, and is directly entered into the cache for hit testing, the three texels need to be hit tested three times. If all three miss, three requests need to be sent. Using the method of this invention, only two hit tests are needed when entering the cache, and only two requests need to be sent if all three miss.
[0076] In the above embodiments, by performing hit tests on the sorted target texel requests, since consecutive target texels are very likely to be in the same cache line, hit tests can be performed on a line-by-line basis, which can greatly reduce the number of tests and improve the texel sampling speed.
[0077] It should be understood that although the steps in the flowcharts of the embodiments described above 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 embodiments described above 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 of other steps.
[0078] Based on the same inventive concept, this application also provides a texture sampling device based on texel request fusion processing for implementing the texture sampling method based on texel request fusion processing described above. The solution provided by this device is similar to the implementation described in the above method. Therefore, the specific limitations of one or more texture sampling device embodiments based on texel request fusion processing provided below can be found in the limitations of the texture sampling method based on texel request fusion processing described above, and will not be repeated here.
[0079] In one embodiment, such as Figure 6 As shown, a texture sampling device 600 based on texel request fusion processing is provided, including: a texture sampling request creation module 601, a target texel request acquisition module 602, a texel request fusion table processing module 603, and a hit test module 604, wherein:
[0080] A texture sampling request creation module 601 is used to create a texture sampling request; the texture sampling request contains pixels to be processed.
[0081] The target texel request acquisition module 602 is used to obtain multiple target texel requests based on the pixel coordinates of the pixel to be processed.
[0082] The texture request fusion table processing module 603 is used to perform fusion processing on the multiple target texture requests based on preset rules to obtain a texture request fusion table.
[0083] The hit test module 604 is used to perform cache hit tests on the multiple target texel requests sequentially based on the valid cache rows in the texel request fusion table, so as to obtain the target texel.
[0084] In one embodiment, the target texel request acquisition module 602 is further configured to: calculate the texel coordinates of a plurality of target texels corresponding to the pixel coordinates based on the pixel coordinates; and construct a target texel request based on the texel coordinates; wherein each target texel request contains one target texel.
[0085] In one embodiment, the texel request fusion table includes a cache line identifier and a next-level cache block mask; the texel request fusion table processing module 603 is further configured to: calculate the texel identifier of the target texel in each target texel request; and write the plurality of target texel requests into the texel request fusion table based on the comparison result between the texel identifier and the cache line identifier.
[0086] In one embodiment, the texel request fusion table further includes a next-level cache block mask to be requested; the texel request fusion table processing module 603 is further configured to: based on the comparison result, if the texel identifier already exists in the texel request fusion table, perform an OR operation between the cache block mask corresponding to the texel identifier and the next-level cache block mask to be requested, so that the target texel is written into the texel request fusion table.
[0087] In one embodiment, the texel request fusion table processing module 603 is further configured to: if the texel identifier does not exist in the texel request fusion table, write the cache block mask corresponding to the texel identifier into a new cache line and update the texel request fusion table.
[0088] In one embodiment, the hit test module 604 is further configured to: take the cache line corresponding to the texel identifier containing the target texel as the valid cache line, perform a hit test on the valid cache line in sequence, and if a hit occurs, obtain the target texel.
[0089] In one embodiment, the hit test module 604 is further configured to: if missing, send the cache block mask corresponding to the texel identifier containing the target texel to the next level cache space for hit test.
[0090] Each module in the texture sampling device based on texel request fusion processing described above 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.
[0091] In one embodiment, a computer device is 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-described embodiment of the texture sampling method based on texel request fusion processing.
[0092] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above-described embodiment of the texture sampling method based on texel request fusion processing.
[0093] 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.
[0094] 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 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, etc., and are not limited to these.
[0095] 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 specification.
[0096] 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 method for texture sampling based on texel request coalesced processing, the method comprising: The method comprises: creating a texture sampling request; the texture sampling request contains a pixel to be processed; obtaining a plurality of target texel requests according to the pixel coordinates of the pixel to be processed; based on a preset rule, the plurality of target texel requests are fused to obtain a texel request fusion table; according to the valid cache line in the texel request fusion table, the plurality of target texel requests are sequentially tested for cache hit to obtain the target texel; the texel request fusion table contains a cache line identifier and a next level to be requested cache block mask; based on the preset rule, the plurality of target texel requests are fused to obtain a texel request fusion table, which comprises: for each target texel in the target texel request, calculate the texel identifier of the target texel; based on the comparison result of the texel identifier and the cache line identifier, if the texel identifier already exists in the texel request fusion table, the cache block mask corresponding to the texel identifier is operated with the next level to be requested cache block mask to make the target texel write into the texel request fusion table; if the texel identifier does not exist in the texel request fusion table, the cache block mask corresponding to the texel identifier is written into a new cache line, and the texel request fusion table is updated.
2. The method of claim 1, wherein, the plurality of target texel requests are obtained according to the pixel coordinates of the pixel to be processed, which comprises: according to the pixel coordinates, the texel coordinates of a plurality of target texels corresponding to the pixel coordinates are calculated; based on the texel coordinates, a target texel request is constructed; each target texel request contains one target texel.
3. The method of claim 1, wherein, according to the valid cache line in the texel request fusion table, the plurality of target texel requests are sequentially tested for cache hit to obtain the target texel, which comprises: the cache line containing the texel identifier of the target texel is taken as the valid cache line, and the valid cache line is sequentially tested for hit, and if hit, the target texel is obtained.
4. The method of claim 3, wherein, the method further comprises: if missing, the cache block mask containing the texel identifier of the target texel is sent to the next level cache space for hit test.
5. The method according to any one of claims 1 to 4, characterized in that, the texel identifier is used to identify a texel.
6. The method according to any one of claims 1 to 4, characterized in that, the cache line identifier is used to uniquely identify a cache line.
7. A texture sampling device based on texel request fusion processing, characterized in that, the device comprises: a texture sampling request creation module for creating a texture sampling request; the texture sampling request contains a pixel to be processed; a target texel request acquisition module for obtaining a plurality of target texel requests according to the pixel coordinates of the pixel to be processed; a texel request fusion table processing module for fusing the plurality of target texel requests based on a preset rule to obtain a texel request fusion table; a hit test module for sequentially testing the plurality of target texel requests for cache hit according to the valid cache line in the texel request fusion table to obtain the target texel; The texel request fusion table comprises a cache line identifier and a next-level to-be-requested cache block mask; and the texel request fusion table processing module is further configured to calculate a texel identifier of a target texel in each target texel request; based on a comparison result of the texel identifier and the cache line identifier, if the texel identifier already exists in the texel request fusion table, perform an or operation on the cache block mask corresponding to the texel identifier and the next-level to-be-requested cache block mask, so as to write the target texel into the texel request fusion table; if the texel identifier does not exist in the texel request fusion table, write the cache block mask corresponding to the texel identifier into a new cache line, and update the texel request fusion table.
8. The apparatus of claim 7, wherein, The target texel request obtaining module is further configured to calculate texel coordinates of a plurality of target texels corresponding to pixel coordinates according to the pixel coordinates; and construct a target texel request based on the texel coordinates; wherein each target texel request comprises one target texel.
9. The apparatus of claim 7, wherein, The hit test module is further configured to: take a cache line comprising a texel identifier of the target texel as the valid cache line, and sequentially perform a hit test on the valid cache line; if a hit is detected, the target texel is obtained.
10. The apparatus of claim 9, wherein, The hit test module is further configured to: if a miss is detected, send a cache block mask comprising the texel identifier of the target texel to a next-level cache space for a hit test.
Citation Information
Patent Citations
Modeling structure for storage cache of GPU compression textures
CN108022269A
Texture cache of embedded mobile graphics processor and processing method thereof
CN109118422A