A mipmap LOD processing method easy to implement in hardware
By calculating pixel differences in texture units and introducing an adjacent pixel update mechanism, the problem of synchronizing neighboring pixel information in multi-core architectures is solved, achieving efficient mipmap LOD processing and improving hardware performance.
Patent Information
- Application Number
- CN202211722315.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-30
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2042-12-30
AI Technical Summary
Existing multi-level asymptotic texture LOD calculation methods are difficult to synchronously acquire neighboring pixel information in multi-core architectures, leading to hardware implementation difficulties.
The texture unit calculates the difference based on the coordinates of the current and previous pixels to determine whether they are adjacent. It then updates the LOD value using adjacent pixels in the X or Y direction, introducing the XYmajor and lastHandleFlag mechanisms to ensure the accuracy of the LOD value and ease of hardware implementation.
It reduces system latency, improves pixel fill rate and hardware processing capabilities, reduces synchronization and storage workload, and is easy to implement in hardware.
Smart Images

Figure CN115880411B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image rendering technology, and in particular to a mipmap LOD processing method that is easy to implement in hardware. Background Technology
[0002] The current mainstream LOD calculation method for multi-level mipmaps requires simultaneously obtaining the texture coordinates (u, v) of neighboring pixels in both the X and Y directions and calculating the maximum distance L between the pixel and its neighboring pixels in the texture coordinates. This allows the determination of the LOD value for each pixel. Figure 1 D in the middle.
[0003] This algorithm requires simultaneously acquiring the texture coordinates (U, V) of the right and top neighboring pixels each time. In the current multi-core architecture of MVP (Model-View-Presenter), one texture unit corresponds to multiple stream processors (SPs). With multiple SPs processing simultaneously, the texture unit only receives the texture coordinate information of the pixel processed by one stream processor at a time, making it impossible to simultaneously acquire information from neighboring pixels. Furthermore, the pixels received by the texture unit are random, not necessarily consecutive pixels in the x or y direction. This is because the GPU in the current MVP architecture has multiple stream processors that process pixel data in parallel, and the arrival time of each pixel at the texture unit is random. Simultaneously acquiring the texture coordinates (U, V) of the right and top neighboring pixels in hardware is very difficult. Solving the problem of synchronously delivering neighboring pixel information to the texture unit and storing this information is challenging for hardware implementation. Summary of the Invention
[0004] This invention provides a mipmap LOD processing method that is easy to implement in hardware, aiming to solve the problems existing in the mainstream LOD calculation methods of existing multi-level asymptotic textures.
[0005] This invention provides a mipmap LOD processing method that is easy to implement in hardware, comprising the following steps:
[0006] S1. The texture unit calculates the difference between the currently received pixel coordinate information (X,Y;U,V) and the previous pixel coordinate information (X,Y;U,V) to obtain dx, dy, du, and dv;
[0007] S2. Determine whether the current pixel is adjacent to the previous pixel at screen coordinates X or Y. If they are not adjacent, proceed to step S4. If they are adjacent, calculate the LOD value D_level of the current pixel and proceed to step S3.
[0008] S3. When the calculated LOD value of consecutive pixels in another direction is less than or equal to the previous calculated value, the LOD value is updated with the adjacent pixels in the current direction, and step S4 is executed; when the calculated LOD value of consecutive pixels in another direction is greater than the previous calculated value, the LOD value is adjusted to update the LOD value with the adjacent pixels in the other direction, and step S4 is executed.
[0009] S4. Update the final LOD value to the reference value Ref, and update the (X,Y;U,V) coordinate information of the current pixel to the coordinate information of the previous pixel. Output the LOD value and end the calculation for this pixel.
[0010] As a further improvement of the present invention, in step S2, if the current pixel is adjacent to the previous pixel at screen coordinate X, after calculating the LOD value D_level of the current pixel, step S3 includes the following steps:
[0011] a1. If XYmajor == 0, then update the LOD value using the adjacent pixels of X, directly update the reference LOD value Ref to D_level, set lastHandleFlag to 1, and execute step S4; otherwise, execute step a2.
[0012] a2. If lastHandleFlag is 2 and D_level>ref, then the LOD value calculated using the X neighboring pixels is greater than the LOD value calculated using the Y neighboring pixels in the previous iteration. Update the subsequent LOD value using the LOD value of the X neighboring pixels and execute step a3; otherwise, directly execute step S4.
[0013] a3. Flip the XY major indicator as follows:
[0014] XYmajor=0
[0015] Ref = D_level
[0016] lastHandleFlag = 1
[0017] After setting, proceed to step S4.
[0018] As a further improvement of the present invention, in step S2, if the current pixel is adjacent to the previous pixel at screen coordinate Y, after calculating the LOD value D_level of the current pixel, step S3 includes the following steps:
[0019] b1. If XYmajor == 1, then update the LOD value using the adjacent pixels of Y, directly update the reference LOD value Ref to D_level, set lastHandleFlag to 2, and execute step S4; otherwise, execute step b2.
[0020] b2. If lastHandleFlag is 1 and D_level>ref, then the LOD value calculated using the Y neighboring pixels is greater than the LOD value calculated using the X neighboring pixels in the previous iteration. Update the subsequent LOD value using the LOD of the Y neighboring pixels and execute step b3; otherwise, directly execute step S4.
[0021] b3. Flip the XY major indicator as follows:
[0022] XYmajor=1
[0023] Ref = D_level
[0024] lastHandleFlag = 1
[0025] After setting, proceed to step S4.
[0026] As a further improvement of the present invention, in step S2, the LOD value D_level of the current pixel is calculated, and the calculation process is as follows:
[0027] UVnorm=pow(pow(du,2)+pow(dv,2),0.5)
[0028] XYnorm=pow(pow(dx,2)+pow(dy,2),0.5)
[0029] L = UVnorm / XYnorm
[0030] if (L == 0): D_level = 0
[0031] else: D_leve = log2(L).
[0032] As a further improvement of the present invention, before performing step S1, step S0 is also performed:
[0033] If the current pixel is the first pixel processed by the texture unit, the LOD reference value Ref is set to 0, and step S4 is executed; if the current pixel is not the first pixel, step S1 is executed.
[0034] As a further improvement of the present invention, in step S4, the updated pixel coordinate information is fed back to step S1 as the previous pixel coordinate information for the next iteration.
[0035] The beneficial effects of this invention are: This processing method allows the texture unit to process each pixel in a pipeline, without waiting for neighboring pixels to complete SP processing and for relevant information to arrive at the texture unit before calculating the LOD value of that pixel. In large-scale parallel computing graphics rendering pipeline chips such as GPUs, this reduces the overall system latency, improves the pixel fill rate, and significantly enhances hardware processing capabilities. Compared with traditional calculation methods, it reduces the time synchronization of X and Y neighboring pixel processing to the texture unit and the workload of storing multiple pixel information, thus reducing the hardware burden and making it easier to implement in hardware. Attached Figure Description
[0036] Figure 1 This is a schematic diagram illustrating the calculation of the LOD value of each pixel in the prior art of this invention;
[0037] Figure 2 This is a structural diagram of the texture unit in this invention;
[0038] Figure 3 This is a flowchart of the mipmap LOD processing method that is easy to implement in hardware in this invention. Detailed Implementation
[0039] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments.
[0040] like Figure 2 The diagram shows the structure of the Texture unit in the current architecture. The upper level of the Texture is the Fragment Shader (FS shader), which consists of multiple SP stream processors. These stream processors process pixel information in parallel, and after processing, send the pixel information to the Texture unit for calculating the Level of Depth (LOD) of each pixel. The Texture unit randomly receives information from a pixel after SP processing each time to calculate the LOD.
[0041] Since mipmaps primarily address scenarios where pixels are mapped to square regions in texture space, the distance difference between adjacent pixels in the X and Y directions is not significant. We can initially assume that the LOD calculated using consecutive pixels in one X or Y direction is used. For non-consecutive pixels, the LOD calculated from the previous consecutive pixel count can be reused. Simultaneously, a correction mechanism is introduced in the X and Y directions. If the LOD calculated for consecutive pixels in the other direction is greater than the previous calculated value, the LOD value is considered to need to be adjusted. Based on this strategy, we can ensure that the LOD of each pixel is close to the LOD value calculated using traditional methods, with an average absolute error of less than 0.1 per pixel.
[0042] like Figure 3 As shown, the specific calculation method is as follows:
[0043] Step 1: If the current pixel is the first pixel processed by the texture unit, since there is no information about the previous pixel, set the LOD reference value Ref to 0 and execute step 11; if it is not the first pixel, execute step 2.
[0044] Step 2: Based on the coordinates of the current pixel and the previous pixel, calculate dx, dy, du, and dv:
[0045] dx = Pixel_X - PrePixel_X
[0046] dy = Pixel_Y - PrePixel_Y
[0047] du = Pixel_U - PrePixel_U
[0048] dv = Pixel_V - PrePixel_V.
[0049] Step 3: Determine if the current pixel and the previous pixel are adjacent at screen coordinate X, using the following formula:
[0050] dx==1&&dy==0
[0051] If they are not adjacent, proceed to step 7; otherwise, calculate the LOD value D_level of the current pixel using the following formula:
[0052] UVnorm=pow(pow(du,2)+pow(dv,2),0.5)
[0053] XYnorm=pow(pow(dx,2)+pow(dy,2),0.5)
[0054] L = UVnorm / XYnorm
[0055] if (L == 0): D_level = 0
[0056] else: D_leve = log2(L)
[0057] After the calculation is complete, proceed to Step 4. In the formula, pow represents calculating x to the power of y, and pow(x,0.5) represents calculating x to the power of 0.5, which is to calculate the square root of x.
[0058] Step 4: If XYmajor == 0, it means that the LOD should be updated using the adjacent pixels of X. Directly update the reference LOD value Ref to D_level, set lastHandleFlag to 1, and execute step 11; otherwise, execute step 5.
[0059] Step 5: If lastHandleFlag is 2 and D_level>ref, it means that the LOD value calculated using the X neighboring pixels is greater than the LOD value calculated using the Y neighboring pixels in the previous iteration. The subsequent LOD value should be updated using the LOD of the X neighboring pixels, and step 6 should be executed; otherwise, step 11 should be executed directly.
[0060] Step 6: Flip the XY major indicator with the following settings, then proceed to step 11.
[0061] XYmajor=0
[0062] Ref = D_level
[0063] lastHandleFlag = 1
[0064] Step 7: Determine if the current pixel and the previous pixel are adjacent at screen coordinate Y, using the following formula:
[0065] dx==0&&dy==1
[0066] If the pixels are not closely spaced, proceed to step 11; otherwise, calculate the LOD value D_level of the current pixel according to the formula in Step 3, and proceed to step 8.
[0067] Step 8: If XYmajor == 1, it means that the LOD value should be updated using the adjacent pixels of Y. Directly update the reference LOD value Ref to D_level, set lastHandleFlag to 2, and execute step 11; otherwise, execute step 9.
[0068] Step 9: If lastHandleFlag is 1 and D_level>ref, it means that the LOD value calculated using the Y neighboring pixels is greater than the LOD calculated using the X neighboring pixels in the previous iteration. The subsequent LOD value should be updated using the LOD of the Y neighboring pixels, and step 10 should be executed; otherwise, step 11 should be executed directly.
[0069] Step 10: Flip the XY major indicator with the following settings, then proceed to step 11.
[0070] XYmajor=1
[0071] Ref = D_level
[0072] lastHandleFlag = 1
[0073] Step 11: Update the final LOD value to the reference value Ref, and update the (X,Y) and (U,V) values of the current pixel to the value of prePixel for the next iteration. Output the LOD value and end the calculation for this pixel.
[0074] LOD = Ref
[0075] PrePixel_X = Pixel_X
[0076] prePixel_Y = Pixel_Y
[0077] PrePixel_U = Pixel_U
[0078] PrePixel_V = Pixel_V.
[0079] In the above steps, XYmajor indicates whether to use X or Y adjacent points for calculation and update. XYmajor=0 means to use X adjacent pixels for update, and XYmajor=1 means to use Y adjacent points for calculation and update.
[0080] The lastHandleFlag indicates whether the latest LOD value update used X-adjacent points or Y-adjacent points. The initial value of 0 indicates that the LOD was not calculated and updated using X-adjacent and Y-adjacent points, 1 indicates that the latest update was performed using X-adjacent points, and 2 indicates that the latest update was performed using Y-adjacent points.
[0081] The purpose of introducing `lastHandleFlag` is to limit a scenario where, when the system first starts running, it immediately updates the LOD (Level of Detail) in the other direction, resulting in a LOD that is definitely greater than the initial value `ref = 0`. For example, if `XYmajor = 0` is specified, but the system immediately obtains two adjacent Y points, calculates an LOD > 0, and updates directly. To ensure that the system first calculates and updates adjacent X points instead of immediately using adjacent Y points, `lastHandleFlag` is used as a constraint; that is, when `lastHandleFlag = 1`, it then compares with adjacent Y points.
[0082] The above description, in conjunction with specific preferred embodiments, provides a further detailed explanation of the present invention. It should not be construed that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art, various simple deductions or substitutions can be made without departing from the concept of the present invention, and all such modifications and substitutions should be considered within the scope of protection of the present invention.
Claims
1. A mipmap LOD processing method that is easy to implement in hardware, characterized in that, Includes the following steps: S1. The texture unit calculates the difference between the currently received pixel coordinate information (X,Y; U,V) and the previous pixel coordinate information (X,Y; U,V) to obtain dx, dy, du, and dv; S2. Determine whether the current pixel is adjacent to the previous pixel at screen coordinates X or Y. If they are not adjacent, proceed to step S4. If they are adjacent, calculate the LOD value D_level of the current pixel and proceed to step S3. S3. When the calculated LOD value of consecutive pixels in another direction is less than or equal to the previous calculated value, the LOD value is updated with the adjacent pixels in the current direction, and step S4 is executed; when the calculated LOD value of consecutive pixels in another direction is greater than the previous calculated value, the LOD value is adjusted to update the LOD value with the adjacent pixels in the other direction, and step S4 is executed. S4. Update the final LOD value to the reference value Ref, and update the (X,Y;U,V) coordinate information of the current pixel to the coordinate information of the previous pixel. Output the LOD value and end the calculation for this pixel.
2. The mipmap LOD processing method that is easy to implement in hardware according to claim 1, characterized in that, In step S2, if the current pixel is adjacent to the previous pixel at screen coordinate X, after calculating the LOD value D_level of the current pixel, step S3 includes the following steps: a1. If XYmajor == 0, then update the LOD value using the adjacent pixels of X, directly update the reference LOD value Ref to D_level, set lastHandleFlag to 1, and execute step S4; otherwise, execute step a2. a2. If lastHandleFlag is 2 and D_level>ref, then the LOD value calculated using the X neighboring pixels is greater than the LOD value calculated using the Y neighboring pixels in the previous iteration. Update the subsequent LOD value using the LOD value of the X neighboring pixels and execute step a3; otherwise, directly execute step S4. a3. Flip the XY major indicator as follows: XYmajor=0 Ref = D_level lastHandleFlag = 1 After setting, proceed to step S4.
3. The mipmap LOD processing method that is easy to implement in hardware according to claim 1, characterized in that, In step S2, if the current pixel is adjacent to the previous pixel at screen coordinate Y, after calculating the LOD value D_level of the current pixel, step S3 includes the following steps: b1. If XYmajor == 1, then update the LOD value using the adjacent pixels of Y, directly update the reference LOD value Ref to D_level, set lastHandleFlag to 2, and execute step S4; otherwise, execute step b2. b2. If lastHandleFlag is 1 and D_level>ref, then the LOD value calculated using the Y neighboring pixels is greater than the LOD value calculated using the X neighboring pixels in the previous iteration. Update the subsequent LOD value using the LOD of the Y neighboring pixels and execute step b3; otherwise, directly execute step S4. b3. Flip the XY major indicator as follows: XYmajor=1 Ref = D_level lastHandleFlag = 1 After setting, proceed to step S4.
4. The mipmap LOD processing method that is easy to implement in hardware according to claim 1, characterized in that, In step S2, the LOD value D_level of the current pixel is calculated, and the calculation process is as follows: UVnorm=pow(pow(du,2)+pow(dv,2),0.5) XYnorm=pow(pow(dx,2)+pow(dy,2),0.5) L = UVnorm / XYnorm if (L == 0): D_level = 0 else: D_leve = log2(L).
5. The mipmap LOD processing method that is easy to implement in hardware according to claim 1, characterized in that, Before executing step S1, step S0 is also executed: If the current pixel is the first pixel processed by the texture unit, the LOD reference value Ref is set to 0, and step S4 is executed; if the current pixel is not the first pixel, step S1 is executed.
6. The mipmap LOD processing method that is easy to implement in hardware according to claim 1, characterized in that, In step S4, the updated pixel coordinate information is fed back to step S1 as the previous pixel coordinate information for the next iteration.
Citation Information
Patent Citations
Graphics processing employing cube map texturing
CN108230435A
Approximation of level of detail calculation in cubic mapping without attribute delta function
CN1624722A