Texture samplers and methods for implementing texture feedback
Patent Information
- Authority / Receiving Office
- TW · TW
- Patent Type
- Patents
- Current Assignee / Owner
- MOORE THREADS TECH CO LTD
- Filing Date
- 2025-01-02
- Publication Date
- 2026-08-01
AI Technical Summary
In GPUs, the inefficient loading of textures leads to increased memory usage due to the loading of textures that are not actually used, resulting in significant memory waste.
Implementing sampler feedback to provide the loading and usage status of each texture level, allowing the GPU to prioritize which textures and levels to load, using a texture sampler with a texture address processing module and filtering module to optimize texture loading.
This approach reduces unnecessary video memory usage and improves memory utilization by directly feeding back required texture coordinates and levels, enhancing operational efficiency.
Smart Images

Figure TWG2TB001903752_001 
Figure TWG2TB001903752_002 
Figure TWG2TB001903752_003
Abstract
Description
Texture samplers and methods for implementing texture feedback The present disclosure relates to a texture sampler for implementing texture feedback in a GPU (Graphics Processing Unit), and also to a method and program for implementing texture feedback. The original execution process within the GPU is that the internal processing module obtains the normalized coordinates sent by the upstream module, calculates the coordinates and texture level (mip level) of the corresponding texture space, obtains the color data of the corresponding texture coordinates from the video memory, and performs specified filtering calculations on the sampled texture color to obtain the final sampled color and return it. Finally, the color of the area that needs to be rendered is fully calculated and written to the video memory. This application claims priority to Chinese patent application No. 202410006128.2, filed on January 2, 2024, entitled “Texture Sampler and Method for Implementing Texture Feedback”, the entire contents of which are incorporated herein by reference. However, in the GPU, texture loading for tiled resources is dynamically updated, and the texture size may be very large. If many textures that are not actually used are loaded, the memory usage will be greatly increased. To solve the above problems, the present disclosure utilizes sampler feedback. Sampler feedback allows the GPU to provide the loading and usage status of each texture level of the texture when sampling the texture, and feeds back to the driver to help the driver know which textures and corresponding texture levels need to be loaded first when loading the texture next time. According to one aspect of the present disclosure, a texture sampler is proposed, including a texture address processing module and a texture filtering module, wherein the texture address processing module samples at least one group of texels in a level of the texture associated with a pixel, each group of texels including at least one texel, and the texture address processing module transmits the level information and coordinate information of the at least one group of texels to the texture filtering module; the texture filtering module sets a statistical block according to the level information and coordinate information, and counts an area of the size of the statistical block in the texture space each time, wherein the texture filtering module obtains the starting point of a group of texels in the at least one group of texels each time the statistical block is counted, so that the statistical block has the same starting point as the corresponding group of texels and the group of texels is included in the statistical block size, the texture filtering module performs at least one statistical operation, and each statistical operation returns the alignment block where the starting point of the statistical block is located and the position offset of the starting point of the statistical block relative to the starting point of the alignment block where it is located, and the alignment blocks are densely aligned in a manner that fills the texture space. According to another aspect of the present disclosure, a method for implementing texture feedback is provided, comprising the following steps: a texture shader issues a sampler feedback command to a texture sampler for returning the position of at least one group of texels in a level of a texture associated with a pixel; a texture address processing module of the texture sampler receives the sampler feedback command, samples at least one group of texels in the level, each group of texels including at least one texel, and transmits level information and coordinate information of the at least one group of texels to a texture filtering module of the texture sampler; the texture filtering module sets a statistics block based on the level information and coordinate information, and each time counts an area of the texture space having a size of the statistics block, wherein the texture filtering module obtains a starting point of a group of texels in the at least one group of texels during each statistics, so that the statistics block has the same starting point as a corresponding group of texels and the group of texels is included in the size of the statistics block; the texture filtering module performs statistics at least once, and each time returns to the texture shader the alignment block in which the starting point of the statistics block is located and a position offset of the starting point of the statistics block relative to the starting point of the alignment block in which the statistics block is located, wherein the alignment blocks are densely aligned to fill the texture space. The present disclosure also provides a program for implementing a texture sampler and texture feedback, and a computer-readable storage medium including the program. According to another aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by one or more processors, the computer program implements the above method. According to another aspect of the present disclosure, a chip is provided, which includes a programmable logic circuit and / or program instructions, and is used to implement the above method when the chip is running. According to another aspect of the present disclosure, a computer device is provided, comprising a processor and a memory, wherein a computer program is stored in the memory, and the computer program is loaded and executed by the processor to implement the above method. According to another aspect of the present disclosure, a computer program product is provided. The computer program product includes a computer program. The computer program is loaded and executed by a processor to implement the above method. According to the present disclosure, the efficiency of sampler feedback is improved, directly feeding back the required texture coordinates and corresponding texture level information, thereby avoiding unnecessary video memory usage and improving video memory utilization. Furthermore, according to the present disclosure, even when different texel sampling methods are used, the statistical information of the statistical block can be returned by simply reusing the sampler feedback command, while also reducing the number of additional returns and improving operational efficiency. The present disclosure proposes a solution for implementing texture sampler feedback in a GPU. FIG1 shows a schematic block diagram of a GPU in which sampler feedback is implemented. When a texture is sampled, in order to obtain the area of the texture actually used and the corresponding texture level based on the pixel, a sampler feedback is initiated by the shader, and feedback is implemented through the texture sampler with a certain number of pixels (for example, 1, 2, 3...8 or more) loop. The texture sampler calculates the associated address and texture size for each pixel, obtains information about the coordinates and texture level of the sampled texture, and feeds it back to the shader. In some embodiments, the sampler feedback can be an SMP. footprint command. FIG2 shows a schematic flow chart for implementing the above process. As shown in Figure 2, shader 1 issues a sampler feedback command to the texture sampler. Shader 1 loops, for example, in units of 8 pixels, issuing SMP.footprint commands to the texture sampler until all sampling points that require sampler feedback have been fed back. In some embodiments, the sampler feedback command of shader 1 may include the following information: normalized coordinates (u, v, s), specifying the requested increased texture space coordinate fineness (region_size), the texel group address and texel group subaddress (area_id, sub_area_id) associated with the pixel to be sampled, and the requested level of detail (lod), the position of the alignment block in the texture space of one level of the texture (blk_x, blk_y), the position offset of the statistics block starting point in the alignment block to be used for statistics on the texel group (region_offset), the position mask information of the sampled texel in the texture space (regions_mask), and the texel group position return count parameters (area_count, sub_area_count). Texels are also called texture elements, texture pixels, etc. An alignment block is a block of a specific size that is densely packed and aligned in a texture space at a specified coordinate fineness, such as in an increased coordinate fineness texture space, to fill the texture space. Such blocks are non-overlapping and have no gaps between them, thus covering all texels in the texture space. A statistics block is, for example, a block of a specific size used to perform statistics on groups of texels in the increased coordinate fineness texture space. The first texel of each group of texels can be used as the starting point of the texel group, and a texel refers to a unit texel in the increased coordinate fineness texture space. The size of the alignment block defines the number of texels sampled by the texture sampler at each time. In some embodiments, the alignment block size can be, for example, 8x4, the same size as the statistics block. Whenever at least one of the texels in the increased coordinate fineness texture space covered by the statistics block needs to be sampled, the corresponding position in the 8x4 statistics block is marked (mask = 1). In some embodiments, each time shader 1 receives feedback from a texture sampler, it determines whether the current eight pixels have been fully fed back based on the feedback result. If not, it continues to issue sampler feedback commands in a loop. Once the eight pixels have been fully fed back, shader 1 continues to issue sampler feedback commands for the next eight pixels until all pixels that require feedback have completed sampler feedback. In some embodiments, the shader 1 determines, based on parameters area_count and sub_area_count, whether the sampler has returned information about all texels associated with a pixel in at least one texture level for a pixel of interest. When feedback is performed a number of times corresponding to the number of times determined by the parameters area_count and sub_area_count, it is determined that information about all texels associated with the pixel in at least one texture level has been returned for the pixel of interest; otherwise, it is determined that information about all texels associated with the pixel has not been returned. Parameters area_count and sub_area_count are explained below. On the other hand, the texture sampler receives a command from shader 1, and the texture address processing module 2 of the texture sampler determines the sampled texel based on the sampling method. For example, based on the sampling method, the texture address processing module 2 can calculate the level of detail (LOD), obtain the lod_ratio based on the detail level, and determine at least one mip level (0, 1, 2, 3, etc.) of the texture associated with the pixel. For example, when the detail level lod is 0, there is one texture level associated with the pixel, and lod_ratio = 1. When the detail level lod is greater than 0, there are at least two texture levels associated with the pixel, for example, when lod = 0.3, lod_ratio = 2. For each level, the texture address processing module 2 can determine the texture space of the corresponding texture level based on the normalized coordinates sent by shader 1, and sample at least one group of texels associated with the pixel in the texture space, where each group of texels can include one or more texels. In some embodiments, the texture address processing module 2 may employ anisotropic filtering (AF). In this case, the texture address processing module 2 may perform anisotropic filtering on a pixel, sample multiple groups of texels associated with the pixel in the texture space, and calculate a parameter AF_ratio reflecting the number of times the texel addresses need to be returned due to the need to return multiple different texel groups due to anisotropic filtering. For example, in the case of anisotropic filtering, the texture address processing module 2 utilizes a sampling unit to sequentially sample multiple groups of texels, so that the addresses of the sampled texels can be determined and returned group by group. In addition, in some embodiments, if the texture address processing module 2 samples in a repeat address mode, it means that a group of texels associated with a pixel may be distributed at the corners of the texture due to the address mode. In this case, it is necessary to calculate the repeat_ratio, which reflects the number of returns required due to the need to obtain the address of the texel group at the corner of the texture multiple times. For example, in the case of a repeated edge, if the sampled texel group is distributed at the corner of the texture, it may be necessary to return the address of each group of texels at the corner separately. In addition, in some embodiments, the number of returns required to return the address of multiple groups of texels associated with pixels in at least one level of texture space can be counted, and the address information can be returned to the shader 1 one by one. The information reflecting the count can be (area_count, sub_area_count), where area_count can depend on, for example, lod_ratio and AF_ratio. Lod_ratio is determined by the level of detail (LOD). For example, when the level of detail (LOD) is 0, lod_ratio = 1; for example, when the level of detail (LOD) is 0.3, lod_ratio = 2. AF_ratio reflects the number of times the texel address needs to be returned due to anisotropic filtering. For example, when anisotropic filtering is not performed, AF_ratio is set to 1. When anisotropic filtering is performed, AF_ratio can be an integer greater than 1, such as AF_ratio = 8. Therefore, area_count can be expressed as area_count = lod_ratio × AF_ratio. For example, when lod_ratio = 1 and AF_ratio = 8, area_count = 8, and eight feedbacks are required for the sampled texel group in one level. sub_area_count reflects the number of times feedback is repeated for texels at each corner when sampling in a repeated edge manner is scattered at the corners of the texture, and a statistical block size cannot fully cover them. It can be expressed as, for example, sub_area_count = repeat_ratio. For example, when the sampled texels are scattered at the four corners of the texture space, sub_area_count = repeat_ratio = 4, and 4 feedbacks are required. When the number of feedbacks corresponding to the number of returns determined by the parameters area_count and sub_area_count is performed, information about all texels associated with the pixel in all texture levels is returned for a pixel of interest. Texel sampling in texture space can be completed for all levels of the texture associated with the pixel. In some embodiments, the texture sampler may also include a texture address resolution and decompression module 3. The texture address resolution and decompression module 3 directly transmits the coordinate information and address count information (area_count, sub_area_count) sampled by the texture address processing module 2 to the texture filtering module 4. The sampler feedback described here is for a single pixel. However, in actual applications, texture area coordinate information and count information for multiple pixels (e.g., 8 pixels) may need to be transmitted, requiring a large bandwidth. By using the texture address resolution and decompression module 3, the existing high-bandwidth interface between the texture address resolution and decompression module 3 and the texture address processing module 2 can be utilized to minimize interface modifications. The interface bandwidth between the texture address resolution and decompression module 3 and the texture filtering module 4 is also sufficient to transmit sampler feedback information for 8 pixels. Here, at least one group of texels associated with a pixel may be composed of all texels associated with the pixel, or may be composed of only some of the texels associated with the pixel. In other words, all texels associated with a pixel may be included in a group of texels, or may be included in multiple groups of texels in multiple texture levels. For example, one texel associated with a pixel may constitute a group of texels. For example, all texels associated with a pixel in a texture space at one level may constitute a group of texels. After the texture filtering module 4 receives the coordinate information and count information transmitted by the texture address resolution and decompression module 3, in order to return the position of the sampled texel to the shader 1, conventionally, in the texture space of each level associated with the pixel of the texture, the texels of the texture are counted one by one in the texture space with a certain block size as the unit size using the alignment blocks of the same size. Since the statistics of the alignment blocks in the texture space are performed in a dense manner covering the entire texture space, it is possible to determine the position of each alignment block in the texture space and the position of each texel in the alignment block. The texture filtering module 4 returns the position coordinates of the alignment block in which the sampled texel is counted, and returns the position corresponding to the sampled texel in the alignment block. For example, as shown in Figure 3, when the set of texels associated with a pixel is the four texels outlined in dark gray in texture space, in the related art, to count this set of texels using aligned blocks of, for example, 8×4 size, it is necessary to return information for each of the four aligned blocks: alignment block 0, alignment block 1, alignment block 2, and alignment block 3, including the block's position (e.g., block_x = 0, block_y = 0, block_x = 1, block_y = 0, block_x = 0, block_y = 1, block_x = 1, block_y = 1) and the position of the sampled texel within the block. These positions are represented, for example, by region mask information (region_mask) for each block. The region mask information indicates whether each counted texel in the block corresponds to the sampled texel. If so, the counted texel is marked as 1 ("mask = 1"). The region mask information is block-size dependent, e.g., 32 bits of data in the case of an 8×4 alignment block. The texture filtering module repeatedly returns the block information until it has returned the locations of all sampled texels in the hierarchy. However, in the above case, based on the related art, since each alignment block counts only one texel in a group of texels associated with a pixel, information of four alignment blocks needs to be returned, resulting in poor performance. Embodiments of the present disclosure avoid repeatedly returning to the sampled texel position for a group of texels associated with a pixel. For example, as shown in FIG4 , in the example above, the texture filtering module 4 of the present disclosure obtains the starting point of a group of texels associated with the pixel (in this example, four 2×2 texels, outlined in dark gray), determines the alignment block in which the starting point is located, and calculates the position offset of the starting point of the group of texels relative to the starting point of the alignment block. For example, in the example of FIG4 , the texture filtering module 4 first determines the alignment block in which the starting point of the 2×2 group of texels is located, with the starting point being the first texture point at the top left vertex of the four dark gray texels. In the example of FIG4 , the alignment block is an 8×4 block represented by the position block_x=0 and block_y=0. The texture filtering module 4 then calculates the position offset of the starting point of the 2×2 group of texels relative to the starting point of the alignment block (block_x=0, block_y=0), namely region_offset_x=7 and region_offset_y=3. On this basis, the texture filtering module 4 sets a statistical block of the same size as the alignment block, for example, 8×4. This statistical block is marked in light gray in Figure 4 and has the same starting point as a 2×2 group of texels. Here, the size of the statistical block is set to ensure that at least one group of texels is covered. For example, an 8×4 statistical block covers all four texels in a 2×2 group of texels. At this time, only the statistical block information with the starting point of the statistical block in the alignment block (block_x=0, block_y=0) with the starting point (0, 0) and the position offset (region_offset_x=7, region_offset_y=3) needs to be returned, which improves processing efficiency. Because the 8×4 statistics block is not block-aligned but contains position offset information, after receiving the pixel-associated texel position and area_count and sub_area_count parameters returned by texture filtering module 4, shader 1 calculates and restores the statistics block into four aligned 8×4 blocks. It then combines the region_mask of the four aligned blocks with the previous result through an OR operation and updates the position mask information of the four aligned blocks. After the statistics block information returned in Figure 4 is restored, as shown in Figure 5, the set of texels associated with the pixel is restored to the four aligned blocks in the texture hierarchy. Note that to more clearly illustrate the four restored alignment blocks, Figure 5 shows them separated by horizontal and vertical blanks. However, this is only to clearly illustrate the restored alignment blocks; in practice, the blocks are still aligned. Within each alignment block in Figure 5, a gray block labeled "1" indicates the texel associated with the pixel, indicating that the masked position of the texel associated with the pixel is set to 1 ("position mask = 1"). In some embodiments, shader 1 can also determine whether the current eight pixels require additional returns based on parameters such as area_count and sub_area_count returned by the texture sampler. If so, shader 1 loops and issues sampler feedback commands until all pixel feedback is complete before continuing to issue the next eight-pixel command. After all pixels in the current render target are calculated, shader 1 can, for example, update the level of the texture's original feedback map based on the calculation results at a set texture space coordinate granularity. For example, when the texture to be sampled is 128×128 in size and 16×16 in texture space coordinate fineness, the hierarchy of the original feedback map that the shader 1 needs to update is shown in FIG6 . Below, in the context of the aforementioned, a method for using a statistics block to return the positions of at least one set of texels associated with a pixel of a texture according to the present disclosure will be further described in detail with respect to a common texture sampling method. It should be noted that although shader 1 can issue sampler feedback commands to the texture sampler at a fineness of multiple pixels (e.g., a fineness of 8 pixels), for ease of description, this example is based on a single pixel; the process for other pixels is the same. In some embodiments, first, shader 1 sends a SMP.footprint command to the texture sampler for each pixel. An example of the command is as follows: SMP.footprint (t#id, s#id, u, v, s, expected_region_size, 0, 0) After receiving the SMP.Footprint command, Texture Address Processing Module 2 calculates the sampled texels and calculates the area_count and sub_area_count to determine the number of returns. This calculation is illustrated using one pixel as an example; the process for other pixels is the same. In some embodiments, the first sampling mode may include: no trilinear filtering, no anisotropic filtering (AF), and no repeated edges, as shown in FIG7 . Texture address processing module 2 calculates lod = 0, lod_ratio = 1, and AF_ratio = 1. area_count = lod_ratio × AF_ratio = 1, and sub_area_count = 0. Taking pixel p0 as an example, the four texels associated with pixel p0 in texture space (p0t0, p0t1, p0t2, and p0t3) to be sampled are obtained based on the UV coordinates. Their locations are marked in dark gray in Figure 7. The lod value, area_count, sub_area_count, and sampler feedback flag are sent to texture address resolution and decompression module 3. The texture address resolution and decompression module 3 transmits the sampler feedback data to the texture filtering module 4. After receiving this information, the texture filter module 4 obtains the starting point of the group of texels, determines the alignment block in which the starting point is located, and calculates the position offset of the starting point of the group of texels relative to the starting point of the alignment block. For example, in the case of Figure 7, the texture filter module 4 first determines the alignment block in which the starting point of the group of texels is located, namely, the top left vertex of the four dark gray texels. In the case of Figure 7, this alignment block is an 8×4 block represented by the position block_x=0, block_y=0. The texture filter module 4 then calculates the position offset (region_offset_x=7, region_offset_y=3) of the starting point of the group of texels relative to the starting point of the alignment block (block_x=0, block_y=0) (in Figure 7, (0, 0)). The texture filter module 4 further sets an 8×4 statistics block with the same starting point as the group of texels. The statistics block is marked in light gray in Figure 7 and includes the dark gray texel group. Texture filter module 4 sets a 32-bit position mask (region_mask) for the statistics block using a twiddle layout and returns it to shader 1 along with the starting point of the statistics block in the alignment block at position block_x=0, block_y=0 and the offset of the statistics block's starting point relative to the alignment block (region_offset_x=7, region_offset_y=3). The returned region_mask information for the statistics block is shown below: Therefore, since the statistical information of the statistical block can be returned by repeatedly utilizing the sampler feedback command, the number of additional returns is reduced, thereby improving the operating efficiency. In some embodiments, the second sampling mode may be: trilinear filtering, no anisotropic filtering, and no repeated edges, as shown in Figure 8. The command issued by shader 1 is as follows. SMP.footprint (t#id, s#id, u, v, s, expected_region_size, 0, 0) Texture address processing module 2 calculates lod = 0.3, lod_ratio = 2, and AF_ratio = 1. area_count = lod_ratio × AF_ratio = 2. Taking p0 as an example, with area_id = 0, the first-level texture space is retrieved based on the UV coordinates, obtaining the set of texels associated with pixel p0 (p0t0, p0t1, p0t2, p0t3) to be sampled. Their locations are marked in dark gray in Figure 8. Sub_area_count is calculated as 0. The lod value, area_count, sub_area_count, and sampler feedback flag are sent to texture address resolution and decompression module 3. The texture address parsing and decompression module 3 transparently transmits the received data to the texture filtering module 4 . After receiving this information, texture filter module 4 uses a method similar to the first sampling method to determine the starting point of the group of texels, determine the alignment block in which the starting point is located, and calculate the position offset of the starting point of the group of texels relative to the starting point of the alignment block (region_offset_x=7, region_offset_y=3). Based on this, texture filter module 4 sets an 8×4 statistics block with the same starting point as the group of texels. In Figure 8, the statistics block is marked in light gray and includes the dark gray texel group. Based on the rotated layout, 32-bit position mask information is calculated and returned to shader 1 along with area_count=2, the starting point of the statistics block being located in the determined alignment block, and the position offset of the starting point of the statistics block relative to the starting point of the alignment block. When shader 1 receives area_count=2 when area_id=0, it means that additional block information needs to be returned for the current pixel, and shader 1 will issue the command with area_id=1 again. SMP.footprint (t#id, s#id, u, v, s, expected_region_size, 1, 0) When area_id = 1, texture address processing module 2 calculates lod = 0.3, lod_ratio = 2, and AF_ratio = 1. Area_count = lod_ratio × AF_ratio = 2. Taking p0 as an example, where area_id = 1, the module retrieves the set of texels (p0t0, p0t1, p0t2, p0t3) associated with pixel p0 in the second-level texture space that need to be sampled based on the UV coordinates. These are marked in dark gray in Figure 9. Sub_area_count is calculated to be 0. The lod value, area_count, sub_area_count, and sampler feedback flag are sent to texture address resolution and decompression module 3, as shown in Figure 9. The texture address parsing and decompression module 3 transparently transmits the received data to the texture filtering module 4 . After receiving this information, texture filter module 4 obtains the starting point of the group of texels (outlined in dark gray) in the second-level texture space, determines the alignment block in which the starting point is located, and calculates the position offset of the starting point of the group of texels relative to the starting point of the alignment block (region_offset_x=3, region_offset_y=1). Texture filter module 4 further sets an 8×4 statistics block in the second-level texture space that has the same starting point as the group of texels. In Figure 9, the statistics block is outlined in light gray and includes the dark gray texel group. Based on the rotated layout, 32-bit position mask information is calculated and returned to shader 1 along with area_count=2, the starting point of the statistics block within the determined alignment block, and the position offset of the statistics block's starting point relative to the determined alignment block. Therefore, since the statistical information of the statistical block can be returned by repeatedly utilizing the sampler feedback command, the number of additional returns is reduced, thereby improving the operating efficiency. In some embodiments, the third sampling mode may be: repeated edges, no trilinear filtering, and no anisotropic filtering, as shown in Figure 10. The command issued by shader 1 is as follows. SMP.footprint (t#id, s#id, u, v, s, expected_region_size, 0, 0) When area_id = 0, texture address processing module 2 calculates lod = 0, lod_ratio = 1, AF_ratio = 1, and area_count = lod_ratio × AF_ratio = 1. For example, with area_id = 0, the texture hierarchy retrieves the set of texels (p0t0, p0t1, p0t2, p0t3) associated with pixel p0 that needs to be sampled based on the uv coordinates. Since (t1.u - t0.u > 8) && (t2v - t0.v > 4) for p0, as shown in Figure 10, the current set of texels is located at the corner of the texture and is distributed across four different 8×4 statistical blocks. A single statistical block cannot cover this, so each texel in the set must be counted as a group. Therefore, three additional statistical block information is returned, with sub_area_count = 3. Texture address processing module 2 determines that sub_area_count = 3 and sub_area_id = 0. It then sends the UV coordinates of p0t0, resets the coordinates of p0t1 / p0t2 / p0t3 to 0, and sends the area_count, sub_area_count, and sampler feedback flag to texture address resolution and decompression module 3. Figure 10 shows the texel distribution. The texture address parsing and decompression module 3 transparently transmits the received data to the texture filtering module 4 . After receiving this information, texture filter module 4 sets the single texel p0t0 to a group of texels, which is outlined in dark gray in Figure 10. Texture filter module 4 obtains the starting point of texel p0t0, determines the alignment block in which the starting point is located (an 8×4 block (block_x=0, block_y=0) with a starting point at (0, 0) in Figure 10), and calculates the position offset of the starting point of texel p0t0 relative to the starting point of the alignment block. As shown in Figure 10, the position offsets region_offset_x and region_offset_y are both 0. Texture filter module 4 further sets 8×4 statistics block 0, which has the same starting point as texel p0t0 and is outlined in light gray in Figure 10, to include texel p0t0. Calculate the 32-bit position mask information according to the rotated layout, and return area_count=1, sub_area_count=3 and the position mask information together with the starting point of statistics block 0 in the alignment block (block_x=0, block_y=0) with the starting point of (0, 0) and the position offset of the starting point of statistics block 0 relative to the starting point of the alignment block to shader 1. When shader 1 receives area_count = 1 and sub_area_count = 3 when area_id = 0, shader 1 will issue commands for sub_area_id = 1, 2, and 3 again. In this case, similar operations are performed on each of the remaining three groups of texels, p0t1, p0t2, and p0t3, as for p0t0. For example, when sub_area_id = 1, texture filtering module 4 obtains the starting point of texel p0t1, determines the alignment block in which the starting point is located (the 8×4 block (block_x = 1, block_y = 0) with (8, 0) as the starting point in Figure 10), and calculates the position offset of the starting point of texel p0t1 relative to the starting point of the alignment block. As shown in Figure 10, the position offsets are region_offset_x = 7 and region_offset_y = 0. Texture filter module 4 further sets an 8×4 statistics block 1 with the same starting point as texel p0t1 (outlined in light gray in FIG. 10 ) and includes texel p0t1 therein. Texture filter module 4 then returns position mask information, information indicating that statistics block 1's starting point is within an alignment block (block_x=1, block_y=0) with a starting point at (8, 0), and a position offset of statistics block 1's starting point relative to the starting point of the alignment block to shader 1. When sub_area_id=2, texture filter module 4 obtains the starting point of texel p0t2, determines the alignment block in which the starting point is located (the 8×4 block (block_x=0, block_y=1) with a starting point at (0, 4) in FIG. 10 ), and calculates the position offset of texel p0t2's starting point relative to the starting point of the alignment block. As shown in FIG. 10 , the position offsets region_offset_x=0 and region_offset_y=3 are shown. Texture filter module 4 further sets up an 8×4 statistics block 2 with the same starting point as texel p0t2 (outlined in light gray in Figure 10) and including texel p0t2. Texture filter module 4 then returns the position mask information, the fact that the starting point of statistics block 2 is within the alignment block (block_x=0, block_y=1) with a starting point at (0, 4), and the position offset of the starting point of statistics block 2 relative to the starting point of the alignment block to shader 1. When sub_area_id=3, texture filter module 4 obtains the starting point of texel p0t3, determines the alignment block in which the starting point is located (the 8×4 block (block_x=1, block_y=1) with a starting point at (8, 4) in Figure 10), and calculates the position offset of the starting point of texel p0t3 relative to the starting point of the alignment block. As shown in Figure 10, the position offsets are region_offset_x=7 and region_offset_y=3.Texture filtering module 4 further sets statistics block 3, which has the same starting point as texel p0t3 and is marked in light gray in FIG10 and includes texel p0t3, and returns position mask information, the starting point of statistics block 3 in the alignment block (block_x=1, block_y=1) starting at (8, 4), and the position offset of the starting point of statistics block 3 relative to the starting point of the alignment block to shader 1. In this way, by simply returning information about the starting points of four statistics blocks 0-3 within the corresponding four alignment blocks and the four statistics blocks 0-3 with the position offsets relative to the starting points of the corresponding alignment blocks, the position information of all texels associated with pixel p0 can be provided. When repeated edges appear, the texture address processing module 2 will set the required sub_area_count and the texel coordinates that need to be issued for the current sub_area_id according to the interval of the texture coordinates. Table 1 below shows the coordinate issuance order of the texture address processing module 2 at different sub_area_counts. Table 1 Since the statistical information of the statistical block can be returned by repeatedly using the sampler feedback command, the number of additional returns can be reduced and the operation efficiency is improved. In some embodiments, the fourth sampling mode may be: repeated edges, trilinear filtering, and no anisotropic filtering. The command issued by shader 1 is as follows. SMP.footprint (t#id, s#id, u, v, s, expected_region_size, 0, 0) When area_id = 0, texture address processing module 2 calculates lod = 0.3, lod_ratio = 2, AF_ratio = 1, and area_count = lod_ratio × AF_ratio = 2. For example, with area_id = 0, texture address processing module 2 obtains the set of texels (p0t0, p0t1, p0t2, p0t3) associated with pixel p0 in the first-level texture space to be sampled based on the UV coordinates. Since (t1.u - t0.u > 8) && (t2v - t0.v > 4) for p0, sub_area_count = 3. Based on sub_area_count and sub_area_id, the corresponding texel address, area_count, sub_area_count, and sampler feedback flag are sent to texture address resolution and decompression module 3. The texture address parsing and decompression module 3 transparently transmits the received data to the texture filtering module 4 . Upon receiving this information, texture filter module 4 sets the single texel p0t0 into a group of texels, similar to the case shown in Figure 10 (outlined in dark gray). Texture filter module 4 then obtains the starting point of texel p0t0, determines the alignment block in which the starting point lies, and calculates the position offset of texel p0t0's starting point relative to the start of the alignment block. It then sets 8×4 statistics block 0, which has the same starting point as texel p0t0 (outlined in light gray, similar to the case shown in Figure 10), and includes texel p0t0. It then calculates 32-bit position mask information based on the rotated layout and returns it to shader 1 with area_count = 1, sub_area_count = 3, and the position mask information, along with the starting point of statistics block 0 within the alignment block (block_x = 0, block_y = 0) with a starting point of (0, 0) and the position offset of the starting point of statistics block 0 relative to the start of the alignment block. The processing for the remaining texels is the same as in the third sampling method. When shader 1 receives area_count=2, sub_area_count=3 returned when area_id=0, shader 1 will send commands with sub_area_id=1, 2, 3 again. SMP.footprint (t#id, s#id, u, v, s, expected_region_size, 0, 1) SMP.footprint (t#id, s#id, u, v, s, expected_region_size, 0, 2) SMP.footprint (t#id, s#id, u, v, s, expected_region_size, 0, 3) When sub_area_id = 1, 2, or 3, because area_id = 0, texture address processing module 2 behaves the same as if area_id = 0, selecting and distributing coordinates in the first-level texture space based on sub_area_id. After receiving the coordinates, texture filtering module 4 determines the alignment block where the texel's starting point is located, calculates the position offset of the starting point relative to the alignment block's starting point, sets a statistics block with the same starting point as the texel's starting point, and returns the starting point of the statistics block within the determined alignment block, the position offset of the statistics block's starting point relative to the alignment block's starting point, and position mask information to shader 1. When sub_area_id=sub_area_count, shader 1 will jump out of the loop and continue to send the next area_id. SMP.footprint (t#id, s#id, u, v, s, expected_region_size, 1, 0) When area_id = 1 and sub_area_id = 0, texture address processing module 2 calculates the coordinates of the second-level texture space and calculates sub_area_count = 0. Texture address processing module 2 then issues the coordinates and lod value for the second-level texture space. The coordinate distribution is shown in Figure 11. The set of texels (p0t0, p0t1, p0t2, p0t3) associated with the pixel in the second-level texture space are marked in dark gray in Figure 11. Texture filter module 4 receives this information, sets the single texel p0t0 as a group of texels, obtains the starting point of texel p0t0 (outlined in dark gray) in the second-level texture space, determines the alignment block in which the starting point lies, and calculates the offset of the starting point of texel p0t0 relative to the starting point of the alignment block (as shown in Figure 11, region_offset_x and region_offset_y are both 0). Texture filter module 4 further sets an 8×4 statistics block in the second-level texture space that has the same starting point as the group of texels. In Figure 11, the statistics block is outlined in light gray and includes texel p0t0. In this case, even if the other texels p0t1, p0t2, and p0t3 are distributed in the corners of the texture, since the 8×4 statistical block can cover all texels p0t0, p0t1, p0t2, and p0t3, only one statistical block of information needs to be returned, including the starting point of the statistical block in the determined alignment block and the position offset of the starting point of the statistical block relative to the starting point of the alignment block. 32-bit position mask information is calculated based on the rotated layout and returned to shader 1 along with area_count=2 and the determined statistical block information. Therefore, since the statistical information of the statistical block can be returned by repeatedly utilizing the sampler feedback command, the number of additional returns is reduced, thereby improving the operation efficiency. In some embodiments, the fifth sampling mode may be: repeated edges, anisotropic filtering, and no trilinear filtering, as shown in Figure 12. The command issued by shader 1 is as follows. SMP.footprint (t#id, s#id, u, v, s, expected_region_size, 0, 0) When area_id = 0, texture address processing module 2 calculates lod_ratio = 1, AF_ratio = 8x, and area_count = lod_ratio × AF_ratio = 8. For example, for area_id = 0, texture address processing module 2 first calculates p0s0 for the set of texels sampled by sampling unit s0 in texture space, and calculates sub_area_count = 0. Texture address processing module 2 sends the calculated texels, area_count, sub_area_count, and sampler feedback flag to texture address resolution and decompression module 3. The coordinate distribution is shown in Figure 12. The texture address resolution and decompression module 3 transmits the sampler feedback data to the texture filtering module 4. After receiving this information, texture filter module 4 obtains the starting point of texel group p0s0, determines the 8×4 aligned block (starting at (0, 0)) in which the starting point is located, and calculates the position offset of the starting point of texel group p0s0 relative to the starting point of the aligned block (region_offset_x=3, region_offset_y=2). Texture filter module 4 further sets an 8×4 statistics block with the same starting point as texel group p0s0, which includes texel group p0s0. Texture filter module 4 calculates 32-bit position mask information based on the rotated layout and returns it to shader 1 along with area_count=8 and sub_area_count=0, along with the starting point of the statistics block in the aligned block starting at (0, 0) and the position offset of the statistics block's starting point relative to the starting point of the aligned block. When shader 1 receives area_count=8 returned when area_id=0, shader 1 will send area_id=1, 2, 3, 4, 5, 6, 7 again. SMP.footprint (t#id, s#id, u, v, s, expected_region_size, 1-6, 0) When area_id=1, 2, 3, 4, 5, 6, the texture address processing module 2 calculates the texels sampled by each sampling unit s1, s2, s3, s4, s5, s6 in turn and sends them to the texture filtering module 4. The texture filtering module 4 determines the position offset of the corresponding alignment block and the 8×4 statistical block and returns area_count=8. SMP.footprint (t#id, s#id, u, v, s, expected_region_size, 7, 0) When area_id = 7, due to the presence of repeated edges (sampled texels exist at the leftmost and rightmost edges of Figure 12), the texel p0s7 sampled by sampling unit s7 of texture address processing module 2 includes two groups of texels, namely one group of texels at the left edge of Figure 12 and one group of texels at the right edge. In this case, sub_area_count is calculated to be 1, and area_count = 8. Texture address processing module 2 first calculates the first group of texels based on sub_area_id and sub_area_count, and sends it along with area_count, sub_area_count, and sampler feedback flag to texture address resolution and decompression module 3 and texture filtering module 4. After receiving this information, texture filter module 4 obtains the starting point of the first group of texels in p0s7, determines the alignment block in which the starting point is located (starting at (24, 0)), and calculates the position offset of the starting point of the first group of texels relative to the starting point of the alignment block (region_offset_x=0, region_offset_y=2). Texture filter module 4 further sets an 8×4 statistics block with the same starting point as the first group of texels, calculates 32-bit position mask information based on the rotated layout, and returns this information to shader 1 along with area_count=8 and sub_area_count=0, along with the starting point of the statistics block in the alignment block starting at (24, 0) and the position offset of the starting point of the statistics block relative to the starting point of the alignment block (region_offset_x=0, region_offset_y=2). When shader 1 receives sub_area_count>0, it will issue the command again. SMP.footprint (t#id, s#id, u, v, s, expected_region_size, 7, 1) In response to the received instruction, texture filter module 4 obtains the starting point of the second group of texels in p0s7, determines the alignment block in which the starting point is located (with (0, 0) as the starting point), and calculates the position offset of the starting point of the second group of texels relative to the starting point of the alignment block (region_offset_x=0, region_offset_y=2). Texture filter module 4 further sets an 8×4 statistics block with the same starting point as the second group of texels. In a similar manner to the first group of texels in p0s7, it returns the starting point of the statistics block in the alignment block with the starting point (0, 0) and the position offset of the starting point of the statistics block relative to the starting point of the alignment block (region_offset_x=0, region_offset_y=2), and then terminates the process. Therefore, since the statistical information of the statistical block can be returned by repeatedly utilizing the sampler feedback command, the number of additional returns can be reduced, thereby improving the operation efficiency. As described above, after completing the sampler feedback command SMP.footprint for all pixels, shader 1 updates the original feedback map level of each texture level. The updated result is shown in Figure 13. By providing this result to the driver, texture loading can be optimized. In addition, if a minimum mipmap level needs to be generated based on this, the minimum mipmap level of the texture can be generated through the GenerateMinmap function. The result is shown in Figure 14. It is noted that although the above description uses an alignment block and a statistical block with a size of 8×4 as an example, it is clear to those skilled in the art that such a size is only an example and any alignment block and statistical block size such as 4×4, 4×6, 5×5, 6×6, 6×8, 8×8, etc. can be used, as long as such a size can cover a set of texels in the texture space. In addition, according to the aforementioned third to fifth sampling methods, even if the texels associated with the pixels are discrete, the statistics of the sampled texels can be efficiently completed using the embodiments of the present disclosure. Figure 15 is a flowchart illustrating an example of using a statistics block to return the locations of sampled texels according to the present disclosure. As shown in Figure 15 , at step 1501, the texture shader 1 issues a sampler feedback command to the texture sampler, requesting the return of the locations of at least one group of texels in a level of texture space associated with a pixel. At step 1502, the texture address processing module 2 of the texture sampler receives the sampler feedback command and samples at least one group of texels in the texture space, each group of texels comprising at least one texel. The texture address processing module 2 then transmits the level information and coordinate information of the at least one group of texels to the texture filtering module 4. At step 1503, the texture filtering module 4 sets a statistics block based on the level information and coordinate information, each time counting an area of the texture space equal to the size of the statistics block. At step 1504, the texture filtering module 4 obtains the starting point of one of the at least one group of texels, ensuring that the statistics block has the same starting point as the corresponding group of texels and that the group of texels is included within the size of the statistics block. In 1505, the texture filtering module 4 performs statistics at least once, and each time the statistics are returned to the texture shader, indicating in which alignment block the starting point of the statistics block is located in the densely aligned alignment blocks in the texture space, and the position offset of the starting point of the statistics block relative to the starting point of the alignment block in which it is located, completing the statistics of all sampled texels in the texture space and returning the texel position to the shader 1. In addition, for example, after the shader 1 confirms that the sampling of the current level of the texture is completed, similar processing as described above can be performed on other levels of the texture associated with the pixels to complete the sampling at all texture levels. In addition, for example, as described above for the texture address processing module 2 and the texture address sampler 4, different sampling methods such as anisotropic filtering, repeated edges and trilinear filtering can be used when sampling the texture, and statistics are performed on the addresses of multiple groups of texels obtained under different sampling methods. Needless to say, the details described for the device embodiment of the present disclosure are also applicable to the embodiments of the method for implementing the present disclosure. In one or more examples, the functions described may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored on or transmitted over a computer-readable medium as one or more commands, instructions, or code and executed by a hardware-based processing unit. Computer-readable media may include computer-readable storage media, which corresponds to tangible media such as data storage media, or communication media, which includes, for example, any medium that facilitates the transfer of a computer program from one place to another according to a communication protocol. In this manner, computer-readable media may generally correspond to (1) tangible, non-transitory computer-readable storage media, or (2) communication media such as signals or carrier waves. Data storage media may be any available medium that can be accessed by one or more computers or one or more processors to retrieve instructions, codes, and / or data structures for implementing the implementations described in this application. A computer program product may include computer-readable media. In addition, the present disclosure also provides a chip including programmable logic circuits and / or program instructions, which, when executed, implement the above method. Optionally, the chip may be a GPU chip or a graphics card. In addition, an embodiment of the present disclosure further provides a computer device, which includes a processor and a memory, wherein a computer program is stored in the memory, and the computer program is loaded and executed by the processor to implement the above method. In addition, an embodiment of the present disclosure further provides a computer program product, which includes a computer program, and the computer program is loaded and executed by a processor to implement the above method. The terms used in the description of the implementations herein are for the purpose of describing a particular implementation only and are not intended to limit the scope of the claims. As used in the description of the implementations and the accompanying claims, "a", "an", "the", and "said" are also intended to include both the singular and the plural, unless the context clearly indicates otherwise. It will also be understood that the terms "and / or" as used herein refer to and encompass any and all possible combinations of one or more associated listed items. It will be further understood that the terms "comprises" and / or "comprising" when used in this specification specify the presence of stated features, elements, and / or elements, but do not exclude the presence or addition of one or more other features, elements, elements, and / or groups thereof. The description of the present application is provided for the purpose of illustration and description, and is not intended to be exhaustive or to limit the present disclosure to the disclosed form. With the benefit of the teachings presented in the foregoing description and the associated drawings, many modifications, variations and alternative implementations will be apparent to those of ordinary skill in the art. The embodiments are selected and described in order to best explain the principles and practical applications of the present disclosure, and to enable other persons skilled in the art to understand the present disclosure for various implementations, and to best utilize the underlying principles and various implementations with various modifications when suitable for the specific purposes intended. Therefore, it is to be understood that the scope of the claims is not limited to the specific examples of the disclosed implementations, and modifications and other implementations are intended to be included within the scope of the appended claims. 1: Shader 2: Texture address processing module 3: Texture address parsing and decompression module 4: Texture filtering module 5: Texture sampler 1501: 1502: 1503: 1504: 1505: FIG1 schematically illustrates a schematic block diagram of a GPU for implementing sampler feedback; FIG2 schematically illustrates a schematic flow chart for implementing texture feedback according to the present disclosure; FIG3 schematically illustrates a block distribution of sampled texels returned in a conventional manner; FIG4 schematically illustrates a block distribution of sampled texels returned according to the present disclosure; FIG5 schematically illustrates a block distribution restored in a position-aligned manner; FIG6 schematically illustrates different levels of an original feedback map to be updated for a sampled texture; FIG7 schematically illustrates a distribution of statistic blocks under a first sampling scheme; FIG8 and FIG9 schematically illustrate a distribution of statistic blocks under a second sampling scheme; FIG10 schematically illustrates a distribution of statistic blocks under a third sampling scheme; FIG11 schematically illustrates a distribution of statistic blocks under a fourth sampling scheme; FIG12 schematically illustrates a distribution of statistic blocks under a fifth sampling scheme; and FIG13 schematically illustrates different levels of an original feedback map for an example update of a sampled texture. FIG14 schematically shows a diagram of an example minimum primitive feedback map of a sampled texture; FIG15 schematically shows a flow chart of a method for implementing texture feedback according to an embodiment of the present disclosure. 1: Shader 5: Texture Sampler
Claims
1. A texture sampler, comprising a texture address processing module and a texture filtering module; the texture address processing module samples at least one set of texels associated with pixels in a texture layer, each set of texels including at least one texel, the texture address processing module transmitting layer information and coordinate information of the at least one set of texels to the texture filtering module; the texture filtering module sets a statistical block based on the layer information and the coordinate information, and statistically analyzes a region of size sized by the statistical block in the texture space each time; wherein, Each time the texture filtering module performs a statistical analysis, it obtains the starting point of a group of texels from the at least one group of texels, so that the statistical block has the same starting point as the corresponding group of texels and the group of texels is included within the size of the statistical block. The texture filtering module performs at least one statistical analysis, and each statistical analysis returns the alignment block where the starting point of the statistical block is located and the position offset of the starting point of the statistical block relative to the starting point of the alignment block. The alignment blocks are densely aligned in a manner that fills the texture space. The statistical block is a block of a specific size used to perform statistical analysis on the group of texels.
2. The texture sampler as described in claim 1, wherein, All texels associated with a pixel are included in a set of texels.
3. The texture sampler as described in claim 1 or 2, wherein, The texture address processing module samples using anisotropic filtering, trilinear filtering, or a combination of both.
4. The texture sampler as described in claim 3, wherein, The texture address processing module samples in a repeating edge manner.
5. The texture sampler as described in claim 4, wherein, The at least one set of texels is included in the texel group at the corner of the texture.
6. The texture sampler as described in claim 5, wherein, The number of times the texture filtering module returns the statistical block information is determined by at least one of edge repetition, anisotropic filtering, and trilinear filtering.
7. The texture sampler as described in claim 6, wherein, The level is one of at least one levels of the texture associated with the pixel, which is determined by the texture address processing module using trilinear filtering.
8. The texture sampler as described in claim 7, wherein, The texture address processing module instructs the texture filtering module to return the statistical block information for the at least one level.
9. The texture sampler as described in claim 8, wherein, The texture sampler also includes a texture address parsing and decompression module, which receives notifications and instructions from the texture address processing module and passes them through to the texture filtering module.
10. A texture shader that issues a sampler feedback command to a texture sampler according to any one of claims 1 to 9, the texture sampler feedback command causing the texture sampler to return location information of a set of texels associated with a pixel in a texture space, the texture shader repeatedly issuing the texture sampler feedback command to obtain coordinates of the texels associated with the pixel in the texture space at at least one level of the texture, and using these coordinates to update at least one level of an original feedback map of the texture.
11. The texture shader as described in claim 10, wherein, The at least one original feedback mapping level is obtained by increasing the texture space coordinate subtlety of the corresponding texture level by a specified ratio.
12. A method for implementing texture feedback, comprising the following steps: a texture shader issues a sampler feedback command to a texture sampler for returning the positions of at least one set of texels associated with a pixel in a layer of the texture; the texture sampler's texture address processing module receives the texture sampler feedback command, samples at least one set of texels in the layer, each set of texels including at least one texel, and the texture address processing module transmits the layer information and coordinate information of the at least one set of texels to the texture sampler's texture filtering module; The texture filtering module sets up a statistical block based on the hierarchical information and the coordinate information. Each time, the region of the statistical block size in the texture space is statistically analyzed. Each time the texture filtering module performs the statistical analysis, it obtains the starting point of a group of texels in the at least one group of texels, so that the statistical block has the same starting point as the corresponding group of texels and the group of texels is included within the size of the statistical block. The texture filtering module performs at least one statistical analysis. Each time, the module returns to the texture shader the alignment block where the starting point of the statistical block is located and the position offset of the starting point of the statistical block relative to the starting point of the alignment block. The alignment blocks are densely aligned in a manner that fills the texture space. The statistical block is a block of a specific size used to perform statistical analysis on the group of texels.
13. The method as described in claim 12, wherein, The texture address processing module samples all texels associated with a pixel into a set of texels.
14. The method as described in claim 12 or 13, wherein, The texture address processing module samples using anisotropic filtering, trilinear filtering, or a combination of both.
15. The method as described in claim 14, wherein, The texture address processing module samples in a repeating edge manner.
16. The method as described in claim 15, wherein, The at least one set of texels is included in the texel group at the corner of the texture.
17. The method as described in claim 16, wherein, The texture address processing module determines the number of times it returns the statistical block information based on at least one of edge repetition, anisotropic filtering, and trilinear filtering.
18. The method as described in claim 17, wherein, The level is one of at least one levels of the texture associated with the pixel, and the texture address processing module determines the at least one level of the texture associated with the pixel by sampling in a trilinear filtering manner.
19. The method as described in claim 18, wherein, The texture sampler's texture address parsing and decompression module receives notifications and instructions from the texture address processing module and passes them through to the texture filtering module.
20. A computer-readable storage medium having a computer program stored thereon that, when executed by one or more processors, implements a method for implementing texture feedback according to any one of claims 12 to 19.
21. A chip including programmable logic circuitry and / or program instructions, when the chip is in operation, for implementing a method for implementing texture feedback as described in any one of claims 12 to 19.
22. A computer device including a processor and memory storing a computer program loaded and executed by the processor to implement a method for implementing texture feedback as described in any one of claims 12 to 19.
23. A computer program product comprising a computer program loaded by a processor and executed to implement a method for implementing texture feedback as described in any one of claims 12 to 19.