Texture samplers and methods for implementing texture feedback
By introducing a sampler feedback mechanism in the GPU, the problem of high memory usage due to texture loading is solved, and more efficient memory utilization and operation efficiency is achieved.
Patent Information
- Application Number
- CN202410006128.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-02
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-01-02
AI Technical Summary
In GPU, the loading of textures is dynamically updated, and the texture size may be very large. If many textures that are not actually used are loaded, it will greatly increase the memory usage.
The Sampler Feedback mechanism allows the GPU to feedback the loading usage of each level of the texture when sampling the texture, helping drive the optimization of priority when loading the texture next time.
It effectively avoids unnecessary video memory usage, improves the utilization rate of video memory, and improves the operation efficiency.
Smart Images

Figure CN118096847B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to a texture sampler that implements texture feedback in a GPU (Graphics Processing Unit), and also to a method and program for implementing texture feedback. Background Art
[0002] The original execution process inside 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 colors to obtain the final sampled color and return it. Finally, the colors of the area that needs to be rendered are all calculated and written to the video memory. Summary of the invention
[0003] However, in the GPU, the loading of textures for tiled resources is dynamically updated, and the texture size may be very large. If a lot of textures that are not actually used are loaded, the occupancy rate of the video memory will be greatly increased.
[0004] To solve the above problem, the present disclosure utilizes sampler feedback, which allows the loading and usage status of each texture level of the texture when the GPU texture is sampled, 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.
[0005] 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 includes 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 each time counts an area of the statistical block size in the texture space, wherein the texture filtering module obtains a starting point of one of the at least one group of texels each time it counts, 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 statistics, and each time the statistics returns in which alignment block 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 in which it is located, and the alignment blocks are densely aligned in a manner of filling the texture space.
[0006] According to another aspect of the present disclosure, a method for implementing texture feedback is provided, characterized in that it includes the following steps: a texture shader issues a position sampler feedback command for returning at least one group of texels in a level of the texture associated with a pixel to a texture sampler; 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 includes 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 a texture filtering module of the texture sampler; the texture filtering module sets a statistical block according to the level information and the coordinate information, and each time counts an area of the statistical block size in the texture space, wherein the texture filtering module obtains a starting point of one of the at least one group of texels each time it counts, 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 time the statistical operation returns to the texture shader in which alignment block 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 in which it is located, and the alignment blocks are densely aligned in a manner of filling the texture space.
[0007] The present disclosure also proposes a program for implementing a texture sampler and texture feedback and a computer-readable storage medium including the program.
[0008] According to the present disclosure, the efficiency of sampler feedback is improved, and the texture coordinates to be used and the corresponding texture level information are directly fed back, thereby avoiding unnecessary occupation of video memory and improving the utilization rate of video memory. In addition, according to the present disclosure, even when different methods are used to sample texels, the statistical information of the statistical block can be returned by simply reusing the sampler feedback command, while the number of additional returns can be reduced, thereby improving the efficiency of operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1 A schematic block diagram schematically illustrates a GPU for implementing sampler feedback;
[0010] Figure 2 Schematically illustrating a schematic flow chart for implementing texture feedback according to the present disclosure;
[0011] Figure 3 Schematically showing the block distribution of texels sampled back in a conventional manner;
[0012] Figure 4 Schematically illustrating a statistical block distribution of texels for return sampling according to the present disclosure;
[0013] Figure 5 Schematically showing the distribution of blocks restored in a position-aligned manner;
[0014] Figure 6 schematically showing different levels of the original feedback map to be updated for the sampled texture;
[0015] Figure 7 Schematically showing the distribution of statistical blocks in the first sampling mode;
[0016] Figure 8 and Fig. 9 schematically showing the distribution of statistical blocks in the second sampling mode;
[0017] Fig.10 schematically illustrates the distribution of statistical blocks in the third sampling mode;
[0018] Fig.11 schematically illustrates the distribution of statistical blocks in the fourth sampling mode;
[0019] Fig.12 schematically illustrates the distribution of statistical blocks in the fifth sampling mode;
[0020] Fig.13 schematically showing different levels of a raw feedback map of an example update of a sampled texture;
[0021] Fig.14 schematically illustrating an example minimum raw feedback map of a sampled texture;
[0022] Fig.15 The flowchart of the method for implementing texture feedback according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0023] This disclosure proposes a solution to implement texture sampler feedback in a GPU. Figure 1 A schematic block diagram of a GPU in which sampler feedback is implemented is shown. When a texture is sampled, in order to know the area of the texture actually used and the corresponding texture level based on the pixel, a shader is used to initiate sampler feedback, and preferably a certain number of pixels (such as 1, 2, 3...8 or more) are looped to implement feedback through the texture sampler. 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. Figure 2 A schematic flow chart for implementing the above process is shown in FIG.
[0024] like Figure 2As described in FIG. 1 , shader 1 sends a sampler feedback command to the texture sampler. Shader 1 sends SMP.footprint commands to the texture sampler in a loop in units of, for example, 8 pixels, until all sampling points that require sampler feedback have been fed back.
[0025] In some embodiments, the sampling feedback command of the shader 1 may include the following information: normalized coordinates (u, v, s), specifying the required increased texture space coordinate granularity (region_size), the texel group address and texel group subaddress (area_id, sub_area_id) associated with the pixel to be sampled, and requiring the 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 (region_offset) of the starting point of the statistical block for counting the texel group from the starting point of the alignment block in which it is located, 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). Among them, texel (texel) is also called texture element, texture pixel, etc. The alignment block (AlignedBlock) refers to a block of a specific size that is densely packed and aligned in a manner that fills the texture space in a specified coordinate granularity, such as a texture space with increased coordinate granularity, so that there is no gap between the alignment blocks and they do not overlap with each other, and they can cover all texels in the texture space. The statistical block is, for example, a block of a specific size for counting texel groups in a texture space with increased coordinate granularity. Among them, the first texture point 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 texture space with increased coordinate granularity, and the size of the alignment block defines the amount of texels sampled by the texture sampler each time. In some embodiments, the alignment block size can be selected as 8x4, for example, with the same size as the statistical block, and each time at least one texel in the texture space with increased coordinate granularity covered by the statistical block needs to be sampled, the position in the corresponding 8x4 statistical block is marked (mask=1).
[0026] In some embodiments, each time the shader 1 receives feedback information from the texture sampler, it determines whether the current 8 pixels have been fed back according to the feedback result. If not, it continues to issue sampler feedback commands in a loop. When the feedback of 8 pixels is completed, the shader 1 continues to issue sampler feedback commands for the next group of 8 pixels until all pixels that need feedback complete sampler feedback.
[0027] In some embodiments, the shader 1 determines whether the sampler has returned information of all texels associated with a pixel of interest in at least one texture level according to parameters area_count and sub_area_count. When feedback is performed a number of times corresponding to the number of returns determined according to parameters area_count and sub_area_count, it is determined that information of all texels associated with the pixel in at least one texture level has been returned for a pixel of interest, otherwise it is determined that information of all texels associated with the pixel has not been returned. Parameters area_count and sub_area_count are explained in the following text.
[0028] On the other hand, the texture sampler receives a command from the shader 1, and the texture address processing module 2 of the texture sampler determines the sampled texel depending on the sampling method. For example, depending on the sampling method, the texture address processing module 2 can calculate the detail level (lod), obtain lod_ratio according to the detail level, and determine at least one level of the texture associated with the pixel (mip level 0, 1, 2, 3...). For example, when the detail level lod is 0, there is one level of the texture associated with the pixel, and lod_ratio=1. When the detail level lod is greater than 0, there are at least two levels of the texture associated with the pixel, for example, when lod=0.3, lod_ratio=2. The texture address processing module 2 can determine the texture space of the corresponding texture level according to the normalized coordinates sent by the shader 1 for each level, and sample at least one group of texels associated with the pixel in the texture space, wherein each group of texels may include one or more texels.
[0029] In some embodiments, the texture address processing module 2 may use anisotropic filtering (AF), in which case the texture address processing module 2 may perform anisotropic filtering for 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 are returned due to the need to return multiple different texel groups due to the anisotropic filtering. For example, in the case of anisotropic filtering, the texture address processing module sequentially samples multiple groups of texels using a sampling unit, so that the addresses of the sampled texels can be determined and returned group by group.
[0030] In addition, in some embodiments, if the texture address processing module 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, repeat_ratio needs to be calculated, which reflects the number of returns required due to the need to obtain addresses for multiple groups of texels at the corners of the texture. For example, in the case of a repeated edge, if the sampled texel groups are distributed at the corners of the texture, it may be necessary to return addresses for each group of texels at the corners. In addition, in some embodiments, the number of returns required to return the addresses 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 may be (area_count, sub_area_count), where area_count may depend on, for example, lod_ratio and AF_ratio, where lod_ratio is determined according to the detail level lod, for example, when the detail level lod is 0, lod_ratio=1; for example, when the detail level lod=0.3, lod_ratio=2; AF_ratio reflects the number of times the texel address is returned due to anisotropic filtering and multiple different texel groups need to be returned, for example, when anisotropic filtering is not performed, AF_ratio is set to 1; when anisotropic filtering is performed, AF_ratio may be an integer greater than 1, for example, AF_ratio=8. Therefore, area_count may be expressed, for example, as area_count=lod_ratio×AF_ratio. For example, when lod_ratio=1 and AF_ratio=8, area_count=8, and 8 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 the texels to be fed back are scattered at the corners of the texture in the case of repeated edge sampling, and a statistical block size cannot fully cover it. It can be expressed as 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 on all texels associated with the pixel in all texture levels is returned for a pixel of interest.
[0031] The sampling of texels in the 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 parsing and decompression module 3. The texture address parsing and decompression module 3 directly transmits the received coordinate information and address count information (area_count, sub_area_count) sampled by the texture address processing module 2 to the texture filtering module. The sampler feedback action described herein is described with respect to one pixel. However, since it may be necessary to transmit texture area coordinate information and count information about multiple pixels (for example, 8 pixels) in actual applications, a large bandwidth is required. Through the texture address parsing and decompression module 3, the large bandwidth interface between the existing texture address parsing and decompression module 3 and the texture address processing module 2 can be utilized to minimize the interface changes. The interface bandwidth between the texture address parsing and decompression module 3 and the texture filtering module is also sufficient to transmit the sampler feedback information of 8 pixels.
[0032] Here, at least one group of texels associated with a pixel may be composed of all texels associated with a pixel, or may be composed of only some texels associated with a pixel. In other words, all texels associated with a pixel may be in a group of texels, or may be included in multiple groups of texels in multiple texture levels. For example, a texel associated with a pixel may constitute a group of texels. For example, all texels associated with a pixel in a texture space of a level may constitute a group of texels.
[0033] 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 alignment blocks of the same size are used to successively count the texels of the texture in the texture space with a certain block size as the unit size. Since the statistics of the alignment blocks in the texture space are carried out in a densely packed 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 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.
[0034] For example, Figure 3As shown, when a group of texels associated with a pixel is four texels marked in dark gray in the texture space, in the related art, in order to use a position-aligned alignment block of, for example, 8×4 size to count this group of texels, it is necessary to return information of each of the four position-aligned alignment blocks 0, 1, 2, and 3, including the position of the block (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 texels in the block. These positions are, for example, represented by the position mask information (region_mask) of each block, and the position mask information indicates whether each counted texel in the block corresponds to the sampled texel, and if so, the counted texel is marked as 1 ("mask=1"). The position mask information is related to the block size, for example, in the case of an 8×4 size alignment block, it is 32 bits of data. The texture filtering module repeatedly returns the block information until the positions of all sampled texels in the level are returned.
[0035] 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, and thus the performance is poor.
[0036] Embodiments of the present disclosure avoid returning the position of a sampled texel multiple times for a set of texels associated with a pixel. Figure 4 As shown, in the above example, the texture filtering module 4 of the present disclosure obtains the starting point of a group of texels associated with the pixel (in the above example, four texels of 2×2, marked in dark gray), determines the alignment block where 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. Figure 4 In the case of , the texture filtering module 4 first determines the alignment block where the starting point of a group of 2×2 texels is located, and the starting point is the first texture point of the upper left vertices of the four dark gray texels. Figure 4 In the case of , the alignment block is a block of size 8×4 represented by the position block_x=0, block_y=0. Then, the texture filtering module 4 calculates the starting point of a group of 2×2 texels relative to the starting point of the alignment block (block_x=0, block_y=0) (in Figure 4 On this basis, the texture filtering module 4 sets a statistical block of the same size as the alignment block, for example, 8×4. Figure 4It is marked in light gray and has the same starting point as a group of 2×2 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 group of 2×2 texels. At this time, it is only necessary to return a 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), which improves processing efficiency.
[0037] Because the 8×4 statistical block is not block-aligned but contains position offset information, after the shader 1 receives the pixel-associated texel position and area_count, sub_area_count parameters and other information returned by the texture filtering module 4, it restores the statistical block into four aligned blocks of 8×4 position through calculation, merges the region_mask of the four aligned blocks with the previous result through OR operation, and updates the position mask information of the four aligned blocks. Figure 4 After the returned statistical block information is restored, such as Figure 5 As shown, a set of texels associated with a pixel is restored into four aligned blocks that are aligned in position in the texture hierarchy.
[0038] It should be noted that in order to more clearly show the restored four aligned blocks, Figure 5 The four alignment blocks are separated by horizontal and vertical spaces in the middle. However, this is only to more clearly show the restored alignment blocks, and these alignment blocks are still aligned in practice. Figure 5 In each alignment block, a gray block marked with "1" is used to mark the texel associated with the pixel, indicating that the position masked by the texel associated with the pixel is set to 1 ("position mask = 1").
[0039] In some embodiments, the shader 1 can also determine whether the current 8 pixels need additional returns based on parameters such as area_count and sub_area_count returned by the texture sampler. If necessary, the shader 1 loops down the sampler feedback command until the sampling feedback of the pixels is completed and then continues to issue the next 8-pixel command. After all pixels of the current rendering target are calculated, the shader 1 can, for example, update the level of the original feedback map of the texture according to the calculation result at the set texture space coordinate granularity.
[0040] For example, when the texture to be sampled is 128×128 in size and 16×16 in texture space coordinate granularity, the level of the original feedback map that shader 1 needs to update is as follows: Figure 6 shown.
[0041] Below, in the above context, the scheme of using the statistics block to return the position of at least one group of texels associated with a pixel of the texture according to the present disclosure is further described in detail for the common texture sampling method. It should be noted that although the shader 1 can send a sampler feedback command to the texture sampler at a granularity of multiple pixels (e.g., a granularity of 8 pixels), for the sake of ease of description, only one pixel is used as an example for description, and the process of other pixels is the same.
[0042] In some embodiments, first, shader 1 sends a SMP.footprint command to the texture sampler for a pixel. An example of the command is as follows:
[0043] SMP.footprint(t#id,s#id,u,v,s,expected_region_size,0,0)
[0044] After receiving SMP.footprint, the texture address processing module 2 calculates at least one group of sampled texels and calculates area_count and sub_area_count to determine the number of returns. The calculation scenario is described using one pixel as an example, and the process for other pixels is the same.
[0045] In some embodiments, the first sampling mode may be: no trilinear filtering, no anisotropic filtering (AF), no repeated edges, such as Figure 7 shown.
[0046] Texture address processing module 2 calculates lod = 0, lod_ratio = 1, AF_ratio = 1. area_count = lod_ratio × AF_ratio = 1, sub_area_count = 0. Taking pixel p0 as an example, the four texels (p0t0, p0t1, p0t2, p0t3) associated with pixel p0 that need to be sampled in the texture space are obtained according to the uv coordinate as a group of texels. Figure 7 The sample position in is marked in dark grey. The lod value, area_count, sub_area_count, and sampler feedbackflag (sampler feedback flag) are sent to the texture address resolution and decompression module 3.
[0047] The texture address parsing and decompression module 3 transmits the sampler feedback data to the texture filtering module 4.
[0048] After receiving the information, the texture filtering module 4 obtains the starting point of the group of texels, determines the alignment block where 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. Figure 7In the case of, the texture filtering module 4 first determines the alignment block where the starting point of the group of texels, that is, the upper left vertices of the four dark gray texels, are located. Figure 7 In the case of , the alignment block is a block of size 8×4 represented by the position block_x=0, block_y=0. Then, the texture filtering module 4 calculates 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 The texture filtering module 4 further sets an 8×4 statistical block having the same starting point as the group of texels. Figure 7 The statistics block is marked in light gray and includes the dark gray texel group. The texture filtering module 4 sets 32 bits of position mask information (region_mask) for the statistics block according to the rotation layout (twiddle layout), and returns it to the shader 1 together with the starting point of the statistics block in the alignment block with position block_x=0, block_y=0 and the position offset of the starting point of the statistics block relative to the alignment block (region_offset_x=7, region_offset_y=3). The information of the region_mask of the returned statistics block is shown below:
[0049] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1
[0050] Therefore, since the statistical information of the statistical block can be returned by repeatedly utilizing the sampler feedback command and the number of additional returns is reduced, the operating efficiency can be improved.
[0051] In some embodiments, the second sampling mode may be: trilinear filtering, no anisotropic filtering, no repeated edges, such as Figure 8 The commands issued by shader 1 are as follows.
[0052] SMP.footprint(t#id,s#id,u,v,s,expected_region_size,0,0)
[0053] Texture address processing module 2 calculates lod = 0.3, lod_ratio = 2, AF_ratio = 1. area_count = lod_ratio × AF_ratio = 2. Taking p0 as an example, area_id = 0, and a group of texels (p0t0, p0t1, p0t2, p0t3) associated with pixel p0 that need to be sampled in the first-level texture space are obtained according to the uv coordinates. Figure 8The sample position in is marked with dark grey. Calculate sub_area_count = 0. Send lod value, area_count, sub_area_count, samplerfeedback flag to texture address resolution and decompression module 3.
[0054] The texture address parsing and decompression module 3 transparently transmits the received data to the texture filtering module 4 .
[0055] After receiving the information, the texture filter module 4 obtains the starting point of the group of texels in a manner similar to the first sampling method, determines the alignment block where 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=7, region_offset_y=3). On this basis, the texture filter module 4 sets an 8×4 statistical block with the same starting point as the group of texels. Figure 8 The middle statistics block is marked with light gray and includes the dark gray texel group. The 32-bit position mask information is calculated according to the rotation layout, and the information and area_count=2, the starting point of the statistics block is 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 are returned to the shader 1.
[0056] When shader 1 receives area_count=2 returned when area_id=0, it means that additional block information needs to be returned for the current pixel, and shader 1 will issue a command with area_id=1 again.
[0057] SMP.footprint(t#id,s#id,u,v,s,expected_region_size,1,0)
[0058] When area_id=1, texture address processing module 2 calculates lod=0.3, lod_ratio=2, AF_ratio=1. area_count=lod_ratio×AF_ratio=2. Taking p0 as an example, area_id=1, a group of texels (p0t0, p0t1, p0t2, p0t3) associated with pixel p0 in the second-level texture space that need to be sampled are obtained according to the uv coordinates. Fig. 9 Calculate sub_area_count = 0. Send lod value, area_count, sub_area_count, sampler feedback flag to texture address resolution and decompression module 3. Fig. 9 shown.
[0059] The texture address parsing and decompression module 3 transparently transmits the received data to the texture filtering module 4 .
[0060] After receiving the information, the texture filter module 4 obtains the starting point of the group of texels (marked in dark gray) in the second-level texture space, determines the alignment block where 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). The texture filter module 4 further sets an 8×4 statistical block in the second-level texture space that has the same starting point as the group of texels. Fig. 9 The middle statistics block is marked in light grey and includes the dark grey texel group in it. The 32-bit position mask information is calculated according to the rotation layout, and this information and area_count=2 are returned to the shader 1 together with the starting point of the statistics block in the determined alignment block and the position offset of the starting point of the statistics block relative to the determined alignment block.
[0061] Therefore, since the statistical information of the statistical block can be returned by repeatedly utilizing the sampler feedback command and the number of additional returns is reduced, the running efficiency is improved.
[0062] In some embodiments, the third sampling mode may be: repeated edges, no trilinear filtering, no anisotropic filtering, such as Fig.10 The commands issued by shader 1 are as follows.
[0063] SMP.footprint(t#id,s#id,u,v,s,expected_region_size,0,0)
[0064] 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. Taking p0 as an example, area_id=0, a group of texels (p0t0, p0t1, p0t2, p0t3) associated with pixel p0 that need to be sampled in the texture hierarchy are obtained according to the uv coordinates. Since p0's (t1.u-t0.u>8)&&(t2v-t0.v>4), it is explained as follows Fig.10As shown in the figure, the current group of texels is distributed in four different 8×4 statistical blocks because they are at the corner of the texture. One statistical block cannot cover them. Each texel in the group of texels needs to be counted as a group of texels. Therefore, three additional statistical block information is returned, sub_area_count=3. Texture address processing module 2 determines that sub_area_count=3 and sub_area_id=0, sends the UV coordinates of p0t0, clears the coordinates of p0t1 / p0t2 / p0t3 to 0, and sends area_count, sub_area_count, and sampler feedback flag to texture address parsing and decompression module 3. The texel distribution is shown in the figure below. Fig.10 shown.
[0065] The texture address parsing and decompression module 3 transparently transmits the received data to the texture filtering module 4 .
[0066] After receiving the information, the texture filtering module 4 sets the single texel p0t0 as a group of texels. Fig.10 The texture filtering module 4 obtains the starting point of the texel p0t0 and determines the alignment block where the starting point is located ( Fig.10 The 8×4 block (block_x=0, block_y=0) with (0, 0) as the starting point is calculated, and the position offset of the starting point of the texel p0t0 relative to the starting point of the alignment block is calculated by Fig.10 It can be seen that at this time, the position offsets region_offset_x and region_offset_y are both 0. The texture filtering module 4 further sets an 8×4 statistical block 0 having the same starting point as the texel p0t0. Fig.10 The texel p0t0 is marked in light gray and included in it. The 32-bit position mask information is calculated according to the rotation layout, and area_count=1, sub_area_count=3 and the position mask information are returned to the shader 1 together with the starting point of the statistics block 0 in the alignment block (block_x=0, block_y=0) with the starting point (0, 0) and the position offset of the starting point of the statistics block 0 relative to the starting point of the alignment block.
[0067] When shader 1 receives area_count=1, sub_area_count=3 when area_id=0, shader 1 will issue commands for sub_area_id=1, 2, 3 again. In this case, similar operations as p0t0 are performed for each of the remaining three groups of texels p0t1, p0t2, and p0t3. For example, when sub_area_id=1, texture filtering module 4 obtains the starting point of texel p0t1 and determines the alignment block where the starting point is located ( Fig.10The 8×4 block (block_x=1, block_y=0) with (8, 0) as the starting point is calculated, and the position offset of the starting point of the texel p0t1 relative to the starting point of the alignment block is calculated by Fig.10 It can be seen that at this time, the position offset region_offset_x=7, region_offset_y=0. The texture filtering module 4 further sets an 8×4 statistical block 1 having the same starting point as the texel p0t1. Fig.10 The texel p0t1 is marked in light gray and included in it, and the texture filtering module 4 returns the position mask information, the starting point of the statistical block 1 in the alignment block (block_x=1, block_y=0) with the starting point (8, 0), and the position offset of the starting point of the statistical block 1 relative to the starting point of the alignment block to the shader 1. When sub_area_id=2, the texture filtering module 4 obtains the starting point of the texel p0t2, determines the alignment block ( Fig.10 The 8×4 block (block_x=0, block_y=1) with (0, 4) as the starting point and the position offset of the starting point of the texel p0t2 relative to the starting point of the alignment block is calculated by Fig.10 It can be seen that at this time, the position offset region_offset_x=0, region_offset_y=3. The texture filtering module 4 further sets an 8×4 statistical block 2 having the same starting point as the texel p0t2. Fig.10 The texel p0t2 is marked in light gray and included in it, and the texture filtering module 4 returns the position mask information, the starting point of the statistical block 2 in the alignment block (block_x=0, block_y=1) with the starting point (0, 4), and the position offset of the starting point of the statistical block 2 relative to the starting point of the alignment block to the shader 1. When sub_area_id=3, the texture filtering module 4 obtains the starting point of the texel p0t3 and determines the alignment block ( Fig.10 The 8×4 block (block_x=1, block_y=1) with (8, 4) as the starting point and the position offset of the starting point of the texel p0t3 relative to the starting point of the alignment block is calculated by Fig.10 It can be seen that at this time, the position offsets region_offset_x=7 and region_offset_y=3. The texture filtering module 4 further sets a statistical block 3 having the same starting point as the texel p0t3. Fig.10The pixel p0t3 is marked in light gray in the figure and included therein, and the texture filtering module 4 returns the position mask information, the starting point of the statistical block 3 in the alignment block (block_x=1, block_y=1) with (8, 4) as the starting point, and the position offset of the starting point of the statistical block 3 relative to the starting point of the alignment block to the shader 1. In this way, the position information of all texels associated with the pixel p0 can be provided by returning the information of the starting points of the four statistical blocks 0 to 3 in the corresponding four alignment blocks and the four statistical blocks 0 to 3 with the position offsets relative to the starting points of the corresponding alignment blocks.
[0068] 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 sent for the current sub_area_id according to the interval of the texture coordinates. The following Table 1 shows the coordinate sending order of the texture address processing module 2 at different sub_area_counts.
[0069] Table 1
[0070]
[0071] 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.
[0072] 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.
[0073] SMP.footprint(t#id,s#id,u,v,s,expected_region_size,0,0)
[0074] 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. Taking p0 as an example, area_id=0, a group of texels (p0t0, p0t1, p0t2, p0t3) associated with pixel p0 that need to be sampled in the first-level texture space are obtained according to the uv coordinates. Since (t1.u-t0.u>8)&&(t2v-t0.v>4) of p0, sub_area_count=3. According to 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 parsing and decompression module 3.
[0075] The texture address parsing and decompression module 3 transparently transmits the received data to the texture filtering module 4 .
[0076] After receiving the information, the texture filtering module 4 sets the single texel p0t0 as a group of texels. Fig.10 The situation shown is similar, and the group of texels is marked in dark gray. Texture filtering module 4 obtains the starting point of texel p0t0, determines the alignment block where the starting point is located, calculates the position offset of the starting point of texel p0t0 relative to the starting point of the alignment block, sets an 8×4 statistical block 0 with the same starting point as texel p0t0, and Fig.10 The situation shown is similar, the statistics block is marked with light gray and includes the texel p0t0. The 32-bit position mask information is calculated according to the rotation layout, and area_count=1, sub_area_count=3 and the position mask information are returned to the shader 1 together with the starting point of the statistics block 0 in the alignment block (block_x=0, block_y=0) with the starting point (0, 0) and the position offset of the starting point of the statistics block 0 relative to the starting point of the alignment block. The processing process of the remaining texels is the same as the third sampling method.
[0077] When shader 1 receives area_count=2, sub_area_count=3 returned when area_id=0, shader 1 will issue commands of sub_area_id=1, 2, 3 again.
[0078] SMP.footprint(t#id,s#id,u,v,s,expected_region_size,0,1)
[0079] SMP.footprint(t#id,s#id,u,v,s,expected_region_size,0,2)
[0080] SMP.footprint(t#id,s#id,u,v,s,expected_region_size,0,3)
[0081] When sub_area_id=1, 2, 3, because area_id=0, the behavior of texture address processing module 2 is consistent with area_id=0, and the coordinates in the first-level texture space are selected and sent according to sub_area_id. After receiving the coordinates, texture filtering module 4 determines the alignment block where the starting point of the texel is located, calculates the position offset of the starting point relative to the starting point of the alignment block, sets the statistical block whose starting point is the same as the starting point of the texel, locates the starting point of the statistical block in the determined alignment block, and returns the position offset of the starting point of the statistical block relative to the starting point of the alignment block together with the position mask information to shader 1.
[0082] When sub_area_id=sub_area_count, shader 1 will exit the loop and continue to send the next area_id.
[0083] SMP.footprint(t#id,s#id,u,v,s,expected_region_size,1,0)
[0084] When area_id=1 and sub_area_id=0, the texture address processing module 2 calculates the coordinates of the second-level texture space and calculates sub_area_count=0 of the second-level texture space. The texture address processing module 2 sends the coordinates and lod value of the second-level texture space. The coordinate distribution is as follows: Fig.11 As shown in the figure. A set of texels (p0t0, p0t1, p0t2, p0t3) associated with a pixel in the second-level texture space is Fig.11 Indicated in dark grey.
[0085] The texture filtering module 4 receives the information, sets the single texel p0t0 as a group of texels, obtains the starting point of the texel p0t0 (marked in dark gray) in the second-level texture space, determines the alignment block where the starting point is located, and calculates the position offset of the starting point of the texel p0t0 relative to the starting point of the alignment block (given by Fig.11 It can be seen that region_offset_x and region_offset_y are both 0). The texture filtering module 4 further sets an 8×4 statistical block in the second-level texture space that has the same starting point as the group of texels. Fig.11The statistical block is marked in light gray and includes the 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 the texels p0t0, p0t1, p0t2, and p0t3, it is only necessary to return the information of a statistical block 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. The 32-bit position mask information is calculated based on the rotation layout, and the information and area_count=2 are returned to the shader 1 together with the determined statistical block information.
[0086] Therefore, since the statistical information of the statistical block can be returned by repeatedly utilizing the sampler feedback command and the number of additional returns is reduced, the operation efficiency is improved.
[0087] In some embodiments, the fifth sampling mode may be: repeated edges, anisotropic filtering, no trilinear filtering, such as Fig.12 The commands issued by shader 1 are as follows.
[0088] SMP.footprint(t#id,s#id,u,v,s,expected_region_size,0,0)
[0089] When area_id=0, texture address processing module 2 calculates lod_ratio=1, AF_ratio=8x, and calculates area_count=lod_ratio×AF_ratio=8. Taking p0 as an example, area_id=0, first calculate p0s0 of a group of texels sampled by sampling unit s0 in the texture space, and calculate 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 parsing and decompression module 3. The coordinate distribution is as follows Fig.12 shown.
[0090] The texture address parsing and decompression module 3 transmits the sampler feedback data to the texture filtering module 4.
[0091] After receiving the information, the texture filtering module 4 obtains the starting point of the group of texels p0s0, determines the 8×4 alignment block where the starting point is located (with (0, 0) as the starting point) and calculates the position offset of the starting point of the texel group p0s0 relative to the starting point of the alignment block (region_offset_x=3, region_offset_y=2). The texture filtering module 4 further sets an 8×4 statistical block with the same starting point as the texel group p0s0, which includes the texel group p0s0. The texture filtering module 4 calculates the 32-bit position mask information according to the rotation layout, and returns it to the shader 1 together with area_count=8 and sub_area_count=0, together with the starting point of the statistical block in the alignment block with the starting point (0, 0) and the position offset of the starting point of the statistical block relative to the starting point of the alignment block.
[0092] 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.
[0093] SMP.footprint(t#id,s#id,u,v,s,expected_region_size,1-6,0)
[0094] 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.
[0095] SMP.footprint(t#id,s#id,u,v,s,expected_region_size,7,0)
[0096] When area_id=7, due to the existence of duplicate edges (in Fig.12 There are sampled texels at the leftmost edge and the rightmost edge of the texture address processing module 2), and the texels p0s7 sampled by the sampling unit s7 of the texture address processing module 2 include two groups of texels, namely Fig.12 A group of texels at the left edge and a group of texels at the right edge, at this time sub_area_count is calculated to be 1, area_count = 8. Texture address processing module 2 first calculates the first group of texels according to sub_area_id and sub_area_count, and sends it together with area_count, sub_area_count, and sampler feedback flag to texture address parsing and decompression module 3 and texture filtering module 4.
[0097] After receiving the information, the texture filter module 4 obtains the starting point of the first group of texels of p0s7, determines the alignment block where the starting point is located (with (24, 0) as the starting point) 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). The texture filter module 4 further sets an 8×4 statistical block with the same starting point as the first group of texels, calculates the 32-bit position mask information according to the rotation layout, and returns it to the shader 1 together with area_count=8 and sub_area_count=0, together with the starting point of the statistical block in the alignment block with the starting point (24, 0) and the position offset of the starting point of the statistical block relative to the starting point of the alignment block (region_offset_x=0, region_offset_y=2).
[0098] When shader 1 receives sub_area_count>0, it will issue the command again.
[0099] SMP.footprint(t#id,s#id,u,v,s,expected_region_size,7,1)
[0100] According to the received instruction, the texture filtering module 4 obtains the starting point of the second group of texels of p0s7, determines the alignment block where 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). The texture filtering module 4 further sets an 8×4 statistical block with the same starting point as the second group of texels, and returns the starting point of the statistical block in the alignment block with the starting point (0, 0) and the position offset of the starting point of the statistical block relative to the starting point of the alignment block (region_offset_x=0, region_offset_y=2) in a similar manner to the first group of texels of p0s7, and ends the processing.
[0101] Therefore, since the statistical information of the statistical block can be returned by repeatedly utilizing the sampler feedback command and the number of additional returns can be reduced, the operation efficiency is improved.
[0102] As described above, after completing the sampler feedback command SMP.footprint for all pixels, shader 1 updates the level of the original feedback map of each texture level. The updated result is as follows Fig.13 shown.
[0103] By providing this result to the driver, texture loading can be optimized. In addition, if a minimum mapping level (minmipmap) needs to be generated based on this, the minimum mapping level of the texture can be generated through the GenerateMinmap function. The result is in Fig.14 Shown in.
[0104] It is noted that although the alignment block and the statistical block are described above with an example of 8×4 size, it is clear to those skilled in the art that such 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 size can cover a set of texels in the texture space.
[0105] In addition, according to the third to fifth sampling methods described above, even if the texels associated with the pixels are in a discrete state, the statistics of the sampled texels can be efficiently completed by using the embodiments of the present disclosure.
[0106] Fig.15 is an example flow chart showing the use of a statistics block to return the location of a sampled texel according to the present disclosure. Fig.15As shown, in 1501, the texture shader 1 sends a sampler feedback command to the texture sampler, requesting to return the position of at least one group of texels in a texture space of a level associated with a pixel of the texture. In 1502, the texture address processing module 2 of the texture sampler receives the sampler feedback command, samples at least one group of texels in the texture space, each group of texels includes at least one texel, and the texture address processing module 2 passes the level information and coordinate information of the at least one group of texels to the texture filtering module 4. In 1503, the texture filtering module 4 sets the statistical block according to the level information and coordinate information, and counts the area of the statistical block size in the texture space each time. In 1504, the texture filtering module 4 obtains the starting point of one group of 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 in the statistical block size. In 1505, the texture filtering module 4 performs statistics at least once, and each time the statistics are returned to the texture shader, in which alignment block of the densely aligned alignment blocks in the texture space the starting point of the statistics block is located, 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, completes the statistics of all sampled texels in the texture space and returns 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 pixel 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, when sampling the texture, different sampling methods such as anisotropic filtering, repeated edges and trilinear filtering can be used, 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.
[0107] In one or more examples, the functions described may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, these functions may be stored or transmitted on a computer-readable medium as one or more commands, instructions, or codes, and executed by a hardware-based processing unit. A computer-readable medium may include a computer-readable storage medium, the medium corresponding to a tangible medium such as a data storage medium, or a communication medium, the communication medium including, 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, a computer-readable medium may generally correspond to (1) a tangible, non-temporary computer-readable storage medium, or (2) a communication medium such as a signal or carrier wave. A data storage medium 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 implementation described in the present application. A computer program product may include a computer-readable medium.
[0108] The terms used in the description of the implementation in this article are only for the purpose of describing a specific implementation, and are not intended to limit the scope of the claims. As used in the description of the implementation and the appended claims, "one", "the" and "said" are also intended to include singular and plural forms, unless the context clearly indicates otherwise. It will also be understood that the term "and / or" used in this article refers to and covers any and all possible combinations of one or more associated listed items. It will be further understood that the terms "including" and / or "comprising" specify the presence of declared features, elements and / or components when used in this specification, but do not exclude the presence or addition of one or more other features, elements, components and / or groups thereof.
[0109] The description of the present application is given 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 technical personnel 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 intended specific use. 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.
Claims
1. A texture sampler, comprising 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 the pixel, each group of texels includes at least one texel, and the texture address processing module transmits level information and coordinate information of the at least one group of texels to the texture filtering module; The texture filtering module sets the statistical block according to the level information and coordinate information. The statistical block is a block of a specific size in the texture space used to count the texel group. Each time the statistical block size area in the texture space is counted, The texture filtering module obtains the starting point of one of the at least one group of texels each time it performs statistics, 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 size of the statistical block. The texture filtering module performs statistics at least once, and each time the statistics returns in which alignment block 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 in which it is located. The alignment blocks are densely aligned in a manner to fill the texture space.
2. The texture sampler according to claim 1, characterized in that All texels associated with a pixel are included in a set of texels.
3. The texture sampler according to claim 1, characterized in that: The texture address processing module samples in anisotropic filtering mode or in trilinear filtering mode or in a combination of the two filtering modes.
4. The texture sampler according to claim 3, characterized in that: The texture address processing module samples in a repeated edge manner.
5. The texture sampler according to claim 4, characterized in that: The at least one group of texels comprises a group of texels at a corner of the texture.
6. The texture sampler according to claim 5, characterized in that: 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 according to claim 6, characterized in that The level is one of at least one level of the texture associated with the pixel, the at least one level being determined by sampling in a trilinear filtering manner by a texture address processing module.
8. The texture sampler according to claim 7, characterized in that: The texture address processing module instructs the texture filtering module to return statistical block information for the at least one level.
9. The texture sampler according to claim 8, characterized in that: The texture sampler also includes a texture address parsing and decompression module, which receives notifications and instructions from the texture address processing module and transmits them to the texture filtering module.
10. A texture shader, which issues a sampler feedback command to a texture sampler according to any one of claims 1 to 9, wherein the sampler feedback command causes the texture sampler to return position information of a set of texels associated with a pixel in a texture space, and the texture shader repeatedly issues the sampler feedback command to obtain the coordinates of the texels associated with the pixel in the texture space in at least one level of the texture, and uses these coordinates to update at least one level of the original feedback map of the texture.
11. The texture shader according to claim 10, characterized in that: The level of the at least one original feedback map is obtained by increasing the texture space coordinate granularity of the corresponding texture level by a specified ratio.
12. A method for implementing texture feedback, characterized in that The following steps are involved: issuing, by the texture shader to the texture sampler, a sampler feedback command for returning positions of at least a set of texels in a level of the texture associated with the pixel; The texture address processing module of the texture sampler receives the sampler feedback command, samples at least one group of texels in the hierarchy, each group of texels includes at least one texel, and the texture address processing module transmits the hierarchy information and coordinates of the at least one group of texels to the texture filtering module of the texture sampler; The texture filtering module sets a statistical block according to the level information and the coordinate information. The statistical block is a block of a specific size in the texture space for counting the texel group. Each time, the area of the statistical block size in the texture space is counted. Each time the texture filtering module counts, it obtains the starting point of one of 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 texel groups is included in the statistical block size. The texture filtering module performs at least one statistical operation, and each time the statistical operation returns to the texture shader the alignment block in which 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 in which it is located. The alignment blocks are densely aligned in a manner to fill the texture space.
13. The method according to claim 12, characterized in that The texture address processing module samples all texels associated with a pixel in a set of texels.
14. The method according to claim 12, characterized in that The texture address processing module samples in anisotropic filtering mode or in trilinear filtering mode or in a combination of the two filtering modes.
15. The method according to claim 14, characterized in that The texture address processing module samples in a repeated edge manner.
16. The method according to claim 15, characterized in that The at least one group of texels comprises a group of texels at a corner of the texture.
17. The method according to claim 16, characterized in that The texture address processing module determines the number of times the texture filtering module returns the statistical block information according to at least one of edge repetition, anisotropic filtering and trilinear filtering.
18. The method according to claim 17, characterized in that The level is one of at least one level of the texture associated with the pixel, and the texture address processing module samples the at least one level of the texture associated with the pixel in a trilinear filtering manner.
19. The method according to claim 18, characterized in that The texture address parsing and decompression module of the texture sampler receives notifications and instructions from the texture address processing module and transmits them to the texture filtering module.
20. A computer readable storage medium having stored thereon a computer program, which when executed by one or more processors implements the method of implementing texture feedback according to any one of claims 12 to 19.
Citation Information
Patent Citations
GPU multi-thread texture mapping SystemC modeling structure
CN106683171A
Cache architecture for efficiently accessing texture data using buffers
CN107153617A
Cited By
Texture sampler, and method for realizing texture feedback
WO2025146097A1