Cube mapping texture cache allocation method based on X-Y coordinate and surface mark optimization
By using an optimization method based on XY coordinates and polygons, the coordinates of cube map texture data are redistributed and texture size is aligned, which solves the cache conflict problem, improves rendering performance and efficiency, and is applicable to cube maps of various sizes.
Patent Information
- Application Number
- CN202410915513.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-09
- Publication Date
- 2026-01-09
AI Technical Summary
Existing texture cache allocation methods do not fully consider the special structure of cube maps, which can easily lead to cache conflicts during bilinear sampling, affecting rendering performance and efficiency.
A dual optimization method based on XY coordinates and polygons is adopted to reallocate the coordinates of cube map texture data and perform texture size alignment in block memory layout, thereby optimizing cache allocation strategy and reducing cache conflicts and redundancy.
Significantly reduces cache conflicts, improves texture sampling efficiency, optimizes hardware resource utilization, enhances rendering performance and system stability, and is suitable for cube maps of various sizes.
Smart Images

Figure CN121304889A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of graphics processing technology, and in particular to a method for allocating cube map texture caches based on XY coordinates and surface optimization. Background Technology
[0002] With the development of graphics processing technology, cube maps are widely used in graphics rendering such as environment mapping and reflection. However, existing texture buffer allocation methods do not fully consider the special structure of cube maps, which easily leads to buffer conflicts during bilinear sampling, affecting rendering performance.
[0003] Traditional texture buffer allocation methods typically rely on simple allocation based on XY coordinates. While this approach is effective in 2D texture mapping, it suffers from low sampling efficiency in cube mapping because it fails to consider the sampling requirements of different faces. This is particularly problematic when performing bilinear sampling, as sampling between faces and corners requires coordinate rotation, further complicating the issue.
[0004] For example, to resolve cache conflicts, some techniques mitigate the conflict by increasing cache capacity. However, while this method can reduce cache conflicts to some extent, increasing cache capacity significantly increases costs and places higher demands on hardware resources.
[0005] Another approach is to reduce conflicts by adjusting caching strategies. For example, using different cache replacement algorithms or allocation strategies. However, these adjustments have limited effectiveness in complex scenarios, cannot fundamentally solve the cache conflict problem, and can easily introduce new performance bottlenecks.
[0006] Furthermore, existing methods tend to lead to high cache conflict rates when using small-sized cube maps and bilinear sampling. This high conflict rate not only reduces system stability but also affects rendering speed and quality. Additionally, traditional methods struggle to efficiently handle coordinate rotations required for sampling between faces and corners, resulting in performance degradation. The computational complexity introduced by coordinate rotations increases the system's burden and impacts real-time rendering quality.
[0007] Therefore, how to reduce cache conflicts and improve texture sampling efficiency has become the technical problem to be solved by this invention. Summary of the Invention
[0008] The technical problem solved by this invention is to address the deficiencies in the prior art by providing a cube map texture cache allocation method based on XY coordinates and surface optimization, so as to solve the problems of cache conflict and low sampling efficiency mentioned in the background art.
[0009] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:
[0010] A cube map texture cache allocation method based on XY coordinates and polygon optimization includes the following steps:
[0011] Step 1: Obtain cube map texture data and perform dual optimization classification based on the XY coordinates and polygon labels of the texture data;
[0012] Step 2: Unfold the cube map into a plane, and with the top left corner as the origin, redistribute the coordinates of each pixel according to its position in the unfolded map;
[0013] Step 3: Based on the reallocated XY coordinates and surface information, optimize the texture data cache allocation strategy to make the texture data distribution in the cache more reasonable and reduce cache conflicts and redundancy.
[0014] Step 4: When performing texture sampling, prioritize reading the allocated texture data from the cache to improve rendering efficiency.
[0015] As a further aspect of the present invention, the step of reallocating the XY coordinates includes:
[0016] The X-coordinate is adjusted according to the surface coordinate, where different surface coordinates correspond to different X-coordinate adjustment rules;
[0017] The Y-coordinate is adjusted based on the surface coordinate, where different surface coordinates correspond to different Y-coordinate adjustment rules.
[0018] As a further aspect of the present invention, the adjustment rule for the X-coordinate is as follows:
[0019] For coordinates 2, 3, and 4, the X coordinate is increased by the texture width increment;
[0020] For cases where the surface coordinate is 0, the X coordinate is increased by twice the texture width increment;
[0021] For the case where the surface coordinate is 5, the X coordinate is increased by 3 times the texture width increment.
[0022] As a further aspect of the present invention, the adjustment rule for the Y-coordinate is as follows:
[0023] For coordinates 1, 4, 0, and 5, the Y coordinate is increased by the texture height increment;
[0024] For the case with a face value of 3, the Y coordinate is increased by twice the texture height increment.
[0025] As a further aspect of the present invention, the following steps are also included:
[0026] Align the texture sizes in the block memory layout to align them with the cache lines;
[0027] Adjust the increments of texture width and height according to the size of the cache line to match the size after aligning with the cache line.
[0028] As a further aspect of the present invention, the texture size alignment method includes:
[0029] Align the texture width to the cache line alignment size and calculate the texture width increment after alignment;
[0030] Align the texture height to the cache line alignment size and calculate the texture height increment after alignment;
[0031] Adjust the increment of the X coordinate to the increment of the aligned texture width;
[0032] Adjust the increment of the Y coordinate to match the increment of the aligned texture height.
[0033] As a further aspect of the present invention, the method is applicable to textures including but not limited to odd-numbered or prime-numbered dimensions.
[0034] As a further aspect of the present invention, the following steps are also included:
[0035] Monitor cache usage and update cache allocation strategies regularly to adapt to different rendering needs and scene changes;
[0036] The cache management module allows for timely adjustments to cache allocation strategies, ensuring system performance stability and efficiency.
[0037] Compared with the prior art, the beneficial effects of the present invention are:
[0038] 1. Significantly Reduced Cache Conflicts: By combining XY coordinates and Face ID for dual optimization, the coordinates of each pixel in the unfolded image are redistributed, significantly reducing cache conflicts. This innovative method is particularly suitable for small cubemaps and bilinear sampling, effectively reducing cache conflict rates and thus improving system stability and response speed.
[0039] 2. Improved Texture Sampling Efficiency: The optimized cache allocation strategy results in a more rational distribution of texture data within the cache, reducing the complexity and performance overhead caused by coordinate rotation. By prioritizing the reading of allocated texture data from the cache, overall rendering performance is improved, particularly in high-performance graphics rendering applications such as games and virtual reality.
[0040] 3. Efficient Hardware Resource Utilization: This invention proposes a more rational resource allocation scheme, enabling fuller utilization of hardware resources. By employing a texture size alignment method in the block memory layout, it ensures that each cache line is effectively utilized, improving cache hit rate and extending device lifespan. This efficient hardware resource utilization strategy reduces system resource consumption and enhances overall system performance and efficiency.
[0041] 4. Wide applicability: This method is applicable to cube maps of various sizes, including odd- and prime-sized maps, demonstrating strong versatility and flexibility. Whether the cube map is large or small, this method provides an efficient cache allocation strategy, adapting to different application scenarios and needs.
[0042] 5. Optimized Block Memory Layout: In the block memory layout, the texture size alignment method has been optimized to align texture sizes with cache line alignment sizes, further improving cache utilization efficiency. Regardless of the cache line size, the algorithm can adaptively adjust, improving cache hit rate and utilization efficiency.
[0043] 6. Simple code implementation and easy integration: The method of this invention is relatively simple and clear to implement, easy to integrate into existing graphics processing pipelines, and can run efficiently on different hardware platforms. This simplicity in implementation not only reduces development costs but also ensures the widespread application and promotion of the method.
[0044] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0045] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 In this invention, the cube map is unfolded into a plane (following the VK / DirectX standard), with the top left corner as the origin, and the coordinates of each pixel are redistributed according to its position in the unfolded map.
[0047] Figure 2 This is an example diagram of the distribution of the unoptimized cube map texture cache bank in this invention.
[0048] Figure 3 An example diagram showing the distribution of the cube map texture cache bank optimized for this invention.
[0049] Figure 4 This is an example diagram of the distribution of the unoptimized cube map texture cache bank in this invention.
[0050] Figure 5 An example diagram showing the distribution of the cube map texture cache bank optimized for this invention. Detailed Implementation
[0051] The technical solutions in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0052] Please see Figure 1 —5. In this embodiment of the invention, a cube map texture cache allocation method based on XY coordinates and surface index optimization includes the following steps:
[0053] Step 1: Obtain cube map texture data and perform dual-optimized classification based on the XY coordinates and face ID of the texture data;
[0054] Step 2: Unfold the cube map into a plane, and with the top left corner as the origin, redistribute the coordinates of each pixel according to its position in the unfolded map;
[0055] Step 3: Based on the reallocated XY coordinates and surface information, optimize the texture data cache allocation strategy to make the texture data distribution in the cache more reasonable and reduce cache conflicts and redundancy.
[0056] Step 4: When performing texture sampling, prioritize reading the allocated texture data from the cache to improve rendering efficiency.
[0057] The steps for reallocating XY coordinates include:
[0058] The X-coordinate is adjusted based on the Face ID identifier, and the adjustment rules for the X-coordinate are different for different Face ID identifiers;
[0059] The Y-coordinate is adjusted based on the Face ID identifier, and the adjustment rules for the Y-coordinate are different for different Face ID identifiers.
[0060] The rules for adjusting the X-coordinate are as follows:
[0061] For coordinates 2, 3, and 4, the X coordinate is increased by the texture width increment;
[0062] For cases where the surface coordinate is 0, the X coordinate is increased by twice the texture width increment;
[0063] For the case where the surface coordinate is 5, the X coordinate is increased by 3 times the texture width increment.
[0064] The adjustment rules for the Y-axis are as follows:
[0065] For coordinates 1, 4, 0, and 5, the Y coordinate is increased by the texture height increment;
[0066] For the case with a face value of 3, the Y coordinate is increased by twice the texture height increment.
[0067] As a further aspect of the present invention, the following steps are also included:
[0068] Align the texture sizes in the block memory layout to align them with the cache lines;
[0069] Adjust the increments of texture width and height according to the size of the cache line to match the size after aligning with the cache line.
[0070] Texture size alignment methods include:
[0071] Align the texture width to the cache line alignment size and calculate the texture width increment after alignment;
[0072] Align the texture height to the cache line alignment size and calculate the texture height increment after alignment;
[0073] Adjust the increment of the X coordinate to the increment of the aligned texture width;
[0074] Adjust the increment of the Y coordinate to match the increment of the aligned texture height.
[0075] This invention provides a cube map texture cache allocation method based on XY coordinates and surface index optimization, applicable to textures including but not limited to odd or prime number sizes.
[0076] A cube map texture cache allocation method based on XY coordinates and surface optimization further includes the following steps:
[0077] Monitor cache usage and update cache allocation strategies regularly to adapt to different rendering needs and scene changes;
[0078] The cache management module allows for timely adjustments to cache allocation strategies, ensuring system performance stability and efficiency.
[0079] Example 1:
[0080] In the field of graphics processing, cube maps are widely used in scenarios such as environment mapping and reflection. Existing texture cache allocation methods are usually based on simple XY coordinate allocation, which does not fully consider the special structure of cube maps, leading to cache conflicts during bilinear sampling, especially in small cube maps. To solve this problem, this embodiment proposes a dual-optimized cube map texture cache allocation method based on XY coordinates and face ID.
[0081] First, the cube map is unfolded into a plane, with the top-left corner as the origin, and processed according to the VK / DirectX standard. Based on the position in the unfolded map, the XY coordinates and polygon information of each pixel are redistributed. For example, the code implementation is as follows:
[0082] int x_increment=texture_width;
[0083] int y_increment=texture_height;
[0084] / / Adjusting the cube's X coordinate
[0085] switch(face_id){
[0086] case 2:
[0087] case 3:
[0088] case 4:
[0089] X = x + x_increment;
[0090] break;
[0091] case 0:
[0092] X = x + x_increment * 2;
[0093] break;
[0094] case 5:
[0095] X = x + x_increment * 3;
[0096] break;}
[0097] / / Adjusting the Y-coordinate of the cube
[0098] switch(face_id){
[0099] case 1:
[0100] case 4:
[0101] case 0:
[0102] case 5:
[0103] Y = y + y_increment;
[0104] break;
[0105] case 3:
[0106] Y = y + y_increment * 2;
[0107] break;}
[0108] Furthermore, in the block memory layout, to optimize the algorithm and align the texture size to the cache line alignment size, x_increment and y_increment need to be modified. Assuming a cache line can hold u*v pixels, the alignment macro is defined as follows:
[0109] #defineALIGN(x,align)(((x)+(align)-1) / (align))*(align)
[0110] alignedTextureWidth=ALIGN(texture_width,u);
[0111] alignedTextureHeight=ALIGN(texture_height,v);
[0112] x_increment=alignedTextureWidth>>log2_u;
[0113] y_increment=alignedTextureHeight>>log2_v;
[0114] The dual optimization strategy implemented in the code above makes the distribution of texture data in the cache more reasonable, reducing cache conflicts caused by coordinate rotation and surface collisions. In practical applications, this method is particularly suitable for high-performance graphics rendering scenarios, such as real-time games and virtual reality environments. By prioritizing the reading of allocated texture data from the cache, texture sampling efficiency is improved, thereby significantly enhancing overall rendering performance.
[0115] See Figure 1The specific implementation scheme of this invention is as follows: 1. Unfold the cube texture into a plane as shown in the figure below (following the VK / DirectX standard), with the upper left corner as the origin. 2. Reassign the coordinates of each pixel according to its position in the unfolded image.
[0116] Furthermore, to further optimize cache utilization, cache rows are aligned to ensure efficient use of each cache row. For example, assuming a 3x3 cube texture with a 4-bank cache, each cache row can store 2x2 pixels, the X and Y coordinate increments are adjusted by adjusting the aligned texture width and height increments to match the aligned cache row dimensions. An example of the optimized cube texture cache bank distribution is shown below:
[0117] Example 1: Suppose there is a 3x3 cube texture with a block memory layout, a 4-bank cache, and each row of the cache can store 2x2 pixels.
[0118] In this case, see Figure 2 The number represents the assigned bank ID. Example diagram of unoptimized cube map texture cache bank distribution: The distribution is exactly the same on each face, the cache banks are used unevenly, which can easily cause cache conflicts.
[0119] And see also Figure 3 Example diagram of optimized cube map texture cache bank distribution: The distribution is different on each face, the cache bank is used relatively evenly, and the caching efficiency is high.
[0120] Example 2: Suppose a 2x2 cube texture, a block memory layout, a 4-bank cache, and one row of cache can store 2x2 pixels.
[0121] In this case, see Figure 4 Example diagram of unoptimized cube map texture cache bank distribution: The distribution is exactly the same on each face, the cache bank usage is severely uneven, which can easily cause cache conflicts, and only bank 1 is used.
[0122] And see also Figure 5 Example diagram of optimized cube map texture cache bank distribution: The distribution is different on each face, the cache bank is used very evenly, and the caching efficiency is high.
[0123] With this optimized allocation strategy, the distribution of each face is different, the cache bank is used more evenly, and the caching efficiency is effectively improved.
[0124] The dual optimization strategy and cache line alignment method in this embodiment solve the problems of high cache conflict rate and low sampling efficiency in the prior art. Practical application shows that after adopting this method, system performance is significantly improved, cache utilization is increased, and resource consumption is reduced, demonstrating high practical application value. This method is applicable to cube maps of various sizes, possessing versatility and flexibility, and can meet the needs of different application scenarios.
[0125] Example 2:
[0126] In the field of graphics processing, cube maps are widely used in scenarios such as environment mapping and reflection. However, existing texture buffer allocation methods do not fully consider the special structure of cube maps, leading to buffer conflicts during bilinear sampling, especially in small-sized cube maps. To address this issue, this embodiment proposes a dual-optimized cube map texture buffer allocation method based on XY coordinates and polygon scales.
[0127] First, the cube map is unfolded into a plane, with the top-left corner as the origin. Based on the position in the unfolded map, the XY coordinates and polygon information of each pixel are redistributed. For example, for polygons 2, 3, and 4, the X coordinate is increased by the texture width increment; for polygon 0, the X coordinate is increased by twice the texture width increment; and for polygon 5, the X coordinate is increased by three times the texture width increment. For polygons 1, 4, 0, and 5, the Y coordinate is increased by the texture height increment; and for polygon 3, the Y coordinate is increased by twice the texture height increment.
[0128] By employing the aforementioned dual optimization strategy, the distribution of texture data in the cache becomes more rational, reducing cache conflicts caused by coordinate rotation and surface collisions. In practical applications, this method is particularly suitable for high-performance graphics rendering scenarios, such as real-time games and virtual reality environments. In these applications, the rendering engine needs to quickly and efficiently acquire and process large amounts of texture data. Using the method in this embodiment can significantly reduce cache conflicts, improve texture sampling efficiency, and thus enhance overall rendering performance.
[0129] During implementation, texture sizes in the block memory layout can be aligned with cache lines. For example, the texture width is aligned to the cache line alignment size, and the texture width increment after alignment is calculated; the texture height is aligned to the cache line alignment size, the texture height increment after alignment is calculated, and the increments of the X and Y coordinates are adjusted to match the aligned texture width and height increments. This step further optimizes cache allocation, enabling more efficient use of hardware resources and extending the device's lifespan.
[0130] By employing the methods described above, this embodiment solves the problems of high cache conflict rate and low sampling efficiency in the prior art. Specific applications show that after adopting the method of this embodiment, system performance is significantly improved, cache utilization is increased, and resource consumption is reduced.
[0131] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the invention. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, it is intended that all variations falling within the meaning and scope of equivalents of the claims be included within the present invention.
Claims
1. A method for allocating a cube map texture cache based on XY coordinates and surface optimization, characterized in that, Includes the following steps: Step 1: Obtain cube map texture data and perform dual optimization classification based on the XY coordinates and polygon labels of the texture data; Step 2: Unfold the cube map into a plane and redistribute the coordinates of each pixel according to its position in the unfolded map; Step 3: Based on the reallocated XY coordinates and surface information, optimize the texture data cache allocation strategy to make the texture data distribution in the cache more reasonable and reduce cache conflicts and redundancy. Step 4: When performing texture sampling, prioritize reading the allocated texture data from the cache to improve rendering efficiency.
2. The cube map texture cache allocation method based on XY coordinates and surface optimization according to claim 1, characterized in that, The step of reallocating the XY coordinates includes: The X-coordinate is adjusted according to the surface coordinate, where different surface coordinates correspond to different X-coordinate adjustment rules; The Y-coordinate is adjusted based on the surface coordinate, where different surface coordinates correspond to different Y-coordinate adjustment rules.
3. The cube map texture cache allocation method based on XY coordinates and surface optimization according to claim 2, characterized in that, The adjustment rules for the X-coordinate are as follows: For coordinates 2, 3, and 4, the X coordinate is increased by the texture width increment; For cases where the surface coordinate is 0, the X coordinate is increased by twice the texture width increment; For the case where the surface coordinate is 5, the X coordinate is increased by 3 times the texture width increment.
4. The cube map texture cache allocation method based on XY coordinates and surface optimization according to claim 2, characterized in that, The adjustment rules for the Y-coordinate are as follows: For coordinates 1, 4, 0, and 5, the Y coordinate is increased by the texture height increment; For the case with a face value of 3, the Y coordinate is increased by twice the texture height increment.
5. The cube map texture cache allocation method based on XY coordinates and surface optimization according to claim 1, characterized in that, It also includes the following steps: Align the texture sizes in the block memory layout to align them with the cache lines; Adjust the increments of texture width and height according to the size of the cache line to match the size after aligning with the cache line.
6. The cube map texture cache allocation method based on XY coordinates and surface optimization according to claim 5, characterized in that, The texture size alignment method includes: Align the texture width to the cache line alignment size and calculate the texture width increment after alignment; Align the texture height to the cache line alignment size and calculate the texture height increment after alignment; Adjust the increment of the X coordinate to the increment of the aligned texture width; Adjust the increment of the Y coordinate to match the increment of the aligned texture height.
7. The cube map texture cache allocation method based on XY coordinates and surface optimization according to claim 1, characterized in that, The method is applicable to textures of odd or prime sizes, including but not limited to.
8. The cube map texture cache allocation method based on XY coordinates and surface optimization according to claim 1, characterized in that, It also includes the following steps: Monitor cache usage and update cache allocation strategies regularly to adapt to different rendering needs and scene changes; The cache management module allows for timely adjustments to cache allocation strategies, ensuring system performance stability and efficiency.
